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  };
179  RenderBufferMap mRenderBufferMap;
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
Frame Buffer Object properties for a certain texture format.
Frame Buffer Object abstraction.
A &#39;canvas&#39; which can receive the results of a rendering operation.
unsigned int uint
Factory for GL Frame Buffer Objects, and related things.
std::vector< T, A > type
void unbind(RenderTarget *target)
Unbind a certain render target.
Stencil and depth renderbuffers of the same format are re-used between surfaces of the same size and ...
PixelFormat
The pixel format used for images, textures, and render surfaces.
RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa)
bool checkFormat(PixelFormat format)
Check if a certain format is usable as FBO rendertarget format.
Manager/factory for RenderTextures.
#define _OgreGL3PlusExport
_StringBase String
An abstract class that contains a depth/stencil buffer.
Allowed modes/properties for this pixel format.
unsigned int uint32
Definition: OgrePlatform.h:359
This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info...
GLuint getTemporaryFBO()
Get a FBO without depth/stencil for temporary use, like blitting between textures.
RBRef(GL3PlusRenderBuffer *inBuffer)
map< RBFormat, RBRef >::type RenderBufferMap
This class represents a render target that renders to multiple RenderTextures at once.
GLuint mTempFBO
Temporary FBO identifier.
Base class for GL Render Textures.
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)

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 Sun Oct 22 2017 04:04:15