switch(c)
{
- case VF_MIN: r_view.x = (int)f[0];
- r_view.y = (int)f[1];
+ case VF_MIN: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
break;
- case VF_MIN_X: r_view.x = (int)k;
+ case VF_MIN_X: r_view.x = (int)(k * vid.width / vid_conwidth.value);
break;
- case VF_MIN_Y: r_view.y = (int)k;
+ case VF_MIN_Y: r_view.y = (int)(k * vid.height / vid_conheight.value);
break;
- case VF_SIZE: r_view.width = (int)f[0];
- r_view.height = (int)f[1];
+ case VF_SIZE: r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
break;
- case VF_SIZE_Y: r_view.width = (int)k;
+ case VF_SIZE_Y: r_view.width = (int)(k * vid.width / vid_conwidth.value);
break;
- case VF_SIZE_X: r_view.height = (int)k;
+ case VF_SIZE_X: r_view.height = (int)(k * vid.height / vid_conheight.value);
break;
- case VF_VIEWPORT: r_view.x = (int)f[0];
- r_view.y = (int)f[1];
- r_view.z = 0;
- // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them!
+ case VF_VIEWPORT: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
f = PRVM_G_VECTOR(OFS_PARM2);
- r_view.width = (int)f[0];
- r_view.height = (int)f[1];
- r_view.depth = 1;
+ r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
break;
- case VF_FOV: //r_refdef.fov_x = f[0]; // FIXME!
- //r_refdef.fov_y = f[1]; // FIXME!
+ case VF_FOV: r_view.frustum_x = tan(f[0] * M_PI / 360.0);
+ r_view.frustum_y = tan(f[1] * M_PI / 360.0);
break;
- case VF_FOVX: //r_refdef.fov_x = k; // FIXME!
+ case VF_FOVX: r_view.frustum_x = tan(k * M_PI / 360.0);
break;
- case VF_FOVY: //r_refdef.fov_y = k; // FIXME!
+ case VF_FOVY: r_view.frustum_y = tan(k * M_PI / 360.0);
break;
case VF_ORIGIN: VectorCopy(f, cl.csqc_origin);
CSQC_R_RecalcView();
case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
break;
+ case VF_PERSPECTIVE: r_view.useperspective = k != 0;
+ break;
+
default: PRVM_G_FLOAT(OFS_RETURN) = 0;
VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c);
return;
#define VF_CL_VIEWANGLES_Y 35 //(float)
#define VF_CL_VIEWANGLES_Z 36 //(float)
-//#define VF_PERSPECTIVE 200
+#define VF_PERSPECTIVE 200 //(float)
#define RF_VIEWMODEL 1 // The entity is never drawn in mirrors. In engines with realtime lighting, it casts no shadows.
#define RF_EXTERNALMODEL 2 // The entity is appears in mirrors but not in the normal view. It does still cast shadows in engines with realtime lighting.
void R_SetupView(const matrix4x4_t *matrix)
{
- if (r_refdef.rtworldshadows || r_refdef.rtdlightshadows)
+ if (!r_view.useperspective)
+ GL_SetupView_Mode_Ortho(r_view.x, r_view.y, r_view.x + r_view.width, r_view.y + r_view.height, -r_refdef.farclip, r_refdef.farclip);
+ else if (r_refdef.rtworldshadows || r_refdef.rtdlightshadows)
GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_view.frustum_x, r_view.frustum_y, r_refdef.nearclip);
else
GL_SetupView_Mode_Perspective(r_view.frustum_x, r_view.frustum_y, r_refdef.nearclip, r_refdef.farclip);