Login  Register

Re: My Application crashed

Posted by Pixelapp on Jul 28, 2012; 9:57pm
URL: https://forum.jogamp.org/My-Application-crashed-tp4025350p4025685.html

Julien:

What do you mean by "Calling put() on your direct NIO buffer is not enough, you have to send the data again if you use vertex arrays (glVertexPointer) or VBO (glBufferSubData or glBufferData)."? Please, elaborate and tell me what's wrong with this 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);

                // Missing code here; to shorten this post

                gl.glFrontFace(GL2.GL_CCW);
               
                gl.glVertexPointer(3, GL2.GL_FLOAT, 0, myVertices);
                gl.glEnable(GL2.GL_TEXTURE_2D);
                gl.glColorPointer(4, GL2.GL_FLOAT, 0, mColorBufferElements);
               
               
                gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, mTexBufferElements);
               
                gl.glDrawElements(GL2.GL_TRIANGLES, cubeFillerIElements.length,
                                GL2.GL_UNSIGNED_SHORT, mIndexBufferElements);
               
               
                gl.glPopMatrix();
}