CmGLTexture.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 "CmGLPrerequisites.h"
  27. #include "CmRenderTexture.h"
  28. #include "CmTexture.h"
  29. #include "CmGLSupport.h"
  30. #include "CmHardwarePixelBuffer.h"
  31. namespace CamelotEngine {
  32. class CM_RSGL_EXPORT GLTexture : public Texture
  33. {
  34. public:
  35. // Constructor
  36. GLTexture(GLSupport& support);
  37. virtual ~GLTexture();
  38. void createRenderTexture();
  39. /// @copydoc Texture::getBuffer
  40. HardwarePixelBufferPtr getBuffer(size_t face, size_t mipmap);
  41. // Takes the OGRE texture type (1d/2d/3d/cube) and returns the appropriate GL one
  42. GLenum getGLTextureTarget(void) const;
  43. GLuint getGLID() const
  44. {
  45. return mTextureID;
  46. }
  47. void getCustomAttribute(const String& name, void* pData);
  48. /// @copydoc Resource::loadImpl
  49. void initImpl();
  50. protected:
  51. /// @copydoc Texture::createInternalResourcesImpl
  52. void createInternalResourcesImpl(void);
  53. /// @copydoc Resource::freeInternalResourcesImpl
  54. void freeInternalResourcesImpl(void);
  55. /** internal method, create GLHardwarePixelBuffers for every face and
  56. mipmap level. This method must be called after the GL texture object was created,
  57. the number of mipmaps was set (GL_TEXTURE_MAX_LEVEL) and glTexImageXD was called to
  58. actually allocate the buffer
  59. */
  60. void _createSurfaceList();
  61. /// Used to hold images between calls to prepare and load.
  62. //typedef SharedPtr<vector<Image>::type > LoadedImages;
  63. /** Vector of images that were pulled from disk by
  64. prepareLoad but have yet to be pushed into texture memory
  65. by loadImpl. Images should be deleted by loadImpl and unprepareImpl.
  66. */
  67. //LoadedImages mLoadedImages;
  68. private:
  69. GLuint mTextureID;
  70. GLSupport& mGLSupport;
  71. /// Vector of pointers to subsurfaces
  72. typedef vector<HardwarePixelBufferPtr>::type SurfaceList;
  73. SurfaceList mSurfaceList;
  74. };
  75. typedef std::shared_ptr<GLTexture> GLTexturePtr;
  76. }
  77. #endif // __GLTEXTURE_H__