OOOP Where to start?

This is a discussion on OOOP Where to start? within the Game Programming forums, part of the General Programming Boards category; OK I have to draw a living room and its easy an all with C since you basically just do ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    68

    OOOP Where to start?

    OK

    I have to draw a living room and its easy an all with C since you basically just do

    glBegin(GL_QUADS)
    glVertex3i(put in all your coordinates for all 6 sides)
    glEnd()

    and it draws your cube for you rite?

    but how do You do it using classes?
    -Ti22-

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Depends how you want to do it. Two common ways are to have the room object draw itself or to have another viewer object draw the room model(similar to model-view-controller or MFC's document-view). So, for example, you could have an interface like this:

    Code:
    class Room {
    public:
          // ... //
           
          void draw( // ... // )
    private:
          // vertex data
    } ;
    The style used here would be for the room object to draw itself. On the other hand, having the room model notify a viewer object when it has changed could look like this

    Code:
    class RoomModel {
          void addChangeListener(ChangeListener l);
          void removeChangeListener(ChangeListener l);
    public:
         // vertex data
    };
    
    class RomeViewer : public ChangeListener {
    public:
            virtual void stateChanged(ChangeEvent e);
    };
    In the techneque above, when the RomeModel changes, the RoomViewer is notified, by stateChanged. The RoomViewer will then attempt to draw itself on the screen or update some type of display infomation.

    What technique you use depends on the circumstance. I don't know too much about OpenGL, but the first technque, I think, is usually the best if all the rendering is done all at once. The second technique might be good for a GUI application, whereby the screen is rendered only when a display object has changed.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    I am abit of a noob I can't understand your code
    -Ti22-

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    You understand the first example, right?

    For the second example, the methods to add and remove the model listeners should be public, and the data should private. When the model changes, the code, if completed, should tell its listeners, the viewers, that its data has been modified. The listeners are then able to react to this change in data by drawing themselves. But this technique isn't too useful for opengl; you're drawing the objects that are visible, rather than the objects that have changed.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    I am sure your explanation is awesome

    but I am just stupid, dull

    what does //...// mean?

    I just got into C++ for like 1 or 2 days maybe I need to read some more tutorials.

    my lecturer was kinda mean he basically threw the coursework rite in our face and we've never i repeate NEVER done C++ before

    sure we can do C not a problem but the CW Spec says C++ so I assume we have to use classes n stuff which we have no idea. anyways I am gonna get back to doing some more detail research. and come back to this thread in a few days.
    -Ti22-

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    // is a C++ style comment
    it comments out the rest of the line

  7. #7
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    The code I gave you was never meant to be compilable, but you could replace with /* */. I used that notation just to mean that you'd probably have to send in a graphic device context of some sort, I think OpenGL hides this within the library.

    but I am just stupid, dull
    Well, you have to give yourself some time to learn C++.

  8. #8
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Go to NeHe Downloads and download the resources - nehe_sdk.zip. Within this zip file lays the best OpenGL scene creator. All you have to do to create your scene is to put your code in between this one function in this one class, start with the first example, rip out the stuff you don't need, compile, edit, compile, edit, repeat 200 times, and you're an OpenGL wizard ;)

    Repeat 20000 more times, and you'll be working for a really good game designing company! lol

  9. #9
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    K i will give it a go.

    thx guys.
    -Ti22-

  10. #10
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    I'm not sure they'll allow you to use a third API in a course.

  11. #11
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    I just finished the Window GL framework but its all in Structured code

    so now I am gonna convert it to OO Code.
    -Ti22-

  12. #12
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    Quote Originally Posted by sean_mackrory
    I'm not sure they'll allow you to use a third API in a course.

    I am not using it I am just taking a look at the code and seeing how it is applied.
    -Ti22-

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Since the API is written by people who have a great deal of experience in C++, looking at them will probably only serve to confuse you more.

  14. #14
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    well

    I am now writing the OpenGL for Windows framework in C++ and I am slowly getting the hang of it. but I do get confused too like you say. I'll try it if it fails then. I don't know what to do

    dunno why our lectuere forced this on us.

    I think its wrong to just let us do OO program with OpenGL when we've never done it before.
    Last edited by Ti22; 01-10-2005 at 08:30 AM.
    -Ti22-

  15. #15
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    ok I am completely lost now lol...

    pls tell me what I am doing wrong.


    http://ti-x.net/files/WGLOOSkeleton.rar
    Last edited by Ti22; 01-10-2005 at 11:31 AM.
    -Ti22-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 10:48 PM
  4. GNOME Desktop won't start (Mandriva)
    By psychopath in forum Tech Board
    Replies: 10
    Last Post: 07-19-2006, 01:21 PM
  5. Start bar color in WinXP
    By confuted in forum Tech Board
    Replies: 4
    Last Post: 05-03-2003, 06:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21