Jump to content
  • Advertisement
Sign in to follow this  
ashstampede

OpenGL model "instancing" with opengl

This topic is 3806 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

I say "Instancing" because that is a directX feature. But what i would like to know is If i have placed a model in a vbo. how would i then have more than one object sharing that model data. an example is to load one tree model but have 100 objects of this tree rendered. Also when i have loaded this model in to vertex buffer. how do I move it/rotate if i have deleted the local data? i.e I now what to place these 100 tree objects all over the scene. thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if I understand the question, you can just draw that tree 100 times with different rotations and transforms after loading the data into a VBO. Have you drawn it yet after setting up the VBO? If not search for glDrawElements.

Share this post


Link to post
Share on other sites
goodperiodical, well that is what i dont know how to do, i have gldrawelements as the call to render whats in the vbo. the code is structured as

INIT:
load model from file,
create the size of the vbo and index array,
fill vbo,delete local model data,

Update:
render.

is it just a simple as when you are in the update,call render 100 times with different glrot and gltrans?

What i had planned was to have a texture, like a height map texture where ever there was white on the texture draw a tree.

a side note isn't glDrawRangeElement better than glDrawElements. I ended up using glDrawElements because i couldnt get the data glDrawRangeElements need correctly.

Share this post


Link to post
Share on other sites
Quote:
Original post by ashstampede
is it just a simple as when you are in the update,call render 100 times with different glrot and gltrans?

Yes. Don't forget to push/pop the matrix between models.

Quote:
Original post by ashstampede
a side note isn't glDrawRangeElement better than glDrawElements. I ended up using glDrawElements because i couldnt get the data glDrawRangeElements need correctly.

glDrawRangeElement is considered more optimal, but glDrawElements is usually fine most of the time.

You can also get more D3D-like instancing using the EXT_draw_instanced extension (needs a GF8).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!