PDA

View Full Version : State Enable optimization



Pierre
02-04-2010, 01:25 PM
Hello everyone,

I would like to know something that I've found anywhere on the OpenGL state, even in books.

Is it better to enable every state to load the world, or enable the states one by one to each frame as and when we should use it?

Thank you and goodbye,

dletozeun
02-04-2010, 01:36 PM
I am not sure to understand your question but I will try to answer. Opengl states are not like game engines features, "enabling" all of them as you said, won't result in fantastic graphics.

With opengl, you enable or set states you need and disable the ones you don't need.

Pierre
02-04-2010, 02:23 PM
No my question is:

What is the best method?

1. Enable all statements at the opening of the window.

2. Enable and disable the states in each frame every time I use it.


I would like to gain speed.

Alfonse Reinheart
02-04-2010, 02:26 PM
What is the best method?

Like he said, "you enable or set states you need and disable the ones you don't need."

dletozeun
02-04-2010, 02:44 PM
You can't set gl states once for all at the beginning of your your program (except if your program is very simple). Sometimes you may need for example, to enable 2D texturing, sometimes you don't. Each rendering batch has its set of gl states. The best method is to draw all batches consecutively that require the same set of states and avoid expensive states initialization as much as you can.

Pierre
02-04-2010, 03:39 PM
Thank for your answer.

Goodbye!