Sign in to follow this  
vicer1234

Unusual FreeGlut error

Recommended Posts

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

The code structure looks like
[code]
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;
}
[/code]


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 [size="3"][b] FREEGLUT ERROR : Function <glutdDisplayFunc> called without first calling 'glutInit'.

[/b]But as you can see i have called glutInit function [b]

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

All suggestions are welcome
[/size]

Share this post


Link to post
Share on other sites
Butabah    100
[quote name='vicer1234' timestamp='1310475359' post='4834269']
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 [size="3"][b] FREEGLUT ERROR : Function <glutdDisplayFunc> called without first calling 'glutInit'.

[/b]But as you can see i have called glutInit function [b]

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

All suggestions are welcome
[/size]
[/quote]

What is the purpose of

[code]
main_window = glutCreateWindow("Hello");
[/code]

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

[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;
}
[/code]

The pragma directive simply links the library.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this