Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: in galaxy tab 2, draw line with 2 points work but with 1 point not

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    25

    in galaxy tab 2, draw line with 2 points work but with 1 point not

    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:

    Code :
    #define LRP_VERTEX_CODE \
          "attribute vec4 a_Position;" \
          "uniform mat4 projectionMatrix;" \
          "void main() {gl_Position = a_Position*projectionMatrix;}"
     
    #define LRP_FRAGMENT_CODE \
          "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);
       setCurrentProgram(lrpProgram);
       lrpColor = glGetUniformLocation(lrpProgram, "a_Color");
       lrpPosition = glGetAttribLocation(lrpProgram, "a_Position"); // get
    handle to vertex shader's vPosition member
       glEnableVertexAttribArray(lrpPosition);
    }
     
    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;
     
       setCurrentProgram(lrpProgram);
       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
    (4.0.4).

    thanks

    guich

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    25
    Is there any kind of parameter that would make opengl es 2 clip a single pixel?

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    25
    Found the problem! Have to set the gl_PointSize to 1.0.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •