model "instancing" with opengl
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.
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.
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.
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.
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement