OgreGL3PlusFBORenderTexture.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 __OgreGL3PlusFBORTT_H__
29 #define __OgreGL3PlusFBORTT_H__
30 
32 #include "OgreGL3PlusContext.h"
34 
35 namespace Ogre {
36  class GL3PlusFBOManager;
37  class GL3PlusRenderBuffer;
38 
42  {
43  public:
44  GL3PlusFBORenderTexture(GL3PlusFBOManager *manager, const String &name, const GL3PlusSurfaceDesc &target, bool writeGamma, uint fsaa);
45 
46  virtual void getCustomAttribute(const String& name, void* pData);
47 
49  virtual void swapBuffers();
50 
52  virtual bool attachDepthBuffer( DepthBuffer *depthBuffer );
53  virtual void detachDepthBuffer();
54  virtual void _detachDepthBuffer();
55  protected:
57  };
58 
62  {
63  public:
66 
70  void bind(RenderTarget *target);
71 
74  void unbind(RenderTarget *target) {};
75 
78  void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat);
79 
82  virtual GL3PlusFBORenderTexture *createRenderTexture(const String &name,
83  const GL3PlusSurfaceDesc &target, bool writeGamma, uint fsaa);
84 
87  virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
88 
91  GL3PlusSurfaceDesc requestRenderBuffer(GLenum format, uint32 width, uint32 height, uint fsaa);
95  void requestRenderBuffer(const GL3PlusSurfaceDesc &surface);
98  void releaseRenderBuffer(const GL3PlusSurfaceDesc &surface);
99 
102  bool checkFormat(PixelFormat format) { return mProps[format].valid; }
103 
106  GLuint getTemporaryFBO() { return mTempFBO; }
107  private:
111  {
112  bool valid; // This format can be used as RTT (FBO)
113 
116  struct Mode
117  {
118  size_t depth; // Depth format (0=no depth)
119  size_t stencil; // Stencil format (0=no stencil)
120  };
121 
123  };
127 
132  struct RBFormat
133  {
134  RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa):
135  format(inFormat), width(inWidth), height(inHeight), samples(fsaa)
136  {}
137  RBFormat() {}
138  GLenum format;
139  size_t width;
140  size_t height;
142  // Overloaded comparison operator for usage in map
143  bool operator < (const RBFormat &other) const
144  {
145  if(format < other.format)
146  {
147  return true;
148  }
149  else if(format == other.format)
150  {
151  if(width < other.width)
152  {
153  return true;
154  }
155  else if(width == other.width)
156  {
157  if(height < other.height)
158  return true;
159  else if (height == other.height)
160  {
161  if (samples < other.samples)
162  return true;
163  }
164  }
165  }
166  return false;
167  }
168  };
169  struct RBRef
170  {
171  RBRef(){}
173  buffer(inBuffer), refcount(1)
174  { }
176  size_t refcount;
177  };
180 
183  GLuint mTempFBO;
184 
186  void detectFBOFormats();
187  GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
188  bool _tryPackedFormat(GLenum packedFormat);
189  void _createTempFramebuffer(int ogreFormat, GLuint internalFormat, GLuint fmt, GLenum dataType, GLuint &fb, GLuint &tid);
190  };
191 }
192 
193 #endif
OgreGL3PlusFrameBufferObject.h
Ogre::GL3PlusRenderBuffer
Renderbuffer surface.
Definition: OgreGL3PlusHardwarePixelBuffer.h:135
Ogre::GL3PlusFBOManager::RBRef::RBRef
RBRef(GL3PlusRenderBuffer *inBuffer)
Definition: OgreGL3PlusFBORenderTexture.h:172
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::DepthBuffer
An abstract class that contains a depth/stencil buffer.
Definition: OgreDepthBuffer.h:82
OgreGL3PlusContext.h
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::GL3PlusFBOManager::FormatProperties::Mode
Allowed modes/properties for this pixel format.
Definition: OgreGL3PlusFBORenderTexture.h:116
OgreGL3PlusRenderTexture.h
Ogre::GL3PlusFBOManager::mRenderBufferMap
RenderBufferMap mRenderBufferMap
Definition: OgreGL3PlusFBORenderTexture.h:179
Ogre::GL3PlusRenderTexture
Base class for GL Render Textures.
Definition: OgreGL3PlusRenderTexture.h:51
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GL3PlusFBOManager::getTemporaryFBO
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
Definition: OgreGL3PlusFBORenderTexture.h:106
Ogre::GL3PlusFBOManager::unbind
void unbind(RenderTarget *target)
Unbind a certain render target.
Definition: OgreGL3PlusFBORenderTexture.h:74
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
Ogre::GL3PlusFBOManager::RBRef::refcount
size_t refcount
Definition: OgreGL3PlusFBORenderTexture.h:176
Ogre::GL3PlusFBOManager::RBFormat
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
Definition: OgreGL3PlusFBORenderTexture.h:132
Ogre::GL3PlusFrameBufferObject
Frame Buffer Object abstraction.
Definition: OgreGL3PlusFrameBufferObject.h:41
Ogre::GL3PlusFBOManager::RBRef::buffer
GL3PlusRenderBuffer * buffer
Definition: OgreGL3PlusFBORenderTexture.h:175
Ogre::RenderTarget
A 'canvas' which can receive the results of a rendering operation.
Definition: OgreRenderTarget.h:65
Ogre::GL3PlusFBOManager::FormatProperties
Frame Buffer Object properties for a certain texture format.
Definition: OgreGL3PlusFBORenderTexture.h:110
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::GL3PlusFBOManager::FormatProperties::modes
vector< Mode >::type modes
Definition: OgreGL3PlusFBORenderTexture.h:122
Ogre::GL3PlusFBOManager::RBFormat::RBFormat
RBFormat()
Definition: OgreGL3PlusFBORenderTexture.h:137
_OgreGL3PlusExport
#define _OgreGL3PlusExport
Definition: OgreGL3PlusPrerequisites.h:91
Ogre::GL3PlusFBORenderTexture
RenderTexture for GL FBO.
Definition: OgreGL3PlusFBORenderTexture.h:41
Ogre::GL3PlusRTTManager
Manager/factory for RenderTextures.
Definition: OgreGL3PlusRenderTexture.h:65
Ogre::GL3PlusFBOManager::RenderBufferMap
map< RBFormat, RBRef >::type RenderBufferMap
Definition: OgreGL3PlusFBORenderTexture.h:178
Ogre::GL3PlusFBOManager::RBFormat::format
GLenum format
Definition: OgreGL3PlusFBORenderTexture.h:138
Ogre::GL3PlusSurfaceDesc
GL surface descriptor.
Definition: OgreGL3PlusRenderTexture.h:39
Ogre::GL3PlusFBOManager::RBRef
Definition: OgreGL3PlusFBORenderTexture.h:169
Ogre::MultiRenderTarget
This class represents a render target that renders to multiple RenderTextures at once.
Definition: OgreRenderTexture.h:69
Ogre::GL3PlusFBOManager::RBFormat::width
size_t width
Definition: OgreGL3PlusFBORenderTexture.h:139
Ogre::GL3PlusFBOManager::FormatProperties::Mode::depth
size_t depth
Definition: OgreGL3PlusFBORenderTexture.h:118
Ogre::GL3PlusFBOManager::FormatProperties::Mode::stencil
size_t stencil
Definition: OgreGL3PlusFBORenderTexture.h:119
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::PF_COUNT
@ PF_COUNT
Definition: OgrePixelFormat.h:260
Ogre::GL3PlusFBOManager::RBFormat::samples
uint samples
Definition: OgreGL3PlusFBORenderTexture.h:141
Ogre::GL3PlusFBOManager
Factory for GL Frame Buffer Objects, and related things.
Definition: OgreGL3PlusFBORenderTexture.h:61
Ogre::GL3PlusFBORenderTexture::mFB
GL3PlusFrameBufferObject mFB
Definition: OgreGL3PlusFBORenderTexture.h:56
Ogre::GL3PlusFBOManager::RBRef::RBRef
RBRef()
Definition: OgreGL3PlusFBORenderTexture.h:171
Ogre::operator<
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Definition: OgreSharedPtr.h:326
Ogre::GL3PlusFBOManager::checkFormat
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
Definition: OgreGL3PlusFBORenderTexture.h:102
Ogre::GL3PlusFBOManager::mTempFBO
GLuint mTempFBO
Temporary FBO identifier.
Definition: OgreGL3PlusFBORenderTexture.h:183
Ogre::GL3PlusFBOManager::RBFormat::RBFormat
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
Definition: OgreGL3PlusFBORenderTexture.h:134
Ogre::GL3PlusFBOManager::RBFormat::height
size_t height
Definition: OgreGL3PlusFBORenderTexture.h:140
Ogre::GL3PlusFBOManager::FormatProperties::valid
bool valid
Definition: OgreGL3PlusFBORenderTexture.h:112

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