ack my reshape function causes my PC to crash please help

yet another question, sorry guys lol

void reshape(int width, int height)
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}

glViewport(0,0,width,height);						// Reset The Current Viewport

ASPECT_RATIO = (float)width/(float)height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, ASPECT_RATIO, 1.0, 4000.0);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);	// Black background
glutPostRedisplay();
glutSwapBuffers();
glMatrixMode(GL_MODELVIEW);

}

this seems to be causing my pc to crash horribly when i resize in certain directions, can you spot any obvious discrepancies about what im doing?

i feel like im one of those bug busting questions in C++ in 21 days, can you spot the bug

glutPostRedisplay();
glutSwapBuffers();

Shouldn’t the glutSwapBuffers be done in the Display function? glutPostRedisplay basically just posts a WM_PAINT message, it doesn’t actually call your display function. Your display function will likely not be called until after the reshape is done, when the WM_PAINT message is then picked up.

As the other person posted the glutPostRedisplay and glutswapbuffers should not be in the reshape.

Also on window reshape, it automatically calls you glutPostRedisplay so you are repeating it twice by puttin it in.

on the glutswapbuffers sould be called at the end of you display routine.

Look at my website with glut examples:
www.angelfire.com/linux/nexusone

Originally posted by ShinGouki:
[b]yet another question, sorry guys lol

void reshape(int width, int height)
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}

glViewport(0,0,width,height); // Reset The Current Viewport

ASPECT_RATIO = (float)width/(float)height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, ASPECT_RATIO, 1.0, 4000.0);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black background
glutPostRedisplay();
glutSwapBuffers();
glMatrixMode(GL_MODELVIEW);
}

this seems to be causing my pc to crash horribly when i resize in certain directions, can you spot any obvious discrepancies about what im doing?

i feel like im one of those bug busting questions in C++ in 21 days, can you spot the bug [/b]