OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLESFBORenderTexture.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __OgreGLESFBORTT_H__
29 #define __OgreGLESFBORTT_H__
30 
31 #include "OgreGLESRenderTexture.h"
32 #include "OgreGLESContext.h"
35 
36 namespace Ogre {
37  class GLESFBOManager;
38  class GLESRenderBuffer;
39 
43  {
44  public:
45  GLESFBORenderTexture(GLESFBOManager *manager, const String &name, const GLESSurfaceDesc &target, bool writeGamma, uint fsaa);
46 
47  virtual void getCustomAttribute(const String& name, void* pData);
48 
50  virtual void swapBuffers();
51 
53  virtual bool attachDepthBuffer( DepthBuffer *depthBuffer );
54  virtual void detachDepthBuffer();
55  virtual void _detachDepthBuffer();
56  protected:
58 
59 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
60 
61  virtual void notifyOnContextLost();
62 
64  virtual void notifyOnContextReset();
65 #endif
66  };
67 
71  {
72  public:
74  ~GLESFBOManager();
75 
79  void bind(RenderTarget *target);
80 
83  void unbind(RenderTarget *target) {};
84 
87  void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat);
88 
91  virtual GLESFBORenderTexture *createRenderTexture(const String &name,
92  const GLESSurfaceDesc &target, bool writeGamma, uint fsaa);
93 
96  virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
97 
100  GLESSurfaceDesc requestRenderBuffer(GLenum format, size_t width, size_t height, uint fsaa);
104  void requestRenderBuffer(const GLESSurfaceDesc &surface);
107  void releaseRenderBuffer(const GLESSurfaceDesc &surface);
108 
111  bool checkFormat(PixelFormat format) { return mProps[format].valid; }
112 
115  GLuint getTemporaryFBO() { return mTempFBO; }
116 
118  void _reload();
119 
120  private:
124  {
125  bool valid; // This format can be used as RTT (FBO)
126 
129  struct Mode
130  {
131  size_t depth; // Depth format (0=no depth)
132  size_t stencil; // Stencil format (0=no stencil)
133  };
134 
136  };
140 
145  struct RBFormat
146  {
147  RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa):
148  format(inFormat), width(inWidth), height(inHeight), samples(fsaa)
149  {}
150  GLenum format;
151  size_t width;
152  size_t height;
154  // Overloaded comparison operator for usage in map
155  bool operator < (const RBFormat &other) const
156  {
157  if(format < other.format)
158  {
159  return true;
160  }
161  else if(format == other.format)
162  {
163  if(width < other.width)
164  {
165  return true;
166  }
167  else if(width == other.width)
168  {
169  if(height < other.height)
170  return true;
171  else if (height == other.height)
172  {
173  if (samples < other.samples)
174  return true;
175  }
176  }
177  }
178  return false;
179  }
180  };
181  struct RBRef
182  {
183  RBRef(){}
185  buffer(inBuffer), refcount(1)
186  { }
188  size_t refcount;
189  };
192  // map(format, sizex, sizey) -> [GLSurface*,refcount]
193 
196  GLuint mTempFBO;
197 
199  void detectFBOFormats();
200  GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
201  bool _tryPackedFormat(GLenum packedFormat);
202  };
203 }
204 
205 #endif
A 'canvas' which can receive the results of a rendering operation.
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
std::vector< T, A > type
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
RenderTexture for GL ES FBO.
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
GL surface descriptor.
#define _OgreGLESExport
Frame Buffer Object properties for a certain texture format.
This class represents a render target that renders to multiple RenderTextures at once.
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Frame Buffer Object abstraction.
Manager/factory for RenderTextures.
An abstract class that contains a depth/stencil buffer.
#define MANAGED_RESOURCE
PixelFormat
The pixel format used for images, textures, and render surfaces.
void unbind(RenderTarget *target)
Unbind a certain render target.
Allowed modes/properties for this pixel format.
GLuint mTempFBO
Temporary FBO identifier.
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
map< RBFormat, RBRef >::type RenderBufferMap
_StringBase String
Definition: OgreCommon.h:53
Base class for GL Render Textures.
Factory for GL Frame Buffer Objects, and related things.
RBRef(GLESRenderBuffer *inBuffer)
unsigned int uint