font machine broke
This commit is contained in:
parent
25ad47a5e4
commit
ad32cb9a2a
4
Makefile
4
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:
|
||||
|
BIN
bin32/liboverlay.so
Executable file
BIN
bin32/liboverlay.so
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ftgl/makefont.o
BIN
ftgl/makefont.o
Binary file not shown.
BIN
ftgl/mat4.o
BIN
ftgl/mat4.o
Binary file not shown.
BIN
ftgl/platform.o
BIN
ftgl/platform.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ftgl/vector.o
BIN
ftgl/vector.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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);
|
||||
|
@ -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);
|
||||
|
11
include/log.h
Normal file
11
include/log.h
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* log.h
|
||||
*
|
||||
* Created on: Nov 14, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void
|
||||
log_write(const char *format, ...);
|
@ -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();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "overlay.h"
|
||||
#include "programs.h"
|
||||
#include "vertex_structs.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <math.h>
|
||||
@ -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;
|
||||
|
BIN
src/drawglx.o
BIN
src/drawglx.o
Binary file not shown.
@ -8,6 +8,7 @@
|
||||
#include "drawglx_internal.h"
|
||||
#include "vertex_structs.h"
|
||||
#include "overlay.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
@ -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
|
||||
|
Binary file not shown.
@ -6,14 +6,20 @@
|
||||
*/
|
||||
|
||||
#include "fontapi_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
BIN
src/fontapi.o
BIN
src/fontapi.o
Binary file not shown.
@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "input.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
|
BIN
src/input.o
BIN
src/input.o
Binary file not shown.
36
src/log.c
Normal file
36
src/log.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* log.c
|
||||
*
|
||||
* Created on: Nov 14, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -8,45 +8,69 @@
|
||||
#include "overlay.h"
|
||||
#include "input.h"
|
||||
#include "drawglx_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <GL/glx.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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:
|
||||
|
BIN
src/overlay.o
BIN
src/overlay.o
Binary file not shown.
@ -11,6 +11,7 @@
|
||||
#include "programs.h"
|
||||
#include "texture-atlas.h"
|
||||
#include "drawglx_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
DECL_PROGRAM_INIT(freetype)
|
||||
{
|
||||
|
Binary file not shown.
@ -9,6 +9,7 @@
|
||||
|
||||
#include "programs.h"
|
||||
#include "drawglx_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
DECL_PROGRAM_INIT(triangles_plain)
|
||||
{
|
||||
|
Binary file not shown.
@ -9,6 +9,7 @@
|
||||
|
||||
#include "programs.h"
|
||||
#include "drawglx_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
DECL_PROGRAM_INIT(triangles_textured)
|
||||
{
|
||||
|
Binary file not shown.
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "drawglx_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -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);
|
||||
|
BIN
src/programs.o
BIN
src/programs.o
Binary file not shown.
@ -7,6 +7,7 @@
|
||||
|
||||
#include "drawglx_internal.h"
|
||||
#include "textureapi_internal.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
@ -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);
|
||||
}
|
||||
|
BIN
src/textureapi.o
BIN
src/textureapi.o
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user