Wizard Engine
2D cross-platform game engine built around SDL2
 
Loading...
Searching...
No Matches
renderer.hpp
Go to the documentation of this file.
1/*
2 Wizard Engine
3 Copyright (C) 2023-2024 Zana Domán
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef WIZARD_ENGINE_RENDERER_HPP
23#define WIZARD_ENGINE_RENDERER_HPP
24
28
29namespace wze {
35class renderer final {
36 private:
37 static float _origo_x;
38 static float _origo_y;
39 static SDL_Renderer* _base;
40 static uint8_t _background_color_r;
41 static uint8_t _background_color_g;
42 static uint8_t _background_color_b;
43 static std::shared_ptr<texture> _background_texture;
44 static std::unique_ptr<texture, std::function<void(texture*)>> _space;
45 static uint8_t _space_color_r;
46 static uint8_t _space_color_g;
47 static uint8_t _space_color_b;
48 static uint8_t _space_color_a;
49 static std::shared_ptr<texture> _space_texture;
50 static SDL_FRect _space_area;
51 static std::unique_ptr<texture, std::function<void(texture*)>> _plane;
52 static uint8_t _plane_color_r;
53 static uint8_t _plane_color_g;
54 static uint8_t _plane_color_b;
55 static uint8_t _plane_color_a;
56
62 renderer() = default;
63
70 static void open_frame();
71
78 static void open_space();
79
86 static void open_plane();
87
95 [[nodiscard]] static bool invisible(renderable const& instance);
96
103 static void transform(renderable& instance);
104
114 [[nodiscard]] static bool offscreen(renderable const& instance);
115
124 static void render(renderable const& instance);
125
132 static void close_frame();
133
134 public:
141 [[nodiscard]] static float origo_x();
142
149 static void set_origo_x(float origo_x);
150
157 [[nodiscard]] static float origo_y();
158
165 static void set_origo_y(float origo_y);
166
167#ifdef __WIZARD_ENGINE_INTERNAL__
174 [[nodiscard]] static SDL_Renderer* base();
175#endif /* __WIZARD_ENGINE_INTERNAL__ */
176
183 [[nodiscard]] static uint8_t background_color_r();
184
191 static void set_background_color_r(uint8_t background_color_r);
192
199 [[nodiscard]] static uint8_t background_color_g();
200
207 static void set_background_color_g(uint8_t background_color_g);
208
215 [[nodiscard]] static uint8_t background_color_b();
216
223 static void set_background_color_b(uint8_t background_color_b);
224
232 [[nodiscard]] static std::shared_ptr<texture> const& background_texture();
233
241 static void
242 set_background_texture(std::shared_ptr<texture> const& background_texture);
243
250 [[nodiscard]] static uint8_t space_color_r();
251
258 static void set_space_color_r(uint8_t space_color_r);
259
266 [[nodiscard]] static uint8_t space_color_g();
267
274 static void set_space_color_g(uint8_t space_color_g);
275
282 [[nodiscard]] static uint8_t space_color_b();
283
290 static void set_space_color_b(uint8_t space_color_b);
291
298 [[nodiscard]] static uint8_t space_color_a();
299
306 static void set_space_color_a(uint8_t space_color_a);
307
316 [[nodiscard]] static std::shared_ptr<texture> const& space_texture();
317
326 static void
327 set_space_texture(std::shared_ptr<texture> const& space_texture);
328
335 [[nodiscard]] static uint8_t plane_color_r();
336
343 static void set_plane_color_r(uint8_t plane_color_r);
344
351 [[nodiscard]] static uint8_t plane_color_g();
352
359 static void set_plane_color_g(uint8_t plane_color_g);
360
367 [[nodiscard]] static uint8_t plane_color_b();
368
375 static void set_plane_color_b(uint8_t plane_color_b);
376
383 [[nodiscard]] static uint8_t plane_color_a();
384
391 static void set_plane_color_a(uint8_t plane_color_a);
392
393#ifdef __WIZARD_ENGINE_INTERNAL__
401 static void initialize();
402#endif /* __WIZARD_ENGINE_INTERNAL__ */
403
404#ifdef __WIZARD_ENGINE_INTERNAL__
410 static void update();
411#endif /* __WIZARD_ENGINE_INTERNAL__ */
412
413#ifdef __WIZARD_ENGINE_INTERNAL__
422 [[nodiscard]] static std::pair<float, float> detransform(float x, float y);
423#endif /* __WIZARD_ENGINE_INTERNAL__ */
424};
425} /* namespace wze */
426
427#endif /* WIZARD_ENGINE_RENDERER_HPP */
Image file in host memory.
Export header of the Wizard Engine.
Wizard Engine.
Interface to make an object renderable.