diff --git a/Makefile b/Makefile index e0c7ee0..d79daa8 100644 --- a/Makefile +++ b/Makefile @@ -30,8 +30,8 @@ all: ifndef ARCH $(MAKE) clean $(MAKE) $(TARGET64) -e ARCH=64 - #$(MAKE) clean - #$(MAKE) $(TARGET32) -e ARCH=32 + $(MAKE) clean + $(MAKE) $(TARGET32) -e ARCH=32 endif install: diff --git a/bin32/liboverlay.so b/bin32/liboverlay.so new file mode 100755 index 0000000..7ef261e Binary files /dev/null and b/bin32/liboverlay.so differ diff --git a/bin32/liboverlay.so.0 b/bin32/liboverlay.so.0 deleted file mode 100755 index f732a56..0000000 Binary files a/bin32/liboverlay.so.0 and /dev/null differ diff --git a/bin64/liboverlay.so b/bin64/liboverlay.so index be4fe51..fe025c8 100755 Binary files a/bin64/liboverlay.so and b/bin64/liboverlay.so differ diff --git a/bin64/liboverlay.so (copy).0 b/bin64/liboverlay.so (copy).0 deleted file mode 100755 index 7ea0a2f..0000000 Binary files a/bin64/liboverlay.so (copy).0 and /dev/null differ diff --git a/bin64/liboverlay.so.0 b/bin64/liboverlay.so.0 deleted file mode 100755 index 7ea0a2f..0000000 Binary files a/bin64/liboverlay.so.0 and /dev/null differ diff --git a/ftgl/distance-field.o b/ftgl/distance-field.o index 3e5eae4..c641568 100644 Binary files a/ftgl/distance-field.o and b/ftgl/distance-field.o differ diff --git a/ftgl/edtaa3func.o b/ftgl/edtaa3func.o index 67878e7..f7f4543 100644 Binary files a/ftgl/edtaa3func.o and b/ftgl/edtaa3func.o differ diff --git a/ftgl/font-manager.o b/ftgl/font-manager.o index bcb5165..3fe7aad 100644 Binary files a/ftgl/font-manager.o and b/ftgl/font-manager.o differ diff --git a/ftgl/makefont.o b/ftgl/makefont.o index 3d52698..aac95e4 100644 Binary files a/ftgl/makefont.o and b/ftgl/makefont.o differ diff --git a/ftgl/mat4.o b/ftgl/mat4.o index 9ad1a1d..204e958 100644 Binary files a/ftgl/mat4.o and b/ftgl/mat4.o differ diff --git a/ftgl/platform.o b/ftgl/platform.o index f27af78..0c4893b 100644 Binary files a/ftgl/platform.o and b/ftgl/platform.o differ diff --git a/ftgl/text-buffer.o b/ftgl/text-buffer.o index 474528a..8a67c3c 100644 Binary files a/ftgl/text-buffer.o and b/ftgl/text-buffer.o differ diff --git a/ftgl/texture-atlas.o b/ftgl/texture-atlas.o index c2ad287..604ae61 100644 Binary files a/ftgl/texture-atlas.o and b/ftgl/texture-atlas.o differ diff --git a/ftgl/texture-font.o b/ftgl/texture-font.o index 579fe89..9e2dabf 100644 Binary files a/ftgl/texture-font.o and b/ftgl/texture-font.o differ diff --git a/ftgl/utf8-utils.o b/ftgl/utf8-utils.o index b365571..bb42a99 100644 Binary files a/ftgl/utf8-utils.o and b/ftgl/utf8-utils.o differ diff --git a/ftgl/vector.o b/ftgl/vector.o index 8287c5a..27d1118 100644 Binary files a/ftgl/vector.o and b/ftgl/vector.o differ diff --git a/ftgl/vertex-attribute.o b/ftgl/vertex-attribute.o index a7dc12b..d008b9a 100644 Binary files a/ftgl/vertex-attribute.o and b/ftgl/vertex-attribute.o differ diff --git a/ftgl/vertex-buffer.o b/ftgl/vertex-buffer.o index 28be7ab..378cd1e 100644 Binary files a/ftgl/vertex-buffer.o and b/ftgl/vertex-buffer.o differ diff --git a/include/fontapi.h b/include/fontapi.h index dcd268b..115d0c1 100644 --- a/include/fontapi.h +++ b/include/fontapi.h @@ -9,6 +9,7 @@ typedef unsigned int xoverlay_font_handle_t; #define XOVERLAY_FONT_COUNT 64 +#define XOVERLAY_FONT_INVALID_HANDLE (xoverlay_font_handle_t)(-1) xoverlay_font_handle_t xoverlay_font_load(const char *path, float size); diff --git a/include/fontapi_internal.h b/include/fontapi_internal.h index 33621c0..4bdffb3 100644 --- a/include/fontapi_internal.h +++ b/include/fontapi_internal.h @@ -14,12 +14,15 @@ struct fontapi_font_t { int init; + int loaded; + int error; texture_font_t *font; texture_atlas_t *atlas; -}; -struct fontapi_font_t loaded_fonts[XOVERLAY_FONT_COUNT]; + char path[256]; + float size; +}; texture_font_t* fontapi_get(xoverlay_font_handle_t handle); @@ -31,4 +34,4 @@ void fontapi_destroy(); xoverlay_font_handle_t -fontapi_add_font(struct fontapi_font_t font); +fontapi_add_font(struct fontapi_font_t *font); diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..8a640e3 --- /dev/null +++ b/include/log.h @@ -0,0 +1,11 @@ +/* + * log.h + * + * Created on: Nov 14, 2017 + * Author: nullifiedcat + */ + +#pragma once + +void +log_write(const char *format, ...); diff --git a/include/overlay.h b/include/overlay.h index c50dfbf..54c00c6 100644 --- a/include/overlay.h +++ b/include/overlay.h @@ -47,7 +47,7 @@ struct xoverlay_library char mapped; }; -struct xoverlay_library xoverlay_library; +extern struct xoverlay_library xoverlay_library; typedef struct xoverlay_vec4_t { @@ -71,6 +71,7 @@ typedef struct xoverlay_vec4_t }; } xoverlay_vec4_t, xoverlay_rgba_t; +void xoverlay_preinit(); int xoverlay_init(); void xoverlay_destroy(); @@ -109,6 +110,14 @@ xoverlay_draw_string_with_outline(float x, float y, const char *string, xoverlay void xoverlay_draw_circle(float x, float y, float radius, xoverlay_rgba_t color, float thickness, int steps); -void xoverlay_poll_events(); -void xoverlay_draw_begin(); -void xoverlay_draw_end(); +void +xoverlay_get_string_size(const char *string, xoverlay_font_handle_t font, float *out_x, float *out_y); + +void +xoverlay_poll_events(); + +void +xoverlay_draw_begin(); + +void +xoverlay_draw_end(); diff --git a/src/drawglx.c b/src/drawglx.c index 7291362..b51c44c 100644 --- a/src/drawglx.c +++ b/src/drawglx.c @@ -9,6 +9,7 @@ #include "overlay.h" #include "programs.h" #include "vertex_structs.h" +#include "log.h" #include #include @@ -55,7 +56,7 @@ int glx_is_extension_supported(const char *list, const char *extension) int xoverlay_glx_init() { glXQueryVersion(xoverlay_library.display, &glx_state.version_major, &glx_state.version_minor); - printf("GL Version: %s\n", glGetString(GL_VERSION)); + log_write("GL Version: %s\n", glGetString(GL_VERSION)); return 0; } @@ -98,13 +99,18 @@ int xoverlay_glx_create_window() } XFree(info); } + if (fbc_best == -1) + { + log_write("Could not get FB config with 32 depth\n"); + return -1; + } GLXFBConfig fbconfig = fbc[fbc_best]; XFree(fbc); XVisualInfo *info = glXGetVisualFromFBConfig(xoverlay_library.display, fbconfig); if (info == NULL) { - printf("GLX initialization error\n"); + log_write("GLX initialization error\n"); return -1; } Window root = DefaultRootWindow(xoverlay_library.display); @@ -119,11 +125,11 @@ int xoverlay_glx_create_window() attr.do_not_propagate_mask = (KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|ButtonMotionMask); unsigned long mask = CWBackPixel | CWBorderPixel | CWSaveUnder | CWOverrideRedirect | CWColormap | CWEventMask | CWDontPropagate; - printf("depth %d\n", info->depth); + log_write("depth %d\n", info->depth); xoverlay_library.window = XCreateWindow(xoverlay_library.display, root, 0, 0, xoverlay_library.width, xoverlay_library.height, 0, info->depth, InputOutput, info->visual, mask, &attr); if (xoverlay_library.window == 0) { - printf("X window initialization error\n"); + log_write("X window initialization error\n"); return -1; } @@ -145,7 +151,7 @@ int xoverlay_glx_create_window() if (!glx_is_extension_supported(extensions, "GLX_ARB_create_context")) { - printf("Falling back to glXCreateNewContext\n"); + log_write("Falling back to glXCreateNewContext\n"); glx_state.context = glXCreateNewContext(xoverlay_library.display, fbconfig, GLX_RGBA_TYPE, NULL, GL_TRUE); } else @@ -160,29 +166,29 @@ int xoverlay_glx_create_window() } if (glx_state.context == NULL) { - printf("OpenGL context initialization error\n"); + log_write("OpenGL context initialization error\n"); return -1; } if (!glXIsDirect(xoverlay_library.display, glx_state.context)) { - printf("Context is indirect\n"); + log_write("Context is indirect\n"); } else { - printf("Context is direct\n"); + log_write("Context is direct\n"); } glXMakeCurrent(xoverlay_library.display, xoverlay_library.window, glx_state.context); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { - printf("GLEW initialization error: %s\n", glewGetErrorString(glGetError())); + log_write("GLEW initialization error: %s\n", glewGetErrorString(glGetError())); return -1; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(xoverlay_library.display, xoverlay_library.window); - printf("Initializing DS\n"); + log_write("Initializing DS\n"); ds_init(); program_init_everything(); @@ -215,6 +221,8 @@ xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color, x += 0.5f; y += 0.5f; + dx -= 0.5f; + dy -= 0.5f; GLuint idx = dstream.next_index; GLuint indices[6] = { idx, idx + 1, idx + 3, idx + 3, idx +2, idx }; @@ -268,6 +276,8 @@ xoverlay_draw_rect(float x, float y, float w, float h, xoverlay_rgba_t color) x += 0.5f; y += 0.5f; + w -= 0.5f; + h -= 0.5f; struct vertex_v2fc4f vertices[4]; GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx }; @@ -320,6 +330,8 @@ xoverlay_draw_rect_textured(float x, float y, float w, float h, xoverlay_rgba_t x += 0.5f; y += 0.5f; + w -= 0.5f; + h -= 0.5f; GLuint idx = dstream.next_index; @@ -422,9 +434,10 @@ xoverlay_draw_string(float x, float y, const char *string, xoverlay_font_handle_ ds_prepare_font(font); texture_font_t *fnt = fontapi_get(font); - if (fnt == NULL) - return; + { + log_write("xoverlay_draw_string: INVALID FONT HANDLE %u\n", font); + } fnt->rendermode = RENDER_NORMAL; fnt->outline_thickness = 0.0f; @@ -445,6 +458,8 @@ xoverlay_draw_string_with_outline(float x, float y, const char *string, xoverlay outline_color.a = color.a; texture_font_t *fnt = fontapi_get(font); + if (fnt == NULL) + return; fnt->rendermode = RENDER_OUTLINE_POSITIVE; fnt->outline_thickness = outline_width; @@ -455,6 +470,43 @@ xoverlay_draw_string_with_outline(float x, float y, const char *string, xoverlay draw_string_internal(x, y, string, fnt, *(vec4*)&color, out_x, out_y); } +void +xoverlay_get_string_size(const char *string, xoverlay_font_handle_t font, float *out_x, float *out_y) +{ + + float pen_x = 0; + float pen_y = 0; + + float size_x = 0; + float size_y = 0; + + texture_font_t *fnt = fontapi_get(font); + if (fnt == NULL) + return; + texture_font_load_glyphs(fnt, string); + + for (size_t i = 0; i < strlen(string); ++i) + { + texture_glyph_t *glyph = texture_font_find_glyph(fnt, &string[i]); + if (glyph == NULL) + { + continue; + } + + pen_x += texture_glyph_get_kerning(glyph, &string[i]); + pen_x += glyph->advance_x; + if (pen_x > size_x) + size_x = pen_x; + + if (glyph->height > size_y) + size_y = glyph->height; + } + if (out_x) + *out_x = size_x; + if (out_y) + *out_y = size_y; +} + int xoverlay_glx_destroy() { return 0; diff --git a/src/drawglx.o b/src/drawglx.o index 92b2a54..f2ed89a 100644 Binary files a/src/drawglx.o and b/src/drawglx.o differ diff --git a/src/drawglx_internal.c b/src/drawglx_internal.c index 22318c1..ff4b4d9 100644 --- a/src/drawglx_internal.c +++ b/src/drawglx_internal.c @@ -8,6 +8,7 @@ #include "drawglx_internal.h" #include "vertex_structs.h" #include "overlay.h" +#include "log.h" #include #include @@ -297,8 +298,10 @@ ds_render_if_needed() void ds_pre_render() { + glXMakeContextCurrent(xoverlay_library.display, xoverlay_library.window, xoverlay_library.window, glx_state.context); + glClear(GL_COLOR_BUFFER_BIT); - glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT); + glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); @@ -329,6 +332,7 @@ ds_post_render() glPopAttrib(); glFlush(); glXSwapBuffers(xoverlay_library.display, xoverlay_library.window); + glXMakeContextCurrent(xoverlay_library.display, None, None, None); } void diff --git a/src/drawglx_internal.o b/src/drawglx_internal.o index e351e23..07bd9ae 100644 Binary files a/src/drawglx_internal.o and b/src/drawglx_internal.o differ diff --git a/src/fontapi.c b/src/fontapi.c index e6ac169..c21e4e7 100644 --- a/src/fontapi.c +++ b/src/fontapi.c @@ -6,14 +6,20 @@ */ #include "fontapi_internal.h" +#include "log.h" #include #include +#include + +struct fontapi_font_t *loaded_fonts = 0; int fontapi_init() { - memset(loaded_fonts, 0, sizeof(loaded_fonts)); + loaded_fonts = calloc(XOVERLAY_FONT_COUNT, sizeof(struct fontapi_font_t)); + log_write("fontapi: init %u\n", XOVERLAY_FONT_COUNT * sizeof(struct fontapi_font_t)); + fflush(stdout); return 0; } @@ -28,55 +34,95 @@ xoverlay_font_load(const char *path, float size) { struct fontapi_font_t result; memset(&result, 0, sizeof(result)); - result.atlas = texture_atlas_new(1024, 1024, 1); - result.font = texture_font_new_from_file(result.atlas, size, path); - - return fontapi_add_font(result); + strncpy(result.path, path, sizeof(result.path) - 1); + result.size = size; + xoverlay_font_handle_t handle = fontapi_add_font(&result); + log_write("fontapi: init font %u: %d %d\n", handle, loaded_fonts[handle].init, result.init); + fflush(stdout); + return handle; } void xoverlay_font_unload(xoverlay_font_handle_t handle) { - if (handle == 0) - return; if (handle > XOVERLAY_FONT_COUNT) return; - if (loaded_fonts[handle - 1].init == 0) + if (loaded_fonts[handle].init == 0) + return; + if (loaded_fonts[handle].loaded == 0) return; - texture_atlas_delete(loaded_fonts[handle - 1].atlas); - texture_font_delete(loaded_fonts[handle - 1].font); + texture_atlas_delete(loaded_fonts[handle].atlas); + texture_font_delete(loaded_fonts[handle].font); } xoverlay_font_handle_t -fontapi_add_font(struct fontapi_font_t font) +fontapi_add_font(struct fontapi_font_t *font) { for (xoverlay_font_handle_t i = 0; i < XOVERLAY_FONT_COUNT; ++i) { if (loaded_fonts[i].init == 0) { - memcpy(&loaded_fonts[i], &font, sizeof(font)); - loaded_fonts[i].init = 1; - return i + 1; + font->init = 1; + memcpy(&loaded_fonts[i], font, sizeof(struct fontapi_font_t)); + return i; } } - return 0; + return XOVERLAY_FONT_INVALID_HANDLE; +} + +void +fontapi_texture_load(xoverlay_font_handle_t handle) +{ + log_write("fontapi: loading font %u\n", handle); + struct fontapi_font_t *font = &loaded_fonts[handle]; + + font->error = 1; + + font->atlas = texture_atlas_new(1024, 1024, 1); + if (font->atlas != NULL) + { + font->font = texture_font_new_from_file(font->atlas, font->size, font->path); + if (font->font != NULL) + { + font->error = 0; + } + else + { + log_write("fontapi: load: could not init font\n"); + } + } + else + { + log_write("fontapi: load: could not init atlas\n"); + } + + font->loaded = 1; } texture_font_t* fontapi_get(xoverlay_font_handle_t handle) { - if (handle == 0) - return NULL; + log_write("fontapi: finding font %u\n", handle); if (handle >= XOVERLAY_FONT_COUNT) + { + log_write("fontapi: invalid handle %u\n", handle); + fflush(stdout); return NULL; - if (loaded_fonts[handle - 1].init == 0) + } + if (loaded_fonts[handle].init == 0) + { + log_write("fontapi: font '%s' %u not init\n", loaded_fonts[handle - 1].path, handle); + fflush(stdout); return NULL; - return loaded_fonts[handle - 1].font; -} - -void -xoverlay_string_size(xoverlay_font_handle_t handle, const char *string, int *x, int *y) -{ - + } + if (loaded_fonts[handle].loaded == 0) + fontapi_texture_load(handle); + if (loaded_fonts[handle].error == 1) + { + log_write("fontapi: %u loading error\n", handle); + fflush(stdout); + return NULL; + } + return loaded_fonts[handle].font; } diff --git a/src/fontapi.o b/src/fontapi.o index a183610..07778dd 100644 Binary files a/src/fontapi.o and b/src/fontapi.o differ diff --git a/src/input.c b/src/input.c index e0a554c..2394e10 100644 --- a/src/input.c +++ b/src/input.c @@ -6,6 +6,8 @@ */ #include "input.h" +#include "log.h" + #include #include #include diff --git a/src/input.o b/src/input.o index d569443..b77cca8 100644 Binary files a/src/input.o and b/src/input.o differ diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..e5b348c --- /dev/null +++ b/src/log.c @@ -0,0 +1,36 @@ +/* + * log.c + * + * Created on: Nov 14, 2017 + * Author: nullifiedcat + */ + +#include "log.h" + +#include +#include + +FILE *log_file = 0; + +void +log_write(const char *format, ...) +{ + if (log_file == 0) + { + log_file = fopen("/tmp/xoverlay.log", "w"); + if (log_file == 0) + { + perror("log opening"); + log_file = stderr; + } + } + + va_list args; + va_start(args, format); + + vfprintf(log_file, format, args); + fflush(log_file); + + va_end(args); +} + diff --git a/src/log.o b/src/log.o new file mode 100644 index 0000000..d3360dd Binary files /dev/null and b/src/log.o differ diff --git a/src/overlay.c b/src/overlay.c index 371ca85..0ad8b29 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -8,45 +8,69 @@ #include "overlay.h" #include "input.h" #include "drawglx_internal.h" +#include "log.h" #include #include #include #include +#include int event_ShapeNotify; int event_ShapeError; +struct xoverlay_library xoverlay_library; + +int preinit_done = 0; + +void xoverlay_preinit() +{ + preinit_done = 1; + if (init_input() < 0) + { + perror("XOVERLAY: init_input failed"); + return; + } + fontapi_init(); + textureapi_init(); +} int xoverlay_init() { memset(&xoverlay_library, 0, sizeof(struct xoverlay_library)); - if (init_input() < 0) - { - return -1; - } + xoverlay_library.display = XOpenDisplay(NULL); if (xoverlay_library.display == NULL) { - return -1; + log_write("XOVERLAY: XOpenDisplay failed\n"); + return -2; } + if (preinit_done == 0) + xoverlay_preinit(); + else + log_write("Preinit already done\n"); + xoverlay_library.screen = DefaultScreen(xoverlay_library.display); xoverlay_library.width = DisplayWidth(xoverlay_library.display, xoverlay_library.screen); xoverlay_library.height = DisplayHeight(xoverlay_library.display, xoverlay_library.screen); if (!XShapeQueryExtension(xoverlay_library.display, &event_ShapeNotify, &event_ShapeError)) { - return -1; + log_write("XOVERLAY: no shape extension\n"); + return -3; } if (xoverlay_glx_init() < 0) - return -1; + { + log_write("XOVERLAY: xoverlay_glx_init failed\n"); + return -4; + } if (xoverlay_glx_create_window() < 0) - return -1; - - textureapi_init(); - fontapi_init(); + { + log_write("XOVERLAY: xoverlay_glx_create_window failed\n"); + return -5; + } xoverlay_library.init = 1; @@ -232,7 +256,7 @@ void xoverlay_poll_events() /*XEvent xevt; if (XCheckWindowEvent(xoverlay_library.display, xoverlay_library.window, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask, &xevt)) { - printf("event %d\n", xevt.type); + log_write("event %d\n", xevt.type); switch (xevt.type) { case KeyPress: diff --git a/src/overlay.o b/src/overlay.o index 6dfd2cb..78edb43 100644 Binary files a/src/overlay.o and b/src/overlay.o differ diff --git a/src/program_freetype.c b/src/program_freetype.c index 03b5bed..7c0dbb2 100644 --- a/src/program_freetype.c +++ b/src/program_freetype.c @@ -11,6 +11,7 @@ #include "programs.h" #include "texture-atlas.h" #include "drawglx_internal.h" +#include "log.h" DECL_PROGRAM_INIT(freetype) { diff --git a/src/program_freetype.o b/src/program_freetype.o index b4f3bcd..defd43b 100644 Binary files a/src/program_freetype.o and b/src/program_freetype.o differ diff --git a/src/program_triangles_plain.c b/src/program_triangles_plain.c index 7374621..9a32bff 100644 --- a/src/program_triangles_plain.c +++ b/src/program_triangles_plain.c @@ -9,6 +9,7 @@ #include "programs.h" #include "drawglx_internal.h" +#include "log.h" DECL_PROGRAM_INIT(triangles_plain) { diff --git a/src/program_triangles_plain.o b/src/program_triangles_plain.o index 13c1d81..627ba56 100644 Binary files a/src/program_triangles_plain.o and b/src/program_triangles_plain.o differ diff --git a/src/program_triangles_textured.c b/src/program_triangles_textured.c index 6096123..a2c74ed 100644 --- a/src/program_triangles_textured.c +++ b/src/program_triangles_textured.c @@ -9,6 +9,7 @@ #include "programs.h" #include "drawglx_internal.h" +#include "log.h" DECL_PROGRAM_INIT(triangles_textured) { diff --git a/src/program_triangles_textured.o b/src/program_triangles_textured.o index e01b010..00e62d4 100644 Binary files a/src/program_triangles_textured.o and b/src/program_triangles_textured.o differ diff --git a/src/programs.c b/src/programs.c index 8c42c21..9360a9e 100644 --- a/src/programs.c +++ b/src/programs.c @@ -6,6 +6,7 @@ */ #include "drawglx_internal.h" +#include "log.h" #include @@ -20,7 +21,7 @@ GLuint compile_shader(const char *source, GLenum type) { char error_log[256]; glGetShaderInfoLog(shader, sizeof(error_log), NULL, error_log); - printf("GL Shader compilation error:\n%s\n", error_log); + log_write("GL Shader compilation error:\n%s\n", error_log); exit(1); } return shader; @@ -65,7 +66,7 @@ program_init_inplace(struct program_t *program, const char *vertex_format, const { char error_log[256]; glGetShaderInfoLog(program->shader, sizeof(error_log), NULL, error_log); - printf("GL Shader linking error:\n%s\n", error_log); + log_write("GL Shader linking error:\n%s\n", error_log); exit(1); } @@ -120,7 +121,7 @@ const char *shader_v2ft2fc4f_freetype_frag = void program_init_everything() { - printf("Initializing programs\n"); + log_write("Initializing programs\n"); PROGRAM_INIT_INPLACE(&programs[PROGRAM_TRIANGLES_PLAIN], "vertex:2f,color:4f", shader_v2fc4f_frag, shader_v2fc4f_vert, triangles_plain); setup_matrices(programs[PROGRAM_TRIANGLES_PLAIN].shader, 0); PROGRAM_INIT_INPLACE(&programs[PROGRAM_TRIANGLES_TEXTURED], "vertex:2f,tex_coord:2f,color:4f", shader_v2ft2fc4f_frag, shader_v2ft2fc4f_vert, triangles_textured); diff --git a/src/programs.o b/src/programs.o index f21a67c..c14b360 100644 Binary files a/src/programs.o and b/src/programs.o differ diff --git a/src/textureapi.c b/src/textureapi.c index b8a8917..09cfd30 100644 --- a/src/textureapi.c +++ b/src/textureapi.c @@ -7,6 +7,7 @@ #include "drawglx_internal.h" #include "textureapi_internal.h" +#include "log.h" #include #include @@ -28,14 +29,14 @@ textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out) fread(header, 1, 8, file); if (png_sig_cmp(header, 0, 8)) { - printf("textureapi: not a PNG file\n"); + log_write("textureapi: not a PNG file\n"); fclose(file); return -1; } png_structp pngstr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (pngstr == NULL) { - printf("textureapi: png creation error\n"); + log_write("textureapi: png creation error\n"); return -1; } png_infop pnginfo = png_create_info_struct(pngstr); @@ -54,7 +55,7 @@ textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out) int row_bytes; if (PNG_COLOR_TYPE_RGBA != png_get_color_type(pngstr, pnginfo)) { - printf("textureapi: not RGBA PNG\n"); + log_write("textureapi: not RGBA PNG\n"); png_destroy_read_struct(pngstr, pnginfo, pngend); fclose(file); return -1; @@ -65,7 +66,7 @@ textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out) out->data = malloc(row_bytes * height * sizeof(png_byte)); if (out->data == NULL) { - printf("malloc error\n"); + log_write("malloc error\n"); png_destroy_read_struct(pngstr, pnginfo, pngend); fclose(file); return -1; @@ -73,7 +74,7 @@ textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out) row_pointers = malloc(height * sizeof(png_bytep)); if (row_pointers == NULL) { - printf("malloc error\n"); + log_write("malloc error\n"); png_destroy_read_struct(pngstr, pnginfo, pngend); free(out->data); fclose(file); @@ -103,7 +104,7 @@ textureapi_bind(xoverlay_texture_handle_t handle) return; if (!texture->bound) { - printf("generating texture\n"); + log_write("generating texture\n"); glGenTextures(1, &texture->texture_id); glBindTexture(GL_TEXTURE_2D, texture->texture_id); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -125,7 +126,7 @@ xoverlay_texture_load_png_rgba(const char *path) strncpy(result.filename, path, 255); if (textureapi_load_png_rgba(path, &result) != 0) { - printf("textureapi: could not load texture file %s\n", path); + log_write("textureapi: could not load texture file %s\n", path); } return textureapi_add_texture(result); } diff --git a/src/textureapi.o b/src/textureapi.o index 3d6dc6d..7b11ebf 100644 Binary files a/src/textureapi.o and b/src/textureapi.o differ