1 // 2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer 8 // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105. 9 10 #ifndef LIBGLESV2_FRAMEBUFFER_H_ 11 #define LIBGLESV2_FRAMEBUFFER_H_ 12 13 #include "common/angleutils.h" 14 #include "common/RefCountObject.h" 15 #include "constants.h" 16 17 namespace rx 18 { 19 class Renderer; 20 } 21 22 namespace gl 23 { 24 class FramebufferAttachment; 25 class Colorbuffer; 26 class Depthbuffer; 27 class Stencilbuffer; 28 class DepthStencilbuffer; 29 30 class Framebuffer 31 { 32 public: 33 explicit Framebuffer(rx::Renderer *renderer); 34 35 virtual ~Framebuffer(); 36 37 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer); 38 void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer); 39 void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer); 40 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer); 41 42 void detachTexture(GLuint texture); 43 void detachRenderbuffer(GLuint renderbuffer); 44 45 unsigned int getRenderTargetSerial(unsigned int colorAttachment) const; 46 unsigned int getDepthbufferSerial() const; 47 unsigned int getStencilbufferSerial() const; 48 49 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const; 50 FramebufferAttachment *getDepthbuffer() const; 51 FramebufferAttachment *getStencilbuffer() const; 52 FramebufferAttachment *getDepthStencilBuffer() const; 53 FramebufferAttachment *getDepthOrStencilbuffer() const; 54 FramebufferAttachment *getReadColorbuffer() const; 55 GLenum getReadColorbufferType() const; 56 FramebufferAttachment *getFirstColorbuffer() const; 57 58 GLenum getColorbufferType(unsigned int colorAttachment) const; 59 GLenum getDepthbufferType() const; 60 GLenum getStencilbufferType() const; 61 GLenum getDepthStencilbufferType() const; 62 63 GLuint getColorbufferHandle(unsigned int colorAttachment) const; 64 GLuint getDepthbufferHandle() const; 65 GLuint getStencilbufferHandle() const; 66 GLenum getDepthStencilbufferHandle() const; 67 68 GLenum getColorbufferMipLevel(unsigned int colorAttachment) const; 69 GLenum getDepthbufferMipLevel() const; 70 GLenum getStencilbufferMipLevel() const; 71 GLenum getDepthStencilbufferMipLevel() const; 72 73 GLenum getColorbufferLayer(unsigned int colorAttachment) const; 74 GLenum getDepthbufferLayer() const; 75 GLenum getStencilbufferLayer() const; 76 GLenum getDepthStencilbufferLayer() const; 77 78 GLenum getDrawBufferState(unsigned int colorAttachment) const; 79 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer); 80 81 bool isEnabledColorAttachment(unsigned int colorAttachment) const; 82 bool hasEnabledColorAttachment() const; 83 bool hasStencil() const; 84 int getSamples() const; 85 bool usingExtendedDrawBuffers() const; 86 87 virtual GLenum completeness() const; 88 89 protected: 90 FramebufferTextureBindingPointer<FramebufferAttachment> mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS]; 91 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS]; 92 GLenum mReadBufferState; 93 94 FramebufferTextureBindingPointer<FramebufferAttachment> mDepthbuffer; 95 FramebufferTextureBindingPointer<FramebufferAttachment> mStencilbuffer; 96 97 rx::Renderer *mRenderer; 98 99 private: 100 DISALLOW_COPY_AND_ASSIGN(Framebuffer); 101 102 FramebufferAttachment *lookupAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const; 103 }; 104 105 class DefaultFramebuffer : public Framebuffer 106 { 107 public: 108 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil); 109 110 virtual GLenum completeness() const; 111 112 private: 113 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); 114 }; 115 116 } 117 118 #endif // LIBGLESV2_FRAMEBUFFER_H_ 119