Hi,
I’m writing a little TimeCrisis/VirtuaCop engine using OpenGL and SDL
and I’m facing some problems. I use OpenGL select mode to check out
where do the bullets go, but I’m getting an undesired zoom effect when I
do it.
I think it happens because select mode simulates a redraw on a small
zone of the screen to achieve its function, and somehow SDL makes that
redraw happen. I have been told on comp.graphics.api.opengl to…
Don’t know about SDL, but this happens in plain OpenGL. The solution…
- If you are using single-buffering, don’t.
- If you are using double-buffering, don’t call swap buffers when you
do
the select.
I’ve tried turning on double buffering like this:
SDL_SetVideoMode(640, 480, 0, SDL_OPENGL | SDL_FULLSCREEN |
SDL_DOUBLEBUF)
but this doesn’t solve the problem…
any ideas? I could post the code if anyone is interested (right now, you
can kill some cylinders
Alex the Koala wrote:
Hi,
I’m writing a little TimeCrisis/VirtuaCop engine using OpenGL and SDL
and I’m facing some problems. I use OpenGL select mode to check out
where do the bullets go, but I’m getting an undesired zoom effect when I
do it.
Did you select the good render mode ? With : glRenderMode(GL_SELECT)
From what you describe, you’re always in GL_RENDER mode.
Franck.
Yes, of course I use it
The code goes more or less like this:
if(button==SDL_BUTTON(1)) {
GLuint *selectbuf;
GLint hits;
GLint viewport[4];
int i,j,t1;
selectbuf=(GLuint *) malloc(sizeof(GLuint)*BUFSIZE);
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFSIZE, selectbuf);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble) mousex, (GLdouble)
(viewport[3]-mousey),5.0,5.0,viewport);
gluPerspective(45.0f,Aspecto,0.1f,100.0f);
Escena(1); // This draws the scene
glPopMatrix();
glFlush();
hits=glRenderMode(GL_RENDER);
// Code for checking the hits…
}
}
// And this as normal
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // Borramos todo
Escena(0);
Franck Guillaud wrote:
Alex the Koala wrote:
Hi,
I’m writing a little TimeCrisis/VirtuaCop engine using OpenGL and SDL
and I’m facing some problems. I use OpenGL select mode to check out
where do the bullets go, but I’m getting an undesired zoom effect when
I
do it.
Did you select the good render mode ? With : glRenderMode(GL_SELECT)
From what you describe, you’re always in GL_RENDER mode.
Franck.
Alex the Koala wrote:
Yes, of course I use it
The code goes more or less like this:
[code snipped]
Well, this look exactly like the Red Book sample, I
see nothing wrong here.
But I don’t think the error is related with SDL. SDL only opens
an OpenGL display but doesn’t wrap OpenGL calls, * If I Remember
Correctly *.
Ouuuupssss, last minute update before posting.
Your end code :
Escena(1); // This draws the scene
glPopMatrix();
glFlush();
Try :
Escena(1); // This draws the scene
glMatrixMode(GL_PROJECTION); <-------------- !!! Here !!!
glPopMatrix();
glFlush();
I suppose the Escena proc manipulates only the MODELVIEW matrix. So
the
glPopMatrix pops a MODELVIEW matrix. When you return in RENDER mode, the
projection matrix is always “perturbed” by gluPickMatrix.
Hope this helps.
Franck.>
Franck Guillaud wrote:
Alex the Koala wrote:
Hi,
I’m writing a little TimeCrisis/VirtuaCop engine using OpenGL and
SDL
and I’m facing some problems. I use OpenGL select mode to check
out
where do the bullets go, but I’m getting an undesired zoom effect
when I
do it.
Did you select the good render mode ? With :
glRenderMode(GL_SELECT)
From what you describe, you’re always in GL_RENDER mode.
Franck.
–
Well, this look exactly like the Red Book sample, I
see nothing wrong here.
Good eye!
But I don’t think the error is related with SDL. SDL only opens
an OpenGL display but doesn’t wrap OpenGL calls, * If I Remember
Correctly *.
Ouuuupssss, last minute update before posting.
I suppose the Escena proc manipulates only the MODELVIEW matrix. So
the
glPopMatrix pops a MODELVIEW matrix. When you return in RENDER mode, the
projection matrix is always “perturbed” by gluPickMatrix.
Yes! Brilliant! Perfect! That’s it… I should have noticed; if it had been
any other problem,
I would have got an horrible flicker
Hope this helps.
A lot!!! Thank you very much!