Issue the same model several times

What I'm trying to do basically has 1 model, which is obtained multiple times, with different translations and rotations.

So, I know how to use Array Buffers and Array Element Buffers ( Vertex Buffer Objects ), my question is. This is now that I loaded the model into VBO , which would be a better approach if I wanted to display it multiple times with different translations and rotations.

I have 2 theories on how to do this. (Although I ask what would be the best approach).

  • Load the model into one VBO , and then continue to call glDrawArrays and apply translation and rotation for each model I want to display.

  • Download the model in one VBO several times. Then the same model is stored several times, which ends up using a large amount of memory.

Optional:. When using method 1, you can use Quadtrees and / or Frustum, which minimize the number of models that should be displayed.

Which of these methods would be best done if I want high FPS and still retain the most memory, or is there another approach that is even better?

Just to clarify, I am not asking how to render using VBO's or how to render in general, I ask what works best if you want to display the same model several times.

Testing model

This is just an image of a test model.

Demo model

Edit

I am currently using OpenGL version 4.2.0 and I am using it on the Windows desktop.

+6
source share
1 answer

To minimize callbacks and form submission , you can use glDrawArrayInstanced () . This way you send as many instances of the original object as you wish in a single callback! Matrices for each instance that you can pack in UBO (a single buffer object) and access those that are in the vertex shader for one instance, with gl_InstanceID

+2
source

Source: https://habr.com/ru/post/952488/


All Articles