blob: 9a1bee0c15c072228021ca7db892187a667d9e26 [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 setColorbuffer(GLenum type, GLuint colorbuffer);
39 void setDepthbuffer(GLenum type, GLuint depthbuffer);
40 void setStencilbuffer(GLenum type, GLuint stencilbuffer);
41
42 void detachTexture(GLuint texture);
43 void detachRenderbuffer(GLuint renderbuffer);
44
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000045 unsigned int getRenderTargetSerial(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000046 unsigned int getRenderTargetSerial() const;
47 unsigned int getDepthbufferSerial() const;
48 unsigned int getStencilbufferSerial() const;
daniel@transgaming.com092bd482010-05-12 03:39:36 +000049
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000050 Renderbuffer *getColorbuffer(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000051 Renderbuffer *getColorbuffer() const;
52 Renderbuffer *getDepthbuffer() const;
53 Renderbuffer *getStencilbuffer() const;
54 Renderbuffer *getDepthOrStencilbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000055 Renderbuffer *getReadColorbuffer() const;
56 Renderbuffer *getFirstColorBuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000057
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000058 GLenum getColorbufferType(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000059 GLenum getColorbufferType() const;
60 GLenum getDepthbufferType() const;
61 GLenum getStencilbufferType() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000062
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000063 GLuint getColorbufferHandle(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000064 GLuint getColorbufferHandle() const;
65 GLuint getDepthbufferHandle() const;
66 GLuint getStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000067
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000068 GLenum getDrawBufferState(unsigned int colorAttachment) const;
69 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
70
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000071 bool hasStencil() const;
72 int getSamples() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000073
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000074 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000075
76 protected:
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000077 GLenum mColorbufferTypes[IMPLEMENTATION_MAX_DRAW_BUFFERS];
78 BindingPointer<Renderbuffer> mColorbufferPointers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
79 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
80 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000081
82 GLenum mDepthbufferType;
83 BindingPointer<Renderbuffer> mDepthbufferPointer;
84
85 GLenum mStencilbufferType;
86 BindingPointer<Renderbuffer> mStencilbufferPointer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000087
daniel@transgaming.com16418b12012-11-28 19:32:22 +000088 rx::Renderer *mRenderer;
89
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000090 private:
91 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
92
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000093 Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000094};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000095
96class DefaultFramebuffer : public Framebuffer
97{
98 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +000099 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000100
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000101 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000102
103 private:
104 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
105};
106
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000107}
108
109#endif // LIBGLESV2_FRAMEBUFFER_H_