View Full Version : in galaxy tab 2, draw line with 2 points work but with 1 point not

10-16-2012, 11:52 AM
I'm now getting a strange problem. I have a gl2 program that draws a
point. It works in the sony xperia S (android 2.3.7) but not in the samsung galaxy tab 2. This is the code:

"attribute vec4 a_Position;" \
"uniform mat4 projectionMatrix;" \
"void main() {gl_Position = a_Position*projectionMatrix;}"

"precision mediump float;" \
"uniform vec4 a_Color;" \
"void main() {gl_FragColor = a_Color;}"

static GLuint lrpProgram;
static GLuint lrpPosition;
static GLuint lrpColor;

void initLineRectPoint()
lrpProgram = createProgram(LRP_VERTEX_CODE, LRP_FRAGMENT_CODE);
lrpColor = glGetUniformLocation(lrpProgram, "a_Color");
lrpPosition = glGetAttribLocation(lrpProgram, "a_Position"); // get
handle to vertex shader's vPosition member

void glDrawLine(int32 x1, int32 y1, int32 x2, int32 y2, int32 rgb)
GLfloat* coords = glcoords;
PixelConv pc;
pc.pixel = rgb;
coords[0] = x1;
coords[1] = y1;
coords[3] = x2;
coords[4] = y2;
coords[2] = coords[5] = 0;

glUniform4f(lrpColor, f255[pc.r], f255[pc.g], f255[pc.b], 1); // Set color for drawing the line
glVertexAttribPointer(lrpPosition, COORDS_PER_VERTEX, GL_FLOAT, GL_FALSE, COORDS_PER_VERTEX * sizeof(float), coords); // Prepare the triangle coordinate data
glDrawArrays(GL_LINES, 0,2);

Some notes:
1. glcoords is a GLfloat array
2. f255 is a lookup array for x/255f
3. setCurrentProgram just calls glUseProgram
4. coords[2], [5], etc is always 0.

I already checked the output for each function call in the functions
above but none return errors.

If i call drawLine(10,10,10,10,0xFFFFFF), i don't see anything; if i call drawLine(10,20,11,20,0xFFFFFF), i see a line with 2 dots.

Again, the code works fine on xperia (2.3.7 - i see the dot) but not on galaxy tab 2



10-16-2012, 12:52 PM
Is there any kind of parameter that would make opengl es 2 clip a single pixel?

10-16-2012, 01:08 PM
Found the problem! Have to set the gl_PointSize to 1.0.

"attribute vec4 a_Position;" \
"uniform mat4 projectionMatrix;" \
"void main() {gl_PointSize = 1.0; gl_Position = a_Position*projectionMatrix;}"