00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef RE_OGLState_h
00021 #define RE_OGLState_h
00022
00023 #include "RE_API.h"
00024 #include "RE_Types.h"
00025 #include "RE_TextureTypes.h"
00026 #include "RE_Uniform.h"
00027
00028 #include <UT/UT_Rect.h>
00029 #include <UT/UT_RefArray.h>
00030
00031 class RE_OGLFramebuffer;
00032 class RE_OGLTexture;
00033 class RE_Shader;
00034
00035 class RE_API RE_OGLState
00036 {
00037 public:
00038 RE_OGLState(bool list_state);
00039 ~RE_OGLState();
00040
00041 bool isListState() const { return myDisplayListState; }
00042 void invalidate();
00043 void raiseAssertsForStateDifferences(const RE_OGLState &state);
00044 void verifySync();
00045
00046 void pushColorBuf();
00047 void pushEnable();
00048 void pushCurrent();
00049 void pushFog();
00050 void pushHint();
00051 void pushDepthBuf();
00052 void pushLines();
00053 void pushLighting();
00054 void pushPointStyle();
00055 void pushPolygon();
00056 void pushStencilBuf();
00057 void pushTexture();
00058 void pushViewport();
00059
00060 unsigned int getPushedBits() const { return myPushedBits; }
00061
00062
00063 GLint _matrixMode;
00064 int _colorBufferWriting;
00065
00066
00067 unsigned
00068 myAlphaTestState : 2,
00069 myColorMaterialState : 2,
00070 myDepthCueingState :2,
00071 myDepthTestState : 2,
00072 myDitherState : 2,
00073 myFillOffsetState : 2,
00074 myLightingState : 2,
00075 myLineOffsetState : 2,
00076 myLineSmoothingState : 2,
00077 myPointOffsetState : 2,
00078 myPointSmoothingState : 2,
00079 myScissorState : 2,
00080 myStencilState : 2,
00081 mySeamlessMapState : 2;
00082
00083 unsigned concave:2,
00084 backface:2,
00085 reverse_winding:2;
00086
00087 float wPosX, wPosY, wPosZ;
00088 float rx, ry, rz;
00089
00090 UT_DimRect scissorState;
00091 UT_DimRect viewportState;
00092
00093 bool scissorEnabled;
00094
00095 int viewportStateValid;
00096 int scissorStateValid;
00097
00098 float myXZoom, myYZoom;
00099
00100 float zNear, zFar;
00101 float _offset_variable;
00102 float _offset_constant;
00103
00104
00105 unsigned lightingOn:2;
00106 RE_InterpMode myShadeModel;
00107 unsigned myColorMask;
00108
00109 RE_ZFunction _z_function;
00110 int _s_clear_value;
00111 int _s_write_mask;
00112 RE_SFunction _s_function;
00113 int _s_function_ref;
00114 int _s_function_mask;
00115 RE_SOperation _s_operation_sfail;
00116 RE_SOperation _s_operation_dpfail;
00117 RE_SOperation _s_operation_dppass;
00118
00119
00120 RE_OGLFramebuffer *myDrawFBOStack[RE_FRAMEBUFFER_STACK_SIZE];
00121 int myDrawFBOStackIndex;
00122 RE_OGLFramebuffer *myReadFBOStack[RE_FRAMEBUFFER_STACK_SIZE];
00123 int myReadFBOStackIndex;
00124
00125 RE_CMMatrix projectionStack[PROJECTION_STACK_SIZE];
00126 int projectionIndex;
00127 float lineWidthStack[PATTERN_STACK_SIZE];
00128 int lineWidthIndex;
00129 unsigned short lineStyleStack[PATTERN_STACK_SIZE];
00130 int lineStyleIndex;
00131 short patternStack[PATTERN_STACK_SIZE];
00132 int patternIndex;
00133 RE_ColorStack colorStack[RE_COLOR_STACK_SIZE];
00134 int colorStackIndex;
00135 float pointSizeStack[PATTERN_STACK_SIZE];
00136 int pointSizeIndex;
00137
00138 struct
00139 {
00140 unsigned char read:4,
00141 write:4;
00142 } myAlignmentStack[RE_ALIGN_STACK_SIZE];
00143 int myAlignmentStackIndex;
00144
00145 float myGLColor[4];
00146
00147
00148 struct re_TexStackItem
00149 {
00150 int myActiveUnit;
00151 int myRestoreUnit;
00152
00153 struct re_TexUnit
00154 {
00155 RE_OGLTexture *texture;
00156 unsigned type : 4,
00157 mode : 4,
00158 texcoords:1;
00159 } myUnits[RE_MAX_TEXTURES];
00160
00161 } myTexStack[RE_MAX_TEXTURE_STATE_STACK];
00162
00163 int myTexStackIndex;
00164
00165
00166 int myBlendSmoothLevel;
00167 re_BlendSmoothState myBlendSmoothStack[RE_SMOOTH_STACK_SIZE];
00168
00169
00170 int myStencilLevel;
00171 re_StencilState myStencilStack[RE_STENCIL_STACK_SIZE];
00172
00173
00174 int myShaderLevel;
00175 RE_Shader *myShaderStack[RE_SHADER_STACK_SIZE];
00176
00177 unsigned myShaderStackValid : 1,
00178 myFBOStackValid : 1;
00179
00180 private:
00181 bool myDisplayListState;
00182
00183
00184 unsigned myPushedBits;
00185
00186 void privPushColorBuf();
00187 void privPushEnable();
00188 void privPushCurrent();
00189 void privPushFog();
00190 void privPushHint();
00191 void privPushDepthBuf();
00192 void privPushLines();
00193 void privPushLighting();
00194 void privPushPointStyle();
00195 void privPushPolygon();
00196 void privPushStencilBuf();
00197 void privPushTexture();
00198 void privPushViewport();
00199 };
00200
00201 #define IMPL_INLINE_PUSH(name) \
00202 inline void RE_OGLState::push##name() \
00203 { if(myDisplayListState) privPush##name(); }
00204
00205 IMPL_INLINE_PUSH(ColorBuf);
00206 IMPL_INLINE_PUSH(Enable);
00207 IMPL_INLINE_PUSH(Current);
00208 IMPL_INLINE_PUSH(Fog);
00209 IMPL_INLINE_PUSH(Hint);
00210 IMPL_INLINE_PUSH(DepthBuf);
00211 IMPL_INLINE_PUSH(Lines);
00212 IMPL_INLINE_PUSH(Lighting);
00213 IMPL_INLINE_PUSH(PointStyle);
00214 IMPL_INLINE_PUSH(Polygon);
00215 IMPL_INLINE_PUSH(StencilBuf);
00216 IMPL_INLINE_PUSH(Texture);
00217 IMPL_INLINE_PUSH(Viewport);
00218
00219 #endif