Simple OO OpenGL Setup.

Member
Posts: 89
Joined: 2005.06
Post: #1
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:

Code:
class UI {
     void UI () {
          I declare stuff here, set up variables.
     }
}


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 Mad).
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #2
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. Smile
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #3
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.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Simple OpenGL/Xcode Question. loopfick 10 6,688 Sep 8, 2005 09:54 AM
Last Post: Volte