Using OpenGL drawing operations in an object-oriented setup?

I plowed the main shaders and something else like the application I'm writing, and I had problems figuring out a high-level organization for drawing calls.

I am thinking of having a singleton class that implements a number of basic drawing operations, taking data from "user" classes and passing them to the corresponding opengl calls.

I wonder how people do this when they write their own applications, since the Internet has complete basic tutorials, “Your First Shader,” but very little about the proposed organization of the drawing code.

My special environment is for iPad / OpenGL ES 2.0, but I think this question is suitable for most environments.

+3
source share
1 answer

If you see drawing applications / libraries such as Qt (QPainter), Cairo and others, the basic concept is to create a Context + Painter class that embeds at least the basic drawing operations. Singleton is very discouraged because you can lose several contexts (for example, at different scales).

+1
source

Source: https://habr.com/ru/post/1741228/


All Articles