Unfinished Wayland PR #1

Merged
IoI_xD merged 55 commits from IoI_xD/milsko:wayland into master 2025-12-10 11:11:02 +09:00
7 changed files with 30 additions and 24 deletions
Showing only changes of commit 89ff065a71 - Show all commits

seperate opengl contexts

IoIxD 2025-12-07 18:52:49 -07:00

View file

@ -162,6 +162,7 @@ MWDECL void (*MwLLDestroy)(MwLL handle);
MWDECL void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color); MWDECL void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
MWDECL void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color); MWDECL void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
MWDECL void (*MwLLBeginDraw)(MwLL handle);
MWDECL void (*MwLLEndDraw)(MwLL handle); MWDECL void (*MwLLEndDraw)(MwLL handle);
MWDECL MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b); MWDECL MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);

View file

@ -10,6 +10,7 @@
\ \
MwLLPolygon = MwLLPolygonImpl; \ MwLLPolygon = MwLLPolygonImpl; \
MwLLLine = MwLLLineImpl; \ MwLLLine = MwLLLineImpl; \
MwLLBeginDraw = MwLLBeginDrawImpl; \
MwLLEndDraw = MwLLEndDrawImpl; \ MwLLEndDraw = MwLLEndDrawImpl; \
\ \
MwLLAllocColor = MwLLAllocColorImpl; \ MwLLAllocColor = MwLLAllocColorImpl; \

View file

@ -277,6 +277,7 @@ static void MwLLDestroyImpl(MwLL handle) {
free(handle); free(handle);
} }
static void MwLLBeginDrawImpl(MwLL handle) {}
static void MwLLEndDrawImpl(MwLL handle) {} static void MwLLEndDrawImpl(MwLL handle) {}
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {

View file

@ -274,12 +274,6 @@ static MwBool egl_setup(MwLL self, int width, int height) {
return MwFALSE; return MwFALSE;
} }
// Make the context current
if(!eglMakeCurrent(display, surface, surface, context)) {
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
return MwFALSE;
}
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)eglGetProcAddress("glGenFramebuffers"); glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)eglGetProcAddress("glGenFramebuffers");
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)eglGetProcAddress("glFramebufferTexture2D"); glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)eglGetProcAddress("glFramebufferTexture2D");
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)eglGetProcAddress("glGenRenderbuffers"); glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)eglGetProcAddress("glGenRenderbuffers");
@ -305,7 +299,7 @@ static MwBool egl_setup(MwLL self, int width, int height) {
if((err = glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE) { if((err = glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE) {
printf("Error binding framebuffer: %0X\n", err); printf("Error binding framebuffer: %0X\n", err);
return MwFALSE; // return MwFALSE;
} }
glBindFramebuffer(GL_FRAMEBUFFER_BINDING, 0); glBindFramebuffer(GL_FRAMEBUFFER_BINDING, 0);
@ -653,12 +647,10 @@ static void setup_subsurface(MwLL parent, MwLL r, int x, int y) {
// arrpush(parent->wayland.subsurfaces, r); // arrpush(parent->wayland.subsurfaces, r);
r->wayland.configured = MwTRUE; r->wayland.configured = MwTRUE;
if(!r->wayland.egl_setup) {
r->wayland.egl_context = topmost_parent->wayland.egl_context; r->wayland.egl_setup = egl_setup(r, r->wayland.ww, r->wayland.wh);
r->wayland.egl_display = topmost_parent->wayland.egl_display; MwLLForceRender(r);
r->wayland.egl_surface = topmost_parent->wayland.egl_surface; };
r->wayland.fbo = topmost_parent->wayland.fbo;
r->wayland.fbo_texture = topmost_parent->wayland.fbo_texture;
arrpush(parent->wayland.subwidgets, r); arrpush(parent->wayland.subwidgets, r);
} }
@ -826,6 +818,13 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
framebuffer_action_end(handle); framebuffer_action_end(handle);
} }
static void MwLLBeginDrawImpl(MwLL handle) {
if(!eglMakeCurrent(handle->wayland.egl_display, handle->wayland.egl_surface, handle->wayland.egl_surface, handle->wayland.egl_context)) {
printf("ERROR: eglMakeCurrent, %0X\n", eglGetError());
return;
}
}
static void MwLLEndDrawImpl(MwLL handle) { static void MwLLEndDrawImpl(MwLL handle) {
int w, h; int w, h;
@ -859,6 +858,7 @@ static void MwLLEndDrawImpl(MwLL handle) {
glFinish(); glFinish();
wl_surface_damage(handle->wayland.surface, 0, 0, handle->wayland.ww, handle->wayland.wh); wl_surface_damage(handle->wayland.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) { if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) {
printf("error swapping buffers! %0X\n", eglGetError()); printf("error swapping buffers! %0X\n", eglGetError());
} else { } else {

View file

@ -259,6 +259,7 @@ static void MwLLDestroyImpl(MwLL handle) {
free(handle); free(handle);
} }
static void MwLLBeginDrawImpl(MwLL handle) {}
static void MwLLEndDrawImpl(MwLL handle) {} static void MwLLEndDrawImpl(MwLL handle) {}
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {

View file

@ -9,15 +9,16 @@ static void lldrawhandler(MwLL handle, void* data) {
int ind; int ind;
(void)data; (void)data;
if(handle->wayland.parent == NULL)
MwLLBeginDraw(handle);
h->bgcolor = NULL; h->bgcolor = NULL;
MwDispatch(h, draw); MwDispatch(h, draw);
if(h->draw_inject != NULL) h->draw_inject(h); if(h->draw_inject != NULL) h->draw_inject(h);
MwDispatchUserHandler(h, MwNdrawHandler, NULL); MwDispatchUserHandler(h, MwNdrawHandler, NULL);
if(handle->wayland.parent == NULL) { if(handle->wayland.parent == NULL)
MwLLEndDraw(handle); MwLLEndDraw(handle);
}
} }
static void lluphandler(MwLL handle, void* data) { static void lluphandler(MwLL handle, void* data) {

View file

@ -6,6 +6,7 @@ void (*MwLLDestroy)(MwLL handle);
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color); void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color); void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
void (*MwLLBeginDraw)(MwLL handle);
void (*MwLLEndDraw)(MwLL handle); void (*MwLLEndDraw)(MwLL handle);
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b); MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);