c++ - How to create a class to wrap GLUT? -
I am writing a game for school in OpenGL. Since there are many more similar functions, I want to create a small framework for OpenLL in general. I have made some simple games in the past and I usually break it down to screen input and drawing in the IO classroom, to break the class of games for the main game loop / logic, and break the sections of the objects in the game I am
Before I was using SDL, so my question is, is it the right way to go to OpenGL? I have already participated in some trouble. I want my IO class to initialize the window, visual drawing, and mouse click handle. Therefore the creator looks like this:
IO :: IO () {currWindowSize [0] = DEF_WIDTH; Curl window shape [1] = DEF_HEEHET; GlutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA); GlutInitWindowPosition (INIT_WINDOW_POSITION [0], INIT_WINDOW_POSITION [1]); GlutInitWindowSize (currWindowSize [0], currWindowSize [1]); Glute Crew Wandow ("Test"); Set-up(); GlutDisplayFunc (drawScene); GlutMainLoop (); }
However, drawScene
is a class method. What is a way to pass class method without stabilizing glutDisplayFunc ()
?
Unfortunately glutDisplayFunc ()
a zero *
Not indicative so that you can have a fake object object. You have to do a static job that can call the correct IO frequency using a static variable.
I also see some minor problems with your pattern, though. As far as I know, glutMainLoop ()
does not return unless you end the GLUT reference, so you have a manufacturer who does not return practically, so Your program flow is inappropriate, you should move that call to a different run ()
method in your class.
(Personally I will use GLFW, which avoids full callback messages with GLUT, though you write your main note.)
Comments
Post a Comment