very good

This commit is contained in:
nullifiedcat 2017-11-16 21:09:57 +03:00
parent 350bef500a
commit 523296bb46
6 changed files with 24 additions and 10 deletions

View File

@ -8,6 +8,7 @@ BIN64_DIR=bin64
SOURCES=$(shell find $(SRC_DIR) -name "*.c" -print) SOURCES=$(shell find $(SRC_DIR) -name "*.c" -print)
SOURCES+=$(shell find "ftgl" -name "*.c" -print) SOURCES+=$(shell find "ftgl" -name "*.c" -print)
OBJECTS=$(SOURCES:.c=.o) OBJECTS=$(SOURCES:.c=.o)
DEPENDS=$(SOURCES:.c=.d)
TARGET32=$(BIN32_DIR)/liboverlay.so TARGET32=$(BIN32_DIR)/liboverlay.so
TARGET64=$(BIN64_DIR)/liboverlay.so TARGET64=$(BIN64_DIR)/liboverlay.so
@ -56,6 +57,9 @@ ftgl/makefont.o : CFLAGS+=-w
.c.o: .c.o:
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
.c.d:
@$(CC) -M $(CXXFLAGS) $< > $@
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@ $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@
@ -64,5 +68,10 @@ clean_objects:
clean: clean:
find . -type f -name '*.o' -delete find . -type f -name '*.o' -delete
find . -type f -name '*.d' -delete
rm -f bin32/*.so rm -f bin32/*.so
rm -f bin64/*.so rm -f bin64/*.so
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPENDS)
endif

Binary file not shown.

Binary file not shown.

View File

@ -378,7 +378,7 @@ void
draw_string_internal(float x, float y, const char *string, texture_font_t *fnt, vec4 color, float *out_x, float *out_y) draw_string_internal(float x, float y, const char *string, texture_font_t *fnt, vec4 color, float *out_x, float *out_y)
{ {
float pen_x = x; float pen_x = x;
float pen_y = y; float pen_y = y + fnt->height / 1.5f;
float size_y = 0; float size_y = 0;
//texture_font_load_glyphs(fnt, string); //texture_font_load_glyphs(fnt, string);
@ -389,10 +389,10 @@ draw_string_internal(float x, float y, const char *string, texture_font_t *fnt,
} }
ds_bind_texture(fnt->atlas->id); ds_bind_texture(fnt->atlas->id);
if (fnt->atlas->dirty) { if (fnt->atlas->dirty) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, fnt->atlas->width, fnt->atlas->height, 0, GL_RED, GL_UNSIGNED_BYTE, fnt->atlas->data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, fnt->atlas->width, fnt->atlas->height, 0, GL_RED, GL_UNSIGNED_BYTE, fnt->atlas->data);
fnt->atlas->dirty = 0; fnt->atlas->dirty = 0;
} }
@ -406,7 +406,7 @@ draw_string_internal(float x, float y, const char *string, texture_font_t *fnt,
texture_glyph_t *glyph = texture_font_find_glyph(fnt, &string[i]); texture_glyph_t *glyph = texture_font_find_glyph(fnt, &string[i]);
if (glyph == NULL) if (glyph == NULL)
{ {
texture_font_load_glyph(fnt, &string[i - 1]); texture_font_load_glyph(fnt, &string[i]);
continue; continue;
} }
GLuint indices[6]; GLuint indices[6];
@ -438,6 +438,7 @@ draw_string_internal(float x, float y, const char *string, texture_font_t *fnt,
vertices[3] = (struct vertex_main){ (vec2){ x1, y0 }, (vec2){ s1, t0 }, color, DRAW_MODE_FREETYPE }; vertices[3] = (struct vertex_main){ (vec2){ x1, y0 }, (vec2){ s1, t0 }, color, DRAW_MODE_FREETYPE };
pen_x += glyph->advance_x; pen_x += glyph->advance_x;
pen_x = (int)pen_x + 1;
if (glyph->height > size_y) if (glyph->height > size_y)
size_y = glyph->height; size_y = glyph->height;

View File

@ -42,12 +42,15 @@ xoverlay_font_load(const char *path, float size)
if (result.font == NULL) if (result.font == NULL)
{ {
log_write("fontapi: load: could not init font\n"); log_write("fontapi: load: could not init font\n");
return XOVERLAY_FONT_INVALID_HANDLE;
} }
} }
else else
{ {
log_write("fontapi: load: could not init atlas\n"); log_write("fontapi: load: could not init atlas\n");
return XOVERLAY_FONT_INVALID_HANDLE;
} }
result.font->hinting = 0;
return fontapi_add_font(&result); return fontapi_add_font(&result);
} }

View File

@ -67,9 +67,10 @@ const char *shader_ultimate_frag =
" if (frag_DrawMode == 2)\n" " if (frag_DrawMode == 2)\n"
" gl_FragColor = frag_Color * tex;\n" " gl_FragColor = frag_Color * tex;\n"
" else if (frag_DrawMode == 3)\n" " else if (frag_DrawMode == 3)\n"
" if (tex.r < 0.5) gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" " {\n"
" else\n" " if (tex.r > 0.4) tex.r = 1.0;\n"
" gl_FragColor = vec4(frag_Color.rgb, frag_Color.a * tex.r);\n" " gl_FragColor = vec4(frag_Color.rgb, frag_Color.a * tex.r);\n"
" }\n"
" else\n" " else\n"
" gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n" " gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n"
" }\n" " }\n"