/*
=====================
R_ObliqueProjection - adjust near plane of previously set projection matrix to perform an oblique projection
=====================
*/
static void R_ObliqueProjection(viewDef_t *parms)
{
	float mvt[16];	//model view transpose
	idPlane pB = parms->clipPlanes[0];
	idPlane cp;
	R_MatrixTranspose(parms->worldSpace.modelViewMatrix, mvt);
	R_GlobalPlaneToLocal(mvt, pB, cp);	//transform plane (which is set to the surface we're mirroring about's plane) to camera space

	//oblique projection adjustment code
	idVec4 clipPlane(cp[0], cp[1], cp[2], cp[3]);
	idVec4 q;
	q[0] = ((clipPlane[0] < 0.0f ? -1.0f : clipPlane[0] > 0.0f ? 1.0f : 0.0f) + parms->projectionMatrix[8]) / parms->projectionMatrix[0];
	q[1] = ((clipPlane[1] < 0.0f ? -1.0f : clipPlane[1] > 0.0f ? 1.0f : 0.0f) + parms->projectionMatrix[9]) / parms->projectionMatrix[5];
	q[2] = -1.0f;
	q[3] = (1.0f + parms->projectionMatrix[10]) / parms->projectionMatrix[14];

	// scaled plane vector
	float d = 2.0f / (clipPlane * q);

	// Replace the third row of the projection matrix
	parms->projectionMatrix[2] = clipPlane[0] * d;
	parms->projectionMatrix[6] = clipPlane[1] * d;
	parms->projectionMatrix[10] = clipPlane[2] * d + 1.0f;
	parms->projectionMatrix[14] = clipPlane[3] * d;
}
Beispiel #2
0
/*
============================
idAutoRender::RenderLoadingIcon
============================
*/
void idAutoRender::RenderLoadingIcon( float fracX, float fracY, float size, float speed )
{

	float s = 0.0f;
	float c = 1.0f;
	
	if( autoRenderIcon != AUTORENDER_HELLICON )
	{
		if( Sys_Milliseconds() >= nextRotateTime )
		{
			nextRotateTime = Sys_Milliseconds() + 100;
			currentRotation -= 90.0f;
		}
		float angle = DEG2RAD( currentRotation );
		idMath::SinCos( angle, s, c );
	}
	
	const float pixelAspect = renderSystem->GetPixelAspect();
	const float screenWidth = renderSystem->GetWidth();
	const float screenHeight = renderSystem->GetHeight();
	
	const float minSize = Min( screenWidth, screenHeight );
	if( minSize <= 0.0f )
	{
		return;
	}
	
	float scaleX = size * minSize / screenWidth;
	float scaleY = size * minSize / screenHeight;
	
	float scale[16] = { 0 };
	scale[0] = c * scaleX / pixelAspect;
	scale[1] = -s * scaleY;
	scale[4] = s * scaleX / pixelAspect;
	scale[5] = c * scaleY;
	scale[10] = 1.0f;
	scale[15] = 1.0f;
	
	scale[12] = fracX;
	scale[13] = fracY;
	
	float ortho[16] = { 0 };
	ortho[0] = 2.0f;
	ortho[5] = -2.0f;
	ortho[10] = -2.0f;
	ortho[12] = -1.0f;
	ortho[13] = 1.0f;
	ortho[14] = -1.0f;
	ortho[15] = 1.0f;
	
	float finalOrtho[16];
	R_MatrixMultiply( scale, ortho, finalOrtho );
	
	float projMatrixTranspose[16];
	R_MatrixTranspose( finalOrtho, projMatrixTranspose );
	renderProgManager.SetRenderParms( RENDERPARM_MVPMATRIX_X, projMatrixTranspose, 4 );
	
	float a = 1.0f;
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		float alpha = DEG2RAD( Sys_Milliseconds() * speed );
		a = idMath::Sin( alpha );
		a = 0.35f + ( 0.65f * idMath::Fabs( a ) );
	}
	
	GL_SelectTexture( 0 );
	
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		globalImages->hellLoadingIconImage->Bind();
	}
	else
	{
		globalImages->loadingIconImage->Bind();
	}
	
	GL_State( GLS_DEPTHFUNC_ALWAYS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
	
	// Set Parms
	float texS[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
	float texT[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
	renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_S, texS );
	renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_T, texT );
	
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		GL_Color( 1.0f, 1.0f, 1.0f, a );
	}
	
	// disable texgen
	float texGenEnabled[4] = { 0, 0, 0, 0 };
	renderProgManager.SetRenderParm( RENDERPARM_TEXGEN_0_ENABLED, texGenEnabled );
	
	renderProgManager.BindShader_TextureVertexColor();
	
	RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
}