2D_Game_Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
Renderer Class Reference

#include <renderer.hpp>

Public Member Functions

 Renderer ()
 
 ~Renderer ()
 
void StartScene ()
 
void DrawScene ()
 
void Clear (bool ambient_light=false) const
 
void Clear (Vec4 color) const
 
void DrawTexture (Vec2 pos, Vec2 size, int layer, float texID)
 
void DrawTexture (Vec2 pos, Vec2 size, Vec2 texture_pos, Vec2 texture_size, Vec2 texture_total_size, int layer, float texID)
 
void DrawTexture (Vec2 pos, Vec2 size, bool reverse_x, bool reverse_y, int layer, Texture &texture)
 
void DrawSpriteSheet (Vec2 pos, Vec2 size, float row, float col, int layer, SpriteSheet &s)
 
void DrawAnimatedTexture (Vec2 pos, Vec2 size, int layer, SpriteSheet &s, bool &play_animation, bool loop_animation, float animation_delay, float &last_animation_time, int &animation_index)
 
void DrawTriangle (Vec2 pos1, Vec2 pos2, Vec2 pos3, Vec4 color, int layer)
 
void DrawSolidQuad (Vec2 pos, Vec2 size, Vec4 color, int layer)
 
void DrawPoint (Vec2 pos, Vec4 color, int layer)
 
void DrawCircle (Vec2 pos, Vec4 color, float border, int layer)
 
void DrawLine (Vec2 pos1, Vec2 pos2, Vec4 color, int layer)
 
void DrawLight (Vec2 pos, Vec4 color, LightType light_type, float radius=0.0f, float blurAmount=0.0f)
 
void Render (bool post_processing=false)
 
void RenderTextures (bool post_processing, float max_layer)
 
void RenderTriangles (float max_layer)
 
void RenderLines (float max_layer)
 
void RenderPoints (float max_layer)
 
void SetPostProcessing (const char *uniform_name)
 
void PostProcessing ()
 
void SetLineWidth (float new_size)
 
void UpdateLineWidth ()
 
void SetPointSize (float new_size)
 
float GetPointSize ()
 
float GetLineWidth ()
 
void SetAmbientLight (Vec3 color)
 
void SetClearColor (Vec3 color)
 
void AddSegment (Vec2 start_point, Vec2 end_point)
 
void UpdateScreenSegments ()
 
void ClearSegments ()
 
std::vector< std::pair< Vec2, Vec2 > > & GetSegments ()
 
void ApplyLight ()
 
void ApplyLight (Framebuffer *framebuffer)
 
void KeepCircle (Vec2 pos, float radius, float blurAmount)
 
std::pair< Vec2, float > GetIntersection (const std::pair< Vec2, Vec2 > &ray, const std::pair< Vec2, Vec2 > &seg)
 
RendererDataGetLightsData ()
 
unsigned int GetFramebufferID ()
 
void SetTonemapType (TonemapType type)
 
void SetGamma (float gamma)
 
void SetExposure (float exposure)
 
TonemapType GetTonemapType ()
 
float GetGamma ()
 
float GetExposure ()
 
void CreateShaders ()
 
void ReloadShaders ()
 
void SetProjMat (glm::mat4 proj)
 
void SetViewMat (glm::mat4 view)
 
void SetViewProjMat (glm::mat4 view_proj)
 

Static Public Member Functions

static void ImGui_Init ()
 
static void ImGui_Theme ()
 
static void ImGui_Start_Frame ()
 
static void ImGui_Content ()
 
static void ImGui_End_Frame ()
 
static void ImGui_Close ()
 

Friends

class Camera
 

Detailed Description

Definition at line 40 of file renderer.hpp.

Constructor & Destructor Documentation

◆ Renderer()

Renderer::Renderer ( )

Definition at line 12 of file renderer.cpp.

◆ ~Renderer()

Renderer::~Renderer ( )

Definition at line 116 of file renderer.cpp.

Member Function Documentation

◆ AddSegment()

void Renderer::AddSegment ( Vec2 start_point,
Vec2 end_point )

Definition at line 754 of file renderer.cpp.

◆ ApplyLight() [1/2]

void Renderer::ApplyLight ( )

Apply the lighting framebuffer to the main framebuffer

Definition at line 916 of file renderer.cpp.

◆ ApplyLight() [2/2]

void Renderer::ApplyLight ( Framebuffer * framebuffer)

Merge the lighting framebuffer with the framebuffer

Parameters
framebufferthe framebuffer to merge with

Definition at line 920 of file renderer.cpp.

◆ Clear() [1/2]

void Renderer::Clear ( bool ambient_light = false) const

Clear the screen

Parameters
ambient_lightif true, the ambient light will be applied, else the clear color will be applied

Definition at line 732 of file renderer.cpp.

◆ Clear() [2/2]

void Renderer::Clear ( Vec4 color) const

Clear the screen

Parameters
colorthe color to clear the screen

Definition at line 740 of file renderer.cpp.

◆ ClearSegments()

void Renderer::ClearSegments ( )

Definition at line 765 of file renderer.cpp.

◆ CreateShaders()

void Renderer::CreateShaders ( )

Definition at line 171 of file renderer.cpp.

◆ DrawAnimatedTexture()

void Renderer::DrawAnimatedTexture ( Vec2 pos,
Vec2 size,
int layer,
SpriteSheet & s,
bool & play_animation,
bool loop_animation,
float animation_delay,
float & last_animation_time,
int & animation_index )

Draw an animated texture

Parameters
posPosition of the texture
sizeSize of the texture
layerLayer of the texture (higher layers are drawn on top of lower layers)
sthe sprite sheet to use
play_animationif true, the animation will be played
loop_animationif true, the animation will be looped
animation_delaythe delay between two frames
last_animation_timethe last time the animation was updated
animation_indexthe current animation index

Definition at line 321 of file renderer.cpp.

◆ DrawCircle()

void Renderer::DrawCircle ( Vec2 pos,
Vec4 color,
float border,
int layer )

Draw an empty point. Use SetPointSize to change the size of the point

Parameters
posPosition of the point
colorColor of the point
borderBorder of the point (in range [0,1])
layerLayer of the point (higher layers are drawn on top of lower layers)

Definition at line 382 of file renderer.cpp.

◆ DrawLight()

void Renderer::DrawLight ( Vec2 pos,
Vec4 color,
LightType light_type,
float radius = 0.0f,
float blurAmount = 0.0f )

Draw a light

Parameters
posPosition of the light
colorColor of the light
light_typeType of the light
radiusRadius of the light
blurAmountAmount of blur starting from the edge of the light

Definition at line 802 of file renderer.cpp.

◆ DrawLine()

void Renderer::DrawLine ( Vec2 pos1,
Vec2 pos2,
Vec4 color,
int layer )

Draw a line. Use SetLineWidth to change the size of the line

Parameters
pos1Position of the first vertex
pos2Position of the second vertex
colorColor of the line
layerLayer of the line (higher layers are drawn on top of lower layers)

Definition at line 396 of file renderer.cpp.

◆ DrawPoint()

void Renderer::DrawPoint ( Vec2 pos,
Vec4 color,
int layer )

Draw a round point. Use SetPointSize to change the size of the point

Parameters
posPosition of the point
colorColor of the point
layerLayer of the point (higher layers are drawn on top of lower layers)

Definition at line 368 of file renderer.cpp.

◆ DrawScene()

void Renderer::DrawScene ( )

Definition at line 481 of file renderer.cpp.

◆ DrawSolidQuad()

void Renderer::DrawSolidQuad ( Vec2 pos,
Vec2 size,
Vec4 color,
int layer )

Draw a solid quad

Parameters
posPosition of the quad
sizeSize of the quad
colorColor of the quad
layerLayer of the quad (higher layers are drawn on top of lower layers)

Definition at line 361 of file renderer.cpp.

◆ DrawSpriteSheet()

void Renderer::DrawSpriteSheet ( Vec2 pos,
Vec2 size,
float row,
float col,
int layer,
SpriteSheet & s )

Draw a part of a sprite sheet

Parameters
posPosition of the texture
sizeSize of the texture
rowrow in the sprite sheet
colcolumn in the sprite sheet
layerLayer of the texture (higher layers are drawn on top of lower layers)
sthe sprite sheet to use

Definition at line 303 of file renderer.cpp.

◆ DrawTexture() [1/3]

void Renderer::DrawTexture ( Vec2 pos,
Vec2 size,
bool reverse_x,
bool reverse_y,
int layer,
Texture & texture )

Draw a texture

Parameters
posPosition of the texture
sizeSize of the texture
reverse_xif true, the texture will be reversed on the x axis
reverse_yif true, the texture will be reversed on the y axis
layerLayer of the texture (higher layers are drawn on top of lower layers)
texturethe texture to draw

Definition at line 290 of file renderer.cpp.

◆ DrawTexture() [2/3]

void Renderer::DrawTexture ( Vec2 pos,
Vec2 size,
int layer,
float texID )

Draw a texture

Parameters
posPosition of the texture
sizeSize of the texture
layerLayer of the texture (higher layers are drawn on top of lower layers)
texIDID of the texture

Definition at line 254 of file renderer.cpp.

◆ DrawTexture() [3/3]

void Renderer::DrawTexture ( Vec2 pos,
Vec2 size,
Vec2 texture_pos,
Vec2 texture_size,
Vec2 texture_total_size,
int layer,
float texID )

Render a portion of a texture

Parameters
posPosition of the texture
sizeSize of the texture
texture_posPosition of the portion of the texture
texture_sizeSize of the portion of the texture
texture_total_sizeSize of the whole texture
layerLayer of the texture (higher layers are drawn on top of lower layers)

Definition at line 272 of file renderer.cpp.

◆ DrawTriangle()

void Renderer::DrawTriangle ( Vec2 pos1,
Vec2 pos2,
Vec2 pos3,
Vec4 color,
int layer )

Draw a triangle

Parameters
pos1Position of the first vertex
pos2Position of the second vertex
pos3Position of the third vertex
colorColor of the triangle
layerLayer of the triangle (higher layers are drawn on top of lower layers)

Definition at line 345 of file renderer.cpp.

◆ GetExposure()

float Renderer::GetExposure ( )

Definition at line 250 of file renderer.cpp.

◆ GetFramebufferID()

unsigned int Renderer::GetFramebufferID ( )
inline

Definition at line 237 of file renderer.hpp.

◆ GetGamma()

float Renderer::GetGamma ( )

Definition at line 242 of file renderer.cpp.

◆ GetIntersection()

std::pair< Vec2, float > Renderer::GetIntersection ( const std::pair< Vec2, Vec2 > & ray,
const std::pair< Vec2, Vec2 > & seg )

Get the intersection between a ray and a segment

Parameters
raythe ray
segthe segment
Returns
the intersection point and the time of intersection if an intersection occurs, else return {(-1,-1),-1}

Definition at line 774 of file renderer.cpp.

◆ GetLightsData()

RendererData * Renderer::GetLightsData ( )
inline

Definition at line 236 of file renderer.hpp.

◆ GetLineWidth()

float Renderer::GetLineWidth ( )

Definition at line 434 of file renderer.cpp.

◆ GetPointSize()

float Renderer::GetPointSize ( )

Definition at line 430 of file renderer.cpp.

◆ GetSegments()

std::vector< std::pair< Vec2, Vec2 > > & Renderer::GetSegments ( )

Definition at line 770 of file renderer.cpp.

◆ GetTonemapType()

TonemapType Renderer::GetTonemapType ( )

Definition at line 234 of file renderer.cpp.

◆ ImGui_Close()

void Renderer::ImGui_Close ( )
static

Definition at line 1118 of file renderer.cpp.

◆ ImGui_Content()

void Renderer::ImGui_Content ( )
static

Definition at line 1095 of file renderer.cpp.

◆ ImGui_End_Frame()

