OgreGLTexture.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __GLTEXTURE_H__
  25. #define __GLTEXTURE_H__
  26. #include "OgreGLPrerequisites.h"
  27. #include "OgrePlatform.h"
  28. #include "OgreRenderTexture.h"
  29. #include "OgreTexture.h"
  30. #include "OgreGLSupport.h"
  31. #include "OgreHardwarePixelBuffer.h"
  32. namespace Ogre {
  33. class _OgreGLExport GLTexture : public Texture
  34. {
  35. public:
  36. // Constructor
  37. GLTexture(GLSupport& support);
  38. virtual ~GLTexture();
  39. void createRenderTexture();
  40. /// @copydoc Texture::getBuffer
  41. HardwarePixelBufferPtr getBuffer(size_t face, size_t mipmap);
  42. // Takes the OGRE texture type (1d/2d/3d/cube) and returns the appropriate GL one
  43. GLenum getGLTextureTarget(void) const;
  44. GLuint getGLID() const
  45. {
  46. return mTextureID;
  47. }
  48. void getCustomAttribute(const String& name, void* pData);
  49. protected:
  50. /// @copydoc Texture::createInternalResourcesImpl
  51. void createInternalResourcesImpl(void);
  52. /// @copydoc Resource::prepareImpl
  53. void prepareImpl(void);
  54. /// @copydoc Resource::unprepareImpl
  55. void unprepareImpl(void);
  56. /// @copydoc Resource::loadImpl
  57. void loadImpl(void);
  58. /// @copydoc Resource::freeInternalResourcesImpl
  59. void freeInternalResourcesImpl(void);
  60. /** internal method, create GLHardwarePixelBuffers for every face and
  61. mipmap level. This method must be called after the GL texture object was created,
  62. the number of mipmaps was set (GL_TEXTURE_MAX_LEVEL) and glTexImageXD was called to
  63. actually allocate the buffer
  64. */
  65. void _createSurfaceList();
  66. /// Used to hold images between calls to prepare and load.
  67. //typedef SharedPtr<vector<Image>::type > LoadedImages;
  68. /** Vector of images that were pulled from disk by
  69. prepareLoad but have yet to be pushed into texture memory
  70. by loadImpl. Images should be deleted by loadImpl and unprepareImpl.
  71. */
  72. //LoadedImages mLoadedImages;
  73. private:
  74. GLuint mTextureID;
  75. GLSupport& mGLSupport;
  76. /// Vector of pointers to subsurfaces
  77. typedef vector<HardwarePixelBufferPtr>::type SurfaceList;
  78. SurfaceList mSurfaceList;
  79. };
  80. typedef std::shared_ptr<GLTexture> GLTexturePtr;
  81. }
  82. #endif // __GLTEXTURE_H__