Hi guys, probably is a stupid question but…is it possible to call the fuction display if it isn’t in the same class of glutDisplayFunc? I mean, is it possible:
Try it and see. I don’t know why you’d introduce that complexity, but any “function pointer” type object taking no args should do (a static method qualifies; an instance method doesn’t). Only question is whether C++ typing will get in your way.
it doesn’t work to me . I tried to declare in the main:
extern void display(display);
I tried to create an header file, but it doesn’t work too… i’m a newbie, but i think that the problem is the definition of the function display. when the program is all in one file, there isn’t the problem, but when I split it, the compiler expect a definition of it, that there isn’t… But I don’t know how to write it! anyone knows how to solve the problem?
Use glutDisplayFunc(ClassB::display); This is the syntax for referencing static member functions. Of course make sure that the class header is included in main’s source file.
Hi arthas,
The problem is compiler unable to find display function definition. static function should have the definition in file scope. move your display function definition inside the header file.I hope your including the header file,a file which u given display function declaration.
Hi avis, I’ve included in the file main.cpp, the line
#include "Draw.h"
and I created, a file Draw.h, that contains the declaration
static void display(void);
the result is :
>Compiling…
>main.cpp
>c:…main.cpp(55) : error C2129: static function ‘void display(void)’ declared but not defined
> c:…draw.h(1) : see declaration of ‘display’
so the problem is the definiton… I only need to clean the code, moving the function display in another file, there isn’t a way?
Solved!!! The problem was Static!!! the function declared static is in the scope of the file it is declared/defined in, so only a c++ problem, not opengl