Fixed mouse bug on windows, recompiled and added SDL2 and OpenAL for windows

dev
Shariq Shah 9 years ago
parent 145a0977ee
commit e95074a904
  1. 2
      build/linux/makefile
  2. 129
      include/SDL2/SDL_config_windows.h
  3. BIN
      libs/debug/win64_msvc/OpenAL32.lib
  4. BIN
      libs/debug/win64_msvc/OpenAL32.pdb
  5. BIN
      libs/debug/win64_msvc/SDL2.lib
  6. BIN
      libs/release/win64_msvc/OpenAL32.lib
  7. BIN
      libs/release/win64_msvc/SDL2.lib
  8. 6
      orgfile.org
  9. 11
      src/game.c
  10. 14
      src/geometry.c
  11. 2
      src/geometry.h
  12. 6
      src/gui.c
  13. 10
      src/input.h
  14. 9
      src/transform.c

@ -1,5 +1,5 @@
PROJECT_NAME = Symmetry PROJECT_NAME = Symmetry
CC = gcc CC = clang
SRC_DIR = ../../src SRC_DIR = ../../src
INCLUDE_DIR = ../../include INCLUDE_DIR = ../../include
LIB_DIR_RELEASE = ../../libs/release/linux64_gcc LIB_DIR_RELEASE = ../../libs/release/linux64_gcc

