Fx2D
A C++20 2D rigid-body physics engine
Loading...
Searching...
No Matches
FxRylbRenderer Class Reference

Runs and draws an FxScene in a raylib window. More...

#include <Renderer.h>

+ Collaboration diagram for FxRylbRenderer:

Public Member Functions

 FxRylbRenderer (FxScene &scene, int fps=60, unsigned int scale=100)
 
 ~FxRylbRenderer ()
 
void run (bool play=true)
 
void frame ()
 
void set_background (const FxVec4ui8 &color)
 
void set_background (const std::string &filepath)
 
void set_real_time_factor (const double &rt_factor)
 
double get_real_time_factor () const
 
FxVec2f screen_to_world (const FxVec2f &screen) const
 
FxVec2f world_to_screen (const FxVec2f &world) const
 
void set_draw_callback (const std::function< void(FxRylbRenderer &)> &callback)
 

Protected Member Functions

Texture2D get_or_load_texture (const std::string &path)
 
void init (int fps=60)
 
void draw_ui (double curr_rt_factor)
 
void draw_scene ()
 
void poll_input ()
 

Protected Attributes

FxScene & m_scene
 
unsigned int m_scale
 
unsigned int m_display_w
 
unsigned int m_display_h
 
double m_fixed_dt = 1.0 / 60.0
 
double m_dt_accumulator = 0.0
 
double m_simulation_time = 0.0
 
double m_real_time_factor = 1.0
 
double m_max_time_step = 0.06
 
double m_min_time_step = 1e-3
 
bool m_play = true
 
Color m_backgroundColor {50, 50, 50, 255}
 
Texture2D m_backgroundTexture {0, 0, 0, 0, 0}
 
bool m_hasBackgroundTexture {false}
 
std::unordered_map< std::string, Texture2D > m_textureCache
 
std::function< void(FxRylbRenderer &)> m_func_draw_callback
 

Detailed Description

Runs and draws an FxScene in a raylib window.

Definition at line 25 of file Renderer.h.

Constructor & Destructor Documentation

◆ FxRylbRenderer()

FxRylbRenderer::FxRylbRenderer ( FxScene &  scene,
int  fps = 60,
unsigned int  scale = 100 
)

◆ ~FxRylbRenderer()

FxRylbRenderer::~FxRylbRenderer ( )

Member Function Documentation

◆ draw_scene()

void FxRylbRenderer::draw_scene ( )
protected

◆ draw_ui()

void FxRylbRenderer::draw_ui ( double  curr_rt_factor)
protected

◆ frame()

void FxRylbRenderer::frame ( )

◆ get_or_load_texture()

Texture2D FxRylbRenderer::get_or_load_texture ( const std::string &  path)
protected

◆ get_real_time_factor()

double FxRylbRenderer::get_real_time_factor ( ) const
inline

Definition at line 67 of file Renderer.h.

◆ init()

void FxRylbRenderer::init ( int  fps = 60)
protected

◆ poll_input()

void FxRylbRenderer::poll_input ( )
protected

◆ run()

void FxRylbRenderer::run ( bool  play = true)

◆ screen_to_world()

FxVec2f FxRylbRenderer::screen_to_world ( const FxVec2f &  screen) const

◆ set_background() [1/2]

void FxRylbRenderer::set_background ( const FxVec4ui8 &  color)

◆ set_background() [2/2]

void FxRylbRenderer::set_background ( const std::string &  filepath)

◆ set_draw_callback()

void FxRylbRenderer::set_draw_callback ( const std::function< void(FxRylbRenderer &)> &  callback)
inline

Definition at line 75 of file Renderer.h.

◆ set_real_time_factor()

void FxRylbRenderer::set_real_time_factor ( const double &  rt_factor)

◆ world_to_screen()

FxVec2f FxRylbRenderer::world_to_screen ( const FxVec2f &  world) const

Member Data Documentation

◆ m_backgroundColor

Color FxRylbRenderer::m_backgroundColor {50, 50, 50, 255}
protected

Definition at line 40 of file Renderer.h.

◆ m_backgroundTexture

Texture2D FxRylbRenderer::m_backgroundTexture {0, 0, 0, 0, 0}
protected

Definition at line 41 of file Renderer.h.

◆ m_display_h

unsigned int FxRylbRenderer::m_display_h
protected

Definition at line 29 of file Renderer.h.

◆ m_display_w

unsigned int FxRylbRenderer::m_display_w
protected

Definition at line 29 of file Renderer.h.

◆ m_dt_accumulator

double FxRylbRenderer::m_dt_accumulator = 0.0
protected

Definition at line 32 of file Renderer.h.

◆ m_fixed_dt

double FxRylbRenderer::m_fixed_dt = 1.0 / 60.0
protected

Definition at line 31 of file Renderer.h.

◆ m_func_draw_callback

std::function<void(FxRylbRenderer&)> FxRylbRenderer::m_func_draw_callback
protected

Definition at line 47 of file Renderer.h.

◆ m_hasBackgroundTexture

bool FxRylbRenderer::m_hasBackgroundTexture {false}
protected

Definition at line 42 of file Renderer.h.

◆ m_max_time_step

double FxRylbRenderer::m_max_time_step = 0.06
protected

Definition at line 36 of file Renderer.h.

◆ m_min_time_step

double FxRylbRenderer::m_min_time_step = 1e-3
protected

Definition at line 37 of file Renderer.h.

◆ m_play

bool FxRylbRenderer::m_play = true
protected

Definition at line 38 of file Renderer.h.

◆ m_real_time_factor

double FxRylbRenderer::m_real_time_factor = 1.0
protected

Definition at line 35 of file Renderer.h.

◆ m_scale

unsigned int FxRylbRenderer::m_scale
protected

Definition at line 28 of file Renderer.h.

◆ m_scene

FxScene& FxRylbRenderer::m_scene
protected

Definition at line 27 of file Renderer.h.

◆ m_simulation_time

double FxRylbRenderer::m_simulation_time = 0.0
protected

Definition at line 33 of file Renderer.h.

◆ m_textureCache

std::unordered_map<std::string, Texture2D> FxRylbRenderer::m_textureCache
protected

Definition at line 44 of file Renderer.h.


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