View Full Version : background not working

01-11-2006, 11:54 AM
hello, I am trying to make a simple program where the character simply moves around the screen with the arrow keys. However, whenever the 'glutReshapeFunc(ChangeSize)' thing is called it doesn't clear the background. This is confusing because this function would clear the bg in a different program. Any suggestions?


//I am using the OpenGL SuperBible 3rd Ed

function in question:

void ChangeSize( int w, int h )
GLfloat nRange = 100.0f;

if( h == 0 )
h = 1;

glViewport( 0, 0, w, h );

glMatrixMode( GL_PROJECTION );
glLoadIdentity( );

if( w (less than or equal to) h ) /* the website wouldn't let me post using the 'left carrot' symbol b/c it thinks I'm trying to do html*/
glOrtho( -nRange, nRange, -nRange * h/w, nRange * h/w, -nRange, nRange );
glOrtho( -nRange * w/h, nRange * w/h, -nRange, nRange, -nRange, nRange );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );

01-12-2006, 12:32 AM
if you want to clear the color buffer, call glClear(GL_COLOR_BUFFER_BIT)

this should probably be in the beginners' forum, rather than the Mac-specific one ;)

01-12-2006, 09:26 AM
I see - thank you :rolleyes: