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