Class for rasterizing polygons in a frame buffer. More...
#include <Rasterizer.hpp>


Public Member Functions | |
| Rasterizer (FrameBuffer< Color > &frame) | |
| Constructs a Rasterizer with a given frame buffer. | |
| Rasterizer ()=default | |
| Default constructor for the Rasterizer class (Default). | |
| ~Rasterizer ()=default | |
| Default destructor for the Rasterizer class. | |
| const FrameBuffer< Color > & | get_frame_buffer () const |
| Gets the frame buffer associated with this rasterizer. | |
| void | set_color (const Color &new_color) |
| Gets the current color used for drawing polygons. | |
| void | clear () |
| Gets the current color used for clearing the frame buffer. | |
| void | fill_convex_polygon (const glm::ivec4 *const vertices, const int *const indices_begin, const int *const indices_end) |
| Fills a convex polygon defined by its vertices and indices. | |
| void | fill_convex_polygon (const glm::ivec4 *const vertices, const face_t *const face) |
| Fills a convex polygon defined by its vertices and face structure. | |
| void | fill_convex_polygon_z_buffer (const glm::ivec4 *const vertices, const face_t *const face) |
| Fills a convex polygon in the Z-buffer. | |
| void | fill_convex_polygon_z_buffer (const glm::ivec4 *const vertices, const int *const indices_begin, const int *const indices_end) |
| Fills a convex polygon in the Z-buffer using vertex indices. | |
Public Attributes | |
| bool | debug_enabled = true |
Private Member Functions | |
| template<typename VALUE_TYPE, size_t SHIFT> | |
| void | interpolate (int *cache, int v0, int v1, int y_min, int y_max) |
| < Enable or disable debug logging for rasterization operations. | |
| template<unsigned COLOR_SIZE> | |
| void | fill_row (Color *start, unsigned left_offset, unsigned right_offset, const Color &color) |
| Fills a row of pixels in the frame buffer with a specified color. | |
| template<unsigned COLOR_SIZE> | |
| void | fill_row_zbuffer (Color *start, int *zbuffer, unsigned left_offset, unsigned right_offset, int z_start, int dz, const Color &color) |
| Fills a row of pixels in the frame buffer with a specified color using Z-buffering. | |
| void | fill_row (RGB565 *start, unsigned left_offset, unsigned right_offset, const RGB565 &color) |
| void | fill_row_zbuffer (RGB565 *start, int *zbuffer, unsigned left_offset, unsigned right_offset, int z_start, int dz, const RGB565 &color) |
Private Attributes | |
| FrameBuffer< Color > & | frame_buffer |
| Reference to the frame buffer where polygons will be drawn. | |
| std::vector< int > | z_buffer |
| Z-buffer for depth testing, used when painter's algorithm is disabled. | |
| Color | color |
| Current color to be used for drawing polygons. | |
| Color | clear_color |
| Color used to clear the frame buffer, default is black. | |
Static Private Attributes | |
| static int | offset_cache0 [1024] |
| Cache for left offsets of scanlines > | |
| static int | offset_cache1 [1024] |
| Cache for right offsets of scanlines. | |
| static int | z_cache0 [1024] |
| Cache for Z-buffer values for left offsets. | |
| static int | z_cache1 [1024] |
| Cache for Z-buffer values for right offsets. | |
| static constexpr const char * | RASTER_TAG = "Rasterizer" |
Class for rasterizing polygons in a frame buffer.
This class provides methods to fill convex polygons in a frame buffer with a specified color. It supports both standard rasterization and Z-buffering techniques.
| Color | The color type used for the frame buffer (e.g., RGB565). |
|
inline |
Constructs a Rasterizer with a given frame buffer.
Initializes the rasterizer with the specified frame buffer and prepares the Z-buffer if needed.
| frame | Reference to the frame buffer where polygons will be drawn. |
|
default |
Default constructor for the Rasterizer class (Default).
|
default |
Default destructor for the Rasterizer class.
Cleans up resources used by the rasterizer.
|
inline |
Gets the current color used for clearing the frame buffer.
This method returns the color that will be used to clear the frame buffer.
| void Ragot::Rasterizer< COLOR >::fill_convex_polygon | ( | const glm::ivec4 *const | vertices, |
| const face_t *const | face ) |
Fills a convex polygon defined by its vertices and face structure.
This method fills a convex polygon in the frame buffer using the specified vertices and face structure.
| vertices | Pointer to an array of vertices defining the polygon. |
| face | Pointer to the face structure containing vertex indices. |
| void Ragot::Rasterizer< COLOR >::fill_convex_polygon | ( | const glm::ivec4 *const | vertices, |
| const int *const | indices_begin, | ||
| const int *const | indices_end ) |
Fills a convex polygon defined by its vertices and indices.
This method fills a convex polygon in the frame buffer using the specified vertices and indices.
| vertices | Pointer to an array of vertices defining the polygon. |
| indices_begin | Pointer to the beginning of the indices array. |
| indices_end | Pointer to the end of the indices array. |

