out[2] = v->z + (out[2] * iw + 1.0f) * v->depth * 0.5f;
}
-static void R_Viewport_ApplyNearClipPlane(r_viewport_t *v, double normalx, double normaly, double normalz, double dist)
+static void R_Viewport_ApplyNearClipPlane(r_viewport_t *v, float normalx, float normaly, float normalz, float dist)
{
- double q[4];
- double d;
+ float q[4];
+ float d;
float clipPlane[4], v3[3], v4[3];
float normal[3];
v->m[14] = clipPlane[3] * d;
}
-void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double x1, double y1, double x2, double y2, double nearclip, double farclip, const double *nearplane)
+void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float nearclip, float farclip, const float *nearplane)
{
float left = x1, right = x2, bottom = y2, top = y1, zNear = nearclip, zFar = farclip;
memset(v, 0, sizeof(*v));
v->m[13] = - (top + bottom)/(top - bottom);
v->m[14] = - (zFar + zNear)/(zFar - zNear);
v->m[15] = 1;
+ v->screentodepth[0] = -farclip / (farclip - nearclip);
+ v->screentodepth[1] = farclip * nearclip / (farclip - nearclip);
Matrix4x4_Invert_Full(&v->viewmatrix, &v->cameramatrix);
- Matrix4x4_FromArrayDoubleGL(&v->projectmatrix, v->m);
+ Matrix4x4_FromArrayFloatGL(&v->projectmatrix, v->m);
if (nearplane)
R_Viewport_ApplyNearClipPlane(v, nearplane[0], nearplane[1], nearplane[2], nearplane[3]);
#endif
}
-void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double frustumx, double frustumy, double nearclip, double farclip, const double *nearplane)
+void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
{
matrix4x4_t tempmatrix, basematrix;
memset(v, 0, sizeof(*v));
v->m[10] = -(farclip + nearclip) / (farclip - nearclip);
v->m[11] = -1;
v->m[14] = -2 * nearclip * farclip / (farclip - nearclip);
+ v->screentodepth[0] = -farclip / (farclip - nearclip);
+ v->screentodepth[1] = farclip * nearclip / (farclip - nearclip);
Matrix4x4_Invert_Full(&tempmatrix, &v->cameramatrix);
Matrix4x4_CreateRotate(&basematrix, -90, 1, 0, 0);
Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
Matrix4x4_Concat(&v->viewmatrix, &basematrix, &tempmatrix);
- Matrix4x4_FromArrayDoubleGL(&v->projectmatrix, v->m);
+ Matrix4x4_FromArrayFloatGL(&v->projectmatrix, v->m);
if (nearplane)
R_Viewport_ApplyNearClipPlane(v, nearplane[0], nearplane[1], nearplane[2], nearplane[3]);
}
-void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double frustumx, double frustumy, double nearclip, const double *nearplane)
+void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, const float *nearplane)
{
matrix4x4_t tempmatrix, basematrix;
- const double nudge = 1.0 - 1.0 / (1<<23);
+ const float nudge = 1.0 - 1.0 / (1<<23);
memset(v, 0, sizeof(*v));
if(v_flipped.integer)
v->m[10] = -nudge;
v->m[11] = -1;
v->m[14] = -2 * nearclip * nudge;
+ v->screentodepth[0] = (v->m[10] + 1) * 0.5 - 1;
+ v->screentodepth[1] = v->m[14] * -0.5;
Matrix4x4_Invert_Full(&tempmatrix, &v->cameramatrix);
Matrix4x4_CreateRotate(&basematrix, -90, 1, 0, 0);
Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
Matrix4x4_Concat(&v->viewmatrix, &basematrix, &tempmatrix);
- Matrix4x4_FromArrayDoubleGL(&v->projectmatrix, v->m);
+ Matrix4x4_FromArrayFloatGL(&v->projectmatrix, v->m);
if (nearplane)
R_Viewport_ApplyNearClipPlane(v, nearplane[0], nearplane[1], nearplane[2], nearplane[3]);
Matrix4x4_FromArrayFloatGL(&basematrix, cubeviewmatrix[side]);
Matrix4x4_Invert_Simple(&tempmatrix, &v->cameramatrix);
Matrix4x4_Concat(&v->viewmatrix, &basematrix, &tempmatrix);
- Matrix4x4_FromArrayDoubleGL(&v->projectmatrix, v->m);
+ Matrix4x4_FromArrayFloatGL(&v->projectmatrix, v->m);
if (nearplane)
R_Viewport_ApplyNearClipPlane(v, nearplane[0], nearplane[1], nearplane[2], nearplane[3]);
Matrix4x4_FromArrayFloatGL(&basematrix, rectviewmatrix[side]);
Matrix4x4_Invert_Simple(&tempmatrix, &v->cameramatrix);
Matrix4x4_Concat(&v->viewmatrix, &basematrix, &tempmatrix);
- Matrix4x4_FromArrayDoubleGL(&v->projectmatrix, v->m);
+ Matrix4x4_FromArrayFloatGL(&v->projectmatrix, v->m);
if (nearplane)
R_Viewport_ApplyNearClipPlane(v, nearplane[0], nearplane[1], nearplane[2], nearplane[3]);
// Load the projection matrix into OpenGL
qglMatrixMode(GL_PROJECTION);CHECKGLERROR
- qglLoadMatrixd(gl_state.viewport.m);CHECKGLERROR
+ qglLoadMatrixf(gl_state.viewport.m);CHECKGLERROR
qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
// FIXME: v_flipped_state is evil, this probably breaks somewhere
qglCompileShaderARB(shaderobject);CHECKGLERROR
qglGetObjectParameterivARB(shaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &shadercompiled);CHECKGLERROR
qglGetInfoLogARB(shaderobject, sizeof(compilelog), NULL, compilelog);CHECKGLERROR
- if (compilelog[0] && developer.integer > 0)
+ if (compilelog[0] && developer.integer > 0 && (strstr(compilelog, "error") || strstr(compilelog, "ERROR") || strstr(compilelog, "Error") || strstr(compilelog, "WARNING") || strstr(compilelog, "warning") || strstr(compilelog, "Warning")))
{
int i, j, pretextlines = 0;
for (i = 0;i < numstrings - 1;i++)
qglGetInfoLogARB(programobject, sizeof(linklog), NULL, linklog);CHECKGLERROR
if (linklog[0])
{
- Con_DPrintf("program link log:\n%s\n", linklog);
+ if (strstr(linklog, "error") || strstr(linklog, "ERROR") || strstr(linklog, "Error") || strstr(linklog, "WARNING") || strstr(linklog, "warning") || strstr(linklog, "Warning"))
+ Con_DPrintf("program link log:\n%s\n", linklog);
// 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
}
}
+int R_Mesh_TexBound(unsigned int unitnum, int id)
+{
+ gltextureunit_t *unit = gl_state.units + unitnum;
+ if (unitnum >= vid.teximageunits)
+ return 0;
+ if (id == GL_TEXTURE_2D)
+ return unit->t2d;
+ if (id == GL_TEXTURE_3D)
+ return unit->t3d;
+ if (id == GL_TEXTURE_CUBE_MAP_ARB)
+ return unit->tcubemap;
+ if (id == GL_TEXTURE_RECTANGLE_ARB)
+ return unit->trectangle;
+ return 0;
+}
+
void R_Mesh_TexBindAll(unsigned int unitnum, int tex2d, int tex3d, int texcubemap, int texrectangle)
{
gltextureunit_t *unit = gl_state.units + unitnum;
void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
{
gltextureunit_t *unit = gl_state.units + unitnum;
- if (matrix->m[3][3])
+ if (matrix && matrix->m[3][3])
{
// texmatrix specified, check if it is different
if (!unit->texmatrixenabled || memcmp(&unit->matrix, matrix, sizeof(matrix4x4_t)))
}
}
-void R_Mesh_TextureState(const rmeshstate_t *m)
-{
- unsigned int i;
-
- BACKENDACTIVECHECK
-
- CHECKGLERROR
- for (i = 0;i < vid.teximageunits;i++)
- R_Mesh_TexBindAll(i, m->tex[i], m->tex3d[i], m->texcubemap[i], m->texrectangle[i]);
- for (i = 0;i < vid.texarrayunits;i++)
- {
- if (m->pointer_texcoord3f[i])
- R_Mesh_TexCoordPointer(i, 3, m->pointer_texcoord3f[i], m->pointer_texcoord_bufferobject[i], m->pointer_texcoord_bufferoffset[i]);
- else
- R_Mesh_TexCoordPointer(i, 2, m->pointer_texcoord[i], m->pointer_texcoord_bufferobject[i], m->pointer_texcoord_bufferoffset[i]);
- }
- for (i = 0;i < vid.texunits;i++)
- {
- R_Mesh_TexMatrix(i, &m->texmatrix[i]);
- R_Mesh_TexCombine(i, m->texcombinergb[i], m->texcombinealpha[i], m->texrgbscale[i], m->texalphascale[i]);
- }
- CHECKGLERROR
-}
-
void R_Mesh_ResetTextureState(void)
{
unsigned int unitnum;