blob: 09951457a61cfc26234c0043bac662c075551064 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
2// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3// 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
13#define GL_APICALL
14#include <GLES2/gl2.h>
15#include <d3d9.h>
16
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000017#include "common/angleutils.h"
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000018#include "libGLESv2/RefCountObject.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000019
20namespace gl
21{
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000022class Renderbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000023class Colorbuffer;
24class Depthbuffer;
25class Stencilbuffer;
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +000026class DepthStencilbuffer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
apatrick@chromium.orgff8bdfb2010-09-15 17:27:49 +000028class Framebuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000029{
30 public:
apatrick@chromium.orgff8bdfb2010-09-15 17:27:49 +000031 Framebuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000032
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000033 virtual ~Framebuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000034
35 void setColorbuffer(GLenum type, GLuint colorbuffer);
36 void setDepthbuffer(GLenum type, GLuint depthbuffer);
37 void setStencilbuffer(GLenum type, GLuint stencilbuffer);
38
39 void detachTexture(GLuint texture);
40 void detachRenderbuffer(GLuint renderbuffer);
41
42 IDirect3DSurface9 *getRenderTarget();
43 IDirect3DSurface9 *getDepthStencil();
44
daniel@transgaming.com092bd482010-05-12 03:39:36 +000045 unsigned int getRenderTargetSerial();
daniel@transgaming.com339ae702010-05-12 03:40:20 +000046 unsigned int getDepthbufferSerial();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +000047 unsigned int getStencilbufferSerial();
daniel@transgaming.com092bd482010-05-12 03:39:36 +000048
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 Colorbuffer *getColorbuffer();
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +000050 DepthStencilbuffer *getDepthbuffer();
51 DepthStencilbuffer *getStencilbuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +000053 GLenum getColorbufferType();
54 GLenum getDepthbufferType();
55 GLenum getStencilbufferType();
56
57 GLuint getColorbufferHandle();
58 GLuint getDepthbufferHandle();
59 GLuint getStencilbufferHandle();
60
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000061 bool hasStencil();
daniel@transgaming.comd470a1b2010-08-24 19:20:48 +000062 bool isMultisample();
daniel@transgaming.com1f135d82010-08-24 19:20:36 +000063 int getSamples();
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +000064
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000065 virtual GLenum completeness();
66
67 protected:
68 GLenum mColorbufferType;
69 BindingPointer<Renderbuffer> mColorbufferPointer;
70
71 GLenum mDepthbufferType;
72 BindingPointer<Renderbuffer> mDepthbufferPointer;
73
74 GLenum mStencilbufferType;
75 BindingPointer<Renderbuffer> mStencilbufferPointer;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000076
77 private:
78 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
79
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000080 Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000081};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +000082
83class DefaultFramebuffer : public Framebuffer
84{
85 public:
86 DefaultFramebuffer(Colorbuffer *color, DepthStencilbuffer *depthStencil);
87
88 virtual GLenum completeness();
89
90 private:
91 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
92};
93
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000094}
95
96#endif // LIBGLESV2_FRAMEBUFFER_H_