Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How do you control everything?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Årsunda,gästrikland,Sweden
    Posts
    113

    How do you control everything?

    how do you keep everything under control do you have a class for each thing.. like Object class, Camera class, Light class, Texture class, Vertex class. And then a big "OpenGL" Class that start's the gl rendering contex and then you load in all objects, cameras, lights into that class

    like this:
    you have your own Object class with a vertex list and a pointer to a texture and so on..

    class C_Object {
    int m_iNrVertices; // Number of vertices in list
    C_Vertex3f *VertexList; // Vertex list
    C_Texture *Texture; // Pointer to a texture
    public:
    void ReadObject(void); // Read object from file (.ase or what ever you use)
    void RenderObject(void); // Object Render function
    }

    then you have a big class that you can put your object into

    class C_Scene {
    int m_iNrObjects;
    C_Object *m_pObjects[10]; // Pointer to objects in scene

    C_Camera *Camera; // Pointer to a camera
    C_Lights *Lights[8]; // Pointer to Lights

    public:
    void Render(void); // a loop function for render all objects and position the lights& cameras
    }

    if you got something like this.. tell me

    what different Classes do you have?

    and what different things are in that classes?

    Is it so usefull as it looks like or is it slow?

    when I use the classes should I create a "new" class for each object like this:
    class SpaceShip : private C_Object {
    // All stuff for a spaceship and so on
    // perheps a new renderfunction..
    };
    or is that only usefull if I need a specefic render function, can I have the same function for all objects?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: How do you control everything?

    I am not a big C++ person, but it is good to break down thing into objects or sections.

    example:

    step 1: program startup
    setup window
    setup init data for program.
    enter event loop.

    step2: event loop
    check input devices
    check our objects for movement or put into motion.
    build new world data
    render new data to screen
    repeat event loop until an exit command is recieved.

    As for what classes to build, lighting, camera, object, world have been some that I have seen used in a C++ program.
    Each class would be processed before rendering takes place.

    I hope this helps.


    Originally posted by McZ:
    how do you keep everything under control do you have a class for each thing.. like Object class, Camera class, Light class, Texture class, Vertex class. And then a big "OpenGL" Class that start's the gl rendering contex and then you load in all objects, cameras, lights into that class

    like this:
    you have your own Object class with a vertex list and a pointer to a texture and so on..

    class C_Object {
    int m_iNrVertices; // Number of vertices in list
    C_Vertex3f *VertexList; // Vertex list
    C_Texture *Texture; // Pointer to a texture
    public:
    void ReadObject(void); // Read object from file (.ase or what ever you use)
    void RenderObject(void); // Object Render function
    }

    then you have a big class that you can put your object into

    class C_Scene {
    int m_iNrObjects;
    C_Object *m_pObjects[10]; // Pointer to objects in scene

    C_Camera *Camera; // Pointer to a camera
    C_Lights *Lights[8]; // Pointer to Lights

    public:
    void Render(void); // a loop function for render all objects and position the lights& cameras
    }

    if you got something like this.. tell me

    what different Classes do you have?

    and what different things are in that classes?

    Is it so usefull as it looks like or is it slow?

    when I use the classes should I create a "new" class for each object like this:
    class SpaceShip : private C_Object {
    // All stuff for a spaceship and so on
    // perheps a new renderfunction..
    };
    or is that only usefull if I need a specefic render function, can I have the same function for all objects?


  3. #3
    Intern Contributor
    Join Date
    Sep 2001
    Location
    paris, france
    Posts
    73

    Re: How do you control everything?

    ask JW Bush !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •