I'm working with OpenGL and in my program, drawing various geometric shapes (squares, triangles, etc.) each object with different textures.
I tested perform rendering with VBO and shaders and this worked well creating a VBO per object. The problem occurs when a large amount of objects (between 150 and 200) ... this means very many calls to function glDrawElements()
:
glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
I found that the best way is to create a single VBO which contains all vertices to draw (vertices, texture coordinates, indices, etc.).
The problem with this is that I can not use a different texture for each of the objects as the VBO draw all geometry once.
The question is .. what is the best way (most optimal) to perform what I need? without using functions or methods that were already deprecated as glBegin ()
/ glEnd ()
or glDrawArrays ()
(I'm working with open GL 3.0 and higher).
PD: I use OpenGL with C++.
If you want to render a VBO first with one texture then with another:
If you want to draw part of a VBO with one texture and part of it with another texture you have a couple options: