blob: 56eb6d9196dc770b965638c6623a3d6c3b2799b8 [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
Jamie Madill3c7fa222014-06-05 13:08:51 -040045 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
46 FramebufferAttachment *getDepthbuffer() const;
47 FramebufferAttachment *getStencilbuffer() const;
48 FramebufferAttachment *getDepthStencilBuffer() const;
49 FramebufferAttachment *getDepthOrStencilbuffer() const;
50 FramebufferAttachment *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000051 GLenum getReadColorbufferType() const;
Jamie Madill3c7fa222014-06-05 13:08:51 -040052 FramebufferAttachment *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000053
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000054 GLenum getColorbufferType(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000055 GLenum getDepthbufferType() const;
56 GLenum getStencilbufferType() const;
Geoff Lang55ba29c2013-07-11 16:57:53 -040057 GLenum getDepthStencilbufferType() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000058
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000059 GLuint getColorbufferHandle(unsigned int colorAttachment) const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000060 GLuint getDepthbufferHandle() const;
61 GLuint getStencilbufferHandle() const;
Jamie Madille261b442014-06-25 12:42:21 -040062 GLuint getDepthStencilbufferHandle() const;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000063
Jamie Madille261b442014-06-25 12:42:21 -040064 GLint getColorbufferMipLevel(unsigned int colorAttachment) const;
65 GLint getDepthbufferMipLevel() const;
66 GLint getStencilbufferMipLevel() const;
67 GLint getDepthStencilbufferMipLevel() const;
Geoff Langc90d73a2013-07-22 16:39:23 -040068
Jamie Madille261b442014-06-25 12:42:21 -040069 GLint getColorbufferLayer(unsigned int colorAttachment) const;
70 GLint getDepthbufferLayer() const;
71 GLint getStencilbufferLayer() const;
72 GLint getDepthStencilbufferLayer() const;
Geoff Langc90d73a2013-07-22 16:39:23 -040073
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000074 GLenum getDrawBufferState(unsigned int colorAttachment) const;
75 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
76
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000077 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
78 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000079 bool hasStencil() const;
80 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000081 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000082
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000083 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000084
85 protected:
Jamie Madille261b442014-06-25 12:42:21 -040086 rx::Renderer *mRenderer;
87
88 FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000089 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
90 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000091
Jamie Madille261b442014-06-25 12:42:21 -040092 FramebufferAttachment *mDepthbuffer;
93 FramebufferAttachment *mStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000094
Jamie Madille261b442014-06-25 12:42:21 -040095 bool hasValidDepthStencil() const;
daniel@transgaming.com16418b12012-11-28 19:32:22 +000096
Jamie Madille261b442014-06-25 12:42:21 -040097private:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
99
Jamie Madille261b442014-06-25 12:42:21 -0400100 FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000101};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000102
103class DefaultFramebuffer : public Framebuffer
104{
105 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +0000106 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000107
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000108 virtual GLenum completeness() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000109
110 private:
111 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
112};
113
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000114}
115
116#endif // LIBGLESV2_FRAMEBUFFER_H_