rasterizer_dummy.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**************************************************************************/
  2. /* rasterizer_dummy.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_DUMMY_H
  31. #define RASTERIZER_DUMMY_H
  32. #include "core/templates/rid_owner.h"
  33. #include "core/templates/self_list.h"
  34. #include "scene/resources/mesh.h"
  35. #include "servers/rendering/dummy/environment/fog.h"
  36. #include "servers/rendering/dummy/environment/gi.h"
  37. #include "servers/rendering/dummy/rasterizer_canvas_dummy.h"
  38. #include "servers/rendering/dummy/rasterizer_scene_dummy.h"
  39. #include "servers/rendering/dummy/storage/light_storage.h"
  40. #include "servers/rendering/dummy/storage/material_storage.h"
  41. #include "servers/rendering/dummy/storage/mesh_storage.h"
  42. #include "servers/rendering/dummy/storage/particles_storage.h"
  43. #include "servers/rendering/dummy/storage/texture_storage.h"
  44. #include "servers/rendering/dummy/storage/utilities.h"
  45. #include "servers/rendering/renderer_compositor.h"
  46. #include "servers/rendering_server.h"
  47. class RasterizerDummy : public RendererCompositor {
  48. private:
  49. uint64_t frame = 1;
  50. double delta = 0;
  51. double time = 0.0;
  52. protected:
  53. RasterizerCanvasDummy canvas;
  54. RendererDummy::Utilities utilities;
  55. RendererDummy::LightStorage light_storage;
  56. RendererDummy::MaterialStorage material_storage;
  57. RendererDummy::MeshStorage mesh_storage;
  58. RendererDummy::ParticlesStorage particles_storage;
  59. RendererDummy::TextureStorage texture_storage;
  60. RendererDummy::GI gi;
  61. RendererDummy::Fog fog;
  62. RasterizerSceneDummy scene;
  63. public:
  64. RendererUtilities *get_utilities() override { return &utilities; };
  65. RendererLightStorage *get_light_storage() override { return &light_storage; };
  66. RendererMaterialStorage *get_material_storage() override { return &material_storage; };
  67. RendererMeshStorage *get_mesh_storage() override { return &mesh_storage; };
  68. RendererParticlesStorage *get_particles_storage() override { return &particles_storage; };
  69. RendererTextureStorage *get_texture_storage() override { return &texture_storage; };
  70. RendererGI *get_gi() override { return &gi; };
  71. RendererFog *get_fog() override { return &fog; };
  72. RendererCanvasRender *get_canvas() override { return &canvas; }
  73. RendererSceneRender *get_scene() override { return &scene; }
  74. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) override {}
  75. void initialize() override {}
  76. void begin_frame(double frame_step) override {
  77. frame++;
  78. delta = frame_step;
  79. time += frame_step;
  80. }
  81. void prepare_for_blitting_render_targets() override {}
  82. void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) override {}
  83. void end_frame(bool p_swap_buffers) override {
  84. if (p_swap_buffers) {
  85. DisplayServer::get_singleton()->swap_buffers();
  86. }
  87. }
  88. void finalize() override {}
  89. static RendererCompositor *_create_current() {
  90. return memnew(RasterizerDummy);
  91. }
  92. static void make_current() {
  93. _create_func = _create_current;
  94. low_end = true;
  95. }
  96. uint64_t get_frame_number() const override { return frame; }
  97. double get_frame_delta_time() const override { return delta; }
  98. double get_total_time() const override { return time; }
  99. RasterizerDummy() {}
  100. ~RasterizerDummy() {}
  101. };
  102. #endif // RASTERIZER_DUMMY_H