editor_preview_plugins.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*************************************************************************/
  2. /* editor_preview_plugins.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef EDITORPREVIEWPLUGINS_H
  31. #define EDITORPREVIEWPLUGINS_H
  32. #include "editor/editor_resource_preview.h"
  33. class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
  34. GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator)
  35. public:
  36. virtual bool handles(const String &p_type) const;
  37. virtual Ref<Texture> generate(const RES &p_from);
  38. EditorTexturePreviewPlugin();
  39. };
  40. class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
  41. GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator)
  42. public:
  43. virtual bool handles(const String &p_type) const;
  44. virtual Ref<Texture> generate(const RES &p_from);
  45. EditorBitmapPreviewPlugin();
  46. };
  47. class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
  48. public:
  49. virtual bool handles(const String &p_type) const;
  50. virtual Ref<Texture> generate(const RES &p_from);
  51. virtual Ref<Texture> generate_from_path(const String &p_path);
  52. EditorPackedScenePreviewPlugin();
  53. };
  54. class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
  55. GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator)
  56. RID scenario;
  57. RID sphere;
  58. RID sphere_instance;
  59. RID viewport;
  60. RID viewport_texture;
  61. RID light;
  62. RID light_instance;
  63. RID light2;
  64. RID light_instance2;
  65. RID camera;
  66. volatile bool preview_done;
  67. void _preview_done(const Variant &p_udata);
  68. protected:
  69. static void _bind_methods();
  70. public:
  71. virtual bool handles(const String &p_type) const;
  72. virtual Ref<Texture> generate(const RES &p_from);
  73. EditorMaterialPreviewPlugin();
  74. ~EditorMaterialPreviewPlugin();
  75. };
  76. class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
  77. public:
  78. virtual bool handles(const String &p_type) const;
  79. virtual Ref<Texture> generate(const RES &p_from);
  80. EditorScriptPreviewPlugin();
  81. };
  82. // FIXME: Needs to be rewritten for AudioStream in Godot 3.0+
  83. #if 0
  84. class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator {
  85. public:
  86. virtual bool handles(const String& p_type) const;
  87. virtual Ref<Texture> generate(const RES& p_from);
  88. EditorSamplePreviewPlugin();
  89. };
  90. #endif
  91. class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
  92. GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator)
  93. RID scenario;
  94. RID mesh_instance;
  95. RID viewport;
  96. RID viewport_texture;
  97. RID light;
  98. RID light_instance;
  99. RID light2;
  100. RID light_instance2;
  101. RID camera;
  102. volatile bool preview_done;
  103. void _preview_done(const Variant &p_udata);
  104. protected:
  105. static void _bind_methods();
  106. public:
  107. virtual bool handles(const String &p_type) const;
  108. virtual Ref<Texture> generate(const RES &p_from);
  109. EditorMeshPreviewPlugin();
  110. ~EditorMeshPreviewPlugin();
  111. };
  112. #endif // EDITORPREVIEWPLUGINS_H