Skip to content

Commit d87ec3b

Browse files
committed
Merge remote-tracking branch 'tsoding/master'
2 parents 3129cfb + 02b3447 commit d87ec3b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
# Quick Start
66

7+
## Dependencies
8+
9+
- [SDL2 2.0.9+](https://www.libsdl.org/)
10+
- [FreeType 2.13.0+](https://freetype.org/)
11+
- [GLEW 2.1.0+](https://glew.sourceforge.net/)
12+
713
## POSIX
814

915
```console

shaders/simple_epic.frag

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ vec3 hsl2rgb(vec3 c) {
1313

1414
void main() {
1515
vec4 tc = texture(image, out_uv);
16+
float d = tc.r;
17+
float aaf = fwidth(d);
18+
float alpha = smoothstep(0.5 - aaf, 0.5 + aaf, d);
1619
vec2 frag_uv = gl_FragCoord.xy / resolution;
1720
vec4 rainbow = vec4(hsl2rgb(vec3((time + frag_uv.x + frag_uv.y), 0.5, 0.5)), 1.0);
18-
gl_FragColor = tc.x * rainbow;
21+
gl_FragColor = vec4(rainbow.rgb, alpha);
1922
}

shaders/simple_text.frag

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ in vec4 out_color;
66
in vec2 out_uv;
77

88
void main() {
9-
gl_FragColor = texture(image, out_uv).x*out_color;
9+
float d = texture(image, out_uv).r;
10+
float aaf = fwidth(d);
11+
float alpha = smoothstep(0.5 - aaf, 0.5 + aaf, d);
12+
gl_FragColor = vec4(out_color.rgb, alpha);
1013
}

src/free_glyph.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
void free_glyph_atlas_init(Free_Glyph_Atlas *atlas, FT_Face face)
66
{
7+
FT_Int32 load_flags = FT_LOAD_RENDER | FT_LOAD_TARGET_(FT_RENDER_MODE_SDF);
78
for (int i = 32; i < 128; ++i) {
8-
if (FT_Load_Char(face, i, FT_LOAD_RENDER)) {
9+
if (FT_Load_Char(face, i, load_flags)) {
910
fprintf(stderr, "ERROR: could not load glyph of a character with code %d\n", i);
1011
exit(1);
1112
}
@@ -39,7 +40,7 @@ void free_glyph_atlas_init(Free_Glyph_Atlas *atlas, FT_Face face)
3940

4041
int x = 0;
4142
for (int i = 32; i < 128; ++i) {
42-
if (FT_Load_Char(face, i, FT_LOAD_RENDER)) {
43+
if (FT_Load_Char(face, i, load_flags)) {
4344
fprintf(stderr, "ERROR: could not load glyph of a character with code %d\n", i);
4445
exit(1);
4546
}

0 commit comments

Comments
 (0)