00001 #ifndef GLW_FRAMEBUFFER_H 00002 #define GLW_FRAMEBUFFER_H 00003 00004 #include "./texture2d.h" 00005 #include "./renderbuffer.h" 00006 00007 #include <vector> 00008 #include <map> 00009 #include <set> 00010 00011 namespace glw 00012 { 00013 00014 class RenderTarget 00015 { 00016 public: 00017 00018 typedef void BaseType; 00019 typedef RenderTarget ThisType; 00020 00021 RenderableHandle target; 00022 GLint level; 00023 GLint layer; 00024 GLenum face; 00025 00026 RenderTarget(void) 00027 { 00028 this->clear(); 00029 } 00030 00031 RenderTarget(RenderableHandle & rTarget, GLint rLevel, GLint rLayer, GLenum rFace) 00032 : target (rTarget) 00033 , level (rLevel) 00034 , layer (rLayer) 00035 , face (rFace) 00036 { 00037 ; 00038 } 00039 00040 RenderTarget(RenderableHandle & rTarget) 00041 : target (rTarget) 00042 , level (0) 00043 , layer (0) 00044 , face (GL_TEXTURE_CUBE_MAP_POSITIVE_X) 00045 { 00046 ; 00047 } 00048 00049 void clear(void) 00050 { 00051 this->target.setNull(); 00052 this->level = 0; 00053 this->layer = -1; 00054 this->face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; 00055 } 00056 00057 bool isNull(void) const 00058 { 00059 return this->target.isNull(); 00060 } 00061 }; 00062 00063 typedef std::vector<RenderTarget> RenderTargetVector; 00064 00065 inline RenderTarget texture2DTarget(Texture2DHandle & handle, GLint level = 0) 00066 { 00067 return RenderTarget(handle, level, 0, GL_NONE); 00068 } 00069 00070 inline RenderTarget textureCubeTarget(TextureCubeHandle & handle, GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X, GLint level = 0) 00071 { 00072 return RenderTarget(handle, level, 0, face); 00073 } 00074 00075 inline RenderTarget renderbufferTarget(RenderbufferHandle & handle) 00076 { 00077 return RenderTarget(handle, 0, 0, GL_NONE); 00078 } 00079 00080 class RenderTargetMapping 00081 { 00082 public: 00083 00084 typedef void BaseType; 00085 typedef RenderTargetMapping ThisType; 00086 00087 typedef std::map<GLuint, RenderTarget> Map; 00088 typedef Map::const_iterator ConstIterator; 00089 typedef Map::iterator Iterator; 00090 typedef Map::value_type Value; 00091 00092 Map bindings; 00093 00094 RenderTargetMapping(void) 00095 { 00096 this->clear(); 00097 } 00098 00099 void clear(void) 00100 { 00101 this->bindings.clear(); 00102 } 00103 00104 const RenderTarget & operator [] (GLuint attachmentIndex) const 00105 { 00106 return this->bindings.find(attachmentIndex)->second; 00107 } 00108 00109 RenderTarget & operator [] (GLuint attachmentIndex) 00110 { 00111 return this->bindings[attachmentIndex]; 00112 } 00113 }; 00114 00115 class RenderTargetBinding 00116 { 00117 public: 00118 00119 typedef void BaseType; 00120 typedef RenderTargetBinding ThisType; 00121 00122 typedef std::map<GLuint, GLuint> Map; 00123 typedef Map::const_iterator ConstIterator; 00124 typedef Map::iterator Iterator; 00125 typedef Map::value_type Value; 00126 00127 Map bindings; 00128 00129 RenderTargetBinding(void) 00130 { 00131 this->clear(); 00132 } 00133 00134 void clear(void) 00135 { 00136 this->bindings.clear(); 00137 } 00138 00139 GLuint operator [] (GLuint attachmentIndex) const 00140 { 00141 return this->bindings.find(attachmentIndex)->second; 00142 } 00143 00144 GLuint & operator [] (GLuint attachmentIndex) 00145 { 00146 return this->bindings[attachmentIndex]; 00147 } 00148 }; 00149 00150 class FramebufferArguments : public ObjectArguments 00151 { 00152 public: 00153 00154 typedef ObjectArguments BaseType; 00155 typedef FramebufferArguments ThisType; 00156 00157 RenderTargetMapping colorTargets; 00158 RenderTarget depthTarget; 00159 RenderTarget stencilTarget; 00160 RenderTargetBinding targetInputs; 00161 00162 FramebufferArguments(void) 00163 : BaseType() 00164 { 00165 ; 00166 } 00167 00168 void clear(void) 00169 { 00170 BaseType::clear(); 00171 this->colorTargets .clear(); 00172 this->depthTarget .clear(); 00173 this->stencilTarget .clear(); 00174 this->targetInputs .clear(); 00175 } 00176 }; 00177 00178 class Framebuffer : public Object 00179 { 00180 friend class Context; 00181 00182 public: 00183 00184 typedef Object BaseType; 00185 typedef Framebuffer ThisType; 00186 00187 virtual ~Framebuffer(void) 00188 { 00189 this->destroy(); 00190 } 00191 00192 virtual Type type(void) const 00193 { 00194 return FramebufferType; 00195 } 00196 00197 const FramebufferArguments & arguments(void) const 00198 { 00199 return this->m_config; 00200 } 00201 00202 bool setColorTarget(GLenum target, GLint unit, GLint index, const RenderTarget & renderTarget) 00203 { 00204 (void)unit; 00205 GLW_ASSERT(this->isValid()); 00206 this->m_config.colorTargets[index].clear(); 00207 const bool r = this->attachTarget(target, GL_COLOR_ATTACHMENT0 + index, renderTarget); 00208 if (!r) return false; 00209 this->m_config.colorTargets[index] = renderTarget; 00210 return true; 00211 } 00212 00213 bool removeColorTarget(GLenum target, GLint unit, GLint index) 00214 { 00215 (void)unit; 00216 GLW_ASSERT(this->isValid()); 00217 glFramebufferRenderbuffer(target, GL_COLOR_ATTACHMENT0 + index, GL_RENDERBUFFER, 0); 00218 this->m_config.colorTargets[index].clear(); 00219 return true; 00220 } 00221 00222 bool removeAllColorTargets(GLenum target, GLint unit) 00223 { 00224 (void)unit; 00225 for (RenderTargetMapping::ConstIterator it=this->m_config.colorTargets.bindings.begin(); it!=this->m_config.colorTargets.bindings.end(); ++it) 00226 { 00227 glFramebufferRenderbuffer(target, GL_COLOR_ATTACHMENT0 + it->first, GL_RENDERBUFFER, 0); 00228 } 00229 this->m_config.colorTargets.clear(); 00230 return true; 00231 } 00232 00233 bool setDepthTarget(GLenum target, GLint unit, const RenderTarget & renderTarget) 00234 { 00235 (void)unit; 00236 GLW_ASSERT(this->isValid()); 00237 this->m_config.depthTarget.clear(); 00238 const bool r = this->attachTarget(target, GL_DEPTH_ATTACHMENT, renderTarget); 00239 if (!r) return false; 00240 this->m_config.depthTarget = renderTarget; 00241 return true; 00242 } 00243 00244 bool removeDepthTarget(GLenum target, GLint unit) 00245 { 00246 (void)unit; 00247 GLW_ASSERT(this->isValid()); 00248 glFramebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); 00249 this->m_config.depthTarget.clear(); 00250 return true; 00251 } 00252 00253 bool setStencilTarget(GLenum target, GLint unit, const RenderTarget & renderTarget) 00254 { 00255 (void)unit; 00256 GLW_ASSERT(this->isValid()); 00257 this->m_config.stencilTarget.clear(); 00258 const bool r = this->attachTarget(target, GL_STENCIL_ATTACHMENT, renderTarget); 00259 if (!r) return false; 00260 this->m_config.stencilTarget = renderTarget; 00261 return true; 00262 } 00263 00264 bool removeStencilTarget(GLenum target, GLint unit) 00265 { 00266 (void)unit; 00267 GLW_ASSERT(this->isValid()); 00268 glFramebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); 00269 this->m_config.stencilTarget.clear(); 00270 return true; 00271 } 00272 00273 bool removeAllTargets(GLenum target, GLint unit) 00274 { 00275 this->removeAllColorTargets (target, unit); 00276 this->removeDepthTarget (target, unit); 00277 this->removeStencilTarget (target, unit); 00278 return true; 00279 } 00280 00281 bool setTargetInputs(GLenum target, GLint unit, const RenderTargetBinding & targetInputs) 00282 { 00283 (void)target; 00284 (void)unit; 00285 GLW_ASSERT(this->isValid()); 00286 this->configureTargetInputs(targetInputs); 00287 return true; 00288 } 00289 00290 bool readColorPixels(GLenum target, GLint unit, GLint index, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data) 00291 { 00292 (void)target; 00293 (void)unit; 00294 GLW_ASSERT(this->isValid()); 00295 if (this->m_config.colorTargets.bindings.count(index) <= 0) 00296 { 00297 GLW_ASSERT(0); 00298 return false; 00299 } 00300 glReadBuffer(GL_COLOR_ATTACHMENT0 + index); 00301 glReadPixels(x, y, width, height, format, type, data); 00302 return true; 00303 } 00304 00305 bool readDepthPixels(GLenum target, GLint unit, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00306 { 00307 (void)target; 00308 (void)unit; 00309 GLW_ASSERT(this->isValid()); 00310 if (this->m_config.depthTarget.isNull()) 00311 { 00312 GLW_ASSERT(0); 00313 return false; 00314 } 00315 glReadPixels(x, y, width, height, GL_DEPTH_COMPONENT, type, data); 00316 return true; 00317 } 00318 00319 bool readStencilPixels(GLenum target, GLint unit, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00320 { 00321 (void)target; 00322 (void)unit; 00323 GLW_ASSERT(this->isValid()); 00324 if (this->m_config.stencilTarget.isNull()) 00325 { 00326 GLW_ASSERT(0); 00327 return false; 00328 } 00329 glReadPixels(x, y, width, height, GL_STENCIL_INDEX, type, data); 00330 return true; 00331 } 00332 00333 protected: 00334 00335 Framebuffer(Context * ctx) 00336 : BaseType(ctx) 00337 { 00338 ; 00339 } 00340 00341 bool create(const FramebufferArguments & args) 00342 { 00343 this->destroy(); 00344 00345 GLint boundNameDraw = 0; 00346 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &boundNameDraw); 00347 00348 GLint boundNameRead = 0; 00349 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &boundNameRead); 00350 00351 glGenFramebuffers(1, &(this->m_name)); 00352 glBindFramebuffer(GL_FRAMEBUFFER, this->m_name); 00353 this->configure(GL_FRAMEBUFFER, args); 00354 glBindFramebuffer(GL_FRAMEBUFFER, 0); 00355 00356 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, boundNameDraw); 00357 glBindFramebuffer(GL_READ_FRAMEBUFFER, boundNameRead); 00358 00359 return true; 00360 } 00361 00362 virtual void doDestroy(void) 00363 { 00364 glDeleteFramebuffers(1, &(this->m_name)); 00365 this->m_config.clear(); 00366 } 00367 00368 virtual bool doIsValid(void) const 00369 { 00370 return true; 00371 } 00372 00373 private: 00374 00375 FramebufferArguments m_config; 00376 00377 void configure(GLenum target, const FramebufferArguments & args) 00378 { 00379 this->m_config.clear(); 00380 00381 for (RenderTargetMapping::ConstIterator it=args.colorTargets.bindings.begin(); it!=args.colorTargets.bindings.end(); ++it) 00382 { 00383 const bool colorAttached = this->attachTarget(target, GL_COLOR_ATTACHMENT0 + it->first, it->second); 00384 if (!colorAttached) continue; 00385 this->m_config.colorTargets[it->first] = it->second; 00386 } 00387 00388 const bool depthAttached = this->attachTarget(target, GL_DEPTH_ATTACHMENT, args.depthTarget); 00389 if (depthAttached) this->m_config.depthTarget = args.depthTarget; 00390 00391 const bool stencilAttached = this->attachTarget(target, GL_STENCIL_ATTACHMENT, args.stencilTarget); 00392 if (stencilAttached) this->m_config.stencilTarget = args.stencilTarget; 00393 00394 this->configureTargetInputs(args.targetInputs); 00395 } 00396 00397 bool attachTarget(GLenum target, GLenum attachment, const RenderTarget & renderTarget) 00398 { 00399 const RenderableHandle & handle = renderTarget.target; 00400 00401 if (!handle) 00402 { 00403 glFramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0); 00404 return false; 00405 } 00406 00407 switch (handle->type()) 00408 { 00409 case RenderbufferType : glFramebufferRenderbuffer (target, attachment, GL_RENDERBUFFER, handle->name() ); break; 00410 case Texture2DType : glFramebufferTexture2D (target, attachment, GL_TEXTURE_2D, handle->name(), renderTarget.level); break; 00411 case TextureCubeType : glFramebufferTexture2D (target, attachment, renderTarget.face, handle->name(), renderTarget.level); break; 00412 default : GLW_ASSERT(0); break; 00413 } 00414 00415 return true; 00416 } 00417 00418 void configureTargetInputs(const RenderTargetBinding & targetInputs) 00419 { 00420 if (this->m_config.colorTargets.bindings.empty() && targetInputs.bindings.empty()) 00421 { 00422 glDrawBuffer(GL_NONE); 00423 glReadBuffer(GL_NONE); 00424 return; 00425 } 00426 00427 std::vector<GLenum> drawBuffers; 00428 drawBuffers.reserve(targetInputs.bindings.size()); 00429 for (RenderTargetBinding::ConstIterator it=targetInputs.bindings.begin(); it!=targetInputs.bindings.end(); ++it) 00430 { 00431 const GLuint fragOutput = it->second; 00432 const GLuint attachmentIndex = GL_COLOR_ATTACHMENT0 + it->first; 00433 if (drawBuffers.size() <= size_t(fragOutput)) 00434 { 00435 drawBuffers.resize(size_t(fragOutput + 1), GL_NONE); 00436 } 00437 drawBuffers[fragOutput] = attachmentIndex; 00438 this->m_config.targetInputs[it->first] = fragOutput; 00439 } 00440 glDrawBuffers(GLsizei(drawBuffers.size()), &(drawBuffers[0])); 00441 glReadBuffer(drawBuffers[0]); 00442 } 00443 }; 00444 00445 namespace detail { template <> struct BaseOf <Framebuffer> { typedef Object Type; }; }; 00446 typedef detail::ObjectSharedPointerTraits <Framebuffer> ::Type FramebufferPtr; 00447 00448 class SafeFramebuffer : public SafeObject 00449 { 00450 friend class Context; 00451 friend class BoundFramebuffer; 00452 00453 public: 00454 00455 typedef SafeObject BaseType; 00456 typedef SafeFramebuffer ThisType; 00457 00458 const FramebufferArguments & arguments(void) const 00459 { 00460 return this->object()->arguments(); 00461 } 00462 00463 protected: 00464 00465 SafeFramebuffer(const FramebufferPtr & program) 00466 : BaseType(program) 00467 { 00468 ; 00469 } 00470 00471 const FramebufferPtr & object(void) const 00472 { 00473 return static_cast<const FramebufferPtr &>(BaseType::object()); 00474 } 00475 00476 FramebufferPtr & object(void) 00477 { 00478 return static_cast<FramebufferPtr &>(BaseType::object()); 00479 } 00480 }; 00481 00482 namespace detail { template <> struct BaseOf <SafeFramebuffer> { typedef SafeObject Type; }; }; 00483 namespace detail { template <> struct ObjectBase <SafeFramebuffer> { typedef Framebuffer Type; }; }; 00484 namespace detail { template <> struct ObjectSafe <Framebuffer > { typedef SafeFramebuffer Type; }; }; 00485 typedef detail::ObjectSharedPointerTraits <SafeFramebuffer> ::Type FramebufferHandle; 00486 00487 class FramebufferBindingParams : public ObjectBindingParams 00488 { 00489 public: 00490 00491 typedef ObjectBindingParams BaseType; 00492 typedef FramebufferBindingParams ThisType; 00493 00494 FramebufferBindingParams(void) 00495 : BaseType() 00496 { 00497 ; 00498 } 00499 00500 FramebufferBindingParams(GLenum target) 00501 : BaseType(target, 0) 00502 { 00503 ; 00504 } 00505 }; 00506 00507 class BoundFramebuffer : public BoundObject 00508 { 00509 friend class Context; 00510 00511 public: 00512 00513 typedef BoundObject BaseType; 00514 typedef BoundFramebuffer ThisType; 00515 00516 BoundFramebuffer(void) 00517 : BaseType() 00518 { 00519 ; 00520 } 00521 00522 const FramebufferHandle & handle(void) const 00523 { 00524 return static_cast<const FramebufferHandle &>(BaseType::handle()); 00525 } 00526 00527 FramebufferHandle & handle(void) 00528 { 00529 return static_cast<FramebufferHandle &>(BaseType::handle()); 00530 } 00531 00532 GLenum getStatus(void) const 00533 { 00534 return glCheckFramebufferStatus(this->m_target); 00535 } 00536 00537 bool isComplete(void) const 00538 { 00539 return (this->getStatus() == GL_FRAMEBUFFER_COMPLETE); 00540 } 00541 00542 bool setColorTarget(GLint index, const RenderTarget & renderTarget) 00543 { 00544 return this->object()->setColorTarget(this->m_target, this->m_unit, index, renderTarget); 00545 } 00546 00547 bool removeColorTarget(GLint index) 00548 { 00549 return this->object()->removeColorTarget(this->m_target, this->m_unit, index); 00550 } 00551 00552 bool removeAllColorTargets(void) 00553 { 00554 return this->object()->removeAllColorTargets(this->m_target, this->m_unit); 00555 } 00556 00557 bool setDepthTarget(const RenderTarget & renderTarget) 00558 { 00559 return this->object()->setDepthTarget(this->m_target, this->m_unit, renderTarget); 00560 } 00561 00562 bool removeDepthTarget(void) 00563 { 00564 return this->object()->removeDepthTarget(this->m_target, this->m_unit); 00565 } 00566 00567 bool setStencilTarget(const RenderTarget & renderTarget) 00568 { 00569 return this->object()->setStencilTarget(this->m_target, this->m_unit, renderTarget); 00570 } 00571 00572 bool removeStencilTarget(void) 00573 { 00574 return this->object()->removeStencilTarget(this->m_target, this->m_unit); 00575 } 00576 00577 bool removeAllTargets(void) 00578 { 00579 return this->object()->removeAllTargets(this->m_target, this->m_unit); 00580 } 00581 00582 bool setTargetInputs(const RenderTargetBinding & targetInputs) 00583 { 00584 return this->object()->setTargetInputs(this->m_target, this->m_unit, targetInputs); 00585 } 00586 00587 protected: 00588 00589 BoundFramebuffer(const FramebufferHandle & handle, const FramebufferBindingParams & params) 00590 : BaseType(handle, params) 00591 { 00592 ; 00593 } 00594 00595 const FramebufferPtr & object(void) const 00596 { 00597 return this->handle()->object(); 00598 } 00599 00600 FramebufferPtr & object(void) 00601 { 00602 return this->handle()->object(); 00603 } 00604 00605 virtual void bind(void) 00606 { 00607 glBindFramebuffer(this->m_target, this->object()->name()); 00608 } 00609 00610 virtual void unbind(void) 00611 { 00612 glBindFramebuffer(this->m_target, 0); 00613 } 00614 }; 00615 00616 namespace detail { template <> struct ParamsOf <BoundFramebuffer> { typedef FramebufferBindingParams Type; }; }; 00617 namespace detail { template <> struct BaseOf <BoundFramebuffer> { typedef BoundObject Type; }; }; 00618 namespace detail { template <> struct ObjectBase <BoundFramebuffer> { typedef Framebuffer Type; }; }; 00619 namespace detail { template <> struct ObjectBound <Framebuffer > { typedef BoundFramebuffer Type; }; }; 00620 typedef detail::ObjectSharedPointerTraits <BoundFramebuffer> ::Type BoundFramebufferHandle; 00621 00622 class ReadFramebufferBindingParams : public FramebufferBindingParams 00623 { 00624 public: 00625 00626 typedef FramebufferBindingParams BaseType; 00627 typedef ReadFramebufferBindingParams ThisType; 00628 00629 ReadFramebufferBindingParams(void) 00630 : BaseType(GL_READ_FRAMEBUFFER) 00631 { 00632 ; 00633 } 00634 }; 00635 00636 class BoundReadFramebuffer : public BoundFramebuffer 00637 { 00638 friend class Context; 00639 00640 public: 00641 00642 typedef BoundFramebuffer BaseType; 00643 typedef BoundReadFramebuffer ThisType; 00644 00645 BoundReadFramebuffer(void) 00646 : BaseType() 00647 { 00648 ; 00649 } 00650 00651 bool readColorPixels(GLint index, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data) 00652 { 00653 return this->object()->readColorPixels(this->m_target, this->m_unit, index, x, y, width, height, format, type, data); 00654 } 00655 00656 bool readDepthPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00657 { 00658 return this->object()->readDepthPixels(this->m_target, this->m_unit, x, y, width, height, type, data); 00659 } 00660 00661 bool readStencilPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00662 { 00663 return this->object()->readStencilPixels(this->m_target, this->m_unit, x, y, width, height, type, data); 00664 } 00665 00666 protected: 00667 00668 BoundReadFramebuffer(const FramebufferHandle & handle, const ReadFramebufferBindingParams & params) 00669 : BaseType(handle, params) 00670 { 00671 ; 00672 } 00673 }; 00674 00675 namespace detail { template <> struct ParamsOf <BoundReadFramebuffer> { typedef ReadFramebufferBindingParams Type; }; }; 00676 namespace detail { template <> struct BaseOf <BoundReadFramebuffer> { typedef BoundFramebuffer Type; }; }; 00677 namespace detail { template <> struct ObjectBase <BoundReadFramebuffer> { typedef Framebuffer Type; }; }; 00678 typedef detail::ObjectSharedPointerTraits <BoundReadFramebuffer> ::Type BoundReadFramebufferHandle; 00679 00680 class DrawFramebufferBindingParams : public FramebufferBindingParams 00681 { 00682 public: 00683 00684 typedef FramebufferBindingParams BaseType; 00685 typedef DrawFramebufferBindingParams ThisType; 00686 00687 DrawFramebufferBindingParams(void) 00688 : BaseType(GL_DRAW_FRAMEBUFFER) 00689 { 00690 ; 00691 } 00692 }; 00693 00694 class BoundDrawFramebuffer : public BoundFramebuffer 00695 { 00696 friend class Context; 00697 00698 public: 00699 00700 typedef BoundFramebuffer BaseType; 00701 typedef BoundDrawFramebuffer ThisType; 00702 00703 BoundDrawFramebuffer(void) 00704 : BaseType() 00705 { 00706 ; 00707 } 00708 00709 protected: 00710 00711 BoundDrawFramebuffer(const FramebufferHandle & handle, const DrawFramebufferBindingParams & params) 00712 : BaseType(handle, params) 00713 { 00714 ; 00715 } 00716 }; 00717 00718 namespace detail { template <> struct ParamsOf <BoundDrawFramebuffer> { typedef DrawFramebufferBindingParams Type; }; }; 00719 namespace detail { template <> struct BaseOf <BoundDrawFramebuffer> { typedef BoundFramebuffer Type; }; }; 00720 namespace detail { template <> struct ObjectBase <BoundDrawFramebuffer> { typedef Framebuffer Type; }; }; 00721 typedef detail::ObjectSharedPointerTraits <BoundDrawFramebuffer> ::Type BoundDrawFramebufferHandle; 00722 00723 class ReadDrawFramebufferBindingParams : public FramebufferBindingParams 00724 { 00725 public: 00726 00727 typedef FramebufferBindingParams BaseType; 00728 typedef ReadDrawFramebufferBindingParams ThisType; 00729 00730 ReadDrawFramebufferBindingParams(void) 00731 : BaseType(GL_FRAMEBUFFER) 00732 { 00733 ; 00734 } 00735 }; 00736 00737 class BoundReadDrawFramebuffer : public BoundFramebuffer 00738 { 00739 friend class Context; 00740 00741 public: 00742 00743 typedef BoundFramebuffer BaseType; 00744 typedef BoundReadDrawFramebuffer ThisType; 00745 00746 BoundReadDrawFramebuffer(void) 00747 : BaseType() 00748 { 00749 ; 00750 } 00751 00752 bool readColorPixels(GLint index, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data) 00753 { 00754 return this->object()->readColorPixels(this->m_target, this->m_unit, index, x, y, width, height, format, type, data); 00755 } 00756 00757 bool readDepthPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00758 { 00759 return this->object()->readDepthPixels(this->m_target, this->m_unit, x, y, width, height, type, data); 00760 } 00761 00762 bool readStencilPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, GLvoid * data) 00763 { 00764 return this->object()->readStencilPixels(this->m_target, this->m_unit, x, y, width, height, type, data); 00765 } 00766 00767 protected: 00768 00769 BoundReadDrawFramebuffer(const FramebufferHandle & handle, const ReadDrawFramebufferBindingParams & params) 00770 : BaseType(handle, params) 00771 { 00772 ; 00773 } 00774 }; 00775 00776 namespace detail { template <> struct ParamsOf <BoundReadDrawFramebuffer> { typedef ReadDrawFramebufferBindingParams Type; }; }; 00777 namespace detail { template <> struct BaseOf <BoundReadDrawFramebuffer> { typedef BoundFramebuffer Type; }; }; 00778 namespace detail { template <> struct ObjectBase <BoundReadDrawFramebuffer> { typedef Framebuffer Type; }; }; 00779 typedef detail::ObjectSharedPointerTraits <BoundReadDrawFramebuffer> ::Type BoundReadDrawFramebufferHandle; 00780 00781 }; 00782 00783 #endif // GLW_FRAMEBUFFER_H