blob: 54c92d6d80e5e37710653d76f059d1cd8cfa4dd6 [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);
Geoff Lang55ba29c2013-07-11 16:57:53 -040040 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
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 getDepthbufferSerial() const;
47 unsigned int getStencilbufferSerial() const;
daniel@transgaming.com092bd482010-05-12 03:39:36 +000048
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000049 Renderbuffer *getColorbuffer(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000050 Renderbuffer *getDepthbuffer() const;
51 Renderbuffer *getStencilbuffer() const;
52 Renderbuffer *getDepthOrStencilbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000053 Renderbuffer *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000054 GLenum getReadColorbufferType() const;
shannon.woods%transgaming.com@gtempaccount.com882434c2013-04-13 03:34:14 +000055 Renderbuffer *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000057 GLenum getColorbufferType(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000058 GLenum getDepthbufferType() const;
59 GLenum getStencilbufferType() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040060 GLenum getDepthStencilbufferType() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000061
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000062 GLuint getColorbufferHandle(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000063 GLuint getDepthbufferHandle() const;
64 GLuint getStencilbufferHandle() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040065 GLenum getDepthStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000066
Geoff Langc90d73a2013-07-22 16:39:23 -040067 GLenum getColorbufferMipLevel(unsigned int colorAttachment) const;
68 GLenum getDepthbufferMipLevel() const;
69 GLenum getStencilbufferMipLevel() const;
70 GLenum getDepthStencilbufferMipLevel() const;
71
72 GLenum getColorbufferLayer(unsigned int colorAttachment) const;
73 GLenum getDepthbufferLayer() const;
74 GLenum getStencilbufferLayer() const;
75 GLenum getDepthStencilbufferLayer() const;
76
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000077 GLenum getDrawBufferState(unsigned int colorAttachment) const;
78 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
79
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000080 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
81 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000082 bool hasStencil() const;
83 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000084 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000085
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000086 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000087
88 protected:
Geoff Langc90d73a2013-07-22 16:39:23 -040089 FramebufferTextureBindingPointer<Renderbuffer> mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000090 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
91 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000092
Geoff Langc90d73a2013-07-22 16:39:23 -040093 FramebufferTextureBindingPointer<Renderbuffer> mDepthbuffer;
94 FramebufferTextureBindingPointer<Renderbuffer> mStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000095
daniel@transgaming.com16418b12012-11-28 19:32:22 +000096 rx::Renderer *mRenderer;
97
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 private:
99 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
100
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000101 Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000102};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000103
104class DefaultFramebuffer : public Framebuffer
105{
106 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +0000107 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000108
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000109 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000110
111 private:
112 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
113};
114
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115}
116
117#endif // LIBGLESV2_FRAMEBUFFER_H_