Hi all,
Im having some trouble switching from ortho. to perspective… in my humble first-time-using-OpenGL program i have a buttoned menu with mode-switching buttons (among the others)…
When i make the switch to perspective mode it flikers the drawing once…and only when i reshape, move the window or press the ‘perspective button’ it flikers once again…
Now…for both modes im using glutRedisplay. But it seems that it only works for the orthographic projection as i use the same drawing procedure for both.
What doesn’t make sense is i that do see the shapes fliker once, indicating that the perspective parameters are defined OK.
Any ideas may be helpfull!
Maybe you’re making a permanent change to a matrix each frame, but not reverting to either the identity or a known matrix?
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Do you have this line?
gluPerspective(…);
glMatrixMode(GL_MODELVIEW);
ASide from that, are you sure it is drawing once? It can often be hard to be sure.
Make sure your objects are going to be visible in the perspective. Think about the shapes of the clipping planes, and the position of the eye in each case. You may need to translate your scene backwards to get your objects in-view.
(Damn is the forum software picky these days. Deleted half my post when I used a pipe symbol earlier, and now I find it won’t let me use angle brackets at all, not even HTML-escaped… :mad: )
OK, i found it !
The problem was that i “initialized” the depth buffer and related, only when switching between modes! Why it worked fine for the ortho. projection?
simply because no depth initialization needed…
however, in perspective mode depth init. is a must!! The bottom line is to initialize the depth buffer before glPerspective(…) in the display function… (then postRedisplay will do the job also for the perspective projection)