Reputation: 2854
I want to draw a model with LWJGL
and I know that on calling each glVertex
method, a JNI
call occurs, that is time consuming. Since I have the model in a file, I want to use just one JNI
call (add a native method to LWJGL
library), and at the native side, get my model vertices from the file (using c language) and draw them all (avoiding a JNI
call per vertex).
So, I want to change LWJGL
library source and add a function to do this.
my question is, does this feature available in LWJGL
, JOGL
or in any possible java bindings for openGL
?
Upvotes: 1
Views: 562
Reputation: 13877
Use Vertex Buffer Objects to store your vertex data, and make calls to draw as many vertices/triangles is practical with just one call to glDrawArrays, glDrawElements or similar.
This page explains how to use them in LWJGL.
Note that the LWJGL version of the OpenGL docs is rather lacking. Check the OpenGL official site for the C versions which explain their functionality very well.
Upvotes: 3
Reputation:
you could use the OpenGL glVertexPointer function which in LWJGL is wrapped by glVertexPointer (link).
BUT!
if you are worried about the speed of a mere JNI call, then why not reconsider doing this in c/c++ instead?
Later Edit: documentation for glVertexPointer
Upvotes: 1