diff --git a/bin64/liboverlay.so.0 b/bin64/liboverlay.so.0 index cc059a8..097b3c4 100755 Binary files a/bin64/liboverlay.so.0 and b/bin64/liboverlay.so.0 differ diff --git a/include/drawglx_internal.h b/include/drawglx_internal.h index fb9b0ac..a8f37d9 100644 --- a/include/drawglx_internal.h +++ b/include/drawglx_internal.h @@ -45,7 +45,7 @@ struct draw_instruction_t /* DI_PROGRAM_SWITCH_FONT */ xoverlay_font_handle_t font; /* */ - xoverlay_texture_handle thandle; + xoverlay_texture_handle_t thandle; }; }; @@ -101,7 +101,7 @@ void dis_program_switch_texture(GLuint texture); void -dis_textureapi_switch_texture(xoverlay_texture_handle texture); +dis_textureapi_switch_texture(xoverlay_texture_handle_t texture); void dis_program_switch_font(xoverlay_font_handle_t font); @@ -121,7 +121,7 @@ struct draw_state GLuint texture; xoverlay_font_handle_t font; - xoverlay_texture_handle thandle; + xoverlay_texture_handle_t thandle; GLuint shader; }; @@ -155,7 +155,7 @@ ds_render_next_frame(); /* To be called by draw functions */ void -ds_prepare_texture_handle(xoverlay_texture_handle handle); +ds_prepare_texture_handle(xoverlay_texture_handle_t handle); void ds_prepare_texture(GLuint texture); @@ -173,26 +173,3 @@ ds_use_shader(GLuint shader); void ds_use_font(xoverlay_font_handle_t font); - -/* Primitive Internal Drawing API */ - -void -draw_line(vec2 xy, vec2 delta, vec4 color, float thickness); - -void -draw_rect(vec2 xy, vec2 hw, vec4 color); - -void -draw_rect_outline(vec2 xy, vec2 hw, vec4 color, float thickness); - -void -draw_rect_textured(vec2 xy, vec2 hw, vec4 color, xoverlay_texture_handle texture, vec2 t_xy, vec2 t_hw); - -void -draw_string_internal(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, int *out_x, int *out_y); - -void -draw_string(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, int *out_x, int *out_y); - -void -draw_string_with_outline(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, vec4 outline_color, float outline_width, int adjust_outline_alpha, int *out_x, int *out_y); diff --git a/include/overlay.h b/include/overlay.h index eaf9a8c..b492774 100644 --- a/include/overlay.h +++ b/include/overlay.h @@ -70,12 +70,6 @@ typedef struct xoverlay_vec4_t }; } xoverlay_vec4_t, xoverlay_rgba_t; -typedef struct xoverlay_vec2_t -{ - float x; - float y; -} xoverlay_vec2_t; - int xoverlay_init(); void xoverlay_destroy(); @@ -87,22 +81,22 @@ void xoverlay_install_mouse_callback(xoverlay_callback_mousemove callback); xoverlay_rgba_t xoverlay_rgba(int r, int g, int b, int a); void -xoverlay_draw_line(xoverlay_vec2_t xy, xoverlay_vec2_t delta, xoverlay_rgba_t color, float thickness); +xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color, float thickness); void -xoverlay_draw_rect(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color); +xoverlay_draw_rect(float x, float y, float w, float h, xoverlay_rgba_t color); void -xoverlay_draw_rect_outline(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color, float thickness); +xoverlay_draw_rect_outline(float x, float y, float w, float h, xoverlay_rgba_t color, float thickness); void -xoverlay_draw_rect_textured(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color, xoverlay_texture_handle texture, xoverlay_vec2_t t_xy, xoverlay_vec2_t t_hw); +xoverlay_draw_rect_textured(float x, float y, float w, float h, xoverlay_rgba_t color, xoverlay_texture_handle_t texture, float tx, float ty, float tw, float th); void -xoverlay_draw_string(xoverlay_vec2_t xy, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, int *out_x, int *out_y); +xoverlay_draw_string(float x, float y, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, float *out_x, float *out_y); void -xoverlay_draw_string_with_outline(xoverlay_vec2_t xy, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, xoverlay_vec4_t outline_color, float outline_width, int adjust_outline_alpha, int *out_x, int *out_y); +xoverlay_draw_string_with_outline(float x, float y, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, xoverlay_vec4_t outline_color, float outline_width, int adjust_outline_alpha, float *out_x, float *out_y); void xoverlay_poll_events(); void xoverlay_draw_begin(); diff --git a/include/textureapi.h b/include/textureapi.h index b21e0d3..e149a91 100644 --- a/include/textureapi.h +++ b/include/textureapi.h @@ -7,13 +7,13 @@ #pragma once -typedef unsigned xoverlay_texture_handle; +typedef unsigned xoverlay_texture_handle_t; -xoverlay_texture_handle +xoverlay_texture_handle_t xoverlay_texture_load_png_rgba(const char *path); void -xoverlay_texture_unload(xoverlay_texture_handle handle); +xoverlay_texture_unload(xoverlay_texture_handle_t handle); void -xoverlay_texture_get_size(xoverlay_texture_handle handle, int *width, int *height); +xoverlay_texture_get_size(xoverlay_texture_handle_t handle, int *width, int *height); diff --git a/include/textureapi_internal.h b/include/textureapi_internal.h index b8878f6..75dfa87 100644 --- a/include/textureapi_internal.h +++ b/include/textureapi_internal.h @@ -34,10 +34,10 @@ int textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out); struct textureapi_texture_t * -textureapi_get(xoverlay_texture_handle handle); +textureapi_get(xoverlay_texture_handle_t handle); void -textureapi_bind(xoverlay_texture_handle handle); +textureapi_bind(xoverlay_texture_handle_t handle); int textureapi_init(); @@ -45,7 +45,7 @@ textureapi_init(); void textureapi_destroy(); -xoverlay_texture_handle +xoverlay_texture_handle_t textureapi_add_texture(struct textureapi_texture_t font); diff --git a/src/drawglx.c b/src/drawglx.c index 0498ac8..998c7c8 100644 --- a/src/drawglx.c +++ b/src/drawglx.c @@ -5,12 +5,13 @@ * Author: nullifiedcat */ -#include "drawglx.h" +#include "drawglx_internal.h" #include "overlay.h" #include "programs.h" -#include "drawglx_internal.h" +#include "vertex_structs.h" #include +#include #include #include #include @@ -187,6 +188,228 @@ int xoverlay_glx_create_window() return 0; } +void +xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color, float thickness) +{ + ds_prepare_program(PROGRAM_TRIANGLES_PLAIN); + + GLuint idx = dstream.next_index; + GLuint indices[6] = { idx, idx + 1, idx + 3, idx + 3, idx +2, idx }; + struct vertex_v2fc4f vertices[4]; + + float nx = -dy; + float ny = dx; + + float ex = x + dx; + float ey = y + dy; + + float length = sqrtf(nx * nx + ny * ny); + + if (length == 0) + return; + + length /= thickness; + nx /= length; + ny /= length; + + vertices[0].pos.x = x - nx; + vertices[0].pos.y = y - ny; + vertices[0].color = *(vec4*)&color; + + vertices[1].pos.x = x + nx; + vertices[1].pos.y = y + ny; + vertices[1].color = *(vec4*)&color; + + + vertices[2].pos.x = ex - nx; + vertices[2].pos.y = ey - ny; + vertices[2].color = *(vec4*)&color; + + + vertices[3].pos.x = ex + ny; + vertices[3].pos.y = ey + ny; + vertices[3].color = *(vec4*)&color; + + dis_push_vertices(4, sizeof(struct vertex_v2fc4f), vertices); + dis_push_indices(6, indices); +} + +void +xoverlay_draw_rect(float x, float y, float w, float h, xoverlay_rgba_t color) +{ + ds_prepare_program(PROGRAM_TRIANGLES_PLAIN); + GLuint idx = dstream.next_index; + + struct vertex_v2fc4f vertices[4]; + GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx }; + + vertices[0].pos.x = x; + vertices[0].pos.y = y; + vertices[0].color = *(vec4*)&color; + + vertices[1].pos.x = x; + vertices[1].pos.y = y + h; + vertices[1].color = *(vec4*)&color; + + vertices[2].pos.x = x + w; + vertices[2].pos.y = y + h; + vertices[2].color = *(vec4*)&color; + + vertices[3].pos.x = x + w; + vertices[3].pos.y = y; + vertices[3].color = *(vec4*)&color; + + dis_push_vertices(4, sizeof(struct vertex_v2fc4f), vertices); + dis_push_indices(6, indices); +} + +void +xoverlay_draw_rect_outline(float x, float y, float w, float h, xoverlay_rgba_t color, float thickness) +{ + xoverlay_draw_line(x, y, w, 0, color, thickness); + xoverlay_draw_line(x + w, y, 0, h, color, thickness); + xoverlay_draw_line(x + w, y + h, -w, 0, color, thickness); + xoverlay_draw_line(x, y + h, 0, -h, color, thickness); +} + +void +xoverlay_draw_rect_textured(float x, float y, float w, float h, xoverlay_rgba_t color, xoverlay_texture_handle_t texture, float tx, float ty, float tw, float th) +{ + struct textureapi_texture_t *tex = textureapi_get(texture); + + if (tex == NULL) + return; + + ds_prepare_program(PROGRAM_TRIANGLES_TEXTURED); + ds_prepare_texture_handle(texture); + + GLuint idx = dstream.next_index; + + struct vertex_v2ft2fc4f vertices[4]; + GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx }; + + float s0 = tx / tex->width; + float s1 = (tx + tw) / tex->width; + float t0 = ty / tex->height; + float t1 = (ty + th) / tex->height; + + vertices[0].pos.x = x; + vertices[0].pos.y = y; + vertices[0].uv.x = s0; + vertices[0].uv.y = t1; + vertices[0].color = *(vec4*)&color; + + vertices[1].pos.x = x; + vertices[1].pos.y = y + h; + vertices[1].uv.x = s0; + vertices[1].uv.y = t0; + vertices[1].color = *(vec4*)&color; + + vertices[2].pos.x = x + w; + vertices[2].pos.y = y + h; + vertices[2].uv.x = s1; + vertices[2].uv.y = t0; + vertices[2].color = *(vec4*)&color; + + vertices[3].pos.x = x + w; + vertices[3].pos.y = y; + vertices[3].uv.x = s1; + vertices[3].uv.y = t1; + vertices[3].color = *(vec4*)&color; + + dis_push_vertices(4, sizeof(struct vertex_v2ft2fc4f), vertices); + dis_push_indices(6, indices); +} + +void +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_y = y; + float size_y = 0; + + 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; + } + if (i > 0) + { + x += texture_glyph_get_kerning(glyph, &string[i - 1]); + } + + float x0 = (pen_x + glyph->offset_x); + float y0 = (pen_y - glyph->offset_y); + float x1 = (x0 + glyph->width); + float y1 = (y0 + glyph->height); + float s0 = glyph->s0; + float t0 = glyph->t0; + float s1 = glyph->s1; + float t1 = glyph->t1; + + GLuint idx = dstream.next_index; + GLuint indices[] = { idx, idx + 1, idx + 2, + idx + 2, idx + 3, idx }; + struct vertex_v2ft2fc4f vertices[] = { + { (vec2){ x0, y0 }, (vec2){ s0, t0 }, color }, + { (vec2){ x0, y1 }, (vec2){ s0, t1 }, color }, + { (vec2){ x1, y1 }, (vec2){ s1, t1 }, color }, + { (vec2){ x1, y0 }, (vec2){ s1, t0 }, color } + }; + + dis_push_indices(6, indices); + dis_push_vertices(4, sizeof(struct vertex_v2ft2fc4f), vertices); + + pen_x += glyph->advance_x; + if (glyph->height > size_y) + size_y = glyph->height; + } + if (out_x) + *out_x = pen_x - x; + if (out_y) + *out_y = size_y; +} +void +xoverlay_draw_string(float x, float y, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, float *out_x, float *out_y) +{ + ds_prepare_program(PROGRAM_FREETYPE); + ds_prepare_font(font); + + texture_font_t *fnt = fontapi_get(font); + + if (fnt == NULL) + return; + + fnt->rendermode = RENDER_NORMAL; + fnt->outline_thickness = 0.0f; + + draw_string_internal(x, y, string, fnt, *(vec4*)&color, out_x, out_y); +} + +void +xoverlay_draw_string_with_outline(float x, float y, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, xoverlay_vec4_t outline_color, float outline_width, int adjust_outline_alpha, float *out_x, float *out_y) +{ + ds_prepare_program(PROGRAM_FREETYPE); + ds_prepare_font(font); + + if (adjust_outline_alpha) + outline_color.a = color.a; + + texture_font_t *fnt = fontapi_get(font); + + fnt->rendermode = RENDER_OUTLINE_POSITIVE; + fnt->outline_thickness = outline_width; + draw_string_internal(x, y, string, fnt, *(vec4*)&outline_color, NULL, NULL); + + fnt->rendermode = RENDER_NORMAL; + fnt->outline_thickness = 0.0f; + draw_string_internal(x, y, string, fnt, *(vec4*)&color, out_x, out_y); +} + int xoverlay_glx_destroy() { return 0; diff --git a/src/drawglx.o b/src/drawglx.o index d68a706..0caf18b 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 d0193d4..22318c1 100644 --- a/src/drawglx_internal.c +++ b/src/drawglx_internal.c @@ -239,7 +239,7 @@ dis_fetch_instruction() } void -dis_textureapi_switch_texture(xoverlay_texture_handle texture) +dis_textureapi_switch_texture(xoverlay_texture_handle_t texture) { struct draw_instruction_t *last = dis_last_pushed_instruction(); @@ -429,7 +429,7 @@ ds_use_font(xoverlay_font_handle_t font) } void -ds_prepare_texture_handle(xoverlay_texture_handle handle) +ds_prepare_texture_handle(xoverlay_texture_handle_t handle) { if (handle != ds.thandle) { @@ -467,238 +467,3 @@ ds_prepare_font(xoverlay_font_handle_t font) ds.font = font; } } - -void -draw_line(vec2 xy, vec2 delta, vec4 color, float thickness) -{ - ds_prepare_program(PROGRAM_TRIANGLES_PLAIN); - GLuint idx = dstream.next_index; - - struct vertex_v2fc4f vertices[4]; - /* A C => ABC, CDB - * B D - */ - GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx + 1 }; - - vec2 normal = { .x = -delta.y, .y = delta.x }; - vec2 end = (vec2){ xy.x + delta.x, xy.y + delta.y }; - float length = sqrtf(normal.x * normal.x + normal.y * normal.y); - if (length == 0) - return; - length /= thickness; - normal.x /= length; - normal.y /= length; - - vertices[0].pos.x = xy.x - normal.x; - vertices[0].pos.y = xy.y - normal.y; - vertices[0].color = color; - - vertices[1].pos.x = xy.x + normal.x; - vertices[1].pos.y = xy.y + normal.y; - vertices[1].color = color; - - vertices[2].pos.x = end.x - normal.x; - vertices[2].pos.y = end.y - normal.y; - vertices[2].color = color; - - vertices[3].pos.x = end.x + normal.x; - vertices[3].pos.y = end.y + normal.y; - vertices[3].color = color; - - dis_push_vertices(4, sizeof(struct vertex_v2fc4f), vertices); - dis_push_indices(6, indices); -} - -void -draw_rect(vec2 xy, vec2 hw, vec4 color) -{ - ds_prepare_program(PROGRAM_TRIANGLES_PLAIN); - GLuint idx = dstream.next_index; - - struct vertex_v2fc4f vertices[4]; - /* A D => ABC, CDA - * B C - */ - GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx }; - - vertices[0].pos.x = xy.x; - vertices[0].pos.y = xy.y; - vertices[0].color = color; - - vertices[1].pos.x = xy.x; - vertices[1].pos.y = xy.y + hw.y; - vertices[1].color = color; - - vertices[2].pos.x = xy.x + hw.x; - vertices[2].pos.y = xy.y + hw.y; - vertices[2].color = color; - - vertices[3].pos.x = xy.x + hw.x; - vertices[3].pos.y = xy.y; - vertices[3].color = color; - - dis_push_vertices(4, sizeof(struct vertex_v2fc4f), vertices); - dis_push_indices(6, indices); -} - -void -draw_rect_outline(vec2 xy, vec2 hw, vec4 color, float thickness) -{ - vec2 point = xy; - vec2 delta = { hw.x, 0 }; - draw_line(point, delta, color, thickness); - point.x += delta.x; - delta.x = 0; - delta.y = hw.y; - draw_line(point, delta, color, thickness); - point.y += delta.y; - delta.x = -hw.x; - delta.y = 0; - draw_line(point, delta, color, thickness); - point.x += delta.x; - delta.x = 0; - delta.y = -hw.y; - draw_line(point, delta, color, thickness); -} - - -void -draw_rect_textured(vec2 xy, vec2 hw, vec4 color, xoverlay_texture_handle texture, vec2 t_xy, vec2 t_hw) -{ - struct textureapi_texture_t *tx = textureapi_get(texture); - if (tx == NULL) - return; - - ds_prepare_program(PROGRAM_TRIANGLES_TEXTURED); - ds_prepare_texture_handle(texture); - - GLuint idx = dstream.next_index; - - struct vertex_v2ft2fc4f vertices[4]; - /* A C => ABC, CDB - * B D - */ - GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx }; - - float s0 = t_xy.x / tx->width; - float s1 = (t_xy.x + t_hw.x) / tx->width; - float t0 = t_xy.y / tx->height; - float t1 = (t_xy.y + t_hw.y) / tx->height; - - vertices[0].pos.x = xy.x; - vertices[0].pos.y = xy.y; - vertices[0].uv = (vec2){ s0, t1 }; - vertices[0].color = color; - - vertices[1].pos.x = xy.x; - vertices[1].pos.y = xy.y + hw.y; - vertices[1].uv = (vec2){ s0, t0 }; - vertices[1].color = color; - - vertices[2].pos.x = xy.x + hw.x; - vertices[2].pos.y = xy.y + hw.y; - vertices[2].uv = (vec2){ s1, t0 }; - vertices[2].color = color; - - vertices[3].pos.x = xy.x + hw.x; - vertices[3].pos.y = xy.y; - vertices[3].uv = (vec2){ s1, t1 }; - vertices[3].color = color; - - dis_push_vertices(4, sizeof(struct vertex_v2ft2fc4f), vertices); - dis_push_indices(6, indices); -} - -void -draw_string_internal(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, int *out_x, int *out_y) -{ - ds_prepare_program(PROGRAM_FREETYPE); - ds_prepare_font(font); - - texture_font_t *fnt = fontapi_get(font); - if (!fnt) - return; - - vec2 pen = { xy.x, xy.y }; - vec2 pen_start = pen; - vec2 size = { 0, 0 }; - 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; - } - if (i > 0) - { - pen.x += texture_glyph_get_kerning(glyph, &string[i - 1]); - } - - float x0 = (pen.x + glyph->offset_x); - float y0 = (pen.y - glyph->offset_y); - float x1 = (x0 + glyph->width); - float y1 = (y0 + glyph->height); - float s0 = glyph->s0; - float t0 = glyph->t0; - float s1 = glyph->s1; - float t1 = glyph->t1; - - GLuint idx = dstream.next_index; - GLuint indices[] = { idx, idx + 1, idx + 2, - idx + 2, idx + 3, idx }; - struct vertex_v2ft2fc4f vertices[] = { - { (vec2){ x0, y0 }, (vec2){ s0, t0 }, color }, - { (vec2){ x0, y1 }, (vec2){ s0, t1 }, color }, - { (vec2){ x1, y1 }, (vec2){ s1, t1 }, color }, - { (vec2){ x1, y0 }, (vec2){ s1, t0 }, color } - }; - - dis_push_indices(6, indices); - dis_push_vertices(4, sizeof(struct vertex_v2ft2fc4f), vertices); - - pen.x += glyph->advance_x; - if (glyph->height > size.y) - size.y = glyph->height; - } - size.x = pen.x - pen_start.x; - if (out_x) - *out_x = size.x; - if (out_y) - *out_y = size.y; -} - -void -draw_string(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, int *out_x, int *out_y) -{ - ds_prepare_program(PROGRAM_FREETYPE); - ds_prepare_font(font); - - texture_font_t *fnt = fontapi_get(font); - fnt->rendermode = RENDER_NORMAL; - fnt->outline_thickness = 0.0f; - - draw_string_internal(xy, string, font, color, out_x, out_y); -} - -void -draw_string_with_outline(vec2 xy, const char *string, xoverlay_font_handle_t font, vec4 color, vec4 outline_color, float outline_width, int adjust_outline_alpha, int *out_x, int *out_y) -{ - ds_prepare_program(PROGRAM_FREETYPE); - ds_prepare_font(font); - - if (adjust_outline_alpha) - outline_color.a = color.a; - - texture_font_t *fnt = fontapi_get(font); - - fnt->rendermode = RENDER_OUTLINE_POSITIVE; - fnt->outline_thickness = outline_width; - draw_string_internal(xy, string, font, outline_color, 0, 0); - - fnt->rendermode = RENDER_NORMAL; - fnt->outline_thickness = 0.0f; - draw_string_internal(xy, string, font, color, out_x, out_y); - -} diff --git a/src/drawglx_internal.o b/src/drawglx_internal.o index 56cff53..1c0f973 100644 Binary files a/src/drawglx_internal.o and b/src/drawglx_internal.o differ diff --git a/src/overlay.c b/src/overlay.c index e9448fa..0bc8af9 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -91,24 +91,6 @@ xoverlay_rgba_t xoverlay_rgba(int r, int g, int b, int a) return result; } -void -xoverlay_draw_line(xoverlay_vec2_t xy, xoverlay_vec2_t delta, xoverlay_rgba_t color, float thickness) -{ - draw_line(*(vec2*)&xy, *(vec2*)&delta, *(vec4*)&color, thickness); -} - -void -xoverlay_draw_rect(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color) -{ - draw_rect(*(vec2*)&xy, *(vec2*)&hw, *(vec4*)&color); -} - -void -xoverlay_draw_rect_outline(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color, float thickness) -{ - draw_rect_outline(*(vec2*)&xy, *(vec2*)&hw, *(vec4*)&color, thickness); -} - void xoverlay_install_keyboard_callback(xoverlay_callback_keypress callback) { xoverlay_library.cb_keypress = callback; @@ -257,24 +239,6 @@ void xoverlay_poll_events() }*/ } -void -xoverlay_draw_string(xoverlay_vec2_t xy, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, int *out_x, int *out_y) -{ - draw_string(*(vec2*)&xy, string, font, *(vec4*)&color, out_x, out_y); -} - -void -xoverlay_draw_string_with_outline(xoverlay_vec2_t xy, const char *string, xoverlay_font_handle_t font, xoverlay_vec4_t color, xoverlay_vec4_t outline_color, float outline_width, int adjust_outline_alpha, int *out_x, int *out_y) -{ - draw_string_with_outline(*(vec2*)&xy, string, font, *(vec4*)&color, *(vec4*)&outline_color, outline_width, adjust_outline_alpha, out_x, out_y); -} - -void -xoverlay_draw_rect_textured(xoverlay_vec2_t xy, xoverlay_vec2_t hw, xoverlay_rgba_t color, xoverlay_texture_handle texture, xoverlay_vec2_t t_xy, xoverlay_vec2_t t_hw) -{ - draw_rect_textured(*(vec2*)&xy, *(vec2*)&hw, *(vec4*)&color, texture, *(vec2*)&t_xy, *(vec2*)&t_hw); -} - void xoverlay_draw_begin() { if (!xoverlay_library.init) return; diff --git a/src/overlay.o b/src/overlay.o index fd96fd8..289a77d 100644 Binary files a/src/overlay.o and b/src/overlay.o differ diff --git a/src/program_freetype.o b/src/program_freetype.o index 7a0b554..b4f3bcd 100644 Binary files a/src/program_freetype.o and b/src/program_freetype.o differ diff --git a/src/program_triangles_plain.o b/src/program_triangles_plain.o index bcdc436..13c1d81 100644 Binary files a/src/program_triangles_plain.o and b/src/program_triangles_plain.o differ diff --git a/src/program_triangles_textured.o b/src/program_triangles_textured.o index e720989..e01b010 100644 Binary files a/src/program_triangles_textured.o and b/src/program_triangles_textured.o differ diff --git a/src/programs.o b/src/programs.o index c624a33..f21a67c 100644 Binary files a/src/programs.o and b/src/programs.o differ diff --git a/src/textureapi.c b/src/textureapi.c index 24993de..b8a8917 100644 --- a/src/textureapi.c +++ b/src/textureapi.c @@ -96,7 +96,7 @@ textureapi_load_png_rgba(const char *name, struct textureapi_texture_t *out) void -textureapi_bind(xoverlay_texture_handle handle) +textureapi_bind(xoverlay_texture_handle_t handle) { struct textureapi_texture_t *texture = textureapi_get(handle); if (texture == NULL || texture->init == 0) @@ -117,7 +117,7 @@ textureapi_bind(xoverlay_texture_handle handle) ds_bind_texture(texture->texture_id); } -xoverlay_texture_handle +xoverlay_texture_handle_t xoverlay_texture_load_png_rgba(const char *path) { struct textureapi_texture_t result; @@ -132,7 +132,7 @@ xoverlay_texture_load_png_rgba(const char *path) void -xoverlay_texture_get_size(xoverlay_texture_handle handle, int *width, int *height) +xoverlay_texture_get_size(xoverlay_texture_handle_t handle, int *width, int *height) { struct textureapi_texture_t *tx = textureapi_get(handle); if (tx == NULL) @@ -144,7 +144,7 @@ xoverlay_texture_get_size(xoverlay_texture_handle handle, int *width, int *heigh } struct textureapi_texture_t * -textureapi_get(xoverlay_texture_handle handle) +textureapi_get(xoverlay_texture_handle_t handle) { if (handle == 0 || handle >= XOVERLAY_TEXTURE_COUNT) return NULL; @@ -166,10 +166,10 @@ textureapi_destroy() } -xoverlay_texture_handle +xoverlay_texture_handle_t textureapi_add_texture(struct textureapi_texture_t texture) { - for (xoverlay_texture_handle i = 0; i < XOVERLAY_TEXTURE_COUNT; ++i) + for (xoverlay_texture_handle_t i = 0; i < XOVERLAY_TEXTURE_COUNT; ++i) { if (loaded_textures[i].init == 0) { @@ -182,7 +182,7 @@ textureapi_add_texture(struct textureapi_texture_t texture) } void -xoverlay_texture_unload(xoverlay_texture_handle handle) +xoverlay_texture_unload(xoverlay_texture_handle_t handle) { // TODO } diff --git a/src/textureapi.o b/src/textureapi.o new file mode 100644 index 0000000..3d6dc6d Binary files /dev/null and b/src/textureapi.o differ diff --git a/src/textureapi_internal.o b/src/textureapi_internal.o deleted file mode 100644 index b3edaf6..0000000 Binary files a/src/textureapi_internal.o and /dev/null differ