*.d
*.swp
vrtris
+gltris
*.exe
*.dll
data/
+# options -------------------------------------------------
+vrbuild = true
+# ---------------------------------------------------------
+
src = $(wildcard src/*.c)
obj = $(src:.c=.o)
dep = $(obj:.o=.d)
-bin = vrtris
+ifeq ($(vrbuild), true)
+ bin = vrtris
+ vr_ldflags = -lgoatvr
+ vr_cflags = -DBUILD_VR
+else
+ bin = gltris
+endif
warn = -pedantic -Wall -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
dbg = -g
opt = -O0
-CFLAGS = $(warn) $(dbg) $(opt) `pkg-config --cflags sdl2 freetype2`
+CFLAGS = $(warn) $(dbg) $(opt) `pkg-config --cflags sdl2 freetype2` $(vr_cflags)
LDFLAGS = $(libsys) -ldrawtext $(libgl) `pkg-config --libs sdl2 freetype2` \
- -lgoatvr -limago -lpng -lz -ljpeg -lpthread -lm
+ $(vr_ldflags) -limago -lpng -lz -ljpeg -lpthread -lm
sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
#include <assert.h>
+#ifdef BUILD_VR
#include <goatvr.h>
+#endif
#include <cgmath/cgmath.h>
#include "opengl.h"
#include "game.h"
static void calc_framerate(void);
static void print_framerate(void);
+#ifdef BUILD_VR
static int should_swap;
+#endif
static unsigned long framerate;
return -1;
}
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
if(goatvr_init() == -1) {
return -1;
goatvr_startvr();
should_swap = goatvr_should_swap();
}
+#endif /* BUILD_VR */
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
void game_cleanup()
{
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
goatvr_shutdown();
}
+#endif
cleanup_screens();
}
void game_display(void)
{
static long prev_msec;
- int i;
float dt = (float)(time_msec - prev_msec) / 1000.0f;
prev_msec = time_msec;
update(dt);
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
+ int i;
goatvr_draw_start();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
game_swap_buffers();
}
- } else {
+ } else
+#endif /* BUILD_VR */
+ {
/* non-VR mode */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
void game_reshape(int x, int y)
{
glViewport(0, 0, x, y);
+#ifdef BUILD_VR
goatvr_set_fb_size(x, y, 1.0f);
+#endif
reshape_screens(x, y);
}
break;
case KEY_HOME:
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
goatvr_recenter();
}
+#endif
break;
default:
#include <time.h>
#include <assert.h>
#include <imago2.h>
+#ifdef BUILD_VR
#include <goatvr.h>
+#endif
#include "opengl.h"
#include "game.h"
#include "screen.h"
static void update_input(float dtsec)
{
+#ifdef BUILD_VR
int num_vr_sticks;
if((num_vr_sticks = goatvr_num_sticks()) > 0) {
joy_axis[GPAD_LSTICK_Y] = p[1];
}
}
+#endif /* BUILD_VR */
ginp_bnstate = 0;
enum {
OPTCFG_SIZE,
+#ifdef BUILD_VR
OPTCFG_VR,
+#endif
OPTCFG_FULLSCREEN,
OPTCFG_WINDOWED,
OPTCFG_SCREEN,
static struct optcfg_option options[] = {
// short, long, id, desc
{'s', "size", OPTCFG_SIZE, "window size (WxH)"},
+#ifdef BUILD_VR
{0, "vr", OPTCFG_VR, "enable VR mode"},
+#endif
{'f', "fullscreen", OPTCFG_FULLSCREEN, "run in fullscreen mode"},
{'w', "windowed", OPTCFG_WINDOWED, "run in windowed mode"},
{0, "screen", OPTCFG_SCREEN, "select starting screen"},
}
break;
+#ifdef BUILD_VR
case OPTCFG_VR:
if(is_enabled(oc)) {
opt.flags |= OPT_VR;
opt.flags &= ~OPT_VR;
}
break;
+#endif
case OPTCFG_FULLSCREEN:
if(is_enabled(oc)) {