llcubemaparray.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * @file llcubemaparray.h
  3. * @brief LLCubeMapArray class definition
  4. *
  5. * $LicenseInfo:firstyear=2022&license=viewergpl$
  6. *
  7. * Copyright (c) 2022, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLCUBEMAPARRAY_H
  33. #define LL_LLCUBEMAPARRAY_H
  34. #include "llgl.h"
  35. #include "llimagegl.h"
  36. class LLVector3;
  37. class LLCubeMapArray : public LLRefCount
  38. {
  39. friend class LLTexUnit;
  40. protected:
  41. LL_INLINE ~LLCubeMapArray()
  42. {
  43. destroyGL();
  44. }
  45. public:
  46. LL_INLINE LLCubeMapArray()
  47. : mTextureStage(0),
  48. mTexName(0),
  49. mResolution(0),
  50. mCount(0)
  51. {
  52. }
  53. // Allocates a cube map array
  54. // res - resolution of each cube face
  55. // components - number of components per pixel
  56. // count - number of cube maps in the array
  57. // use_mips - if true, mipmaps will be allocated for this cube map array
  58. // and anisotropic filtering will be used.
  59. void allocate(U32 res, U32 components, U32 count, bool use_mips = true);
  60. void bind(S32 stage);
  61. void unbind();
  62. LL_INLINE U32 getGLName() const { return mImage->getTexName(); }
  63. void destroyGL();
  64. // Returns the resolution of the cubemaps in the array.
  65. LL_INLINE U32 getResolution() const { return mResolution; }
  66. // Returns the number of cubemaps in the array
  67. LL_INLINE U32 getCount() const { return mCount; }
  68. protected:
  69. // Note: the first member variable is 32 bits in order to align on 64 bits
  70. // for the next variables, counting the 32 bits counter from LLRefCount. HB
  71. S32 mTextureStage;
  72. LLPointer<LLImageGL> mImage;
  73. U32 mTexName; // For GL image alloc tracking.
  74. U32 mResolution;
  75. U32 mCount;
  76. public:
  77. static GLenum sTargets[6];
  78. // Look and up vectors for each cube face (agent space)
  79. static LLVector3 sLookVecs[6];
  80. static LLVector3 sUpVecs[6];
  81. // Look and up vectors for each cube face (clip space)
  82. static LLVector3 sClipToCubeLookVecs[6];
  83. static LLVector3 sClipToCubeUpVecs[6];
  84. };
  85. #endif // LL_LLCUBEMAPARRAY_H