OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLFBORenderTexture.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 __OgreGLFBORTT_H__
29 #define __OgreGLFBORTT_H__
30 
31 #include "OgreGLRenderTexture.h"
32 #include "OgreGLContext.h"
34 
36 #define GL_DEPTH24_STENCIL8_EXT 0x88F0
37 
38 
39 namespace Ogre {
40  class GLFBOManager;
41 
45  {
46  public:
47  GLFBORenderTexture(GLFBOManager *manager, const String &name, const GLSurfaceDesc &target, bool writeGamma, uint fsaa);
48 
49  virtual void getCustomAttribute(const String& name, void* pData);
50 
52  virtual void swapBuffers();
53 
55  virtual bool attachDepthBuffer( DepthBuffer *depthBuffer );
56  virtual void detachDepthBuffer();
57  virtual void _detachDepthBuffer();
58  protected:
60  };
61 
65  {
66  public:
67  GLFBOManager(bool atimode);
68  ~GLFBOManager();
69 
73  void bind(RenderTarget *target);
74 
77  void unbind(RenderTarget *target) {};
78 
81  void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat);
82 
85  virtual GLFBORenderTexture *createRenderTexture(const String &name,
86  const GLSurfaceDesc &target, bool writeGamma, uint fsaa);
87 
90  virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
91 
94  GLSurfaceDesc requestRenderBuffer(GLenum format, uint32 width, uint32 height, uint fsaa);
98  void requestRenderBuffer(const GLSurfaceDesc &surface);
101  void releaseRenderBuffer(const GLSurfaceDesc &surface);
102 
105  bool checkFormat(PixelFormat format) { return mProps[format].valid; }
106 
109  GLuint getTemporaryFBO() { return mTempFBO; }
110  private:
114  {
115  bool valid; // This format can be used as RTT (FBO)
116 
119  struct Mode
120  {
121  size_t depth; // Depth format (0=no depth)
122  size_t stencil; // Stencil format (0=no stencil)
123  };
124 
126  };
130 
135  struct RBFormat
136  {
137  RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa):
138  format(inFormat), width(inWidth), height(inHeight), samples(fsaa)
139  {}
140  RBFormat() {}
141  GLenum format;
142  size_t width;
143  size_t height;
145  // Overloaded comparison operator for usage in map
146  bool operator < (const RBFormat &other) const
147  {
148  if(format < other.format)
149  {
150  return true;
151  }
152  else if(format == other.format)
153  {
154  if(width < other.width)
155  {
156  return true;
157  }
158  else if(width == other.width)
159  {
160  if(height < other.height)
161  return true;
162  else if (height == other.height)
163  {
164  if (samples < other.samples)
165  return true;
166  }
167  }
168  }
169  return false;
170  }
171  };
172  struct RBRef
173  {
174  RBRef(){}
175  RBRef(GLRenderBuffer *inBuffer):
176  buffer(inBuffer), refcount(1)
177  { }
179  size_t refcount;
180  };
183  // map(format, sizex, sizey) -> [GLSurface*,refcount]
184 
187  GLuint mTempFBO;
188 
190  bool mATIMode;
191 
193  void detectFBOFormats();
194  GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
195  bool _tryPackedFormat(GLenum packedFormat);
196  void _createTempFramebuffer(GLuint fmt, GLuint &fb, GLuint &tid);
197  };
198 
199 
200 }
201 
202 #endif
A 'canvas' which can receive the results of a rendering operation.
unsigned int uint32
Definition: OgrePlatform.h:420
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.
RenderBufferMap mRenderBufferMap
#define _OgreGLExport
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
bool mATIMode
Buggy ATI driver?
This class represents a render target that renders to multiple RenderTextures at once.
Allowed modes/properties for this pixel format.
map< RBFormat, RBRef >::type RenderBufferMap
RenderTexture for GL FBO.
An abstract class that contains a depth/stencil buffer.
Frame Buffer Object abstraction.
PixelFormat
The pixel format used for images, textures, and render surfaces.
Factory for GL Frame Buffer Objects, and related things.
RBRef(GLRenderBuffer *inBuffer)
Renderbuffer surface.
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Base class for GL Render Textures.
void unbind(RenderTarget *target)
Unbind a certain render target.
_StringBase String
Definition: OgreCommon.h:53
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
Manager/factory for RenderTextures.
GL surface descriptor.
Frame Buffer Object properties for a certain texture format.
unsigned int uint
GLuint mTempFBO
Temporary FBO identifier.