OgreGLES2FBORenderTexture.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-2013 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 __OgreGLES2FBORTT_H__
29 #define __OgreGLES2FBORTT_H__
30 
31 #include "OgreGLES2RenderTexture.h"
32 #include "OgreGLES2Context.h"
35 
36 namespace Ogre {
37  class GLES2FBOManager;
38  class GLES2RenderBuffer;
39 
43  {
44  public:
45  GLES2FBORenderTexture(GLES2FBOManager *manager, const String &name, const GLES2SurfaceDesc &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  ~GLES2FBOManager();
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 GLES2FBORenderTexture *createRenderTexture(const String &name,
92  const GLES2SurfaceDesc &target, bool writeGamma, uint fsaa);
93 
96  virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
97 
100  GLES2SurfaceDesc requestRenderBuffer(GLenum format, size_t width, size_t height, uint fsaa);
104  void requestRenderBuffer(const GLES2SurfaceDesc &surface);
107  void releaseRenderBuffer(const GLES2SurfaceDesc &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  void _createTempFramebuffer(PixelFormat pixFmt, GLuint internalFormat, GLuint fmt, GLenum dataType, GLuint &fb, GLuint &tid);
203  };
204 }
205 
206 #endif
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GLES2FBOManager::RBFormat
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
Definition: OgreGLES2FBORenderTexture.h:145
Ogre::GLES2FBOManager::FormatProperties::modes
vector< Mode >::type modes
Definition: OgreGLES2FBORenderTexture.h:135
Ogre::GLES2FBOManager::RBFormat::format
GLenum format
Definition: OgreGLES2FBORenderTexture.h:150
Ogre::DepthBuffer
An abstract class that contains a depth/stencil buffer.
Definition: OgreDepthBuffer.h:82
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::GLES2FBOManager
Factory for GL ES 2 Frame Buffer Objects, and related things.
Definition: OgreGLES2FBORenderTexture.h:70
Ogre::GLES2FBOManager::RBFormat::width
size_t width
Definition: OgreGLES2FBORenderTexture.h:151
Ogre::GLES2FBOManager::FormatProperties::Mode
Allowed modes/properties for this pixel format.
Definition: OgreGLES2FBORenderTexture.h:129
Ogre::GLES2FBOManager::mRenderBufferMap
RenderBufferMap mRenderBufferMap
Definition: OgreGLES2FBORenderTexture.h:191
OgreGLES2RenderTexture.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLES2FBOManager::RBFormat::samples
uint samples
Definition: OgreGLES2FBORenderTexture.h:153
Ogre::GLES2FBORenderTexture::mFB
GLES2FrameBufferObject mFB
Definition: OgreGLES2FBORenderTexture.h:57
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
Ogre::RenderTarget
A 'canvas' which can receive the results of a rendering operation.
Definition: OgreRenderTarget.h:65
Ogre::GLES2FBOManager::RBRef::RBRef
RBRef()
Definition: OgreGLES2FBORenderTexture.h:183
Ogre::GLES2FBOManager::FormatProperties::Mode::stencil
size_t stencil
Definition: OgreGLES2FBORenderTexture.h:132
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::GLES2SurfaceDesc
GL surface descriptor.
Definition: OgreGLES2RenderTexture.h:39
Ogre::GLES2FBOManager::RBRef::RBRef
RBRef(GLES2RenderBuffer *inBuffer)
Definition: OgreGLES2FBORenderTexture.h:184
OgreGLES2ManagedResource.h
Ogre::GLES2FBOManager::RBRef::refcount
size_t refcount
Definition: OgreGLES2FBORenderTexture.h:188
OgreGLES2Context.h
Ogre::GLES2FBOManager::unbind
void unbind(RenderTarget *target)
Unbind a certain render target.
Definition: OgreGLES2FBORenderTexture.h:83
Ogre::MultiRenderTarget
This class represents a render target that renders to multiple RenderTextures at once.
Definition: OgreRenderTexture.h:69
Ogre::GLES2FBOManager::RBFormat::height
size_t height
Definition: OgreGLES2FBORenderTexture.h:152
Ogre::GLES2FBOManager::mTempFBO
GLuint mTempFBO
Temporary FBO identifier.
Definition: OgreGLES2FBORenderTexture.h:196
Ogre::GLES2FBOManager::FormatProperties::Mode::depth
size_t depth
Definition: OgreGLES2FBORenderTexture.h:131
Ogre::GLES2RenderBuffer
Renderbuffer surface.
Definition: OgreGLES2HardwarePixelBuffer.h:147
Ogre::GLES2FBOManager::RBRef
Definition: OgreGLES2FBORenderTexture.h:181
Ogre::GLES2FBOManager::RenderBufferMap
map< RBFormat, RBRef >::type RenderBufferMap
Definition: OgreGLES2FBORenderTexture.h:190
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::GLES2RTTManager
Manager/factory for RenderTextures.
Definition: OgreGLES2RenderTexture.h:61
Ogre::PF_COUNT
@ PF_COUNT
Definition: OgrePixelFormat.h:260
MANAGED_RESOURCE
#define MANAGED_RESOURCE
Definition: OgreGLESManagedResource.h:33
_OgreGLES2Export
#define _OgreGLES2Export
Definition: OgreGLES2Prerequisites.h:260
Ogre::GLES2FBOManager::FormatProperties::valid
bool valid
Definition: OgreGLES2FBORenderTexture.h:125
Ogre::GLES2FBOManager::getTemporaryFBO
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Definition: OgreGLES2FBORenderTexture.h:115
OgreGLES2FrameBufferObject.h
Ogre::GLES2FBOManager::FormatProperties
Frame Buffer Object properties for a certain texture format.
Definition: OgreGLES2FBORenderTexture.h:123
Ogre::GLES2FBOManager::RBRef::buffer
GLES2RenderBuffer * buffer
Definition: OgreGLES2FBORenderTexture.h:187
Ogre::GLES2FBORenderTexture
RenderTexture for GL ES 2 FBO.
Definition: OgreGLES2FBORenderTexture.h:42
Ogre::GLES2FBOManager::RBFormat::RBFormat
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
Definition: OgreGLES2FBORenderTexture.h:147
Ogre::operator<
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Definition: OgreSharedPtr.h:326
Ogre::GLES2FrameBufferObject
Frame Buffer Object abstraction.
Definition: OgreGLES2FrameBufferObject.h:42
Ogre::GLES2FBOManager::checkFormat
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
Definition: OgreGLES2FBORenderTexture.h:111
Ogre::GLES2RenderTexture
Base class for GL Render Textures.
Definition: OgreGLES2RenderTexture.h:51

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15