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.
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.
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