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: advice on program structure

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2006
    Posts
    3

    advice on program structure

    hi, *very* new to opengl. looking for some advice on how to structure code. this is for a class i will be teaching that uses opengl. i have a bunch of books, but the code that looks the cleanest so far is in buss' stuff: <http://www.math.ucsd.edu/~sbuss/MathCG/OpenGLsoft/>.

    the pipeline and fsm is a bit much to grok all at once, but i suppose the structure of the main code would follow the pipeline: <http://en.wikipedia.org/wiki/Graphics_pipeline>? perhaps there is a sample that takes a simple object or two through the pipline and does something at each stage?

    ideally i would like a *simple* o-o wrapper for the opengl api, but i haven't found one yet.

    any pointers will be appreciated.

    thanks

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: advice on program structure

    Because it's portable to different languages OpenGL is not o-o and it seems like most of utility libraries and framerorks aren't.
    To minimize amount of platform-dependent code I would recommend to use GLUT (that's exactly what's used in that example) - it handles all window management, etc. and leaves you with just OpenGL programming. It's very basic, so it's good for teaching. Additionally many demos and examples are based on it.

    i suppose the structure of the main code would follow the pipeline (...) perhaps there is a sample that takes a simple object or two through the pipline and does something at each stage?
    Basically, being aware that OpenGL is a state machine should be enough. You do not program each stage of pipeline separately or so.
    There are some comands in OpenGL (like, glEnable, glRotate, glDepthFunc...) that configure pipeline and all primitives rendered by your application are processed by this pipeline.

  3. #3
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: advice on program structure

    As OpenGL was initially build as a state machine there is no real need for OO wrapper... IMHO,an OO wrapper would make the API more dificult to understand. From all libraries I used so far, OpenGL was the cleanest one and most well-designed. For Window handling, use GLUT or GLFW. Look at Nehe pages, he has very nice tutorials for beginners that explain OpenGL from scratch

Posting Permissions

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