views:

52

answers:

1

I've been plowing through basic shaders and whatnot for an application I'm writing, and I've been having trouble figuring out a high-level organization for the drawing calls.

I'm thinking of having a singleton class which implements a number of basic drawing operations, taking data from "user" classes and passing that to the appropriate opengl calls.

I'm wondering how people do this when writing their own applications, as the internet is chock full of basic "Your first shader" tutorials, but very little on suggested organization of drawing code.

My particular environment is targeted at iPad/OpenGL ES 2.0, but I think the question stands for most environments.

A: 

If you see Drawing Applications / Libraries like Qt (QPainter), Cairo, and Others, the main concept is to create a class Context + Painter that embed at least the basic drawing operations. Singleton is heavily discouraged because you could end up wanting to have multiple Contexts (for example at different scales).

fabrizioM