PDA

View Full Version : Confused about VA, VAOs and VBO and more questions



RoiiG
08-15-2010, 11:16 AM
Hello i'm trying to use 3.3 core profile, but there are not many tutorials out there :(.

When I learned OpenGL I did it the old way.. fixed pipeline and now I find very hard the transition because I have more questions without answers than never. So let's start...

1) From what I read, VAOs are just Buffer Objects used to store vertex information. So if i have 3 meshes i have to store the vertex in 1 Vertex Array (VA), all the vertex information will be stored in the GPU memory. Then create 3 Buffer Objects and bind them to each mesh 1by1 . Finally, I have to create 1 VAO and bind it all the 3 VBO? or only the the VA?

2) Which vertex will be passed to the Vertex shader? I suppose only the ones specified by a VAO. So can I have various meshes rendered with only a VAO?

3) I always used glloadidentity, gluperspective, glrotate etc.. i have to implement it, ok it's no problem at all, but what about modelview and projection matrix? Have I to maintain a stack?

4) glViewport is not deprecated, but I made a project without it and it works using opengl 3.3 with a simple vertex shader and a simple fragment shader. Why?

5) If i have a cube with 6 different textures one for each face. Which is the best way to handle it? creating one VAO? 6 VAOs? how many VBO? :S im really lost here.

If I said something that is really wrong please correct me.

Well thanks! I think is enough for now :o

Aleksandar
08-15-2010, 12:12 PM
When I learned OpenGL I did it the old way.. fixed pipeline and now I find very hard the transition because I have more questions without answers than never. So let's start...
The old way does not mean the wrong way. If you know how fixed functionality works, you have a good foundation for further studies.


1) From what I read, VAOs are just Buffer Objects used to store vertex information. So if i have 3 meshes i have to store the vertex in 1 Vertex Array (VA), all the vertex information will be stored in the GPU memory. Then create 3 Buffer Objects and bind them to each mesh 1by1 . Finally, I have to create 1 VAO and bind it all the 3 VBO? or only the the VA?
Where have you read that? VBOs store vertex attributes. VAOs collect states. The right place to start reading about it is:
http://www.opengl.org/wiki

If you store data in VAs, they reside on the client side. It is deprecated and slow (in most cases). Read more about VBO and VAO on the Wiki.


2) Which vertex will be passed to the Vertex shader? I suppose only the ones specified by a VAO. So can I have various meshes rendered with only a VAO?

All vertices must go through vertex shader. VAO has totally different purpose. You will probably need a separate VAO for each mesh, because you have to bind different VBOs. Even if your meshes share the same VBO, offsets to the start of each would require different pointers.
You can use the same VAO for several VBOs, but it is so expensive that it is not recommended.


3) I always used glloadidentity, gluperspective, glrotate etc.. i have to implement it, ok it's no problem at all, but what about modelview and projection matrix? Have I to maintain a stack?

There is no stacks any more! If you need them, you should implement them on your own. (Of course, using compatibility profile enables all deprecated functionality.)


4) glViewport is not deprecated, but I made a project without it and it works using opengl 3.3 with a simple vertex shader and a simple fragment shader. Why?

Probably good default values. I have no definite answer to this question. Which OS?


5) If i have a cube with 6 different textures one for each face. Which is the best way to handle it? creating one VAO? 6 VAOs? how many VBO? :S im really lost here.
For the beginning, forget word VAO :)
Just kidding. Read more about VAO and you'll realize what you have asked.
There are different ways to do that: using a single 2D texture, a cube map texture, a texture array (with 6 levels), or 6 different textures (which is the most expensive choice).

James A.
08-15-2010, 03:45 PM
As Aleksandar says maybe you should just forget about VAOs right now and come back to them when you have a firmer grasp on the basics.

http://www.opengl.org/wiki/Vertex_Buffer_Objects

Read the link above and if anything is unclear you should come back and ask :)