| template void Ragot::Rasterizer< Color >::fill_convex_polygon_z_buffer | ( | const glm::ivec4 *const | vertices, |
| const face_t *const | face ) |
Fills a convex polygon in the Z-buffer.
This method fills a convex polygon in the Z-buffer using the specified vertices and face structure. It performs depth testing to ensure correct rendering order.
| vertices | Pointer to an array of vertices defining the polygon. |
| face | Pointer to the face structure containing vertex indices. |
| template void Ragot::Rasterizer< Color >::fill_convex_polygon_z_buffer | ( | const glm::ivec4 *const | vertices, |
| const int *const | indices_begin, | ||
| const int *const | indices_end ) |
Fills a convex polygon in the Z-buffer using vertex indices.
| vertices | Pointer to an array of vertices defining the polygon. |
| indices_begin | Pointer to the beginning of the indices array. |
| indices_end | Pointer to the end of the indices array. |

|
inlineprivate |
Fills a row of pixels in the frame buffer with a specified color.
This method fills a row of pixels in the frame buffer with the specified color, from left_offset to right_offset.
| COLOR_SIZE | The size of the color type in bytes. |
| start | Pointer to the first pixel of the scanline. |
| left_offset | The starting offset (inclusive). |
| right_offset | The ending offset (exclusive). |
| color | The color to fill the row with. |
|
private |
|
inlineprivate |
Fills a row of pixels in the frame buffer with a specified color using Z-buffering.
This method fills a row of pixels in the frame buffer with the specified color, from left_offset to right_offset, while performing depth testing using the Z-buffer.
| COLOR_SIZE | The size of the color type in bytes. |
| start | Pointer to the first pixel of the scanline. |
| zbuffer | Pointer to the first element of the Z-buffer. |
| left_offset | The starting offset (inclusive). |
| right_offset | The ending offset (exclusive). |
| z_start | The initial depth value at left_offset. |
| dz | The increment of depth per pixel. |
| color | The color to fill the row with. |
|
private |
|
inline |
Gets the frame buffer associated with this rasterizer.
This method returns a reference to the frame buffer where polygons will be drawn.
|
private |
< Enable or disable debug logging for rasterization operations.
Interpolates pixel offsets for a scanline.
This method interpolates pixel offsets for a scanline based on the provided vertex values and Y range. It fills the offset cache with calculated pixel offsets.
| VALUE_TYPE | The type of value used for interpolation (e.g., int32_t). |
| SHIFT | The bit shift value used for scaling the interpolation. |
| cache | Pointer to the cache where interpolated offsets will be stored. |
| v0 | The starting vertex value. |
| v1 | The ending vertex value. |
| y_min | The minimum Y coordinate of the scanline. |
| y_max | The maximum Y coordinate of the scanline. |

|
inline |
Gets the current color used for drawing polygons.
This method returns the current color that will be used to fill polygons.
|
private |
Color used to clear the frame buffer, default is black.
|
private |
Current color to be used for drawing polygons.
| bool Ragot::Rasterizer< Color >::debug_enabled = true |
|
private |
Reference to the frame buffer where polygons will be drawn.
|
staticprivate |
Cache for left offsets of scanlines >
|
staticprivate |
Cache for right offsets of scanlines.
|
staticconstexprprivate |
|
private |
Z-buffer for depth testing, used when painter's algorithm is disabled.
|
staticprivate |
Cache for Z-buffer values for left offsets.
|
staticprivate |
Cache for Z-buffer values for right offsets.