A class for rendering graphics in a game.
More...
#include <Renderer.hpp>
|
| Renderer (std::shared_ptr< Game > game) |
| Constructor for the Renderer class. More...
|
|
| ~Renderer () |
| Destructor for the Renderer class. More...
|
|
void | draw () |
| Render the graphics. More...
|
|
void | setDimension (uint32_t width, uint32_t height) |
| Set the dimensions of the rendering area. More...
|
|
uint32_t | getTextureId () const |
| Get the texture ID associated with the renderer. More...
|
|
void | clear () |
| Clear the rendering area by setting all pixels to white. More...
|
|
void | drawLine (int x0, int y0, int x1, int y1) |
| Draw a line from (x0, y0) to (x1, y1). More...
|
|
void | drawCircle (int x, int y, int r) |
| Draw a circle at (x, y) with radius r. More...
|
|
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. More...
|
|
|
void | initializeTexture () |
| Initialize the texture used for rendering. More...
|
|
void | drawLineLow (int x0, int y0, int x1, int y1) |
| Draw a line with a low slope. More...
|
|
void | drawLineHigh (int x0, int y0, int x1, int y1) |
| Draw a line with a high slope. More...
|
|
void | setPixel (int x, int y, int r, int g, int b) |
| Set the color of a pixel at (x, y). More...
|
|
A class for rendering graphics in a game.
◆ Renderer()
shkyera::Renderer::Renderer |
( |
std::shared_ptr< Game > |
game | ) |
|
Constructor for the Renderer class.
- Parameters
-
game | A shared pointer to the Game instance to associate with the renderer. |
◆ ~Renderer()
shkyera::Renderer::~Renderer |
( |
| ) |
|
◆ clear()
void shkyera::Renderer::clear |
( |
| ) |
|
Clear the rendering area by setting all pixels to white.
◆ draw()
void shkyera::Renderer::draw |
( |
| ) |
|
◆ drawCircle()
void shkyera::Renderer::drawCircle |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
r |
|
) |
| |
Draw a circle at (x, y) with radius r.
- Parameters
-
x | The x-coordinate of the circle. |
y | The y-coordinate of the circle. |
r | The radius of the circle. |
◆ drawLine()
void shkyera::Renderer::drawLine |
( |
int |
x0, |
|
|
int |
y0, |
|
|
int |
x1, |
|
|
int |
y1 |
|
) |
| |
Draw a line from (x0, y0) to (x1, y1).
- Parameters
-
x0 | The x-coordinate of the starting point. |
y0 | The y-coordinate of the starting point. |
x1 | The x-coordinate of the ending point. |
y1 | The y-coordinate of the ending point. |
◆ drawLineHigh()
void shkyera::Renderer::drawLineHigh |
( |
int |
x0, |
|
|
int |
y0, |
|
|
int |
x1, |
|
|
int |
y1 |
|
) |
| |
|
private |
Draw a line with a high slope.
◆ drawLineLow()
void shkyera::Renderer::drawLineLow |
( |
int |
x0, |
|
|
int |
y0, |
|
|
int |
x1, |
|
|
int |
y1 |
|
) |
| |
|
private |
Draw a line with a low slope.
◆ drawRectangle()
void shkyera::Renderer::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.
- Parameters
-
x | The x-coordinate of top-left corner of the rectangle. |
y | The y-coordinate of top-left corner of the rectangle. |
w | The width of the rectangle. |
h | The height of the rectangle. |
color | The color of the rectangle as RGB |
◆ getTextureId()
uint32_t shkyera::Renderer::getTextureId |
( |
| ) |
const |
Get the texture ID associated with the renderer.
- Returns
- The texture ID.
◆ initializeTexture()
void shkyera::Renderer::initializeTexture |
( |
| ) |
|
|
private |
Initialize the texture used for rendering.
◆ setDimension()
void shkyera::Renderer::setDimension |
( |
uint32_t |
width, |
|
|
uint32_t |
height |
|
) |
| |
Set the dimensions of the rendering area.
- Parameters
-
width | The width of the rendering area. |
height | The height of the rendering area. |
◆ setPixel()
void shkyera::Renderer::setPixel |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
r, |
|
|
int |
g, |
|
|
int |
b |
|
) |
| |
|
private |
Set the color of a pixel at (x, y).
- Parameters
-
x | The x-coordinate of the pixel. |
y | The y-coordinate of the pixel. |
r | The red component of the color. |
g | The green component of the color. |
b | The blue component of the color. |
◆ _data
uint8_t* shkyera::Renderer::_data = nullptr |
|
private |
A pointer to the pixel data.
◆ _deployData
uint8_t* shkyera::Renderer::_deployData = nullptr |
|
private |
A pointer to the deployed pixel data.
◆ _game
std::shared_ptr<Game> shkyera::Renderer::_game |
|
private |
A shared pointer to the associated Game instance.
◆ _height
uint32_t shkyera::Renderer::_height |
|
private |
The height of the rendering area.
◆ _textureId
uint32_t shkyera::Renderer::_textureId |
|
private |
The texture ID used for rendering.
◆ _width
uint32_t shkyera::Renderer::_width |
|
private |
The width of the rendering area.
The documentation for this class was generated from the following files: