Ejemplo n.º 1
0
static void ST_DrawPendingWeapon(void)
{
	int i;
	int x = 0;
	int wpn;

	if (!st_wpndisplay_show)
		return;

	GL_SetOrthoScale(0.5f);

	for (i = 0; i < NUMWEAPONS; i++) {
		rcolor color;

		if (plyr->weaponowned[i])
			color = D_RGBA(0xff, 0xff, 0x3f, st_wpndisplay_alpha);
		else
			color = WHITEALPHA(st_wpndisplay_alpha);

		Draw_Number(245 + x, 400, i, 0, color);
		x += 16;

	}

	if (plyr->pendingweapon == wp_nochange)
		wpn = plyr->readyweapon;
	else
		wpn = plyr->pendingweapon;

	Draw_BigText(235 + (wpn * 16), 404, WHITEALPHA(st_wpndisplay_alpha),
		     "/b");

	GL_SetOrthoScale(1.0f);
}
Ejemplo n.º 2
0
void Draw_Sprite2D(int type, int rot, int frame, int x, int y,
                   float scale, int pal, rcolor c) {
    spritedef_t    *sprdef;
    spriteframe_t *sprframe;
    float flip = 0.0f;
    int w;
    int h;
    int offsetx = 0;
    int offsety = 0;

    GL_SetState(GLSTATE_BLEND, 1);

    sprdef=&spriteinfo[type];
    sprframe = &sprdef->spriteframes[frame];

    GL_BindSpriteTexture(sprframe->lump[rot], pal);

    w = spritewidth[sprframe->lump[rot]];
    h = spriteheight[sprframe->lump[rot]];

    if(scale <= 1.0f) {
        if(sprframe->flip[rot]) {
            flip = 1.0f;
        }
        else {
            flip = 0.0f;
        }

        offsetx = (int)spriteoffset[sprframe->lump[rot]];
        offsety = (int)spritetopoffset[sprframe->lump[rot]];
    }

    GL_SetOrthoScale(scale);

    GL_SetupAndDraw2DQuad(flip ? (float)(x + offsetx) - w :
                          (float)x - offsetx, (float)y - offsety, w, h,
                          flip, 1.0f - flip, 0, 1.0f, c, 0);

    GL_SetOrthoScale(1.0f);

    cursprite = -1;
    curgfx = -1;

    GL_SetState(GLSTATE_BLEND, 0);
}
Ejemplo n.º 3
0
int Draw_Text(int x, int y, rcolor color, float scale,
              dboolean wrap, const char* string, ...) {
    int c;
    int i;
    int vi = 0;
    int    col;
    const float size = 0.03125f;
    float fcol, frow;
    int start = 0;
    dboolean fill = false;
    char msg[MAX_MESSAGE_SIZE];
    va_list    va;
    const int ix = x;

    va_start(va, string);
    vsprintf(msg, string, va);
    va_end(va);

    GL_SetState(GLSTATE_BLEND, 1);

    if(!r_fillmode.value) {
        dglEnable(GL_TEXTURE_2D);
        dglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        r_fillmode.value = 1.0f;
        fill = true;
    }

    GL_BindGfxTexture("SFONT", true);

    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
    dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);

    GL_SetOrthoScale(scale);
    GL_SetOrtho(0);

    dglSetVertex(vtxstring);

    for(i = 0, vi = 0; i < dstrlen(msg); i++, vi += 4) {
        c = toupper(msg[i]);
        if(c == '\t') {
            while(x % 64) {
                x++;
            }
            continue;
        }
        if(c == '\n') {
            y += ST_FONTWHSIZE;
            x = ix;
            continue;
        }
        if(c == 0x20) {
            if(wrap) {
                if(x > 192) {
                    y += ST_FONTWHSIZE;
                    x = ix;
                    continue;
                }
            }
        }
        else {
            start = (c - ST_FONTSTART);
            col = start & (ST_FONTNUMSET - 1);

            fcol = (col * size);
            frow = (start >= ST_FONTNUMSET) ? 0.5f : 0.0f;

            vtxstring[vi + 0].x     = (float)x;
            vtxstring[vi + 0].y     = (float)y;
            vtxstring[vi + 0].tu    = fcol + 0.0015f;
            vtxstring[vi + 0].tv    = frow + size;
            vtxstring[vi + 1].x     = (float)x + ST_FONTWHSIZE;
            vtxstring[vi + 1].y     = (float)y;
            vtxstring[vi + 1].tu    = (fcol + size) - 0.0015f;
            vtxstring[vi + 1].tv    = frow + size;
            vtxstring[vi + 2].x     = (float)x + ST_FONTWHSIZE;
            vtxstring[vi + 2].y     = (float)y + ST_FONTWHSIZE;
            vtxstring[vi + 2].tu    = (fcol + size) - 0.0015f;
            vtxstring[vi + 2].tv    = frow + 0.5f;
            vtxstring[vi + 3].x     = (float)x;
            vtxstring[vi + 3].y     = (float)y + ST_FONTWHSIZE;
            vtxstring[vi + 3].tu    = fcol + 0.0015f;
            vtxstring[vi + 3].tv    = frow + 0.5f;

            dglSetVertexColor(vtxstring + vi, color, 4);

            dglTriangle(vi + 0, vi + 1, vi + 2);
            dglTriangle(vi + 0, vi + 2, vi + 3);

            if(devparm) {
                vertCount += 4;
            }


        }
        x += ST_FONTWHSIZE;
    }

    if(vi) {
        dglDrawGeometry(vi, vtxstring);
    }

    GL_ResetViewport();

    if(fill) {
        dglDisable(GL_TEXTURE_2D);
        dglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        r_fillmode.value = 0.0f;
    }

    GL_SetState(GLSTATE_BLEND, 0);
    GL_SetOrthoScale(1.0f);

    return x;
}
Ejemplo n.º 4
0
void ST_Drawer(void)
{
	dboolean checkautomap;

	//
	// flash overlay
	//

	if ((st_flashoverlay.value ||
	     gl_max_texture_units <= 2 ||
	     r_texturecombiner.value <= 0) && flashcolor) {
		ST_FlashingScreen(st_flash_r, st_flash_g, st_flash_b,
				  st_flash_a);
	}

	if (iwadDemo)
		return;

	checkautomap = (!automapactive || am_overlay.value);

	//
	// draw hud
	//

	if (checkautomap && st_drawhud.value) {
		//Status graphics
		ST_DrawStatus();

		// original hud layout
		if (st_drawhud.value == 1) {
			//Draw Ammo counter
			if (weaponinfo[plyr->readyweapon].ammo != am_noammo)
				Draw_Number(160, 215,
					    plyr->ammo[weaponinfo
						       [plyr->readyweapon].
						       ammo], 0,
					    REDALPHA(0x7f));

			//Draw Health
			Draw_Number(49, 215, plyr->health, 0, REDALPHA(0x7f));

			//Draw Armor
			Draw_Number(271, 215, plyr->armorpoints, 0,
				    REDALPHA(0x7f));
		}
		// arranged hud layout
		else if (st_drawhud.value >= 2) {
			int wpn;

			if (plyr->pendingweapon == wp_nochange)
				wpn = plyr->readyweapon;
			else
				wpn = plyr->pendingweapon;

			// display ammo sprite
			switch (weaponinfo[wpn].ammo) {
			case am_clip:
				Draw_Sprite2D(SPR_CLIP, 0, 0, 524, 460, 0.5f, 0,
					      WHITEALPHA(0xC0));
				break;
			case am_shell:
				Draw_Sprite2D(SPR_SHEL, 0, 0, 524, 460, 0.5f, 0,
					      WHITEALPHA(0xC0));
				break;
			case am_misl:
				Draw_Sprite2D(SPR_RCKT, 0, 0, 524, 464, 0.5f, 0,
					      WHITEALPHA(0xC0));
				break;
			case am_cell:
				Draw_Sprite2D(SPR_CELL, 0, 0, 524, 464, 0.5f, 0,
					      WHITEALPHA(0xC0));
				break;
			default:
				break;
			}

			// display artifact sprites
			if (plyr->artifacts & (1 << ART_TRIPLE))
				Draw_Sprite2D(SPR_ART3, 0, 0, 260, 872, 0.275f,
					      0, WHITEALPHA(0xC0));

			if (plyr->artifacts & (1 << ART_DOUBLE))
				Draw_Sprite2D(SPR_ART2, 0, 0, 296, 872, 0.275f,
					      0, WHITEALPHA(0xC0));

			if (plyr->artifacts & (1 << ART_FAST))
				Draw_Sprite2D(SPR_ART1, 0, 0, 332, 872, 0.275f,
					      0, WHITEALPHA(0xC0));

			// display medkit/armor
			Draw_Sprite2D(SPR_MEDI, 0, 0, 50, 662, 0.35f, 0,
				      WHITEALPHA(0xC0));
			Draw_Sprite2D(SPR_ARM1, 0, 0, 50, 632, 0.35f, 0,
				      WHITEALPHA(0xC0));

			GL_SetOrthoScale(0.5f);

			//Draw Health
			Draw_Number(96, 448, plyr->health, 2, REDALPHA(0xC0));
			Draw_BigText(104, 450, REDALPHA(0xC0), "%");

			//Draw Armor
			Draw_Number(96, 424, plyr->armorpoints, 2,
				    REDALPHA(0xC0));
			Draw_BigText(104, 426, REDALPHA(0xC0), "%");

			//Draw Ammo counter
			if (weaponinfo[wpn].ammo != am_noammo)
				Draw_Number(550, 448,
					    plyr->ammo[weaponinfo[wpn].ammo], 1,
					    REDALPHA(0xC0));

			GL_SetOrthoScale(1.0f);
		}
	}
	//
	// draw messages
	//

	if (st_hasjmsg && st_regionmsg.value && plyr->messagepic >= 0) {
		ST_DrawJMessage(plyr->messagepic);
	} else if (st_msg && (int)m_messages.value) {
		Draw_Text(20, 20,
			  ST_MSGCOLOR(automapactive ? 0xff : st_msgalpha), 1,
			  false, st_msg);
	} else if (automapactive) {
		char str[128];
		mapdef_t *map = P_GetMapInfo(gamemap);

		if (map) {
			dmemset(&str, 0, 128);

			if (map->type == 2)
				sprintf(str, "%s", map->mapname);
			else
				sprintf(str, "Level %i: %s", gamemap,
					map->mapname);

			Draw_Text(20, 20, ST_MSGCOLOR(0xff), 1, false, str);
		}
	}
	//
	// draw chat text and player names
	//

	if (netgame) {
		ST_DrawChatText();

		if (checkautomap) {
			int i;

			for (i = 0; i < MAXPLAYERS; i++) {
				if (playeringame[i])
					ST_DisplayName(i);
			}
		}
	}
	//
	// draw crosshairs
	//

	if (st_crosshairs && !automapactive) {
		int x = (SCREENWIDTH / 2) - (ST_CROSSHAIRSIZE / 8);
		int y = (SCREENHEIGHT / 2) - (ST_CROSSHAIRSIZE / 8);
		int alpha = (int)st_crosshairopacity.value;

		if (alpha > 0xff)
			alpha = 0xff;

		if (alpha < 0)
			alpha = 0;

		ST_DrawCrosshair(x, y, (int)st_crosshair.value, 2,
				 WHITEALPHA(alpha));
	}
	//
	// use action context
	//

	if (p_usecontext.value) {
		if (P_UseLines(&players[consoleplayer], true)) {
			char usestring[16];
			char contextstring[32];
			float x;

#ifdef _USE_XINPUT		// XINPUT
			if (xgamepad.connected) {
				M_DrawXInputButton(140, 156, XINPUT_GAMEPAD_A);
				Draw_Text(213, 214, WHITEALPHA(0xA0), 0.75,
					  false, "Use");
			} else
#endif
			{
				G_GetActionBindings(usestring, "+use");
				sprintf(contextstring, "(%s)Use", usestring);

				x = (160 / 0.75f) -
				    ((dstrlen(contextstring) * 8) / 2);

				Draw_Text((int)x, 214, WHITEALPHA(0xA0), 0.75f,
					  false, contextstring);
			}
		}
	}
	//
	// damage indicator
	//

	if (p_damageindicator.value)
		ST_DrawDamageMarkers();

	//
	// display pending weapon
	//

	if (st_showpendingweapon.value)
		ST_DrawPendingWeapon();

	//
	// display stats in automap
	//

	if (st_showstats.value && automapactive) {
		Draw_Text(20, 430, WHITE, 0.5f, false,
			  "Monsters:  %i / %i", plyr->killcount, totalkills);
		Draw_Text(20, 440, WHITE, 0.5f, false,
			  "Items:     %i / %i", plyr->itemcount, totalitems);
		Draw_Text(20, 450, WHITE, 0.5f, false,
			  "Secrets:   %i / %i", plyr->secretcount, totalsecret);
		Draw_Text(20, 460, WHITE, 0.5f, false,
			  "Time:      %2.2d:%2.2d", (leveltime / TICRATE) / 60,
			  (leveltime / TICRATE) % 60);
	}
}
Ejemplo n.º 5
0
static void ST_DrawStatus(void)
{
	int lump;
	float width;
	float height;
	float uv[4][2];
	const rcolor color = D_RGBA(0x68, 0x68, 0x68, 0x90);

	GL_SetState(GLSTATE_BLEND, 1);
	lump = GL_BindGfxTexture("STATUS", true);

	width = (float)gfxwidth[lump];
	height = (float)gfxheight[lump];

	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);

	if (st_drawhud.value >= 2)
		GL_SetOrthoScale(0.725f);

	GL_SetOrtho(0);

	dglSetVertex(st_vtx);
	st_vtxcount = 0;

	if (st_drawhud.value == 1) {
		// health

		uv[0][0] = uv[3][0] = 0.0f;
		uv[0][1] = uv[1][1] = 0.0f;
		uv[1][0] = uv[2][0] = 40.0f / width;
		uv[2][1] = uv[3][1] = 6.0f / height;

		ST_DrawStatusItem(st_healthVertex, uv, color);

		// armor

		uv[0][0] = uv[3][0] = 40.0f / width;
		uv[0][1] = uv[1][1] = 0.0f;
		uv[1][0] = uv[2][0] = uv[0][0] + (36.0f / width);
		uv[2][1] = uv[3][1] = 6.0f / height;

		ST_DrawStatusItem(st_armorVertex, uv, color);
	}
	// cards

	uv[0][0] = uv[3][0] = 0.0f;
	uv[0][1] = uv[1][1] = 6.0f / height;
	uv[1][0] = uv[2][0] = 9.0f / width;
	uv[2][1] = uv[3][1] = 1.0f;

	ST_DrawKey(it_bluecard, uv, st_key1Vertex);

	uv[0][0] = uv[3][0] = 9.0f / width;
	uv[1][0] = uv[2][0] = (9.0f / width) * 2;

	ST_DrawKey(it_yellowcard, uv, st_key2Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 2;
	uv[1][0] = uv[2][0] = (9.0f / width) * 3;

	ST_DrawKey(it_redcard, uv, st_key3Vertex);

	// skulls

	uv[0][0] = uv[3][0] = (9.0f / width) * 3;
	uv[1][0] = uv[2][0] = (9.0f / width) * 4;

	ST_DrawKey(it_blueskull, uv, st_key1Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 4;
	uv[1][0] = uv[2][0] = (9.0f / width) * 5;

	ST_DrawKey(it_yellowskull, uv, st_key2Vertex);

	uv[0][0] = uv[3][0] = (9.0f / width) * 5;
	uv[1][0] = uv[2][0] = (9.0f / width) * 6;

	ST_DrawKey(it_redskull, uv, st_key3Vertex);

	dglDrawGeometry(st_vtxcount, st_vtx);

	GL_ResetViewport();
	GL_SetState(GLSTATE_BLEND, 0);

	if (st_drawhud.value >= 2)
		GL_SetOrthoScale(1.0f);
}