valentingalea / vml

C++17 GLSL-like vector and matrix math lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VML

C++17 GLSL vector and matrix math library. Tweaked for best debug code gen.

Quick Usage

Introduce the GLSL types
using vec3 = vml::vector<float, 0, 1, 2>;
using mat3 = vml::matrix<float, vml::vector, vml::indices_pack<0, 1, 2>, vml::indices_pack<0, 1, 2>>;
Compile shader code as C++
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = fragCoord/iResolution.xy;

    // Time varying pixel color
    vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));

    // Output to screen
    fragColor = vec4(col,1.0);
}

Debug!

debug

About

Inspired by and borrowed major ideas from CxxSwizzle but mine is engineered for best possible debug code gen.

It includes a SDL based sample app that runs GLSL shaders in a software rasterizer. It can get decent framerates for simple/medium complexity shaders.

About

C++17 GLSL-like vector and matrix math lib

License:MIT License


Languages

Language:C++ 52.3%Language:C 44.4%Language:HTML 2.0%Language:CMake 0.6%Language:GLSL 0.5%Language:Batchfile 0.2%Language:Makefile 0.0%