projects
/
vrfileman
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
distance field fonts and bevel test in the font shader
[vrfileman]
/
src
/
app.cc
diff --git
a/src/app.cc
b/src/app.cc
index
c3f6b39
..
f5b9894
100644
(file)
--- a/
src/app.cc
+++ b/
src/app.cc
@@
-8,6
+8,9
@@
#include "backdrop.h"
#include "goatvr.h"
#include "opt.h"
#include "backdrop.h"
#include "goatvr.h"
#include "opt.h"
+#include "fs.h"
+
+static void draw_scene();
int win_width, win_height;
float win_aspect;
int win_width, win_height;
float win_aspect;
@@
-19,14
+22,15
@@
static bool should_swap;
static float cam_theta, cam_phi;
static float cam_height = 1.65;
static float cam_theta, cam_phi;
static float cam_height = 1.65;
-static Mesh *mesh_torus;
static bool bnstate[16];
static int prev_x, prev_y;
static bool bnstate[16];
static int prev_x, prev_y;
+static float fov = 60.0;
+
bool app_init(int argc, char **argv)
{
bool app_init(int argc, char **argv)
{
- if(!init_options(argc, argv, 0)) {
+ if(!init_options(argc, argv, "vrfileman.conf")) {
return false;
}
app_resize(opt.width, opt.height);
return false;
}
app_resize(opt.width, opt.height);
@@
-65,13
+69,14
@@
bool app_init(int argc, char **argv)
Mesh::use_custom_sdr_attr = false;
Mesh::use_custom_sdr_attr = false;
- mesh_torus = new Mesh;
- gen_torus(mesh_torus, 1.0, 0.25, 32, 32);
-
if(!init_backdrop()) {
return false;
}
if(!init_backdrop()) {
return false;
}
+ if(!init_fs(opt.path)) {
+ return false;
+ }
+
return true;
}
return true;
}
@@
-80,7
+85,6
@@
void app_cleanup()
if(opt.vr) {
goatvr_shutdown();
}
if(opt.vr) {
goatvr_shutdown();
}
- delete mesh_torus;
cleanup_backdrop();
}
cleanup_backdrop();
}
@@
-95,7
+99,7
@@
void app_draw()
goatvr_draw_eye(i);
glMatrixMode(GL_PROJECTION);
goatvr_draw_eye(i);
glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(goatvr_projection_matrix(i, 0.5, 1000.0));
+ glLoadMatrixf(goatvr_projection_matrix(i, 0.1, 200.0));
view_matrix = goatvr_view_matrix(i);
view_matrix.pre_rotate_x(deg_to_rad(cam_phi));
view_matrix = goatvr_view_matrix(i);
view_matrix.pre_rotate_x(deg_to_rad(cam_phi));
@@
-105,7
+109,7
@@
void app_draw()
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(view_matrix[0]);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(view_matrix[0]);
- draw_backdrop();
+ draw_scene();
}
goatvr_draw_done();
}
goatvr_draw_done();
@@
-118,6
+122,11
@@
void app_draw()
// regular monoscopic mode
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// regular monoscopic mode
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ Mat4 mat;
+ mat.perspective(deg_to_rad(fov), win_aspect, 0.1, 200.0);
+ glMatrixMode(GL_PROJECTION);
+ glLoadMatrixf(mat[0]);
+
view_matrix = Mat4::identity;
view_matrix.pre_rotate_x(deg_to_rad(cam_phi));
view_matrix.pre_rotate_y(deg_to_rad(cam_theta));
view_matrix = Mat4::identity;
view_matrix.pre_rotate_x(deg_to_rad(cam_phi));
view_matrix.pre_rotate_y(deg_to_rad(cam_theta));
@@
-126,7
+135,7
@@
void app_draw()
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(view_matrix[0]);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(view_matrix[0]);
- draw_backdrop();
+ draw_scene();
app_swap_buffers();
app_redraw(); // since we added animation we need to redisplay even in non-VR mode
app_swap_buffers();
app_redraw(); // since we added animation we need to redisplay even in non-VR mode
@@
-134,16
+143,16
@@
void app_draw()
assert(glGetError() == GL_NO_ERROR);
}
assert(glGetError() == GL_NO_ERROR);
}
+static void draw_scene()
+{
+ draw_backdrop();
+ draw_fs();
+}
+
void app_reshape(int x, int y)
{
glViewport(0, 0, x, y);
void app_reshape(int x, int y)
{
glViewport(0, 0, x, y);
- Mat4 mat;
- mat.perspective(deg_to_rad(50), win_aspect, 0.5, 500.0);
-
- glMatrixMode(GL_PROJECTION);
- glLoadMatrixf(mat[0]);
-
if(opt.vr) {
goatvr_set_fb_size(x, y, 1.0);
}
if(opt.vr) {
goatvr_set_fb_size(x, y, 1.0);
}
@@
-173,6
+182,16
@@
void app_keyboard(int key, bool pressed)
goatvr_recenter();
}
break;
goatvr_recenter();
}
break;
+
+ case '-':
+ fov += 1.0;
+ if(fov > 160.0) fov = 160.0;
+ break;
+
+ case '=':
+ fov -= 1.0;
+ if(fov < 0.0) fov = 0.0;
+ break;
}
}
}
}
}
}