Shkyera Engine
Easy to use, game engine for Python
shkyera::Renderer Class Reference

A class for rendering graphics in a game. More...

#include <Renderer.hpp>

Public Member Functions

 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...
 

Private Member Functions

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...
 

Private Attributes

uint8_t * _data = nullptr
 A pointer to the pixel data. More...
 
uint8_t * _deployData = nullptr
 A pointer to the deployed pixel data. More...
 
uint32_t _width
 The width of the rendering area. More...
 
uint32_t _height
 The height of the rendering area. More...
 
std::shared_ptr< Game_game
 A shared pointer to the associated Game instance. More...
 
uint32_t _textureId
 The texture ID used for rendering. More...
 

Detailed Description

A class for rendering graphics in a game.

Constructor & Destructor Documentation

◆ Renderer()

shkyera::Renderer::Renderer ( std::shared_ptr< Game game)

Constructor for the Renderer class.

Parameters
gameA shared pointer to the Game instance to associate with the renderer.

◆ ~Renderer()

shkyera::Renderer::~Renderer ( )

Destructor for the Renderer class.

Member Function Documentation

◆ clear()

void shkyera::Renderer::clear ( )

Clear the rendering area by setting all pixels to white.

◆ draw()

void shkyera::Renderer::draw ( )

Render the graphics.

◆ drawCircle()

void shkyera::Renderer::drawCircle ( int  x,
int  y,
int  r 
)

Draw a circle at (x, y) with radius r.

Parameters
xThe x-coordinate of the circle.
yThe y-coordinate of the circle.
rThe 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
x0The x-coordinate of the starting point.
y0The y-coordinate of the starting point.
x1The x-coordinate of the ending point.
y1The 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
xThe x-coordinate of top-left corner of the rectangle.
yThe y-coordinate of top-left corner of the rectangle.
wThe width of the rectangle.
hThe height of the rectangle.
colorThe 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
widthThe width of the rendering area.
heightThe 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
xThe x-coordinate of the pixel.
yThe y-coordinate of the pixel.
rThe red component of the color.
gThe green component of the color.
bThe blue component of the color.

Member Data Documentation

◆ _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: