libgoatvr

diff src/vr.c @ 32:7eea82cea9d2

added preliminary support for quad-buffer stereo fallback drawing
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 30 Oct 2015 06:12:48 +0200
parents d659cbedde1d
children 1102327fe85f
line diff
     1.1 --- a/src/vr.c	Sun Apr 12 02:02:04 2015 +0300
     1.2 +++ b/src/vr.c	Fri Oct 30 06:12:48 2015 +0200
     1.3 @@ -43,10 +43,15 @@
     1.4  		set_option_vec3f(defopt, VR_LEYE_OFFSET, -DEF_IPD * 0.5f, 0.0f, 0.0f);
     1.5  		set_option_vec3f(defopt, VR_REYE_OFFSET, DEF_IPD * 0.5f, 0.0f, 0.0f);
     1.6  
     1.7 -		if((env = getenv("VR_NULL_STEREO")) && atoi(env)) {
     1.8 -			set_option_int(defopt, VR_NULL_STEREO, 1);
     1.9 +		if((env = getenv("VR_NULL_STEREO_SBS")) && atoi(env)) {
    1.10 +			set_option_int(defopt, VR_NULL_STEREO_SBS, 1);
    1.11  		} else {
    1.12 -			set_option_int(defopt, VR_NULL_STEREO, 0);
    1.13 +			set_option_int(defopt, VR_NULL_STEREO_SBS, 0);
    1.14 +		}
    1.15 +		if((env = getenv("VR_NULL_STEREO_GL")) && atoi(env)) {
    1.16 +			set_option_int(defopt, VR_NULL_STEREO_GL, 1);
    1.17 +		} else {
    1.18 +			set_option_int(defopt, VR_NULL_STEREO_GL, 0);
    1.19  		}
    1.20  	}
    1.21  
    1.22 @@ -364,7 +369,8 @@
    1.23  
    1.24  static void fallback_present(void)
    1.25  {
    1.26 -	int i, show_both = vr_geti(VR_NULL_STEREO);
    1.27 +	int i, show_sbs = vr_geti(VR_NULL_STEREO_SBS);
    1.28 +	int use_quadbuf = vr_geti(VR_NULL_STEREO_GL);
    1.29  
    1.30  	glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
    1.31  
    1.32 @@ -386,7 +392,7 @@
    1.33  	for(i=0; i<2; i++) {
    1.34  		float x0, x1;
    1.35  
    1.36 -		if(show_both) {
    1.37 +		if(show_sbs && !use_quadbuf) {
    1.38  			x0 = i == 0 ? -1 : 0;
    1.39  			x1 = i == 0 ? 0 : 1;
    1.40  		} else {
    1.41 @@ -396,6 +402,10 @@
    1.42  
    1.43  		glBindTexture(GL_TEXTURE_2D, rtarg[i].tex);
    1.44  
    1.45 +		if(use_quadbuf) {
    1.46 +			glDrawBuffer(GL_BACK_LEFT + i);
    1.47 +		}
    1.48 +
    1.49  		glBegin(GL_QUADS);
    1.50  		glTexCoord2f(rtarg[i].umin, rtarg[i].vmin);
    1.51  		glVertex2f(x0, -1);
    1.52 @@ -407,7 +417,11 @@
    1.53  		glVertex2f(x0, 1);
    1.54  		glEnd();
    1.55  
    1.56 -		if(!show_both) break;
    1.57 +		if(!show_sbs && !use_quadbuf) break;
    1.58 +	}
    1.59 +
    1.60 +	if(use_quadbuf) {
    1.61 +		glDrawBuffer(GL_BACK);
    1.62  	}
    1.63  
    1.64  	glPopMatrix();