36 #ifndef IECOREGL_TYPEDSTATECOMPONENT_H
37 #define IECOREGL_TYPEDSTATECOMPONENT_H
39 #include "IECoreGL/Export.h"
40 #include "IECoreGL/StateComponent.h"
42 #include "OpenEXR/ImathColor.h"
43 #include "OpenEXR/ImathBox.h"
48 template<
typename T,
unsigned int TId>
49 class TypedStateComponent :
public StateComponent
55 typedef boost::intrusive_ptr<TypedStateComponent> Ptr;
56 typedef boost::intrusive_ptr<const TypedStateComponent> ConstPtr;
58 TypedStateComponent();
59 TypedStateComponent(
const T &value );
65 const char *typeName()
const override;
67 bool isInstanceOf(
const char *typeName )
const override;
69 static const char *staticTypeName();
73 static const char *baseTypeName();
74 typedef StateComponent BaseClass;
80 void bind()
const override;
83 const T &value()
const;
85 static T defaultValue();
91 static Description<TypedStateComponent<T, TId> > g_description;
96 #define IECOREGL_TYPEDSTATECOMPONENT_SPECIALISE( TYPE, BASETYPE, DEFAULTVALUE ) \
98 IECOREGL_API const char *TYPE::typeName() const \
104 IECOREGL_API const char *TYPE::staticTypeName() \
110 IECOREGL_API BASETYPE TYPE::defaultValue() \
112 return DEFAULTVALUE; \
115 #define IECOREGL_TYPEDSTATECOMPONENT_SPECIALISEANDINSTANTIATE( TYPE, TYPEID, BASETYPE, DEFAULTVALUE ) \
116 IECOREGL_TYPEDSTATECOMPONENT_SPECIALISE( TYPE, BASETYPE, DEFAULTVALUE ) \
117 template IECOREGL_API class TypedStateComponent<BASETYPE, TYPEID>; \
119 typedef TypedStateComponent<Imath::Color4f, ColorTypeId> Color;
121 IECOREGL_API
void Color::bind()
const;
145 struct IECOREGL_API BlendFactors
147 BlendFactors( GLenum src, GLenum dst );
148 BlendFactors(
const BlendFactors &other );
153 struct IECOREGL_API AlphaFunc
155 AlphaFunc( GLenum m, GLfloat value );
156 AlphaFunc(
const AlphaFunc &other );
161 typedef TypedStateComponent<BlendFactors, BlendFuncStateComponentTypeId> BlendFuncStateComponent;
163 IECOREGL_API
void BlendFuncStateComponent::bind()
const;
165 typedef TypedStateComponent<Imath::Color4f, BlendColorStateComponentTypeId> BlendColorStateComponent;
167 IECOREGL_API
void BlendColorStateComponent::bind()
const;
169 typedef TypedStateComponent<GLenum, BlendEquationStateComponentTypeId> BlendEquationStateComponent;
171 IECOREGL_API
void BlendEquationStateComponent::bind()
const;
173 typedef TypedStateComponent<bool, AlphaTestStateComponentTypeId> AlphaTestStateComponent;
175 IECOREGL_API
void AlphaTestStateComponent::bind()
const;
177 typedef TypedStateComponent<AlphaFunc, AlphaFuncStateComponentTypeId> AlphaFuncStateComponent;
179 IECOREGL_API
void AlphaFuncStateComponent::bind()
const;
184 IECOREGL_API
void DoubleSidedStateComponent::bind()
const;
190 IECOREGL_API
void RightHandedOrientationStateComponent::bind()
const;
195 IECOREGL_API
void LineSmoothingStateComponent::bind()
const;
200 IECOREGL_API
void PointSmoothingStateComponent::bind()
const;
205 IECOREGL_API
void PolygonSmoothingStateComponent::bind()
const;
210 IECOREGL_API
void DepthTestStateComponent::bind()
const;
215 IECOREGL_API
void DepthMaskStateComponent::bind()
const;
224 typedef TypedStateComponent<RendererSpace, CullingSpaceStateComponentTypeId> CullingSpaceStateComponent;
227 typedef TypedStateComponent<Imath::Box3f, CullingBoxStateComponentTypeId> CullingBoxStateComponent;
239 IE_CORE_DECLAREPTR( Color );
240 IE_CORE_DECLAREPTR( BlendColorStateComponent );
241 IE_CORE_DECLAREPTR( BlendFuncStateComponent );
242 IE_CORE_DECLAREPTR( BlendEquationStateComponent );
243 IE_CORE_DECLAREPTR( BoundColorStateComponent );
244 IE_CORE_DECLAREPTR( WireframeColorStateComponent );
245 IE_CORE_DECLAREPTR( OutlineColorStateComponent );
246 IE_CORE_DECLAREPTR( PointColorStateComponent );
247 IE_CORE_DECLAREPTR( DoubleSidedStateComponent );
248 IE_CORE_DECLAREPTR( LineSmoothingStateComponent );
249 IE_CORE_DECLAREPTR( PointSmoothingStateComponent );
250 IE_CORE_DECLAREPTR( DepthTestStateComponent );
251 IE_CORE_DECLAREPTR( DepthMaskStateComponent );
252 IE_CORE_DECLAREPTR( CullingSpaceStateComponent );
253 IE_CORE_DECLAREPTR( CullingBoxStateComponent );
254 IE_CORE_DECLAREPTR( ProceduralThreadingStateComponent );
255 IE_CORE_DECLAREPTR( CameraVisibilityStateComponent );
256 IE_CORE_DECLAREPTR( AutomaticInstancingStateComponent );
260 #include "IECoreGL/TypedStateComponent.inl"
262 #endif // IECOREGL_TYPEDSTATECOMPONENT_H
TypedStateComponent< Imath::Color4f, PointColorStateComponentTypeId > PointColorStateComponent
Specifies the color to draw points in.
Definition: TypedStateComponent.h:136
TypedStateComponent< bool, DepthMaskStateComponentTypeId > DepthMaskStateComponent
Used to set glDepthMask to GL_TRUE or GL_FALSE.
Definition: TypedStateComponent.h:213
TypedStateComponent< Imath::Color4f, WireframeColorStateComponentTypeId > WireframeColorStateComponent
Specifies the color to draw wireframes in.
Definition: TypedStateComponent.h:132
TypedStateComponent< bool, ProceduralThreadingStateComponentTypeId > ProceduralThreadingStateComponent
Defines whether or not procedurals will be executed in parallel threads.
Definition: TypedStateComponent.h:230
The namespace within which all CoreGL functionality is defined.
Definition: AlphaTexture.h:41
TypedStateComponent< Imath::Color4f, BoundColorStateComponentTypeId > BoundColorStateComponent
Specifies the color to draw bounding boxes in.
Definition: TypedStateComponent.h:130
TypedStateComponent< bool, AutomaticInstancingStateComponentTypeId > AutomaticInstancingStateComponent
Definition: TypedStateComponent.h:237
TypedStateComponent< bool, PolygonSmoothingStateComponentTypeId > PolygonSmoothingStateComponent
Used to specify enable state of GL_POLYGON_SMOOTH.
Definition: TypedStateComponent.h:203
static TypeId baseTypeId(TypeId typeId)
Returns the base type of the given type, or InvalidTypeId if no such base exists. ...
TypedStateComponent< bool, CameraVisibilityStateComponentTypeId > CameraVisibilityStateComponent
Defines camera visibility.
Definition: TypedStateComponent.h:233
TypeId
Definition: TypeIds.h:46
TypedStateComponent< bool, TransparentShadingStateComponentTypeId > TransparentShadingStateComponent
Definition: TypedStateComponent.h:128
TypedStateComponent< Imath::Color4f, OutlineColorStateComponentTypeId > OutlineColorStateComponent
Specifies the color to draw outlines in.
Definition: TypedStateComponent.h:134
TypedStateComponent< bool, PointSmoothingStateComponentTypeId > PointSmoothingStateComponent
Used to specify enable state of GL_POINT_SMOOTH.
Definition: TypedStateComponent.h:198
TypedStateComponent< bool, DepthTestStateComponentTypeId > DepthTestStateComponent
Used to specify enable state of GL_DEPTH_TEST.
Definition: TypedStateComponent.h:208
TypedStateComponent< bool, RightHandedOrientationStateComponentTypeId > RightHandedOrientationStateComponent
Definition: TypedStateComponent.h:188
TypedStateComponent< bool, DoubleSidedStateComponentTypeId > DoubleSidedStateComponent
Used to specify enable state of GL_CULL_FACE.
Definition: TypedStateComponent.h:182
static bool inheritsFrom(TypeId type, TypeId baseType)
Returns true if type inherits from baseType.
TypedStateComponent< bool, LineSmoothingStateComponentTypeId > LineSmoothingStateComponent
Used to specify enable state of GL_LINE_SMOOTH.
Definition: TypedStateComponent.h:193