Advertisement

What's wrong with this ? (beginner question)

Started by April 23, 2002 03:45 PM
3 comments, last by moromete 22 years, 10 months ago
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..
______________________________Only dead fish go with the main-stream.
Advertisement
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.
You should never let your fears become the boundaries of your dreams.
It''s being clipped. Use gluOrtho2D or translate into the view before drawing your quad.

This topic is closed to new replies.

Advertisement