@ -24,7 +24,6 @@
/* General platform specific identifiers */ /* General platform specific identifiers */
#include "SDL_platform.h" #include "SDL_platform.h"
/* C language features */ /* C language features */
/* #undef const */ /* #undef const */
/* #undef inline */ /* #undef inline */
@ -51,26 +50,26 @@
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
/* Comment this if you want to build without any C library requirements */ /* Comment this if you want to build without any C library requirements */
/* #undef HAVE_LIBC */ #define HAVE_LIBC 1
#if HAVE_LIBC #if HAVE_LIBC
/* Useful headers */ /* Useful headers */
/* #undef HAVE_ALLOCA_H */ /* #undef HAVE_ALLOCA_H */
/* #undef HAVE_SYS_TYPES_H */ /* #undef HAVE_SYS_TYPES_H */
/* #undef HAVE_STDIO_H */ #define HAVE_STDIO_H 1
/* #undef STDC_HEADERS */ #define STDC_HEADERS 1
/* #undef HAVE_STDLIB_H */ /* #undef HAVE_STDLIB_H */
#define HAVE_STDARG_H 1 /* #undef HAVE_STDARG_H */
/* #undef HAVE_MALLOC_H */ /* #undef HAVE_MALLOC_H */
/* #undef HAVE_MEMORY_H */ /* #undef HAVE_MEMORY_H */
/* #undef HAVE_STRING_H */ #define HAVE_STRING_H 1
/* #undef HAVE_STRINGS_H */ /* #undef HAVE_STRINGS_H */
/* #undef HAVE_INTTYPES_H */ /* #undef HAVE_INTTYPES_H */
/* #undef HAVE_STDINT_H */ /* #undef HAVE_STDINT_H */
/* #undef HAVE_CTYPE_H */ #define HAVE_CTYPE_H 1
/* #undef HAVE_MATH_H */ #define HAVE_MATH_H 1
/* #undef HAVE_ICONV_H */ /* #undef HAVE_ICONV_H */
/* #undef HAVE_SIGNAL_H */ #define HAVE_SIGNAL_H 1
/* #undef HAVE_ALTIVEC_H */ /* #undef HAVE_ALTIVEC_H */
/* #undef HAVE_PTHREAD_NP_H */ /* #undef HAVE_PTHREAD_NP_H */
/* #undef HAVE_LIBUDEV_H */ /* #undef HAVE_LIBUDEV_H */
@ -79,77 +78,77 @@
/* #undef HAVE_FCITX_FRONTEND_H */ /* #undef HAVE_FCITX_FRONTEND_H */
/* C library functions */ /* C library functions */
/* #undef HAVE_MALLOC */ #define HAVE_MALLOC 1
/* #undef HAVE_CALLOC */ #define HAVE_CALLOC 1
/* #undef HAVE_REALLOC */ #define HAVE_REALLOC 1
/* #undef HAVE_FREE */ #define HAVE_FREE 1
/* #undef HAVE_ALLOCA */ #define HAVE_ALLOCA 1
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ #ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
/* #undef HAVE_GETENV */ /* #undef HAVE_GETENV */
/* #undef HAVE_SETENV */ /* #undef HAVE_SETENV */
/* #undef HAVE_PUTENV */ /* #undef HAVE_PUTENV */
/* #undef HAVE_UNSETENV */ /* #undef HAVE_UNSETENV */
#endif #endif
/* #undef HAVE_QSORT */ #define HAVE_QSORT 1
/* #undef HAVE_ABS */ #define HAVE_ABS 1
/* #undef HAVE_BCOPY */ /* #undef HAVE_BCOPY */
/* #undef HAVE_MEMSET */ #define HAVE_MEMSET 1
/* #undef HAVE_MEMCPY */ #define HAVE_MEMCPY 1
/* #undef HAVE_MEMMOVE */ #define HAVE_MEMMOVE 1
/* #undef HAVE_MEMCMP */ #define HAVE_MEMCMP 1
/* #undef HAVE_STRLEN */ #define HAVE_STRLEN 1
/* #undef HAVE_STRLCPY */ /* #undef HAVE_STRLCPY */
/* #undef HAVE_STRLCAT */ /* #undef HAVE_STRLCAT */
/* #undef HAVE_STRDUP */ /* #undef HAVE_STRDUP */
/* #undef HAVE__STRREV */ #define HAVE__STRREV 1
/* #undef HAVE__STRUPR */ #define HAVE__STRUPR 1
/* #undef HAVE__STRLWR */ #define HAVE__STRLWR 1
/* #undef HAVE_INDEX */ /* #undef HAVE_INDEX */
/* #undef HAVE_RINDEX */ /* #undef HAVE_RINDEX */
/* #undef HAVE_STRCHR */ #define HAVE_STRCHR 1
/* #undef HAVE_STRRCHR */ #define HAVE_STRRCHR 1
/* #undef HAVE_STRSTR */ #define HAVE_STRSTR 1
/* #undef HAVE_ITOA */ #define HAVE_ITOA 1
/* #undef HAVE__LTOA */ #define HAVE__LTOA 1
/* #undef HAVE__UITOA */ /* #undef HAVE__UITOA */
/* #undef HAVE__ULTOA */ #define HAVE__ULTOA 1
/* #undef HAVE_STRTOL */ #define HAVE_STRTOL 1
/* #undef HAVE_STRTOUL */ #define HAVE_STRTOUL 1
/* #undef HAVE__I64TOA */ /* #undef HAVE__I64TOA */
/* #undef HAVE__UI64TOA */ /* #undef HAVE__UI64TOA */
/* #undef HAVE_STRTOLL */ #define HAVE_STRTOLL 1
/* #undef HAVE_STRTOULL */ /* #undef HAVE_STRTOULL */
/* #undef HAVE_STRTOD */ #define HAVE_STRTOD 1
/* #undef HAVE_ATOI */ #define HAVE_ATOI 1
/* #undef HAVE_ATOF */ #define HAVE_ATOF 1
/* #undef HAVE_STRCMP */ #define HAVE_STRCMP 1
/* #undef HAVE_STRNCMP */ #define HAVE_STRNCMP 1
/* #undef HAVE__STRICMP */ #define HAVE__STRICMP 1
/* #undef HAVE_STRCASECMP */ /* #undef HAVE_STRCASECMP */
/* #undef HAVE__STRNICMP */ #define HAVE__STRNICMP 1
/* #undef HAVE_STRNCASECMP */ /* #undef HAVE_STRNCASECMP */
/* #undef HAVE_VSSCANF */ /* #undef HAVE_VSSCANF */
/* #undef HAVE_VSNPRINTF */ /* #undef HAVE_VSNPRINTF */
/* #undef HAVE_M_PI */ #define HAVE_M_PI 1
/* #undef HAVE_ATAN */ #define HAVE_ATAN 1
/* #undef HAVE_ATAN2 */ #define HAVE_ATAN2 1
/* #undef HAVE_ACOS */ #define HAVE_ACOS 1
/* #undef HAVE_ASIN */ #define HAVE_ASIN 1
/* #undef HAVE_CEIL */ #define HAVE_CEIL 1
/* #undef HAVE_COPYSIGN */ #define HAVE_COPYSIGN 1
/* #undef HAVE_COS */ #define HAVE_COS 1
/* #undef HAVE_COSF */ #define HAVE_COSF 1
/* #undef HAVE_FABS */ #define HAVE_FABS 1
/* #undef HAVE_FLOOR */ #define HAVE_FLOOR 1
/* #undef HAVE_LOG */ #define HAVE_LOG 1
/* #undef HAVE_POW */ #define HAVE_POW 1
/* #undef HAVE_SCALBN */ #define HAVE_SCALBN 1
/* #undef HAVE_SIN */ #define HAVE_SIN 1
/* #undef HAVE_SINF */ #define HAVE_SINF 1
/* #undef HAVE_SQRT */ #define HAVE_SQRT 1
/* #undef HAVE_SQRTF */ #define HAVE_SQRTF 1
/* #undef HAVE_TAN */ #define HAVE_TAN 1
/* #undef HAVE_TANF */ #define HAVE_TANF 1
/* #undef HAVE_FSEEKO */ /* #undef HAVE_FSEEKO */
/* #undef HAVE_FSEEKO64 */ /* #undef HAVE_FSEEKO64 */
/* #undef HAVE_SIGACTION */ /* #undef HAVE_SIGACTION */
@ -166,8 +165,8 @@
/* #undef HAVE_PTHREAD_SET_NAME_NP */ /* #undef HAVE_PTHREAD_SET_NAME_NP */
/* #undef HAVE_SEM_TIMEDWAIT */ /* #undef HAVE_SEM_TIMEDWAIT */
#elif __WIN32__ #elif __WIN32__
#define HAVE_STDARG_H 1 /* #undef HAVE_STDARG_H */
#define HAVE_STDDEF_H 1 /* #undef HAVE_STDDEF_H */
#else #else
/* We may need some replacement for stdarg.h here */ /* We may need some replacement for stdarg.h here */
#include <stdarg.h> #include <stdarg.h>
@ -314,18 +313,18 @@
/* #undef SDL_VIDEO_RENDER_D3D11 */ /* #undef SDL_VIDEO_RENDER_D3D11 */
#define SDL_VIDEO_RENDER_OGL 1 #define SDL_VIDEO_RENDER_OGL 1
/* #undef SDL_VIDEO_RENDER_OGL_ES */ /* #undef SDL_VIDEO_RENDER_OGL_ES */
#define SDL_VIDEO_RENDER_OGL_ES2 1 /* #undef SDL_VIDEO_RENDER_OGL_ES2 */
/* #undef SDL_VIDEO_RENDER_DIRECTFB */ /* #undef SDL_VIDEO_RENDER_DIRECTFB */
/* Enable OpenGL support */ /* Enable OpenGL support */
#define SDL_VIDEO_OPENGL 1 #define SDL_VIDEO_OPENGL 1
/* #undef SDL_VIDEO_OPENGL_ES */ /* #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_BGL */
/* #undef SDL_VIDEO_OPENGL_CGL */ /* #undef SDL_VIDEO_OPENGL_CGL */
/* #undef SDL_VIDEO_OPENGL_GLX */ /* #undef SDL_VIDEO_OPENGL_GLX */
#define SDL_VIDEO_OPENGL_WGL 1 #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 */
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ /* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */

