diff --git a/build/linux/makefile b/build/linux/makefile index 7d32822..0550636 100644 --- a/build/linux/makefile +++ b/build/linux/makefile @@ -1,5 +1,5 @@ PROJECT_NAME = Symmetry -CC = gcc +CC = clang SRC_DIR = ../../src INCLUDE_DIR = ../../include LIB_DIR_RELEASE = ../../libs/release/linux64_gcc diff --git a/include/SDL2/SDL_config_windows.h b/include/SDL2/SDL_config_windows.h index a4479cc..43c9735 100644 --- a/include/SDL2/SDL_config_windows.h +++ b/include/SDL2/SDL_config_windows.h @@ -24,7 +24,6 @@ /* General platform specific identifiers */ #include "SDL_platform.h" - /* C language features */ /* #undef const */ /* #undef inline */ @@ -51,26 +50,26 @@ #define HAVE_DXGI_H 1 /* Comment this if you want to build without any C library requirements */ -/* #undef HAVE_LIBC */ +#define HAVE_LIBC 1 #if HAVE_LIBC /* Useful headers */ /* #undef HAVE_ALLOCA_H */ /* #undef HAVE_SYS_TYPES_H */ -/* #undef HAVE_STDIO_H */ -/* #undef STDC_HEADERS */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 /* #undef HAVE_STDLIB_H */ -#define HAVE_STDARG_H 1 +/* #undef HAVE_STDARG_H */ /* #undef HAVE_MALLOC_H */ /* #undef HAVE_MEMORY_H */ -/* #undef HAVE_STRING_H */ +#define HAVE_STRING_H 1 /* #undef HAVE_STRINGS_H */ /* #undef HAVE_INTTYPES_H */ /* #undef HAVE_STDINT_H */ -/* #undef HAVE_CTYPE_H */ -/* #undef HAVE_MATH_H */ +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 /* #undef HAVE_ICONV_H */ -/* #undef HAVE_SIGNAL_H */ +#define HAVE_SIGNAL_H 1 /* #undef HAVE_ALTIVEC_H */ /* #undef HAVE_PTHREAD_NP_H */ /* #undef HAVE_LIBUDEV_H */ @@ -79,77 +78,77 @@ /* #undef HAVE_FCITX_FRONTEND_H */ /* C library functions */ -/* #undef HAVE_MALLOC */ -/* #undef HAVE_CALLOC */ -/* #undef HAVE_REALLOC */ -/* #undef HAVE_FREE */ -/* #undef HAVE_ALLOCA */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 #ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ /* #undef HAVE_GETENV */ /* #undef HAVE_SETENV */ /* #undef HAVE_PUTENV */ /* #undef HAVE_UNSETENV */ #endif -/* #undef HAVE_QSORT */ -/* #undef HAVE_ABS */ +#define HAVE_QSORT 1 +#define HAVE_ABS 1 /* #undef HAVE_BCOPY */ -/* #undef HAVE_MEMSET */ -/* #undef HAVE_MEMCPY */ -/* #undef HAVE_MEMMOVE */ -/* #undef HAVE_MEMCMP */ -/* #undef HAVE_STRLEN */ +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 /* #undef HAVE_STRLCPY */ /* #undef HAVE_STRLCAT */ /* #undef HAVE_STRDUP */ -/* #undef HAVE__STRREV */ -/* #undef HAVE__STRUPR */ -/* #undef HAVE__STRLWR */ +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 /* #undef HAVE_INDEX */ /* #undef HAVE_RINDEX */ -/* #undef HAVE_STRCHR */ -/* #undef HAVE_STRRCHR */ -/* #undef HAVE_STRSTR */ -/* #undef HAVE_ITOA */ -/* #undef HAVE__LTOA */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 /* #undef HAVE__UITOA */ -/* #undef HAVE__ULTOA */ -/* #undef HAVE_STRTOL */ -/* #undef HAVE_STRTOUL */ +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 /* #undef HAVE__I64TOA */ /* #undef HAVE__UI64TOA */ -/* #undef HAVE_STRTOLL */ +#define HAVE_STRTOLL 1 /* #undef HAVE_STRTOULL */ -/* #undef HAVE_STRTOD */ -/* #undef HAVE_ATOI */ -/* #undef HAVE_ATOF */ -/* #undef HAVE_STRCMP */ -/* #undef HAVE_STRNCMP */ -/* #undef HAVE__STRICMP */ +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 /* #undef HAVE_STRCASECMP */ -/* #undef HAVE__STRNICMP */ +#define HAVE__STRNICMP 1 /* #undef HAVE_STRNCASECMP */ /* #undef HAVE_VSSCANF */ /* #undef HAVE_VSNPRINTF */ -/* #undef HAVE_M_PI */ -/* #undef HAVE_ATAN */ -/* #undef HAVE_ATAN2 */ -/* #undef HAVE_ACOS */ -/* #undef HAVE_ASIN */ -/* #undef HAVE_CEIL */ -/* #undef HAVE_COPYSIGN */ -/* #undef HAVE_COS */ -/* #undef HAVE_COSF */ -/* #undef HAVE_FABS */ -/* #undef HAVE_FLOOR */ -/* #undef HAVE_LOG */ -/* #undef HAVE_POW */ -/* #undef HAVE_SCALBN */ -/* #undef HAVE_SIN */ -/* #undef HAVE_SINF */ -/* #undef HAVE_SQRT */ -/* #undef HAVE_SQRTF */ -/* #undef HAVE_TAN */ -/* #undef HAVE_TANF */ +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 /* #undef HAVE_FSEEKO */ /* #undef HAVE_FSEEKO64 */ /* #undef HAVE_SIGACTION */ @@ -166,8 +165,8 @@ /* #undef HAVE_PTHREAD_SET_NAME_NP */ /* #undef HAVE_SEM_TIMEDWAIT */ #elif __WIN32__ -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 +/* #undef HAVE_STDARG_H */ +/* #undef HAVE_STDDEF_H */ #else /* We may need some replacement for stdarg.h here */ #include @@ -314,18 +313,18 @@ /* #undef SDL_VIDEO_RENDER_D3D11 */ #define SDL_VIDEO_RENDER_OGL 1 /* #undef SDL_VIDEO_RENDER_OGL_ES */ -#define SDL_VIDEO_RENDER_OGL_ES2 1 +/* #undef SDL_VIDEO_RENDER_OGL_ES2 */ /* #undef SDL_VIDEO_RENDER_DIRECTFB */ /* Enable OpenGL support */ #define SDL_VIDEO_OPENGL 1 /* #undef SDL_VIDEO_OPENGL_ES */ -#define SDL_VIDEO_OPENGL_ES2 1 +/* #undef SDL_VIDEO_OPENGL_ES2 */ /* #undef SDL_VIDEO_OPENGL_BGL */ /* #undef SDL_VIDEO_OPENGL_CGL */ /* #undef SDL_VIDEO_OPENGL_GLX */ #define SDL_VIDEO_OPENGL_WGL 1 -#define SDL_VIDEO_OPENGL_EGL 1 +/* #undef SDL_VIDEO_OPENGL_EGL */ /* #undef SDL_VIDEO_OPENGL_OSMESA */ /* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ diff --git a/libs/debug/win64_msvc/OpenAL32.lib b/libs/debug/win64_msvc/OpenAL32.lib new file mode 100644 index 0000000..3b772ef Binary files /dev/null and b/libs/debug/win64_msvc/OpenAL32.lib differ diff --git a/libs/debug/win64_msvc/OpenAL32.pdb b/libs/debug/win64_msvc/OpenAL32.pdb new file mode 100644 index 0000000..6c42070 Binary files /dev/null and b/libs/debug/win64_msvc/OpenAL32.pdb differ diff --git a/libs/debug/win64_msvc/SDL2.lib b/libs/debug/win64_msvc/SDL2.lib index 230d18a..d4ce452 100644 Binary files a/libs/debug/win64_msvc/SDL2.lib and b/libs/debug/win64_msvc/SDL2.lib differ diff --git a/libs/release/win64_msvc/OpenAL32.lib b/libs/release/win64_msvc/OpenAL32.lib new file mode 100644 index 0000000..283ac88 Binary files /dev/null and b/libs/release/win64_msvc/OpenAL32.lib differ diff --git a/libs/release/win64_msvc/SDL2.lib b/libs/release/win64_msvc/SDL2.lib index 4b7e2d3..5061eef 100644 Binary files a/libs/release/win64_msvc/SDL2.lib and b/libs/release/win64_msvc/SDL2.lib differ diff --git a/orgfile.org b/orgfile.org index 3f7d840..ce882af 100644 --- a/orgfile.org +++ b/orgfile.org @@ -92,7 +92,8 @@ All the code in this repository is under GPLv3, see LICENSE for more information ** CANCELED Deferred rendering? - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\ Sticking with forward rendering for now and focusing on tools etc. -** TODO Fix mouse bugs on windows +** DONE Fix mouse bugs on windows +- State "DONE" from "TODO" [2017-03-25 Sat 17:27] ** TODO Configuration/Settings load/save handling ** DONE Fix mousewheel bugs and gui not responding to mousewheel input - State "DONE" from "TODO" [2017-03-19 Sun 01:31] @@ -110,8 +111,9 @@ 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 Fix Key release not being reported ** TODO Better handling incase assets folder is not found? -** DONE OpenAL not working in release builds +** DONE OpenAL not working in releasebuilds - State "DONE" from "TODO" [2017-03-25 Sat 02:06] ** DONE 3d sound using OpenAL - State "DONE" from "TODO" [2017-03-23 Thu 01:43] diff --git a/src/game.c b/src/game.c index 16c58a5..d675e9b 100644 --- a/src/game.c +++ b/src/game.c @@ -87,6 +87,7 @@ void scene_setup(void) int turn_up_keys[1] = {KEY_I}; int turn_down_keys[1] = {KEY_K}; int sprint_keys[2] = {KEY_LSHIFT, KEY_RSHIFT}; + int recompute_keys[2] = {KEY_F5, KEY_H}; input_map_create("Move_Forward", forward_keys, 2); input_map_create("Move_Backward", backward_keys, 2); input_map_create("Move_Up", up_keys, 1); @@ -98,6 +99,7 @@ void scene_setup(void) input_map_create("Turn_Up", turn_up_keys, 1); input_map_create("Turn_Down", turn_down_keys, 1); input_map_create("Sprint", sprint_keys, 2); + input_map_create("Recompute", recompute_keys, 2); struct Entity* player = scene_add_new("player", "None"); game_state->player_node = player->node; @@ -228,10 +230,15 @@ void debug(float dt) if(input_map_state_get("Turn_Right", KS_PRESSED)) turn_left_right += turn_speed; if(input_map_state_get("Turn_Left", KS_PRESSED)) turn_left_right -= turn_speed; + if(input_map_state_get("Recompute", KS_PRESSED)) + { + log_message("Regenerating Bounding Volumes"); + geom_bounding_volume_generate_all(); + } /* if(input_key_state_get(KEY_TAB, KS_PRESSED)) */ /* if(input_key_state_get(KEY_TAB, KS_PRESSED) && input_key_state_get(KEY_LSHIFT, KS_PRESSED)) input_mouse_mode_set(MM_NORMAL); */ - if(input_mousebutton_state_get(MB_RIGHT, KS_PRESSED)) + if(input_mousebutton_state_get(MSB_RIGHT, KS_PRESSED)) { if(input_mouse_mode_get() != MM_RELATIVE) input_mouse_mode_set(MM_RELATIVE); const double scale = 0.25; @@ -1574,7 +1581,7 @@ void debug_gui(float dt) } } nk_end(ctx); - return !nk_window_is_closed(ctx, "Overview"); + //return !nk_window_is_closed(ctx, "Overview"); } diff --git a/src/geometry.c b/src/geometry.c index 8279f63..7840777 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -44,7 +44,6 @@ static GLenum* draw_modes; static int load_from_file(struct Geometry* geometry, const char* filename); static void create_vao(struct Geometry* geometry); static struct Geometry* generate_new_index(int* out_new_index); -static void generate_bounding_volume(int geomtry_index); void geom_init(void) { @@ -71,9 +70,9 @@ int geom_find(const char* filename) return index; } -static void generate_bounding_volume(int geometry_index) +void geom_bounding_volume_generate(int index) { - struct Geometry* geometry = &geometry_list[geometry_index]; + struct Geometry* geometry = &geometry_list[index]; struct Bounding_Box* box = &geometry->bounding_box; struct Bounding_Sphere* sphere = &geometry->bounding_sphere; @@ -98,6 +97,13 @@ static void generate_bounding_volume(int geometry_index) vec3 len_vec; vec3_sub(&len_vec, &box->max, &sphere->center); sphere->radius = fabsf(vec3_len(&len_vec)); + log_message("Radius : %.3f", sphere->radius); +} + +void geom_bounding_volume_generate_all(void) +{ + for(int i = 0; i < array_len(geometry_list); i++) + geom_bounding_volume_generate(i); } static struct Geometry* generate_new_index(int* out_new_index) @@ -134,7 +140,7 @@ int geom_create_from_file(const char* name) if(load_from_file(new_geo, name)) { create_vao(new_geo); - generate_bounding_volume(index); + geom_bounding_volume_generate(index); } else { diff --git a/src/geometry.h b/src/geometry.h index e1941e1..02ae52c 100644 --- a/src/geometry.h +++ b/src/geometry.h @@ -20,6 +20,8 @@ int geom_find(const char* filename); void geom_remove(int index); void geom_cleanup(void); void geom_render(int index, enum Geometry_Draw_Mode); +void geom_bounding_volume_generate(int index); +void geom_bounding_volume_generate_all(void); int geom_render_in_frustum(int index, vec4* frustum, struct Transform* transform, diff --git a/src/gui.c b/src/gui.c index 2385197..a4eb63a 100644 --- a/src/gui.c +++ b/src/gui.c @@ -314,9 +314,9 @@ void gui_handle_mousebutton_event(int button, int state, int x, int y) { int down = state == KS_PRESSED; struct nk_context *ctx = &gui_state->context; - if(button == MB_LEFT) nk_input_button(ctx, NK_BUTTON_LEFT, x, y, down); - if(button == MB_MIDDLE) nk_input_button(ctx, NK_BUTTON_MIDDLE, x, y, down); - if(button == MB_RIGHT) nk_input_button(ctx, NK_BUTTON_RIGHT, x, y, down); + if(button == MSB_LEFT) nk_input_button(ctx, NK_BUTTON_LEFT, x, y, down); + if(button == MSB_MIDDLE) nk_input_button(ctx, NK_BUTTON_MIDDLE, x, y, down); + if(button == MSB_RIGHT) nk_input_button(ctx, NK_BUTTON_RIGHT, x, y, down); } void gui_handle_mousemotion_event(int x, int y, int xrel, int yrel) diff --git a/src/input.h b/src/input.h index 0aed76c..cc8ddc4 100644 --- a/src/input.h +++ b/src/input.h @@ -22,11 +22,11 @@ enum Mouse_Mode enum Mouse_Button { - MB_LEFT = SDL_BUTTON_LEFT, - MB_MIDDLE = SDL_BUTTON_MIDDLE, - MB_RIGHT = SDL_BUTTON_RIGHT, - MB_X1 = SDL_BUTTON_X1, - MB_X2 = SDL_BUTTON_X2 + MSB_LEFT = SDL_BUTTON_LEFT, + MSB_MIDDLE = SDL_BUTTON_MIDDLE, + MSB_RIGHT = SDL_BUTTON_RIGHT, + MSB_X1 = SDL_BUTTON_X1, + MSB_X2 = SDL_BUTTON_X2 }; enum Keyboard_Key diff --git a/src/transform.c b/src/transform.c index 3336bce..d221dea 100644 --- a/src/transform.c +++ b/src/transform.c @@ -11,7 +11,7 @@ static int* empty_indices; void transform_init(void) { transform_list = array_new(struct Transform); - empty_indices = array_new(int); + empty_indices = array_new(int); } void transform_cleanup(void) @@ -57,7 +57,7 @@ void transform_translate(struct Transform* transform, vec3* amount, enum Transfo } else if(space == TS_PARENT) { - struct Entity* parent = entity_get_parent(transform->node); + struct Entity* parent = entity_get_parent(transform->node); struct Transform* parent_tran = entity_component_get(parent, C_TRANSFORM); quat_mul_vec3(&translation_amount, &parent_tran->rotation, &translation_amount); } @@ -169,9 +169,10 @@ void transform_update_transmat(struct Transform* transform) } /* Update all children */ - if(array_len(entity->children) > 0) + int children = array_len(entity->children); + if(children > 0) { - for(int i = 0; i < array_len(entity->children); i++) + for(int i = 0; i < children; i++) { struct Entity* child = entity_get(entity->children[i]); struct Transform* child_tran = entity_component_get(child, C_TRANSFORM);