oculus1

diff src/vr.cc @ 15:402cbb6d9ce3

added the shader as a separate header file
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 04:15:20 +0300
parents cceffea995a4
children f3672317e5c2
line diff
     1.1 --- a/src/vr.cc	Sat Sep 21 03:35:53 2013 +0300
     1.2 +++ b/src/vr.cc	Sat Sep 21 04:15:20 2013 +0300
     1.3 @@ -2,35 +2,7 @@
     1.4  #include <GL/glew.h>
     1.5  #include "vr.h"
     1.6  #include "vr_impl.h"
     1.7 -
     1.8 -static const char *sdr_src =
     1.9 -	"uniform sampler2D tex;\n"
    1.10 -	"uniform vec2 lens_center;\n"
    1.11 -	"uniform vec2 scr_center;\n"
    1.12 -	"uniform vec2 scale;\n"
    1.13 -	"uniform vec2 scale_in;\n"
    1.14 -	"uniform vec4 warp_param;\n"
    1.15 -	"\n"
    1.16 -	"vec2 warp(in vec2 pt, out float dbgrad)\n"
    1.17 -	"{\n"
    1.18 -	"    vec2 theta = (pt - lens_center) * scale_in;\n"
    1.19 -	"    float rsq = dot(theta, theta);\n"
    1.20 -	"    vec2 rvec = theta * (warp_param.x + \n"
    1.21 -	"                         warp_param.y * rsq +\n"
    1.22 -	"                         warp_param.z * rsq * rsq +\n"
    1.23 -	"                         warp_param.w * rsq * rsq * rsq);\n"
    1.24 -	"    dbgrad = length(theta);\n"
    1.25 -	"    return lens_center + scale * rvec;\n"
    1.26 -	"}\n"
    1.27 -	"\n"
    1.28 -	"void main()\n"
    1.29 -	"{\n"
    1.30 -	"    float dbgrad;\n"
    1.31 -	"    vec2 tc = warp(gl_TexCoord[0].xy, dbgrad);\n"
    1.32 -	"    gl_FragColor.rgb = texture2D(tex, tc).rgb;\n"
    1.33 -	"    gl_FragColor.rgb += mix(vec3(1.0, 1.0, 0.0), vec3(0.0), smoothstep(0.01, 0.05, dbgrad));\n"
    1.34 -	"    gl_FragColor.a = 1.0;\n"
    1.35 -	"}\n";
    1.36 +#include "vr_sdr.h"
    1.37  
    1.38  static bool init_ovr();
    1.39  static bool init_sdr();
    1.40 @@ -55,6 +27,7 @@
    1.41  
    1.42  extern "C" void vr_shutdown(void)
    1.43  {
    1.44 +	delete [] vr_ctx.info.display;
    1.45  	//System::Destroy();
    1.46  }
    1.47  
    1.48 @@ -124,6 +97,10 @@
    1.49  		float center_dist_meters = info.HScreenSize * 0.25;
    1.50  		float proj_shift = center_dist_meters - info.LensSeparationDistance * 0.5;
    1.51  		vr_ctx.info.proj_center_offset = 4.0 * proj_shift / info.HScreenSize;
    1.52 +
    1.53 +		// grab the display name
    1.54 +		vr_ctx.info.display = new char[strlen(info.DisplayDeviceName) + 1];
    1.55 +		strcpy(vr_ctx.info.display, info.DisplayDeviceName);
    1.56  	}
    1.57  
    1.58  	// get the sensor device