rasterizer_gles3.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**************************************************************************/
  2. /* rasterizer_gles3.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 RASTERIZER_GLES3_H
  31. #define RASTERIZER_GLES3_H
  32. #ifdef GLES3_ENABLED
  33. #include "effects/copy_effects.h"
  34. #include "environment/fog.h"
  35. #include "environment/gi.h"
  36. #include "rasterizer_canvas_gles3.h"
  37. #include "rasterizer_scene_gles3.h"
  38. #include "servers/rendering/renderer_compositor.h"
  39. #include "storage/config.h"
  40. #include "storage/light_storage.h"
  41. #include "storage/material_storage.h"
  42. #include "storage/mesh_storage.h"
  43. #include "storage/particles_storage.h"
  44. #include "storage/texture_storage.h"
  45. #include "storage/utilities.h"
  46. class RasterizerGLES3 : public RendererCompositor {
  47. private:
  48. uint64_t frame = 1;
  49. float delta = 0;
  50. double time_total = 0.0;
  51. static bool gles_over_gl;
  52. protected:
  53. GLES3::Config *config = nullptr;
  54. GLES3::Utilities *utilities = nullptr;
  55. GLES3::TextureStorage *texture_storage = nullptr;
  56. GLES3::MaterialStorage *material_storage = nullptr;
  57. GLES3::MeshStorage *mesh_storage = nullptr;
  58. GLES3::ParticlesStorage *particles_storage = nullptr;
  59. GLES3::LightStorage *light_storage = nullptr;
  60. GLES3::GI *gi = nullptr;
  61. GLES3::Fog *fog = nullptr;
  62. GLES3::CopyEffects *copy_effects = nullptr;
  63. RasterizerCanvasGLES3 *canvas = nullptr;
  64. RasterizerSceneGLES3 *scene = nullptr;
  65. static RasterizerGLES3 *singleton;
  66. void _blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect, uint32_t p_layer, bool p_first = true);
  67. public:
  68. RendererUtilities *get_utilities() { return utilities; }
  69. RendererLightStorage *get_light_storage() { return light_storage; }
  70. RendererMaterialStorage *get_material_storage() { return material_storage; }
  71. RendererMeshStorage *get_mesh_storage() { return mesh_storage; }
  72. RendererParticlesStorage *get_particles_storage() { return particles_storage; }
  73. RendererTextureStorage *get_texture_storage() { return texture_storage; }
  74. RendererGI *get_gi() { return gi; }
  75. RendererFog *get_fog() { return fog; }
  76. RendererCanvasRender *get_canvas() { return canvas; }
  77. RendererSceneRender *get_scene() { return scene; }
  78. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
  79. void initialize();
  80. void begin_frame(double frame_step);
  81. void prepare_for_blitting_render_targets();
  82. void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
  83. void end_frame(bool p_swap_buffers);
  84. void finalize();
  85. static RendererCompositor *_create_current() {
  86. return memnew(RasterizerGLES3);
  87. }
  88. static bool is_gles_over_gl() { return gles_over_gl; }
  89. static void clear_depth(float p_depth);
  90. static void make_current(bool p_gles_over_gl) {
  91. gles_over_gl = p_gles_over_gl;
  92. _create_func = _create_current;
  93. low_end = true;
  94. }
  95. _ALWAYS_INLINE_ uint64_t get_frame_number() const { return frame; }
  96. _ALWAYS_INLINE_ double get_frame_delta_time() const { return delta; }
  97. _ALWAYS_INLINE_ double get_total_time() const { return time_total; }
  98. static RasterizerGLES3 *get_singleton() { return singleton; }
  99. RasterizerGLES3();
  100. ~RasterizerGLES3();
  101. };
  102. #endif // GLES3_ENABLED
  103. #endif // RASTERIZER_GLES3_H