LWJGL
May 22, 2012, 16:09:47 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Index Buffer layout/format?  (Read 327 times)
MattCa
Newbie
*
Posts: 10


« on: August 28, 2011, 03:39:35 »

Hi! I've been googling around for information about index buffers. The one problem I still have is how to actually 'reference' each vortex and how an index buffer is actually formatted. Could anyone provide me with a basic example of how to use one with a vortex buffer (im using the fixed pipeline, GL11/GL12).

Thanks,
Matt.
Logged
Meanz
Newbie
*
Posts: 38


« Reply #1 on: August 29, 2011, 23:32:26 »

The only thing I could come up with: http://www.gamedev.net/topic/466568-opengl-index-buffers--ibo-/

I am still a newbie, so that may be the reason I am not getting what you are looking for.

But anyways, I am pretty sure it's called "vertex" and not "vortex".

And also since I am not sure what you are looking for ill give this a try.

Code:
    public void updateBufferData(int id, FloatBuffer buffer) {
        if (GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
            ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, id);
            ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer, ARBVertexBufferObject.GL_DYNAMIC_DRAW_ARB);
        }
    }

    public static void updateElementData(int id, IntBuffer buffer) {
        if (GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
            ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, id);
            ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, buffer, ARBVertexBufferObject.GL_DYNAMIC_READ_ARB);
        }
    }

    public int createVBOID() {
        if (GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
            IntBuffer buffer = BufferUtils.createIntBuffer(1);
            ARBVertexBufferObject.glGenBuffersARB(buffer);
            return buffer.get(0);
        }
        return 0;
    }

You have the function createVBOID that "creates" a new pointer to a buffer object.
And then you can add vertex data using updateBufferData and you can use the updateElementData to add vertice indexes.
Again this is still new contents for me and I am pretty sure I don't fully understand this content.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!