1
2
3
4
5
6
7
8
9
10
11
|
// renderextras.cpp: misc gl render code and the HUD
#include "cube.h"
void
line(int x1, int y1, float z1, int x2, int y2, float z2)
{
glBegin(GL_POLYGON);
glVertex3f((float)x1, z1, (float)y1);
glVertex3f((float)x1, z1, y1 + 0.01f);
glVertex3f((float)x2, z2, y2 + 0.01f);
|
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
// renderextras.cpp: misc gl render code and the HUD
#include "cube.h"
#import "DynamicEntity.h"
void
line(int x1, int y1, float z1, int x2, int y2, float z2)
{
glBegin(GL_POLYGON);
glVertex3f((float)x1, z1, (float)y1);
glVertex3f((float)x1, z1, y1 + 0.01f);
glVertex3f((float)x2, z2, y2 + 0.01f);
|
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
void
gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
{
readmatrices();
if (editmode) {
if (cursordepth == 1.0f)
worldpos = player1->o;
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
cursorupdate();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
glDisable(GL_DEPTH_TEST);
invertperspective();
|
|
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
void
gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
{
readmatrices();
if (editmode) {
if (cursordepth == 1.0f)
worldpos = player1.o;
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
cursorupdate();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
glDisable(GL_DEPTH_TEST);
invertperspective();
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
renderscores();
if (!rendermenu()) {
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 1);
glBegin(GL_QUADS);
glColor3ub(255, 255, 255);
if (crosshairfx) {
if (player1->gunwait)
glColor3ub(128, 128, 128);
else if (player1->health <= 25)
glColor3ub(255, 0, 0);
else if (player1->health <= 50)
glColor3ub(255, 128, 0);
}
float chsize = (float)crosshairsize;
glTexCoord2d(0.0, 0.0);
glVertex2f(VIRTW / 2 - chsize, VIRTH / 2 - chsize);
glTexCoord2d(1.0, 0.0);
glVertex2f(VIRTW / 2 + chsize, VIRTH / 2 - chsize);
|
|
|
|
|
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
renderscores();
if (!rendermenu()) {
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 1);
glBegin(GL_QUADS);
glColor3ub(255, 255, 255);
if (crosshairfx) {
if (player1.gunwait)
glColor3ub(128, 128, 128);
else if (player1.health <= 25)
glColor3ub(255, 0, 0);
else if (player1.health <= 50)
glColor3ub(255, 128, 0);
}
float chsize = (float)crosshairsize;
glTexCoord2d(0.0, 0.0);
glVertex2f(VIRTW / 2 - chsize, VIRTH / 2 - chsize);
glTexCoord2d(1.0, 0.0);
glVertex2f(VIRTW / 2 + chsize, VIRTH / 2 - chsize);
|
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
|
draw_textf(@"wqd %d", 3200, 2460, 2, nquads);
draw_textf(@"wvt %d", 3200, 2530, 2, curvert);
draw_textf(@"evt %d", 3200, 2600, 2, xtraverts);
}
glPopMatrix();
if (player1->state == CS_ALIVE) {
glPushMatrix();
glOrtho(0, VIRTW / 2, VIRTH / 2, 0, -1, 1);
draw_textf(@"%d", 90, 827, 2, player1->health);
if (player1->armour)
draw_textf(@"%d", 390, 827, 2, player1->armour);
draw_textf(
@"%d", 690, 827, 2, player1->ammo[player1->gunselect]);
glPopMatrix();
glPushMatrix();
glOrtho(0, VIRTW, VIRTH, 0, -1, 1);
glDisable(GL_BLEND);
drawicon(128, 128, 20, 1650);
if (player1->armour)
drawicon(
(float)(player1->armourtype * 64), 0, 620, 1650);
int g = player1->gunselect;
int r = 64;
if (g > 2) {
g -= 3;
r = 128;
}
drawicon((float)(g * 64), (float)r, 1220, 1650);
glPopMatrix();
|
|
|
|
|
<
|
|
|
|
|
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
draw_textf(@"wqd %d", 3200, 2460, 2, nquads);
draw_textf(@"wvt %d", 3200, 2530, 2, curvert);
draw_textf(@"evt %d", 3200, 2600, 2, xtraverts);
}
glPopMatrix();
if (player1.state == CS_ALIVE) {
glPushMatrix();
glOrtho(0, VIRTW / 2, VIRTH / 2, 0, -1, 1);
draw_textf(@"%d", 90, 827, 2, player1.health);
if (player1.armour)
draw_textf(@"%d", 390, 827, 2, player1.armour);
draw_textf(@"%d", 690, 827, 2, player1.ammo[player1.gunselect]);
glPopMatrix();
glPushMatrix();
glOrtho(0, VIRTW, VIRTH, 0, -1, 1);
glDisable(GL_BLEND);
drawicon(128, 128, 20, 1650);
if (player1.armour)
drawicon(
(float)(player1.armourtype * 64), 0, 620, 1650);
int g = player1.gunselect;
int r = 64;
if (g > 2) {
g -= 3;
r = 128;
}
drawicon((float)(g * 64), (float)r, 1220, 1650);
glPopMatrix();
|