blob: 9205638839a1d618e629f20cee4366e349f03a8d [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// Renderbuffer.h: Defines the virtual gl::Renderbuffer class and its derived
8// classes Colorbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer
9// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
10
11#ifndef LIBGLESV2_RENDERBUFFER_H_
12#define LIBGLESV2_RENDERBUFFER_H_
13
14#define GL_APICALL
15#include <GLES2/gl2.h>
16#include <d3d9.h>
17
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000018#include "common/angleutils.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000019
20namespace gl
21{
22class Renderbuffer
23{
24 public:
25 Renderbuffer();
26
27 virtual ~Renderbuffer();
28
29 virtual bool isColorbuffer();
30 virtual bool isDepthbuffer();
31 virtual bool isStencilbuffer();
32
33 virtual IDirect3DSurface9 *getRenderTarget();
34 virtual IDirect3DSurface9 *getDepthStencil();
35
daniel@transgaming.com866f3182010-05-20 19:28:22 +000036 virtual int getWidth();
37 virtual int getHeight();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +000038 GLenum getFormat();
daniel@transgaming.com092bd482010-05-12 03:39:36 +000039 unsigned int getSerial() const;
40
41 static unsigned int issueSerial();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000042
43 protected:
daniel@transgaming.com866f3182010-05-20 19:28:22 +000044 void setSize(int width, int height);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +000045 GLenum mFormat;
daniel@transgaming.com092bd482010-05-12 03:39:36 +000046 unsigned int mSerial;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000047
48 private:
49 DISALLOW_COPY_AND_ASSIGN(Renderbuffer);
daniel@transgaming.com092bd482010-05-12 03:39:36 +000050
51 static unsigned int mCurrentSerial;
daniel@transgaming.com866f3182010-05-20 19:28:22 +000052
53 int mWidth;
54 int mHeight;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055};
56
57class Colorbuffer : public Renderbuffer
58{
59 public:
daniel@transgaming.com70d312a2010-04-20 18:52:38 +000060 explicit Colorbuffer(IDirect3DSurface9 *renderTarget);
61 Colorbuffer(int width, int height, GLenum format);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000062
63 ~Colorbuffer();
64
65 bool isColorbuffer();
66
67 GLuint getRedSize();
68 GLuint getGreenSize();
69 GLuint getBlueSize();
70 GLuint getAlphaSize();
71
72 IDirect3DSurface9 *getRenderTarget();
73
74 protected:
75 IDirect3DSurface9 *mRenderTarget;
76
77 private:
78 DISALLOW_COPY_AND_ASSIGN(Colorbuffer);
79};
80
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +000081class DepthStencilbuffer : public Renderbuffer
82{
83 public:
84 explicit DepthStencilbuffer(IDirect3DSurface9 *depthStencil);
85 DepthStencilbuffer(int width, int height);
86
87 ~DepthStencilbuffer();
88
89 virtual bool isDepthbuffer();
90 virtual bool isStencilbuffer();
91
92 GLuint getDepthSize();
93 GLuint getStencilSize();
94
95 IDirect3DSurface9 *getDepthStencil();
96
97 private:
98 DISALLOW_COPY_AND_ASSIGN(DepthStencilbuffer);
99 IDirect3DSurface9 *mDepthStencil;
100};
101
102class Depthbuffer : public DepthStencilbuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000103{
104 public:
daniel@transgaming.com70d312a2010-04-20 18:52:38 +0000105 explicit Depthbuffer(IDirect3DSurface9 *depthStencil);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000106 Depthbuffer(int width, int height);
107
108 ~Depthbuffer();
109
110 bool isDepthbuffer();
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +0000111 bool isStencilbuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000112
113 private:
114 DISALLOW_COPY_AND_ASSIGN(Depthbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115};
116
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +0000117class Stencilbuffer : public DepthStencilbuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000118{
119 public:
daniel@transgaming.com70d312a2010-04-20 18:52:38 +0000120 explicit Stencilbuffer(IDirect3DSurface9 *depthStencil);
daniel@transgaming.com4a9d65c2010-03-08 21:30:56 +0000121 Stencilbuffer(int width, int height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000122
123 ~Stencilbuffer();
124
daniel@transgaming.comcdacc8e2010-07-28 19:20:50 +0000125 bool isDepthbuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000126 bool isStencilbuffer();
127
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000128 private:
129 DISALLOW_COPY_AND_ASSIGN(Stencilbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000130};
131}
132
133#endif // LIBGLESV2_RENDERBUFFER_H_