CCTextureCube.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /****************************************************************************
  2. Copyright (c) 2015-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  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. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CCTEXTURECUBE_H__
  22. #define __CCTEXTURECUBE_H__
  23. #include "renderer/CCTexture2D.h"
  24. #include <string>
  25. #include <unordered_map>
  26. #include "base/ccTypes.h"
  27. NS_CC_BEGIN
  28. /**
  29. * @addtogroup _3d
  30. * @{
  31. */
  32. /**
  33. TextureCube is a collection of six separate square textures that are put
  34. onto the faces of an imaginary cube.
  35. */
  36. class CC_DLL TextureCube: public Texture2D
  37. {
  38. public:
  39. /** create cube texture from 6 textures.
  40. @param positive_x texture for the right side of the texture cube face.
  41. @param negative_x texture for the up side of the texture cube face.
  42. @param positive_y texture for the top side of the texture cube face
  43. @param negative_y texture for the bottom side of the texture cube face
  44. @param positive_z texture for the forward side of the texture cube face.
  45. @param negative_z texture for the rear side of the texture cube face.
  46. @return A new texture cube inited with given parameters.
  47. */
  48. static TextureCube* create(const std::string& positive_x, const std::string& negative_x,
  49. const std::string& positive_y, const std::string& negative_y,
  50. const std::string& positive_z, const std::string& negative_z);
  51. /** Sets the min filter, mag filter, wrap s and wrap t texture parameters.
  52. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
  53. */
  54. void setTexParameters(const TexParams&);
  55. /** reload texture cube after GLESContext reconstructed.*/
  56. bool reloadTexture();
  57. CC_CONSTRUCTOR_ACCESS:
  58. /**
  59. * Constructor.
  60. */
  61. TextureCube();
  62. /**
  63. * Destructor.
  64. */
  65. virtual ~TextureCube();
  66. protected:
  67. bool init(const std::string& positive_x, const std::string& negative_x,
  68. const std::string& positive_y, const std::string& negative_y,
  69. const std::string& positive_z, const std::string& negative_z);
  70. private:
  71. std::vector<std::string> _imgPath;
  72. };
  73. // end of 3d group
  74. /// @}
  75. NS_CC_END
  76. #endif // __CCTEXTURECUBE_H__