[android-developers] Re: Vertex Array/Vertex Buffer Objects driver bug on Droid
Doesn't the spec say it has to be 4? From http://www.khronos.org/opengles/sdk/1.1/docs/man/glColorPointer.xml : size Specifies the number of components per color. Must be 4. The initial value is 4. From http://java.sun.com/javame/reference/apis/jsr239/javax/microedition/khronos/opengles/GL10.html#glColorPointer%28int,%20int,%20int,%20java.nio.Buffer%29 : size specifies the number of components per color, and must be 4. On Mar 14, 12:47 pm, Mario Zechner badlogicga...@gmail.com wrote: Hi, just wanted to drop by to tell you about a nice little bug i just encountered on my droid. Here's some sample code: @Override public void render(Application app) { GL11 gl = app.getGraphics().getGL11(); gl.glViewport( 0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight() ); gl.glClearColor( 0.7f, 0.7f, 0.7f, 1 ); gl.glClear( GL11.GL_COLOR_BUFFER_BIT ); gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, vboHandle ); gl.glEnableClientState( GL11.GL_VERTEX_ARRAY ); gl.glEnableClientState( GL11.GL_COLOR_ARRAY ); gl.glVertexPointer( 3, GL11.GL_FLOAT, 6 * 4, 0 ); gl.glColorPointer( 3, GL11.GL_FLOAT, 6 * 4, 3 * 4 ); gl.glDrawArrays( GL11.GL_TRIANGLES, 0, 3 ); } @Override public void setup(Application app) { ByteBuffer buffer = ByteBuffer.allocateDirect( 3 * 6 * 4 ); buffer.order(ByteOrder.nativeOrder()); FloatBuffer vertices = buffer.asFloatBuffer(); vertices.put( new float[] { -0.5f, -0.5f, 0, 1, 0, 0, 0.5f, -0.5f, 0, 0, 1, 0, 0.0f, 0.5f, 0, 0, 0, 1, }); vertices.flip(); GL11 gl = app.getGraphics().getGL11(); int[] handle = new int[1]; gl.glGenBuffers( 1, handle, 0 ); vboHandle = handle[0]; gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, vboHandle ); gl.glBufferData( GL11.GL_ARRAY_BUFFER, 3 * 6 * 4, vertices, GL11.GL_STATIC_DRAW ); gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, 0 ); } In the setup method i create a FloatBuffer holding three vertices, each having 3 coordinates (x,y,z) and 3 color components (r,g,b). Next i generate a vertex buffer object to store the vertex data in. As you can see the vertex data is interleaved, so everything goes into a single VBO. In the render method i set the viewport and clear the screen first. Next i bind the VBO and set the vertex and color pointer to start at the correct positions in the interleaved vertex data in the VBO. This code works perfectly fine on the desktop. On my Droid it crashes horribly in glDrawArrays with a segfault. I triple-checked everything i did with the OpenGL ES specs and i came to the conclusion that i'm not doing anything wrong (also, as i said it works on the desktop). By accident i changed the number of color components from 3 to 4 (r,g,b,a) and finally it worked. This seems like a bug in the Motorola Droid PowerVR drivers. Can anyone confirm this? -- 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
[android-developers] Re: Vertex Array/Vertex Buffer Objects driver bug on Droid
Yes, indeed. I mixed that up with the desktop GL specs at http://www.opengl.org/sdk/docs/man/xhtml/glColorPointer.xml. Now that's embarassing :) On 14 Mrz., 19:07, Lance Nanek lna...@gmail.com wrote: Doesn't the spec say it has to be 4? Fromhttp://www.khronos.org/opengles/sdk/1.1/docs/man/glColorPointer.xml : size Specifies the number of components per color. Must be 4. The initial value is 4. Fromhttp://java.sun.com/javame/reference/apis/jsr239/javax/microedition/k... : size specifies the number of components per color, and must be 4. On Mar 14, 12:47 pm, Mario Zechner badlogicga...@gmail.com wrote: Hi, just wanted to drop by to tell you about a nice little bug i just encountered on my droid. Here's some sample code: @Override public void render(Application app) { GL11 gl = app.getGraphics().getGL11(); gl.glViewport( 0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight() ); gl.glClearColor( 0.7f, 0.7f, 0.7f, 1 ); gl.glClear( GL11.GL_COLOR_BUFFER_BIT ); gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, vboHandle ); gl.glEnableClientState( GL11.GL_VERTEX_ARRAY ); gl.glEnableClientState( GL11.GL_COLOR_ARRAY ); gl.glVertexPointer( 3, GL11.GL_FLOAT, 6 * 4, 0 ); gl.glColorPointer( 3, GL11.GL_FLOAT, 6 * 4, 3 * 4 ); gl.glDrawArrays( GL11.GL_TRIANGLES, 0, 3 ); } @Override public void setup(Application app) { ByteBuffer buffer = ByteBuffer.allocateDirect( 3 * 6 * 4 ); buffer.order(ByteOrder.nativeOrder()); FloatBuffer vertices = buffer.asFloatBuffer(); vertices.put( new float[] { -0.5f, -0.5f, 0, 1, 0, 0, 0.5f, -0.5f, 0, 0, 1, 0, 0.0f, 0.5f, 0, 0, 0, 1, }); vertices.flip(); GL11 gl = app.getGraphics().getGL11(); int[] handle = new int[1]; gl.glGenBuffers( 1, handle, 0 ); vboHandle = handle[0]; gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, vboHandle ); gl.glBufferData( GL11.GL_ARRAY_BUFFER, 3 * 6 * 4, vertices, GL11.GL_STATIC_DRAW ); gl.glBindBuffer( GL11.GL_ARRAY_BUFFER, 0 ); } In the setup method i create a FloatBuffer holding three vertices, each having 3 coordinates (x,y,z) and 3 color components (r,g,b). Next i generate a vertex buffer object to store the vertex data in. As you can see the vertex data is interleaved, so everything goes into a single VBO. In the render method i set the viewport and clear the screen first. Next i bind the VBO and set the vertex and color pointer to start at the correct positions in the interleaved vertex data in the VBO. This code works perfectly fine on the desktop. On my Droid it crashes horribly in glDrawArrays with a segfault. I triple-checked everything i did with the OpenGL ES specs and i came to the conclusion that i'm not doing anything wrong (also, as i said it works on the desktop). By accident i changed the number of color components from 3 to 4 (r,g,b,a) and finally it worked. This seems like a bug in the Motorola Droid PowerVR drivers. Can anyone confirm this? -- 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