Sign in to follow this  

Unusual FreeGlut error

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
[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

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

If you intended to correct an error in the post then please contact us.

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