oculus1
diff src/vr.cc @ 18:1b107de821c1
fixed the test to work with non-pow2 textures
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 26 Sep 2013 10:33:08 +0300 |
parents | cfe4979ab3eb |
children | 899cf9ebffb4 |
line diff
1.1 --- a/src/vr.cc Sat Sep 21 07:09:48 2013 +0300 1.2 +++ b/src/vr.cc Thu Sep 26 10:33:08 2013 +0300 1.3 @@ -4,6 +4,7 @@ 1.4 #include "vr_impl.h" 1.5 #include "vr_sdr.h" 1.6 1.7 +static void init_ctx(); 1.8 static bool init_ovr(); 1.9 static bool init_sdr(); 1.10 1.11 @@ -14,6 +15,8 @@ 1.12 { 1.13 glewInit(); 1.14 1.15 + init_ctx(); 1.16 + 1.17 if(!init_ovr()) { 1.18 return -1; 1.19 } 1.20 @@ -31,6 +34,16 @@ 1.21 //System::Destroy(); 1.22 } 1.23 1.24 +static void init_ctx() 1.25 +{ 1.26 + vr_ctx.info.width = 1280; 1.27 + vr_ctx.info.height = 800; 1.28 + vr_ctx.info.fov = M_PI / 2.0; 1.29 + vr_ctx.info.aspect = (float)vr_ctx.info.width / (float)vr_ctx.info.height; 1.30 + vr_ctx.info.ipd = 0.035; 1.31 + vr_ctx.info.scale = 1.0; 1.32 +} 1.33 + 1.34 static bool init_ovr() 1.35 { 1.36 LogMaskConstants log_level = LogMask_All; 1.37 @@ -312,7 +325,7 @@ 1.38 oq.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(euler + 1, euler, euler + 2); 1.39 } 1.40 1.41 -extern "C" void vr_draw_eye(unsigned int tex, int eye) 1.42 +extern "C" void vr_draw_eye(int eye, unsigned int tex, float tex_scale_x, float tex_scale_y) 1.43 { 1.44 static const float rects[3][4] = { 1.45 {-1, -1, 1, 1}, 1.46 @@ -342,6 +355,10 @@ 1.47 float offset = vr_ctx.info.lens_center_offset * offs_scale[eye]; 1.48 glUniform1f(loc, offset); 1.49 } 1.50 + 1.51 + if((loc = glGetUniformLocation(sdrprog, "tex_scale")) != -1) { 1.52 + glUniform2f(loc, tex_scale_x, tex_scale_y); 1.53 + } 1.54 } 1.55 1.56 glBindTexture(GL_TEXTURE_2D, tex);