VBO's

Started by
15 comments, last by Kincaid 15 years, 3 months ago
im about to start implementing VBO's to speed up my redering (they're the fastest way right ?) but im not clear about the following with vbo's (and also vertex arrays), when drawing 2 triangles that share two points, you will still always need 6 vertices in memory, eventhough there are only 4 unique ones ? right ? (and thus, in editing, you must maintain/have duplicate values) thanx
Advertisement
ARe you drawing separate triangles, a triangle strip, or a triangle fan?

Stephen M. Webb
Professional Free Software Developer

Quote:Original post by Kincaid
with vbo's (and also vertex arrays), when drawing 2 triangles that share two points, you will still always need 6 vertices in memory, eventhough there are only 4 unique ones ? right ?
Nope, because when rendering from VBOs you will use 'indexed triangle lists', which allow you to refer to the same vertex multiple times. duplicate positions are only necessary if you need different normal vectors or texture coordinates for the different faces.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

A point can be shared between two triangles if all of it's attributes are the same like position, texture coordinates, etc... In general when you specify an index OpenGL will take vertexArray[index],texcoordArray[index]...

Hope this helps.

EDIT: ninja'd
whats the call for that ? glIndexPointer refers to colors, and is the only thing with index I find on msdn.
Quote:Original post by Kincaid
whats the call for that ? glIndexPointer refers to colors, and is the only thing with index I find on msdn.
glDrawElements.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

perfect thanx very much
lets see if im getting it..
Is this the correct/fastest way ?

lets say i have 10000 vertices. I place them all in an array and pass that to glVertexPointer (once, at init).
then, at each frame i determine some subset ofvertices, lets say n, and create an int array of n long, with indexes to the vertices.
then i call DrawElements passing the index array to render the frame

it will only execute n times?

(edit: its dynamic data, positions in the vertex array may update per frame (or not))

[Edited by - Kincaid on January 6, 2009 5:20:59 AM]
anyone ?
with glDrawElements you can draw the whole thing or a portion of the buffer

for instance:

int indexCount;
glDrawElements(GL_TRIANGLE_STRIP, indexCount, GL_UNSIGNED_INT, 0);

will draw the whole array.

where:
glDrawElements(GL_TRIANGLE_STRIP, 50, GL_UNSIGNED_INT, 0);

will draw the first 50 elements.


the above is assuming you have an index buffer created and bound.

This topic is closed to new replies.

Advertisement