blob: 0f8e11368a2b8eff4deb899505a432235327ee3a [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:
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -040033 Framebuffer(rx::Renderer *renderer, GLuint id);
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 Woodsaa2ab7d2014-06-24 17:51:51 -040037 GLuint id() const { return mId; }
38
Geoff Lang309c92a2013-07-25 16:23:19 -040039 void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
40 void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
41 void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
42 void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000043
44 void detachTexture(GLuint texture);
45 void detachRenderbuffer(GLuint renderbuffer);
46
Jamie Madill3c7fa222014-06-05 13:08:51 -040047 FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
48 FramebufferAttachment *getDepthbuffer() const;
49 FramebufferAttachment *getStencilbuffer() const;
50 FramebufferAttachment *getDepthStencilBuffer() const;
51 FramebufferAttachment *getDepthOrStencilbuffer() const;
52 FramebufferAttachment *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +000053 GLenum getReadColorbufferType() const;
Jamie Madill3c7fa222014-06-05 13:08:51 -040054 FramebufferAttachment *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055
Jamie Madille92a3542014-07-03 10:38:58 -040056 virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
Geoff Langc90d73a2013-07-22 16:39:23 -040057
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000058 GLenum getDrawBufferState(unsigned int colorAttachment) const;
59 void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
60
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +000061 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
62 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000063 bool hasStencil() const;
64 int getSamples() const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +000065 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000066
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000067 virtual GLenum completeness() const;
Jamie Madille92a3542014-07-03 10:38:58 -040068 bool hasValidDepthStencil() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000069
Jamie Madill400a4412014-08-29 15:46:45 -040070 void invalidate(GLsizei numAttachments, const GLenum* attachments,
71 GLint x, GLint y, GLsizei width, GLsizei height);
72
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000073 protected:
Jamie Madille261b442014-06-25 12:42:21 -040074 rx::Renderer *mRenderer;
75
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -040076 GLuint mId;
77
Jamie Madille261b442014-06-25 12:42:21 -040078 FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +000079 GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
80 GLenum mReadBufferState;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000081
Jamie Madille261b442014-06-25 12:42:21 -040082 FramebufferAttachment *mDepthbuffer;
83 FramebufferAttachment *mStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000084
Jamie Madille261b442014-06-25 12:42:21 -040085private:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000086 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
87
Jamie Madille261b442014-06-25 12:42:21 -040088 FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000089};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000090
91class DefaultFramebuffer : public Framebuffer
92{
93 public:
daniel@transgaming.com16418b12012-11-28 19:32:22 +000094 DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000095
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +000096 virtual GLenum completeness() const;
Jamie Madille92a3542014-07-03 10:38:58 -040097 virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000098
99 private:
100 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
101};
102
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000103}
104
105#endif // LIBGLESV2_FRAMEBUFFER_H_