ST_engine  0.3-ALPHA
renderer_sdl.hpp
1 /* This file is part of the "ST" project.
2  * You may use, distribute or modify this code under the terms
3  * of the GNU General Public License version 2.
4  * See LICENCE.txt in the root directory of the project.
5  *
6  * Author: Maxim Atanasov
7  * E-mail: maxim.atanasov@protonmail.com
8  */
9 
10 #ifndef RENDER_SDL_DEF
11 #define RENDER_SDL_DEF
12 
13 
14 #include <SDL_ttf.h>
15 #include <ST_util/bytell_hash_map.hpp>
16 #include <string>
17 #include <stdexcept>
18 
20 
25 namespace ST::renderer_sdl {
26 
27  void set_draw_color(uint8_t, uint8_t, uint8_t, uint8_t);
28 
29  void clear_screen(SDL_Color color);
30 
31  void clear_screen();
32 
33  void present();
34 
35  void draw_background(uint16_t arg);
36 
37  void draw_background_parallax(uint16_t arg, uint16_t offset);
38 
39  void draw_overlay(uint16_t arg, uint8_t sprite, uint8_t sprite_num);
40 
41  void draw_texture(uint16_t arg, int32_t x, int32_t y);
42 
43  void draw_texture_scaled(uint16_t arg, int32_t x, int32_t y, float scale_x, float scale_y);
44 
45  void draw_rectangle(int32_t x, int32_t y, int32_t w, int32_t h, SDL_Color color);
46 
47  void draw_rectangle_filled(int32_t x, int32_t y, int32_t w, int32_t h, SDL_Color color);
48 
49  void draw_sprite(uint16_t arg, int32_t x, int32_t y, uint8_t sprite, uint8_t animation, uint8_t animation_num,
50  uint8_t sprite_num);
51 
52  void
53  draw_sprite_scaled(uint16_t arg, int32_t x, int32_t y, uint8_t sprite, uint8_t animation, uint8_t animation_num,
54  uint8_t sprite_num, float scale_x, float scale_y);
55 
56  uint16_t draw_text_cached_glyphs(uint16_t font, const std::string &text, int x, int y, SDL_Color color_font);
57 
58  uint16_t draw_text_lru_cached(uint16_t font, const std::string &arg2, int x, int y, SDL_Color color_font);
59 
60  void upload_surfaces(ska::bytell_hash_map<uint16_t, SDL_Surface *> *surfaces);
61 
62  void upload_fonts(ska::bytell_hash_map<uint16_t, TTF_Font *> *fonts);
63 
64  void vsync_on();
65 
66  void vsync_off();
67 
68  int8_t initialize(SDL_Window *win, int16_t width, int16_t height);
69 
70  void close();
71 
72  void set_resolution(int16_t r_width, int16_t r_height);
73 }
74 
75 #endif //RENDER_SDL_DEF
The renderer for the engine.
uint16_t draw_text_lru_cached(uint16_t font, const std::string &arg2, int x, int y, SDL_Color color_font)
void upload_fonts(ska::bytell_hash_map< uint16_t, TTF_Font * > *fonts)
void upload_surfaces(ska::bytell_hash_map< uint16_t, SDL_Surface * > *surfaces)
void draw_overlay(uint16_t arg, uint8_t sprite, uint8_t sprite_num)
void draw_sprite_scaled(uint16_t arg, int32_t x, int32_t y, uint8_t sprite, uint8_t animation, uint8_t animation_num, uint8_t sprite_num, float scale_x, float scale_y)
void draw_sprite(uint16_t arg, int32_t x, int32_t y, uint8_t sprite, uint8_t animation, uint8_t animation_num, uint8_t sprite_num)
void clear_screen(SDL_Color color)
void draw_texture(uint16_t arg, int32_t x, int32_t y)
uint16_t draw_text_cached_glyphs(uint16_t font, const std::string &text, int x, int y, SDL_Color color_font)
void draw_background_parallax(uint16_t arg, uint16_t offset)
int8_t initialize(SDL_Window *win, int16_t width, int16_t height)
void draw_texture_scaled(uint16_t arg, int32_t x, int32_t y, float scale_x, float scale_y)
void set_resolution(int16_t r_width, int16_t r_height)
void draw_background(uint16_t arg)
void draw_rectangle(int32_t x, int32_t y, int32_t w, int32_t h, SDL_Color color)
void set_draw_color(uint8_t, uint8_t, uint8_t, uint8_t)
void draw_rectangle_filled(int32_t x, int32_t y, int32_t w, int32_t h, SDL_Color color)
This struct represents text objects in the game.
Definition: text.hpp:23