2016-10-16 92 views
1

喜,问题与GLUT回调函数

我想创建与OpenGL和CUDA采用C++,但是当我试图通过函数初始化我收到一个错误的场景。 这里是我的头:

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); 
}; 

在我.cpp文件我有这样的事情,这generete同样的错误:

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); 
    } 
} 

的问题是在显示,闲置,keybord和重塑。报告的错误是这样的:

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 
+0

HTTPS ://msdn.microsoft.com/en-us/library/b0x1aatf.aspx – rasjani

回答

1

从以往的经验,我可以告诉你过剩的作品与OOP架构非常糟糕的还有另一个问题,可以帮助对C++的指针,这是链接到它How to make a pointer to a method in class一个答案。

0

你应该这样的程序:

  • glutDisplayFunc(这个 - >显示)

而不是

  • glutDisplayFunc(obj->显示)