OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGL3PlusTexture.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 
29 #ifndef __GL3PlusTexture_H__
30 #define __GL3PlusTexture_H__
31 
33 #include "OgreGL3PlusSupport.h"
34 #include "OgrePlatform.h"
35 #include "OgreRenderTexture.h"
36 #include "OgreTexture.h"
38 
39 namespace Ogre {
41  {
42  public:
43  // Constructor
44  GL3PlusTexture(ResourceManager* creator, const String& name, ResourceHandle handle,
45  const String& group, bool isManual, ManualResourceLoader* loader,
46  GL3PlusSupport& support);
47 
48  virtual ~GL3PlusTexture();
49 
50  void createRenderTexture();
52  HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap);
53 
54  // Takes the OGRE texture type (1d/2d/3d/cube) and returns the appropriate GL one
55  GLenum getGL3PlusTextureTarget(void) const;
56 
70  GLuint getGLID( bool &outIsFsaa ) const
71  {
72  GLuint retVal = mTextureID;
73  bool isFsaa = false;
74 
75  if( mFSAA > 0 )
76  {
77  RenderTarget *renderTarget = mSurfaceList[0]->getRenderTarget();
78  if( !mFsaaExplicitResolve )
79  {
80  for( size_t face=0; face<getNumFaces(); ++face )
81  {
82  renderTarget = mSurfaceList[face * (mNumMipmaps+1)]->getRenderTarget();
83  if( renderTarget->isFsaaResolveDirty() )
84  renderTarget->swapBuffers( );
85  }
86  }
87  else if( renderTarget->isFsaaResolveDirty() )
88  {
89  //GL 3.2+ supports explicit resolves. Only use the
90  //Fsaa texture before it has been resolved
91  renderTarget->getCustomAttribute( "GL_MULTISAMPLEFBOID", &retVal );
92  isFsaa = true;
93  }
94  }
95 
96  outIsFsaa = isFsaa;
97  return mTextureID;
98  }
99 
100  void getCustomAttribute(const String& name, void* pData);
101 
102  void createShaderAccessPoint(uint bindPoint, TextureAccess access = TA_READ_WRITE,
103  int mipmapLevel = 0, int textureArrayIndex = 0,
104  PixelFormat* format = NULL);
105 
106  protected:
108  void createInternalResourcesImpl(void);
110  void prepareImpl(void);
112  void unprepareImpl(void);
114  void loadImpl(void);
116  void freeInternalResourcesImpl(void);
117 
123  void _createSurfaceList();
124 
127 
133 
134 
135  private:
136  GLuint mTextureID;
138 
142  };
143 }
144 
145 #endif
A 'canvas' which can receive the results of a rendering operation.
GL3PlusSupport & mGLSupport
SharedPtr< vector< Image >::type > LoadedImages
Used to hold images between calls to prepare and load.
Interface describing a manual resource loader.
Definition: OgreResource.h:498
bool isFsaaResolveDirty(void) const
PixelFormat
The pixel format used for images, textures, and render surfaces.
Shared pointer implementation used to share pixel buffers.
#define _OgreGL3PlusExport
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
TextureAccess
Enum identifying the texture access privilege.
Definition: OgreTexture.h:67
LoadedImages mLoadedImages
Vector of images that were pulled from disk by prepareLoad but have yet to be pushed into texture mem...
Defines a generic resource handler.
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Definition: OgreCommon.h:53
virtual void getCustomAttribute(const String &name, void *pData)
Gets a custom (maybe platform-specific) attribute.
vector< HardwarePixelBufferSharedPtr >::type SurfaceList
Vector of pointers to subsurfaces.
Abstract class representing a Texture resource.
Definition: OgreTexture.h:111
GLuint getGLID(bool &outIsFsaa) const
Returns the GL Id of the texture.
virtual void swapBuffers(void)
Swaps the frame buffers to display the next frame.
unsigned int uint