Shkyera Engine
Easy to use, game engine for Python
Renderer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "game/Game.hpp"
4 
5 namespace shkyera {
6 
11 class Renderer {
12  public:
18  Renderer(std::shared_ptr<Game> game);
19 
23  ~Renderer();
24 
28  void draw();
29 
36  void setDimension(uint32_t width, uint32_t height);
37 
43  uint32_t getTextureId() const;
44 
48  void clear();
49 
58  void drawLine(int x0, int y0, int x1, int y1);
59 
67  void drawCircle(int x, int y, int r);
68 
78  void drawRectangle(int x, int y, int w, int h, glm::vec3 color = {0, 0, 0});
79 
80  private:
84  void initializeTexture();
85 
89  void drawLineLow(int x0, int y0, int x1, int y1);
90 
94  void drawLineHigh(int x0, int y0, int x1, int y1);
95 
105  void setPixel(int x, int y, int r, int g, int b);
106 
107  uint8_t *_data = nullptr;
108  uint8_t *_deployData = nullptr;
109  uint32_t _width;
110  uint32_t _height;
111 
112  std::shared_ptr<Game> _game;
113  uint32_t _textureId;
114 };
115 
116 } // namespace shkyera
Contains the declaration of the Game class, representing the game environment.
A class for rendering graphics in a game.
Definition: Renderer.hpp:11
uint32_t _width
The width of the rendering area.
Definition: Renderer.hpp:109
~Renderer()
Destructor for the Renderer class.
Definition: Renderer.cpp:20
void draw()
Render the graphics.
Definition: Renderer.cpp:22
Renderer(std::shared_ptr< Game > game)
Constructor for the Renderer class.
Definition: Renderer.cpp:19
uint32_t _height
The height of the rendering area.
Definition: Renderer.hpp:110
void drawLineLow(int x0, int y0, int x1, int y1)
Draw a line with a low slope.
Definition: Renderer.cpp:93
uint8_t * _data
A pointer to the pixel data.
Definition: Renderer.hpp:107
void setPixel(int x, int y, int r, int g, int b)
Set the color of a pixel at (x, y).
Definition: Renderer.cpp:148
void drawRectangle(int x, int y, int w, int h, glm::vec3 color={0, 0, 0})
Draw a rectangle at (x, y) with (w, h) size.
Definition: Renderer.cpp:70
uint8_t * _deployData
A pointer to the deployed pixel data.
Definition: Renderer.hpp:108
void clear()
Clear the rendering area by setting all pixels to white.
Definition: Renderer.cpp:34
uint32_t getTextureId() const
Get the texture ID associated with the renderer.
Definition: Renderer.cpp:32
void drawLine(int x0, int y0, int x1, int y1)
Draw a line from (x0, y0) to (x1, y1).
Definition: Renderer.cpp:79
void drawCircle(int x, int y, int r)
Draw a circle at (x, y) with radius r.
Definition: Renderer.cpp:54
void initializeTexture()
Initialize the texture used for rendering.
Definition: Renderer.cpp:146
void drawLineHigh(int x0, int y0, int x1, int y1)
Draw a line with a high slope.
Definition: Renderer.cpp:120
std::shared_ptr< Game > _game
A shared pointer to the associated Game instance.
Definition: Renderer.hpp:112
void setDimension(uint32_t width, uint32_t height)
Set the dimensions of the rendering area.
Definition: Renderer.cpp:36
uint32_t _textureId
The texture ID used for rendering.
Definition: Renderer.hpp:113
Definition: Entity.cpp:3