opengl support

This commit is contained in:
IoIxD 2025-12-08 23:53:00 -07:00
commit 4513475528

View file

@ -370,15 +370,22 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) {
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glViewport(x, y, width, height);
return MwTRUE;
}
static void egl_resetup(MwLL handle) {
int err;
glViewport(handle->wayland.x, handle->wayland.y, handle->wayland.ww, handle->wayland.wh);
glScissor(handle->wayland.x, handle->wayland.y, handle->wayland.ww, handle->wayland.wh);
float w, h;
if(handle->wayland.parent == NULL) {
w = handle->wayland.ww;
h = handle->wayland.wh;
} else {
w = handle->wayland.parent->wayland.ww;
h = handle->wayland.parent->wayland.wh;
}
glViewport(handle->wayland.x, handle->wayland.y, w, h);
}
static void recursive_draw(MwLL handle) {
@ -556,8 +563,9 @@ static void setup_callbacks(struct _MwLLWayland* wayland) {
static void setup_toplevel(MwLL r, int x, int y) {
int i;
r->wayland.type = MWLL_WAYLAND_TOPLEVEL;
r->wayland.toplevel = malloc(sizeof(struct _MwLLWaylandTopLevel));
r->wayland.type = MWLL_WAYLAND_TOPLEVEL;
r->wayland.toplevel = malloc(sizeof(struct _MwLLWaylandTopLevel));
r->wayland.topmost_parent = NULL;
setup_callbacks(&r->wayland);
@ -754,8 +762,8 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
handle->wayland.x = x;
handle->wayland.y = y;
if(handle->wayland.has_set_xy) {
timed_redraw_by_epoch(handle->wayland.topmost_parent, 15);
recursive_draw(handle->wayland.topmost_parent);
timed_redraw_by_epoch(handle->wayland.topmost_parent, 25);
// recursive_draw(handle->wayland.topmost_parent);
} else if(x != 0 && y != 0) {
handle->wayland.has_set_xy = MwTRUE;
}
@ -775,8 +783,8 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
xdg_surface_set_window_geometry(handle->wayland.toplevel->xdg_surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
} else {
timed_redraw_by_epoch(handle->wayland.topmost_parent, 15);
recursive_draw(handle->wayland.topmost_parent);
timed_redraw_by_epoch(handle->wayland.topmost_parent, 25);
// recursive_draw(handle->wayland.topmost_parent);
}
}
@ -790,8 +798,8 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
w = handle->wayland.ww;
h = handle->wayland.wh;
} else {
w = handle->wayland.parent->wayland.ww;
h = handle->wayland.parent->wayland.wh;
w = handle->wayland.topmost_parent->wayland.ww;
h = handle->wayland.topmost_parent->wayland.wh;
}
glColor3f(color->common.red / 255.0, color->common.green / 255.0, color->common.blue / 255.0);
@ -812,12 +820,12 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
int i;
float w, h;
if(handle->wayland.parent == NULL) {
if(handle->wayland.topmost_parent == NULL) {
w = handle->wayland.ww;
h = handle->wayland.wh;
} else {
w = handle->wayland.parent->wayland.ww;
h = handle->wayland.parent->wayland.wh;
w = handle->wayland.topmost_parent->wayland.ww;
h = handle->wayland.topmost_parent->wayland.wh;
}
glLineWidth(1);
@ -835,7 +843,6 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
}
static void MwLLBeginDrawImpl(MwLL handle) {
egl_resetup(handle);
if(handle->wayland.parent == NULL) {
if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) {
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
@ -939,12 +946,12 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
float x, y, w, h;
if(handle->wayland.parent == NULL) {
if(handle->wayland.topmost_parent == NULL) {
w = handle->wayland.ww;
h = handle->wayland.wh;
} else {
w = handle->wayland.parent->wayland.ww;
h = handle->wayland.parent->wayland.wh;
w = handle->wayland.topmost_parent->wayland.ww;
h = handle->wayland.topmost_parent->wayland.wh;
}
x = ((float)(handle->wayland.x + rect->x) / (w / 2)) - 1.0;