void Renderer::ImGui_End_Frame ( )
static

Definition at line 1112 of file renderer.cpp.

◆ ImGui_Init()

void Renderer::ImGui_Init ( )
static

Definition at line 1007 of file renderer.cpp.

◆ ImGui_Start_Frame()

void Renderer::ImGui_Start_Frame ( )
static

Definition at line 1089 of file renderer.cpp.

◆ ImGui_Theme()

void Renderer::ImGui_Theme ( )
static

Definition at line 1016 of file renderer.cpp.

◆ KeepCircle()

void Renderer::KeepCircle ( Vec2 pos,
float radius,
float blurAmount )

Keep a circle of light. Used for point lights with walls collisions

Parameters
posPosition of the light
radiusRadius of the light
blurAmountAmount of blur starting from the edge of the light

Definition at line 893 of file renderer.cpp.

◆ PostProcessing()

void Renderer::PostProcessing ( )

Apply the post processing function

Definition at line 749 of file renderer.cpp.

◆ ReloadShaders()

void Renderer::ReloadShaders ( )

Definition at line 947 of file renderer.cpp.

◆ Render()

void Renderer::Render ( bool post_processing = false)

Render all the elements stored in buffers

Definition at line 565 of file renderer.cpp.

◆ RenderLines()

void Renderer::RenderLines ( float max_layer)

Render all the lines stored in the buffer

Definition at line 707 of file renderer.cpp.

◆ RenderPoints()

void Renderer::RenderPoints ( float max_layer)

Render all the points stored in the buffer

Definition at line 682 of file renderer.cpp.

◆ RenderTextures()

void Renderer::RenderTextures ( bool post_processing,
float max_layer )

Render all the textures stored in the buffer

Definition at line 602 of file renderer.cpp.

◆ RenderTriangles()

void Renderer::RenderTriangles ( float max_layer)

Render all the triangles stored in the buffer

Definition at line 657 of file renderer.cpp.

◆ SetAmbientLight()

void Renderer::SetAmbientLight ( Vec3 color)

Definition at line 438 of file renderer.cpp.

◆ SetClearColor()

void Renderer::SetClearColor ( Vec3 color)

Definition at line 442 of file renderer.cpp.

◆ SetExposure()

void Renderer::SetExposure ( float exposure)

Definition at line 246 of file renderer.cpp.

◆ SetGamma()

void Renderer::SetGamma ( float gamma)

Definition at line 238 of file renderer.cpp.

◆ SetLineWidth()

void Renderer::SetLineWidth ( float new_size)

Definition at line 411 of file renderer.cpp.

◆ SetPointSize()

void Renderer::SetPointSize ( float new_size)
Parameters
new_sizethe new diameter

Definition at line 423 of file renderer.cpp.

◆ SetPostProcessing()

void Renderer::SetPostProcessing ( const char * uniform_name)

Set the post processing function name in the shader

Definition at line 745 of file renderer.cpp.

◆ SetProjMat()

void Renderer::SetProjMat ( glm::mat4 proj)
inline

Definition at line 249 of file renderer.hpp.

◆ SetTonemapType()

void Renderer::SetTonemapType ( TonemapType type)

Definition at line 230 of file renderer.cpp.

◆ SetViewMat()

void Renderer::SetViewMat ( glm::mat4 view)
inline

Definition at line 252 of file renderer.hpp.

◆ SetViewProjMat()

void Renderer::SetViewProjMat ( glm::mat4 view_proj)
inline

Definition at line 255 of file renderer.hpp.

◆ StartScene()

void Renderer::StartScene ( )

Definition at line 446 of file renderer.cpp.

◆ UpdateLineWidth()

void Renderer::UpdateLineWidth ( )

Definition at line 416 of file renderer.cpp.

◆ UpdateScreenSegments()

void Renderer::UpdateScreenSegments ( )

Definition at line 758 of file renderer.cpp.

Friends And Related Symbol Documentation

◆ Camera

friend class Camera
friend

Definition at line 267 of file renderer.hpp.


The documentation for this class was generated from the following files: