Drawing more than one objects (most tutorials draw only one thing)

Is there any beginner tutorial that does not draw a SINGLE triangle but more DIFFERENT items? like GL_LINES and GL_TRIANGLE at the same time.
I saw many tutorials on opengl (core profile) where they draw a triangle or a square. Or maybe they draw 5 triangles, but all are generated from the same vertices just translated differently.

My question is, what should I do if I want to draw two DIFFERENT object? Lets say a few lines and a triangle and a square? In this case should I have 3 vbo-s, one for each object? Or should I have just one array and reuse it by changing its values on the fly? Do I also need in the shader as many uniform variables as many objects i have?

[QUOTE=pukedli;1291037]Is there any beginner tutorial that does not draw a SINGLE triangle but more DIFFERENT items? like GL_LINES and GL_TRIANGLE at the same time.
I saw many tutorials on opengl (core profile) where they draw a triangle or a square. Or maybe they draw 5 triangles, but all are generated from the same vertices just translated differently.

My question is, what should I do if I want to draw two DIFFERENT object? Lets say a few lines and a triangle and a square? In this case should I have 3 vbo-s, one for each object? Or should I have just one array and reuse it by changing its values on the fly? Do I also need in the shader as many uniform variables as many objects i have?[/QUOTE]

The answer to all your questions is: It depends :stuck_out_tongue:

The question is always what you want to achieve. It is totally fine to use a VAO/VBO combination for every object. This keeps your code simple since all you need to do is switching the vao that you want to draw. If you want high performance code, then you should probably try to squeeze everything into as few buffer objects as possible to keep your state changes to a minimum. In this case the data management can get quiet messy.

Regarding uniform variables: No you don’t need a variable for each object. You usually just need one Variable for each object parameter (displacement, rotation etc). Make sure to always update these values before drawing a new object. But again, if you want performance, you usually create arrays of the same variable and get the right value out of it by using an object specific index.

Additionally, I think most people will encourage you to use uniform blocks + uniform buffer objects instead of plain uniforms, because they give you the ability to share data between different shader programs. But this will as always depend on your personal needs. Uniforms are simpler to use and I think also a little bit faster, but the latter statement is just a guess.