00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VRS_FRAMEBUFFEROBJECTGL_H
00021 #define VRS_FRAMEBUFFEROBJECTGL_H
00022
00023 #include <vrs/monoattribute.h>
00024 #include <vrs/color.h>
00025 #include <vrs/area.h>
00026 #include <vrs/opengl/openglconfig.h>
00027 #include <vrs/opengl/fbo/rendertargetgl.h>
00028 #include <vrs/opengl/fbo/bufferclearancegl.h>
00029 #include <vrs/container/dictionary.h>
00030 #include <set>
00031
00032 namespace VRS {
00033
00034 class Image;
00035 class SceneThing;
00036 class GLCanvas;
00037 class FrameBufferObjectPainterGL;
00038
00044 class VRS_CORE_API FrameBufferObjectGL :
00045 public MonoAttribute
00046 {
00047 public:
00048 VRS_TYPEINFO(FrameBufferObjectGL, MonoAttribute);
00049 VRS_SERIALIZABLE(FrameBufferObjectGL);
00050
00051 FrameBufferObjectGL();
00065 void attachRenderTarget(
00066 GLenum attachmentPoint,
00067 SO<RenderTargetGL> renderTarget,
00068 SO<BufferClearance> clearance = new BufferClearance()
00069 );
00070 void detachRenderTarget(GLenum attachmentPoint);
00081 SO<RenderTargetGL> getAttachedRenderTarget(GLenum attachmentPoint) const;
00084 SO<BufferClearance> getBufferClearance(GLenum attachmentPoint) const;
00089 void clear(GLenum attachmentPoint);
00094 bool isMarkedForClearance(GLenum attachmentPoint) const;
00099 void unmarkClearance(GLenum attachmentPoint);
00102 Area size() const;
00106 SO<Image> renderImage(
00107 SO<SceneThing> scene,
00108 GLenum attachmentPoint = GL_COLOR_ATTACHMENT0_EXT,
00109 SO<GLCanvas> canvas = NULL,
00110 const Area& area = Area()
00111 );
00120 void render(
00121 SO<SceneThing> scene,
00122 SO<GLCanvas> canvas = NULL,
00123 const Area& area = Area()
00124 );
00132
00133 bool isValid() const { return m_isValid; }
00134
00135 TransactionNo getLastUpdate() const;
00136 void setLastUpdate(TransactionNo);
00138
00139 private:
00140 void renderImpl(
00141 SO<SceneThing> scene,
00142 SO<GLCanvas> canvas,
00143 const Area& area,
00144 SO<RenderTargetGL> renderTarget,
00145 SO<MonoAttribute> internalBufferCopierGL = NULL
00146 );
00147
00148 SO<Dictionary<GLenum, SO<RenderTargetGL> > > attachments_;
00149 SO<Dictionary<GLenum, SO<BufferClearance> > > clearances_;
00150 std::set<GLenum> markedForClearance_;
00151
00152 friend class FrameBufferObjectPainterGL;
00153 bool m_isValid;
00154
00155 TransactionNo lastUpdate_;
00156 };
00157
00158 inline TransactionNo FrameBufferObjectGL::getLastUpdate() const { return lastUpdate_; }
00159 inline void FrameBufferObjectGL::setLastUpdate(TransactionNo last) { lastUpdate_ = last; }
00160
00161 }
00162
00163 #endif // VRS_FRAMEBUFFEROBJECTGL_H