2016-10-16 90 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->顯示)