What's wrong with this ? (beginner question)
glClearColor(0.5, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
And i get a red window and no poly...
Am i doing something wrong here ?
COnforming to the source, i should get a
white square in the middle of the screen
moromete
I think the valus in glOrtho are wrong. I''m not sure but i remeber something about clipping values not being negative...
..i could be way off here..
..i could be way off here..
______________________________Only dead fish go with the main-stream.
try doing a glLoadIdentity() before your glOrtho call. glOrtho multiplies the current matrix with whatever it generated. You should also have the projection matrix selected before calling glOrtho() - glMatrixMode(GL_PROJECTION);
try this...
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( ...whatever... );
glMatrixMode( GL_MODELVIEW );
// glDisable( GL_DEPTH_TEST ); // (you might need to enable this)
glLoadIdentity();
... draw 2D stuff here
also you shouldn''t call glFlush(). It is called automatic on
SwapBuffers(...) call.
You should never let your fears become the boundaries of your dreams.
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( ...whatever... );
glMatrixMode( GL_MODELVIEW );
// glDisable( GL_DEPTH_TEST ); // (you might need to enable this)
glLoadIdentity();
... draw 2D stuff here
also you shouldn''t call glFlush(). It is called automatic on
SwapBuffers(...) call.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement