Esempio n. 1
0
//==========================================================================
//
//  Calculate mirrorplane
//
//==========================================================================
void GLWall::MirrorPlane(secplane_t * plane, bool ceiling)
{
	if (!(gl.flags&RFL_NOSTENCIL))
	{
		if (ceiling && viewz >= plane->ZatPoint(viewx, viewy)) return;
		if (!ceiling && viewz <= plane->ZatPoint(viewx, viewy)) return;
		type=RENDERWALL_PLANEMIRROR;
		planemirror=plane;
		PutWall(0);
	}
}
Esempio n. 2
0
//==========================================================================
//
//  Calculate sky texture
//
//==========================================================================
void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect)
{
	FPortal *portal = sector->portals[plane];
	if (portal != NULL)
	{
		if (GLPortal::instack[1-plane]) return;
		type=RENDERWALL_SECTORSTACK;
		this->portal = portal;
	}
	else if (sector->GetTexture(plane)==skyflatnum)
	{
		GLSkyInfo skyinfo;
		ASkyViewpoint * skyboxx = sector->GetSkyBox(plane);

		// JUSTHIT is used as an indicator that a skybox is in use.
		// This is to avoid recursion

		if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor!=skyboxx && !(skyboxx->flags&MF_JUSTHIT))
		{
			type=RENDERWALL_SKYBOX;
			skybox=skyboxx;
		}
		else
		{
			int sky1 = sector->sky;
			memset(&skyinfo, 0, sizeof(skyinfo));
			if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT-1)))
			{
				const line_t *l = &lines[(sky1&(PL_SKYFLAT-1))-1];
				const side_t *s = l->sidedef[0];
				int pos;
				
				if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
				{
					pos = side_t::bottom;
				}
				else
				{
					pos = side_t::top;
				}

				FTextureID texno = s->GetTexture(pos);
				skyinfo.texture[0] = FMaterial::ValidateTexture(texno, false, true);
				if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky;
				skyinfo.skytexno1 = texno;
				skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos));
				skyinfo.y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos));
				skyinfo.mirrored = !l->args[2];
			}
			else
			{
			normalsky:
				if (level.flags&LEVEL_DOUBLESKY)
				{
					skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, false, true);
					skyinfo.x_offset[1] = GLRenderer->mSky1Pos;
					skyinfo.doublesky = true;
				}
				
				if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) &&
					sky2texture!=sky1texture)	// If both skies are equal use the scroll offset of the first!
				{
					skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, false, true);
					skyinfo.skytexno1=sky2texture;
					skyinfo.sky2 = true;
					skyinfo.x_offset[0] = GLRenderer->mSky2Pos;
				}
				else
				{
					skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, false, true);
					skyinfo.skytexno1=sky1texture;
					skyinfo.x_offset[0] = GLRenderer->mSky1Pos;
				}
			}
			if (skyfog>0) 
			{
				skyinfo.fadecolor=Colormap.FadeColor;
				skyinfo.fadecolor.a=0;
			}
			else skyinfo.fadecolor=0;

			type=RENDERWALL_SKY;
			sky=UniqueSkies.Get(&skyinfo);
		}
	}
	else if (allowreflect && sector->GetReflect(plane) > 0)
	{
		if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) ||
			(plane == sector_t::floor && viewz < -sector->floorplane.d)) return;
		type=RENDERWALL_PLANEMIRROR;
		planemirror = plane == sector_t::ceiling? &sector->ceilingplane : &sector->floorplane;
	}
	else return;
	PutWall(0);
}
Esempio n. 3
0
//==========================================================================
//
//  Calculate sky texture
//
//==========================================================================
void GLWall::SkyTexture(int sky1,ASkyViewpoint * skyboxx, bool ceiling)
{
	// JUSTHIT is used as an indicator that a skybox is in use.
	// This is to avoid recursion
	if (!gl_noskyboxes && !(gl.flags&RFL_NOSTENCIL) && skyboxx && viewactor!=skyboxx && !(skyboxx->flags&MF_JUSTHIT))
	{
		if (!skyboxx->Mate) 
		{
			type=RENDERWALL_SKYBOX;
			skybox=skyboxx;
		}
		else 
		{
			static GLSectorStackInfo stackinfo;
			if (ceiling && GLPortal::inlowerstack) return;
			if (!ceiling && GLPortal::inupperstack) return;
			type=RENDERWALL_SECTORSTACK;
			stackinfo.deltax = skyboxx->Mate->x - skyboxx->x;
			stackinfo.deltay = skyboxx->Mate->y - skyboxx->y;
			stackinfo.deltaz = 0;
			stackinfo.isupper= ceiling;
			stack=&stackinfo;
		}
	}
	else
	{
		if (skyboxx && skyboxx->Mate) return;

		// VC's optimizer totally screws up if this is made local...
		static GLSkyInfo skyinfo;

		memset(&skyinfo, 0, sizeof(skyinfo));
		if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT-1)) && !(gl.flags&RFL_NOSTENCIL))
		{
			const line_t *l = &lines[(sky1&(PL_SKYFLAT-1))-1];
			const side_t *s = &sides[l->sidenum[0]];
			int pos;
			
			if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
			{
				pos = side_t::bottom;
			}
			else
			{
				pos = side_t::top;
			}

			FTextureID texno = s->GetTexture(pos);
			skyinfo.texture[0] = FGLTexture::ValidateTexture(texno);
			if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky;
			skyinfo.skytexno1 = texno;
			skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos));
			skyinfo.y_offset = TO_GL(s->GetTextureYOffset(pos));
			skyinfo.mirrored = !l->args[2];
		}
		else
		{
		normalsky:
			if (level.flags&LEVEL_DOUBLESKY)
			{
				skyinfo.texture[1]=FGLTexture::ValidateTexture(sky1texture);
				if (!skyinfo.texture[1]) return;
				skyinfo.x_offset[1] = gl_sky1pos;
				skyinfo.doublesky = true;
			}
			
			if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT && !(gl.flags&RFL_NOSTENCIL)) || (level.flags&LEVEL_DOUBLESKY)) &&
				sky2texture!=sky1texture)	// If both skies are equal use the scroll offset of the first!
			{
				skyinfo.texture[0]=FGLTexture::ValidateTexture(sky2texture);
				skyinfo.skytexno1=sky2texture;
				skyinfo.x_offset[0] = gl_sky2pos;
			}
			else
			{
				skyinfo.texture[0]=FGLTexture::ValidateTexture(sky1texture);
				skyinfo.skytexno1=sky1texture;
				skyinfo.x_offset[0] = gl_sky1pos;
			}
			if (!skyinfo.texture[0]) return;

		}
		if (skyfog>0) 
		{
			skyinfo.fadecolor=Colormap.FadeColor;
			skyinfo.fadecolor.a=0;
		}
		else skyinfo.fadecolor=0;

		type=RENDERWALL_SKY;
		sky = &skyinfo;
	}
	PutWall(0);
}