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.
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.
10 #ifndef LIBGLESV2_FRAMEBUFFER_H_
11 #define LIBGLESV2_FRAMEBUFFER_H_
13 #include "common/angleutils.h"
14 #include "common/RefCountObject.h"
15 #include "constants.h"
24 class FramebufferAttachment;
28 class DepthStencilbuffer;
33 Framebuffer(rx::Renderer *renderer, GLuint id);
35 virtual ~Framebuffer();
37 GLuint id() const { return mId; }
39 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
40 void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
41 void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
42 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
44 void detachTexture(GLuint texture);
45 void detachRenderbuffer(GLuint renderbuffer);
47 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
48 FramebufferAttachment *getDepthbuffer() const;
49 FramebufferAttachment *getStencilbuffer() const;
50 FramebufferAttachment *getDepthStencilBuffer() const;
51 FramebufferAttachment *getDepthOrStencilbuffer() const;
52 FramebufferAttachment *getReadColorbuffer() const;
53 GLenum getReadColorbufferType() const;
54 FramebufferAttachment *getFirstColorbuffer() const;
56 virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
58 GLenum getDrawBufferState(unsigned int colorAttachment) const;
59 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
61 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
62 bool hasEnabledColorAttachment() const;
63 bool hasStencil() const;
64 int getSamples() const;
65 bool usingExtendedDrawBuffers() const;
67 virtual GLenum completeness() const;
68 bool hasValidDepthStencil() const;
71 rx::Renderer *mRenderer;
75 FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
76 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
77 GLenum mReadBufferState;
79 FramebufferAttachment *mDepthbuffer;
80 FramebufferAttachment *mStencilbuffer;
83 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
85 FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
88 class DefaultFramebuffer : public Framebuffer
91 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
93 virtual GLenum completeness() const;
94 virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
97 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
102 #endif // LIBGLESV2_FRAMEBUFFER_H_