blob: c3e0f0b139275daba6ee744c0c1fe0d88fcdaa3a [file] [log] [blame]
Nicolas Capensdbf6fc82014-10-23 13:33:20 -04001// SwiftShader Software Renderer
2//
3// Copyright(c) 2005-2013 TransGaming Inc.
4//
5// All rights reserved. No part of this software may be copied, distributed, transmitted,
6// transcribed, stored in a retrieval system, translated into any human or computer
7// language by any means, or disclosed to third parties without the explicit written
8// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
9// or implied, including but not limited to any patent rights, are granted to you.
10//
11
12// Framebuffer.h: Defines the Framebuffer class. Implements GL framebuffer
13// objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
14
15#ifndef LIBGLESV2_FRAMEBUFFER_H_
16#define LIBGLESV2_FRAMEBUFFER_H_
17
18#include "RefCountObject.h"
19#include "Image.hpp"
20
21#define GL_APICALL
22#include <GLES2/gl2.h>
23
24namespace gl
25{
26class Renderbuffer;
27class Colorbuffer;
28class Depthbuffer;
29class Stencilbuffer;
30class DepthStencilbuffer;
31
32class Framebuffer
33{
34public:
35 Framebuffer();
36
37 virtual ~Framebuffer();
38
39 void setColorbuffer(GLenum type, GLuint colorbuffer);
40 void setDepthbuffer(GLenum type, GLuint depthbuffer);
41 void setStencilbuffer(GLenum type, GLuint stencilbuffer);
42
43 void detachTexture(GLuint texture);
44 void detachRenderbuffer(GLuint renderbuffer);
45
46 Image *getRenderTarget();
47 Image *getDepthStencil();
48
49 Renderbuffer *getColorbuffer();
50 Renderbuffer *getDepthbuffer();
51 Renderbuffer *getStencilbuffer();
52
53 GLenum getColorbufferType();
54 GLenum getDepthbufferType();
55 GLenum getStencilbufferType();
56
57 GLuint getColorbufferHandle();
58 GLuint getDepthbufferHandle();
59 GLuint getStencilbufferHandle();
60
61 bool hasStencil();
62
63 virtual GLenum completeness();
64 GLenum completeness(int &width, int &height, int &samples);
65
66protected:
67 GLenum mColorbufferType;
68 BindingPointer<Renderbuffer> mColorbufferPointer;
69
70 GLenum mDepthbufferType;
71 BindingPointer<Renderbuffer> mDepthbufferPointer;
72
73 GLenum mStencilbufferType;
74 BindingPointer<Renderbuffer> mStencilbufferPointer;
75
76private:
77 Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
78};
79
80class DefaultFramebuffer : public Framebuffer
81{
82public:
83 DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
84
85 virtual GLenum completeness();
86};
87
88}
89
90#endif // LIBGLESV2_FRAMEBUFFER_H_