OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 __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, uint32 width, uint32 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
A 'canvas' which can receive the results of a rendering operation.
Allowed modes/properties for this pixel format.
unsigned int uint32
Definition: OgrePlatform.h:344
GL surface descriptor.
std::vector< T, A > type
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
#define _OgreGLES2Export
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
Factory for GL ES 2 Frame Buffer Objects, and related things.
RenderTexture for GL ES 2 FBO.
void unbind(RenderTarget *target)
Unbind a certain render target.
This class represents a render target that renders to multiple RenderTextures at once.
An abstract class that contains a depth/stencil buffer.
#define MANAGED_RESOURCE
PixelFormat
The pixel format used for images, textures, and render surfaces.
map< RBFormat, RBRef >::type RenderBufferMap
Frame Buffer Object abstraction.
GLuint mTempFBO
Temporary FBO identifier.
RBRef(GLES2RenderBuffer *inBuffer)
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
_StringBase String
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Frame Buffer Object properties for a certain texture format.
Base class for GL Render Textures.
unsigned int uint
Manager/factory for RenderTextures.