Fixed, problem was that I forget the "bb.order(ByteOrder.nativeOrder())" so that the memory was in the correct format.
On Aug 4, 5:40 pm, HaMMeReD <[email protected]> wrote: > Been getting a headache with some 2d Opengl coordinates and putting > them in a direct buffer. > > I have a basic square defined as such > > static float[] Coords = new float[] { > -0.5f,-0.5f, > 0.5f,-0.5f, > 0.5f,0.5f, > -0.5f,0.5f, > }; > static FloatBuffer VertexBuffer; > > This Works, but no guarantee of direct buffer, exception thrown when > indirect buffer is used > static { > VertexBuffer = FloatBuffer.wrap(Coords); > } > > This runs, no segfault or anything, and when I iterate through the > buffer the size and values seem exactly the same (8 elements, ordered > just as the array). What happens though is that my draw() function > draws nothing, it works one way, but doesn't work the other way. I use > Direct Buffers in a lot of my other geometry. I have to get direct > buffers working or I know that my software might not be reliable. > > static { > ByteBuffer bb = > ByteBuffer.allocateDirect(Coords.length*(Float.SIZE/ > Byte.SIZE)); > VertexBuffer = bb.asFloatBuffer(); > for (int i=0; i< Coords.length; i++) { > VertexBuffer.put(i, Coords[i]); > } > } > > My Drawing function is as follows, if it helps. > > public void draw (GL10 gl) { > gl.glPushMatrix(); > gl.glTranslatef(x,y,0); > gl.glScalef(width,height,0); > gl.glEnable(GL10.GL_VERTEX_ARRAY); > gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); > gl.glTexCoordPointer(2,GL10.GL_FLOAT,0, MapBuffer); > gl.glFrontFace(GL10.GL_CW); > gl.glVertexPointer(2,GL10.GL_FLOAT, 0, VertexBuffer); > gl.glBindTexture(GL10.GL_TEXTURE_2D, Textures[0]); > gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4); > gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); > gl.glDisable(GL10.GL_VERTEX_ARRAY); > gl.glDisable(GL10.GL_COLOR_ARRAY); > gl.glPopMatrix(); > } -- 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

