glViewport and glScissors
by Robert Blanchet Jr. · in Torque Game Engine · 07/21/2002 (9:55 pm) · 0 replies
Hi. This is a question for more of the graphics folks out there. I have a problem.
I'm trying to use glViewport and glScissors (note: i'm not using dglSetViewport) including glEnable(GL_SCISSORS_TEST) to render to a specific spot and size to the screen.
Here is my code:
What I'm trying to do is draw a map to a specific portion and size of the screen, instead of going through the gui editor and setting this. The main reason why is because I'm having odd centering issues in anything other than an extent of 640 x 480 but I figure if I can render to a specific spot and size to the screen, like it was rendering it to the full screen, I will not have these problems.
However, setting the viewport like this doesn't seem to work at all :/ Any ideas?
I'm trying to use glViewport and glScissors (note: i'm not using dglSetViewport) including glEnable(GL_SCISSORS_TEST) to render to a specific spot and size to the screen.
Here is my code:
void GuiMapView::renderWorld(const RectI & updateRect)
{
// Store the old vis distance variable and set the new distance
F32 visDistance = gClientSceneGraph->getVisibleDistance();
gClientSceneGraph->setVisibleDistance(mVisibleDistance);
RectI oldViewport;
dglGetViewport(&oldViewport);
glViewport(0, 0, 440, 280);
glScissors(0, 0, 440, 280);
glEnable(GL_SCISSORS_TEST);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
dglSetCanonicalState();
// Render Scene
const U32 mask = StaticObjectType | DecalManagerObjectType | CameraObjectType | StaticShapeObjectType | PlayerObjectType | ItemObjectType |
VehicleObjectType | ProjectileObjectType | ExplosionObjectType | CorpseObjectType | DebrisObjectType | StaticTSObjectType;
gClientSceneGraph->renderScene(mask);
renderMissionArea();
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSORS_TEST);
dglSetViewport(oldViewport);
}What I'm trying to do is draw a map to a specific portion and size of the screen, instead of going through the gui editor and setting this. The main reason why is because I'm having odd centering issues in anything other than an extent of 640 x 480 but I figure if I can render to a specific spot and size to the screen, like it was rendering it to the full screen, I will not have these problems.
However, setting the viewport like this doesn't seem to work at all :/ Any ideas?