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-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 __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
Ogre::GLFBOManager::RBFormat::samples
uint samples
Definition: OgreGLFBORenderTexture.h:144
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GLFBOManager::FormatProperties::modes
vector< Mode >::type modes
Definition: OgreGLFBORenderTexture.h:125
Ogre::DepthBuffer
An abstract class that contains a depth/stencil buffer.
Definition: OgreDepthBuffer.h:82
Ogre::map
Definition: OgrePrerequisites.h:533
OgreGLFrameBufferObject.h
Ogre::GLRenderTexture
Base class for GL Render Textures.
Definition: OgreGLRenderTexture.h:49
OgreGLContext.h
Ogre::GLFBOManager::mATIMode
bool mATIMode
Buggy ATI driver?
Definition: OgreGLFBORenderTexture.h:190
Ogre::GLFBOManager::RBRef::RBRef
RBRef(GLRenderBuffer *inBuffer)
Definition: OgreGLFBORenderTexture.h:175
Ogre::GLFBOManager::RBFormat::RBFormat
RBFormat()
Definition: OgreGLFBORenderTexture.h:140
Ogre::GLFBOManager::RenderBufferMap
map< RBFormat, RBRef >::type RenderBufferMap
Definition: OgreGLFBORenderTexture.h:181
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLFBOManager::unbind
void unbind(RenderTarget *target)
Unbind a certain render target.
Definition: OgreGLFBORenderTexture.h:77
Ogre::GLFBOManager::FormatProperties
Frame Buffer Object properties for a certain texture format.
Definition: OgreGLFBORenderTexture.h:113
Ogre::GLFBORenderTexture::mFB
GLFrameBufferObject mFB
Definition: OgreGLFBORenderTexture.h:59
Ogre::GLRenderBuffer
Renderbuffer surface.
Definition: OgreGLHardwarePixelBuffer.h:127
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
Ogre::GLFBOManager
Factory for GL Frame Buffer Objects, and related things.
Definition: OgreGLFBORenderTexture.h:64
Ogre::GLFBOManager::FormatProperties::valid
bool valid
Definition: OgreGLFBORenderTexture.h:115
Ogre::GLFBOManager::RBRef::buffer
GLRenderBuffer * buffer
Definition: OgreGLFBORenderTexture.h:178
Ogre::RenderTarget
A 'canvas' which can receive the results of a rendering operation.
Definition: OgreRenderTarget.h:65
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::GLFBOManager::RBFormat::height
size_t height
Definition: OgreGLFBORenderTexture.h:143
Ogre::GLFBOManager::mRenderBufferMap
RenderBufferMap mRenderBufferMap
Definition: OgreGLFBORenderTexture.h:182
_OgreGLExport
#define _OgreGLExport
Definition: OgreGLPrerequisites.h:99
Ogre::GLFBOManager::RBFormat::RBFormat
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
Definition: OgreGLFBORenderTexture.h:137
Ogre::GLFrameBufferObject
Frame Buffer Object abstraction.
Definition: OgreGLFrameBufferObject.h:38
Ogre::GLFBOManager::RBFormat::width
size_t width
Definition: OgreGLFBORenderTexture.h:142
Ogre::MultiRenderTarget
This class represents a render target that renders to multiple RenderTextures at once.
Definition: OgreRenderTexture.h:69
Ogre::GLFBOManager::RBFormat
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
Definition: OgreGLFBORenderTexture.h:135
Ogre::GLFBOManager::RBRef::RBRef
RBRef()
Definition: OgreGLFBORenderTexture.h:174
Ogre::GLFBOManager::getTemporaryFBO
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Definition: OgreGLFBORenderTexture.h:109
Ogre::GLFBORenderTexture
RenderTexture for GL FBO.
Definition: OgreGLFBORenderTexture.h:44
Ogre::GLFBOManager::RBRef::refcount
size_t refcount
Definition: OgreGLFBORenderTexture.h:179
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::PF_COUNT
@ PF_COUNT
Definition: OgrePixelFormat.h:260
Ogre::GLFBOManager::mTempFBO
GLuint mTempFBO
Temporary FBO identifier.
Definition: OgreGLFBORenderTexture.h:187
Ogre::GLFBOManager::checkFormat
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
Definition: OgreGLFBORenderTexture.h:105
Ogre::GLFBOManager::FormatProperties::Mode::depth
size_t depth
Definition: OgreGLFBORenderTexture.h:121
Ogre::GLFBOManager::FormatProperties::Mode
Allowed modes/properties for this pixel format.
Definition: OgreGLFBORenderTexture.h:119
Ogre::GLRTTManager
Manager/factory for RenderTextures.
Definition: OgreGLRenderTexture.h:64
Ogre::GLSurfaceDesc
GL surface descriptor.
Definition: OgreGLRenderTexture.h:37
OgreGLRenderTexture.h
Ogre::GLFBOManager::FormatProperties::Mode::stencil
size_t stencil
Definition: OgreGLFBORenderTexture.h:122
Ogre::operator<
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Definition: OgreSharedPtr.h:326
Ogre::GLFBOManager::RBFormat::format
GLenum format
Definition: OgreGLFBORenderTexture.h:141
Ogre::GLFBOManager::RBRef
Definition: OgreGLFBORenderTexture.h:172

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