glDrawRangeElement issue.
Still not sure you understand it. You speak of streaming the index arrays from main memory, but what we're talking about doesn't include any streaming. At all. Not even of the index array. It only includes adding an integer to the last parameter to glDraw(Range)Elements and nothing else.
This is my old testing implimentation without the new changes. Note the render method if vbo is true and the null pointer. Are you saying put an integer where Null is on DrawElements?
Method BeginRender() glEnableClientState(GL_Vertex_Array) If fltColor glEnableClientState(GL_Color_Array) EndIf If VBO glBindBuffer(GL_ARRAY_BUFFER, intVertexBuffer) glVertexPointer(3, GL_FLOAT , 0, Null) If fltColor glBindBuffer(GL_ARRAY_BUFFER, intColorBuffer) glColorPointer(3, GL_Float , 0, Null) EndIf glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, intElementBuffer) Else glVertexPointer(3, GL_FLOAT , 0 , Varptr(fltVertex[0]) ) If fltColor glColorPointer(3, GL_FLOAT , 0 , Varptr(fltColor[0]) ) EndIf glLockArraysEXT(0, shtElements.length) EndIf End Method Method Render() If VBO glDrawElements(GL_TRIANGLES, shtElements.length , GL_UNSIGNED_SHORT, Null) Else 'using VA glDrawElements(GL_TRIANGLES, shtElements.length , GL_UNSIGNED_SHORT , Varptr(shtElements[0]) ) EndIf End Method
From the tutorials i've seen. You pass a null pointer when VBO binding..i'm assuming you can do this because it's not loading data off of ram like in VAs. If you look at the render method and if VBO is true. You see i don't need a pointer to anything because it's loaded in the Vram(i'm guessing). So i use a null. In the case of VA, i do need to pass a pointer. So i'm saying i could have Vertices, Normals etc on Vram. If I put indices on Vram..how can i control the pointer? The pointer address is the ram address.
The last parameter can have two different meanings.
That's how you do it, both for regular VA and VBO.
- When VBO is NOT used, that is, "regular" vertex arrays are in use, it is a pointer to the first index in the index array you want to draw. If you want to start drawing at index 8 (just an example), you can call glDrawElements like this:
glDrawElements(..., &myIndexArray[8]);
You offset the start by 8 indices. - When VBO is in use, the last parameter is the offset from the start of the buffer. If you pass a null pointer, wich has the value 0, it means you want to start taking indices from the beginning, plus an offset of 0.
To start drawing at index 8, just like in the last example, you provide the corresponding offset.glDrawElements(..., reinterpret_cast<void *>(8 * sizeof(GLushort)));
Don't know what the corresponding code to convert an arbitrary integer to a pointer is, but this is how it looks in C++. Basically, you provide the offset in bytes. The eighth index is located at a byte offset of 8 times the size of an index in bytes. For example, for 16 bit indices, the byte offset would be 8*2=16 bytes.
That's how you do it, both for regular VA and VBO.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement