These are fewer OpenGL questions and more C ++ related questions.
I will have a simple scene graph (n-tree) with nodes that (for the sake of this question) will display some geometry. To be more specific, each of them has some OpenGL drawing commands inside the draw() method.
For optimization reasons, I would like to combine similar objects together and draw them all at once. For this reason, I would like to express what I call "state sets" for OpenGL. A set of states is just a bunch of OpenGL bundles, or the commands that are installed before drawing are called on X objects and after that they become uninstalled.
Thus, a set of states has at least set() and unset() and will be called by the rendering system before and after commands to draw nodes that use this set of states.
My question is how to express these states of sets? Of course, there can be many functions, but I would prefer to name the set and recall it. For example, node A has a set of states LIGHTING_AND_SHADOW and node B has CEL_SHADING .
For this reason, creating an abstract class called stateSet , which is essentially an interface to the set() and unset() methods and inheriting each set of states, seems like a good idea. But this requires the creation of many objects in order to get the name in essence. It seems that there may be a better way.
Ideally, I would like to have a list of all stateSets that can be easily called. For example, before starting the rendering, it would be nice to sort all the nodes in the scene graph using stateSet .
Any ideas?
source share