michael@0: // michael@0: // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer michael@0: // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105. michael@0: michael@0: #ifndef LIBGLESV2_FRAMEBUFFER_H_ michael@0: #define LIBGLESV2_FRAMEBUFFER_H_ michael@0: michael@0: #include "common/angleutils.h" michael@0: #include "common/RefCountObject.h" michael@0: #include "Constants.h" michael@0: michael@0: namespace rx michael@0: { michael@0: class Renderer; michael@0: } michael@0: michael@0: namespace gl michael@0: { michael@0: class Renderbuffer; michael@0: class Colorbuffer; michael@0: class Depthbuffer; michael@0: class Stencilbuffer; michael@0: class DepthStencilbuffer; michael@0: michael@0: class Framebuffer michael@0: { michael@0: public: michael@0: explicit Framebuffer(rx::Renderer *renderer); michael@0: michael@0: virtual ~Framebuffer(); michael@0: michael@0: void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer); michael@0: void setDepthbuffer(GLenum type, GLuint depthbuffer); michael@0: void setStencilbuffer(GLenum type, GLuint stencilbuffer); michael@0: michael@0: void detachTexture(GLuint texture); michael@0: void detachRenderbuffer(GLuint renderbuffer); michael@0: michael@0: unsigned int getRenderTargetSerial(unsigned int colorAttachment) const; michael@0: unsigned int getDepthbufferSerial() const; michael@0: unsigned int getStencilbufferSerial() const; michael@0: michael@0: Renderbuffer *getColorbuffer(unsigned int colorAttachment) const; michael@0: Renderbuffer *getDepthbuffer() const; michael@0: Renderbuffer *getStencilbuffer() const; michael@0: Renderbuffer *getDepthOrStencilbuffer() const; michael@0: Renderbuffer *getReadColorbuffer() const; michael@0: GLenum getReadColorbufferType() const; michael@0: Renderbuffer *getFirstColorbuffer() const; michael@0: michael@0: GLenum getColorbufferType(unsigned int colorAttachment) const; michael@0: GLenum getDepthbufferType() const; michael@0: GLenum getStencilbufferType() const; michael@0: michael@0: GLuint getColorbufferHandle(unsigned int colorAttachment) const; michael@0: GLuint getDepthbufferHandle() const; michael@0: GLuint getStencilbufferHandle() const; michael@0: michael@0: GLenum getDrawBufferState(unsigned int colorAttachment) const; michael@0: void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer); michael@0: michael@0: bool isEnabledColorAttachment(unsigned int colorAttachment) const; michael@0: bool hasEnabledColorAttachment() const; michael@0: bool hasStencil() const; michael@0: int getSamples() const; michael@0: bool usingExtendedDrawBuffers() const; michael@0: michael@0: virtual GLenum completeness() const; michael@0: michael@0: protected: michael@0: GLenum mColorbufferTypes[IMPLEMENTATION_MAX_DRAW_BUFFERS]; michael@0: BindingPointer mColorbufferPointers[IMPLEMENTATION_MAX_DRAW_BUFFERS]; michael@0: GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS]; michael@0: GLenum mReadBufferState; michael@0: michael@0: GLenum mDepthbufferType; michael@0: BindingPointer mDepthbufferPointer; michael@0: michael@0: GLenum mStencilbufferType; michael@0: BindingPointer mStencilbufferPointer; michael@0: michael@0: rx::Renderer *mRenderer; michael@0: michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(Framebuffer); michael@0: michael@0: Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const; michael@0: }; michael@0: michael@0: class DefaultFramebuffer : public Framebuffer michael@0: { michael@0: public: michael@0: DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil); michael@0: michael@0: virtual GLenum completeness() const; michael@0: michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif // LIBGLESV2_FRAMEBUFFER_H_