开发者

Using OpenGL drawing operations in an object-oriented setting?

开发者 https://www.devze.com 2022-12-27 12:41 出处:网络
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 organiza开发者_开发技巧tion for the drawing calls.

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 organiza开发者_开发技巧tion 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号