带有 winform C++/CLR 的 OpenGL

OpenGL with winform C++/CLR

是否可以调用函数

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Window");
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);
    glutMotionFunc(mouseMovement); //check for mousemovement
    glutKeyboardFunc(keyboard);
    glutMainLoop();
    return 0;
}

在按钮点击事件中?其中显示、键盘等是不同的功能

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
    {
          main(); -------(Not sure of syntax)
    }

我明白了。只需创建一个 class 调用函数作为按钮单击事件中的对象,它就按我想要的方式工作。无论如何感谢您的帮助

刚刚在头文件中声明了一个class

class foo
{
public:
    foo();
    ~foo();
    int main(int argc, char **argv);

};

将.cpp中的main函数定义为

 foo::foo()
    {
    }


    foo::~foo()
    {
    }

     - - - -  - - - - - - - - - - - - - -
    ------Other functions here-----
     - - - -  - - - - - - - - - - - - - -
    //main function    
    int foo::main(int argc, char **argv) {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
        glutInitWindowSize(500, 500);
        -------------
        ----------
        glutMainLoop();
        return 0;
}

最后在按钮点击事件中调用

private: System::Void btn_Load_Click(System::Object^  sender, System::EventArgs^  e)  
{

    foo Objct;
    int Arg1;
    char** Arg2;
    int functn = Objct.main(Arg1, Arg2);
}