PDA

View Full Version : ack my reshape function causes my PC to crash please help



ShinGouki
05-08-2003, 08:42 PM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif*

Deiussum
05-09-2003, 04:23 AM
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.

nexusone
05-09-2003, 04:46 AM
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 (http://www.angelfire.com/linux/nexusone)



Originally posted by ShinGouki:
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 http://www.opengl.org/discussion_boards/ubb/wink.gif*