imports
This commit is contained in:
@@ -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;
|
||||
}
|
||||
5
examples/modules/testpkg/cwd_test.sx
Normal file
5
examples/modules/testpkg/cwd_test.sx
Normal 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"); }
|
||||
Reference in New Issue
Block a user