Getting Started
Installation
Build AXSLC from source:
bash
# Clone the repository
git clone https://github.com/LuizPedroSousa/astra
cd axslc
# Build with CMake
mkdir build && cd build
cmake ..
make
# Install (optional)
sudo make installYour First Shader
Create a file shader.axsl:
axsl
@version 450;
@stage vertex {
@location(0) in vec3 a_pos;
@binding(0) uniform mat4 u_mvp;
void main() {
gl_Position = u_mvp * vec4(a_pos, 1.0);
}
}
@stage fragment {
out vec4 o_color;
void main() {
o_color = vec4(1.0, 0.0, 0.0, 1.0);
}
}Compile the Shader
bash
axslc shader.axslThis generates GLSL output files with the default prefix out:
out.vert.glsl- vertex shader (GLSL 4.5 core)out.frag.glsl- fragment shader (GLSL 4.5 core)
Custom Output Prefix
bash
axslc -o build/shaders/basic shader.axslor
bash
axslc --output build/shaders/basic shader.axslGenerates:
build/shaders/basic.vert.glslbuild/shaders/basic.frag.glsl
Additional CLI Options
bash
axslc [options] <input.axsl>Options:
-o, --output <prefix>- Output file prefix (default:out)-I, --include-path <path>- Override base directory for includes-v, --verbose- Print compilation status-h, --help- Print usage--version- Print version
Output naming convention:
.vert.glsl- vertex stage.frag.glsl- fragment stage.geom.glsl- geometry stage.comp.glsl- compute stage
File Structure
An .axsl file has the following structure:
axsl
@version <number>;
@include "path/to/file.axsl"; // zero or more
// Global declarations (structs, consts, uniforms, interfaces, functions)
@stage vertex { ... }
@stage fragment { ... }
@stage geometry { ... }
@stage compute { ... }Understanding the Output
AXSLC generates standard GLSL 4.5 core shaders from your unified .axsl source:
Generated GLSL structure:
- Version header:
#version 450 core - Global declarations (structs, functions, constants)
- Global uniforms/buffers (only if used in the stage)
- Stage-specific items (interface blocks, stage-local uniforms, functions)
Dead code elimination: Uniforms are only included in stages that actually reference them, reducing unnecessary uniform declarations.
Compilation Pipeline
AXSLC processes shaders through four phases:
- Tokenizer - Lexical analysis, converts source text to token stream
- Parser - Syntax analysis, builds Abstract Syntax Tree using Pratt parsing
- Linker - Resolves symbols, handles
@includefiles, tracks uniform usage per stage - Emitter - Generates final GLSL code with proper layout qualifiers
Error Handling
If compilation fails, AXSLC provides detailed error messages with source context:
file:line:col: message
N-2 | source line
N-1 | source line
N | source line where error occurred
| ^
N+1 | source line
N+2 | source lineCommon errors:
- Parse errors - syntax issues, unexpected tokens, missing braces
- Linker errors - unresolved symbols, undefined identifiers, missing include files
The parser attempts error recovery to report multiple issues in a single compilation.
Next Steps
- Learn about Language Syntax
- Explore the Interface System
- Check out complete Examples