1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// renderextras.cpp: misc gl render code and the HUD
#include "cube.h"
#import "Command.h"
#import "Entity.h"
#import "Player.h"
#import "Variable.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);
glVertex3f((float)x2, z2, (float)y2);
glEnd();
xtraverts += 4;
}
void
linestyle(float width, int r, int g, int b)
{
glLineWidth(width);
glColor3ub(r, g, b);
}
void
box(const struct block *b, float z1, float z2, float z3, float z4)
{
glBegin(GL_POLYGON);
glVertex3f((float)b->x, z1, (float)b->y);
|
>
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// renderextras.cpp: misc gl render code and the HUD
#include "cube.h"
#import "Command.h"
#import "Entity.h"
#import "OFColor+Cube.h"
#import "Player.h"
#import "Variable.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);
glVertex3f((float)x2, z2, (float)y2);
glEnd();
xtraverts += 4;
}
void
linestyle(float width, OFColor *color)
{
glLineWidth(width);
[color cube_setAsGLColor];
}
void
box(const struct block *b, float z1, float z2, float z3, float z4)
{
glBegin(GL_POLYGON);
glVertex3f((float)b->x, z1, (float)b->y);
|
︙ | | | ︙ | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
blendbox(int x1, int y1, int x2, int y2, bool border)
{
glDepthMask(GL_FALSE);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBegin(GL_QUADS);
if (border)
glColor3d(0.5, 0.3, 0.4);
else
glColor3d(1.0, 1.0, 1.0);
glVertex2i(x1, y1);
glVertex2i(x2, y1);
glVertex2i(x2, y2);
glVertex2i(x1, y2);
glEnd();
glDisable(GL_BLEND);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_POLYGON);
glColor3d(0.2, 0.7, 0.4);
glVertex2i(x1, y1);
glVertex2i(x2, y1);
glVertex2i(x2, y2);
glVertex2i(x1, y2);
glEnd();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
xtraverts += 8;
|
|
>
>
>
|
|
>
>
>
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
blendbox(int x1, int y1, int x2, int y2, bool border)
{
glDepthMask(GL_FALSE);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBegin(GL_QUADS);
if (border)
[[OFColor colorWithRed:0.5f
green:0.3f
blue:0.4f
alpha:1.0f] cube_setAsGLColor];
else
[OFColor.white cube_setAsGLColor];
glVertex2i(x1, y1);
glVertex2i(x2, y1);
glVertex2i(x2, y2);
glVertex2i(x1, y2);
glEnd();
glDisable(GL_BLEND);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_POLYGON);
[[OFColor colorWithRed:0.2f
green:0.7f
blue:0.4f
alpha:1.0f] cube_setAsGLColor];
glVertex2i(x1, y1);
glVertex2i(x2, y1);
glVertex2i(x2, y2);
glVertex2i(x1, y2);
glEnd();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
xtraverts += 8;
|
︙ | | | ︙ | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindTexture(GL_TEXTURE_2D, 4);
for (struct sphere *p, **pp = &slist; (p = *pp) != NULL;) {
glPushMatrix();
float size = p->size / p->max;
glColor4f(1.0f, 1.0f, 1.0f, 1.0f - size);
glTranslatef(p->o.x, p->o.z, p->o.y);
glRotatef(lastmillis / 5.0f, 1, 1, 1);
glScalef(p->size, p->size, p->size);
glCallList(1);
glScalef(0.8f, 0.8f, 0.8f);
glCallList(1);
glPopMatrix();
|
>
>
>
|
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindTexture(GL_TEXTURE_2D, 4);
for (struct sphere *p, **pp = &slist; (p = *pp) != NULL;) {
glPushMatrix();
float size = p->size / p->max;
[[OFColor colorWithRed:1.0f
green:1.0f
blue:1.0f
alpha:1.0f - size] cube_setAsGLColor];
glTranslatef(p->o.x, p->o.z, p->o.y);
glRotatef(lastmillis / 5.0f, 1, 1, 1);
glScalef(p->size, p->size, p->size);
glCallList(1);
glScalef(0.8f, 0.8f, 0.8f);
glCallList(1);
glPopMatrix();
|
︙ | | | ︙ | |
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
glDepthMask(GL_FALSE);
if (dblend || underwater) {
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBegin(GL_QUADS);
if (dblend)
glColor3d(0.0f, 0.9f, 0.9f);
else
glColor3d(0.9f, 0.5f, 0.0f);
glVertex2i(0, 0);
glVertex2i(VIRTW, 0);
glVertex2i(VIRTW, VIRTH);
glVertex2i(0, VIRTH);
glEnd();
dblend -= curtime / 3;
if (dblend < 0)
|
>
>
|
>
>
>
|
>
|
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
glDepthMask(GL_FALSE);
if (dblend || underwater) {
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBegin(GL_QUADS);
if (dblend)
[[OFColor colorWithRed:0.0f
green:0.9f
blue:0.9f
alpha:1.0f] cube_setAsGLColor];
else
[[OFColor colorWithRed:0.9f
green:0.5f
blue:0.0f
alpha:1.0f] cube_setAsGLColor];
glVertex2i(0, 0);
glVertex2i(VIRTW, 0);
glVertex2i(VIRTW, VIRTH);
glVertex2i(0, VIRTH);
glEnd();
dblend -= curtime / 3;
if (dblend < 0)
|
︙ | | | ︙ | |
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
draw_text(player, 20, 1570, 2);
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);
glTexCoord2d(1.0, 1.0);
|
|
|
|
|
>
>
>
|
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
draw_text(player, 20, 1570, 2);
renderscores();
if (!rendermenu()) {
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 1);
glBegin(GL_QUADS);
[OFColor.white cube_setAsGLColor];
if (crosshairfx) {
if (player1.gunWait)
[OFColor.gray cube_setAsGLColor];
else if (player1.health <= 25)
[OFColor.red cube_setAsGLColor];
else if (player1.health <= 50)
[[OFColor colorWithRed:1.0f
green:0.5f
blue:0.0f
alpha:1.0f] cube_setAsGLColor];
}
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);
glTexCoord2d(1.0, 1.0);
|
︙ | | | ︙ | |