Exemple #1
0
 /* ========================================================================= */
 void
 CL_RegisterTEntModels ( void )
 {
   cl_mod_explode = R_RegisterModel ( "models/objects/explode/tris.md2" );
   cl_mod_smoke = R_RegisterModel ( "models/objects/smoke/tris.md2" );
   cl_mod_flash = R_RegisterModel ( "models/objects/flash/tris.md2" );
   cl_mod_parasite_segment = R_RegisterModel ( "models/monsters/parasite/segment/tris.md2" );
   cl_mod_grapple_cable = R_RegisterModel ( "models/ctf/segment/tris.md2" );
   cl_mod_parasite_tip = R_RegisterModel ( "models/monsters/parasite/tip/tris.md2" );
   cl_mod_explo4 = R_RegisterModel ( "models/objects/r_explode/tris.md2" );
   cl_mod_bfg_explo = R_RegisterModel ( "sprites/s_bfg2.sp2" );
   cl_mod_powerscreen = R_RegisterModel ( "models/items/armor/effect/tris.md2" );
   R_RegisterModel ( "models/objects/laser/tris.md2" );
   R_RegisterModel ( "models/objects/grenade2/tris.md2" );
   R_RegisterModel ( "models/weapons/v_machn/tris.md2" );
   R_RegisterModel ( "models/weapons/v_handgr/tris.md2" );
   R_RegisterModel ( "models/weapons/v_shotg2/tris.md2" );
   R_RegisterModel ( "models/objects/gibs/bone/tris.md2" );
   R_RegisterModel ( "models/objects/gibs/sm_meat/tris.md2" );
   R_RegisterModel ( "models/objects/gibs/bone2/tris.md2" );
   Draw_FindPic ( "w_machinegun" );
   Draw_FindPic ( "a_bullets" );
   Draw_FindPic ( "i_health" );
   Draw_FindPic ( "a_grenades" );
   cl_mod_explo4_big = R_RegisterModel ( "models/objects/r_explode2/tris.md2" );
   cl_mod_lightning = R_RegisterModel ( "models/proj/lightning/tris.md2" );
   cl_mod_heatbeam = R_RegisterModel ( "models/proj/beam/tris.md2" );
   cl_mod_monster_heatbeam = R_RegisterModel ( "models/proj/widowbeam/tris.md2" );
 }
Exemple #2
0
/*
=============
Draw_Pic
=============
*/
void Draw_Pic (int x, int y, char *pic)
{
	image_t *gl;

	gl = Draw_FindPic (pic);
	if (!gl)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}
	if (scrap_dirty)
		Scrap_Upload ();

	GL_Bind (gl->texnum);
	
	xeeBegin (GL_QUADS);
	xeeTexCoord2f (gl->sl, gl->tl);
	xeeVertex2f (x, y);
	xeeTexCoord2f (gl->sh, gl->tl);
	xeeVertex2f (x+gl->width, y);
	xeeTexCoord2f (gl->sh, gl->th);
	xeeVertex2f (x+gl->width, y+gl->height);
	xeeTexCoord2f (gl->sl, gl->th);
	xeeVertex2f (x, y+gl->height);
	
	xeeEnd ();
	xeeSubmit();
}
Exemple #3
0
/*
=============
Draw_Pic
=============
*/
void Draw_Pic (int x, int y, char *pic)
{
	image_t *gl;

	gl = Draw_FindPic (pic);
	if (!gl)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}
	if (scrap_dirty)
		Scrap_Upload ();

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha)
		qglDisable (GL_ALPHA_TEST);

	GL_Bind (gl->texnum);
	qglBegin (GL_QUADS);
	qglTexCoord2f (gl->sl, gl->tl);
	qglVertex2f (x, y);
	qglTexCoord2f (gl->sh, gl->tl);
	qglVertex2f (x+gl->width, y);
	qglTexCoord2f (gl->sh, gl->th);
	qglVertex2f (x+gl->width, y+gl->height);
	qglTexCoord2f (gl->sl, gl->th);
	qglVertex2f (x, y+gl->height);
	qglEnd ();

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) )  && !gl->has_alpha)
		qglEnable (GL_ALPHA_TEST);
}
Exemple #4
0
/*
=============
Draw_TileClear

This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void Draw_TileClear (int x, int y, int w, int h, char *pic)
{
	image_t	*image;

	image = Draw_FindPic (pic);
	if (!image)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) )  && !image->has_alpha)
		qglDisable (GL_ALPHA_TEST);

	GL_Bind (image->texnum);
	qglBegin (GL_QUADS);
	qglTexCoord2f (x/64.0, y/64.0);
	qglVertex2f (x, y);
	qglTexCoord2f ( (x+w)/64.0, y/64.0);
	qglVertex2f (x+w, y);
	qglTexCoord2f ( (x+w)/64.0, (y+h)/64.0);
	qglVertex2f (x+w, y+h);
	qglTexCoord2f ( x/64.0, (y+h)/64.0 );
	qglVertex2f (x, y+h);
	qglEnd ();

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) )  && !image->has_alpha)
		qglEnable (GL_ALPHA_TEST);
}
Exemple #5
0
/*
=============
Draw_TileClear

This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void Draw_TileClear (int x, int y, int w, int h, char *pic)
{
	image_t	*image;

	image = Draw_FindPic (pic);
	if (!image)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}

	GL_Bind (image->texnum);
	
	xeeBegin (GL_QUADS);
	xeeTexCoord2f (x/64.0, y/64.0);
	xeeVertex2f (x, y);
	xeeTexCoord2f ( (x+w)/64.0, y/64.0);
	xeeVertex2f (x+w, y);
	xeeTexCoord2f ( (x+w)/64.0, (y+h)/64.0);
	xeeVertex2f (x+w, y+h);
	xeeTexCoord2f ( x/64.0, (y+h)/64.0 );
	xeeVertex2f (x, y+h);
	
	xeeEnd ();
	xeeSubmit();
}
Exemple #6
0
/*
 * Allows rendering code to cache all needed sbar graphics
 */
