Ejemplo n.º 1
0
void GLDrawInfo::DrawUnhandledMissingTextures()
{
	if (!(gl.flags&RFL_NOSTENCIL))	// needs a stencil to work!
	{
		// Set the drawing mode
		gl.DepthMask(false);							// don't write to Z-buffer!
		gl_EnableFog(true);
		gl.AlphaFunc(GL_GEQUAL,0.5f);
		gl.BlendFunc(GL_ONE,GL_ZERO);

		validcount++;
		for(int i=MissingUpperSegs.Size()-1; i>=0; i--)
		{
			int index = MissingUpperSegs[i].MTI_Index;
			if (index>=0 && MissingUpperTextures[index].seg==NULL) continue;

			seg_t * seg = MissingUpperSegs[i].seg;

			// already done!
			if (seg->linedef->validcount==validcount) continue;		// already done
			seg->linedef->validcount=validcount;
			if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < viewz) continue;	// out of sight
			//if (seg->frontsector->ceilingpic==skyflatnum) continue;

			// FIXME: The check for degenerate subsectors should be more precise
			if (seg->PartnerSeg && seg->PartnerSeg->Subsector->degenerate) continue;
			if (seg->backsector->transdoor) continue;
			if (seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum) continue;
			if (seg->backsector->CeilingSkyBox && seg->backsector->CeilingSkyBox->bAlways) continue;

			if (!gl_notexturefill) FloodUpperGap(seg);
		}

		validcount++;
		for(int i=MissingLowerSegs.Size()-1; i>=0; i--)
		{
			int index = MissingLowerSegs[i].MTI_Index;
			if (index>=0 && MissingLowerTextures[index].seg==NULL) continue;

			seg_t * seg = MissingLowerSegs[i].seg;

			// already done!
			if (seg->linedef->validcount==validcount) continue;		// already done
			seg->linedef->validcount=validcount;
			if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue;
			if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > viewz) continue;	// out of sight
			if (seg->backsector->transdoor) continue;
			if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue;
			if (seg->backsector->FloorSkyBox && seg->backsector->FloorSkyBox->bAlways) continue;

			if (!gl_notexturefill) FloodLowerGap(seg);
		}
	}
	MissingUpperTextures.Clear();
	MissingLowerTextures.Clear();
	MissingUpperSegs.Clear();
	MissingLowerSegs.Clear();

	gl.DepthMask(true);
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void GLSkyPortal::DrawContents()
{
	bool drawBoth = false;
	int CM_Index;
	PalEntry FadeColor(0,0,0,0);

	if (gl_fixedcolormap) 
	{
		CM_Index=gl_fixedcolormap<CM_LIMIT? gl_fixedcolormap:CM_DEFAULT;
	}
	else 
	{
		CM_Index=CM_DEFAULT;
		FadeColor=origin->fadecolor;
	}

	gl_EnableFog(false);
	gl.Disable(GL_ALPHA_TEST);
	gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	gl.PushMatrix();
	gl_SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1), true);

	if (origin->texture[0] && origin->texture[0]->bSkybox)
	{
		if (fixedcolormap)
		{						
			float rr,gg,bb;

			gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb);
			R=rr;
			G=gg;
			B=bb;
		}
		else R=G=B=1.f;

		RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index);
		gl.Enable(GL_ALPHA_TEST);
	}
	else
	{
		if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false;	

		gl.Translatef(0.f, -1000.f, 0.f);

		if (origin->texture[0])
		{
			gl_SetTextureMode(TM_OPAQUE);
			RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, CM_Index);
			gl_SetTextureMode(TM_MODULATE);
		}
		
		gl.Enable(GL_ALPHA_TEST);
		gl.AlphaFunc(GL_GEQUAL,0.05f);
		
		if (origin->doublesky && origin->texture[1])
		{
			secondlayer=true;
			RenderDome(0, origin->texture[1], origin->x_offset[1], origin->y_offset, CM_Index);
			secondlayer=false;
		}

		if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b))
		{
			gl_EnableTexture(false);
			foglayer=true;
			gl.Color4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f);
			RenderDome(0, NULL, 0, 0, CM_DEFAULT);
			gl_EnableTexture(true);
			foglayer=false;
		}
	}
	gl.PopMatrix();
}