diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 3 | ||||
| -rw-r--r-- | src/script_sys.c | 33 | ||||
| -rw-r--r-- | src/script_sys.h | 5 |
3 files changed, 41 insertions, 0 deletions
@@ -1,6 +1,7 @@ #include <raylib.h> #include "texture_sys.h" #include "shader_sys.h" +#include "script_sys.h" int main() { @@ -10,6 +11,7 @@ int main() init_tex_sys(); init_shader_sys(); + init_script_sys(); int femme = load_new_tex("assets/femme.png"); int grayscale = load_new_shader("assets/gs_full.glsl"); @@ -25,6 +27,7 @@ int main() EndDrawing(); } + deinit_script_sys(); unload_active_textures(); unload_active_shaders(); diff --git a/src/script_sys.c b/src/script_sys.c new file mode 100644 index 0000000..047ba8a --- /dev/null +++ b/src/script_sys.c @@ -0,0 +1,33 @@ +#include "script_sys.h" + +#include <libtcc.h> +#include <stddef.h> +#include <stdio.h> + +TCCState* state = NULL; + +int goob(void) +{ + return 255; +} + +void init_script_sys(void) +{ + state = tcc_new(); + tcc_set_output_type(state, TCC_OUTPUT_MEMORY); + + tcc_add_symbol(state, "goob", goob); + + tcc_add_file(state, "assets/src/main.c"); + + tcc_relocate(state, TCC_RELOCATE_AUTO); + + int(*const test)() = tcc_get_symbol(state, "test"); + printf("Result: %i\n", test()); +} + +void deinit_script_sys(void) +{ + tcc_delete(state); + state = NULL; +}
\ No newline at end of file diff --git a/src/script_sys.h b/src/script_sys.h new file mode 100644 index 0000000..146ed04 --- /dev/null +++ b/src/script_sys.h @@ -0,0 +1,5 @@ +#pragma once + +void init_script_sys(void); + +void deinit_script_sys(void);
\ No newline at end of file |
