mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-22 00:54:08 +00:00
Unfinished Wayland PR (#1)
moved from the github repo. current progress: <img width="389" alt="image.png" src="attachments/6a2cb365-7348-44b4-8fa7-9980df965a67"> Other notes: - took the opportunity to remove MwLLSetBackground which I was told was deprecated - Updated .gitignore to more accurately cover/remove example binaries - Uses OpenGL as the backend. - New LL function for swapping buffers, MwLLEndDraw - [TODO] Uses weak linking for all libraries so that systems that don't support Wayland or even have it installed can launch without it. Reviewed-on: https://gitea.nishi.boats/pyrite-dev/milsko/pulls/1 Co-authored-by: IoIxD <alphaproject217@gmail.com> Co-committed-by: IoIxD <alphaproject217@gmail.com>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
#include <Mw/Milsko.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
#ifdef USE_WAYLAND
|
||||
#include <stb_ds.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_GDI
|
||||
typedef HGLRC(WINAPI* MWwglCreateContext)(HDC);
|
||||
typedef BOOL(WINAPI* MWwglMakeCurrent)(HDC, HGLRC);
|
||||
@@ -103,6 +109,12 @@ static int create(MwWidget handle) {
|
||||
o->gl = o->glXCreateContext(handle->lowlevel->x11.display, o->visual, NULL, GL_TRUE);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
/* Wayland uses OpenGL as its backend so its already initialized */
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
}
|
||||
#endif
|
||||
|
||||
handle->internal = r;
|
||||
handle->lowlevel->common.copy_buffer = 0;
|
||||
|
||||
@@ -133,6 +145,10 @@ static void destroy(MwWidget handle) {
|
||||
MwDynamicClose(o->lib);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
/* Wayland uses OpenGL as its backend so its destroyed accordingly */
|
||||
#endif
|
||||
|
||||
free(handle->internal);
|
||||
}
|
||||
|
||||
@@ -151,6 +167,10 @@ static void mwOpenGLMakeCurrentImpl(MwWidget handle) {
|
||||
o->glXMakeCurrent(handle->lowlevel->x11.display, handle->lowlevel->x11.window, o->gl);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
||||
@@ -168,6 +188,16 @@ static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
||||
o->glXSwapBuffers(handle->lowlevel->x11.display, handle->lowlevel->x11.window);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
#define tp handle->lowlevel->wayland.topmost_parent->wayland
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
if(!eglSwapBuffers(
|
||||
tp.egl_display, tp.egl_surface)) {
|
||||
printf("Userland error: eglSwapBuffers, %0X\n", eglGetError());
|
||||
}
|
||||
}
|
||||
#undef topmost_parent
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
||||
@@ -184,6 +214,11 @@ static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
||||
|
||||
return o->glXGetProcAddress((const GLubyte*)name);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ static void draw(MwWidget handle) {
|
||||
}
|
||||
|
||||
static void mouse_move(MwWidget handle) {
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
scrollbar_t* scr = handle->internal;
|
||||
|
||||
if(!handle->pressed) return;
|
||||
@@ -170,9 +170,9 @@ static void mouse_move(MwWidget handle) {
|
||||
}
|
||||
|
||||
static void mouse_down(MwWidget handle, void* ptr) {
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
scrollbar_t* scr = handle->internal;
|
||||
MwLLMouse* m = ptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user