daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 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 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 7 | // Renderbuffer.h: Defines the wrapper class gl::Renderbuffer, as well as the |
| 8 | // class hierarchy used to store its contents: RenderbufferStorage, Colorbuffer, |
| 9 | // DepthStencilbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10 | // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108. |
| 11 | |
| 12 | #ifndef LIBGLESV2_RENDERBUFFER_H_ |
| 13 | #define LIBGLESV2_RENDERBUFFER_H_ |
| 14 | |
| 15 | #define GL_APICALL |
| 16 | #include <GLES2/gl2.h> |
| 17 | #include <d3d9.h> |
| 18 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 19 | #include "common/angleutils.h" |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 20 | #include "libGLESv2/RefCountObject.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | |
| 22 | namespace gl |
| 23 | { |
enne@chromium.org | 0fa7463 | 2010-09-21 16:18:52 +0000 | [diff] [blame^] | 24 | class Texture; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 25 | |
| 26 | // A class derived from RenderbufferStorage is created whenever glRenderbufferStorage |
| 27 | // is called. The specific concrete type depends on whether the internal format is |
| 28 | // colour depth, stencil or packed depth/stencil. |
| 29 | class RenderbufferStorage |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 30 | { |
| 31 | public: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 32 | RenderbufferStorage(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 33 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 34 | virtual ~RenderbufferStorage() = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 35 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 36 | virtual bool isColorbuffer() const; |
| 37 | virtual bool isDepthbuffer() const; |
| 38 | virtual bool isStencilbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 39 | |
| 40 | virtual IDirect3DSurface9 *getRenderTarget(); |
| 41 | virtual IDirect3DSurface9 *getDepthStencil(); |
| 42 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 43 | virtual int getWidth() const; |
| 44 | virtual int getHeight() const; |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 45 | virtual GLenum getFormat() const; |
daniel@transgaming.com | 1297d92 | 2010-09-01 15:47:47 +0000 | [diff] [blame] | 46 | virtual bool isFloatingPoint() const; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 47 | D3DFORMAT getD3DFormat() const; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 48 | GLsizei getSamples() const; |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 49 | unsigned int getSerial() const; |
| 50 | |
| 51 | static unsigned int issueSerial(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | |
| 53 | protected: |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 54 | void setSize(int width, int height); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 55 | GLenum mFormat; |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 56 | D3DFORMAT mD3DFormat; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 57 | GLsizei mSamples; |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 58 | unsigned int mSerial; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 59 | |
| 60 | private: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage); |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 62 | |
| 63 | static unsigned int mCurrentSerial; |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 64 | |
| 65 | int mWidth; |
| 66 | int mHeight; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 69 | // Renderbuffer implements the GL renderbuffer object. |
| 70 | // It's only a wrapper for a RenderbufferStorage, but the internal object |
| 71 | // can change whenever glRenderbufferStorage is called. |
| 72 | class Renderbuffer : public RefCountObject |
| 73 | { |
| 74 | public: |
| 75 | Renderbuffer(GLuint id, RenderbufferStorage *storage); |
| 76 | |
| 77 | ~Renderbuffer(); |
| 78 | |
| 79 | bool isColorbuffer() const; |
| 80 | bool isDepthbuffer() const; |
| 81 | bool isStencilbuffer() const; |
| 82 | |
| 83 | IDirect3DSurface9 *getRenderTarget(); |
| 84 | IDirect3DSurface9 *getDepthStencil(); |
| 85 | |
| 86 | int getWidth() const; |
| 87 | int getHeight() const; |
| 88 | GLenum getFormat() const; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 89 | D3DFORMAT getD3DFormat() const; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 90 | unsigned int getSerial() const; |
| 91 | |
| 92 | void setStorage(RenderbufferStorage *newStorage); |
| 93 | RenderbufferStorage *getStorage() { return mStorage; } |
| 94 | |
| 95 | private: |
| 96 | DISALLOW_COPY_AND_ASSIGN(Renderbuffer); |
| 97 | |
| 98 | RenderbufferStorage *mStorage; |
| 99 | }; |
| 100 | |
| 101 | class Colorbuffer : public RenderbufferStorage |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 102 | { |
| 103 | public: |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 104 | explicit Colorbuffer(IDirect3DSurface9 *renderTarget); |
enne@chromium.org | 0fa7463 | 2010-09-21 16:18:52 +0000 | [diff] [blame^] | 105 | explicit Colorbuffer(const Texture* texture); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 106 | Colorbuffer(int width, int height, GLenum format, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 107 | |
| 108 | ~Colorbuffer(); |
| 109 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 110 | bool isColorbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 111 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 112 | GLuint getRedSize() const; |
| 113 | GLuint getGreenSize() const; |
| 114 | GLuint getBlueSize() const; |
| 115 | GLuint getAlphaSize() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 116 | |
| 117 | IDirect3DSurface9 *getRenderTarget(); |
| 118 | |
| 119 | protected: |
| 120 | IDirect3DSurface9 *mRenderTarget; |
| 121 | |
| 122 | private: |
| 123 | DISALLOW_COPY_AND_ASSIGN(Colorbuffer); |
| 124 | }; |
| 125 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 126 | class DepthStencilbuffer : public RenderbufferStorage |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 127 | { |
| 128 | public: |
| 129 | explicit DepthStencilbuffer(IDirect3DSurface9 *depthStencil); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 130 | DepthStencilbuffer(int width, int height, GLsizei samples); |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 131 | |
| 132 | ~DepthStencilbuffer(); |
| 133 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 134 | virtual bool isDepthbuffer() const; |
| 135 | virtual bool isStencilbuffer() const; |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 136 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 137 | GLuint getDepthSize() const; |
| 138 | GLuint getStencilSize() const; |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 139 | |
| 140 | IDirect3DSurface9 *getDepthStencil(); |
| 141 | |
| 142 | private: |
| 143 | DISALLOW_COPY_AND_ASSIGN(DepthStencilbuffer); |
| 144 | IDirect3DSurface9 *mDepthStencil; |
| 145 | }; |
| 146 | |
| 147 | class Depthbuffer : public DepthStencilbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 148 | { |
| 149 | public: |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 150 | explicit Depthbuffer(IDirect3DSurface9 *depthStencil); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 151 | Depthbuffer(int width, int height, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 152 | |
| 153 | ~Depthbuffer(); |
| 154 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 155 | bool isDepthbuffer() const; |
| 156 | bool isStencilbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 157 | |
| 158 | private: |
| 159 | DISALLOW_COPY_AND_ASSIGN(Depthbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 162 | class Stencilbuffer : public DepthStencilbuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 163 | { |
| 164 | public: |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 165 | explicit Stencilbuffer(IDirect3DSurface9 *depthStencil); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 166 | Stencilbuffer(int width, int height, GLsizei samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 167 | |
| 168 | ~Stencilbuffer(); |
| 169 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 170 | bool isDepthbuffer() const; |
| 171 | bool isStencilbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 172 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 173 | private: |
| 174 | DISALLOW_COPY_AND_ASSIGN(Stencilbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 175 | }; |
| 176 | } |
| 177 | |
| 178 | #endif // LIBGLESV2_RENDERBUFFER_H_ |