vrfileman
diff src/app.cc @ 2:282da6123fd4
lalalala
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 01 Feb 2015 12:51:10 +0200 |
parents | dca518e371cf |
children | 2cbf85690e03 |
line diff
1.1 --- a/src/app.cc Sat Jan 31 20:01:35 2015 +0200 1.2 +++ b/src/app.cc Sun Feb 01 12:51:10 2015 +0200 1.3 @@ -1,6 +1,12 @@ 1.4 #include <assert.h> 1.5 #include "opengl.h" 1.6 #include "app.h" 1.7 +#include "user.h" 1.8 + 1.9 +static void draw_grid(int num, float sep); 1.10 + 1.11 +static User user; 1.12 +static float eye_level = 1.6; 1.13 1.14 bool app_init() 1.15 { 1.16 @@ -18,6 +24,15 @@ 1.17 { 1.18 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.19 1.20 + glMatrixMode(GL_MODELVIEW); 1.21 + glLoadIdentity(); 1.22 + 1.23 + Matrix4x4 viewmat; 1.24 + user.posrot.calc_inv_matrix(&viewmat); 1.25 + glLoadTransposeMatrixf(viewmat.m[0]); 1.26 + glTranslatef(0, -eye_level, 0); 1.27 + 1.28 + draw_grid(20, 1.0); 1.29 1.30 swap_buffers(); 1.31 assert(glGetError() == GL_NO_ERROR); 1.32 @@ -49,3 +64,41 @@ 1.33 void app_mouse_motion(int x, int y) 1.34 { 1.35 } 1.36 + 1.37 +void app_sball_motion(float x, float y, float z) 1.38 +{ 1.39 +} 1.40 + 1.41 +void app_sball_rotate(float x, float y, float z) 1.42 +{ 1.43 +} 1.44 + 1.45 +void app_sball_button(int bn, bool pressed) 1.46 +{ 1.47 +} 1.48 + 1.49 +static void draw_grid(int num, float sep) 1.50 +{ 1.51 + int hnum = num / 2; 1.52 + float max_dist = hnum * sep; 1.53 + 1.54 + glBegin(GL_LINES); 1.55 + glVertex3f(0, 0, -max_dist); 1.56 + glVertex3f(0, 0, max_dist); 1.57 + glVertex3f(-max_dist, 0, 0); 1.58 + glVertex3f(max_dist, 0, 0); 1.59 + 1.60 + for(int i=1; i<hnum; i++) { 1.61 + float x = i * sep; 1.62 + 1.63 + glVertex3f(-x, 0, -max_dist); 1.64 + glVertex3f(-x, 0, max_dist); 1.65 + glVertex3f(x, 0, -max_dist); 1.66 + glVertex3f(x, 0, max_dist); 1.67 + glVertex3f(-max_dist, 0, -x); 1.68 + glVertex3f(max_dist, 0, -x); 1.69 + glVertex3f(-max_dist, 0, x); 1.70 + glVertex3f(max_dist, 0, x); 1.71 + } 1.72 + glEnd(); 1.73 +}