OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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"
34 
35 namespace Ogre {
36  class GLESFBOManager;
37  class GLESRenderBuffer;
38 
42  {
43  public:
44  GLESFBORenderTexture(GLESFBOManager *manager, const String &name, const GLESSurfaceDesc &target, bool writeGamma, uint fsaa);
45 
46  virtual void getCustomAttribute(const String& name, void* pData);
47 
49  virtual void swapBuffers(bool waitForVSync = true);
50  protected:
52  };
53 
57  {
58  public:
60  ~GLESFBOManager();
61 
65  void bind(RenderTarget *target);
66 
69  void unbind(RenderTarget *target) {};
70 
73  void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat);
74 
77  virtual GLESFBORenderTexture *createRenderTexture(const String &name,
78  const GLESSurfaceDesc &target, bool writeGamma, uint fsaa);
79 
82  virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
83 
86  GLESSurfaceDesc requestRenderBuffer(GLenum format, size_t width, size_t height, uint fsaa);
90  void requestRenderBuffer(const GLESSurfaceDesc &surface);
93  void releaseRenderBuffer(const GLESSurfaceDesc &surface);
94 
97  bool checkFormat(PixelFormat format) { return mProps[format].valid; }
98 
101  GLuint getTemporaryFBO() { return mTempFBO; }
102  private:
106  {
107  bool valid; // This format can be used as RTT (FBO)
108 
111  struct Mode
112  {
113  size_t depth; // Depth format (0=no depth)
114  size_t stencil; // Stencil format (0=no stencil)
115  };
116 
118  };
122 
127  struct RBFormat
128  {
129  RBFormat(GLenum format, size_t width, size_t height, uint fsaa):
130  format(format), width(width), height(height), samples(fsaa)
131  {}
132  GLenum format;
133  size_t width;
134  size_t height;
136  // Overloaded comparison operator for usage in map
137  bool operator < (const RBFormat &other) const
138  {
139  if(format < other.format)
140  {
141  return true;
142  }
143  else if(format == other.format)
144  {
145  if(width < other.width)
146  {
147  return true;
148  }
149  else if(width == other.width)
150  {
151  if(height < other.height)
152  return true;
153  else if (height == other.height)
154  {
155  if (samples < other.samples)
156  return true;
157  }
158  }
159  }
160  return false;
161  }
162  };
163  struct RBRef
164  {
165  RBRef(){}
167  buffer(buffer), refcount(1)
168  { }
170  size_t refcount;
171  };
174  // map(format, sizex, sizey) -> [GLSurface*,refcount]
175 
178  GLuint mTempFBO;
179 
181  void detectFBOFormats();
182  GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
183  bool _tryPackedFormat(GLenum packedFormat);
184  };
185 }
186 
187 #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
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.
PixelFormat
The pixel format used for images, textures, and render surfaces.
void unbind(RenderTarget *target)
Unbind a certain render target.
RBFormat(GLenum format, size_t width, size_t height, uint fsaa)
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
Base class for GL Render Textures.
Factory for GL Frame Buffer Objects, and related things.
RBRef(GLESRenderBuffer *buffer)
unsigned int uint