/*
	================
	RB_SetGL2D
	================
	*/
	static void RB_SetGL2D( void )
	{
		matrix_t proj;

		GLimp_LogComment( "--- RB_SetGL2D ---\n" );

#if defined( USE_D3D10 )
		// TODO
#else

		// disable offscreen rendering
		if ( glConfig.framebufferObjectAvailable )
		{
			R_BindNullFBO();
		}

#endif

		backEnd.projection2D = qtrue;

#if defined( USE_D3D10 )
		// TODO
#else
		// set 2D virtual screen size
		GL_Viewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );
		GL_Scissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );

		MatrixOrthogonalProjection( proj, 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 );
		GL_LoadProjectionMatrix( proj );
		GL_LoadModelViewMatrix( matrixIdentity );

		GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );

		qglDisable( GL_CULL_FACE );
		qglDisable( GL_CLIP_PLANE0 );
#endif

		// set time for 2D shaders
		backEnd.refdef.time = ri.Milliseconds();
		backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f;
	}
Exemple #2
0
/*
==================
RB_RenderFlares

Because flares are simulating an occular effect, they should be drawn after
everything (all views) in the entire frame has been drawn.

Because of the way portals use the depth buffer to mark off areas, the
needed information would be lost after each view, so we are forced to draw
flares after each view.

The resulting artifact is that flares in mirrors or portals don't dim properly
when occluded by something in the main view, and portal flares that should
extend past the portal edge will be overwritten.
==================
*/
void RB_RenderFlares(void)
{
	flare_t        *f;
	flare_t       **prev;
	qboolean        draw;
	matrix_t        ortho;

	if(!r_flares->integer)
		return;

#if 0
	if(r_flareCoeff->modified)
	{
		if(r_flareCoeff->value == 0.0f)
			flareCoeff = atof("150");
		else
			flareCoeff = r_flareCoeff->value;

		r_flareCoeff->modified = qfalse;
	}
#endif

	// reset currentEntity to world so that any previously referenced entities don't have influence
	// on the rendering of these flares (i.e. RF_ renderer flags).
	backEnd.currentEntity = &tr.worldEntity;
	backEnd.orientation = backEnd.viewParms.world;
	GL_LoadModelViewMatrix(backEnd.viewParms.world.modelViewMatrix);

	if(tr.world != NULL)		// thx Thilo
	{
		RB_AddLightFlares();
	}

	// perform z buffer readback on each flare in this view
	draw = qfalse;
	prev = &r_activeFlares;
	while((f = *prev) != NULL)
	{
		// throw out any flares that weren't added last frame
		if(f->addedFrame < backEnd.viewParms.frameCount - 1)
		{
			*prev = f->next;
			f->next = r_inactiveFlares;
			r_inactiveFlares = f;
			continue;
		}

		// don't draw any here that aren't from this scene / portal
		f->drawIntensity = 0;
		if(f->frameSceneNum == backEnd.viewParms.frameSceneNum && f->inPortal == backEnd.viewParms.isPortal)
		{
			RB_TestFlare(f);

			if(f->drawIntensity)
			{
				draw = qtrue;
			}
			else
			{
				// this flare has completely faded out, so remove it from the chain
				*prev = f->next;
				f->next = r_inactiveFlares;
				r_inactiveFlares = f;
				continue;
			}
		}

		prev = &f->next;
	}

	if(!draw)
	{
		// none visible
		return;
	}

	if(backEnd.viewParms.isPortal)
	{
		qglDisable(GL_CLIP_PLANE0);
	}

	GL_CheckErrors();

	GL_PushMatrix();
	MatrixOrthogonalProjection(ortho, backEnd.viewParms.viewportX,
									backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth,
									backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight,
									-99999, 99999);
	GL_LoadProjectionMatrix(ortho);
	GL_LoadModelViewMatrix(matrixIdentity);


	for(f = r_activeFlares; f; f = f->next)
	{
		if(f->frameSceneNum == backEnd.viewParms.frameSceneNum && f->inPortal == backEnd.viewParms.isPortal && f->drawIntensity)
			RB_RenderFlare(f);
	}

	GL_PopMatrix();

	GL_CheckErrors();
}