From e09f58ce22aa16e6fc68347b70c2be6a864f25b3 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 1 Mar 2019 13:51:29 +0200 Subject: [PATCH] fixed crash when passing the -screen argument, due to trying to free the static string in def_opt --- src/game.c | 2 +- src/game.h | 2 ++ src/gamescr.c | 4 ++++ src/opt.c | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index d4a7fe3..a729996 100644 --- a/src/game.c +++ b/src/game.c @@ -12,7 +12,7 @@ static void calc_framerate(void); static void print_framerate(void); -static float view_matrix[16], proj_matrix[16]; +float view_matrix[16], proj_matrix[16]; static int should_swap; static unsigned long framerate; diff --git a/src/game.h b/src/game.h index 0bcd229..3ada420 100644 --- a/src/game.h +++ b/src/game.h @@ -7,6 +7,8 @@ int vp_width, vp_height; /* viewport size differs from win size during VR eye re float win_aspect; int fb_srgb; +float view_matrix[16], proj_matrix[16]; + enum { MOD_SHIFT = 1, MOD_ALT = 2, diff --git a/src/gamescr.c b/src/gamescr.c index 52db999..0bd7f70 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -1,3 +1,4 @@ +#include "opengl.h" #include "screen.h" #include "cmesh.h" @@ -63,6 +64,9 @@ static void update(float dt) static void draw(void) { + glTranslatef(0, 0, 6); + + cmesh_draw(blkmesh); } static void reshape(int x, int y) diff --git a/src/opt.c b/src/opt.c index 33d7dfb..acce25f 100644 --- a/src/opt.c +++ b/src/opt.c @@ -38,6 +38,11 @@ int init_options(int argc, char **argv, const char *cfgfile) /* default options */ opt = def_opt; + if(!(opt.start_scr = malloc(strlen(def_opt.start_scr) + 1))) { + perror("failed to allocate memory"); + return -1; + } + strcpy(opt.start_scr, def_opt.start_scr); argv0 = argv[0]; -- 1.7.10.4