Exemple #1
0
static void ST_DrawStatusItem(const float xy[4][2], const float uv[4][2],
			      rcolor color)
{
	int i;

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

	dglSetVertexColor(st_vtx + st_vtxcount, color, 4);

	for (i = 0; i < 4; i++) {
		st_vtx[st_vtxcount + i].x = xy[i][0] + ViewBorderX;;
		st_vtx[st_vtxcount + i].y = xy[i][1];
		st_vtx[st_vtxcount + i].tu = uv[i][0];
		st_vtx[st_vtxcount + i].tv = uv[i][1];
	}

	st_vtxcount += 4;
}
Exemple #2
0
static void ST_DrawDamageMarkers(void)
{
	damagemarker_t *dmgmarker;

	for (dmgmarker = dmgmarkers.next; dmgmarker != &dmgmarkers;
	     dmgmarker = dmgmarker->next) {
		static vtx_t v[3];
		player_t *p;
		float angle;
		byte alpha;

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

		alpha = (dmgmarker->tics << 3);

		if (alpha < 0)
			alpha = 0;

		v[0].x = -8;
		v[0].a = alpha;
		v[1].x = 8;
		v[1].a = alpha;
		v[2].y = 4;
		v[2].r = 255;
		v[2].a = alpha;

		p = &players[consoleplayer];

		angle = (float)TRUEANGLES(p->mo->angle -
					  R_PointToAngle2(dmgmarker->source->x,
							  dmgmarker->source->y,
							  p->mo->x, p->mo->y));

		dglPushMatrix();
		dglTranslatef(160, 120, 0);
		dglRotatef(angle, 0.0f, 0.0f, 1.0f);
		dglTranslatef(0, 16, 0);
		dglDisable(GL_TEXTURE_2D);
		dglSetVertex(v);
		dglTriangle(0, 1, 2);
		dglDrawGeometry(3, v);
		dglEnable(GL_TEXTURE_2D);
		dglPopMatrix();

		GL_ResetViewport();
		GL_SetState(GLSTATE_BLEND, 0);
	}
}
Exemple #3
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;
}
Exemple #4
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;
}