OGLTextureCube.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  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. #pragma once
  24. #include "RenderSurface.h"
  25. #include "SharedPtr.h"
  26. #include "Texture.h"
  27. class Deserializer;
  28. class Image;
  29. /// Cube texture resource
  30. class TextureCube : public Texture
  31. {
  32. OBJECT(TextureCube);
  33. public:
  34. /// Construct
  35. TextureCube(Context* context);
  36. /// Destruct
  37. virtual ~TextureCube();
  38. /// Register object factory
  39. static void RegisterObject(Context* context);
  40. /// Load resource. Return true if successful
  41. virtual bool Load(Deserializer& source);
  42. /// Release texture
  43. virtual void Release();
  44. /// Set size, format and usage. Return true if successful
  45. bool SetSize(int size, unsigned format, TextureUsage usage = TEXTURE_STATIC);
  46. /// Load one face from a stream. Return true if successful
  47. bool Load(CubeMapFace face, Deserializer& source);
  48. /// Load one face from an image. Return true if successful
  49. bool Load(CubeMapFace face, SharedPtr<Image> image);
  50. /// Return render surface for one face
  51. RenderSurface* GetRenderSurface(CubeMapFace face) const { return renderSurfaces_[face]; }
  52. private:
  53. /// Create texture
  54. bool Create();
  55. /// Render surfaces
  56. SharedPtr<RenderSurface> renderSurfaces_[MAX_CUBEMAP_FACES];
  57. /// Memory use per face
  58. unsigned faceMemoryUse_[MAX_CUBEMAP_FACES];
  59. };