Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/rendering/renderer_compositor.h
10277 views
1
/**************************************************************************/
2
/* renderer_compositor.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
#pragma once
32
33
#include "servers/rendering/environment/renderer_fog.h"
34
#include "servers/rendering/environment/renderer_gi.h"
35
#include "servers/rendering/renderer_canvas_render.h"
36
#include "servers/rendering/storage/light_storage.h"
37
#include "servers/rendering/storage/material_storage.h"
38
#include "servers/rendering/storage/mesh_storage.h"
39
#include "servers/rendering/storage/particles_storage.h"
40
#include "servers/rendering/storage/texture_storage.h"
41
#include "servers/rendering/storage/utilities.h"
42
43
class RendererSceneRender;
44
struct BlitToScreen {
45
RID render_target;
46
Rect2 src_rect = Rect2(0.0, 0.0, 1.0, 1.0);
47
Rect2i dst_rect;
48
49
struct {
50
bool use_layer = false;
51
uint32_t layer = 0;
52
} multi_view;
53
54
struct {
55
//lens distorted parameters for VR
56
bool apply = false;
57
Vector2 eye_center;
58
float k1 = 0.0;
59
float k2 = 0.0;
60
61
float upscale = 1.0;
62
float aspect_ratio = 1.0;
63
} lens_distortion;
64
};
65
66
class RendererCompositor {
67
private:
68
bool xr_enabled = false;
69
static RendererCompositor *singleton;
70
71
protected:
72
static RendererCompositor *(*_create_func)();
73
bool back_end = false;
74
static bool low_end;
75
76
public:
77
static RendererCompositor *create();
78
79
virtual RendererUtilities *get_utilities() = 0;
80
virtual RendererLightStorage *get_light_storage() = 0;
81
virtual RendererMaterialStorage *get_material_storage() = 0;
82
virtual RendererMeshStorage *get_mesh_storage() = 0;
83
virtual RendererParticlesStorage *get_particles_storage() = 0;
84
virtual RendererTextureStorage *get_texture_storage() = 0;
85
virtual RendererGI *get_gi() = 0;
86
virtual RendererFog *get_fog() = 0;
87
virtual RendererCanvasRender *get_canvas() = 0;
88
virtual RendererSceneRender *get_scene() = 0;
89
90
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
91
92
virtual void initialize() = 0;
93
virtual void begin_frame(double frame_step) = 0;
94
95
virtual void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
96
97
virtual bool is_opengl() = 0;
98
virtual void gl_end_frame(bool p_swap_buffers) = 0;
99
virtual void end_frame(bool p_present) = 0;
100
virtual void finalize() = 0;
101
virtual uint64_t get_frame_number() const = 0;
102
virtual double get_frame_delta_time() const = 0;
103
virtual double get_total_time() const = 0;
104
virtual bool can_create_resources_async() const = 0;
105
106
static bool is_low_end() { return low_end; }
107
virtual bool is_xr_enabled() const;
108
109
static RendererCompositor *get_singleton() { return singleton; }
110
RendererCompositor();
111
virtual ~RendererCompositor();
112
};
113
114