Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::render3d::SoftwareFramebuffer Class Reference

Manages RGBA8 color pixels and Z-buffer for software rasterization. More...

#include <SoftwareFramebuffer.hpp>

Public Member Functions

 SoftwareFramebuffer ()=default
 Constructs an empty framebuffer.
 SoftwareFramebuffer (uint32_t width, uint32_t height)
 Constructs a framebuffer with specific pixel dimensions.
void resize (uint32_t width, uint32_t height)
 Resizes color and depth buffers.
void clearColor (RgbaColor color) noexcept
 Clears color buffer to specified RGBA color.
void clearDepth (float depth=1.0F) noexcept
 Clears depth buffer to specified value.
void clear (RgbaColor color, float depth=1.0F) noexcept
 Clears both color and depth buffers.
bool testAndSetPixel (uint32_t pixel_x, uint32_t pixel_y, float depth, RgbaColor color) noexcept
 Tests depth and writes pixel if closer than current depth.
bool blendAdditivePixel (uint32_t pixel_x, uint32_t pixel_y, float depth, RgbaColor color) noexcept
 Performs depth-tested additive alpha blending into the color buffer without writing depth.
float getDepth (uint32_t pixel_x, uint32_t pixel_y) const noexcept
 Reads depth value at pixel.
uint32_t width () const noexcept
uint32_t height () const noexcept
std::span< const uint8_t > colorBytes () const noexcept
const std::vector< uint8_t > & colorBuffer () const noexcept
const std::vector< float > & depthBuffer () const noexcept

Private Attributes

uint32_t width_ {0}
uint32_t height_ {0}
std::vector< uint8_t > color_buffer_
std::vector< float > depth_buffer_

Detailed Description

Manages RGBA8 color pixels and Z-buffer for software rasterization.

Constructor & Destructor Documentation

◆ SoftwareFramebuffer() [1/2]

correlation::render3d::SoftwareFramebuffer::SoftwareFramebuffer ( )
default

Constructs an empty framebuffer.

◆ SoftwareFramebuffer() [2/2]

correlation::render3d::SoftwareFramebuffer::SoftwareFramebuffer ( uint32_t width,
uint32_t height )
inline

Constructs a framebuffer with specific pixel dimensions.

Parameters
widthViewport pixel width.
heightViewport pixel height.
Here is the call graph for this function:

Member Function Documentation

◆ blendAdditivePixel()

bool correlation::render3d::SoftwareFramebuffer::blendAdditivePixel ( uint32_t pixel_x,
uint32_t pixel_y,
float depth,
RgbaColor color )
inlinenoexcept

Performs depth-tested additive alpha blending into the color buffer without writing depth.

Parameters
pixel_xX pixel coordinate.
pixel_yY pixel coordinate.
depthFragment depth value.
colorFragment RGBA color (alpha channel modulates additive brightness).
Returns
True if fragment passed depth test and was blended.

◆ clear()

void correlation::render3d::SoftwareFramebuffer::clear ( RgbaColor color,
float depth = 1.0F )
inlinenoexcept

Clears both color and depth buffers.

Parameters
colorBackground fill color.
depthClear depth value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearColor()

void correlation::render3d::SoftwareFramebuffer::clearColor ( RgbaColor color)
inlinenoexcept

Clears color buffer to specified RGBA color.

Parameters
colorFill color.
Here is the caller graph for this function:

◆ clearDepth()

void correlation::render3d::SoftwareFramebuffer::clearDepth ( float depth = 1.0F)
inlinenoexcept

Clears depth buffer to specified value.

Parameters
depthDepth value (default 1.0F).
Here is the caller graph for this function:

◆ colorBuffer()

const std::vector< uint8_t > & correlation::render3d::SoftwareFramebuffer::colorBuffer ( ) const
inlinenodiscardnoexcept

◆ colorBytes()

std::span< const uint8_t > correlation::render3d::SoftwareFramebuffer::colorBytes ( ) const
inlinenodiscardnoexcept

◆ depthBuffer()

const std::vector< float > & correlation::render3d::SoftwareFramebuffer::depthBuffer ( ) const
inlinenodiscardnoexcept

◆ getDepth()

float correlation::render3d::SoftwareFramebuffer::getDepth ( uint32_t pixel_x,
uint32_t pixel_y ) const
inlinenodiscardnoexcept

Reads depth value at pixel.

Parameters
pixel_xX pixel coordinate.
pixel_yY pixel coordinate.
Returns
Depth buffer value.

◆ height()

uint32_t correlation::render3d::SoftwareFramebuffer::height ( ) const
inlinenodiscardnoexcept
Here is the caller graph for this function:

◆ resize()

void correlation::render3d::SoftwareFramebuffer::resize ( uint32_t width,
uint32_t height )
inline

Resizes color and depth buffers.

Parameters
widthNew pixel width.
heightNew pixel height.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testAndSetPixel()

bool correlation::render3d::SoftwareFramebuffer::testAndSetPixel ( uint32_t pixel_x,
uint32_t pixel_y,
float depth,
RgbaColor color )
inlinenoexcept

Tests depth and writes pixel if closer than current depth.

Parameters
pixel_xX pixel coordinate.
pixel_yY pixel coordinate.
depthFragment depth value.
colorFragment RGBA color.
Returns
True if fragment passed depth test and was written.

◆ width()

uint32_t correlation::render3d::SoftwareFramebuffer::width ( ) const
inlinenodiscardnoexcept
Here is the caller graph for this function:

Member Data Documentation

◆ color_buffer_

std::vector<uint8_t> correlation::render3d::SoftwareFramebuffer::color_buffer_
private

◆ depth_buffer_

std::vector<float> correlation::render3d::SoftwareFramebuffer::depth_buffer_
private

◆ height_

uint32_t correlation::render3d::SoftwareFramebuffer::height_ {0}
private

◆ width_

uint32_t correlation::render3d::SoftwareFramebuffer::width_ {0}
private

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