blob: 1a5e2b6801c86c4f704e5b6ddf95d42c8bed478f [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;
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
Geoff Lang309c92a2013-07-25 16:23:19 -040037 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
38 void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
39 void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
40 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
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
Jamie Madill3c7fa222014-06-05 13:08:51 -040049 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
50 FramebufferAttachment *getDepthbuffer() const;
51 FramebufferAttachment *getStencilbuffer() const;
52 FramebufferAttachment *getDepthStencilBuffer() const;
53 FramebufferAttachment *getDepthOrStencilbuffer() const;
54 FramebufferAttachment *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000055 GLenum getReadColorbufferType() const;
Jamie Madill3c7fa222014-06-05 13:08:51 -040056 FramebufferAttachment *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 getDepthbufferType() const;
60 GLenum getStencilbufferType() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040061 GLenum getDepthStencilbufferType() 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 getDepthbufferHandle() const;
65 GLuint getStencilbufferHandle() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040066 GLenum getDepthStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000067
Geoff Langc90d73a2013-07-22 16:39:23 -040068 GLenum getColorbufferMipLevel(unsigned int colorAttachment) const;
69 GLenum getDepthbufferMipLevel() const;
70 GLenum getStencilbufferMipLevel() const;
71 GLenum getDepthStencilbufferMipLevel() const;
72
73 GLenum getColorbufferLayer(unsigned int colorAttachment) const;
74 GLenum getDepthbufferLayer() const;
75 GLenum getStencilbufferLayer() const;
76 GLenum getDepthStencilbufferLayer() const;
77
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000078 GLenum getDrawBufferState(unsigned int colorAttachment) const;
79 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
80
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000081 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
82 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000083 bool hasStencil() const;
84 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000085 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000086
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000087 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000088
89 protected:
Jamie Madill3c7fa222014-06-05 13:08:51 -040090 FramebufferTextureBindingPointer<FramebufferAttachment> mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000091 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
92 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000093
Jamie Madill3c7fa222014-06-05 13:08:51 -040094 FramebufferTextureBindingPointer<FramebufferAttachment> mDepthbuffer;
95 FramebufferTextureBindingPointer<FramebufferAttachment> mStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000096
daniel@transgaming.com16418b12012-11-28 19:32:22 +000097 rx::Renderer *mRenderer;
98
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000099 private:
100 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
101
Jamie Madill3c7fa222014-06-05 13:08:51 -0400102 FramebufferAttachment *lookupAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000103};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000104
105class DefaultFramebuffer : public Framebuffer
106{
107 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +0000108 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000109
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000110 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000111
112 private:
113 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
114};
115
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000116}
117
118#endif // LIBGLESV2_FRAMEBUFFER_H_