srp
software rendering pipeline
Loading...
Searching...
No Matches
Framebuffer

Color and depth buffer management. More...

Collaboration diagram for Framebuffer:

Classes

struct  SRPColor
 
struct  SRPFramebuffer
 
typedef struct SRPColor SRPColor
 
typedef struct SRPFramebuffer SRPFramebuffer
 
SRPFramebuffersrpNewFramebuffer (size_t width, size_t height)
 
void srpFreeFramebuffer (SRPFramebuffer *this)
 
void framebufferClear (const SRPFramebuffer *this)
 
void srpFramebufferDrawPixel (const SRPFramebuffer *this, size_t x, size_t y, double depth, uint32_t color)
 
void srpFramebufferNDCToScreenSpace (const SRPFramebuffer *this, const double *NDC, double *SS)
 

Detailed Description

Color and depth buffer management.

Typedef Documentation

◆ SRPColor

typedef struct SRPColor SRPColor

Holds RGBA8888 color data

◆ SRPFramebuffer

Holds RBGA8888 color buffer and depth buffer

Function Documentation

◆ framebufferClear()

void framebufferClear ( const SRPFramebuffer this)

Clear a framebuffer: fill the color with black and depth with -1

Parameters
[in]thisThe pointer to SRPFramebuffer, as returned from srpNewFramebuffer()

◆ srpFramebufferDrawPixel()

void srpFramebufferDrawPixel ( const SRPFramebuffer this,
size_t  x,
size_t  y,
double  depth,
uint32_t  color 
)

Draw a pixel in a framebuffer

Parameters
[in]thisThe pointer to SRPFramebuffer, as returned from srpNewFramebuffer
[in]x,yPosition at which to draw the pixel. X-axis points from left to right, Y-axis - from top to bottom
[in]depthDepth value to assign to the pixel, assumed to be inside the [-1, 1] interval. If it is less than currently assigned depth buffer value to this pixel, nothing is drawn.
[in]colorRBGA8888 color to draw.
Todo:
This is not the job of the framebuffer to check this, this should be deleted after the primitive clipping implementation

◆ srpFramebufferNDCToScreenSpace()

void srpFramebufferNDCToScreenSpace ( const SRPFramebuffer this,
const double *  NDC,
double *  SS 
)

Convert Normalized Device Coordinates to screen-space coordiantes

Parameters
[in]thisThe pointer to SRPFramebuffer, as returned from srpNewFramebuffer
[in]NDCPointer to 3-element double array containing NDC position
[out]SSPointer to 3-element double array that will contain SS position after the call. The z-component is the same as z-component of NDC coordinates.

◆ srpFreeFramebuffer()

void srpFreeFramebuffer ( SRPFramebuffer this)

Free a framebuffer

Parameters
[in]thisThe pointer to SRPFramebuffer, as returned from srpNewFramebuffer()

◆ srpNewFramebuffer()

SRPFramebuffer * srpNewFramebuffer ( size_t  width,
size_t  height 
)

Create a framebuffer

Parameters
[in]widthWidth of a new framebuffer in pixels
[in]heightHeight of a new framebuffer in pixels
Returns
A pointer to the created framebuffer