Reputation:
Hei,
I am trying to create a scene with OpenGL and CUDA using C++ but i receive an error when i try to pass the function for initialization. Here is my header :
class SimpleScene
{
public:
SimpleScene();
~SimpleScene();
void computeFPS();
void render();
void display();
void idle();
void keyboard(unsigned char key, int x, int y);
void reshape(int x, int y);
void cleanup();
void initGLBuffers();
uchar *loadRawFile(const char *filename, size_t size);
void initGL(int *argc, char **argv);
int chooseCudaDevice(int argc, char **argv, bool bUseOpenGL);
void runAutoTest(const char *ref_file, char *exec_path);
void loadVolumeData(char *exec_path);
};
And in my .cpp file i have something like this and this generete same errors:
void SimpleScene::initGL(int * argc, char ** argv)
{
SimpleScene* obj = new SimpleScene;
// initialize GLUT callback functions
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(width, height);
glutCreateWindow("CUDA 3D texture");
glutDisplayFunc(obj->display);
glutKeyboardFunc(obj->keyboard);
glutReshapeFunc(obj->reshape);
glutIdleFunc(obj->idle);
if (!isGLVersionSupported(2, 0) || !areGLExtensionsSupported("GL_ARB_pixel_buffer_object"))
{
fprintf(stderr, "Required OpenGL extensions are missing.");
exit(EXIT_FAILURE);
}
}
The problems are in the display,idle,keybord and reshape. The errors reported are like this:
Error C3867 'SimpleScene::display': non-standard syntax; use '&' to create a pointer to member
Error C3867 'SimpleScene::idle': non-standard syntax; use '&' to create a pointer to member
Error C3867 'SimpleScene::keyboard': non-standard syntax; use '&' to create a pointer to member
Error C3867 'SimpleScene::reshape': non-standard syntax; use '&' to create a pointer to member
Upvotes: 1
Views: 446
Reputation: 3
You should program like this:
rather than
Upvotes: 0
Reputation: 103
From experience I can tell you glut works really bad with OOP architecture there is an answer on another question that can help about c++ pointers this is the link to it How to make a pointer to a method in class.
Upvotes: 1