Sign in to follow this  
_OskaR

VBO - drawing part of buffer

Recommended Posts

_OskaR    144
I want to draw only part of (indexed) VBO. So:
glDrawRangeElements(GL_TRIANGLE_STRIP, 5600,5600+448,448, GL_UNSIGNED_INT,0);
glDrawRangeElements(GL_TRIANGLE_STRIP, 0,448,448, GL_UNSIGNED_INT,0);
But in both situations I see same part of buffer. I can't start for example from 56th index. I heart about glPrimitiveRestartIndex but I'm not sure how to use it.

Share this post


Link to post
Share on other sites
Jansic    251
Both of these functions start at the same offset (zero) and render 448 elements. The index ranges are optimisations for the active array ranges covered by the indices, not offsets into the index array. Try putting your index offset into the indices pointer param.

Jans.

Share this post


Link to post
Share on other sites
HuntsMan    368
What is on your index buffer? You should use the last parameter as an offset into the IBO, and move it appropiately to match the 56th index.

Share this post


Link to post
Share on other sites
_OskaR    144
Sth works but it's strange. First image for:
glDrawElements(GL_TRIANGLE_STRIP,56, GL_UNSIGNED_INT,0);


Two different VBO's, in both situations - squares (5x5 vertices) - parts of bigger 129x129 VBOs. No problems.

2nd:
glDrawElements(GL_TRIANGLE_STRIP,112, GL_UNSIGNED_INT,0);


Also good - 2 squares per VBO.

Now I want to show only 2nd square:
unsigned int offset = 56;
glDrawElements(GL_TRIANGLE_STRIP,56, GL_UNSIGNED_INT,((GLvoid *) offset));

Result:


That's strange but I checked also:
unsigned int offset = 56*4;
glDrawElements(GL_TRIANGLE_STRIP,56, GL_UNSIGNED_INT,((GLvoid *) offset));

Result:

Looks like the offset value is only 25% of value which I need. I can draw all parts of VBO but I must multiply offset by 4. I don't understand why.

Share this post


Link to post
Share on other sites
Lord_Evil    680
IIRC the offset is given in bytes. Since you specify your indices to be unsigned integers (4 bytes) you'd have to multiply your integer offset by 4 to get the byte offset.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this