and that class render all the scene with one glDrawElement, what do you think on that
While it should always be your goal to reduce the number of draw calls to as few as possible, 1 draw call for the whole scene is simply not possible.
You are basically thinking in entirely the wrong direction. If you had some kind of manager like what you described you just be wasting CPU time inside your manager instead of inside the OpenGL driver. Even if it was possible to reduce the whole scene into 1 draw call, it would likely be extremely slower as you collect and reconstruct all the data each frame.
There are way to increase performance not covered in those books.
#1: Reduce redundant render-state changes. Don’t enable culling if it is already enabled. Don’t activate a shader if it is already active. Don’t set a texture if it is already set. Don’t bind a vertex buffer if it is already bound.
#2: Make things redundant. Point #1 doesn’t make sense if you draw ABABABABA. In order to make #1 useful, draw AAAAABBBB. Use a render-queue with frame-to-frame temporal coherence to sort objects such that objects are drawn using the same states one after another.
#3: Most models have meshes that are copy-pasted from the right to the left (or vise versa) and a transform applied to them. There is no reason to have a separate vertex buffer for every single part if many parts are duplicates of each other. Find duplicates and use the same vertex buffer for both parts, using the render-queue to make sure they are drawn back-to-back so that #1 can be used and no vertex-buffer changes are made between draws.
#4: Standad GPU optimizations apply. Don’t modify resources that are in-use. Reduce render-target swaps to the minimum necessary. Only use 2 render targets for bloom, even if you have to ping-pong the downsample process 6 times. Only use 16-bit indices. Order your vertices for best cache usage (major help). Etc.
Edited by L. Spiro, 28 July 2014 - 03:56 PM.
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums