• 13
• 18
• 19
• 27
• 10

# Unusual FreeGlut error

This topic is 2441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi
I am trying to build a small program using glut function.

The code structure looks like
 int main(int argc, char** argv) { //initialising the glut and creating the window glutInit(&argc, argv); glutInitWindowSize(1024, 768); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_STENCIL|GLUT_DEPTH); main_window = glutCreateWindow("Hello"); glutDisplayFunc( Display ); glutReshapeFunc( Reshape ); ....... ........... ......... glutMainLoop(); return EXIT_SUCCESS; } 

there is no errors when compiled but when i try to run it the command line splashes and disappears in a way it crashes

The command line shows a message FREEGLUT ERROR : Function <glutdDisplayFunc> called without first calling 'glutInit'.

But as you can see i have called glutInit function

I tried in google but did not get any proper solution for it... What is the reason for this BUG????

All suggestions are welcome

##### Share on other sites

there is no errors when compiled but when i try to run it the command line splashes and disappears in a way it crashes

The command line shows a message FREEGLUT ERROR : Function <glutdDisplayFunc> called without first calling 'glutInit'.

But as you can see i have called glutInit function

I tried in google but did not get any proper solution for it... What is the reason for this BUG????

All suggestions are welcome

What is the purpose of

 main_window = glutCreateWindow("Hello"); 

I ran your code in VS2010 with no errors. Here is my code:

 #include <gl\freeglut.h> #pragma comment(lib, "freeglut.lib") void Reshape(int w, int h) { } void Display() { } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(1024, 768); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_STENCIL|GLUT_DEPTH); glutCreateWindow("Hello"); glutDisplayFunc( Display ); glutReshapeFunc( Reshape ); glutMainLoop(); return EXIT_SUCCESS; } 

The pragma directive simply links the library.