Пример #1
0
/*
=================
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);
}
Пример #2
0
/*
=================
R_DrawSkyChain
=================
*/
void R_DrawSkyChain (msurface_t *s)
{
    GL_Use (gl_polygon1textureprogram);
    
    glUniformMatrix4fv(gl_polygon1textureprogram_transform, 1, 0, gl_polygon_matrix);

    msurface_t	*fa;

	GL_DisableMultitexture();

	// used when gl_texsort is on
	GL_Bind(solidskytexture);
	speedscale = realtime*8;
	speedscale -= (int)speedscale & ~127 ;

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

	glEnable (GL_BLEND);
	GL_Bind (alphaskytexture);
	speedscale = realtime*16;
	speedscale -= (int)speedscale & ~127 ;

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

	glDisable (GL_BLEND);
}
Пример #3
0
/*
===============
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);
}
Пример #4
0
/*
=================
R_DrawSkyChain
=================
*/
void
R_DrawSkyChain(msurface_t *s)
{
    msurface_t *fa;
    texture_t *t = s->texinfo->texture;

    if (gl_mtexable) {
	GL_SelectTexture(GL_TEXTURE0_ARB);
	GL_Bind(t->gl_texturenum);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	GL_EnableMultitexture();
	GL_Bind(t->gl_texturenum_alpha);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

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

	speedscale2 = realtime * 16;
	speedscale2 -= (int)speedscale2 & ~127;

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

	GL_DisableMultitexture();

    } else {
	GL_DisableMultitexture();

	GL_Bind(t->gl_texturenum);
	speedscale = realtime * 8;
	speedscale -= (int)speedscale & ~127;

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

	glEnable(GL_BLEND);
	GL_Bind(t->gl_texturenum_alpha);
	speedscale = realtime * 16;
	speedscale -= (int)speedscale & ~127;

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

	glDisable(GL_BLEND);
    }
}
Пример #5
0
/*
	R_DrawSkyChain
*/
void
R_DrawSkyChain ( msurface_t *s )
{
	msurface_t	*fa;

	int		i;
	vec3_t	verts[MAX_CLIP_VERTS];
	glpoly_t	*p;

	if (r_sky->value) {
		c_sky = 0;
		GL_Bind(solidskytexture);

		// calculate vertex values for sky box
		for (fa=s ; fa ; fa=fa->texturechain) {
			for (p=fa->polys ; p ; p=p->next) {
				for (i=0 ; i<p->numverts ; i++) {
					VectorSubtract (p->verts[i], r_origin, verts[i]);
				}
				ClipSkyPolygon (p->numverts, verts[0], 0);
			}
		}
	} else {
		GL_DisableMultitexture();

		// used when gl_texsort is on
		GL_Bind(solidskytexture);
		speedscale = realtime*8;
		speedscale -= (int)speedscale & ~127 ;

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

		glEnable (GL_BLEND);
		GL_Bind (alphaskytexture);
		speedscale = realtime*16;
		speedscale -= (int)speedscale & ~127 ;

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

		glDisable (GL_BLEND);
	}
}
Пример #6
0
/*
===============
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)
{
	GL_DisableMultitexture();

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

	EmitSkyPolys (fa);

	glEnable (GL_BLEND);
	GL_Bind (alphaskytexture);
	speedscale = realtime*16;
	speedscale -= (int)speedscale & ~127 ;

	EmitSkyPolys (fa);

	glDisable (GL_BLEND);
}
Пример #7
0
/*
===============
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)
{
    texture_t *t = fa->texinfo->texture;

    GL_DisableMultitexture();

    GL_Bind(t->gl_texturenum);
    speedscale = realtime * 8;
    speedscale -= (int)speedscale & ~127;

    EmitSkyPolys(fa);

    glEnable(GL_BLEND);
    GL_Bind(t->gl_texturenum_alpha);
    speedscale = realtime * 16;
    speedscale -= (int)speedscale & ~127;

    EmitSkyPolys(fa);

    glDisable(GL_BLEND);
}
Пример #8
0
/*
=================
R_DrawSkyChain
=================
*/
void R_DrawSkyChain (msurface_t *s)
{
	msurface_t	*fa;

	GL_DisableMultitexture();

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

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

	QGX_Blend(TRUE);
	GL_Bind0 (alphaskytexture);
	speedscale = realtime*16;
	speedscale -= (int)speedscale & ~127 ;

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

	QGX_Blend(FALSE);
}
Пример #9
0
/*
=================
R_DrawSkyChain
=================
*/
void R_DrawSkyChain (msurface_t *s)
{
    msurface_t  *fa;

    GL_DisableMultitexture();

    // used when gl_texsort is on
    GL_Bind(solidskytexture);
    speedscale = realtime*8;
    speedscale -= (int)speedscale & ~127 ;

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

    glEnable (GL_BLEND);
    GL_Bind (alphaskytexture);
    speedscale = realtime*16;
    speedscale -= (int)speedscale & ~127 ;

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

    glDisable (GL_BLEND);
}
Пример #10
0
/*
================
R_DrawSequentialPoly

Systems that have fast state and texture changes can
just do everything as it passes with no need to sort
================
*/
EXPORT void R_DrawSequentialPoly (msurface_t *s, int lightmap_textures,
                           qboolean * lightmap_modified, 
                           glRect_t * lightmap_rectchange, byte * lightmaps,
                           int lightmap_bytes, int solidskytexture, 
                           float * speedscale, int alphaskytexture, 
                           qboolean gl_mtexable, int currenttexture,
                           int * cnttextures, double realtime, 
                           lpMTexFUNC qglMTexCoord2fSGIS, int gl_lightmap_format,
                           lpSelTexFUNC qglSelectTextureSGIS, vec3_t r_origin )
{
	glpoly_t	*p;
	float		*v;
	int			i;
	texture_t	*t;
	vec3_t		nv;
	glRect_t	*theRect;

	//
	// normal lightmaped poly
	//

	if (! (s->flags & (SURF_DRAWSKY|SURF_DRAWTURB|SURF_UNDERWATER) ) )
	{
		//R_RenderDynamicLightmaps (s);
		if (gl_mtexable) {
			p = s->polys;

			t = dr_R_TextureAnimation (s->texinfo->texture);
			// Binds world to texture env 0
			GL_SelectTexture(TEXTURE0_SGIS, gl_mtexable, qglSelectTextureSGIS, 
                currenttexture, cnttextures );
			dr_GL_Bind (t->gl_texturenum);
			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
			// Binds lightmap to texenv 1
			dr_GL_DisableMultitexture(); // Same as SelectTexture (TEXTURE1)
			dr_GL_Bind (lightmap_textures + s->lightmaptexturenum);
			i = s->lightmaptexturenum;
			if (lightmap_modified[i])
			{
				lightmap_modified[i] = false;
				theRect = &lightmap_rectchange[i];
				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, 
					BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE,
					lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes);
				theRect->l = BLOCK_WIDTH;
				theRect->t = BLOCK_HEIGHT;
				theRect->h = 0;
				theRect->w = 0;
			}
			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
			glBegin(GL_POLYGON);
			v = p->verts[0];
			for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
			{
				qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]);
				qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]);
				glVertex3fv (v);
			}
			glEnd ();
			return;
		} else {
			p = s->polys;

			t = dr_R_TextureAnimation (s->texinfo->texture);
			dr_GL_Bind (t->gl_texturenum);
			glBegin (GL_POLYGON);
			v = p->verts[0];
			for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
			{
				glTexCoord2f (v[3], v[4]);
				glVertex3fv (v);
			}
			glEnd ();

			dr_GL_Bind (lightmap_textures + s->lightmaptexturenum);
			glEnable (GL_BLEND);
			glBegin (GL_POLYGON);
			v = p->verts[0];
			for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
			{
				glTexCoord2f (v[5], v[6]);
				glVertex3fv (v);
			}
			glEnd ();

			glDisable (GL_BLEND);
		}

		return;
	}

	//
	// subdivided water surface warp
	//

	if (s->flags & SURF_DRAWTURB)
	{
		dr_GL_DisableMultitexture();
		dr_GL_Bind (s->texinfo->texture->gl_texturenum);
		EmitWaterPolys( s, realtime );
		return;
	}

	//
	// subdivided sky warp
	//
	if (s->flags & SURF_DRAWSKY)
	{
		dr_GL_DisableMultitexture();
		dr_GL_Bind (solidskytexture);
		*speedscale = realtime*8;
		*speedscale -= (int)(*speedscale) & ~127;

		EmitSkyPolys (s, *speedscale, r_origin);

		glEnable (GL_BLEND);
		dr_GL_Bind (alphaskytexture);
		*speedscale = realtime*16;
		*speedscale -= (int)(*speedscale) & ~127;
		EmitSkyPolys (s, *speedscale, r_origin);

		glDisable (GL_BLEND);
		return;
	}

	//
	// underwater warped with lightmap
	//
	//R_RenderDynamicLightmaps (s);
	if (gl_mtexable) {
		p = s->polys;

		t = dr_R_TextureAnimation (s->texinfo->texture);
    	GL_SelectTexture(TEXTURE0_SGIS, gl_mtexable, qglSelectTextureSGIS, 
                currenttexture, cnttextures );
		dr_GL_Bind (t->gl_texturenum);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
		dr_GL_DisableMultitexture();
		dr_GL_Bind (lightmap_textures + s->lightmaptexturenum);
		i = s->lightmaptexturenum;
		if (lightmap_modified[i])
		{
			lightmap_modified[i] = false;
			theRect = &lightmap_rectchange[i];
			glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, 
				BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE,
				lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes);
			theRect->l = BLOCK_WIDTH;
			theRect->t = BLOCK_HEIGHT;
			theRect->h = 0;
			theRect->w = 0;
		}
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
		glBegin (GL_TRIANGLE_FAN);
		v = p->verts[0];
		for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
		{
			qglMTexCoord2fSGIS (TEXTURE0_SGIS, v[3], v[4]);
			qglMTexCoord2fSGIS (TEXTURE1_SGIS, v[5], v[6]);

			nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime);
			nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime);
			nv[2] = v[2];

			glVertex3fv (nv);
		}
		glEnd ();

	} else {
		p = s->polys;

		t = dr_R_TextureAnimation (s->texinfo->texture);
		dr_GL_Bind (t->gl_texturenum);
		DrawGLWaterPoly( p, realtime );

		dr_GL_Bind (lightmap_textures + s->lightmaptexturenum);
		glEnable (GL_BLEND);
		DrawGLWaterPolyLightmap( p, realtime );
		glDisable (GL_BLEND);
	}
}
Пример #11
0
void R_DrawSkyChain (void) {
    msurface_t *fa;
    extern cvar_t gl_fogsky;
    if (!skychain)
        return;

    GL_DisableMultitexture();

    if (gl_fogenable.value && gl_fogsky.value)
        glEnable(GL_FOG);
    if (r_fastsky.value || cl.worldmodel->bspversion == HL_BSPVERSION) {
        glDisable (GL_TEXTURE_2D);

        glColor3ubv (r_skycolor.color);

        for (fa = skychain; fa; fa = fa->texturechain)
            EmitFlatPoly (fa);

        glEnable (GL_TEXTURE_2D);
        glColor3ubv (color_white);
    } else {
        if (gl_mtexable) {
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
            GL_Bind (solidskytexture);

            GL_EnableMultitexture();
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
            GL_Bind (alphaskytexture);

            speedscale = r_refdef2.time * 8;
            speedscale -= (int) speedscale & ~127;
            speedscale2 = r_refdef2.time * 16;
            speedscale2 -= (int) speedscale2 & ~127;

            for (fa = skychain; fa; fa = fa->texturechain)
                EmitSkyPolys (fa, true);

            GL_DisableMultitexture();
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        } else {
            GL_Bind(solidskytexture);
            speedscale = r_refdef2.time * 8;
            speedscale -= (int) speedscale & ~127;

            for (fa = skychain; fa; fa = fa->texturechain)
                EmitSkyPolys (fa, false);

            glEnable (GL_BLEND);
            GL_Bind (alphaskytexture);

            speedscale = r_refdef2.time * 16;
            speedscale -= (int) speedscale & ~127;

            for (fa = skychain; fa; fa = fa->texturechain)
                EmitSkyPolys (fa, false);

            glDisable (GL_BLEND);
        }
    }

    if (gl_fogenable.value && gl_fogsky.value)
        glDisable(GL_FOG);

    skychain = NULL;
    skychain_tail = &skychain;
}