/*
=================
R_DrawSkyChain
=================
*/
void R_DrawSkyChain (msurface_t *s)
{
	msurface_t	*fa;

	// note: 3dfx doesn't like GL_DECAL
	if (!is_3dfx && gl_multitexture.integer && gl_mtexable)
	{
		for (fa = s ; fa ; fa = fa->texturechain)
			EmitSkyPolysMulti (fa);
		return;
	}

	GL_Bind(solidskytexture);
	speedscale = realtime*8;
	speedscale -= (int)speedscale & ~127;

	for (fa = s ; fa ; fa = fa->texturechain)
		EmitSkyPolys (fa);

	glEnable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor4f_fp(1.0f, 1.0f, 1.0f, r_skyalpha.value);
	GL_Bind (alphaskytexture);
	speedscale = realtime*16;
	speedscale -= (int)speedscale & ~127;

	for (fa = s ; fa ; fa = fa->texturechain)
		EmitSkyPolys (fa);

	glDisable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
/*
===============
EmitBothSkyLayers

Does a sky warp on the pre-fragmented glpoly_t chain
This will be called for brushmodels, the world
will have them chained together.
===============
*/
void EmitBothSkyLayers (msurface_t *fa)
{
	// note: 3dfx doesn't like GL_DECAL
	if (!is_3dfx && gl_multitexture.integer && gl_mtexable)
	{
		EmitSkyPolysMulti (fa);
		return;
	}

	GL_Bind(solidskytexture);
	speedscale = realtime*8;
	speedscale -= (int)speedscale & ~127;

	EmitSkyPolys (fa);

	glEnable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor4f_fp(1.0f, 1.0f, 1.0f, r_skyalpha.value);
	GL_Bind (alphaskytexture);
	speedscale = realtime*16;
	speedscale -= (int)speedscale & ~127;

	EmitSkyPolys (fa);

	glDisable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
Beispiel #3
0
void R_DrawParticles (void)
{
	int		i, color;
	particle_t	*p;
	float		scale;
#define	SCALE_BASE	((p->type == pt_snow) ? p->count/10 : 1)

	GL_Bind(particletexture);
	glEnable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glBegin_fp (GL_TRIANGLES);

	VectorScale (vup, 1.5, r_pup);
	VectorScale (vright, 1.5, r_pright);

	for (p = active_particles ; p ; p = p->next)
	{
		// hack a scale up to keep particles from disapearing
		scale = (p->org[0] - r_origin[0])*vpn[0] +
			(p->org[1] - r_origin[1])*vpn[1] +
			(p->org[2] - r_origin[2])*vpn[2];
		if (scale < 20)
			scale = SCALE_BASE;
		else
			scale = SCALE_BASE + scale * 0.004;

	/* clamp color to 0-511: particle->type 10 and 11 (pt_c_explode
	 * and pt_c_explode2, e.g. Crusader's ice particles hitting a
	 * wall) lead to negative values, because R_UpdateParticles ()
	 * decrements their color against time. */
		color = ((int)p->color) & 0x01ff;
		if (color < 256)
			glColor3ubv_fp ((byte *)&d_8to24table[color]);
		else
			glColor4ubv_fp ((byte *)&d_8to24TranslucentTable[color-256]);

		// setup texture coordinates
		i = 0;
		if (p->type == pt_snow)
		{
			if (p->count >= 69)
				i = 3;	// happy snow!
			else if (p->count >= 40)
				i = 2;
			else if (p->count >= 30)
				i = 1;
		}

		glTexCoord2fv_fp (ptex_coord[i][0]);
		glVertex3fv_fp (p->org);
		glTexCoord2fv_fp (ptex_coord[i][1]);
		glVertex3f_fp (p->org[0] + r_pup[0]*scale, p->org[1] + r_pup[1]*scale, p->org[2] + r_pup[2]*scale);
		glTexCoord2fv_fp (ptex_coord[i][2]);
		glVertex3f_fp (p->org[0] + r_pright[0]*scale, p->org[1] + r_pright[1]*scale, p->org[2] + r_pright[2]*scale);
	}

	glEnd_fp ();
	glDisable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
void R_DrawSkyBox (void)
{
	int		i;

#if 0
	glEnable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor4f_fp (1,1,1,0.5);
	glDisable_fp (GL_DEPTH_TEST);
#endif
	for (i = 0; i < 6; i++)
	{
		if ( (skymins[0][i] >= skymaxs[0][i]) || (skymins[1][i] >= skymaxs[1][i]) )
			continue;

		GL_Bind(sky_tex[skytexorder[i]]);
#if 0
		skymins[0][i] = -1;
		skymins[1][i] = -1;
		skymaxs[0][i] = 1;
		skymaxs[1][i] = 1;
#endif
		glBegin_fp (GL_QUADS);
		MakeSkyVec (skymins[0][i], skymins[1][i], i);
		MakeSkyVec (skymins[0][i], skymaxs[1][i], i);
		MakeSkyVec (skymaxs[0][i], skymaxs[1][i], i);
		MakeSkyVec (skymaxs[0][i], skymins[1][i], i);
		glEnd_fp ();
	}
#if 0
	glDisable_fp (GL_BLEND);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glColor4f_fp (1,1,1,0.5);
	glEnable_fp (GL_DEPTH_TEST);
#endif
}
/*
=============
EmitSkyPolys
=============
*/
static void EmitSkyPolysMulti (msurface_t *fa)
{
	glpoly_t	*p;
	float		*v;
	int		i;
	float	s, ss, t, tt;
	vec3_t		dir;
	float		length;

	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	GL_Bind (solidskytexture);

	glActiveTextureARB_fp (GL_TEXTURE1_ARB);
	glTexEnvf_fp(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	glEnable_fp(GL_TEXTURE_2D);
	GL_Bind (alphaskytexture);

	for (p = fa->polys ; p ; p = p->next)
	{
		glBegin_fp (GL_POLYGON);
		for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE)
		{
			VectorSubtract (v, r_origin, dir);
			dir[2] *= 3;	// flatten the sphere

			length = dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2];
			length = sqrt (length);
			length = 6*63/length;

			dir[0] *= length;
			dir[1] *= length;

			s = (realtime*8 + dir[0]) * (1.0/128);
			t = (realtime*8 + dir[1]) * (1.0/128);

			ss = (realtime*16 + dir[0]) * (1.0/128);
			tt = (realtime*16 + dir[1]) * (1.0/128);

			glMultiTexCoord2fARB_fp (GL_TEXTURE0_ARB, s, t);
			glMultiTexCoord2fARB_fp (GL_TEXTURE1_ARB, ss, tt);
			glVertex3fv_fp (v);
		}
		glEnd_fp ();
	}

	glDisable_fp(GL_TEXTURE_2D);
	glActiveTextureARB_fp (GL_TEXTURE0_ARB);
}