Sign in to follow this  
My_Mind_Is_Going

Are calls to glEnable/glDisable expensive?

Recommended Posts

For example to render my bitmap fonts correctly I have to disable lighting and textures and then re-enable them when I'm finished, is this a normal thing to have to do or should I be worried about making a lot of calls like this? Is this a ridiculous thing to be worried about?

Share this post


Link to post
Share on other sites
heh.. you really shouldn't worry :)

finish your game/engine or whatever and then worry about function calls, and I bet in 99.999% of the cases it's your own functions you should worry about :)

Share this post


Link to post
Share on other sites
You are switching opengl state when you do that so it could be expensive. How much is hard to say without benchmarking it. Like ggp83 says though, don't worry about it too much.

If you do worry anyway, a good idea would be to makes sure you do all text rendering at the same time. Then you only have to switch state before and after all text rendering, instead of for each rendered text.

Share this post


Link to post
Share on other sites
It's only a problem if you do it MANY times and you CPU and drivers are slow.
In general, the less calls to GL the better. And it depends very much on the actual call. glBindTexture is expensive, glUseProgram, etc...
glEnable and glDisable are less expensive

Share this post


Link to post
Share on other sites
profile your application with C/C++ profiler to find its bottlenecks. Then you'll know to improve your code. The results can be really impressive.

/P.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this