blob: 0c5a8d7c9185d6cb3ee099dd87d612bd98d24906 [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{
Jamie Madill3c7fa222014-06-05 13:08:51 -040024class FramebufferAttachment;
Jamie Madill6c7b4ad2014-06-16 10:33:59 -040025class FramebufferAttachmentImpl;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000026class Colorbuffer;
27class Depthbuffer;
28class Stencilbuffer;
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +000029class DepthStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000030
apatrick@chromium.orgff8bdfb2010-09-15 17:27:49 +000031class Framebuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000032{
33 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +000034 explicit Framebuffer(rx::Renderer *renderer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000035
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000036 virtual ~Framebuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000037
Geoff Lang309c92a2013-07-25 16:23:19 -040038 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
39 void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
40 void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
41 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000042
43 void detachTexture(GLuint texture);
44 void detachRenderbuffer(GLuint renderbuffer);
45
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000046 unsigned int getRenderTargetSerial(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000047 unsigned int getDepthbufferSerial() const;
48 unsigned int getStencilbufferSerial() const;
daniel@transgaming.com092bd482010-05-12 03:39:36 +000049
Jamie Madill3c7fa222014-06-05 13:08:51 -040050 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
51 FramebufferAttachment *getDepthbuffer() const;
52 FramebufferAttachment *getStencilbuffer() const;
53 FramebufferAttachment *getDepthStencilBuffer() const;
54 FramebufferAttachment *getDepthOrStencilbuffer() const;
55 FramebufferAttachment *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000056 GLenum getReadColorbufferType() const;
Jamie Madill3c7fa222014-06-05 13:08:51 -040057 FramebufferAttachment *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000059 GLenum getColorbufferType(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000060 GLenum getDepthbufferType() const;
61 GLenum getStencilbufferType() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040062 GLenum getDepthStencilbufferType() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000063
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000064 GLuint getColorbufferHandle(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000065 GLuint getDepthbufferHandle() const;
66 GLuint getStencilbufferHandle() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040067 GLenum getDepthStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000068
Geoff Langc90d73a2013-07-22 16:39:23 -040069 GLenum getColorbufferMipLevel(unsigned int colorAttachment) const;
70 GLenum getDepthbufferMipLevel() const;
71 GLenum getStencilbufferMipLevel() const;
72 GLenum getDepthStencilbufferMipLevel() const;
73
74 GLenum getColorbufferLayer(unsigned int colorAttachment) const;
75 GLenum getDepthbufferLayer() const;
76 GLenum getStencilbufferLayer() const;
77 GLenum getDepthStencilbufferLayer() const;
78
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000079 GLenum getDrawBufferState(unsigned int colorAttachment) const;
80 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
81
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000082 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
83 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000084 bool hasStencil() const;
85 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000086 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000087
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000088 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000089
90 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -040091 FramebufferTextureBindingPointer<FramebufferAttachment> mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000092 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
93 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000094
Jamie Madill3c7fa222014-06-05 13:08:51 -040095 FramebufferTextureBindingPointer<FramebufferAttachment> mDepthbuffer;
96 FramebufferTextureBindingPointer<FramebufferAttachment> mStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000097
daniel@transgaming.com16418b12012-11-28 19:32:22 +000098 rx::Renderer *mRenderer;
99
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000100 private:
101 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
102
Jamie Madill6c7b4ad2014-06-16 10:33:59 -0400103 FramebufferAttachmentImpl *createAttachmentImpl(GLenum type, GLuint handle, GLint level, GLint layer) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000104};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000105
106class DefaultFramebuffer : public Framebuffer
107{
108 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +0000109 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000110
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000111 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000112
113 private:
114 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
115};
116
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000117}
118
119#endif // LIBGLESV2_FRAMEBUFFER_H_