projects
/
vrtris
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build-time config option for VR mode
[vrtris]
/
src
/
game.c
diff --git
a/src/game.c
b/src/game.c
index
68f6a23
..
eba4a23
100644
(file)
--- a/
src/game.c
+++ b/
src/game.c
@@
-1,5
+1,7
@@
#include <assert.h>
#include <assert.h>
+#ifdef BUILD_VR
#include <goatvr.h>
#include <goatvr.h>
+#endif
#include <cgmath/cgmath.h>
#include "opengl.h"
#include "game.h"
#include <cgmath/cgmath.h>
#include "opengl.h"
#include "game.h"
@@
-12,7
+14,9
@@
static void calc_framerate(void);
static void print_framerate(void);
static void calc_framerate(void);
static void print_framerate(void);
+#ifdef BUILD_VR
static int should_swap;
static int should_swap;
+#endif
static unsigned long framerate;
static unsigned long framerate;
@@
-30,6
+34,7
@@
int game_init(int argc, char **argv)
return -1;
}
return -1;
}
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
if(goatvr_init() == -1) {
return -1;
if(opt.flags & OPT_VR) {
if(goatvr_init() == -1) {
return -1;
@@
-40,6
+45,7
@@
int game_init(int argc, char **argv)
goatvr_startvr();
should_swap = goatvr_should_swap();
}
goatvr_startvr();
should_swap = goatvr_should_swap();
}
+#endif /* BUILD_VR */
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
@@
-51,9
+57,11
@@
int game_init(int argc, char **argv)
void game_cleanup()
{
void game_cleanup()
{
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
goatvr_shutdown();
}
if(opt.flags & OPT_VR) {
goatvr_shutdown();
}
+#endif
cleanup_screens();
}
cleanup_screens();
}
@@
-65,13
+73,14
@@
static void update(float dt)
void game_display(void)
{
static long prev_msec;
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);
float dt = (float)(time_msec - prev_msec) / 1000.0f;
prev_msec = time_msec;
update(dt);
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
if(opt.flags & OPT_VR) {
+ int i;
goatvr_draw_start();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
goatvr_draw_start();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@
-98,7
+107,9
@@
void game_display(void)
game_swap_buffers();
}
game_swap_buffers();
}
- } else {
+ } else
+#endif /* BUILD_VR */
+ {
/* non-VR mode */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* non-VR mode */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@
-125,7
+136,9
@@
void game_display(void)
void game_reshape(int x, int y)
{
glViewport(0, 0, x, y);
void game_reshape(int x, int y)
{
glViewport(0, 0, x, y);
+#ifdef BUILD_VR
goatvr_set_fb_size(x, y, 1.0f);
goatvr_set_fb_size(x, y, 1.0f);
+#endif
reshape_screens(x, y);
}
reshape_screens(x, y);
}
@@
-149,9
+162,11
@@
void game_keyboard(int key, int pressed)
break;
case KEY_HOME:
break;
case KEY_HOME:
+#ifdef BUILD_VR
if(opt.flags & OPT_VR) {
goatvr_recenter();
}
if(opt.flags & OPT_VR) {
goatvr_recenter();
}
+#endif
break;
default:
break;
default: