Jump to content
  • Advertisement
Sign in to follow this  
rewolfer

OpenGL consequent call overhead

This topic is 3403 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

State changes in graphics APIs can be expensive, but if I were to make the same state change call twice in a row, would it take twice as long or does opengl know the current state. ie. Should I record which shader is enabled before calling glUseProgram again, in case its already setup?

Share this post


Link to post
Share on other sites
Advertisement
As to whether the gl knows that the shader is already bound and just basically "skips" that call would really depend on the manufactures implementation of opengl, perhaps someone with better knowledge of nvidia's or amd/ati's driver's could comment?

If you are really keen on checking yourself you could do something like this:

if(nowShader != currentBoundShader)
{
glUseProgam(nowShader);
currentBoundShader = nowShader;
}




of course this means you have an if statement every time you want to bind a shader. I think it is easier to just make sure you use glUsePrgram(0) whenever you are finished with a shader that way you can avoid any checking. If you have to use that same shader multiple times per frame than try and group that geometry together so you don't have to enable so many times.

Share this post


Link to post
Share on other sites
Thank you. I do use grouping, but was just pondering to myself about that - i guess you're right about the implementation dependance.

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!