tags:

views:

79

answers:

1

As the question states. The best example of this I have right now is the function glSelectBuffer. I'd like to know if I can call it just once in my init function or if I have to call it every single time, before I do glRenderMode(GL_SELECT). But just in general, there have been many times when I've wondered whether I can just call a function once at the beginning of my program or if I have to call it every frame.

I know that OpenGL is a state engine, but it seems to me like some things are kept in the state and others aren't. And yes I know, when I modify something later in my program, I'll have to reset it back to the first value in the beginning of my loop each time, because of OpenGL being a state engine; that's not the answer I'm looking for.

If nothing else, if you find me very confused and you haven't had such a problem, then please just answer my sub-question of whether glSelectBuffer can be called once or needs to be called every time.

+1  A: 

Only the direct rendering calls are ought to be called each time. (glClear, glBegin - glVertex - glEnd, e.t.c.) The state modifying calls sometimes need to be called every frame because you want to set them to different states at different points in the frame rendering process.

This is the case for glRenderMode too - you want to continuously toggle between GL_SELECT and other modes.

EDIT: Sorry, this appears to be also the case for glSelectBuffer - according to man page exiting GL_SELECT mode automatically resets the buffer pointer.

EFraim