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