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