import c
This commit is contained in:
@@ -194,7 +194,7 @@ main :: () {
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, xx vertices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, @vertices, GL_STATIC_DRAW);
|
||||
|
||||
// Position attribute (location 0): 3 floats, stride 32 bytes, offset 0
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 32, xx 0);
|
||||
|
||||
14
examples/33-c-import.sx
Normal file
14
examples/33-c-import.sx
Normal file
@@ -0,0 +1,14 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
#import c {
|
||||
#include "vendors/test_c/test.h";
|
||||
#source "vendors/test_c/test.c";
|
||||
};
|
||||
|
||||
main :: () -> s32 {
|
||||
a := add_numbers(10, 20);
|
||||
b := multiply(5, 6);
|
||||
print("add_numbers(10, 20) = {}\n", a);
|
||||
print("multiply(5, 6) = {}\n", b);
|
||||
0;
|
||||
}
|
||||
16
examples/33-stb-image.sx
Normal file
16
examples/33-stb-image.sx
Normal file
@@ -0,0 +1,16 @@
|
||||
#import "modules/std.sx";
|
||||
stb :: #import "modules/stb.sx";
|
||||
|
||||
main :: () -> s32 {
|
||||
w: s32 = 0;
|
||||
h: s32 = 0;
|
||||
ch: s32 = 0;
|
||||
img := stb.stbi_load("test.png", @w, @h, @ch, 4);
|
||||
if xx img != 0 {
|
||||
print("loaded {}x{} ({} channels)\n", w, h, ch);
|
||||
stb.stbi_image_free(xx img);
|
||||
} else {
|
||||
print("no image (expected in test)\n");
|
||||
}
|
||||
0;
|
||||
}
|
||||
10
examples/34-c-import-ns.sx
Normal file
10
examples/34-c-import-ns.sx
Normal file
@@ -0,0 +1,10 @@
|
||||
#import "modules/std.sx";
|
||||
tc :: #import "modules/test_c.sx";
|
||||
|
||||
main :: () -> s32 {
|
||||
a := tc.add_numbers(10, 20);
|
||||
b := tc.multiply(5, 6);
|
||||
print("tc.add_numbers(10, 20) = {}\n", a);
|
||||
print("tc.multiply(5, 6) = {}\n", b);
|
||||
0;
|
||||
}
|
||||
4
examples/modules/stb.sx
Normal file
4
examples/modules/stb.sx
Normal file
@@ -0,0 +1,4 @@
|
||||
#import c {
|
||||
#include "vendors/stb_image/stb_image.h";
|
||||
#source "vendors/stb_image/stb_image_impl.c";
|
||||
};
|
||||
4
examples/modules/test_c.sx
Normal file
4
examples/modules/test_c.sx
Normal file
@@ -0,0 +1,4 @@
|
||||
#import c {
|
||||
#include "vendors/test_c/test.h";
|
||||
#source "vendors/test_c/test.c";
|
||||
};
|
||||
Reference in New Issue
Block a user