Skip to content

About

Minimal CPU shader multithreaded renderer written in pure C - raw Win32, no libraries

Resources

Stars

31 stars

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C-CPUShader

Minimal CPU shader multithreaded renderer written in pure C - raw Win32, no libraries, no abstraction layers. Pixels, threads, and math from scratch.
I just felt like doing something with C.
The math library isn't done yet, I just added the functions that I needed for the demo.

Compile

gcc src/*.c src/shaders/*.c -o build/bin.exe -lgdi32

Code

Simply init the window and choose the render function with the number of threads you want to use from your CPU. The last parameter is to enable temporal accumulation for ray tracing shaders.

#include "defines.h"
#include "win.h"
#include "shaders/sphere_tracing.h"
#include "shaders/glass_disks.h"

vec4_t main_image(vec2_t fragCoord, vec2_t resolution, float time, uint frame)
{
    return glass_disks_main(fragCoord, resolution, time, frame);
}

int main(void)
{
    //Init Window
    window_create("Renderer", 700, 450);

    //Render Loop with 10 threads and temporal accumulation enabled
    window_run(main_image, 10, true);

    return 0;
}

Screenshots

Renderer _ Rendering _ 8 0fps, 125 0ms _ Time _ 191 61s 3_9_2026 6_16_08 PM Renderer _ Rendering _ 21 3fps, 47 0ms _ Time _ 182 14s 3_10_2026 7_42_16 AM

About

Minimal CPU shader multithreaded renderer written in pure C - raw Win32, no libraries

Resources

Stars

31 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages