This commit is contained in:
agra
2026-02-24 13:37:27 +02:00
parent 170e236764
commit b98711a1d3
13 changed files with 157 additions and 632 deletions

View File

@@ -96,3 +96,41 @@ load_gl :: (get_proc: ([:0]u8) -> *void) {
glDepthFunc = xx get_proc("glDepthFunc");
glUniform1f = xx get_proc("glUniform1f");
}
// --- Shader utilities ---
create_program :: (vert_src: [:0]u8, frag_src: [:0]u8) -> u32 {
vs := compile_shader(GL_VERTEX_SHADER, vert_src);
fs := compile_shader(GL_FRAGMENT_SHADER, frag_src);
prog := glCreateProgram();
glAttachShader(prog, vs);
glAttachShader(prog, fs);
glLinkProgram(prog);
status : s32 = 0;
glGetProgramiv(prog, GL_LINK_STATUS, @status);
if status == GL_FALSE {
log_buf: [512]u8 = ---;
glGetProgramInfoLog(prog, 512, null, log_buf);
}
glDeleteShader(vs);
glDeleteShader(fs);
return prog;
}
compile_shader :: (shader_type : u32, source: [:0]u8) -> u32 {
shader := glCreateShader(shader_type);
glShaderSource(shader, 1, source, null);
glCompileShader(shader);
status : s32 = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, @status);
if status == GL_FALSE {
log_buf : [512]u8 = ---;
glGetShaderInfoLog(shader, 512, null, log_buf);
}
return shader;
}

View File

@@ -0,0 +1,5 @@
// This file lives in modules/testpkg/ but imports modules/std.sx
// via cwd-relative path (not relative to this file's directory).
#import "modules/std.sx";
cwd_greet :: () -> string { format("cwd-import-ok"); }