Shaders
Mach::GL uses a proprietary file for shaders that takes in all valid types of shaders and combines them into one file that needs to be read. This file is a plain text file with the extension of .mglsdr. This standard is recommended, however, a vertex shader and fragment shader can be loaded in separately. With this, there are 2 constructors available for a Graphics::MACH_SHADER object.
Graphics::MACH_SHADER shader1 = Graphics::Shader::createShader("shader.mglsdr");
Graphics::MACH_SHADER shader2 = Graphics::Shader::createShader("shader.vert", "shader.frag");
There are many functions available to send information (uniforms) to shaders:
Function | Type | Size (bytes) |
---|---|---|
setUniform1i(name, value) | int | 4 |
setUniform1iv(name, value, count) | int (array) | 4 * count |
setUniform1f(name, value) | float | 4 |
setUniform1fv(name, value, count) | float (array) | 4 * count |
setUniform2f(name, value) | float2 | 8 |
setUniform2fv(name, value, count) | float2 (array) | 8 * count |
setUniform3f(name, value) | float3 | 12 |
setUniform3fv(name, value, count) | float3 (array) | 12 * count |
setUniform4f(name, value) | float4 | 16 |
setUniform1fv(name, value, count) | float4 (array) | 16 * count |
setUniformMatrix4fv(name, matrix) | matrix4x4 | 64 |