overnhet
Junior Devvie  
Java games rock!
|
 |
«
Reply #1 - Posted
2004-03-23 06:51:15 » |
|
1) allocate a direct, native ordered {Byte, Float, Int}Buffer per data set using net.java.games.jogl.util.BufferUtils
2) fill each buffer with data (using put(int[]) for example)
3) enable GL states with glEnableClientState(GL_VERTEX_ARRAY) and glEnableClientState(GL_TEXTURE_COORD_ARRAY)
4) bind buffers : glVertexPointer(3, GL_INT, 0, vertices); glColorPointer(3, GL_FLOAT, 0, colors);
5) 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
|