Jump to content
  • Advertisement
Sign in to follow this  
Limitz

from indices to vertexbuffers

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I want to do the following, but i don't really know how to do it, i guess i am looking for a method to add an offset to indices to vertices. This is what i want to do: I have an indexed triangle strip, i want to store it on the GPU. I have several vertex buffers i want to store at the GPU. Now i want to make the GPU draw the triangle strip using one of the vertex buffers as the base of its indices. Anyone know a nice way to do this? Greetings...

Share this post


Link to post
Share on other sites
Advertisement

I am not sure if I understand exactly your problem.

You seem to be familiar with VBs and IBs so what seems to be the problem with using them ?

DX Sdk comes with simple examples of

Setting Vertex Buffer
Setting Index Buffer
Setting the vertex declaration

... plenty of stuff before reaching the point of actually drawing something ...

DrawIndexedPrimitive

Share this post


Link to post
Share on other sites
Well the problem is that i want to store them on the GPU. I know howto declare them in user memory and draw both the VB en IB in one call, but i want to store a vertex buffer on the GPU that contains several concatenated vertex buffers. Now i want to store the index buffer on the gpu, set an offset for the vertex buffer and draw the resulting set.

It's like this. I have terrain data 257 * 257 vertices. and a 17 by 17 trianglestrip. I want to set the offset for the teraindata to 17*17 to get the second block for instance, and then draw the trianglestrip which uses indices 0 to 17*17-1, so it uses the same indices + offset to draw a different portion of the terrain.

I am using opengl btw...

Share this post


Link to post
Share on other sites
Quote:
Original post by Limitz
Well the problem is that i want to store them on the GPU. I know howto declare them in user memory and draw both the VB en IB in one call, but i want to store a vertex buffer on the GPU that contains several concatenated vertex buffers. Now i want to store the index buffer on the gpu, set an offset for the vertex buffer and draw the resulting set.

It's like this. I have terrain data 257 * 257 vertices. and a 17 by 17 trianglestrip. I want to set the offset for the teraindata to 17*17 to get the second block for instance, and then draw the trianglestrip which uses indices 0 to 17*17-1, so it uses the same indices + offset to draw a different portion of the terrain.

I am using opengl btw...

I also don't clearly understand the problem ... let me see:

1) Of course you can store the index buffer on the GPU, just use GL_ELEMENT_ARRAY_BUFFER with the buffer target (instead of GL_ARRAY_BUFFER with the data buffers).

2) Just provide an incremented pointer to glDrawElements to start from an offset on the data buffer. Like for the second strip, this should work:
glDrawElements(GL_TRIANGLE_STRIP, 17*17, GL_UNSIGNED_SHORT, BUFFER_OFFSET(17*17*sizeof(vertex)));


/edit: After re-reading phantom's post, seems like I misunderstood; you have just one set of indices (for one strip). Sorry about the confusion, as he said use gl*Pointer().

Share this post


Link to post
Share on other sites
Quote:
Original post by phantom
you have to perform the offset, in bytes, in the gl*Pointer() calls


Thanks a lot. I'll try that :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!