Jump to content
  • Advertisement
Sign in to follow this  
TheStudent111

How many VAO can OpenGL bind at the same time?

This topic is 393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How many VAOs are allowed to be bound to OpenGL at one time. I'm asking this because I recently saw code that looked like the following

while(running){

bindVAO1   // Cube with lighting

draw


bindVAO2  // Cube

draw

}

 

When I ran the program, both rendered without problems. My previous understanding was that OpenGL was restricted to one VAO at a time (Being a state machine). I originally expected to be some flickering between the two VAOs, as glDrawArray wouldn't have the other VAO binding to it for drawing. So how many VAO does OpenGL allow? Does glDrawArray keep track of previous renderings of objects?

 

 

Edited by TheStudent111

Share this post


Link to post
Share on other sites
Advertisement

When you issue the second binding call, you overwrite the existing binding with the new one, so VAO 1 gets unbound, and VAO 2 gets bound.

What I mean is that doing:

bind(vao1);

bind(vao2);

And doing:

bind(vao1);

unbind(vao1);

bind(vao2);

Work practically the same. There is only one VAO binding point, and further bindings will overwrite it.

Share this post


Link to post
Share on other sites

Thanks TheChubu,

Though I have to ask how is there no flickering occurring. Wouldn't the second drawing,

bindVAO2  // Cube

draw

overrwrite what was there before. Does glDrawArray maintain state from previous renderings?

Share this post


Link to post
Share on other sites

Your draw command draws what's in the VAO to the target render buffer (probably the colour buffer in most cases).  Your flow is something like this.

clear the colour buffer
bind VAO
draw what's in the VAO to the colour buffer
bind another VAO
draw what's in the other VAO to the colour buffer
flip the colour buffer to the front so it's drawn on the screen

I don't really see any reason for flickering, since it's a complete serial operation.  Sure, if the second VAO holds vertexes that will overwrite or occlude what's in the first VAO, you might not see what you expect, but maybe that's just your expectations that are wrong.

Share this post


Link to post
Share on other sites

Think of it as Photoshop/Gimp layers if it helps.

You draw to a render target, a texture. Each draw you add a new layer to the render target with something new to paste over the stuff it is already there (it gets more complicated with depth/stencil tests but bear with me).

Once you draw everything, you call swap buffers and the target you were drawing to gets shown in the screen, while you get back the old target to draw on top of.

Thats why you call glClear in between swap buffer calls, so you clean the existing target for further drawing. Otherwise what you draw before gets stuck there in the target and each object you draw would appear smeared over the screen when you move the camera.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!