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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 #ifndef VRS_OPENGL_COLORBUFFERGL_H
00090 #define VRS_OPENGL_COLORBUFFERGL_H
00091
00092 #include <vrs/monoattribute.h>
00093 #include <vrs/area.h>
00094 #include <vrs/opengl/openglconfig.h>
00095
00096 namespace VRS {
00097
00099 class VRS_CORE_API ColorBufferGL : public MonoAttribute {
00100 public:
00101 enum Operations {
00102 Unused = 1 << 0,
00103 SetColorMask = 1 << 1,
00104 EnableAlphaTest = 1 << 2,
00105 DisableAlphaTest = 1 << 3,
00106 EnableBlending = 1 << 4,
00107 DisableBlending = 1 << 5,
00108 EnableScissor = 1 << 6,
00109 DisableScissor = 1 << 7,
00110 EnableMultisampling = 1 << 8,
00111 SetShadeModel = 1 << 9,
00112 DisableMultisampling = 1 << 10,
00113 EnableAlpha2Coverage = 1 << 11,
00114 DisableAlpha2Coverage = 1 << 12
00115 };
00116 VRS_SERIALIZABLE_CLASS_ENUM(Operations);
00117
00118 ColorBufferGL(int ops);
00126 bool operator==(const ColorBufferGL& other) const;
00127
00128 void enableOperation(int flagToBeAdded);
00129 void disableOperation(int flagToBeRemoved);
00130 int getOperations() const;
00131
00132 void setColorMask(bool red, bool green, bool blue, bool alpha);
00133 int getColorMask() const;
00134
00135 void setAlphaFunction(GLenum fct);
00136 GLenum getAlphaFunction() const;
00137
00138 void setAlpha(double alpha);
00139 double getAlpha() const;
00140
00141 void setScissor(const Area& area);
00142 void setScissor(int x, int y, int width, int height);
00143 Area getScissor() const;
00144
00145 void setSourceBlend(GLenum mode);
00146 GLenum getSourceBlend() const;
00147
00148 void setDestinationBlend(GLenum mode);
00149 GLenum getDestinationBlend() const;
00151
00152 void setFlatShading(bool onOff);
00153 bool getFlatShading() const;
00155
00156 static ColorBufferGL* newAlphaTest(bool enable, GLenum fct = GL_ALWAYS, double refAlpha = 1.0);
00157 static ColorBufferGL* newBlending(bool enable, GLenum srcFactor = GL_DST_COLOR, GLenum dstFactor = GL_ZERO);
00158 static ColorBufferGL* newLock(bool red, bool green, bool blue, bool alpha);
00159 static ColorBufferGL* newFlatShading(bool enable);
00160 static ColorBufferGL* newScissorTest(bool enable, const VRS::Area& region = VRS::Area());
00161
00162 VRS_TYPEINFO(ColorBufferGL, MonoAttribute);
00163 VRS_SERIALIZABLE(ColorBufferGL);
00164
00165 protected:
00166
00167 ColorBufferGL();
00168
00169 private:
00170 int ops_;
00171
00172 int mask_;
00173 GLenum fct_;
00174 double alpha_;
00175 Area scissor_;
00176 GLenum src_;
00177 GLenum dest_;
00178 bool flat_;
00179 };
00180
00181 inline int ColorBufferGL::getOperations() const { return ops_; }
00182 inline int ColorBufferGL::getColorMask() const { return mask_; }
00183 inline GLenum ColorBufferGL::getAlphaFunction() const { return fct_; }
00184 inline double ColorBufferGL::getAlpha() const { return alpha_; }
00185 inline Area ColorBufferGL::getScissor() const { return scissor_; }
00186 inline GLenum ColorBufferGL::getSourceBlend() const { return src_; }
00187 inline GLenum ColorBufferGL::getDestinationBlend() const { return dest_; }
00188 inline bool ColorBufferGL::getFlatShading() const { return flat_; }
00189
00190 }
00191
00192 #endif // VRS_OPENGL_COLORBUFFERGL_H