Hello Triangle
Introduction
Violet is an incredibly tiny (<300K) cross-platform low level graphics API. Violet makes use of Violet Shading Language (VSL) to enable quickly authoring cross-platform shaders.
Buffers
Buffers in Violet can contain any data used between the CPU and GPU. Buffers can then be bound sequentially (with encoder.set_vertex_buffer
or encoder.set_fragment_buffer
) in the order in which they appear in the shader code.
struct View {
float4 view_matrix[16];
float4 proj_matrix[16];
};
View camera;
Handle<Buffer> view_buffer = renderer.create_buffer(&camera, sizeof(View));
render_encoder.set_vertex_buffer(view_buffer);
Features
Features
Violet Shading Language (VSL)
Violet provides a shading language for easily authoring cross-platform shaders.
struct VertexIn {
float2 position @attribute(position);
float3 color @attribute(color);
};
struct VertexOut {
float4 position @position;
float4 color @color;
};
VertexOut vertex_main(VertexIn input) @vertex {
VertexOut output;
output.position = float4(input.position.x, input.position.y, 0.0, 1.0);
output.color = float4(input.color, 1.0);
return output;
}
float4 fragment_main(VertexOut input) @fragment {
return input.color;
}
Getting Started
Benchmarks
Compatibility
Platform | API | Status |
Windows | D3D11 | 🚧 In-Progress |
macOS and iOS | Metal | ✅ Implemented |
Linux | OpenGL4 | ❌ Planned |
Web | WebGL2 | 🚧 In-Progress |
Violet has been tested the following compilers:
- Clang 15.0.0 (macOS)
- GCC 11.4.0 (Linux)
- MSVC 19.41.34120 (Windows)