PDA

View Full Version : a problem about GLUT



thunder2001
03-31-2004, 02:56 PM
i find the glut functions can't be usable in VC++6.0,such as glutdisplayfunc();glutpostredisplay();glutmainloop ();......
can you tell me the reasons?

chowe6685
03-31-2004, 03:19 PM
what do you mean can't be usuable? Does the program crash, not compile, what happens?

I'm going to guess that you aren't linking with the glut32 library but you should give more detail for a proper answer

nexusone
03-31-2004, 03:37 PM
GLUT work's fine in VC++, when you have everything setup correctly.
So the problem must be something you are doing, please post the error you are getting.


Originally posted by thunder2001:
i find the glut functions can't be usable in VC++6.0,such as glutdisplayfunc();glutpostredisplay();glutmainloop ();......
can you tell me the reasons?

thunder2001
04-01-2004, 03:36 PM
I apply the GLUT function {glutDisplayFunc(display);} in the Ondraw function.I have defined
the display function in the head file:void display();
the system give me the error:error C2664: 'glutDisplayFunc' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'
None of the functions with this name in scope match the target type

why???????
thank for your help!!

Deiussum
04-02-2004, 04:36 AM
Let me make sure I am understanding you correctly... You say you are putting functions like glutDisplayFunc in an OnDraw() function? Is this an MFC app? Generally, you create glut apps as a console program and put the functions like glutDisplayFunc() in main().

Also, are you trying to create your display function as a member function of one of your classes? If so, that will not work because non-static class member functions use a different calling convention, which is used to pass a "this" pointer to the function.

Anyway, if this doesn't help you any, post some code (within [CODE] tags) and try and be more specific on what your problem is.

nexusone
04-02-2004, 08:34 AM
GLUT is a windowing API to be used in place of the standard windows API. So you can not mix the Windows API with the glut API. There are examples of using only the windows API at nehe.gamedev.net for openGL programming also has glut examples as well.

You also could have some issues with glut because it is a C based API and you can use it with C++, but you have to in mind that you can not do some types C++ operations with the routines without some type of wraper class.

If you could post a little more code as to how you are calling the glutDisplayFunc would be helpful.

04-07-2004, 02:08 AM
I am getting a similar problem with Glut. When I run this simple code from the book: OpenGL by E. Angel I get 4 error messages with respect to the four Glut functions saying [Undeclared Identifier] and one warning. Can someone tell me what do I need to do to make it work. Thank you very much.

/*simple.c*/

#include <GL\glut.h>

void display()
{
glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();

glFlush();
}

int main(int argc, char **argv)
{
/* Intialize the program */
glutInit(&argc, argv);
glutCreateWindow("simple");

/* Register the callbacks */
glutDisplayFunc(display);

glutMainLoop();
}

mw
04-07-2004, 03:29 AM
make sure that you download and install the correct glut header and library files (don't forget to set add glut.lib to the linker as well), since glut is no standard library delivered with VC (which you are probably using)