• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Renderbuffer;
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);
38     void setDepthbuffer(GLenum type, GLuint depthbuffer);
39     void setStencilbuffer(GLenum type, GLuint stencilbuffer);
40 
41     void detachTexture(GLuint texture);
42     void detachRenderbuffer(GLuint renderbuffer);
43 
44     unsigned int getRenderTargetSerial(unsigned int colorAttachment) const;
45     unsigned int getDepthbufferSerial() const;
46     unsigned int getStencilbufferSerial() const;
47 
48     Renderbuffer *getColorbuffer(unsigned int colorAttachment) const;
49     Renderbuffer *getDepthbuffer() const;
50     Renderbuffer *getStencilbuffer() const;
51     Renderbuffer *getDepthOrStencilbuffer() const;
52     Renderbuffer *getReadColorbuffer() const;
53     GLenum getReadColorbufferType() const;
54     Renderbuffer *getFirstColorbuffer() const;
55 
56     GLenum getColorbufferType(unsigned int colorAttachment) const;
57     GLenum getDepthbufferType() const;
58     GLenum getStencilbufferType() const;
59 
60     GLuint getColorbufferHandle(unsigned int colorAttachment) const;
61     GLuint getDepthbufferHandle() const;
62     GLuint getStencilbufferHandle() const;
63 
64     GLenum getDrawBufferState(unsigned int colorAttachment) const;
65     void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
66 
67     bool isEnabledColorAttachment(unsigned int colorAttachment) const;
68     bool hasEnabledColorAttachment() const;
69     bool hasStencil() const;
70     int getSamples() const;
71     bool usingExtendedDrawBuffers() const;
72 
73     virtual GLenum completeness() const;
74 
75   protected:
76     GLenum mColorbufferTypes[IMPLEMENTATION_MAX_DRAW_BUFFERS];
77     BindingPointer<Renderbuffer> mColorbufferPointers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
78     GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
79     GLenum mReadBufferState;
80 
81     GLenum mDepthbufferType;
82     BindingPointer<Renderbuffer> mDepthbufferPointer;
83 
84     GLenum mStencilbufferType;
85     BindingPointer<Renderbuffer> mStencilbufferPointer;
86 
87     rx::Renderer *mRenderer;
88 
89   private:
90     DISALLOW_COPY_AND_ASSIGN(Framebuffer);
91 
92     Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
93 };
94 
95 class DefaultFramebuffer : public Framebuffer
96 {
97   public:
98     DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
99 
100     virtual GLenum completeness() const;
101 
102   private:
103     DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
104 };
105 
106 }
107 
108 #endif   // LIBGLESV2_FRAMEBUFFER_H_
109