Re: My Application crashed
Posted by
Pixelapp on
Jul 28, 2012; 3:09am
URL: https://forum.jogamp.org/My-Application-crashed-tp4025350p4025682.html
How am I supposed to use new vertices if I can only call .put(myVertices) only once.
This is what I do in my display() loop.
BEGINING OF CODE.
public void init(GLAutoDrawable drawable)
{
vbbElements = ByteBuffer
.allocateDirect(myVertices.length * 4);
vbbElements.order(ByteOrder.nativeOrder());
mVertexBufferElements = vbbElements.asFloatBuffer();
}
public void display()
{
mVertexBufferElements.put(myVertices);
mVertexBufferElements.position(0);
}
END OF CODE.
Is this a safe operation? If not, how do I update the myVertices variable once it is passed as an argument?
Moreover, it is my understanding that FloatBuffers are allocated outside the Java Heap when I use "ByteBuffer
.allocateDirect(" which makes them resistant to Garbage Collector's removal.
Please look at how Google does it here:
http://developer.android.com/training/graphics/opengl/shapes.html. This approach I think makes it impossible to have new vertex values or indices or normal values, since the geometrical shapes would be defined once and once only on the constructor.
Also, how do you jogampers do it? You don't seem to have any trouble with your graphics code!
Any suggestions?