6 fps lol
This commit is contained in:
parent
59c6aed2c8
commit
25ad47a5e4
6
Makefile
6
Makefile
@ -1,7 +1,7 @@
|
||||
CC=$(shell sh -c "which gcc-7 || which gcc")
|
||||
CFLAGS=-O3 -Wall -fPIC -fmessage-length=0 -D_GNU_SOURCE=1 -DFREETYPE_GL_USE_VAO=1 -g3 -ggdb -Iinclude -isystemftgl -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2
|
||||
LDFLAGS=-shared
|
||||
LDLIBS=-lm -lX11 -lXext -lrt -lpthread -lXfixes -lGL -lfreetype -lGLEW
|
||||
LDLIBS=-lm -lX11 -lXext -lrt -lpthread -lXfixes -lGL -lfreetype -lGLEW -lpng
|
||||
SRC_DIR=src
|
||||
BIN32_DIR=bin32
|
||||
BIN64_DIR=bin64
|
||||
@ -9,8 +9,8 @@ SOURCES=$(shell find $(SRC_DIR) -name "*.c" -print)
|
||||
SOURCES+=$(shell find "ftgl" -name "*.c" -print)
|
||||
OBJECTS=$(SOURCES:.c=.o)
|
||||
|
||||
TARGET32=$(BIN32_DIR)/liboverlay.so.0
|
||||
TARGET64=$(BIN64_DIR)/liboverlay.so.0
|
||||
TARGET32=$(BIN32_DIR)/liboverlay.so
|
||||
TARGET64=$(BIN64_DIR)/liboverlay.so
|
||||
TARGET=undefined
|
||||
|
||||
.PHONY: clean directories
|
||||
|
BIN
bin64/liboverlay.so
Executable file
BIN
bin64/liboverlay.so
Executable file
Binary file not shown.
BIN
bin64/liboverlay.so (copy).0
Executable file
BIN
bin64/liboverlay.so (copy).0
Executable file
Binary file not shown.
Binary file not shown.
@ -44,6 +44,7 @@ struct xoverlay_library
|
||||
|
||||
char init;
|
||||
char drawing;
|
||||
char mapped;
|
||||
};
|
||||
|
||||
struct xoverlay_library xoverlay_library;
|
||||
@ -78,7 +79,14 @@ void xoverlay_install_click_callback(xoverlay_callback_click callback);
|
||||
void xoverlay_install_scroll_callback(xoverlay_callback_scroll callback);
|
||||
void xoverlay_install_mouse_callback(xoverlay_callback_mousemove callback);
|
||||
|
||||
xoverlay_rgba_t xoverlay_rgba(int r, int g, int b, int a);
|
||||
void
|
||||
xoverlay_show();
|
||||
|
||||
void
|
||||
xoverlay_hide();
|
||||
|
||||
xoverlay_rgba_t
|
||||
xoverlay_rgba(int r, int g, int b, int a);
|
||||
|
||||
void
|
||||
xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color, float thickness);
|
||||
@ -98,6 +106,9 @@ xoverlay_draw_string(float x, float y, const char *string, xoverlay_font_handle_
|
||||
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);
|
||||
|
||||
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();
|
||||
|
@ -136,7 +136,8 @@ int xoverlay_glx_create_window()
|
||||
|
||||
XFree(info);
|
||||
XStoreName(xoverlay_library.display, xoverlay_library.window, "OverlayWindow");
|
||||
XMapWindow(xoverlay_library.display, xoverlay_library.window);
|
||||
|
||||
xoverlay_show();
|
||||
|
||||
const char *extensions = glXQueryExtensionsString(xoverlay_library.display, xoverlay_library.screen);
|
||||
glXCreateContextAttribsARBfn glXCreateContextAttribsARB = (glXCreateContextAttribsARBfn)
|
||||
@ -188,11 +189,33 @@ int xoverlay_glx_create_window()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
xoverlay_draw_circle(float x, float y, float radius, xoverlay_rgba_t color, float thickness, int steps)
|
||||
{
|
||||
float px = 0;
|
||||
float py = 0;
|
||||
for (int i = 0; i < steps; i++) {
|
||||
float ang = 2 * M_PI * ((float)i / steps);
|
||||
if (!i)
|
||||
ang = 2 * M_PI * ((float)(steps - 1) / steps);
|
||||
if (i)
|
||||
xoverlay_draw_line(px, py, x - px + radius * cos(ang), y - py + radius * sin(ang), color, thickness);
|
||||
px = x + radius * cos(ang);
|
||||
py = y + radius * sin(ang);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color, float thickness)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
ds_prepare_program(PROGRAM_TRIANGLES_PLAIN);
|
||||
|
||||
x += 0.5f;
|
||||
y += 0.5f;
|
||||
|
||||
GLuint idx = dstream.next_index;
|
||||
GLuint indices[6] = { idx, idx + 1, idx + 3, idx + 3, idx +2, idx };
|
||||
struct vertex_v2fc4f vertices[4];
|
||||
@ -226,7 +249,7 @@ xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color,
|
||||
vertices[2].color = *(vec4*)&color;
|
||||
|
||||
|
||||
vertices[3].pos.x = ex + ny;
|
||||
vertices[3].pos.x = ex + nx;
|
||||
vertices[3].pos.y = ey + ny;
|
||||
vertices[3].color = *(vec4*)&color;
|
||||
|
||||
@ -237,9 +260,15 @@ xoverlay_draw_line(float x, float y, float dx, float dy, xoverlay_rgba_t color,
|
||||
void
|
||||
xoverlay_draw_rect(float x, float y, float w, float h, xoverlay_rgba_t color)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
ds_prepare_program(PROGRAM_TRIANGLES_PLAIN);
|
||||
GLuint idx = dstream.next_index;
|
||||
|
||||
x += 0.5f;
|
||||
y += 0.5f;
|
||||
|
||||
struct vertex_v2fc4f vertices[4];
|
||||
GLuint indices[6] = { idx, idx + 1, idx + 2, idx + 2, idx + 3, idx };
|
||||
|
||||
@ -266,6 +295,9 @@ xoverlay_draw_rect(float x, float y, float w, float h, xoverlay_rgba_t color)
|
||||
void
|
||||
xoverlay_draw_rect_outline(float x, float y, float w, float h, xoverlay_rgba_t color, float thickness)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
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);
|
||||
@ -275,6 +307,9 @@ xoverlay_draw_rect_outline(float x, float y, float w, float h, xoverlay_rgba_t c
|
||||
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)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
struct textureapi_texture_t *tex = textureapi_get(texture);
|
||||
|
||||
if (tex == NULL)
|
||||
@ -283,6 +318,9 @@ xoverlay_draw_rect_textured(float x, float y, float w, float h, xoverlay_rgba_t
|
||||
ds_prepare_program(PROGRAM_TRIANGLES_TEXTURED);
|
||||
ds_prepare_texture_handle(texture);
|
||||
|
||||
x += 0.5f;
|
||||
y += 0.5f;
|
||||
|
||||
GLuint idx = dstream.next_index;
|
||||
|
||||
struct vertex_v2ft2fc4f vertices[4];
|
||||
@ -324,6 +362,7 @@ xoverlay_draw_rect_textured(float x, float y, float w, float h, xoverlay_rgba_t
|
||||
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;
|
||||
@ -376,6 +415,9 @@ draw_string_internal(float x, float y, const char *string, texture_font_t *fnt,
|
||||
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)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
ds_prepare_program(PROGRAM_FREETYPE);
|
||||
ds_prepare_font(font);
|
||||
|
||||
@ -393,6 +435,9 @@ xoverlay_draw_string(float x, float y, const char *string, xoverlay_font_handle_
|
||||
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)
|
||||
{
|
||||
if (xoverlay_library.mapped == 0 || xoverlay_library.drawing == 0)
|
||||
return;
|
||||
|
||||
ds_prepare_program(PROGRAM_FREETYPE);
|
||||
ds_prepare_font(font);
|
||||
|
||||
|
BIN
src/drawglx.o
BIN
src/drawglx.o
Binary file not shown.
Binary file not shown.
@ -78,10 +78,14 @@ int poll_low_event(int fd, struct input_event *event)
|
||||
int poll_event(int device, struct input_event_parsed *event)
|
||||
{
|
||||
struct input_event ie;
|
||||
if (!poll_low_event(*input_devices[device], &ie))
|
||||
int failcount = 0;
|
||||
while (failcount++ < 2)
|
||||
{
|
||||
return 0;
|
||||
if (poll_low_event(*input_devices[device], &ie))
|
||||
break;
|
||||
}
|
||||
if (failcount >= 2)
|
||||
return 0;
|
||||
switch (ie.type)
|
||||
{
|
||||
case EV_KEY:
|
||||
|
BIN
src/input.o
BIN
src/input.o
Binary file not shown.
@ -49,6 +49,7 @@ int xoverlay_init()
|
||||
fontapi_init();
|
||||
|
||||
xoverlay_library.init = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -116,6 +117,26 @@ void xoverlay_install_mouse_callback(xoverlay_callback_mousemove callback)
|
||||
xoverlay_library.cb_draw = callback;
|
||||
}*/
|
||||
|
||||
void
|
||||
xoverlay_show()
|
||||
{
|
||||
if (xoverlay_library.mapped == 1)
|
||||
return;
|
||||
|
||||
XMapWindow(xoverlay_library.display, xoverlay_library.window);
|
||||
xoverlay_library.mapped = 1;
|
||||
}
|
||||
|
||||
void
|
||||
xoverlay_hide()
|
||||
{
|
||||
if (xoverlay_library.mapped == 0)
|
||||
return;
|
||||
|
||||
XUnmapWindow(xoverlay_library.display, xoverlay_library.window);
|
||||
xoverlay_library.mapped = 0;
|
||||
}
|
||||
|
||||
void xoverlay_poll_events()
|
||||
{
|
||||
if (!xoverlay_library.init) return;
|
||||
|
BIN
src/overlay.o
BIN
src/overlay.o
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user