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