srp
software rendering pipeline
Loading...
Searching...
No Matches
framebuffer.c File Reference
#include <stdio.h>
#include <assert.h>
#include "framebuffer.h"
#include "message_callback_p.h"
#include "defines.h"
Include dependency graph for framebuffer.c:

Functions

SRPFramebuffersrpNewFramebuffer (size_t width, size_t height)
 
void srpFreeFramebuffer (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)
 
void framebufferClear (const SRPFramebuffer *this)
 
static uint32_t * framebufferGetPixelPointer (const SRPFramebuffer *this, size_t x, size_t y)
 
static double * framebufferGetDepthPointer (const SRPFramebuffer *this, size_t x, size_t y)
 

Detailed Description

Framebuffer implementation

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()
Examples
01_colored_triangle/main.c, 02_spinning_triangle/main.c, and 03_spinning_textured_cube/main.c.

◆ 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()
Examples
01_colored_triangle/main.c, 02_spinning_triangle/main.c, and 03_spinning_textured_cube/main.c.

◆ 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
Examples
01_colored_triangle/main.c, 02_spinning_triangle/main.c, and 03_spinning_textured_cube/main.c.