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 | |
| 7 | // Renderbuffer.cpp: the gl::Renderbuffer class and its derived classes |
| 8 | // Colorbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer |
| 9 | // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108. |
| 10 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 13 | #include "libGLESv2/main.h" |
| 14 | #include "libGLESv2/utilities.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 15 | |
| 16 | namespace gl |
| 17 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 18 | unsigned int RenderbufferStorage::mCurrentSerial = 1; |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 19 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 20 | Renderbuffer::Renderbuffer(GLuint id, RenderbufferStorage *storage) : RefCountObject(id) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 22 | ASSERT(storage != NULL); |
| 23 | mStorage = storage; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | Renderbuffer::~Renderbuffer() |
| 27 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 28 | delete mStorage; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 29 | } |
| 30 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 31 | bool Renderbuffer::isColorbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 32 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 33 | return mStorage->isColorbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 34 | } |
| 35 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 36 | bool Renderbuffer::isDepthbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 38 | return mStorage->isDepthbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 39 | } |
| 40 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 41 | bool Renderbuffer::isStencilbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 43 | return mStorage->isStencilbuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | IDirect3DSurface9 *Renderbuffer::getRenderTarget() |
| 47 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 48 | return mStorage->getRenderTarget(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | IDirect3DSurface9 *Renderbuffer::getDepthStencil() |
| 52 | { |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 53 | return mStorage->getDepthStencil(); |
| 54 | } |
| 55 | |
| 56 | int Renderbuffer::getWidth() const |
| 57 | { |
| 58 | return mStorage->getWidth(); |
| 59 | } |
| 60 | |
| 61 | int Renderbuffer::getHeight() const |
| 62 | { |
| 63 | return mStorage->getHeight(); |
| 64 | } |
| 65 | |
| 66 | GLenum Renderbuffer::getFormat() const |
| 67 | { |
| 68 | return mStorage->getFormat(); |
| 69 | } |
| 70 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame^] | 71 | D3DFORMAT Renderbuffer::getD3DFormat() const |
| 72 | { |
| 73 | return mStorage->getD3DFormat(); |
| 74 | } |
| 75 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 76 | unsigned int Renderbuffer::getSerial() const |
| 77 | { |
| 78 | return mStorage->getSerial(); |
| 79 | } |
| 80 | |
| 81 | void Renderbuffer::setStorage(RenderbufferStorage *newStorage) |
| 82 | { |
| 83 | ASSERT(newStorage != NULL); |
| 84 | |
| 85 | delete mStorage; |
| 86 | mStorage = newStorage; |
| 87 | } |
| 88 | |
| 89 | RenderbufferStorage::RenderbufferStorage() |
| 90 | { |
| 91 | mSerial = issueSerial(); |
| 92 | } |
| 93 | |
| 94 | RenderbufferStorage::~RenderbufferStorage() |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | bool RenderbufferStorage::isColorbuffer() const |
| 99 | { |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | bool RenderbufferStorage::isDepthbuffer() const |
| 104 | { |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | bool RenderbufferStorage::isStencilbuffer() const |
| 109 | { |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | IDirect3DSurface9 *RenderbufferStorage::getRenderTarget() |
| 114 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 115 | return NULL; |
| 116 | } |
| 117 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 118 | IDirect3DSurface9 *RenderbufferStorage::getDepthStencil() |
| 119 | { |
| 120 | return NULL; |
| 121 | } |
| 122 | |
| 123 | int RenderbufferStorage::getWidth() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 124 | { |
| 125 | return mWidth; |
| 126 | } |
| 127 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 128 | int RenderbufferStorage::getHeight() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 129 | { |
| 130 | return mHeight; |
| 131 | } |
| 132 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 133 | void RenderbufferStorage::setSize(int width, int height) |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 134 | { |
| 135 | mWidth = width; |
| 136 | mHeight = height; |
| 137 | } |
| 138 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 139 | GLenum RenderbufferStorage::getFormat() const |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 140 | { |
| 141 | return mFormat; |
| 142 | } |
| 143 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame^] | 144 | D3DFORMAT RenderbufferStorage::getD3DFormat() const |
| 145 | { |
| 146 | return mD3DFormat; |
| 147 | } |
| 148 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 149 | unsigned int RenderbufferStorage::getSerial() const |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 150 | { |
| 151 | return mSerial; |
| 152 | } |
| 153 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 154 | unsigned int RenderbufferStorage::issueSerial() |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 155 | { |
| 156 | return mCurrentSerial++; |
| 157 | } |
| 158 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 159 | Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(renderTarget) |
| 160 | { |
| 161 | if (renderTarget) |
| 162 | { |
| 163 | renderTarget->AddRef(); |
| 164 | |
| 165 | D3DSURFACE_DESC description; |
| 166 | renderTarget->GetDesc(&description); |
| 167 | |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 168 | setSize(description.Width, description.Height); |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 169 | mD3DFormat = description.Format; |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | mD3DFormat = D3DFMT_UNKNOWN; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 174 | } |
daniel@transgaming.com | 092bd48 | 2010-05-12 03:39:36 +0000 | [diff] [blame] | 175 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 176 | } |
| 177 | |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 178 | Colorbuffer::Colorbuffer(int width, int height, GLenum format) |
| 179 | { |
| 180 | IDirect3DDevice9 *device = getDevice(); |
| 181 | |
| 182 | mRenderTarget = NULL; |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 183 | D3DFORMAT requestedFormat = es2dx::ConvertRenderbufferFormat(format); |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 184 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 185 | if (width > 0 && height > 0) |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 186 | { |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 187 | HRESULT result = device->CreateRenderTarget(width, height, requestedFormat, |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 188 | D3DMULTISAMPLE_NONE, 0, FALSE, &mRenderTarget, NULL); |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 189 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 190 | if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) |
| 191 | { |
| 192 | error(GL_OUT_OF_MEMORY); |
| 193 | |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | ASSERT(SUCCEEDED(result)); |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 198 | } |
| 199 | |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 200 | if (mRenderTarget) |
| 201 | { |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 202 | setSize(width, height); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 203 | mFormat = format; |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 204 | mD3DFormat = requestedFormat; |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 205 | } |
| 206 | else |
| 207 | { |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 208 | setSize(0, 0); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 209 | mFormat = GL_RGBA4; |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 210 | mD3DFormat = D3DFMT_UNKNOWN; |
daniel@transgaming.com | 70d312a | 2010-04-20 18:52:38 +0000 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 214 | Colorbuffer::~Colorbuffer() |
| 215 | { |
| 216 | if (mRenderTarget) |
| 217 | { |
| 218 | mRenderTarget->Release(); |
| 219 | } |
| 220 | } |
| 221 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 222 | bool Colorbuffer::isColorbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 223 | { |
| 224 | return true; |
| 225 | } |
| 226 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 227 | GLuint Colorbuffer::getRedSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 228 | { |
| 229 | if (mRenderTarget) |
| 230 | { |
| 231 | D3DSURFACE_DESC description; |
| 232 | mRenderTarget->GetDesc(&description); |
| 233 | |
| 234 | return es2dx::GetRedSize(description.Format); |
| 235 | } |
| 236 | |
| 237 | return 0; |
| 238 | } |
| 239 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 240 | GLuint Colorbuffer::getGreenSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 241 | { |
| 242 | if (mRenderTarget) |
| 243 | { |
| 244 | D3DSURFACE_DESC description; |
| 245 | mRenderTarget->GetDesc(&description); |
| 246 | |
| 247 | return es2dx::GetGreenSize(description.Format); |
| 248 | } |
| 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 253 | GLuint Colorbuffer::getBlueSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 254 | { |
| 255 | if (mRenderTarget) |
| 256 | { |
| 257 | D3DSURFACE_DESC description; |
| 258 | mRenderTarget->GetDesc(&description); |
| 259 | |
| 260 | return es2dx::GetBlueSize(description.Format); |
| 261 | } |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 266 | GLuint Colorbuffer::getAlphaSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 267 | { |
| 268 | if (mRenderTarget) |
| 269 | { |
| 270 | D3DSURFACE_DESC description; |
| 271 | mRenderTarget->GetDesc(&description); |
| 272 | |
| 273 | return es2dx::GetAlphaSize(description.Format); |
| 274 | } |
| 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | IDirect3DSurface9 *Colorbuffer::getRenderTarget() |
| 280 | { |
| 281 | return mRenderTarget; |
| 282 | } |
| 283 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 284 | DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepthStencil(depthStencil) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 285 | { |
| 286 | if (depthStencil) |
| 287 | { |
| 288 | depthStencil->AddRef(); |
| 289 | |
| 290 | D3DSURFACE_DESC description; |
| 291 | depthStencil->GetDesc(&description); |
| 292 | |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 293 | setSize(description.Width, description.Height); |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 294 | mFormat = (description.Format == D3DFMT_D16 ? GL_DEPTH_COMPONENT16 : GL_DEPTH24_STENCIL8_OES); |
| 295 | mD3DFormat = description.Format; |
| 296 | } |
| 297 | else |
| 298 | { |
| 299 | mD3DFormat = D3DFMT_UNKNOWN; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 303 | DepthStencilbuffer::DepthStencilbuffer(int width, int height) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 304 | { |
| 305 | IDirect3DDevice9 *device = getDevice(); |
| 306 | |
| 307 | mDepthStencil = NULL; |
| 308 | HRESULT result = device->CreateDepthStencilSurface(width, height, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &mDepthStencil, 0); |
| 309 | |
| 310 | if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) |
| 311 | { |
| 312 | error(GL_OUT_OF_MEMORY); |
| 313 | |
| 314 | return; |
| 315 | } |
| 316 | |
| 317 | ASSERT(SUCCEEDED(result)); |
| 318 | |
| 319 | if (mDepthStencil) |
| 320 | { |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 321 | setSize(width, height); |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 322 | mFormat = GL_DEPTH24_STENCIL8_OES; |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 323 | mD3DFormat = D3DFMT_D24S8; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 324 | } |
| 325 | else |
| 326 | { |
daniel@transgaming.com | 866f318 | 2010-05-20 19:28:22 +0000 | [diff] [blame] | 327 | setSize(0, 0); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 328 | mFormat = GL_RGBA4; //default format |
daniel@transgaming.com | ca7c008 | 2010-08-24 19:20:20 +0000 | [diff] [blame] | 329 | mD3DFormat = D3DFMT_UNKNOWN; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 333 | DepthStencilbuffer::~DepthStencilbuffer() |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 334 | { |
| 335 | if (mDepthStencil) |
| 336 | { |
| 337 | mDepthStencil->Release(); |
| 338 | } |
| 339 | } |
| 340 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 341 | bool DepthStencilbuffer::isDepthbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 342 | { |
| 343 | return true; |
| 344 | } |
| 345 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 346 | bool DepthStencilbuffer::isStencilbuffer() const |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 347 | { |
| 348 | return true; |
| 349 | } |
| 350 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 351 | GLuint DepthStencilbuffer::getDepthSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 352 | { |
| 353 | if (mDepthStencil) |
| 354 | { |
| 355 | D3DSURFACE_DESC description; |
| 356 | mDepthStencil->GetDesc(&description); |
| 357 | |
daniel@transgaming.com | 7a2c280 | 2010-03-16 06:23:33 +0000 | [diff] [blame] | 358 | return es2dx::GetDepthSize(description.Format); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | return 0; |
| 362 | } |
| 363 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 364 | GLuint DepthStencilbuffer::getStencilSize() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 365 | { |
| 366 | if (mDepthStencil) |
| 367 | { |
| 368 | D3DSURFACE_DESC description; |
| 369 | mDepthStencil->GetDesc(&description); |
| 370 | |
| 371 | return es2dx::GetStencilSize(description.Format); |
| 372 | } |
| 373 | |
| 374 | return 0; |
| 375 | } |
| 376 | |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 377 | IDirect3DSurface9 *DepthStencilbuffer::getDepthStencil() |
| 378 | { |
| 379 | return mDepthStencil; |
| 380 | } |
| 381 | |
| 382 | Depthbuffer::Depthbuffer(IDirect3DSurface9 *depthStencil) : DepthStencilbuffer(depthStencil) |
| 383 | { |
| 384 | if (depthStencil) |
| 385 | { |
| 386 | mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function |
| 387 | // will expect one of the valid renderbuffer formats for use in |
| 388 | // glRenderbufferStorage |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | Depthbuffer::Depthbuffer(int width, int height) : DepthStencilbuffer(width, height) |
| 393 | { |
| 394 | if (getDepthStencil()) |
| 395 | { |
| 396 | mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function |
| 397 | // will expect one of the valid renderbuffer formats for use in |
| 398 | // glRenderbufferStorage |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | Depthbuffer::~Depthbuffer() |
| 403 | { |
| 404 | } |
| 405 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 406 | bool Depthbuffer::isDepthbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 407 | { |
| 408 | return true; |
| 409 | } |
| 410 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 411 | bool Depthbuffer::isStencilbuffer() const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 412 | { |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 413 | return false; |
| 414 | } |
| 415 | |
| 416 | Stencilbuffer::Stencilbuffer(IDirect3DSurface9 *depthStencil) : DepthStencilbuffer(depthStencil) |
| 417 | { |
| 418 | if (depthStencil) |
| 419 | { |
| 420 | mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function |
| 421 | // will expect one of the valid renderbuffer formats for use in |
| 422 | // glRenderbufferStorage |
| 423 | } |
| 424 | else |
| 425 | { |
| 426 | mFormat = GL_RGBA4; //default format |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | Stencilbuffer::Stencilbuffer(int width, int height) : DepthStencilbuffer(width, height) |
| 431 | { |
| 432 | if (getDepthStencil()) |
| 433 | { |
| 434 | mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function |
| 435 | // will expect one of the valid renderbuffer formats for use in |
| 436 | // glRenderbufferStorage |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | Stencilbuffer::~Stencilbuffer() |
| 441 | { |
| 442 | } |
| 443 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 444 | bool Stencilbuffer::isDepthbuffer() const |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 445 | { |
| 446 | return false; |
| 447 | } |
| 448 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 449 | bool Stencilbuffer::isStencilbuffer() const |
daniel@transgaming.com | cdacc8e | 2010-07-28 19:20:50 +0000 | [diff] [blame] | 450 | { |
| 451 | return true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 452 | } |
| 453 | } |