Simple OO OpenGL Setup. - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Simple OO OpenGL Setup. (/thread-5042.html)
Simple OO OpenGL Setup. - Volte - Sep 12, 2005 03:56 AM
Hey there. I am looking to make a very simple program as to which I can move a camera around. I've done a few Tuts, but non of them really anticipate greater development. If I were to make a small 3D space in which I could rotate my view, how would the best way of setting up an OO structure be. I suppose the objects I would want would be similar to:
UI - User Interface displays relevant text such as view angle. Could send other objects to it at which point it would display it.
Camera - Really nothing, just the coordinates of the camera, and its viewing angle.
Could I do this? would this be the correct approach? Having a UI object, and a Camera object of which I both instantiate once in the main function? I am really not sure how OOP works in C++, lol I took a class a long time ago in HS, but we immediately dived into JAVA :shudder:
I make a file a class, which can be called as an object so I do something like:
and that would be the extent of the UI class (besides other things that I would actually add rather than sudo code)?
What about the "main" file? if everything is a class, how does it know where to start? do I make a non-class file with a standard main function in it which from there I create all my calls? As I recall in Java, you created a file with the same name as your program. Is this the same case in C++ OOP?
I know, they're a lot of nobbish questions, but I promise you, get me past this part, and I am home-free. Also, if you don't feel like answering, at least direct me to a relivent tut. I'd be much appreciated (my C++ book doenst come in till 1-6 weeks Grrr Borders ).
Simple OO OpenGL Setup. - Fenris - Sep 12, 2005 09:41 AM
I'm in a bit of a rush here, but:
1) Check out the tutorials at nehe.gamedev.net
2) Try GLUT/SDL
3) If everything is a class, you still need a main() function somewhere.
4) Stop by #idevgames at Freenode.net, and we'll talk.
Simple OO OpenGL Setup. - szymczyk - Sep 12, 2005 10:58 AM
Volte Wrote:What about the "main" file? if everything is a class, how does it know where to start? do I make a non-class file with a standard main function in it which from there I create all my calls? As I recall in Java, you created a file with the same name as your program. Is this the same case in C++ OOP?You normally create an Application class and a file named main.cpp that calls the main() function. The Application class does things like initialize the program and run the event loop. The main() function declares an object of the Application class and calls member functions of the Application class. I know you downloaded my AGL tutorial. Look at the main.cpp file to see how the main() function works.
If you're interested in seeing how 3D engines are structured, take a look at this list of engines. Many of them are open source and object-oriented. I know Ogre and Crystal Space use C++ and are open source. You can look at them and see how they're structured.