Hello,
Does JOGL have a native Vertex DataType class already? (I didn’t want to use another package or make my own). Also does someone have a camera movement example using the mouse in JOGL already mocked up?
Thanks in advance,
Coop
Hello,
Does JOGL have a native Vertex DataType class already? (I didn’t want to use another package or make my own). Also does someone have a camera movement example using the mouse in JOGL already mocked up?
Thanks in advance,
Coop
Your native vertex type is most likely going to be a FloatBuffer that was made using “allocateDirect”.
This way the memory is directly accessible to the C-side libs, therefore no copying (or minimum possible) will occur.
See other forums here and the JOGL demos for example usage.
For camera, again I recommend checking out the JOGL demos to start, specifically the Gears demo. Beyond that most any OpenGL tutorials are all you need. (Until later that is… ;-))
[quote]Your native vertex type is most likely going to be a FloatBuffer that was made using “allocateDirect”.
[/quote]
I tried this way:
FloatBuffer v = ByteBuffer.allocateDirect( 3*4 ).asFloatBuffer( );
v.put( -5 ).put( -9 ).put( -9 );
gl.glVertex3fv( v.array( ) );
but receive an java.lang.UnsupportedOperationException calling that array() method.
Could you give me a clue, please?
melvyn
i dont really know anything about vertex buffers. can someone just tell me what they are… like how are they different/better than just using lists of triangles. thats what im doing with my current scene graph.
about a camera. i suggest using a vector to represent the camera position and a quaternion to represent its rotation. i suggest that you read up on Quaternion math if youre unfamiliar with it… i believe there is a quat class in the javax.vecmath package, but im using my own. if you want i can paste my current Camera and Quaternion implementation in my scene graph for a physics engine. as for interpreting mouse events for rotation, there is a decent example in the Gears demo. once you understand quaternion rotations its really quite simple to implement. hope this helps.
–eric
Yeah I’m still learning about quaternions, and example code would be great!
Thanks,
Coop
to melvyn,
I would same just use a regular float[] for starters, special for the glVertex3fv( ) type calls.
You only need to use the FloatBuffers once you start using VertexArray type rendering.
Sounds like you are have a bit of OpenGL API fun. I would suggest checking out the NeHe tutorials as well as a good OpenGL book to get you started with JOGL.
Sorry, it seems that my question was not accurate enough. My example really is not very useful indeed.
What I wanted to know was why FloatBuffer.toarray( ) throws that exception (although we dont need it since the relevant vertex array methods get a java.nio.Buffer).
array() is an optional method. I’m not sure you’ll get much of a better answer than what the javadocs say: