Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Say, I send 10 polygon pairs (one polygon pair == one 2d sprite == one rectangle == two triangles) into OpenGL ES 2.0 VBO. The 10 polygon pairs represent one animated 2D object consisting of 10 frames.

The 10 frames, of course, can not be rendered all at the same time, but will be rendered in particular order to make up smooth animation.

Would you have an advice, how to pick up proper polygon pair for rendering (4 vertices) inside Vertex Shader from the VBO? Creating separate VBO for each frame would end up with thousands of VBOs, which is not the right way of doing it.

I use OpenGL ES 2.0, and VBOs for both Vertices and Indices.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

If you use glDrawElements, you should be able to define offset. If you have bound indeces with glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices), last parameter in glDrawElements is just offset. So you can start from anywhere and stop after few indeces (second parameter - count).

share|improve this answer
    
@zaharmarz: hi and +1. That is great advice. I will take closer look at the last parameter of glDrawElements(). I am curious, do you think, there is a way on how to contoll VBO polygons directly from the Vertex Shader? –  Bunkai.Satori Feb 17 '11 at 20:00
    
I am marking this one as the Accepted Answer. I have tested it, and it works well for me. Thank you. –  Bunkai.Satori Feb 17 '11 at 22:59
    
I haven't try to control polygons directly from vertex shader. But I think it's not possible. Vertex program is executed on one processor, which has it's own registers (I think). It can't access global memory like CUDA. –  zacharmarz Feb 17 '11 at 23:29
add comment

One approach is to use a shader to interpolate frames, so you get smooth animation and possibly less data.

Look at this question and its answers: interpolating frames in a vertex shader

share|improve this answer
    
+1 for valuable answer. Yeah, that would be a solution as well, if I do nto use one of the values like normal, uv, color... Meanwhile I already implemented Zacharmarz's solution, and it worked very well. Thank you :-) –  Bunkai.Satori Feb 17 '11 at 22:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.