Binary file not shown.

Binary file not shown.

@ -92,7 +92,8 @@ All the code in this repository is under GPLv3, see LICENSE for more information
** CANCELED Deferred rendering? ** CANCELED Deferred rendering?
- State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\ - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\
Sticking with forward rendering for now and focusing on tools etc. 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 ** TODO Configuration/Settings load/save handling
** DONE Fix mousewheel bugs and gui not responding to mousewheel input ** DONE Fix mousewheel bugs and gui not responding to mousewheel input
- State "DONE" from "TODO" [2017-03-19 Sun 01:31] - 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 - Decoupled event handling of gui and input if possible
- Custom rendering for gui - Custom rendering for gui
** TODO Allow passsing base path as commandline argument? ** TODO Allow passsing base path as commandline argument?
** TODO Fix Key release not being reported
** TODO Better handling incase assets folder is not found? ** 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] - State "DONE" from "TODO" [2017-03-25 Sat 02:06]
** DONE 3d sound using OpenAL ** DONE 3d sound using OpenAL
- State "DONE" from "TODO" [2017-03-23 Thu 01:43] - State "DONE" from "TODO" [2017-03-23 Thu 01:43]

@ -87,6 +87,7 @@ void scene_setup(void)
int turn_up_keys[1] = {KEY_I}; int turn_up_keys[1] = {KEY_I};
int turn_down_keys[1] = {KEY_K}; int turn_down_keys[1] = {KEY_K};
int sprint_keys[2] = {KEY_LSHIFT, KEY_RSHIFT}; 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_Forward", forward_keys, 2);
input_map_create("Move_Backward", backward_keys, 2); input_map_create("Move_Backward", backward_keys, 2);
input_map_create("Move_Up", up_keys, 1); 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_Up", turn_up_keys, 1);
input_map_create("Turn_Down", turn_down_keys, 1); input_map_create("Turn_Down", turn_down_keys, 1);
input_map_create("Sprint", sprint_keys, 2); input_map_create("Sprint", sprint_keys, 2);
input_map_create("Recompute", recompute_keys, 2);
struct Entity* player = scene_add_new("player", "None"); struct Entity* player = scene_add_new("player", "None");
game_state->player_node = player->node; 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_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("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)) */
/* 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_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); if(input_mouse_mode_get() != MM_RELATIVE) input_mouse_mode_set(MM_RELATIVE);
const double scale = 0.25; const double scale = 0.25;
@ -1574,7 +1581,7 @@ void debug_gui(float dt)
} }
} }
nk_end(ctx); nk_end(ctx);
return !nk_window_is_closed(ctx, "Overview"); //return !nk_window_is_closed(ctx, "Overview");
} }

@ -44,7 +44,6 @@ static GLenum* draw_modes;
static int load_from_file(struct Geometry* geometry, const char* filename); static int load_from_file(struct Geometry* geometry, const char* filename);
static void create_vao(struct Geometry* geometry); static void create_vao(struct Geometry* geometry);
static struct Geometry* generate_new_index(int* out_new_index); static struct Geometry* generate_new_index(int* out_new_index);
static void generate_bounding_volume(int geomtry_index);
void geom_init(void) void geom_init(void)
{ {
@ -71,9 +70,9 @@ int geom_find(const char* filename)
return index; 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_Box* box = &geometry->bounding_box;
struct Bounding_Sphere* sphere = &geometry->bounding_sphere; struct Bounding_Sphere* sphere = &geometry->bounding_sphere;
@ -98,6 +97,13 @@ static void generate_bounding_volume(int geometry_index)
vec3 len_vec; vec3 len_vec;
vec3_sub(&len_vec, &box->max, &sphere->center); vec3_sub(&len_vec, &box->max, &sphere->center);
sphere->radius = fabsf(vec3_len(&len_vec)); 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) 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)) if(load_from_file(new_geo, name))
{ {
create_vao(new_geo); create_vao(new_geo);
generate_bounding_volume(index); geom_bounding_volume_generate(index);
} }
else else
{ {

@ -20,6 +20,8 @@ int geom_find(const char* filename);
void geom_remove(int index); void geom_remove(int index);
void geom_cleanup(void); void geom_cleanup(void);
void geom_render(int index, enum Geometry_Draw_Mode); 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, int geom_render_in_frustum(int index,
vec4* frustum, vec4* frustum,
struct Transform* transform, struct Transform* transform,

@ -314,9 +314,9 @@ void gui_handle_mousebutton_event(int button, int state, int x, int y)
{ {
int down = state == KS_PRESSED; int down = state == KS_PRESSED;
struct nk_context *ctx = &gui_state->context; struct nk_context *ctx = &gui_state->context;
if(button == MB_LEFT) nk_input_button(ctx, NK_BUTTON_LEFT, x, y, down); if(button == MSB_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 == MSB_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_RIGHT) nk_input_button(ctx, NK_BUTTON_RIGHT, x, y, down);
} }
void gui_handle_mousemotion_event(int x, int y, int xrel, int yrel) void gui_handle_mousemotion_event(int x, int y, int xrel, int yrel)

@ -22,11 +22,11 @@ enum Mouse_Mode
enum Mouse_Button enum Mouse_Button
{ {
MB_LEFT = SDL_BUTTON_LEFT, MSB_LEFT = SDL_BUTTON_LEFT,
MB_MIDDLE = SDL_BUTTON_MIDDLE, MSB_MIDDLE = SDL_BUTTON_MIDDLE,
MB_RIGHT = SDL_BUTTON_RIGHT, MSB_RIGHT = SDL_BUTTON_RIGHT,
MB_X1 = SDL_BUTTON_X1, MSB_X1 = SDL_BUTTON_X1,
MB_X2 = SDL_BUTTON_X2 MSB_X2 = SDL_BUTTON_X2
}; };
enum Keyboard_Key enum Keyboard_Key

@ -11,7 +11,7 @@ static int* empty_indices;
void transform_init(void) void transform_init(void)
{ {
transform_list = array_new(struct Transform); transform_list = array_new(struct Transform);
empty_indices = array_new(int); empty_indices = array_new(int);
} }
void transform_cleanup(void) void transform_cleanup(void)
@ -57,7 +57,7 @@ void transform_translate(struct Transform* transform, vec3* amount, enum Transfo
} }
else if(space == TS_PARENT) 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); struct Transform* parent_tran = entity_component_get(parent, C_TRANSFORM);
quat_mul_vec3(&translation_amount, &parent_tran->rotation, &translation_amount); quat_mul_vec3(&translation_amount, &parent_tran->rotation, &translation_amount);
} }
@ -169,9 +169,10 @@ void transform_update_transmat(struct Transform* transform)
} }
/* Update all children */ /* 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 Entity* child = entity_get(entity->children[i]);
struct Transform* child_tran = entity_component_get(child, C_TRANSFORM); struct Transform* child_tran = entity_component_get(child, C_TRANSFORM);

Loading…
Cancel
Save