Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is it possible to call the function

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

inside a button click event like below ? where display,keyboard etc are different functions

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


What I have tried:

tried declaring the main function in .h file instead of .cpp but didn't work.
Posted
Updated 16-Dec-19 6:41am
Comments
11917640 Member 17-Dec-19 1:04am    
GLUT is simple lightweight GUI framework for using (and mostly learning) OpenGL. If you want to use OpenGL in UI program (Windows API, C++/CLI, MFC or any other UI toolkit), use OpenGL directly without GLUT.
SIDHARTH S 18-Dec-19 1:28am    
OpenGL directly without GLUT ? Can you please elaborate or share a link for the said information. To my knowledge OpenGL was just a library without an GUI .

1 solution

No, one should not call main from anywhere. It is the designated entry point for CLI programs. For GUI programs in windows the entry point is WinMain.

This is a bit confusing. How is it you have a button in a window with a CLI program?

If you want to learn how to use OpenGL in a WinForms app there are several articles here that describe it. A search at this site turns up these: CodeProject Search[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900