lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
lmgl::renderer::Renderer Class Reference

Manages the rendering of scenes. More...

#include <renderer.hpp>

Public Member Functions

 Renderer ()
 Constructor for the Renderer class.
 
 ~Renderer ()=default
 Destructor for the Renderer class.
 
void render (std::shared_ptr< scene::Scene > scene, std::shared_ptr< scene::Camera > camera)
 Render a scene from the perspective of a camera.
 
void set_render_mode (RenderMode mode)
 Set the rendering mode.
 
void set_culling (bool enabled)
 Enable or disable face culling.
 
void set_depth_test (bool enabled)
 Enable or disable depth testing.
 
void set_blending (bool enabled)
 Enable or disable blending.
 
RenderMode get_render_mode () const
 Get the current rendering mode.
 
unsigned int get_draw_calls () const
 Get the number of draw calls made in the last render.
 
unsigned int get_triangles_count () const
 Get the number of triangles rendered in the last render.
 
void resize (int width, int height)
 Resizes the framebuffer to specific width and height.
 
void set_tone_map_mode (int mode)
 Sets the tone map mode.
 
void set_exposure (float exposure)
 Sets the exposure of the tone map.
 
void set_gamma (float gamma)
 Sets the gamma of the tone map.
 
void enable_post_processing (bool enabled)
 Enables post processing effects based on tone map mode and exposure/gamma.
 
void set_bloom_enabled (bool enabled)
 Enable or disable bloom effect.
 
void set_bloom_threshold (float threshold)
 Sets the bloom brightness threshold.
 
void set_bloom_intensity (float intensity)
 Sets the bloom intensity/strength.
 

Detailed Description

Manages the rendering of scenes.

This class is responsible for rendering 3D scenes using OpenGL. It handles the rendering pipeline, including setting up the camera, managing render modes, and optimizing draw calls.

Constructor & Destructor Documentation

◆ Renderer()

lmgl::renderer::Renderer::Renderer ( )

Constructor for the Renderer class.

Initializes the renderer with default settings.

◆ ~Renderer()

lmgl::renderer::Renderer::~Renderer ( )
default

Destructor for the Renderer class.

Cleans up any resources used by the renderer.

Member Function Documentation

◆ enable_post_processing()

void lmgl::renderer::Renderer::enable_post_processing ( bool enabled)

Enables post processing effects based on tone map mode and exposure/gamma.

Parameters
enabledWhether the postprocessing effects are enabled.

◆ get_draw_calls()

unsigned int lmgl::renderer::Renderer::get_draw_calls ( ) const
inline

Get the number of draw calls made in the last render.

This method returns the number of draw calls that were made during the last rendering operation.

Returns
Number of draw calls.

◆ get_render_mode()

RenderMode lmgl::renderer::Renderer::get_render_mode ( ) const
inline

Get the current rendering mode.

This method returns the current rendering mode of the renderer.

Returns
The current RenderMode.

◆ get_triangles_count()

unsigned int lmgl::renderer::Renderer::get_triangles_count ( ) const
inline

Get the number of triangles rendered in the last render.

This method returns the total number of triangles that were rendered during the last rendering operation.

Returns
Number of triangles rendered.

◆ render()

void lmgl::renderer::Renderer::render ( std::shared_ptr< scene::Scene > scene,
std::shared_ptr< scene::Camera > camera )

Render a scene from the perspective of a camera.

This method takes a scene and a camera as input and renders the scene using the specified camera's view and projection matrices. It also applies the current render mode and handles depth testing and blending based on the renderer's settings.

Parameters
sceneShared pointer to the scene to be rendered.
cameraShared pointer to the camera used for rendering.

◆ resize()

void lmgl::renderer::Renderer::resize ( int width,
int height )

Resizes the framebuffer to specific width and height.

Parameters
widthThe width to resize to.
heightThe height to resize to.

◆ set_blending()

void lmgl::renderer::Renderer::set_blending ( bool enabled)

Enable or disable blending.

This method allows toggling blending, which is used for rendering transparent objects.

Parameters
enabledTrue to enable blending, false to disable.

◆ set_bloom_enabled()

void lmgl::renderer::Renderer::set_bloom_enabled ( bool enabled)
inline

Enable or disable bloom effect.

Parameters
enabledTrue to enable bloom, false otherwise.

◆ set_bloom_intensity()

void lmgl::renderer::Renderer::set_bloom_intensity ( float intensity)
inline

Sets the bloom intensity/strength.

Parameters
intensityBloom intensity (default 0.5f).

◆ set_bloom_threshold()

void lmgl::renderer::Renderer::set_bloom_threshold ( float threshold)
inline

Sets the bloom brightness threshold.

Only pixels brighter than this value will bloom.

Parameters
thresholdBrightness threshold (default 1.0f).

◆ set_culling()

void lmgl::renderer::Renderer::set_culling ( bool enabled)

Enable or disable face culling.

This method allows toggling face culling, which can improve performance by not rendering faces of geometry that are not visible to the camera.

Parameters
enabledTrue to enable culling, false to disable.

◆ set_depth_test()

void lmgl::renderer::Renderer::set_depth_test ( bool enabled)

Enable or disable depth testing.

This method allows toggling depth testing, which ensures that closer objects are rendered in front of farther ones.

Parameters
enabledTrue to enable depth testing, false to disable.

◆ set_exposure()

void lmgl::renderer::Renderer::set_exposure ( float exposure)
inline

Sets the exposure of the tone map.

Parameters
exposureThe exposure float value.

◆ set_gamma()

void lmgl::renderer::Renderer::set_gamma ( float gamma)
inline

Sets the gamma of the tone map.

Parameters
gammaThe gamma float value.

◆ set_render_mode()

void lmgl::renderer::Renderer::set_render_mode ( RenderMode mode)

Set the rendering mode.

This method allows changing the rendering mode of the renderer. The mode can be set to solid, wireframe, or points, affecting how the geometry is displayed.

Parameters
modeThe desired rendering mode.

◆ set_tone_map_mode()

void lmgl::renderer::Renderer::set_tone_map_mode ( int mode)
inline

Sets the tone map mode.

The tone map modes are:

  • 0 = none;
  • 1 = reinhard;
  • 2 = aces.
Parameters
modeThe tone map mode.

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