PDA

View Full Version : Get a run time error when turn to freeglut.



Qiaowen
03-09-2012, 05:41 AM
Hi.
I use the glut library first.Then I read the red book.And the red book recommand the freeglut.So I turn to the freeglut,and set up the environment.Then I run the first example in the red book(draw a rectangle). A run time error occur, this error is dircted to the "glutDisplayFunc(&myDisplay);".The error type is "an unhandled exception".
Under glut,it's fine.

uwi2k2
03-09-2012, 10:27 AM
hi,

i had something simelar once.
are you runing in gameMode ?
if yes, make shure that you have the right 'GameModeString' settings.
as this one seems to cause problems sometime.
just play around with diffrent values for resolution and Hrz.

cu
uwi

Qiaowen
03-09-2012, 10:19 PM
Hi,
What is gameMode?My code are very simple.


#include <gl/glut.h>
//#include <stdlib.h>
#include <iostream>
#include <windows.h>

//using namespace std;

void myDisplay(void)
{

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(0.1,0.25,0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.5,0.75,0.0);
glEnd();
glFlush();
} //End of the function

void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
} //End of the init function


int main(int argc, char* argv[])
{
glutInit(&amp;argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowPosition(0,0);
glutInitWindowSize(400,400);
glutCreateWindow("The First OpenGL App");
init();
glutDisplayFunc(&amp;myDisplay);
//init();
glutMainLoop();

} //End of the main function

ZbuffeR
03-10-2012, 02:13 AM
What does it says when you run it through a debugger ?
"an unhandled exception" is not really helpful.