Esempio n. 1
0
static void ST_DrawJMessage(int pic)
{
	int lump = st_jmessages[pic];

	GL_BindGfxTexture(lumpinfo[lump].name, true);
	GL_SetState(GLSTATE_BLEND, 1);

	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, DGL_CLAMP);
	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, DGL_CLAMP);
	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	dglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	GL_SetupAndDraw2DQuad(20,
			      20,
			      gfxwidth[lump - g_start],
			      gfxheight[lump - g_start],
			      0,
			      1,
			      0,
			      1,
			      ST_MSGCOLOR(automapactive ? 0xff : st_msgalpha),
			      false);

	GL_SetState(GLSTATE_BLEND, 0);
}
Esempio n. 2
0
void ST_DrawCrosshair(int x, int y, int slot, byte scalefactor, rcolor color)
{
	float u;
	int index;
	int scale;

	if (slot <= 0)
		return;

	if (slot > st_crosshairs)
		return;

	index = slot - 1;

	GL_BindGfxTexture("CRSHAIRS", true);
	GL_SetState(GLSTATE_BLEND, 1);

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

	u = 1.0f / st_crosshairs;
	scale =
	    scalefactor ==
	    0 ? ST_CROSSHAIRSIZE : (ST_CROSSHAIRSIZE / (1 << scalefactor));

	GL_SetupAndDraw2DQuad((float)x, (float)y, scale, scale,
			      u * index, u + (u * index), 0, 1, color, 0);

	GL_SetState(GLSTATE_BLEND, 0);
}
Esempio n. 3
0
void Draw_GfxImage(int x, int y, const char* name, rcolor color, dboolean alpha) {
    int gfxIdx = GL_BindGfxTexture(name, alpha);

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

    GL_SetState(GLSTATE_BLEND, 1);
    GL_SetupAndDraw2DQuad((float)x, (float)y,
                          gfxwidth[gfxIdx], gfxheight[gfxIdx], 0, 1.0f, 0, 1.0f, color, 0);

    GL_SetState(GLSTATE_BLEND, 0);
}
Esempio n. 4
0
int Draw_BigText(int x, int y, rcolor color, const char* string) {
    int c = 0;
    int i = 0;
    int vi = 0;
    int index = 0;
    float vx1 = 0.0f;
    float vy1 = 0.0f;
    float vx2 = 0.0f;
    float vy2 = 0.0f;
    float tx1 = 0.0f;
    float tx2 = 0.0f;
    float ty1 = 0.0f;
    float ty2 = 0.0f;
    float smbwidth;
    float smbheight;
    int pic;

    if(x <= -1) {
        x = Center_Text(string);
    }

    y += 14;

    pic = GL_BindGfxTexture("SYMBOLS", true);

    smbwidth = (float)gfxwidth[pic];
    smbheight = (float)gfxheight[pic];

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

    dglSetVertex(vtxstring);

    GL_SetState(GLSTATE_BLEND, 1);
    GL_SetOrtho(0);

    for(i = 0, vi = 0; i < dstrlen(string); i++, vi += 4) {
        vx1 = (float)x;
        vy1 = (float)y;

        c = string[i];
        if(c == '\n' || c == '\t') {
            continue;    // villsa: safety check
        }
        else if(c == 0x20) {
            x += 6;
            continue;
        }
        else {
            if(c >= '0' && c <= '9') {
                index = (c - '0') + SM_NUMBERS;
            }
            if(c >= 'A' && c <= 'Z') {
                index = (c - 'A') + SM_FONT1;
            }
            if(c >= 'a' && c <= 'z') {
                index = (c - 'a') + SM_FONT2;
            }
            if(c == '-') {
                index = SM_MISCFONT;
            }
            if(c == '%') {
                index = SM_MISCFONT + 1;
            }
            if(c == '!') {
                index = SM_MISCFONT + 2;
            }
            if(c == '.') {
                index = SM_MISCFONT + 3;
            }
            if(c == '?') {
                index = SM_MISCFONT + 4;
            }
            if(c == ':') {
                index = SM_MISCFONT + 5;
            }

            // [kex] use 'printf' style formating for special symbols
            if(c == '/') {
                c = string[++i];

                switch(c) {
                // up arrow
                case 'u':
                    index = SM_MICONS + 17;
                    break;
                // down arrow
                case 'd':
                    index = SM_MICONS + 16;
                    break;
                // right arrow
                case 'r':
                    index = SM_MICONS + 18;
                    break;
                // left arrow
                case 'l':
                    index = SM_MICONS;
                    break;
                // cursor box
                case 'b':
                    index = SM_MICONS + 1;
                    break;
                // thermbar
                case 't':
                    index = SM_THERMO;
                    break;
                // thermcursor
                case 's':
                    index = SM_THERMO + 1;
                    break;
                default:
                    return 0;
                }
            }

            vx2 = vx1 + symboldata[index].w;
            vy2 = vy1 - symboldata[index].h;

            tx1 = ((float)symboldata[index].x / smbwidth) + 0.001f;
            tx2 = (tx1 + (float)symboldata[index].w / smbwidth) - 0.002f;

            ty1 = ((float)symboldata[index].y / smbheight);
            ty2 = ty1 + (((float)symboldata[index].h / smbheight));

            vtxstring[vi + 0].x     = vx1;
            vtxstring[vi + 0].y     = vy1;
            vtxstring[vi + 0].tu    = tx1;
            vtxstring[vi + 0].tv    = ty2;
            vtxstring[vi + 1].x     = vx2;
            vtxstring[vi + 1].y     = vy1;
            vtxstring[vi + 1].tu    = tx2;
            vtxstring[vi + 1].tv    = ty2;
            vtxstring[vi + 2].x     = vx2;
            vtxstring[vi + 2].y     = vy2;
            vtxstring[vi + 2].tu    = tx2;
            vtxstring[vi + 2].tv    = ty1;
            vtxstring[vi + 3].x     = vx1;
            vtxstring[vi + 3].y     = vy2;
            vtxstring[vi + 3].tu    = tx1;
            vtxstring[vi + 3].tv    = ty1;

            dglSetVertexColor(vtxstring + vi, color, 4);

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

            if(devparm) {
                vertCount += 4;
            }

            x += symboldata[index].w;
        }
    }

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

    GL_ResetViewport();
    GL_SetState(GLSTATE_BLEND, 0);

    return x;
}
Esempio n. 5
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;
}
Esempio n. 6
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);
}