예제 #1
0
파일: r_portals.c 프로젝트: Picmip/qfusion
/*
* R_DrawPortals
*/
void R_DrawPortals( void ) {
	unsigned int i;

	if( rn.renderFlags & RF_SKYSHADOWVIEW ) {
		// render depth mask for skylights
		// TODO: rewrite this!
		float depthmin, depthmax;

		RB_GetDepthRange( &depthmin, &depthmax );

		RB_ClearDepth( depthmin );

		RB_Clear( GL_DEPTH_BUFFER_BIT, 0, 0, 0, 0 );

		if( rn.portalmasklist && rn.portalmasklist->numDrawSurfs ) {
			RB_SetShaderStateMask( ~0, GLSTATE_DEPTHWRITE | GLSTATE_NO_COLORWRITE | GLSTATE_OFFSET_FILL | GLSTATE_DEPTHFUNC_GT );
			RB_FlipFrontFace();
			RB_DepthRange( depthmax, depthmax );
			R_DrawPortalSurfaces( rn.portalmasklist );
			RB_SetShaderStateMask( ~0, GLSTATE_DEPTHWRITE | GLSTATE_NO_COLORWRITE | GLSTATE_OFFSET_FILL );
			RB_FlipFrontFace();
			RB_DepthRange( depthmin, depthmax );
		}

		RB_ClearDepth( depthmax );

		return;
	}

	if( rn.renderFlags & ( RF_MIRRORVIEW | RF_LIGHTVIEW | RF_PORTALVIEW ) ) {
		return;
	}
	if( rn.viewcluster == -1 ) {
		return;
	}

	R_DrawPortalsDepthMask();

	if( rn.skyportalSurface ) {
		// render skyportal
		portalSurface_t *ps = rn.skyportalSurface;
		R_DrawSkyportal( ps->entity, ps->skyPortal );
	} else {
		// FIXME: move this?
		// render sky dome that writes to depth
		R_DrawDepthSkySurf();
	}

	// render regular portals
	for( i = 0; i < rn.numPortalSurfaces; i++ ) {
		portalSurface_t ps = rn.portalSurfaces[i];
		if( !ps.skyPortal ) {
			R_DrawPortalSurface( &ps );
			rn.portalSurfaces[i] = ps;
		}
	}
}
예제 #2
0
파일: r_scene.c 프로젝트: MGXRace/racesow
/*
* R_RenderDebugSurface
*/
static void R_RenderDebugSurface( const refdef_t *fd )
{
	rtrace_t tr;
	vec3_t forward;
	vec3_t start, end;
	msurface_t *surf;

	if( fd->rdflags & RDF_NOWORLDMODEL )
		return;

	if( r_speeds->integer != 4 && r_speeds->integer != 5 )
		return;

	VectorCopy( &fd->viewaxis[AXIS_FORWARD], forward );
	VectorCopy( fd->vieworg, start );
	VectorMA( start, 4096, forward, end );

	surf = R_TraceLine( &tr, start, end, 0 );
	if( surf && surf->drawSurf && !r_showtris->integer )
	{
		R_ClearDrawList( rn.meshlist );

		R_ClearDrawList( rn.portalmasklist );

		if( !R_AddSurfToDrawList( rn.meshlist, R_NUM2ENT(tr.ent), NULL, surf->shader, 0, 0, NULL, surf->drawSurf ) ) {
			return;
		}

		if( rn.refdef.rdflags & RDF_FLIPPED )
			RB_FlipFrontFace();

		rsc.debugSurface = surf;

		if( r_speeds->integer == 5 ) {
			// VBO debug mode
			R_AddVBOSlice( surf->drawSurf - rsh.worldBrushModel->drawSurfaces, 
				surf->drawSurf->numVerts, surf->drawSurf->numElems,
				0, 0 );
		}
		else {
			// classic mode (showtris for individual surface)
			R_AddVBOSlice( surf->drawSurf - rsh.worldBrushModel->drawSurfaces, 
				surf->mesh->numVerts, surf->mesh->numElems,
				surf->firstDrawSurfVert, surf->firstDrawSurfElem );
		}

		R_DrawOutlinedSurfaces( rn.meshlist );

		if( rn.refdef.rdflags & RDF_FLIPPED )
			RB_FlipFrontFace();
	}
}