forked from Wolf3s/glDoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
glsbar.c
187 lines (161 loc) · 4.54 KB
/
glsbar.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <windows.h>
#include <fcntl.h>
#include <io.h>
//#include <gl/gl.h>
#include <glad/glad.h>
#include "doomtype.h"
#include "r_defs.h"
#include "v_video.h"
#include "w_wad.h"
#include "z_zone.h"
#include "gldefs.h"
#include "gl_utils.h"
typedef struct
{
unsigned char r;
unsigned char g;
unsigned char b;
}MY_PAL;
extern MY_PAL gamepal[256];
extern MY_PAL statpal[256];
typedef struct
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
}MY_RGBA;
extern int deathmatch;
unsigned char Transparent[512*512];
unsigned char TexAlpha[512*512];
extern int TexWide, TexHigh;
extern int SBarTexture[2];
extern GLTexData SBarTex[2];
extern unsigned char TexRaw[512*512];
GLubyte *TexRGB, *MipMaps[16][32768];
MY_RGBA StatFrag[40*32], StatArms[40*32], StatBack[4][35*31], *TempTex;
unsigned char patchbuff[320*200];
unsigned char platebuff[320*200];
unsigned char MsgText[2048];
void lfprintf(char *message, ... );
void GL_StatArmsOvl(MY_RGBA *RGBData);
int GL_MakeSpriteTexture(patch_t *, GLTexData *Tex, dboolean smooth);
int MakeRGBATexture(dboolean clamp, dboolean smooth, int dw, int dh);
void InsertArmsPlate()
{
int y, x, soff, doff;
soff = 0;
doff = 104;
for (y = 0; y < 32; y++)
{
for (x = 0; x < 40; x++)
{
TexRaw[doff+x] = platebuff[soff+x];
}
doff += 256;
soff += 40;
}
}
void GL_CreateStatusBar(patch_t *sbar)
{
int yoff, y, d, x;
for (x = 0; x < 256; x++)
{
TexAlpha[x] = GLD_COLORED;
TexRaw[x] = 0;
patchbuff[x] = 0;
}
V_DrawPatchBuff( 0, 0, patchbuff, sbar);
for (y = 0, d = 0; y < 32; y++)
{
yoff = y * 320;
for (x = 0; x < 256; x++, d++)
{
TexRaw[d] = patchbuff[yoff+x];
}
}
TexWide = 256;
TexHigh = 32;
if (deathmatch == 0)
{
InsertArmsPlate();
}
SBarTexture[0] = MakeRGBATexture(true, false, 256, 32);
for (x = 0; x < 64; x++)
{
TexAlpha[x] = GLD_COLORED;
TexRaw[x] = 0;
patchbuff[x] = 0;
}
for (y = 0, d = 0; y < 32; y++)
{
yoff = (y * 320)+256;
for (x = 0; x < 64; x++, d++)
{
TexRaw[d] = patchbuff[yoff+x];
}
}
TexWide = 64;
TexHigh = 32;
SBarTexture[1] = MakeRGBATexture(true, false, 64, 32);
if (deathmatch == 0)
{
GL_StatArmsOvl(StatArms);
}
}
void GL_RGBStatFrag(patch_t *sbar)
{
int x, y, z, i, yoff;
V_DrawPatchBuff( 0, 0, platebuff, sbar);
for (y = 0, i = 0; y < 32; y++)
{
yoff = (31-y) * 104;
for (x = 0, z = 0; x < 40; x++, i++, z++)
{
StatFrag[i].r = gammatable[usegamma][statpal[patchbuff[yoff+z]].r];
StatFrag[i].g = gammatable[usegamma][statpal[patchbuff[yoff+z]].g];
StatFrag[i].b = gammatable[usegamma][statpal[patchbuff[yoff+z]].b];
StatFrag[i].a = 255;
}
}
}
void GL_RGBStatArms(patch_t *armsbg)
{
int x, y, i, yoff;
V_DrawPatchBuff( 0, 0, platebuff, armsbg);
yoff = 31*40;
for (y = 0, i = 0; y < 32; y++)
{
for (x = 0; x < 40; x++, i++)
{
StatArms[i].r = gammatable[usegamma][statpal[platebuff[yoff+x]].r];
StatArms[i].g = gammatable[usegamma][statpal[platebuff[yoff+x]].g];
StatArms[i].b = gammatable[usegamma][statpal[platebuff[yoff+x]].b];
StatArms[i].a = 255;
}
yoff -= 40;
}
}
void GL_StatArmsOvl(MY_RGBA *RGBData)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, SBarTexture[0]);
glTexSubImage2D(GL_TEXTURE_2D, 0, 104, 0, 40, 32, GL_RGBA, GL_UNSIGNED_BYTE, RGBData );
glDisable(GL_TEXTURE_2D);
}
void GL_RGBStatBack(patch_t *statback, int player)
{
int x, y, z, i, yoff;
V_DrawPatchBuff( 0, 0, patchbuff, statback);
for (y = 0, i = 0; y < statback->height; y++)
{
yoff = ((statback->height-1) - y) * statback->width;
for (x = 0, z = 0; x < statback->width; x++, z++, i++)
{
StatBack[player][i].r = gammatable[usegamma][statpal[patchbuff[yoff+z]].r];
StatBack[player][i].g = gammatable[usegamma][statpal[patchbuff[yoff+z]].g];
StatBack[player][i].b = gammatable[usegamma][statpal[patchbuff[yoff+z]].b];
StatBack[player][i].a = 255;
}
}
}