@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2222// r_main.c
2323
2424#include "quakedef.h"
25+ #include "vr.h"
2526
2627qboolean r_cache_thrash ; // compatability
2728
@@ -102,6 +103,11 @@ cvar_t r_noshadow_list = {"r_noshadow_list", "progs/flame2.mdl,progs/flame.mdl,p
102103extern cvar_t r_vfog ;
103104//johnfitz
104105
106+ //phoboslab -- cvars for vr
107+ extern cvar_t vr_enabled ;
108+ extern cvar_t vr_crosshair ;
109+ //phoboslab
110+
105111cvar_t gl_zfix = {"gl_zfix" , "0" , CVAR_NONE }; // QuakeSpasm z-fighting fix
106112
107113cvar_t r_lavaalpha = {"r_lavaalpha" ,"0" ,CVAR_NONE };
@@ -437,6 +443,9 @@ void R_SetFrustum (float fovx, float fovy)
437443 if (r_stereo .value )
438444 fovx += 10 ; //silly hack so that polygons don't drop out becuase of stereo skew
439445
446+ if (vr_enabled .value )
447+ fovx += 25 ; // meh
448+
440449 TurnVector (frustum [0 ].normal , vpn , vright , fovx /2 - 90 ); //left plane
441450 TurnVector (frustum [1 ].normal , vpn , vright , 90 - fovx /2 ); //right plane
442451 TurnVector (frustum [2 ].normal , vpn , vup , 90 - fovy /2 ); //bottom plane
@@ -472,28 +481,34 @@ R_SetupGL
472481*/
473482void R_SetupGL (void )
474483{
475- //johnfitz -- rewrote this section
476- glMatrixMode (GL_PROJECTION );
477- glLoadIdentity ();
478- glViewport (glx + r_refdef .vrect .x ,
479- gly + glheight - r_refdef .vrect .y - r_refdef .vrect .height ,
480- r_refdef .vrect .width ,
481- r_refdef .vrect .height );
482- //johnfitz
484+ if (vr_enabled .value ) {
485+ VR_SetMatrices ();
486+ }
487+ else
488+ {
489+ //johnfitz -- rewrote this section
490+ glMatrixMode (GL_PROJECTION );
491+ glLoadIdentity ();
492+ glViewport (glx + r_refdef .vrect .x ,
493+ gly + glheight - r_refdef .vrect .y - r_refdef .vrect .height ,
494+ r_refdef .vrect .width ,
495+ r_refdef .vrect .height );
496+ //johnfitz
483497
484- GL_SetFrustum (r_fovx , r_fovy ); //johnfitz -- use r_fov* vars
498+ GL_SetFrustum (r_fovx , r_fovy ); //johnfitz -- use r_fov* vars
485499
486- // glCullFace(GL_BACK); //johnfitz -- glquake used CCW with backwards culling -- let's do it right
500+ // glCullFace(GL_BACK); //johnfitz -- glquake used CCW with backwards culling -- let's do it right
487501
488- glMatrixMode (GL_MODELVIEW );
489- glLoadIdentity ();
502+ glMatrixMode (GL_MODELVIEW );
503+ glLoadIdentity ();
490504
491- glRotatef (-90 , 1 , 0 , 0 ); // put Z going up
492- glRotatef (90 , 0 , 0 , 1 ); // put Z going up
493- glRotatef (- r_refdef .viewangles [2 ], 1 , 0 , 0 );
494- glRotatef (- r_refdef .viewangles [0 ], 0 , 1 , 0 );
495- glRotatef (- r_refdef .viewangles [1 ], 0 , 0 , 1 );
496- glTranslatef (- r_refdef .vieworg [0 ], - r_refdef .vieworg [1 ], - r_refdef .vieworg [2 ]);
505+ glRotatef (-90 , 1 , 0 , 0 ); // put Z going up
506+ glRotatef (90 , 0 , 0 , 1 ); // put Z going up
507+ glRotatef (- r_refdef .viewangles [2 ], 1 , 0 , 0 );
508+ glRotatef (- r_refdef .viewangles [0 ], 0 , 1 , 0 );
509+ glRotatef (- r_refdef .viewangles [1 ], 0 , 0 , 1 );
510+ glTranslatef (- r_refdef .vieworg [0 ], - r_refdef .vieworg [1 ], - r_refdef .vieworg [2 ]);
511+ }
497512
498513 //
499514 // set drawing parms
@@ -662,6 +677,9 @@ void R_DrawViewModel (void)
662677 if (cl .items & IT_INVISIBILITY || cl .stats [STAT_HEALTH ] <= 0 )
663678 return ;
664679
680+ if (vr_enabled .value && vr_crosshair .value )
681+ VR_ShowCrosshair ();
682+
665683 currententity = & cl .viewent ;
666684 if (!currententity -> model )
667685 return ;
0 commit comments