blob: b54e008dd82581d05218912957216b7060a9ccad [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +00002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// 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
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000013#include "common/angleutils.h"
apatrick@chromium.orgb66a7012012-01-23 20:04:48 +000014#include "common/RefCountObject.h"
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000015#include "constants.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000016
daniel@transgaming.com16418b12012-11-28 19:32:22 +000017namespace rx
18{
19class Renderer;
20}
21
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000022namespace gl
23{
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000024class Renderbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000025class Colorbuffer;
26class Depthbuffer;
27class Stencilbuffer;
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +000028class DepthStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000029
apatrick@chromium.orgff8bdfb2010-09-15 17:27:49 +000030class Framebuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000031{
32 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +000033 explicit Framebuffer(rx::Renderer *renderer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000034
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000035 virtual ~Framebuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000036
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000037 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000038 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
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000044 unsigned int getRenderTargetSerial(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000045 unsigned int getDepthbufferSerial() const;
46 unsigned int getStencilbufferSerial() const;
daniel@transgaming.com092bd482010-05-12 03:39:36 +000047
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000048 Renderbuffer *getColorbuffer(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000049 Renderbuffer *getDepthbuffer() const;
50 Renderbuffer *getStencilbuffer() const;
51 Renderbuffer *getDepthOrStencilbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000052 Renderbuffer *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000053 GLenum getReadColorbufferType() const;
shannon.woods%transgaming.com@gtempaccount.com882434c2013-04-13 03:34:14 +000054 Renderbuffer *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000056 GLenum getColorbufferType(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000057 GLenum getDepthbufferType() const;
58 GLenum getStencilbufferType() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000059
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000060 GLuint getColorbufferHandle(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000061 GLuint getDepthbufferHandle() const;
62 GLuint getStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000063
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000064 GLenum getDrawBufferState(unsigned int colorAttachment) const;
65 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
66
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000067 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
68 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000069 bool hasStencil() const;
70 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000071 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000072
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000073 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000074
75 protected:
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000076 GLenum mColorbufferTypes[IMPLEMENTATION_MAX_DRAW_BUFFERS];
77 BindingPointer<Renderbuffer> mColorbufferPointers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
78 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
79 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000080
81 GLenum mDepthbufferType;
82 BindingPointer<Renderbuffer> mDepthbufferPointer;
83
84 GLenum mStencilbufferType;
85 BindingPointer<Renderbuffer> mStencilbufferPointer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000086
daniel@transgaming.com16418b12012-11-28 19:32:22 +000087 rx::Renderer *mRenderer;
88
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000089 private:
90 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
91
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000092 Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000093};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000094
95class DefaultFramebuffer : public Framebuffer
96{
97 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +000098 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000099
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000100 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000101
102 private:
103 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
104};
105
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000106}
107
108#endif // LIBGLESV2_FRAMEBUFFER_H_