void
SCR_TouchPics(void)
{
	int i, j;

	for (i = 0; i < 2; i++)
	{
		for (j = 0; j < 11; j++)
		{
			Draw_FindPic(sb_nums[i][j]);
		}
	}

	if (crosshair->value)
	{
		if ((crosshair->value > 3) || (crosshair->value < 0))
		{
			crosshair->value = 3;
		}

		Com_sprintf(crosshair_pic, sizeof(crosshair_pic), "ch%i",
				(int)(crosshair->value));
		Draw_GetPicSize(&crosshair_width, &crosshair_height, crosshair_pic);

		if (!crosshair_width)
		{
			crosshair_pic[0] = 0;
		}
	}
}
Exemple #7
0
/*
 * ============= Draw_StretchPic -- only used for drawing console...
 * =============
 */
void
Draw_StretchPic(int x, int y, int w, int h, char *pic, float alpha)
{
	image_t        *gl;

	gl = Draw_FindPic(pic);
	if (!gl) {
		ri.Con_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}
	if (scrap_dirty)
		Scrap_Upload();

	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION))
	    && !gl->has_alpha)
		qglDisable(GL_ALPHA_TEST);

	/* add alpha support */
	if (gl->has_alpha || alpha < 1) {
		qglDisable(GL_ALPHA_TEST);

		GL_Bind(gl->texnum);

		GL_TexEnv(GL_MODULATE);
		qglColor4f(1, 1, 1, alpha);
		qglEnable(GL_BLEND);
		qglDepthMask(false);
	} else
		GL_Bind(gl->texnum);

	qglBegin(GL_QUADS);
	qglTexCoord2f(gl->sl, gl->tl);
	qglVertex2f(x, y);
	qglTexCoord2f(gl->sh, gl->tl);
	qglVertex2f(x + w, y);
	qglTexCoord2f(gl->sh, gl->th);
	qglVertex2f(x + w, y + h);
	qglTexCoord2f(gl->sl, gl->th);
	qglVertex2f(x, y + h);
	qglEnd();

	/* add alpha support */
	if (gl->has_alpha || alpha < 1) {
		qglDepthMask(true);
		GL_TexEnv(GL_REPLACE);
		qglDisable(GL_BLEND);
		qglColor4f(1, 1, 1, 1);

		qglEnable(GL_ALPHA_TEST);
	}
	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION))
	    && !gl->has_alpha)
		qglEnable(GL_ALPHA_TEST);
}
Exemple #8
0
/*
=============
Draw_StretchPic
=============
*/
void Draw_StretchPic (int x, int y, int w, int h, const char *name, float alpha)
{
	image_t	*pic;

	pic = Draw_FindPic (name);
	if (!pic)
	{
		Com_Printf ("Can't find pic: %s\n", name);
		return;
	}
	Draw_StretchPicImplementation (x, y, w, h, pic);
}
Exemple #9
0
/*
=============
Draw_StretchPic
=============
*/
void Draw_StretchPic (int x, int y, int w, int h, char *name)
{
	image_t	*pic;

	pic = Draw_FindPic (name);
	if (!pic)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", name);
		return;
	}
	Draw_StretchPicImplementation (x, y, w, h, pic);
}
Exemple #10
0
/*
 * ============= Draw_Pic =============
 */
