示例#1
0
/*
* R_DrawBSPSurf
*/
qboolean R_DrawBSPSurf( const entity_t *e, const shader_t *shader, const mfog_t *fog, drawSurfaceBSP_t *drawSurf )
{
	vboSlice_t *slice;

	slice = R_GetVBOSlice( drawSurf - rsh.worldBrushModel->drawSurfaces );
	assert( slice != NULL );

	RB_BindVBO( drawSurf->vbo->index, GL_TRIANGLES );

	if( drawSurf->dlightFrame == rsc.frameCount ) {
		RB_SetDlightBits( drawSurf->dlightBits & rn.dlightBits );
	}
	else {
		RB_SetDlightBits( 0 );
	}

	if( drawSurf->shadowFrame == rsc.frameCount ) {
		RB_SetShadowBits( drawSurf->shadowBits & rn.shadowBits );
	}
	else {
		RB_SetShadowBits( 0 );
	}

	RB_SetLightstyle( drawSurf->superLightStyle );

	if( drawSurf->numInstances ) {
		RB_DrawElementsInstanced( slice->firstVert, slice->numVerts, slice->firstElem, slice->numElems, 
			drawSurf->numInstances, drawSurf->instances );
	}
	else {
		RB_DrawElements( slice->firstVert, slice->numVerts, slice->firstElem, slice->numElems );
	}

	return qfalse;
}
示例#2
0
/*
* R_DrawBSPSurf
*/
bool R_DrawBSPSurf( const entity_t *e, const shader_t *shader, const mfog_t *fog, const portalSurface_t *portalSurface, drawSurfaceBSP_t *drawSurf )
{
	const vboSlice_t *slice;
	const vboSlice_t *shadowSlice;
	static const vboSlice_t nullSlice = { 0 };
	int firstVert, firstElem;
	int firstShadowVert, firstShadowElem;

	slice = R_GetVBOSlice( drawSurf - rsh.worldBrushModel->drawSurfaces );
	shadowSlice = R_GetVBOSlice( rsh.worldBrushModel->numDrawSurfaces + ( drawSurf - rsh.worldBrushModel->drawSurfaces ) );
	if( !shadowSlice ) {
		shadowSlice = &nullSlice;
	}

	assert( slice != NULL );

	RB_BindVBO( drawSurf->vbo->index, GL_TRIANGLES );

	if( drawSurf->dlightFrame == rsc.frameCount ) {
		RB_SetDlightBits( drawSurf->dlightBits & rn.dlightBits );
	}
	else {
		RB_SetDlightBits( 0 );
	}

	if( drawSurf->shadowFrame == rsc.frameCount ) {
		RB_SetShadowBits( (drawSurf->shadowBits & rn.shadowBits) & rsc.renderedShadowBits );
	}
	else {
		RB_SetShadowBits( 0 );
	}

	RB_SetLightstyle( drawSurf->superLightStyle );

	firstVert = drawSurf->firstVboVert + slice->firstVert;
	firstElem = drawSurf->firstVboElem + slice->firstElem;
	firstShadowVert = drawSurf->firstVboVert + shadowSlice->firstVert;
	firstShadowElem = drawSurf->firstVboElem + shadowSlice->firstElem;

	if( drawSurf->numInstances ) {
		RB_DrawElementsInstanced( firstVert, slice->numVerts, firstElem, slice->numElems, 
			firstShadowVert, shadowSlice->numVerts, firstShadowElem, shadowSlice->numElems,
			drawSurf->numInstances, drawSurf->instances );
	}
	else {
		RB_DrawElements( firstVert, slice->numVerts,firstElem, slice->numElems,
			firstShadowVert, shadowSlice->numVerts, firstShadowElem, shadowSlice->numElems );
	}

	return false;
}
示例#3
0
文件: r_surf.c 项目: MGXRace/racesow
/*
* R_DrawBSPSurf
*/
void R_DrawBSPSurf( const entity_t *e, const shader_t *shader, const mfog_t *fog, const portalSurface_t *portalSurface, unsigned int entShadowBits, drawSurfaceBSP_t *drawSurf )
{
	const vboSlice_t *slice;
	const vboSlice_t *shadowSlice;
	static const vboSlice_t nullSlice = { 0 };
	int firstVert, firstElem;
	int numVerts, numElems;
	int firstShadowVert, firstShadowElem;
	int numShadowVerts, numShadowElems;
	unsigned shadowBits, dlightBits;

	slice = R_GetVBOSlice( drawSurf - rsh.worldBrushModel->drawSurfaces );
	shadowSlice = R_GetVBOSlice( rsh.worldBrushModel->numDrawSurfaces + ( drawSurf - rsh.worldBrushModel->drawSurfaces ) );
	if( !shadowSlice ) {
		shadowSlice = &nullSlice;
	}

	assert( slice != NULL );

	if( drawSurf->dlightFrame == rsc.frameCount ) {
		dlightBits = drawSurf->dlightBits & rn.dlightBits;
	}
	else {
		dlightBits = 0;
	}

	if( drawSurf->shadowFrame == rsc.frameCount ) {
		shadowBits = (drawSurf->shadowBits & rn.shadowBits) & rsc.renderedShadowBits;
	}
	else {
		shadowBits = 0;
	}

	// shadowBits are shared for all rendering instances (normal view, portals, etc)
	// if either shadow slice is empty or shadowBits is 0, then we must pass the surface unshadowed
	numVerts = slice->numVerts;
	numElems = slice->numElems;
	firstVert = drawSurf->firstVboVert + slice->firstVert;
	firstElem = drawSurf->firstVboElem + slice->firstElem;
	if( shadowBits && shadowSlice->numElems ) {
		numShadowVerts = shadowSlice->numVerts;
		numShadowElems = shadowSlice->numElems;
		firstShadowVert = drawSurf->firstVboVert + shadowSlice->firstVert;
		firstShadowElem = drawSurf->firstVboElem + shadowSlice->firstElem;
	}
	else {
		shadowBits = 0;
		numShadowVerts = 0;
		numShadowElems = 0;
		firstShadowVert = 0;
		firstShadowElem = 0;
	}

	RB_BindVBO( drawSurf->vbo->index, GL_TRIANGLES );

	RB_SetDlightBits( dlightBits );

	RB_SetShadowBits( shadowBits );

	RB_SetLightstyle( drawSurf->superLightStyle );

	if( drawSurf->numInstances ) {
		RB_DrawElementsInstanced( firstVert, numVerts, firstElem, numElems, 
			firstShadowVert, numShadowVerts, firstShadowElem, numShadowElems,
			drawSurf->numInstances, drawSurf->instances );
	}
	else {
		RB_DrawElements( firstVert, numVerts, firstElem, numElems, 
			firstShadowVert, numShadowVerts, firstShadowElem, numShadowElems );
	}
}