The first obviously wrong thing is creating new objects in onDrawFrame. AFAIK buffers passed to glVertexPointer and glTexCoordPointer have to be direct buffers. Take a look at APIDemos. Allocation code should look similar to this
bb = ByteBuffer.allocateDirect(); bb.order(ByteOrder.nativeOrder()); mVertexBuffer = bb.asFloatBuffer(); On 31 дек 2010, 02:19, bob <[email protected]> wrote: > I'm having trouble getting my Android opengl app to display a quad. Is > there anything obviously wrong with this code? > > public void onDrawFrame(GL10 gl) { > gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); > gl.glMatrixMode(GL10.GL_MODELVIEW); > gl.glLoadIdentity(); > > float[] myverts = new float[] > { > -.77f, .58f, > .77f, .58f, > .77f, -.58f, > -.77f, -.58f > > }; > > FloatBuffer[] fb = new FloatBuffer[1]; > fb[0] = FloatBuffer.wrap(myverts); > > float[] mytex = new float[] > { > 0, 0, > 1, 0, > 1, 1, > 0, 1 > > }; > > FloatBuffer[] tfb = new FloatBuffer[1]; > tfb[0] = FloatBuffer.wrap(myverts); > > gl.glTranslatef(0, 0, -5); > > gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesBuffer.get(0)); > gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); > gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); > > gl.glVertexPointer(2, GL10.GL_FLOAT, 0, fb[0]); > gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, tfb[0]); > > gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4); > > gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); > gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); > > > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

