Wolf3D
renderwindow.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "global.hpp"
15 
16 class RenderWindow {
17  public:
18  RenderWindow();
19 
27  void create(const char *title, int width, int height);
28 
34  void draw_buffer(Uint32 *buffer);
35 
42  SDL_Texture *load_texture(const char *file_path);
43 
52  void render(int x, int y, float scale_factor, SDL_Texture *texture);
53 
64  void render(int x, int y, float scale_factor, std::string text, TTF_Font *font, SDL_Colour text_colour);
65 
70  void redraw();
71 
80  bool done(bool quit_if_esc = true, bool delay = true);
81 
87  const Uint8 *readKeys();
88 
97  bool keyDown(const Uint8 *inkeys, int key);
98 
99 
100  private:
101  SDL_Window *window;
102  SDL_Renderer *renderer;
103  SDL_Texture *framebuffer;
104 };
Definition: renderwindow.hpp:16
void draw_buffer(Uint32 *buffer)
Draws a buffer of pixel colours to the screen.
Definition: renderwindow.cpp:46
SDL_Texture * load_texture(const char *file_path)
Definition: renderwindow.cpp:55
void create(const char *title, int width, int height)
Create the window and the renderer.
Definition: renderwindow.cpp:10
bool keyDown(const Uint8 *inkeys, int key)
If the key is held down.
Definition: renderwindow.cpp:122
void render(int x, int y, float scale_factor, SDL_Texture *texture)
Render an SDL_Texture to the renderer.
Definition: renderwindow.cpp:67
bool done(bool quit_if_esc=true, bool delay=true)
Used in while loops to tell if the window has been closed or not.
Definition: renderwindow.cpp:110
const Uint8 * readKeys()
Get the current held down keys.
Definition: renderwindow.cpp:118
void redraw()
Draws the renderer to the window.
Definition: renderwindow.cpp:105