}
#endif
-#define BACKENDACTIVECHECK if (!backendactive) Sys_Error("GL backend function called when backend is not active\n");
+#define BACKENDACTIVECHECK if (!backendactive) Sys_Error("GL backend function called when backend is not active");
void SCR_ScreenShot_f (void);
memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
}
-void GL_SetupView_Mode_Perspective (double fovx, double fovy, double zNear, double zFar)
+void GL_SetupView_Mode_Perspective (double frustumx, double frustumy, double zNear, double zFar)
{
- double xmax, ymax;
double m[16];
if (!r_render.integer)
// set up viewpoint
qglMatrixMode(GL_PROJECTION);CHECKGLERROR
qglLoadIdentity();CHECKGLERROR
- // pyramid slopes
- xmax = zNear * tan(fovx * M_PI / 360.0);
- ymax = zNear * tan(fovy * M_PI / 360.0);
// set view pyramid
- qglFrustum(-xmax, xmax, -ymax, ymax, zNear, zFar);CHECKGLERROR
+ qglFrustum(-frustumx * zNear, frustumx * zNear, -frustumy * zNear, frustumy * zNear, zNear, zFar);CHECKGLERROR
qglGetDoublev(GL_PROJECTION_MATRIX, m);
backend_projectmatrix.m[0][0] = m[0];
backend_projectmatrix.m[1][0] = m[1];
GL_SetupView_Orientation_Identity();
}
-void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double fovx, double fovy, double zNear)
+void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double frustumx, double frustumy, double zNear)
{
double nudge, m[16];
qglLoadIdentity();CHECKGLERROR
// set view pyramid
nudge = 1.0 - 1.0 / (1<<23);
- m[ 0] = 1.0 / tan(fovx * M_PI / 360.0);
+ m[ 0] = 1.0 / frustumx;
m[ 1] = 0;
m[ 2] = 0;
m[ 3] = 0;
m[ 4] = 0;
- m[ 5] = 1.0 / tan(fovy * M_PI / 360.0);
+ m[ 5] = 1.0 / frustumy;
m[ 6] = 0;
m[ 7] = 0;
m[ 8] = 0;
{
GLint vertexshadercompiled, fragmentshadercompiled, programlinked;
GLuint vertexshaderobject, fragmentshaderobject, programobject = 0;
- char compilelog[4096];
+ char compilelog[MAX_INPUTLINE];
CHECKGLERROR
programobject = qglCreateProgramObjectARB();
qglGetObjectParameterivARB(vertexshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &vertexshadercompiled);
qglGetInfoLogARB(vertexshaderobject, sizeof(compilelog), NULL, compilelog);
if (compilelog[0])
- Con_Printf("vertex shader compile log:\n%s\n", compilelog);
+ Con_DPrintf("vertex shader compile log:\n%s\n", compilelog);
if (!vertexshadercompiled)
{
qglDeleteObjectARB(programobject);
qglGetObjectParameterivARB(fragmentshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &fragmentshadercompiled);
qglGetInfoLogARB(fragmentshaderobject, sizeof(compilelog), NULL, compilelog);
if (compilelog[0])
- Con_Printf("fragment shader compile log:\n%s\n", compilelog);
+ Con_DPrintf("fragment shader compile log:\n%s\n", compilelog);
if (!fragmentshadercompiled)
{
qglDeleteObjectARB(programobject);
qglGetInfoLogARB(programobject, sizeof(compilelog), NULL, compilelog);
if (compilelog[0])
{
- Con_Printf("program link log:\n%s\n", compilelog);
+ Con_DPrintf("program link log:\n%s\n", compilelog);
// software vertex shader is ok but software fragment shader is WAY
// too slow, fail program if so.
// NOTE: this string might be ATI specific, but that's ok because the
==============================================================================
*/
-qboolean SCR_ScreenShot(char *filename, qbyte *buffer1, qbyte *buffer2, qbyte *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg, qboolean gammacorrect)
+qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *buffer2, unsigned char *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg, qboolean gammacorrect)
{
int indices[3] = {0,1,2};
qboolean ret;
}
}
-/*
-====================
-CalcFov
-====================
-*/
-float CalcFov (float fov_x, float width, float height)
-{
- // calculate vision size and alter by aspect, then convert back to angle
- return atan (((height/width)/vid_pixelaspect.value)*tan(fov_x/360.0*M_PI))*360.0/M_PI;
-}
+qboolean CL_VM_UpdateView (void);
+void SCR_DrawConsole (void);
int r_stereo_side;
}
// LordHavoc: viewzoom (zoom in for sniper rifles, etc)
- r_refdef.fov_x = scr_fov.value * r_refdef.fovscale_x;
- r_refdef.fov_y = CalcFov (scr_fov.value, r_refdef.width, r_refdef.height) * r_refdef.fovscale_y;
-
- R_RenderView();
+ // LordHavoc: this is designed to produce widescreen fov values
+ // when the screen is wider than 4/3 width/height aspect, to do
+ // this it simply assumes the requested fov is the vertical fov
+ // for a 4x3 display, if the ratio is not 4x3 this makes the fov
+ // higher/lower according to the ratio
+ r_refdef.frustum_y = tan(scr_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
+ r_refdef.frustum_x = r_refdef.frustum_y * (float)r_refdef.width / (float)r_refdef.height / vid_pixelheight.value;
+
+ r_refdef.frustum_x *= r_refdef.frustumscale_x;
+ r_refdef.frustum_y *= r_refdef.frustumscale_y;
+
+ if(!CL_VM_UpdateView())
+ R_RenderView();
+ else
+ SCR_DrawConsole();
if (scr_zoomwindow.integer)
{
r_refdef.height = vid.height * sizey;
r_refdef.x = (vid.width - r_refdef.width)/2;
r_refdef.y = 0;
- r_refdef.fov_x = scr_zoomwindow_fov.value * r_refdef.fovscale_x;
- r_refdef.fov_y = CalcFov(scr_zoomwindow_fov.value, r_refdef.width, r_refdef.height) * r_refdef.fovscale_y;
- R_RenderView();
+ r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
+ r_refdef.frustum_x = r_refdef.frustum_y * vid_pixelheight.value * (float)r_refdef.width / (float)r_refdef.height;
+
+ r_refdef.frustum_x *= r_refdef.frustumscale_x;
+ r_refdef.frustum_y *= r_refdef.frustumscale_y;
+
+ if(!CL_VM_UpdateView())
+ R_RenderView();
}
}
// size of data buffer
static int r_mesh_rcachedata_size = RCACHEARRAY_DEFAULTSIZE;
// data buffer
-static qbyte r_mesh_rcachedata[RCACHEARRAY_DEFAULTSIZE];
+static unsigned char r_mesh_rcachedata[RCACHEARRAY_DEFAULTSIZE];
// current state
static int r_mesh_rcachedata_offset;
//R_Mesh_CacheArray_ValidateState(3);
// calculate a hashindex to choose a cache chain
r->data = NULL;
- hashindex = CRC_Block((qbyte *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE;
+ hashindex = CRC_Block((unsigned char *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE;
// is it already cached?
for (lhead = &r_mesh_rcachechain[hashindex], l = lhead->next;l != lhead;l = l->next)