|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Manages a 2D depth texture for rendering shadows from directional lights. More...
#include <shadow_map.hpp>
Public Member Functions | |
| ShadowMap (unsigned int width=2048, unsigned int height=2048) | |
| Constructs a ShadowMap with the specified width and height. | |
| ~ShadowMap () | |
| Destructor for ShadowMap. | |
| void | bind () |
| Binds the framebuffer object for rendering to the shadow map. | |
| void | unbind () |
| Unbinds the framebuffer object, returning to the default framebuffer. | |
| void | bind_texture (unsigned int slot=0) const |
| Binds the depth texture to the specified texture slot for use in shaders. | |
| unsigned int | get_texture_id () const |
| Returns the OpenGL texture ID of the depth texture. | |
| unsigned int | get_width () const |
| Returns the width of the shadow map texture. | |
| unsigned int | get_height () const |
| Returns the height of the shadow map texture. | |
| void | resize (unsigned int width, unsigned int height) |
| Resizes the shadow map texture to the specified width and height. | |
Manages a 2D depth texture for rendering shadows from directional lights.
This class encapsulates the creation and management of a framebuffer object (FBO) and a depth texture used for shadow mapping. It provides methods to bind and unbind the FBO, bind the depth texture for use in shaders, and resize the shadow map.
| lmgl::renderer::ShadowMap::ShadowMap | ( | unsigned int | width = 2048, |
| unsigned int | height = 2048 ) |
Constructs a ShadowMap with the specified width and height.
Creates a framebuffer object and a depth texture for shadow mapping.
| width | The width of the shadow map texture. Default is 2048. |
| height | The height of the shadow map texture. Default is 2048. |
| void lmgl::renderer::ShadowMap::bind | ( | ) |
Binds the framebuffer object for rendering to the shadow map.
This method binds the FBO so that subsequent rendering commands will write depth information to the shadow map texture.
| void lmgl::renderer::ShadowMap::bind_texture | ( | unsigned int | slot = 0 | ) | const |
Binds the depth texture to the specified texture slot for use in shaders.
This method binds the depth texture so that it can be sampled in shaders for shadow calculations.
| slot | The texture slot to bind the depth texture to. Default is 0. |
|
inline |
Returns the height of the shadow map texture.
|
inline |
Returns the OpenGL texture ID of the depth texture.
|
inline |
Returns the width of the shadow map texture.
| void lmgl::renderer::ShadowMap::resize | ( | unsigned int | width, |
| unsigned int | height ) |
Resizes the shadow map texture to the specified width and height.
This method recreates the depth texture with the new dimensions.
| width | The new width of the shadow map texture. |
| height | The new height of the shadow map texture. |
| void lmgl::renderer::ShadowMap::unbind | ( | ) |
Unbinds the framebuffer object, returning to the default framebuffer.
This method should be called after rendering to the shadow map is complete. It restores rendering to the default framebuffer.