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
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #ifndef VRS_OPENGL_FRAMEBUFFERGL_H
00104 #define VRS_OPENGL_FRAMEBUFFERGL_H
00105
00106 #include <vrs/monoattribute.h>
00107 #include <vrs/area.h>
00108 #include <vrs/color.h>
00109 #include <vrs/image/image.h>
00110 #include <vrs/opengl/glcanvas.h>
00111 #include <vrs/opengl/openglconfig.h>
00112
00113 namespace VRS {
00114
00116 class VRS_CORE_API FrameBufferGL : public MonoAttribute {
00117 public:
00118 enum Operations {
00119 ClearColor = 1 << 0,
00120 ClearDepth = 1 << 1,
00121 ClearStencil = 1 << 2,
00122 ClearAccum = 1 << 3,
00123 MaskColor = 1 << 4,
00124 MaskDepth = 1 << 5,
00125 MaskStencil = 1 << 6,
00126 CopyToImage = 1 << 7,
00127 CopyFromImage = 1 << 8
00128 };
00129 VRS_SERIALIZABLE_CLASS_ENUM(Operations);
00130
00131 FrameBufferGL(int operations = FrameBufferGL::ClearColor|FrameBufferGL::ClearDepth|FrameBufferGL::ClearStencil);
00142 void enableOperation(int flagToBeAdded);
00143 void disableOperation(int flagToBeRemoved);
00144 int getOperations() const;
00145
00146 enum OpMode {
00147 WhenPushed = 1,
00148 WhenPopped = 2
00149 };
00150 VRS_SERIALIZABLE_CLASS_ENUM(OpMode);
00151 void setOperationMode(int mode);
00152 int getOperationMode() const;
00153
00154 void setClearColor(const Color& clr);
00155 Color getClearColor() const;
00156 void setMaskColor(bool red, bool green, bool blue, bool alpha);
00157 int getMaskColor() const;
00158
00159 void setClearAccum(const Color& acc);
00160 Color getClearAccum() const;
00161
00162 void setClearDepth(GLclampd depth=1.0);
00163 GLclampd getClearDepth() const;
00164 void setMaskDepth(bool onOff);
00165 bool getMaskDepth() const;
00166
00167 void setClearStencil(int clearValue = 0);
00168 int getClearStencil() const;
00169 void setMaskStencil(int stencilMask);
00170 int getMaskStencil() const;
00171
00172 void setCopyToImage(Image* image);
00173 Image* getCopyToImage() const;
00174
00175 void setCopyFromImage(Image* image);
00176 Image* getCopyFromImage() const;
00177
00178 void setBuffer(GLCanvas::CanvasProperties buffer = GLCanvas::RGB_BUFFER);
00179 GLCanvas::CanvasProperties getBuffer() const;
00182 void setRegion(const Area& area);
00183 Area getRegion() const;
00188 static FrameBufferGL* newColorMask(bool red, bool green, bool blue, bool alpha);
00189
00190 VRS_TYPEINFO(FrameBufferGL, MonoAttribute);
00191 VRS_SERIALIZABLE(FrameBufferGL);
00192
00193 private:
00194 int op_;
00195 int opMode_;
00196
00197 Color clearColor_;
00198 Color clearAccum_;
00199 GLclampd clearDepth_;
00200 int clearStencil_;
00201
00202 bool maskR_, maskG_, maskB_, maskA_;
00203 bool maskDepth_;
00204 int maskStencil_;
00205
00206 SO<Image> copyToImage_;
00207 SO<Image> copyFromImage_;
00208 GLCanvas::CanvasProperties buffer_;
00209 Area region_;
00210 };
00211
00212 inline int FrameBufferGL::getOperations() const { return op_; }
00213 inline int FrameBufferGL::getOperationMode() const { return opMode_; }
00214
00215 inline Color FrameBufferGL::getClearColor() const { return clearColor_; }
00216 inline Color FrameBufferGL::getClearAccum() const { return clearAccum_; }
00217 inline GLclampd FrameBufferGL::getClearDepth() const { return clearDepth_; }
00218 inline int FrameBufferGL::getClearStencil() const { return clearStencil_; }
00219
00220 inline bool FrameBufferGL::getMaskDepth() const { return maskDepth_; }
00221 inline int FrameBufferGL::getMaskStencil() const { return maskStencil_; }
00222
00223 inline Image* FrameBufferGL::getCopyToImage() const { return copyToImage_; }
00224 inline Image* FrameBufferGL::getCopyFromImage() const { return copyFromImage_; }
00225
00226 inline GLCanvas::CanvasProperties FrameBufferGL::getBuffer() const { return buffer_; }
00227 inline Area FrameBufferGL::getRegion() const { return region_; }
00228
00229 }
00230
00231 #endif // VRS_OPENGL_FRAMEBUFFERGL_H