From c81d3f9d128b31814f0e7d05b8a334098f69211b Mon Sep 17 00:00:00 2001 From: shariq Date: Mon, 8 May 2017 00:22:57 +0500 Subject: [PATCH] Added reading configuration from config_vars and config.cfg located at root folder of assets --- assets/config.cfg | 18 ++++++++++ build/linux/makefile | 1 + orgfile.org | 21 +++++++---- src/config_vars.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ src/game.c | 37 +++++++++----------- src/hashmap.c | 36 +++++++++++++++---- src/hashmap.h | 9 +++-- src/input.c | 1 - src/main.c | 23 +++++++++--- src/platform.c | 13 ++++--- src/platform.h | 2 +- src/renderer.c | 26 ++++++++------ src/variant.c | 28 +++++++++++++++ src/variant.h | 4 +++ 14 files changed, 244 insertions(+), 58 deletions(-) create mode 100644 assets/config.cfg diff --git a/assets/config.cfg b/assets/config.cfg new file mode 100644 index 0000000..64608fa --- /dev/null +++ b/assets/config.cfg @@ -0,0 +1,18 @@ +# This is a comment +render_width: 800 +render_height: 600 +#fog_mode : 0 = off, 1 = linear, 2 = exponential, 3 = exponential squared +fog_mode: 2 +fog_color: 0.5 0.2 0.2 +fog_density: 0.002 +fog_start_dist: 20 +fog_max_dist: 150 +# There can be comments or empty newlines in between unlike entity definitions + +ambient_light: 0.1 0.1 0.12 +msaa_enabled: true +msaa_levels: 4 + +debug_draw_enabled: false +debug_draw_mode: 0 +debug_draw_color: 0 1 0 1 \ No newline at end of file diff --git a/build/linux/makefile b/build/linux/makefile index 89718f9..dfe70fe 100644 --- a/build/linux/makefile +++ b/build/linux/makefile @@ -56,6 +56,7 @@ dist: release -@echo './Symmetry' >> $(DIST_DIR)/$(PROJECT_NAME)/Launch.sh -@chmod +x $(DIST_DIR)/$(PROJECT_NAME)/Launch.sh -@cp $(PROJECT_NAME) $(DIST_DIR)/$(PROJECT_NAME) + -@chmod +x $(DIST_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME) -@echo DONE creating distribution clean: diff --git a/orgfile.org b/orgfile.org index b720edc..af380f1 100644 --- a/orgfile.org +++ b/orgfile.org @@ -24,15 +24,15 @@ diffuse_texture: "checkered.tga" specular: 0.55 *** Configuration Variables a.k.a cfg-vars -// Comment +# Comment render_width: 1024 render_height: 1024 -fog_enabled: 1 +debug_draw_enabled: true fog_color: 0.5 0.2 0.2 1 -// There can be comments or empty newlines in between unlike entity definitions +# There can be comments or empty newlines in between unlike entity definitions ambient_light: 0.1 0.1 0.1 1 -msaa: 1 +msaa: true msaa_levels: 8 *** Keybindings @@ -89,7 +89,8 @@ msaa_levels: 8 - State "DONE" from "TODO" [2015-08-19 Wed 13:30] ** TODO Bounding Boxes - Recalculated bounding boxes for rotated meshes? -** TODO Fix input lag and other framerate related issues +** DONE Fix input lag and other framerate related issues +- State "DONE" from "TODO" [2017-05-07 Sun 18:40] ** TODO File extension checking for asset loading ** DONE Materials - State "DONE" from "TODO" [2015-10-13 Tue 19:38] @@ -138,7 +139,12 @@ x Font atlas proper cleanup - Decoupled event handling of gui and input if possible - Custom rendering for gui ** TODO Allow passsing base path as commandline argument? -** TODO Variant -> String conversion procedure. Use in editor for debug var slots +** TODO Show SDL dialogbox if we cannot launch at all? +** TODO Writing back to config file + maybe with comments intact? +** DONE Reading from config file +- State "DONE" from "TODO" [2017-05-07 Sun 23:52] +** DONE Variant -> String conversion procedure. Use in editor for debug var slots +- State "DONE" from "TODO" [2017-05-07 Sun 18:43] ** DONE Add strings and booleans to variant types - State "DONE" from "TODO" [2017-03-29 Wed 00:23] ** DONE Fix Key release not being reported @@ -155,7 +161,8 @@ x Font atlas proper cleanup ** TODO Ingame console and console commands etc ** TODO Allow binding/unbinding input maps to functions at runtime, for example if input map "Recompute" is triggered, it would call some function that can recompute bounding spheres. ** TODO Better handling of wav format checking at load time -** TODO Array-based Hashmaps +** DONE Array-based Hashmaps +- State "DONE" from "TODO" [2017-05-07 Sun 18:42] ** TODO Sprite sheet animations ** TODO Replace orgfile with simple text readme and reduce duplication? ** TODO Ray picking diff --git a/src/config_vars.c b/src/config_vars.c index 1b95be4..aede75e 100644 --- a/src/config_vars.c +++ b/src/config_vars.c @@ -2,14 +2,33 @@ #include "string_utils.h" #include "variant.h" #include "hashmap.h" +#include "file_io.h" +#include "log.h" #include +#include + +#define MAX_LINE_LEN 512 static struct Hashmap* cvars = NULL; void config_vars_init(void) { cvars = hashmap_new(); + /* Initialize with default values incase there is no config file */ + hashmap_int_set(cvars, "render_width", 1024); + hashmap_int_set(cvars, "render_height", 768); + hashmap_int_set(cvars, "fog_mode", 0); + hashmap_vec3_setf(cvars, "fog_color", 0.5f, 0.2f, 0.2f); + hashmap_float_set(cvars, "fog_density", 0.1); + hashmap_float_set(cvars, "fog_start_dist", 10.f); + hashmap_float_set(cvars, "fog_max_dist", 50.f); + hashmap_vec3_setf(cvars, "ambient_light", 0.1f, 0.1f, 0.1f); + hashmap_bool_set(cvars, "msaa_enabled", 1); + hashmap_int_set(cvars, "msaa_levels", 4); + hashmap_bool_set(cvars, "debug_draw_enabled", 1); + hashmap_int_set(cvars, "debug_draw_mode", 0); + hashmap_vec4_setf(cvars, "debug_draw_color", 1.f, 0.f, 0.f, 1.f); } void config_vars_cleanup(void) @@ -24,7 +43,71 @@ struct Hashmap* config_vars_get(void) int config_vars_load(const char* filename) { + int success = 0; + FILE* config_file = io_file_open(filename, "r"); + if(!config_file) + { + log_error("config:vars_load", "Could not open %s", filename); + return success; + } + + /* Read line by line, ignore comments */ + char key_str[HASH_MAX_KEY_LEN]; + char line_buffer[MAX_LINE_LEN]; + memset(key_str, '\0', HASH_MAX_KEY_LEN); + memset(line_buffer, '\0', MAX_LINE_LEN); + int current_line = 0; + while(fgets(line_buffer, MAX_LINE_LEN - 1, config_file)) + { + current_line++; + line_buffer[strcspn(line_buffer, "\r\n")] = '\0'; + + if(line_buffer[0] == '#' || strlen(line_buffer) == 0) + continue; + + log_message("Line : %s", line_buffer); + memset(key_str, '\0', HASH_MAX_KEY_LEN); + char* value_str = strstr(line_buffer, ":"); + if(!value_str) + { + log_warning("Malformed value in config file %s, line %d", filename, current_line); + continue; + } + int key_str_len = value_str - line_buffer; + strncpy(key_str, line_buffer, key_str_len); + if(key_str_len >= HASH_MAX_KEY_LEN) + key_str[HASH_MAX_KEY_LEN - 1] = '\0'; + else + key_str[key_str_len] = '\0'; + value_str++; /* Ignore the colon(:) */ + + //char* key = NULL; + struct Variant* value = hashmap_value_get(cvars, key_str); + if(!value) + { + log_warning("Unknown value in config file %s, line %d", filename, current_line); + continue; + } + + variant_from_str(value, value_str, value->type); + /* HASHMAP_FOREACH(cvars, key, value) */ + /* { */ + /* if(strncmp(line_buffer, key, strlen(key)) == 0) */ + /* { */ + /* char* value_str = strstr(line_buffer, ":"); */ + /* if(value_str) */ + /* { */ + /* value_str++; */ + /* variant_from_str(value, value_str, value->type); */ + /* } */ + /* break; */ + /* } */ + /* } */ + } + success = 1; + fclose(config_file); + return success; } void config_vars_save(const char* filename) diff --git a/src/game.c b/src/game.c index 70ddd70..6c24eda 100644 --- a/src/game.c +++ b/src/game.c @@ -66,9 +66,6 @@ int game_init(struct Window* window) /* TODO: Decouple systems' init/cleanup from game, they should exist and run even if there's no "game" */ /* Init systems */ input_init(); - char* base_path = platform_base_path_get(); - io_file_init(base_path); - free(base_path); sound_init(); shader_init(); texture_init(); @@ -82,7 +79,6 @@ int game_init(struct Window* window) editor_init(); model_init(); entity_init(); - config_vars_init(); scene_init(); /* Debug scene setup */ @@ -230,22 +226,22 @@ void scene_setup(void) /* struct Light* sun_light = entity_component_add(sun, C_LIGHT, LT_DIR); */ /* sun_light->intensity = 0.8f; */ - struct Hashmap* cvars = config_vars_get(); - hashmap_int_set(cvars, "My_Int", 20); - hashmap_str_set(cvars, "My_String", "This is my string"); - hashmap_float_set(cvars, "Some_FLOAT", 42.222f); - hashmap_double_set(cvars, "Some_Double", 99.999); - hashmap_bool_set(cvars, "The_Truth", 0); - - char* key = NULL; - struct Variant* value = NULL; - char variant_str[256]; - HASHMAP_FOREACH(cvars, key, value) - { - variant_to_str(value, variant_str, 256); - log_message("VAL :(%s) : (%s)", key, variant_str); - memset(variant_str, '\0', 256); - } + /* struct Hashmap* cvars = config_vars_get(); */ + /* hashmap_int_set(cvars, "My_Int", 20); */ + /* hashmap_str_set(cvars, "My_String", "This is my string"); */ + /* hashmap_float_set(cvars, "Some_FLOAT", 42.222f); */ + /* hashmap_double_set(cvars, "Some_Double", 99.999); */ + /* hashmap_bool_set(cvars, "The_Truth", 0); */ + + /* char* key = NULL; */ + /* struct Variant* value = NULL; */ + /* char variant_str[256]; */ + /* HASHMAP_FOREACH(cvars, key, value) */ + /* { */ + /* variant_to_str(value, variant_str, 256); */ + /* log_message("VAL :(%s) : (%s)", key, variant_str); */ + /* memset(variant_str, '\0', 256); */ + /* } */ /* hashmap_float_set(cvars, "Some_FLOAT", 99.3f); */ /* hashmap_debug_print(cvars); */ @@ -1654,7 +1650,6 @@ void game_cleanup(void) { editor_cleanup(); scene_cleanup(); - config_vars_cleanup(); entity_cleanup(); model_cleanup(); material_cleanup(); diff --git a/src/hashmap.c b/src/hashmap.c index b1f71a5..2f904c3 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -7,8 +7,6 @@ #include #include -#define HASH_MAX_KEY_LEN 128 - struct Hashmap_Entry { char* key; @@ -94,14 +92,16 @@ void hashmap_value_set(struct Hashmap* hashmap, const char* key, const struct Va variant_copy(&new_entry->value, value); } -const struct Variant* hashmap_value_get(const struct Hashmap* hashmap, const char* key) +struct Variant* hashmap_value_get(const struct Hashmap* hashmap, const char* key) { if(!hashmap || !key) return NULL; struct Variant* value = NULL; - unsigned int index = hashmap_generate_hash(key); + unsigned int index = hashmap_generate_hash(key); + int key_len = strlen(key); + int compare_len = key_len < HASH_MAX_KEY_LEN ? key_len : HASH_MAX_KEY_LEN; for(int i = 0; i < array_len(hashmap->buckets[index]); i++) { - if(strncmp(key, hashmap->buckets[index][i].key, HASH_MAX_KEY_LEN) == 0) + if(strncmp(key, hashmap->buckets[index][i].key, compare_len) == 0) { value = &hashmap->buckets[index][i].value; break; @@ -175,6 +175,30 @@ void hashmap_quat_set(struct Hashmap* hashmap, const char* key, const quat* valu variant_assign_quat(&new_entry->value, value); } +void hashmap_vec2_setf(struct Hashmap* hashmap, const char* key, const float x, const float y) +{ + struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); + variant_assign_vec2f(&new_entry->value, x, y); +} + +void hashmap_vec3_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z) +{ + struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); + variant_assign_vec3f(&new_entry->value, x, y, z); +} + +void hashmap_vec4_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z, const float w) +{ + struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); + variant_assign_vec4f(&new_entry->value, x, y, z, w); +} + +void hashmap_quat_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z, const float w) +{ + struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); + variant_assign_quatf(&new_entry->value, x, y, z, w); +} + void hashmap_mat4_set(struct Hashmap* hashmap, const char* key, const mat4* value) { struct Hashmap_Entry* new_entry = hashmap_entry_new(hashmap, key); @@ -211,7 +235,7 @@ double hashmap_double_get(const struct Hashmap* hashmap, const char* key) return variant->val_double; } -int hashmap_get_bool(const struct Hashmap* hashmap, const char* key) +int hashmap_bool_get(const struct Hashmap* hashmap, const char* key) { const struct Variant* variant = hashmap_value_get(hashmap, key); return variant->val_bool; diff --git a/src/hashmap.h b/src/hashmap.h index c61ff50..891680b 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -5,6 +5,7 @@ #include "array.h" #define HASH_MAP_NUM_BUCKETS 10 +#define HASH_MAX_KEY_LEN 128 struct Hashmap; struct Variant; @@ -13,7 +14,7 @@ struct Hashmap* hashmap_new(void); void hashmap_free(struct Hashmap* hashmap); void hashmap_value_remove(struct Hashmap* hashmap, const char* key); void hashmap_value_set(struct Hashmap* hashmap, const char* key, const struct Variant* value); -const struct Variant* hashmap_value_get(const struct Hashmap* hashmap, const char* key); +struct Variant* hashmap_value_get(const struct Hashmap* hashmap, const char* key); void hashmap_float_set(struct Hashmap* hashmap, const char* key, const float value); void hashmap_int_set(struct Hashmap* hashmap, const char* key, const int value); @@ -23,6 +24,10 @@ void hashmap_vec2_set(struct Hashmap* hashmap, const char* key, const void hashmap_vec3_set(struct Hashmap* hashmap, const char* key, const vec3* value); void hashmap_vec4_set(struct Hashmap* hashmap, const char* key, const vec4* value); void hashmap_quat_set(struct Hashmap* hashmap, const char* key, const quat* value); +void hashmap_vec2_setf(struct Hashmap* hashmap, const char* key, const float x, const float y); +void hashmap_vec3_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z); +void hashmap_vec4_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z, const float w); +void hashmap_quat_setf(struct Hashmap* hashmap, const char* key, const float x, const float y, const float z, const float w); void hashmap_mat4_set(struct Hashmap* hashmap, const char* key, const mat4* value); void hashmap_str_set(struct Hashmap* hashmap, const char* key, const char* value); void hashmap_ptr_set(struct Hashmap* hashmap, const char* key, void* value); @@ -30,7 +35,7 @@ void hashmap_ptr_set(struct Hashmap* hashmap, const char* key, void* float hashmap_float_get(const struct Hashmap* hashmap, const char* key); int hashmap_int_get(const struct Hashmap* hashmap, const char* key); double hashmap_double_get(const struct Hashmap* hashmap, const char* key); -int hashmap_get_bool(const struct Hashmap* hashmap, const char* key); +int hashmap_bool_get(const struct Hashmap* hashmap, const char* key); vec2 hashmap_vec2_get(const struct Hashmap* hashmap, const char* key); vec3 hashmap_vec3_get(const struct Hashmap* hashmap, const char* key); vec4 hashmap_vec4_get(const struct Hashmap* hashmap, const char* key); diff --git a/src/input.c b/src/input.c index e96b840..94a33ea 100644 --- a/src/input.c +++ b/src/input.c @@ -72,7 +72,6 @@ void input_on_key(int key, int scancode, int state, int repeat, int mod_ctrl, in { if(repeat) { - log_message("Repeat ignored"); return; /* Ignore key repeat */ } diff --git a/src/main.c b/src/main.c index 57a6b63..5499348 100644 --- a/src/main.c +++ b/src/main.c @@ -5,10 +5,10 @@ #include "platform.h" #include "gl_load.h" #include "game.h" +#include "file_io.h" +#include "config_vars.h" +#include "hashmap.h" - -const int WIN_WIDTH = 1024; -const int WIN_HEIGHT = 768; static struct Window* window = NULL; int init(); @@ -34,8 +34,9 @@ int init(void) } else { + config_vars_init(); if(platform_init()) - { + { success = gl_load_library(); if(!success) { @@ -43,7 +44,18 @@ int init(void) } else { - window = window_create("Symmetry", WIN_WIDTH, WIN_HEIGHT); + char* base_path = platform_base_path_get(); + io_file_init(base_path); + free(base_path); + if(!config_vars_load("config.cfg")) + log_error("main:init", "Could not load config, reverting to defaults"); + + struct Hashmap* cvars = config_vars_get(); + int width = hashmap_int_get(cvars, "render_width"); + int height = hashmap_int_get(cvars, "render_height"); + int msaa = hashmap_bool_get(cvars, "msaa_enabled"); + int msaa_levels = hashmap_int_get(cvars, "msaa_levels"); + window = window_create("Symmetry", width, height, msaa, msaa_levels); if(!window) { log_error("main:init", "Window creation failed"); @@ -68,5 +80,6 @@ void cleanup() { game_cleanup(); platform_cleanup(); + config_vars_cleanup(); log_message("Program exiting!"); } diff --git a/src/platform.c b/src/platform.c index ce2b2d2..ab16463 100644 --- a/src/platform.c +++ b/src/platform.c @@ -1,11 +1,11 @@ #include "platform.h" #include "log.h" #include "input.h" +#include "config_vars.h" +#include "hashmap.h" #include "string_utils.h" #include -//#define GL_DEBUG_CONTEXT - struct Window { void* sdl_window; @@ -26,7 +26,7 @@ struct Platform_State /* TODO: Find a better way to handle internal state */ static struct Platform_State* platform_state = NULL; -struct Window* window_create(const char* title, int width, int height) +struct Window* window_create(const char* title, int width, int height, int msaa, int msaa_levels) { struct Window* new_window = NULL; if(!new_window) @@ -47,8 +47,11 @@ struct Window* window_create(const char* title, int width, int height) SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); + if(msaa) + { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, msaa); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_levels); + } SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); diff --git a/src/platform.h b/src/platform.h index d3f1186..4c42186 100644 --- a/src/platform.h +++ b/src/platform.h @@ -14,7 +14,7 @@ typedef void (*Textinput_Event_Func) (const char* text); // Window Related functions struct Window; -struct Window* window_create(const char* title, int width, int height); +struct Window* window_create(const char* title, int width, int height, int msaa, int msaa_levels); void window_destroy(struct Window* window); void window_show(struct Window* window); void window_hide(struct Window* window); diff --git a/src/renderer.c b/src/renderer.c index cd1c10f..7b9511c 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -14,6 +14,8 @@ #include "transform.h" #include "game.h" #include "gui.h" +#include "config_vars.h" +#include "hashmap.h" static int def_fbo = -1; static int def_albedo_tex = -1; @@ -35,18 +37,22 @@ void renderer_init(void) glEnable(GL_CULL_FACE); glCullFace(GL_BACK); platform_windowresize_callback_set(on_framebuffer_size_change); - - settings.fog.mode = FM_EXPONENTIAL; - settings.fog.density = 0.01f; - settings.fog.start_dist = 50.f; - settings.fog.max_dist = 150.f; - settings.debug_draw_enabled = 1; - settings.debug_draw_mode = GDM_TRIANGLES; + + struct Hashmap* cvars = config_vars_get(); + settings.fog.mode = hashmap_int_get(cvars, "fog_mode"); + settings.fog.density = hashmap_float_get(cvars, "fog_density"); + settings.fog.start_dist = hashmap_float_get(cvars, "fog_start_dist"); + settings.fog.max_dist = hashmap_float_get(cvars, "fog_max_dist"); + settings.fog.color = hashmap_vec3_get(cvars, "fog_color"); + settings.debug_draw_enabled = hashmap_bool_get(cvars, "debug_draw_enabled"); + settings.debug_draw_mode = hashmap_int_get(cvars, "debug_draw_mode"); + settings.debug_draw_color = hashmap_vec4_get(cvars, "debug_draw_color"); + settings.ambient_light = hashmap_vec3_get(cvars, "ambient_light"); settings.max_gui_vertex_memory = MAX_GUI_VERTEX_MEMORY; settings.max_gui_element_memory = MAX_GUI_ELEMENT_MEMORY; - vec3_fill(&settings.fog.color, 60.f/255.f, 60.f/255.f, 75.f/255.f); - vec3_fill(&settings.ambient_light, 0.1f, 0.1f, 0.12f); - vec4_fill(&settings.debug_draw_color, 0.f, 1.f, 0.f, 1.f); + /* vec3_fill(&settings.fog.color, 60.f/255.f, 60.f/255.f, 75.f/255.f); */ + /* vec3_fill(&settings.ambient_light, 0.1f, 0.1f, 0.12f); */ + /* vec4_fill(&settings.debug_draw_color, 0.f, 1.f, 0.f, 1.f); */ gui_init(); diff --git a/src/variant.c b/src/variant.c index 1e361ea..503d764 100644 --- a/src/variant.c +++ b/src/variant.c @@ -78,6 +78,34 @@ void variant_assign_quat(struct Variant* variant, const quat* value) quat_assign(&variant->val_quat, value); } +void variant_assign_vec2f(struct Variant* variant, const float x, const float y) +{ + if(variant->type != VT_VEC2) variant_free(variant); + variant->type = VT_VEC2; + vec2_fill(&variant->val_vec2, x, y); +} + +void variant_assign_vec3f(struct Variant* variant, const float x, const float y, const float z) +{ + if(variant->type != VT_VEC3) variant_free(variant); + variant->type = VT_VEC3; + vec3_fill(&variant->val_vec3, x, y, z); +} + +void variant_assign_vec4f(struct Variant* variant, const float x, const float y, const float z, const float w) +{ + if(variant->type != VT_VEC4) variant_free(variant); + variant->type = VT_VEC4; + vec4_fill(&variant->val_vec4, x, y, z, w); +} + +void variant_assign_quatf(struct Variant* variant, const float x, const float y, const float z, const float w) +{ + if(variant->type != VT_QUAT) variant_free(variant); + variant->type = VT_QUAT; + quat_fill(&variant->val_quat, x, y, z, w); +} + void variant_assign_mat4(struct Variant* variant, const mat4* source) { if(variant->type != VT_MAT4) variant_free(variant); diff --git a/src/variant.h b/src/variant.h index 6f65eb2..add665e 100644 --- a/src/variant.h +++ b/src/variant.h @@ -51,6 +51,10 @@ void variant_assign_vec2(struct Variant* variant, const vec2* value); void variant_assign_vec3(struct Variant* variant, const vec3* value); void variant_assign_vec4(struct Variant* variant, const vec4* value); void variant_assign_quat(struct Variant* variant, const quat* value); +void variant_assign_vec2f(struct Variant* variant, const float x, const float y); +void variant_assign_vec3f(struct Variant* variant, const float x, const float y, const float z); +void variant_assign_vec4f(struct Variant* variant, const float x, const float y, const float z, const float w); +void variant_assign_quatf(struct Variant* variant, const float x, const float y, const float z, const float w); void variant_assign_mat4(struct Variant* variant, const mat4* source); void variant_assign_ptr(struct Variant* variant, void* source); void variant_copy(struct Variant* to, const struct Variant* from);