Skip to content

Commit d2d8f88

Browse files
committed
Cleanup
1 parent c5ac22e commit d2d8f88

3 files changed

Lines changed: 57 additions & 61 deletions

File tree

config/glsl/hud.cfg

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ shader 0 "hud" [
2828
}
2929
]
3030

31+
shader 0 "hudtext" [
32+
attribute vec4 vvertex, vcolor;
33+
attribute vec2 vtexcoord0;
34+
uniform mat4 hudmatrix;
35+
varying vec2 texcoord0;
36+
varying vec4 colorscale;
37+
void main(void)
38+
{
39+
gl_Position = hudmatrix * vvertex;
40+
texcoord0 = vtexcoord0;
41+
colorscale = vcolor;
42+
}
43+
] [
44+
uniform sampler2DRect tex0;
45+
varying vec2 texcoord0;
46+
varying vec4 colorscale;
47+
fragdata(0) vec4 fragcolor;
48+
void main(void)
49+
{
50+
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
51+
if(fragcolor.a != 0) fragcolor.rgb /= fragcolor.a;
52+
}
53+
]
54+
3155
shader 0 "hudrgb" [
3256
attribute vec4 vvertex, vcolor;
3357
attribute vec2 vtexcoord0;
@@ -125,30 +149,6 @@ shader 0 "hudrect" [
125149
}
126150
]
127151

128-
shader 0 "hudtext" [
129-
attribute vec4 vvertex, vcolor;
130-
attribute vec2 vtexcoord0;
131-
uniform mat4 hudmatrix;
132-
varying vec2 texcoord0;
133-
varying vec4 colorscale;
134-
void main(void)
135-
{
136-
gl_Position = hudmatrix * vvertex;
137-
texcoord0 = vtexcoord0;
138-
colorscale = vcolor;
139-
}
140-
] [
141-
uniform sampler2DRect tex0;
142-
varying vec2 texcoord0;
143-
varying vec4 colorscale;
144-
fragdata(0) vec4 fragcolor;
145-
void main(void)
146-
{
147-
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
148-
if(fragcolor.a != 0) fragcolor.rgb = fragcolor.rgb / fragcolor.a;
149-
}
150-
]
151-
152152
shader 0 "hud3d" [
153153
attribute vec4 vvertex, vcolor;
154154
attribute vec3 vtexcoord0;

source/engine/shader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void setupshaders()
10341034
"void main(void)\n"
10351035
"{\n"
10361036
" gl_Position = hudmatrix * vvertex;\n"
1037-
" texcoord0 = vtexcoord0;\n"
1037+
" texcoord0 = vtexcoord0;\n"
10381038
" colorscale = vcolor;\n"
10391039
"}\n",
10401040
"uniform sampler2DRect tex0;\n"

source/engine/ui.cpp

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,82 +2141,78 @@ namespace UI
21412141

21422142
struct Font : Object
21432143
{
2144-
string font;
2144+
char *font;
21452145

2146-
Font() { font[0] = '\0'; }
2146+
Font() : font(NULL) {}
2147+
~Font() { DELETEA(font); }
21472148

21482149
void setup(const char *name)
21492150
{
21502151
Object::setup();
2151-
copystring(font, name, MAXSTRLEN);
2152+
SETSTR(font, name);
21522153
}
21532154

2154-
#define WITHFONT(body) do { \
2155-
pushfont(); \
2156-
setfont(font); \
2157-
body; \
2158-
popfont(); \
2159-
} while(0); \
2160-
21612155
void layout()
21622156
{
2163-
WITHFONT({
2164-
Object::layout();
2165-
});
2157+
pushfont();
2158+
setfont(font);
2159+
Object::layout();
2160+
popfont();
21662161
}
21672162

21682163
void draw(float sx, float sy)
21692164
{
2170-
WITHFONT({
2171-
Object::draw(sx, sy);
2172-
});
2165+
pushfont();
2166+
setfont(font);
2167+
Object::draw(sx, sy);
2168+
popfont();
21732169
}
21742170

21752171
void buildchildren(uint *contents)
21762172
{
2177-
WITHFONT({
2178-
Object::buildchildren(contents);
2179-
});
2173+
pushfont();
2174+
setfont(font);
2175+
Object::buildchildren(contents);
2176+
popfont();
21802177
}
21812178

21822179
#define DOSTATE(flags, func) \
21832180
void func##children(float cx, float cy, int mask, bool inside, int setflags) \
21842181
{ \
2185-
WITHFONT({ \
2186-
Object::func##children(cx, cy, mask, inside, setflags); \
2187-
}); \
2182+
pushfont(); \
2183+
setfont(font); \
2184+
Object::func##children(cx, cy, mask, inside, setflags); \
2185+
popfont(); \
21882186
} \
21892187
DOSTATES
21902188
#undef DOSTATE
21912189

21922190
bool rawkey(int code, bool isdown)
21932191
{
2194-
bool result;
2195-
WITHFONT({
2196-
result = Object::rawkey(code, isdown);
2197-
});
2192+
pushfont();
2193+
setfont(font);
2194+
bool result = Object::rawkey(code, isdown);
2195+
popfont();
21982196
return result;
21992197
}
22002198

22012199
bool key(int code, bool isdown)
22022200
{
2203-
bool result;
2204-
WITHFONT({
2205-
result = Object::key(code, isdown);
2206-
});
2201+
pushfont();
2202+
setfont(font);
2203+
bool result = Object::key(code, isdown);
2204+
popfont();
22072205
return result;
22082206
}
22092207

22102208
bool textinput(const char *str, int len)
22112209
{
2212-
bool result;
2213-
WITHFONT({
2214-
result = Object::textinput(str, len);
2215-
});
2210+
pushfont();
2211+
setfont(font);
2212+
bool result = Object::textinput(str, len);
2213+
popfont();
22162214
return result;
22172215
}
2218-
2219-
#undef WITHFONT
22202216
};
22212217

22222218
float uicontextscale = 0;

0 commit comments

Comments
 (0)