projects
/
laserbrain_demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mirror planes detection needs work
[laserbrain_demo]
/
src
/
app.cc
diff --git
a/src/app.cc
b/src/app.cc
index
b61b0e7
..
30222f9
100644
(file)
--- a/
src/app.cc
+++ b/
src/app.cc
@@
-33,6
+33,7
@@
static Ray calc_pick_ray(int x, int y);
long time_msec;
int win_width, win_height;
long time_msec;
int win_width, win_height;
+int vp_width, vp_height;
float win_aspect;
bool fb_srgb;
bool opt_gear_wireframe;
float win_aspect;
bool fb_srgb;
bool opt_gear_wireframe;
@@
-166,11
+167,8
@@
bool app_init(int argc, char **argv)
avatar.body_rot = rad_to_deg(acos(dot(dir, Vec3(0, 0, 1))));
exman = new ExhibitManager;
avatar.body_rot = rad_to_deg(acos(dot(dir, Vec3(0, 0, 1))));
exman = new ExhibitManager;
- /*
- if(!exman->load(mscn, "data/exhibits")) {
- //return false;
- }
- */
+ // exhibits are loaded in post_scene_init, because they need access to the scene graph
+
if(!exui_init()) {
error_log("failed to initialize exhibit ui system\n");
return false;
if(!exui_init()) {
error_log("failed to initialize exhibit ui system\n");
return false;
@@
-194,6
+192,9
@@
bool app_init(int argc, char **argv)
}
rend = new Renderer;
}
rend = new Renderer;
+ if(!rend->init()) {
+ return false;
+ }
rend->set_scene(mscn);
glUseProgram(0);
rend->set_scene(mscn);
glUseProgram(0);
@@
-208,8
+209,11
@@
bool app_init(int argc, char **argv)
return true;
}
return true;
}
+// post_scene_init is called after the scene has completed loading
static void post_scene_init()
{
static void post_scene_init()
{
+ mscn->update(0); // update once to calculate node matrices
+
int num_mir = mscn->calc_mirror_planes();
info_log("found %d mirror planes\n", num_mir);
int num_mir = mscn->calc_mirror_planes();
info_log("found %d mirror planes\n", num_mir);
@@
-429,6
+433,8
@@
void app_display()
for(int i=0; i<2; i++) {
// for each eye
goatvr_draw_eye(i);
for(int i=0; i<2; i++) {
// for each eye
goatvr_draw_eye(i);
+ vp_width = goatvr_get_fb_eye_width(i);
+ vp_height = goatvr_get_fb_eye_height(i);
proj_matrix = goatvr_projection_matrix(i, NEAR_CLIP, FAR_CLIP);
glMatrixMode(GL_PROJECTION);
proj_matrix = goatvr_projection_matrix(i, NEAR_CLIP, FAR_CLIP);
glMatrixMode(GL_PROJECTION);
@@
-449,6
+455,9
@@
void app_display()
}
goatvr_draw_done();
}
goatvr_draw_done();
+ vp_width = win_width;
+ vp_height = win_height;
+
if(should_swap) {
app_swap_buffers();
}
if(should_swap) {
app_swap_buffers();
}
@@
-555,6
+564,9
@@
void app_reshape(int x, int y)
glViewport(0, 0, x, y);
goatvr_set_fb_size(x, y, 1.0f);
debug_gui_reshape(x, y);
glViewport(0, 0, x, y);
goatvr_set_fb_size(x, y, 1.0f);
debug_gui_reshape(x, y);
+
+ vp_width = x;
+ vp_height = y;
}
void app_keyboard(int key, bool pressed)
}
void app_keyboard(int key, bool pressed)