llgltfmaterialpreview.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file llgltfmaterialpreview.h
  3. * @brief The LLAppViewer class definitions
  4. *
  5. * $LicenseInfo:firstyear=2023&license=viewergpl$
  6. *
  7. * Copyright (c) 2023, 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_LLGLTFMATERIALPREVIEW_H
  33. #define LL_LLGLTFMATERIALPREVIEW_H
  34. #include "lldynamictexture.h"
  35. #include "llfetchedgltfmaterial.h"
  36. class LLGLTFPreviewTexture final : public LLViewerDynamicTexture
  37. {
  38. protected:
  39. // Use getPreview()
  40. LLGLTFPreviewTexture(LLFetchedGLTFMaterial* matp, S32 width = 512);
  41. public:
  42. // Returns NULL if the material is not loaded yet. Note: the texture should
  43. // be cached if the same material is being previewed.
  44. static LLPointer<LLViewerTexture> getPreview(LLFetchedGLTFMaterial* matp);
  45. bool needsRender() override;
  46. void preRender(bool clear_depth = true) override;
  47. bool render() override;
  48. void postRender(bool success) override;
  49. class MaterialLoadLevels
  50. {
  51. public:
  52. MaterialLoadLevels();
  53. bool isFullyLoaded() const;
  54. LL_INLINE S32& operator[](size_t i) { return mLevels[i]; }
  55. LL_INLINE const S32& operator[](size_t i) const { return mLevels[i]; }
  56. // Less is better. Returns false if lhs is not strictly less or equal
  57. // for all levels.
  58. bool operator<(const MaterialLoadLevels& other) const;
  59. // Less is better. Returns false if lhs is not strictly greater or
  60. // equal for all levels
  61. bool operator>(const MaterialLoadLevels& other) const;
  62. public:
  63. S32 mLevels[LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT];
  64. };
  65. private:
  66. LLPointer<LLFetchedGLTFMaterial> mGLTFMaterial;
  67. MaterialLoadLevels mBestLoad;
  68. bool mShouldRender;
  69. };
  70. #endif // LL_LLGLTFMATERIALPREVIEW_H