void
Draw_Pic(int x, int y, char *pic, float alpha)
{
	image_t        *gl;

	gl = Draw_FindPic(pic);
	if (!gl) {
		ri.Con_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}
	if (scrap_dirty)
		Scrap_Upload();

	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha)
		qglDisable(GL_ALPHA_TEST);

	/* add alpha support */
	{
		qglDisable(GL_ALPHA_TEST);

		qglBindTexture(GL_TEXTURE_2D, gl->texnum);

		GL_TexEnv(GL_MODULATE);
		qglColor4f(1, 1, 1, 0.999);	/* need <1 for trans to work */
		qglEnable(GL_BLEND);
		qglDepthMask(false);
	}

	GL_Bind(gl->texnum);
	qglBegin(GL_QUADS);
	qglTexCoord2f(gl->sl, gl->tl);
	qglVertex2f(x, y);
	qglTexCoord2f(gl->sh, gl->tl);
	qglVertex2f(x + gl->width, y);
	qglTexCoord2f(gl->sh, gl->th);
	qglVertex2f(x + gl->width, y + gl->height);
	qglTexCoord2f(gl->sl, gl->th);
	qglVertex2f(x, y + gl->height);
	qglEnd();

	/* add alpha support */
	{
		qglDepthMask(true);
		GL_TexEnv(GL_REPLACE);
		qglDisable(GL_BLEND);
		qglColor4f(1, 1, 1, 1);

		qglEnable(GL_ALPHA_TEST);
	}

	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha)
		qglEnable(GL_ALPHA_TEST);
}
Exemple #11
0
/*
=============
Draw_GetPicSize
=============
*/
void Draw_GetPicSize (int *w, int *h, char *pic)
{
	image_t *gl;

	gl = Draw_FindPic (pic);
	if (!gl)
	{
		*w = *h = -1;
		return;
	}
	*w = gl->width;
	*h = gl->height;
}
Exemple #12
0
void
Draw_InitLocal(void)
{
	/* load console characters (don't bilerp characters) */
	draw_chars = Draw_FindPic("conchars");
	if (!draw_chars)
		ri.Sys_Error(ERR_FATAL, "Couldn't load pics/conchars");

	GL_Bind(draw_chars->texnum);

	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	if (font_color->string) {
		RefreshFont();
	}
}
Exemple #13
0
void R_InitParticleTexture (void)
{
	int		x,y;
	byte	data[8][8][4];

	///
	// particle texture
	//
	for (x=0 ; x<8 ; x++)
	{
		for (y=0 ; y<8 ; y++)
		{
			data[y][x][0] = 255;
			data[y][x][1] = 255;
			data[y][x][2] = 255;
			data[y][x][3] = dottexture[x][y]; // c14 Just this line changes
		}
	}
	r_particletexture = Draw_FindPic("particle");   //c14 add this line

    if (!r_particletexture) {                                 //c14 add this line
		r_particletexture = GL_LoadPic ("***particle***", (byte *)data, 8, 8, it_sprite, 32);
    }                                                         //c14 add this line

	//
	// also use this for bad textures, but without alpha
	//
	for (x=0 ; x<8 ; x++)
	{
		for (y=0 ; y<8 ; y++)
		{
			data[y][x][0] = dottexture[x&3][y&3]*255;
			data[y][x][1] = 0; // dottexture[x&3][y&3]*255;
			data[y][x][2] = 0; //dottexture[x&3][y&3]*255;
			data[y][x][3] = 255;
		}
	}
	r_notexture = GL_LoadPic ("***r_notexture***", (byte *)data, 8, 8, it_wall, 32);

	//		--==OBSIDIAN UPDATE==--
	// Based on work by Carbon14
	r_shelltexture[0] = Draw_FindPic("shell/shell0");
	r_shelltexture[1] = Draw_FindPic("shell/shell1");
	r_shelltexture[2] = Draw_FindPic("shell/shell2");
	r_shelltexture[3] = Draw_FindPic("shell/shell3");
	r_shelltexture[4] = Draw_FindPic("shell/shell4");
	for (x = 0; x < 5; x++){
		if (!r_shelltexture[x])
		{
			r_shelltexture[x] = GL_LoadPic ("***shell***", (byte *)data, 8, 8, it_sprite, 32);
		}
	}
}
Exemple #14
0
/*
=============
Draw_StretchPic
=============
*/
void Draw_StretchPic (int x, int y, int w, int h, char *pic)
{
	image_t *gl;
	GLint previousMagFilter;

	gl = Draw_FindPic (pic);
	if (!gl)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}

	if (scrap_dirty)
		Scrap_Upload ();

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha)
		qglDisable (GL_ALPHA_TEST);

	GL_Bind (gl->texnum);

	qglGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &previousMagFilter );
	qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

	qglBegin (GL_QUADS);
	{
		qglTexCoord2f (gl->sl, gl->tl);
		qglVertex2f (x, y);
		qglTexCoord2f (gl->sh, gl->tl);
		qglVertex2f (x+w, y);
		qglTexCoord2f (gl->sh, gl->th);
		qglVertex2f (x+w, y+h);
		qglTexCoord2f (gl->sl, gl->th);
		qglVertex2f (x, y+h);
	}
	qglEnd ();

	qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, previousMagFilter );

	if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha)
		qglEnable (GL_ALPHA_TEST);
}
Exemple #15
0
/*
=============
Draw_TileClear

This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void Draw_TileClear (int x, int y, int w, int h, char *name)
{
	int			i, j;
	byte		*psrc;
	byte		*pdest;
	image_t		*pic;
	int			x2;

	if (x < 0)
	{
		w += x;
		x = 0;
	}
	if (y < 0)
	{
		h += y;
		y = 0;
	}
	if (x + w > vid.width)
		w = vid.width - x;
	if (y + h > vid.height)
		h = vid.height - y;
	if (w <= 0 || h <= 0)
		return;

	pic = Draw_FindPic (name);
	if (!pic)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", name);
		return;
	}
	x2 = x + w;
	pdest = vid.buffer + y*vid.rowbytes;
	for (i=0 ; i<h ; i++, pdest += vid.rowbytes)
	{
		psrc = pic->pixels[0] + pic->width * ((i+y)&63);
		for (j=x ; j<x2 ; j++)
			pdest[j] = psrc[j&63];
	}
}
Exemple #16
0
void
CL_ParseConfigString(void)
{
    int i, length;
    char *s;
    char olds[MAX_QPATH];

    i = MSG_ReadShort(&net_message);

    if ((i < 0) || (i >= MAX_CONFIGSTRINGS))
    {
        Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS");
    }

    s = MSG_ReadString(&net_message);

    Q_strlcpy(olds, cl.configstrings[i], sizeof(olds));

    length = strlen(s);
    if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0])*i - 1)
    {
        Com_Error(ERR_DROP, "CL_ParseConfigString: oversize configstring");
    }

    strcpy(cl.configstrings[i], s);

    /* do something apropriate */
    if ((i >= CS_LIGHTS) && (i < CS_LIGHTS + MAX_LIGHTSTYLES))
    {
        CL_SetLightstyle(i - CS_LIGHTS);
    }

    else if (i == CS_CDTRACK)
    {
        if (cl.refresh_prepped)
        {
#ifdef CDA
            CDAudio_Play((int)strtol(cl.configstrings[CS_CDTRACK],
                                     (char **)NULL, 10), true);
#endif

#ifdef OGG

            /* OGG/Vorbis */
            if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10)
            {
                char tmp[3] = "0";
                OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
            }
            else
            {
                OGG_ParseCmd(cl.configstrings[CS_CDTRACK]);
            }

#endif
        }
    }
    else if ((i >= CS_MODELS) && (i < CS_MODELS + MAX_MODELS))
    {
        if (cl.refresh_prepped)
        {
            cl.model_draw[i - CS_MODELS] = R_RegisterModel(cl.configstrings[i]);

            if (cl.configstrings[i][0] == '*')
            {
                cl.model_clip[i - CS_MODELS] = CM_InlineModel(cl.configstrings[i]);
            }

            else
            {
                cl.model_clip[i - CS_MODELS] = NULL;
            }
        }
    }
    else if ((i >= CS_SOUNDS) && (i < CS_SOUNDS + MAX_MODELS))
    {
        if (cl.refresh_prepped)
        {
            cl.sound_precache[i - CS_SOUNDS] =
                S_RegisterSound(cl.configstrings[i]);
        }
    }
    else if ((i >= CS_IMAGES) && (i < CS_IMAGES + MAX_MODELS))
    {
        if (cl.refresh_prepped)
        {
            cl.image_precache[i - CS_IMAGES] = Draw_FindPic(cl.configstrings[i]);
        }
    }
    else if ((i >= CS_PLAYERSKINS) && (i < CS_PLAYERSKINS + MAX_CLIENTS))
    {
        if (cl.refresh_prepped && strcmp(olds, s))
        {
            CL_ParseClientinfo(i - CS_PLAYERSKINS);
        }
    }
}
Exemple #17
0
/*
=============
Draw_Pic
=============
*/
void Draw_Pic (int x, int y, char *name)
{
	image_t			*pic;
	byte			*dest, *source;
	int				v, u;
	int				tbyte;
	int				height;

	pic = Draw_FindPic (name);
	if (!pic)
	{
		ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", name);
		return;
	}

	if ((x < 0) ||
		(x + pic->width > vid.width) ||
		(y + pic->height > vid.height))
		return;	//	ri.Sys_Error (ERR_FATAL,"Draw_Pic: bad coordinates");

	height = pic->height;
	source = pic->pixels[0];
	if (y < 0)
	{
		height += y;
		source += pic->width*-y;
		y = 0;
	}

	dest = vid.buffer + y * vid.rowbytes + x;

	if (!pic->transparent)
	{
		for (v=0 ; v<height ; v++)
		{
			memcpy (dest, source, pic->width);
			dest += vid.rowbytes;
			source += pic->width;
		}
	}
	else
	{
		if (pic->width & 7)
		{	// general
			for (v=0 ; v<height ; v++)
			{
				for (u=0 ; u<pic->width ; u++)
					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
						dest[u] = tbyte;

				dest += vid.rowbytes;
				source += pic->width;
			}
		}
		else
		{	// unwound
			for (v=0 ; v<height ; v++)
			{
				for (u=0 ; u<pic->width ; u+=8)
				{
					if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
						dest[u] = tbyte;
					if ( (tbyte=source[u+1]) != TRANSPARENT_COLOR)
						dest[u+1] = tbyte;
					if ( (tbyte=source[u+2]) != TRANSPARENT_COLOR)
						dest[u+2] = tbyte;
					if ( (tbyte=source[u+3]) != TRANSPARENT_COLOR)
						dest[u+3] = tbyte;
					if ( (tbyte=source[u+4]) != TRANSPARENT_COLOR)
						dest[u+4] = tbyte;
					if ( (tbyte=source[u+5]) != TRANSPARENT_COLOR)
						dest[u+5] = tbyte;
					if ( (tbyte=source[u+6]) != TRANSPARENT_COLOR)
						dest[u+6] = tbyte;
					if ( (tbyte=source[u+7]) != TRANSPARENT_COLOR)
						dest[u+7] = tbyte;
				}
				dest += vid.rowbytes;
				source += pic->width;
			}
		}
	}
}
Exemple #18
0
void
Draw_ScaledPic(int x, int y, float scale, float alpha, char *pic, float red, float green, float blue, qboolean fixcoords, qboolean repscale)
{
	float		xoff, yoff;
	image_t        *gl;

	gl = Draw_FindPic(pic);
	if (!gl) {
		ri.Con_Printf(PRINT_ALL, "Can't find pic: %s\n", pic);
		return;
	}
	if (scrap_dirty)
		Scrap_Upload();

	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha)
		qglDisable(GL_ALPHA_TEST);

	/* add alpha support */
	{
		qglDisable(GL_ALPHA_TEST);

		qglBindTexture(GL_TEXTURE_2D, gl->texnum);

		GL_TexEnv(GL_MODULATE);
		qglColor4f(red, green, blue, alpha);
		qglEnable(GL_BLEND);
		qglDepthMask(false);
	}

	/* NOTE: replace this with shaders as soon as they are supported */
	if (repscale)
		scale *= gl->replace_scale;	/* scale down if replacing a pcx image */

	if (fixcoords) {	/* Knightmare- whether to adjust coordinates for scaling */

		xoff = (gl->width * scale - gl->width) / 2;
		yoff = (gl->height * scale - gl->height) / 2;

		GL_Bind(gl->texnum);
		qglBegin(GL_QUADS);
		qglTexCoord2f(gl->sl, gl->tl);
		qglVertex2f(x - xoff, y - yoff);
		qglTexCoord2f(gl->sh, gl->tl);
		qglVertex2f(x + gl->width + xoff, y - yoff);
		qglTexCoord2f(gl->sh, gl->th);
		qglVertex2f(x + gl->width + xoff, y + gl->height + yoff);
		qglTexCoord2f(gl->sl, gl->th);
		qglVertex2f(x - xoff, y + gl->height + yoff);
		qglEnd();

	} else {
		xoff = gl->width * scale - gl->width;
		yoff = gl->height * scale - gl->height;

		GL_Bind(gl->texnum);
		qglBegin(GL_QUADS);
		qglTexCoord2f(gl->sl, gl->tl);
		qglVertex2f(x, y);
		qglTexCoord2f(gl->sh, gl->tl);
		qglVertex2f(x + gl->width + xoff, y);
		qglTexCoord2f(gl->sh, gl->th);
		qglVertex2f(x + gl->width + xoff, y + gl->height + yoff);
		qglTexCoord2f(gl->sl, gl->th);
		qglVertex2f(x, y + gl->height + yoff);
		qglEnd();
	}

	/* add alpha support */
	{
		qglDepthMask(true);
		GL_TexEnv(GL_REPLACE);
		qglDisable(GL_BLEND);
		qglColor4f(1, 1, 1, 1);

		qglEnable(GL_ALPHA_TEST);
	}

	if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha)
		qglEnable(GL_ALPHA_TEST);
}
Exemple #19
0
/*
=============
Draw_Pic
=============
*/
void Draw_Pic (int x, int y, const char *name, float alpha)
{
	image_t			*pic;
	pixel_t			*dest, *source;
	int				v, u;
	pixel_t			tpixel;
	int				height;

	pic = Draw_FindPic (name);
	if (!pic)
	{
		Com_Printf ("Can't find pic: %s\n", name);
		return;
	}

	if ((x < 0) ||
		(x + pic->width > vid.width) ||
		(y + pic->height > vid.height))
		return;	//	Sys_Error ("Draw_Pic: bad coordinates");

	height = pic->height;
	source = pic->pixels[0];
	if (y < 0)
	{
		height += y;
		source += pic->width*-y;
		y = 0;
	}

	dest = vid.buffer + y * vid.rowpixels + x;

	if (!pic->transparent)
	{
		for (v=0 ; v<height ; v++)
		{
			memcpy (dest, source, pic->width * sizeof (pixel_t));
			dest += vid.rowpixels;
			source += pic->width;
		}
	}
	else
	{
		if (pic->width & 7)
		{	// general
			for (v=0 ; v<height ; v++)
			{
				for (u=0 ; u<pic->width ; u++)
					if ( (tpixel=source[u]).c != TRANSPARENT_COLOR)
						dest[u] = tpixel;

				dest += vid.rowpixels;
				source += pic->width;
			}
		}
		else
		{	// unwound
			for (v=0 ; v<height ; v++)
			{
				for (u=0 ; u<pic->width ; u+=8)
				{
					if ( (tpixel=source[u]).c != TRANSPARENT_COLOR)
						dest[u] = tpixel;
					if ( (tpixel=source[u+1]).c != TRANSPARENT_COLOR)
						dest[u+1] = tpixel;
					if ( (tpixel=source[u+2]).c != TRANSPARENT_COLOR)
						dest[u+2] = tpixel;
					if ( (tpixel=source[u+3]).c != TRANSPARENT_COLOR)
						dest[u+3] = tpixel;
					if ( (tpixel=source[u+4]).c != TRANSPARENT_COLOR)
						dest[u+4] = tpixel;
					if ( (tpixel=source[u+5]).c != TRANSPARENT_COLOR)
						dest[u+5] = tpixel;
					if ( (tpixel=source[u+6]).c != TRANSPARENT_COLOR)
						dest[u+6] = tpixel;
					if ( (tpixel=source[u+7]).c != TRANSPARENT_COLOR)
						dest[u+7] = tpixel;
				}
				dest += vid.rowpixels;
				source += pic->width;
			}
		}
	}
}
Exemple #20
0
/*
===============
Draw_InitLocal
===============
*/
void Draw_InitLocal (void)
{
	draw_chars = Draw_FindPic ("conchars");
}
Exemple #21
0
/*
================
CL_ParseConfigString
================
*/
void CL_ParseConfigString (sizebuf_t *msg)
{
	int		i, length;
	char	*s;
	char	olds[MAX_QPATH];

	i = MSG_ReadShort (msg);
	if ((unsigned)i >= MAX_CONFIGSTRINGS)
		Com_Error (ERR_DROP, "configstring > MAX_CONFIGSTRINGS");

	Q_strncpyz (olds, cl.configstrings[i], sizeof(olds));

	s = MSG_ReadString(msg);

	length = strlen(s);

	if (i != CS_NAME && i < CS_GENERAL)
	{
		if (i >= CS_STATUSBAR && i < CS_AIRACCEL)
		{
			Q_strncpyz(cl.configstrings[i], s, MAX_QPATH * (CS_AIRACCEL - i));
		}
		else
		{
			if (length >= MAX_QPATH)
				Com_Printf ("WARNING: Configstring %d of length %d exceeds MAX_QPATH.\n", i, length);
			Q_strncpyz(cl.configstrings[i], s, MAX_QPATH);
		}
	}
	else
	{
		Q_strncpyz(cl.configstrings[i], s, MAX_QPATH * (MAX_CONFIGSTRINGS - i));
	}

	// do something apropriate
	if(i == CS_AIRACCEL)
	{
		cl.pmp.airaccelerate = atoi(cl.configstrings[CS_AIRACCEL]) ? true : false;
	}
	else if (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES)
	{
		CL_SetLightstyle (i - CS_LIGHTS);
	}
	else if (i == CS_CDTRACK)
	{
#ifdef CD_AUDIO
		if (cl.refresh_prepped)
			CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
#endif
	}
	else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS)
	{
		if( i == CS_MODELS + 1 ) {
			if( length > 9 ) {
				Q_strncpyz( cls.mapname, s + 5, sizeof( cls.mapname ) ); // skip "maps/"
				cls.mapname[strlen( cls.mapname ) - 4] = 0; // cut off ".bsp"
			}

		}
		if (cl.refresh_prepped)
		{
			cl.model_draw[i-CS_MODELS] = R_RegisterModel (cl.configstrings[i]);
			if (cl.configstrings[i][0] == '*')
				cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]);
			else
				cl.model_clip[i-CS_MODELS] = NULL;
		}
	}
	else if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_MODELS)
	{
		if (cl.refresh_prepped)
			cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]);
	}
	else if (i >= CS_IMAGES && i < CS_IMAGES+MAX_MODELS)
	{
		if (cl.refresh_prepped)
			cl.image_precache[i-CS_IMAGES] = Draw_FindPic (cl.configstrings[i]);
	}
	else if (i == CS_MAXCLIENTS)
	{
		cl.maxclients = atoi(cl.configstrings[CS_MAXCLIENTS]);
		clamp(cl.maxclients, 0, MAX_CLIENTS);
	}
	else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS)
	{
		if (cl.refresh_prepped && strcmp(olds, s))
			CL_ParseClientinfo (i-CS_PLAYERSKINS);
	}
}
Exemple #22
0
void
CL_LoadClientinfo(clientinfo_t *ci, char *s)
{
    int i;
    char *t;
    char model_name[MAX_QPATH];
    char skin_name[MAX_QPATH];
    char model_filename[MAX_QPATH];
    char skin_filename[MAX_QPATH];
    char weapon_filename[MAX_QPATH];

    Q_strlcpy(ci->cinfo, s, sizeof(ci->cinfo));
    s = ci->cinfo;

    /* isolate the player's name */
    Q_strlcpy(ci->name, s, sizeof(ci->name));
    t = strstr(s, "\\");

    if (t)
    {
        ci->name[t - s] = 0;
        s = t + 1;
    }

    if (cl_noskins->value || (*s == 0))
    {
        strcpy(model_filename, "players/male/tris.md2");
        strcpy(weapon_filename, "players/male/weapon.md2");
        strcpy(skin_filename, "players/male/grunt.pcx");
        strcpy(ci->iconname, "/players/male/grunt_i.pcx");
        ci->model = R_RegisterModel(model_filename);
        memset(ci->weaponmodel, 0, sizeof(ci->weaponmodel));
        ci->weaponmodel[0] = R_RegisterModel(weapon_filename);
        ci->skin = R_RegisterSkin(skin_filename);
        ci->icon = Draw_FindPic(ci->iconname);
    }
    else
    {
        /* isolate the model name */
        strcpy(model_name, s);
        t = strstr(model_name, "/");

        if (!t)
        {
            t = strstr(model_name, "\\");
        }

        if (!t)
        {
            t = model_name;
        }

        *t = 0;

        /* isolate the skin name */
        strcpy(skin_name, s + strlen(model_name) + 1);

        /* model file */
        Com_sprintf(model_filename, sizeof(model_filename),
                    "players/%s/tris.md2", model_name);
        ci->model = R_RegisterModel(model_filename);

        if (!ci->model)
        {
            strcpy(model_name, "male");
            Com_sprintf(model_filename, sizeof(model_filename),
                        "players/male/tris.md2");
            ci->model = R_RegisterModel(model_filename);
        }

        /* skin file */
        Com_sprintf(skin_filename, sizeof(skin_filename),
                    "players/%s/%s.pcx", model_name, skin_name);
        ci->skin = R_RegisterSkin(skin_filename);

        /* if we don't have the skin and the model wasn't male,
         * see if the male has it (this is for CTF's skins) */
        if (!ci->skin && Q_stricmp(model_name, "male"))
        {
            /* change model to male */
            strcpy(model_name, "male");
            Com_sprintf(model_filename, sizeof(model_filename),
                        "players/male/tris.md2");
            ci->model = R_RegisterModel(model_filename);

            /* see if the skin exists for the male model */
            Com_sprintf(skin_filename, sizeof(skin_filename),
                        "players/%s/%s.pcx", model_name, skin_name);
            ci->skin = R_RegisterSkin(skin_filename);
        }

        /* if we still don't have a skin, it means that the male model didn't have
         * it, so default to grunt */
        if (!ci->skin)
        {
            /* see if the skin exists for the male model */
            Com_sprintf(skin_filename, sizeof(skin_filename),
                        "players/%s/grunt.pcx", model_name);
            ci->skin = R_RegisterSkin(skin_filename);
        }

        /* weapon file */
        for (i = 0; i < num_cl_weaponmodels; i++)
        {
            Com_sprintf(weapon_filename, sizeof(weapon_filename),
                        "players/%s/%s", model_name, cl_weaponmodels[i]);
            ci->weaponmodel[i] = R_RegisterModel(weapon_filename);

            if (!ci->weaponmodel[i] && (strcmp(model_name, "cyborg") == 0))
            {
                /* try male */
                Com_sprintf(weapon_filename, sizeof(weapon_filename),
                            "players/male/%s", cl_weaponmodels[i]);
                ci->weaponmodel[i] = R_RegisterModel(weapon_filename);
            }

            if (!cl_vwep->value)
            {
                break; /* only one when vwep is off */
            }
        }

        /* icon file */
        Com_sprintf(ci->iconname, sizeof(ci->iconname),
                    "/players/%s/%s_i.pcx", model_name, skin_name);
        ci->icon = Draw_FindPic(ci->iconname);
    }

    /* must have loaded all data types to be valid */
    if (!ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0])
    {
        ci->skin = NULL;
        ci->icon = NULL;
        ci->model = NULL;
        ci->weaponmodel[0] = NULL;
        return;
    }
}
Exemple #23
0
/*
================
CL_LoadClientinfo

================
*/
void CL_LoadClientinfo (clientinfo_t *ci, char *s)
{
	int			i = 0;
	char		*t;
	char		model_name[MAX_QPATH];
	char		skin_name[MAX_QPATH];
	char		model_filename[MAX_QPATH];
	char		skin_filename[MAX_QPATH];
	char		weapon_filename[MAX_QPATH];

	Q_strncpyz (ci->cinfo, s, sizeof(ci->cinfo));

	// isolate the player's name
	Q_strncpyz (ci->name, s, sizeof(ci->name));

	t = strchr(s, '\\');
	if (t) {
		if (t - s >= sizeof(ci->name)-1) {
			i = -1;
		} else {
			ci->name[t-s] = 0;
			s = t+1;
		}
	}
	t = s;
	while (*t) {
		if (*t <= 32) {
			i = -1;
			break;
		}
		t++;
	}

	if (cl_noskins->integer || *s == 0 || i == -1)
	{
		strcpy (model_filename, "players/male/tris.md2");
		strcpy (weapon_filename, "players/male/weapon.md2");
		strcpy (skin_filename, "players/male/grunt.pcx");
		strcpy (ci->iconname, "/players/male/grunt_i.pcx");
		ci->model = R_RegisterModel (model_filename);
		memset(ci->weaponmodel, 0, sizeof(ci->weaponmodel));
		ci->weaponmodel[0] = R_RegisterModel (weapon_filename);
		ci->skin = R_RegisterSkin (skin_filename);
		ci->icon = Draw_FindPic (ci->iconname);
	}
	else
	{
		// isolate the model name
		Q_strncpyz (model_name, s, sizeof(model_name));
		t = strchr(model_name, '/');
		if (!t)
			t = strchr(model_name, '\\');
		
		if (!t) {
			memcpy (model_name, "male\0grunt\0\0\0\0\0\0", 16);
			s = "male\\grunt\0";
		}
		else {
			*t = 0;
		}

		// isolate the skin name
		Q_strncpyz(skin_name, s + strlen(model_name) + 1, sizeof(skin_name));

		// model file
		Com_sprintf (model_filename, sizeof(model_filename), "players/%s/tris.md2", model_name);
		ci->model = R_RegisterModel (model_filename);
		if (!ci->model)
		{
			strcpy(model_name, "male");
			strcpy(model_filename, "players/male/tris.md2");
			ci->model = R_RegisterModel (model_filename);
		}

		// skin file
		Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/%s.pcx", model_name, skin_name);
		ci->skin = R_RegisterSkin (skin_filename);

		// if we don't have the skin and the model wasn't male,
		// see if the male has it (this is for CTF's skins)
 		if (!ci->skin && Q_stricmp(model_name, "male"))
		{
			// change model to male
			strcpy(model_name, "male");
			strcpy(model_filename, "players/male/tris.md2");
			ci->model = R_RegisterModel (model_filename);

			// see if the skin exists for the male model
			Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/%s.pcx", model_name, skin_name);
			ci->skin = R_RegisterSkin (skin_filename);
		}

		// if we still don't have a skin, it means that the male model didn't have
		// it, so default to grunt
		if (!ci->skin) {
			// see if the skin exists for the male model
			Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/grunt.pcx", model_name);
			ci->skin = R_RegisterSkin (skin_filename);
		}

		// weapon file
		for (i = 0; i < num_cl_weaponmodels; i++) {
			Com_sprintf (weapon_filename, sizeof(weapon_filename), "players/%s/%s", model_name, cl_weaponmodels[i]);
			ci->weaponmodel[i] = R_RegisterModel(weapon_filename);
			if (!ci->weaponmodel[i] && strcmp(model_name, "cyborg") == 0) {
				// try male
				Com_sprintf (weapon_filename, sizeof(weapon_filename), "players/male/%s", cl_weaponmodels[i]);
				ci->weaponmodel[i] = R_RegisterModel(weapon_filename);
			}
			if (!cl_vwep->integer)
				break; // only one when vwep is off
		}

		// icon file
		Com_sprintf (ci->iconname, sizeof(ci->iconname), "/players/%s/%s_i.pcx", model_name, skin_name);
		ci->icon = Draw_FindPic (ci->iconname);
	}

	// must have loaded all data types to be valud
	if (!ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0])
	{
		ci->skin = NULL;
		ci->icon = NULL;
		ci->model = NULL;
		ci->weaponmodel[0] = NULL;
		return;
	}
}