Hello,

I'm trying to display a simple triangle on my Samsung Spica.
I'm using the following data:

float triangle_vertices[] = {
                     0.0f,  0.8f,
                    -0.8f, -0.8f,
                     0.8f, -0.8f
                  };

vertex shader:
attribute vec2 vPosition;
void main(void)
{
  gl_Position = vec4(vPosition, 0.0, 1.0);
}

fragment shader:
void main()
{
            gl_FragColor[0] = gl_FragCoord.x/640.0;
            gl_FragColor[1] = gl_FragCoord.y/480.0;
            gl_FragColor[2] = 0.5;
}

If I display it without VBO, it will show on the screen:
      GLES20.glVertexAttribPointer(
                agrPositionHandle, // attribute
                2,                 // number of elements per vertex
                GLES20.GL_FLOAT,          // the type of each element
                false,          // take our values as-is
                2*Float.SIZE/8,                 // vertices
                //0,                 // no extra data between each position
                triangleVB  // FloatBuffer
              );
        GLES20.glEnableVertexAttribArray(agrPositionHandle);
Utils.displayGLErrorCode(TAG, "onDrawFrame:glEnableVertexAttribArray");
        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
        Utils.displayGLErrorCode(TAG, "onDrawFrame:glDrawArrays");

To use the VBO, I needed to implement the GLES20Fix from this post:
http://stackoverflow.com/questions/8552365/vertex-buffer-objects-vbo-not-working-on-android-2-3-3-using-gles20

Then I replaced the call to GLES20.glVertexAttribPointer() with:
        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, agrVboTriangle.get(0));
        GLES20Fix.glVertexAttribPointer(
                agrPositionHandle, // attribute
               2,                 // number of elements per vertex
                GLES20.GL_FLOAT,          // the type of each element
                false,          // take our values as-is
                2*Float.SIZE/8,                 // vertices
                0  // offset
              );
        Utils.displayGLErrorCode(TAG, "onDrawFrame:glVertexAttribPointer");

But in that case, the screen remains blank. And I saw no OpenGL error.

Any hints would be appreciated.

-
Fabien


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to