Hi to all …
have someone some example of usign java.nio.buffer for this opengl calls?
gl.glVertexPointer(int p1, gl.GL_FLOAT, 0, Buffer);
gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, Buffer);
how do i can fills the buffers?
and … when i must do it?
Hi to all …
have someone some example of usign java.nio.buffer for this opengl calls?
gl.glVertexPointer(int p1, gl.GL_FLOAT, 0, Buffer);
gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, Buffer);
how do i can fills the buffers?
and … when i must do it?
allocate a direct, native ordered {Byte, Float, Int}Buffer per data set using net.java.games.jogl.util.BufferUtils
fill each buffer with data (using put(int[]) for example)
enable GL states with glEnableClientState(GL_VERTEX_ARRAY) and glEnableClientState(GL_TEXTURE_COORD_ARRAY)
bind buffers :
glVertexPointer(3, GL_INT, 0, vertices);
glColorPointer(3, GL_FLOAT, 0, colors);
draw with glDrawArrays (draw everything) or glDrawElements (draw only a subset)
Some comments :
even though you can use a single buffer to store all your vertex, texture coord, color and normal data, it is IMO easier to keep them in separate buffers
usually you’ll only need to enable vertex array states once, in the init method
when you bind a buffer, data can be copied but it is not a requirement ; therefore when you modify your buffer you must rebind it