00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __SGL_STATELET_HPP
00027 #define __SGL_STATELET_HPP
00028
00029 #include <sgl.h>
00030 #include <sglObject.hpp>
00031 #include <sglMatrix.hpp>
00032
00033 class sglCurrState;
00034
00035
00036
00177 class SGL_DLL_API sglStatelet : public sglObject
00178 {
00179 public:
00185 enum StateEnum
00186 {
00187 eALPHA_TEST,
00188 eANTI_ALIAS_LINE,
00189 eANTI_ALIAS_POINT,
00190 eANTI_ALIAS_POLYGON,
00191 eBLENDING,
00192 eCOLOR_MASK,
00193 eCULL_MODE,
00194 eDEPTH_MASK,
00195 eDEPTH_RANGE,
00196 eDEPTH_TEST,
00197 eDITHERING,
00198 eFOG,
00199 eFRONT_FACE,
00200 eHIGHLIGHT,
00201 eLIGHTING,
00202 eLINE_STIPPLE,
00203 eLINE_WIDTH,
00204 eLOGIC_OP,
00205 eMATERIAL,
00206 eOCCLUSION_CULL,
00207 ePOINT_SIZE,
00208 ePOINT_PARAMETERS,
00209 ePOLY_BACK_STYLE,
00210 ePOLY_FRONT_STYLE,
00211 ePOLYGON_OFFSET,
00212 ePOLYGON_STIPPLE,
00213 eSHADE_MODEL,
00214 eTRANSFORM_MATRIX,
00215 eTRANSPARENCY,
00216
00217
00218
00219 eTEX_ENV,
00220 eTEX_GEN,
00221 eTEXTURE,
00222 eTEXTURE_MATRIX,
00223 eNUM_BASIC_STATES
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 };
00235
00236 public:
00238 virtual ~sglStatelet() {}
00239
00245 virtual unsigned int getType() const { return m_type; }
00246
00253 virtual void apply(sglCurrState* curr_state) const = 0;
00254
00262 virtual bool getSorted() const { return false; }
00263
00269 inline const void* getSortKey() const
00270 {
00271 if (m_index == UINT_MAX)
00272 return this;
00273 else
00274 return (const void*)m_index;
00275 }
00276
00283 unsigned int getIndex() const { return m_index; }
00284
00289 bool operator==(const sglStatelet &rhs) const
00290 {
00291 return (this == &rhs) || (m_type == rhs.m_type &&
00292 m_index == rhs.m_index &&
00293 m_index != UINT_MAX);
00294 }
00295
00296
00297 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00298
00299 protected:
00300
00301 sglStatelet(StateEnum type)
00302 : m_index(0), m_type(type) {}
00303
00304 private:
00305 sglStatelet();
00306 sglStatelet(const sglStatelet &);
00307 sglStatelet &operator=(const sglStatelet &);
00308
00309 protected:
00310
00311
00312
00313
00314
00315 mutable unsigned int m_index;
00316
00317 private:
00318 StateEnum m_type;
00319 };
00320
00321
00322
00323
00334 class SGL_DLL_API sglBooleanStatelet : public sglStatelet
00335 {
00336 public:
00341 sglBooleanStatelet(StateEnum type, bool on)
00342 : sglStatelet(type), m_on(on) { setIndex(); }
00343
00345 virtual ~sglBooleanStatelet() {}
00346
00350 void enable(bool on) { m_on = on; setIndex(); }
00351
00355 bool isEnabled() const { return m_on; }
00356
00357
00358 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00359
00360 private:
00361 void setIndex() { m_index = (m_on ? 1 : 0); }
00362
00363 sglBooleanStatelet();
00364 sglBooleanStatelet(const sglBooleanStatelet &);
00365 sglBooleanStatelet &operator=(const sglBooleanStatelet &);
00366
00367 protected:
00368 bool m_on;
00369 };
00370
00371
00372
00373
00391 class SGL_DLL_API sglAlphaTest : public sglStatelet
00392 {
00393 public:
00395 enum AlphaFuncEnum
00396 {
00397 eLESS = GL_LESS,
00398 eALWAYS = GL_ALWAYS,
00399 eLEQUAL = GL_LEQUAL,
00400 eEQUAL = GL_EQUAL,
00401 eGEQUAL = GL_GEQUAL,
00402 eGREATER = GL_GREATER,
00403 eNOTEQUAL = GL_NOTEQUAL,
00404 eNEVER = GL_NEVER
00405 };
00406
00407 public:
00413 sglAlphaTest(AlphaFuncEnum func = eALWAYS, float ref = 0.0f)
00414 : sglStatelet(eALPHA_TEST), m_alpha_func(eALWAYS), m_alpha_ref(0.f)
00415 {
00416 setAlphaFunc(func, ref);
00417 }
00418
00420 virtual ~sglAlphaTest() {}
00421
00427 void setAlphaFunc(AlphaFuncEnum func, float ref);
00428
00435 void getAlphaFunc(AlphaFuncEnum &func, float &ref) const
00436 { func = m_alpha_func; ref = m_alpha_ref; }
00437
00438
00439 void apply(sglCurrState *curr_state) const;
00440
00441
00442 virtual bool getSorted() const { return true; }
00443
00444
00445 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00446
00447 private:
00448 sglAlphaTest(const sglAlphaTest &);
00449 sglAlphaTest &operator=(const sglAlphaTest &);
00450
00451 void setIndex();
00452
00453 private:
00454 AlphaFuncEnum m_alpha_func;
00455 float m_alpha_ref;
00456 };
00457
00458
00459
00460
00472 class SGL_DLL_API sglAntiAliasLine : public sglBooleanStatelet
00473 {
00474 public:
00479 sglAntiAliasLine(bool on = false)
00480 : sglBooleanStatelet(eANTI_ALIAS_LINE, on) {}
00481
00483 virtual ~sglAntiAliasLine() {}
00484
00485
00486 void apply(sglCurrState *curr_state) const;
00487
00488 private:
00489 sglAntiAliasLine(const sglAntiAliasLine &);
00490 sglAntiAliasLine &operator=(const sglAntiAliasLine &);
00491 };
00492
00493
00494
00495
00507 class SGL_DLL_API sglAntiAliasPoint : public sglBooleanStatelet
00508 {
00509 public:
00514 sglAntiAliasPoint(bool on = false)
00515 : sglBooleanStatelet(eANTI_ALIAS_POINT, on) {}
00516
00518 virtual ~sglAntiAliasPoint() {}
00519
00520
00521 void apply(sglCurrState *curr_state) const;
00522
00523 private:
00524 sglAntiAliasPoint(const sglAntiAliasPoint &);
00525 sglAntiAliasPoint &operator=(const sglAntiAliasPoint &);
00526 };
00527
00528
00529
00530
00545 class SGL_DLL_API sglAntiAliasPolygon : public sglBooleanStatelet
00546 {
00547 public:
00552 sglAntiAliasPolygon(bool on = false)
00553 : sglBooleanStatelet(eANTI_ALIAS_POLYGON, on) {}
00554
00556 virtual ~sglAntiAliasPolygon() {}
00557
00558
00559 void apply(sglCurrState *curr_state) const;
00560
00561 private:
00562 sglAntiAliasPolygon(const sglAntiAliasPolygon &);
00563 sglAntiAliasPolygon &operator=(const sglAntiAliasPolygon &);
00564 };
00565
00566
00567
00591 class SGL_DLL_API sglBlending : public sglStatelet
00592 {
00593 public:
00595 enum BlendFuncEnum
00596 {
00597 eZERO = GL_ZERO,
00598 eONE = GL_ONE,
00599 eSRC_COLOR = GL_SRC_COLOR,
00600 eONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
00601 eDST_COLOR = GL_DST_COLOR,
00602 eONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
00603 eSRC_ALPHA = GL_SRC_ALPHA,
00604 eONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
00605 eDST_ALPHA = GL_DST_ALPHA,
00606 eONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
00607 eSRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE
00608 };
00609
00610 public:
00618 sglBlending(BlendFuncEnum src_func = eSRC_ALPHA,
00619 BlendFuncEnum dst_func = eONE_MINUS_SRC_ALPHA,
00620 bool on = false)
00621 : sglStatelet(eBLENDING),
00622 m_src_func(src_func), m_dst_func(dst_func), m_on(on)
00623 { setIndex(); }
00624
00626 virtual ~sglBlending() {}
00627
00631 void enable(bool on) { m_on = on; setIndex(); }
00632
00636 bool isEnabled() const { return m_on; }
00637
00643 void setBlendFunc(BlendFuncEnum src_func, BlendFuncEnum dst_func)
00644 { m_src_func = src_func; m_dst_func = dst_func; setIndex(); }
00645
00650 void getBlendFunc(BlendFuncEnum &src_func, BlendFuncEnum &dst_func) const
00651 { src_func = m_src_func; dst_func = m_dst_func; }
00652
00653
00654 void apply(sglCurrState *curr_state) const;
00655
00656
00657 virtual bool getSorted() const { return true; }
00658
00659
00660 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00661
00662 private:
00663 sglBlending(const sglBlending &);
00664 sglBlending &operator=(const sglBlending &);
00665
00666 void setIndex()
00667 {
00668 m_index = ((m_on == false && m_src_func == eSRC_ALPHA &&
00669 m_dst_func == eONE_MINUS_SRC_ALPHA) ? 0 : UINT_MAX);
00670 }
00671
00672 void printFuncName(ostream &ostrm, BlendFuncEnum func) const;
00673
00674 private:
00675 BlendFuncEnum m_src_func;
00676 BlendFuncEnum m_dst_func;
00677 bool m_on;
00678 };
00679
00680
00681
00682
00696 class SGL_DLL_API sglColorMask : public sglStatelet
00697 {
00698 public:
00706 sglColorMask(bool red = true, bool green = true,
00707 bool blue = true, bool alpha = true)
00708 : sglStatelet(eCOLOR_MASK) { setMask(red, green, blue, alpha); }
00710 virtual ~sglColorMask() {}
00711
00718 void setMask(bool red, bool green, bool blue, bool alpha);
00719
00726 void getMask(bool &red, bool &green, bool &blue, bool &alpha) const;
00727
00728
00729 void apply(sglCurrState *curr_state) const;
00730
00731
00732 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00733
00734 private:
00735 sglColorMask(const sglColorMask &);
00736 sglColorMask &operator=(const sglColorMask &);
00737
00738 private:
00739 GLboolean m_red;
00740 GLboolean m_green;
00741 GLboolean m_blue;
00742 GLboolean m_alpha;
00743 };
00744
00745
00746
00747
00766 class SGL_DLL_API sglCullMode : public sglStatelet
00767 {
00768 public:
00770 enum CullModeEnum
00771 {
00773 eBACK = 0,
00775 eOFF,
00777 eFRONT,
00779 eFRONT_AND_BACK
00780 };
00781
00782 public:
00787 sglCullMode(CullModeEnum mode = eBACK)
00788 : sglStatelet(eCULL_MODE), m_cull_mode(mode) { setIndex(); }
00789
00791 virtual ~sglCullMode() {}
00792
00797 void setCullMode(CullModeEnum mode) { m_cull_mode = mode; setIndex(); }
00798
00803 CullModeEnum getCullMode() const { return m_cull_mode; }
00804
00805
00806 void apply(sglCurrState *curr_state) const;
00807
00808
00809 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00810
00811 private:
00812 sglCullMode(const sglCullMode &);
00813 sglCullMode &operator=(const sglCullMode &);
00814
00815 private:
00816 void setIndex()
00817 {
00818 m_index = m_cull_mode;
00819 }
00820
00821 private:
00822 CullModeEnum m_cull_mode;
00823 };
00824
00825
00826
00827
00847 class SGL_DLL_API sglDepthMask : public sglBooleanStatelet
00848 {
00849 public:
00854 sglDepthMask(bool on = true)
00855 : sglBooleanStatelet(eDEPTH_MASK, on) {}
00856
00858 virtual ~sglDepthMask() {}
00859
00860
00861 void apply(sglCurrState *curr_state) const;
00862
00863 private:
00864 sglDepthMask(const sglDepthMask &);
00865 sglDepthMask &operator=(const sglDepthMask &);
00866 };
00867
00868
00869
00870
00892 class SGL_DLL_API sglDepthRange : public sglStatelet
00893 {
00894 public:
00901 sglDepthRange(double near_val = 0.0, double far_val = 1.0)
00902 : sglStatelet(eDEPTH_RANGE)
00903 { setDepthRange(near_val, far_val); }
00904
00906 virtual ~sglDepthRange() {}
00907
00914 void setDepthRange(double near_val, double far_val);
00915
00920 void getDepthRange(double &near_val, double &far_val) const
00921 {
00922 near_val = m_near;
00923 far_val = m_far;
00924 }
00925
00926
00927 void apply(sglCurrState *curr_state) const;
00928
00929
00930 virtual bool getSorted() const { return true; }
00931
00932
00933 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00934
00935 private:
00936 sglDepthRange(const sglDepthRange &);
00937 sglDepthRange &operator=(const sglDepthRange &);
00938
00939 void setIndex()
00940 {
00941 m_index = ((m_near == 0.0 && m_far == 1.0) ? 0 : UINT_MAX);
00942 }
00943
00944 private:
00945 double m_near, m_far;
00946 };
00947
00948
00949
00950
00968 class SGL_DLL_API sglDepthTest : public sglStatelet
00969 {
00970 public:
00972 enum DepthFuncEnum
00973 {
00975 eLESS = GL_LESS,
00977 eALWAYS = GL_ALWAYS,
00979 eLEQUAL = GL_LEQUAL,
00981 eEQUAL = GL_EQUAL,
00983 eGEQUAL = GL_GEQUAL,
00985 eGREATER = GL_GREATER,
00987 eNOTEQUAL = GL_NOTEQUAL,
00989 eNEVER = GL_NEVER
00990 };
00991
00992 public:
00996 sglDepthTest(DepthFuncEnum func = eLESS)
00997 : sglStatelet(eDEPTH_TEST), m_depth_func(func)
00998 {
00999 setIndex();
01000 }
01001
01003 virtual ~sglDepthTest() {}
01004
01008 void setDepthFunc(DepthFuncEnum func);
01009
01013 DepthFuncEnum getDepthFunc() const { return m_depth_func; }
01014
01015
01016 void apply(sglCurrState *curr_state) const;
01017
01018
01019 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01020
01021 private:
01022 sglDepthTest(const sglDepthTest &);
01023 sglDepthTest &operator=(const sglDepthTest &);
01024
01025 void setIndex();
01026
01027 private:
01028 DepthFuncEnum m_depth_func;
01029 };
01030
01031
01032
01033
01048 class SGL_DLL_API sglDithering : public sglBooleanStatelet
01049 {
01050 public:
01054 sglDithering(bool on = true)
01055 : sglBooleanStatelet(eDITHERING, on) {}
01056
01058 virtual ~sglDithering() {}
01059
01060
01061 void apply(sglCurrState *curr_state) const;
01062
01063 private:
01064 sglDithering(const sglDithering &);
01065 sglDithering &operator=(const sglDithering &);
01066 };
01067
01068
01069
01088 class SGL_DLL_API sglFrontFace : public sglStatelet
01089 {
01090 public:
01092 enum FrontFaceEnum
01093 {
01095 eCCW = GL_CCW,
01096
01098 eCW = GL_CW
01099 };
01100
01101 public:
01105 sglFrontFace(FrontFaceEnum winding = eCCW)
01106 : sglStatelet(eFRONT_FACE), m_winding(winding) { setIndex(); }
01107
01109 virtual ~sglFrontFace() {}
01110
01114 void setFrontFace(FrontFaceEnum winding) { m_winding = winding; setIndex(); }
01115
01119 FrontFaceEnum getFrontFace() const { return m_winding; }
01120
01121
01122 void apply(sglCurrState *curr_state) const;
01123
01124
01125 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01126
01127 private:
01128 void setIndex() { m_index = ((m_winding == eCCW) ? 0 : 1); }
01129
01130 sglFrontFace(const sglFrontFace &);
01131 sglFrontFace &operator=(const sglFrontFace &);
01132
01133 protected:
01134 FrontFaceEnum m_winding;
01135 };
01136
01137
01138
01153 class SGL_DLL_API sglHighlight : public sglBooleanStatelet
01154 {
01155 public:
01159 sglHighlight(bool on = false)
01160 : sglBooleanStatelet(eHIGHLIGHT, on) {}
01161
01163 virtual ~sglHighlight() {}
01164
01165
01166 void apply(sglCurrState *curr_state) const;
01167
01168 private:
01169 sglHighlight(const sglHighlight &);
01170 sglHighlight &operator=(const sglHighlight &);
01171 };
01172
01173
01174
01190 class SGL_DLL_API sglLighting : public sglBooleanStatelet
01191 {
01192 public:
01196 sglLighting(bool on = false)
01197 : sglBooleanStatelet(eLIGHTING, on) {}
01198
01200 virtual ~sglLighting() {}
01201
01202
01203 void apply(sglCurrState *curr_state) const;
01204
01205 private:
01206 sglLighting(const sglLighting &);
01207 sglLighting &operator=(const sglLighting &);
01208 };
01209
01210
01211
01212
01230 class SGL_DLL_API sglLineStipple : public sglStatelet
01231 {
01232 public:
01242 sglLineStipple(GLushort pattern = 0xffff, int factor = 1)
01243 : sglStatelet(eLINE_STIPPLE)
01244 { setLineStipple(pattern, factor); }
01245
01247 virtual ~sglLineStipple() {}
01248
01258 void setLineStipple(GLushort pattern, int factor);
01259
01264 void getLineStipple(GLushort &pattern, int &factor) const
01265 {
01266 pattern = m_pattern;
01267 factor = m_factor;
01268 }
01269
01270
01271 void apply(sglCurrState *curr_state) const;
01272
01273
01274 virtual bool getSorted() const { return true; }
01275
01276
01277 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01278
01279 private:
01280 sglLineStipple(const sglLineStipple &);
01281 sglLineStipple &operator=(const sglLineStipple &);
01282
01283 void setIndex()
01284 {
01285 m_index = ((m_pattern == 0xffff) ? 0 : UINT_MAX);
01286 }
01287
01288 private:
01289 GLushort m_pattern;
01290 int m_factor;
01291 };
01292
01293
01294
01308 class SGL_DLL_API sglLineWidth : public sglStatelet
01309 {
01310 public:
01316 sglLineWidth(float line_width = 1.0f)
01317 : sglStatelet(eLINE_WIDTH)
01318 { setLineWidth(line_width); }
01319
01321 virtual ~sglLineWidth() {}
01322
01327 void setLineWidth(float line_width);
01328
01332 float getLineWidth() const { return m_line_width; }
01333
01334
01335 void apply(sglCurrState *curr_state) const;
01336
01337
01338 virtual bool getSorted() const { return true; }
01339
01340
01341 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01342
01343 private:
01344 sglLineWidth(const sglLineWidth &);
01345 sglLineWidth &operator=(const sglLineWidth &);
01346
01347 void setIndex()
01348 {
01349 m_index = ((m_line_width == 1.0f) ? 0 : UINT_MAX);
01350 }
01351
01352 private:
01353 float m_line_width;
01354 };
01355
01356
01357
01358
01377 class SGL_DLL_API sglLogicOp : public sglStatelet
01378 {
01379 public:
01381 enum LogicOpEnum
01382 {
01384 eCOPY = GL_COPY,
01386 eCLEAR = GL_CLEAR,
01388 eSET = GL_SET,
01390 eCOPY_INVERTED = GL_COPY_INVERTED,
01392 eNOOP = GL_NOOP,
01394 eINVERT = GL_INVERT,
01396 eAND = GL_AND,
01398 eNAND = GL_NAND,
01400 eOR = GL_OR,
01402 eNOR = GL_NOR,
01404 eXOR = GL_XOR,
01406 eEQUIV = GL_EQUIV,
01408 eAND_REVERSE = GL_AND_REVERSE,
01410 eAND_INVERTED = GL_AND_INVERTED,
01412 eOR_REVERSE = GL_OR_REVERSE,
01414 eOR_INVERTED = GL_OR_INVERTED
01415 };
01416
01417 public:
01422 sglLogicOp(LogicOpEnum op = eCOPY)
01423 : sglStatelet(eLOGIC_OP), m_logic_op(op) { setIndex(); }
01424
01426 virtual ~sglLogicOp() {}
01427
01431 void setLogicOp(LogicOpEnum op) { m_logic_op = op; setIndex(); }
01432
01437 LogicOpEnum getLogicOp() const { return m_logic_op; }
01438
01439
01440 void apply(sglCurrState *curr_state) const;
01441
01442
01443 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01444
01445 private:
01446 void setIndex();
01447
01448 sglLogicOp(const sglLogicOp &);
01449 sglLogicOp &operator=(const sglLogicOp &);
01450
01451 protected:
01452 LogicOpEnum m_logic_op;
01453 };
01454
01455
01456
01457
01488 class SGL_DLL_API sglOcclusionCull : public sglStatelet
01489 {
01490 public:
01495 sglOcclusionCull(bool on = false)
01496 : sglStatelet(eOCCLUSION_CULL) { enable(on); }
01497
01499 virtual ~sglOcclusionCull() {}
01500
01504 void enable(bool on)
01505 {
01506 m_on = (on && sgl::s_occlusion_capable);
01507 setIndex();
01508 }
01509
01513 bool isEnabled() const { return m_on; }
01514
01515
01516 void apply(sglCurrState *curr_state) const;
01517
01518
01519 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01520
01521 private:
01522 sglOcclusionCull(const sglOcclusionCull &);
01523 sglOcclusionCull &operator=(const sglOcclusionCull &);
01524
01525 private:
01526 void setIndex() { m_index = (m_on ? 1 : 0); }
01527
01528 private:
01529 bool m_on;
01530 };
01531
01532
01533
01547 class SGL_DLL_API sglPointSize : public sglStatelet
01548 {
01549 public:
01555 sglPointSize(float point_size = 1.0f)
01556 : sglStatelet(ePOINT_SIZE)
01557 { setPointSize(point_size); }
01558
01560 virtual ~sglPointSize() {}
01561
01566 void setPointSize(float point_size);
01567
01571 float getPointSize() const
01572 {
01573 return m_point_size;
01574 }
01575
01576
01577 void apply(sglCurrState *curr_state) const;
01578
01579
01580 virtual bool getSorted() const { return true; }
01581
01582
01583 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01584
01585 private:
01586 sglPointSize(const sglPointSize &);
01587 sglPointSize &operator=(const sglPointSize &);
01588
01589 void setIndex()
01590 {
01591 m_index = ((m_point_size == 1.0f) ? 0 : UINT_MAX);
01592 }
01593
01594 private:
01595 float m_point_size;
01596 };
01597
01598
01599
01633 class SGL_DLL_API sglPointParameters : public sglStatelet
01634 {
01635 public:
01647 sglPointParameters(float dist_atten_A = 1.0f,
01648 float dist_atten_B = 0.0f,
01649 float dist_atten_C = 0.0f,
01650 float fade_threshold =
01651 sgl::s_point_default_fade_threshold,
01652 float min_size = sgl::s_point_default_size_min,
01653 float max_size = sgl::s_point_default_size_max )
01654 : sglStatelet(ePOINT_PARAMETERS)
01655 {
01656 setPointParameters( dist_atten_A, dist_atten_B, dist_atten_C,
01657 fade_threshold,
01658 min_size, max_size );
01659 }
01660
01662 virtual ~sglPointParameters() {}
01663
01675 void setPointParameters(float dist_atten_A,
01676 float dist_atten_B,
01677 float dist_atten_C,
01678 float fade_threshold =
01679 sgl::s_point_default_fade_threshold,
01680 float min_size = sgl::s_point_default_size_min,
01681 float max_size = sgl::s_point_default_size_max )
01682 {
01683
01684 m_min_size = min_size;
01685 m_max_size = max_size;
01686 m_fade_threshold = fade_threshold;
01687 m_dist_atten_A = dist_atten_A;
01688 m_dist_atten_B = dist_atten_B;
01689 m_dist_atten_C = dist_atten_C;
01690
01691 setIndex();
01692 }
01693
01702 void getPointParameters(float &dist_atten_A,
01703 float &dist_atten_B,
01704 float &dist_atten_C,
01705 float &fade_threshold,
01706 float &min_size,
01707 float &max_size)
01708 {
01709 min_size = m_min_size;
01710 max_size = m_max_size;
01711 fade_threshold = m_fade_threshold;
01712 dist_atten_A = m_dist_atten_A;
01713 dist_atten_B = m_dist_atten_B;
01714 dist_atten_C = m_dist_atten_C;
01715 }
01716
01717
01718 void apply(sglCurrState *curr_state) const;
01719
01720
01721 virtual bool getSorted() const { return true; }
01722
01723
01724 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01725
01726 private:
01727 sglPointParameters(const sglPointParameters &);
01728 sglPointParameters &operator=(const sglPointParameters &);
01729
01730 void setIndex()
01731 {
01732 if (m_dist_atten_A != 1.0f ||
01733 m_dist_atten_B != 0.0f ||
01734 m_dist_atten_C != 0.0f ||
01735 m_fade_threshold != sgl::s_point_default_fade_threshold ||
01736 m_min_size != sgl::s_point_default_size_min ||
01737 m_max_size != sgl::s_point_default_size_max )
01738 {
01739 m_index = UINT_MAX;
01740 }
01741 else
01742 {
01743 m_index = 0;
01744 }
01745 }
01746
01747 private:
01748 float m_min_size;
01749 float m_max_size;
01750 float m_dist_atten_A;
01751 float m_dist_atten_B;
01752 float m_dist_atten_C;
01753 float m_fade_threshold;
01754 };
01755
01756
01757
01768 class SGL_DLL_API sglPolyStyle : public sglStatelet
01769 {
01770 public:
01772 enum StyleEnum
01773 {
01775 eFILLED = 0,
01776
01778 eLINE,
01779
01781 ePOINT
01782 };
01783
01784 public:
01788 void setStyle(StyleEnum style) { m_style = style; setIndex(); }
01789
01793 StyleEnum getStyle() const { return m_style; }
01794
01795
01796 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01797
01798 protected:
01799 sglPolyStyle(StateEnum type, StyleEnum style)
01800 : sglStatelet(type), m_style(style) { setIndex(); }
01801 virtual ~sglPolyStyle() {}
01802
01803 private:
01804 sglPolyStyle();
01805 sglPolyStyle(const sglPolyStyle &);
01806 sglPolyStyle &operator=(const sglPolyStyle &);
01807
01808 void setIndex() { m_index = m_style; }
01809
01810 protected:
01811 StyleEnum m_style;
01812 };
01813
01814
01815
01830 class SGL_DLL_API sglPolyBackStyle : public sglPolyStyle
01831 {
01832 public:
01837 sglPolyBackStyle(StyleEnum style = eFILLED)
01838 : sglPolyStyle(ePOLY_BACK_STYLE, style) {}
01839
01841 virtual ~sglPolyBackStyle() {}
01842
01843
01844 void apply(sglCurrState *curr_state) const;
01845
01846 private:
01847 sglPolyBackStyle(const sglPolyBackStyle &);
01848 sglPolyBackStyle &operator=(const sglPolyBackStyle &);
01849 };
01850
01851
01852
01853
01868 class SGL_DLL_API sglPolyFrontStyle : public sglPolyStyle
01869 {
01870 public:
01875 sglPolyFrontStyle(StyleEnum style = eFILLED)
01876 : sglPolyStyle(ePOLY_FRONT_STYLE, style) {}
01877
01879 virtual ~sglPolyFrontStyle() {}
01880
01881
01882 void apply(sglCurrState *curr_state) const;
01883
01884 private:
01885 sglPolyFrontStyle(const sglPolyFrontStyle &);
01886 sglPolyFrontStyle &operator=(const sglPolyFrontStyle &);
01887 };
01888
01889
01890
01917 class SGL_DLL_API sglPolygonOffset : public sglStatelet
01918 {
01919 public:
01928 sglPolygonOffset(float factor = 0, float units = 0)
01929 : sglStatelet(ePOLYGON_OFFSET)
01930 { setPolygonOffset(factor, units); }
01931
01933 virtual ~sglPolygonOffset() {}
01934
01942 void setPolygonOffset(float factor, float units);
01943
01948 void getPolygonOffset(float &factor, float &units) const
01949 {
01950 factor = m_factor;
01951 units = m_units;
01952 }
01953
01958 bool getPolygonOffsetFlag() const { return m_polygon_offset_flag; }
01959
01960
01961 void apply(sglCurrState *curr_state) const;
01962
01963
01964 virtual bool getSorted() const { return true; }
01965
01966
01967 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
01968
01969 private:
01970 sglPolygonOffset(const sglPolygonOffset &);
01971 sglPolygonOffset &operator=(const sglPolygonOffset &);
01972
01973 void setIndex()
01974 {
01975 m_index = (m_polygon_offset_flag ? UINT_MAX : 0);
01976 }
01977
01978 private:
01979 bool m_polygon_offset_flag;
01980 float m_factor;
01981 float m_units;
01982 };
01983
01984
01985
01986
02015 class SGL_DLL_API sglPolygonStipple : public sglStatelet
02016 {
02017 public:
02022 sglPolygonStipple(const GLubyte *pattern = NULL)
02023 : sglStatelet(ePOLYGON_STIPPLE)
02024 { setPolygonStipple(pattern); }
02025
02027 virtual ~sglPolygonStipple() {}
02028
02033 void setPolygonStipple(const GLubyte *pattern);
02034
02042 const GLubyte *getPolygonStipple() const
02043 {
02044 if (m_polygon_stipple_flag)
02045 return m_pattern;
02046 else
02047 return NULL;
02048 }
02049
02054 bool getPolygonStippleFlag() const { return m_polygon_stipple_flag; }
02055
02056
02057 void apply(sglCurrState *curr_state) const;
02058
02059
02060 virtual bool getSorted() const { return true; }
02061
02062
02063 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
02064
02065 private:
02066 sglPolygonStipple(const sglPolygonStipple &);
02067 sglPolygonStipple &operator=(const sglPolygonStipple &);
02068
02069 void setIndex()
02070 {
02071 m_index = (m_polygon_stipple_flag ? UINT_MAX : 0);
02072 }
02073
02074 private:
02075 bool m_polygon_stipple_flag;
02076 GLubyte m_pattern[128];
02077 };
02078
02079
02080
02081
02095 class SGL_DLL_API sglShadeModel : public sglStatelet
02096 {
02097 public:
02099 enum ShadeModelEnum
02100 {
02102 eFLAT = GL_FLAT,
02103
02105 eSMOOTH = GL_SMOOTH
02106 };
02107
02108 public:
02113 sglShadeModel(ShadeModelEnum model = eSMOOTH)
02114 : sglStatelet(eSHADE_MODEL), m_model(model) { setIndex(); }
02115
02117 virtual ~sglShadeModel() {}
02118
02123 void setShadeModel(ShadeModelEnum model) { m_model = model; setIndex(); }
02124
02129 ShadeModelEnum getShadeModel() const { return m_model; }
02130
02131
02132 void apply(sglCurrState *curr_state) const;
02133
02134
02135 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
02136
02137 private:
02138 void setIndex() { m_index = ((m_model == eFLAT) ? 1 : 0); }
02139
02140 sglShadeModel(const sglShadeModel &);
02141 sglShadeModel &operator=(const sglShadeModel &);
02142
02143 protected:
02144 ShadeModelEnum m_model;
02145 };
02146
02147
02148
02166 class SGL_DLL_API sglTexturingStatelet : public sglStatelet
02167 {
02168 public:
02173 sglTexturingStatelet(StateEnum type) : sglStatelet(type) {}
02174
02176 virtual ~sglTexturingStatelet() {}
02177
02178
02179 void apply(sglCurrState *curr_state) const { applyToUnit(curr_state, 0); }
02180
02189 virtual void applyToUnit(sglCurrState *curr_state,
02190 unsigned int unit) const = 0;
02191 };
02192
02193
02194
02243 class SGL_DLL_API sglMultiTextureStatelet : public sglStatelet
02244 {
02245 public:
02252 sglMultiTextureStatelet(sglTexturingStatelet *statelet,
02253 unsigned int unit = 0)
02254 : sglStatelet(eNUM_BASIC_STATES),
02255 m_statelet(NULL),
02256 m_texture_unit(unit)
02257 { setStatelet(statelet); }
02258
02262 virtual ~sglMultiTextureStatelet();
02263
02270 void setTextureUnit(unsigned int unit) { m_texture_unit = unit; }
02271
02276 unsigned int getTextureUnit() const { return m_texture_unit; }
02277
02284 void setStatelet(sglTexturingStatelet *statelet);
02285
02289 sglTexturingStatelet* getStatelet() const { return m_statelet; }
02290
02291
02292 void apply(sglCurrState *curr_state) const;
02293
02294
02295 virtual bool getSorted() const { return m_statelet->getSorted(); }
02296
02297 protected:
02298
02299 unsigned int getType() const;
02300
02301 private:
02302 sglMultiTextureStatelet();
02303 sglMultiTextureStatelet(const sglMultiTextureStatelet &);
02304 sglMultiTextureStatelet &operator=(const sglMultiTextureStatelet &);
02305
02306 private:
02307 sglTexturingStatelet *m_statelet;
02308 unsigned int m_texture_unit;
02309 };
02310
02311
02312
02343 class SGL_DLL_API sglTextureMatrix : public sglTexturingStatelet
02344 {
02345 public:
02352 sglTextureMatrix(sglMat4f *tmat = NULL)
02353 : sglTexturingStatelet(eTEXTURE_MATRIX) { setTextureMatrix(tmat); }
02354
02356 virtual ~sglTextureMatrix() {}
02357
02364 void setTextureMatrix(sglMat4f *tmat);
02365
02369 const sglMat4f &getTextureMatrix() const { return m_texture_matrix; }
02370
02371
02372 void applyToUnit(sglCurrState*, unsigned int) const;
02373
02374
02375 virtual bool getSorted() const { return true; }
02376
02377
02378 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
02379
02380 private:
02381 sglTextureMatrix(const sglTextureMatrix &);
02382 sglTextureMatrix &operator=(const sglTextureMatrix &);
02383
02384 void setIndex()
02385 {
02386 m_index = (m_texture_matrix_flag ? UINT_MAX : 0);
02387 }
02388
02389 private:
02390 bool m_texture_matrix_flag;
02391 sglMat4f m_texture_matrix;
02392 };
02393
02394
02395
02396
02418 class SGL_DLL_API sglTransparency : public sglBooleanStatelet
02419 {
02420 public:
02424 sglTransparency(bool on = false)
02425 : sglBooleanStatelet(eTRANSPARENCY, on) {}
02426
02428 virtual ~sglTransparency() {}
02429
02430
02431 void apply(sglCurrState *curr_state) const;
02432
02433 private:
02434 sglTransparency(const sglTransparency &);
02435 sglTransparency &operator=(const sglTransparency &);
02436 };
02437
02438 #endif