The original ssg state system was relying on an abstract base class named ssgState with two realizations : ssgSimpleState and ssgStateSelector. The OpenGL states managed by ssgSimpleState were fixed and limited to a simple set available in early OpenGL : material colors, single texturing, alpha test, blending and lighting. Moreover, parameters for some were fixed and couldn't be changed.
The new scheme relies on the concept of state attributes and is borrowed from the OpenSceneGraph project. ssgState is now an instanciable class and hold collections of ssgStateAttribute(s) and ssgTextureStateAttribute(s). The difference between these two classes is that the same kind of texture attribute can be set to different texture units. State attribute classes hold specific parameter for that state and the system is now easily expandable. With a small change to it, we could even support user-provided state attributes.
The new classes are summarized below :
for back and front
for back and front
|ssgShadeModel||SSG_STATE_SHADE_MODEL||flat or smooth|
for rgb and alpha
The class ssgState has a new set of methods that manage attributes. They are :
In order to preserve source compatibility, ssgSimpleState is now a ssgState with the old set of supported opengl states already initialized.
New capabilities supported by current OpenGL includes :
In a first phase, only the first two constraints are addressed but the two last are kept in mind in the design choices. The first choice is to create generic 2D, 3D and 4D arrays ( called ssgVec2Array, ssgVec3Array and ssgVec4Array ). Old ssgVertexArray, ssgNormalArray and ssgColourArray are derived from these generic classes, but ssgTexCoordArray ( a 2D array ) is only kept for compatibility reason. The new interfaces accept any 2D, 3D or 4D arrays.
Next is to extend ssgVtxTable and ssgVtxArray classes. For the moment, two new classes are created, ssgVtxTableEx and ssgVtxArrayEx, but their vocation is to replace their old counterpart. They support multiple set of coordinates and ssgVtxArrayEx, used to draw indexed elements, support multiple primitives with their own type and set of indices. Indeed, their is no point of using indexed primitive if we must provide a new set of vertices and vertices attributes every time. The new ssgVtxArrayEx enables to provide only one set of attributes for multiple primitives and thus, will ease the use of VBO.
New or changed methods for class ssgVtxTableEx vs ssgVtxTable :
New or changed methods for class ssgVtxArrayEx vs ssgVtxArray :