Can someone explain why this is not working?
G''Day All.
i''ve tried to some simple OpenGL programming, and cannot figure out WHY my code is doing *weird things*(tm).
Could someone please explain to me WHAT I HAVE DONE WRONG. It''s obvious i''m getting confussed with OpenGL theory.
I have COMMENTED one line below (glLoadIdentity). When I remove it, my ~scene~ looks fine. When I ADD it, my screen FLICKERS everytime I ~move the camera around the scene~
I''ll post what i''ve done....
*********************************************************
void RenderScene(void)
{
int x, y = 1;
int j;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw ground
glColor3f(0.9f, 0.9f, 0.9f);
glBegin(GL_QUADS);
glVertex3f(-100.0f, 0.0f, -100.0f);
glVertex3f(-100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, 100.0f);
glVertex3f( 100.0f, 0.0f, -100.0f);
glEnd();
// ****************************
glLoadIdentity(); // **** THIS LINE CAUSING PROBLEMS *** //
// ****************************
for (x=0; x < 2; x++)
{
glPushMatrix();
glTranslatef(1.0f * x, 0.0f, 10.0f );
// Colour the BOX (not the top surface)
glColor3fv(colour_dark_red);
glCallList(terrainBox);
// Colour the top quad
glColor3fv(colour_dark_green);
glCallList(terrainSurface);
glPopMatrix();
}
glutSwapBuffers();
}
**************************************
-PK-
-PK-
I don''t know the cause though, how about put the glLoadIdentity
before you draw the ground. ( i think it is a good practice ).
before you draw the ground. ( i think it is a good practice ).
skyline
December 05, 2000 10:57 PM
Very odd, I''m not sure what''s going wrong with your code, it looks ok to me although I do agree that you should reset the matrix before you do anything.
Perhaps the screen is flickering because you have vsync disabled for your video card, and the screen isn''t refreshing fast enough to avoid the flicker?
try adding a glFlush() to the end of your drawing code.
Perhaps the screen is flickering because you have vsync disabled for your video card, and the screen isn''t refreshing fast enough to avoid the flicker?
try adding a glFlush() to the end of your drawing code.
I have a funny feeling you are screwing with your projection matrix instead of your modelview matrix.
Try adding:
glMatrixMode( GL_MODELVIEW );
before the load identity and see if it fixes it.
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Try adding:
glMatrixMode( GL_MODELVIEW );
before the load identity and see if it fixes it.
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement