Unfinished Wayland PR #1
7 changed files with 31 additions and 28 deletions
introduce MwLLEndDraw, which can be stubbed safely on any platforms and exists purely for wayland to be able to swap buffers at a better time
commit
247e0b361c
|
|
@ -164,6 +164,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 (*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);
|
||||||
MWDECL void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
MWDECL void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
\
|
\
|
||||||
MwLLPolygon = MwLLPolygonImpl; \
|
MwLLPolygon = MwLLPolygonImpl; \
|
||||||
MwLLLine = MwLLLineImpl; \
|
MwLLLine = MwLLLineImpl; \
|
||||||
|
MwLLEndDraw = MwLLEndDrawImpl; \
|
||||||
\
|
\
|
||||||
MwLLAllocColor = MwLLAllocColorImpl; \
|
MwLLAllocColor = MwLLAllocColorImpl; \
|
||||||
MwLLColorUpdate = MwLLColorUpdateImpl; \
|
MwLLColorUpdate = MwLLColorUpdateImpl; \
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,8 @@ static void MwLLDestroyImpl(MwLL handle) {
|
||||||
free(handle);
|
free(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) {
|
||||||
POINT* p = malloc(sizeof(*p) * points_count);
|
POINT* p = malloc(sizeof(*p) * points_count);
|
||||||
HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0));
|
HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0));
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,7 @@ static MwBool egl_setup(MwLL self, int width, int height) {
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, width, height, 0, -1, 1);
|
glOrtho(0, width, height, 0, -1, 1);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
self->wayland.egl_display = display;
|
self->wayland.egl_display = display;
|
||||||
self->wayland.egl_surface = surface;
|
self->wayland.egl_surface = surface;
|
||||||
|
|
@ -556,31 +557,11 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
/*
|
int i;
|
||||||
* TODO: this function sucks shit, ioi needs to make it not suck shit :)
|
|
||||||
*/
|
|
||||||
int i;
|
|
||||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)eglGetProcAddress("glBindFramebuffer");
|
|
||||||
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)eglGetProcAddress("glBindRenderbuffer");
|
|
||||||
int w, h;
|
|
||||||
|
|
||||||
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
|
|
||||||
w = handle->wayland.ww;
|
|
||||||
h = handle->wayland.wh;
|
|
||||||
} else {
|
|
||||||
MwLL parent = handle->wayland.parent;
|
|
||||||
while(parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
|
||||||
parent = parent->wayland.parent;
|
|
||||||
}
|
|
||||||
w = parent->wayland.ww;
|
|
||||||
h = parent->wayland.wh;
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, handle->wayland.fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, handle->wayland.fbo);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, handle->wayland.fbo_texture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, handle->wayland.fbo_texture, 0);
|
||||||
glLineWidth(1);
|
|
||||||
|
|
||||||
if(points_count == 3) {
|
if(points_count == 3) {
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
@ -598,9 +579,26 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glFinish();
|
glFinish();
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
|
||||||
|
w = handle->wayland.ww;
|
||||||
|
h = handle->wayland.wh;
|
||||||
|
} else {
|
||||||
|
MwLL parent = handle->wayland.parent;
|
||||||
|
w = parent->wayland.ww;
|
||||||
|
h = parent->wayland.wh;
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, handle->wayland.fbo_texture);
|
glBindTexture(GL_TEXTURE_2D, handle->wayland.fbo_texture);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
|
|
||||||
|
|
@ -618,17 +616,12 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
|
||||||
glEnd();
|
glEnd();
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
|
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 {
|
||||||
wl_surface_commit(handle->wayland.surface);
|
wl_surface_commit(handle->wayland.surface);
|
||||||
}
|
}
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
handle->wayland.do_clear = MwFALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,8 @@ static void MwLLDestroyImpl(MwLL handle) {
|
||||||
free(handle);
|
free(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) {
|
||||||
int i;
|
int i;
|
||||||
XPoint* p = malloc(sizeof(*p) * points_count);
|
XPoint* p = malloc(sizeof(*p) * points_count);
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,8 @@ void MwLoop(MwWidget handle) {
|
||||||
}
|
}
|
||||||
if(v != 0) break;
|
if(v != 0) break;
|
||||||
|
|
||||||
|
MwLLEndDraw(handle->lowlevel);
|
||||||
|
|
||||||
for(i = 0; i < arrlen(handle->tick_list); i++) {
|
for(i = 0; i < arrlen(handle->tick_list); i++) {
|
||||||
MwDispatch(handle->tick_list[i], tick);
|
MwDispatch(handle->tick_list[i], tick);
|
||||||
MwDispatchUserHandler(handle->tick_list[i], MwNtickHandler, NULL);
|
MwDispatchUserHandler(handle->tick_list[i], MwNtickHandler, NULL);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ 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 (*MwLLEndDraw)(MwLL handle);
|
||||||
|
|
||||||
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
|
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
|
||||||
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
||||||
void (*MwLLFreeColor)(MwLLColor color);
|
void (*MwLLFreeColor)(MwLLColor color);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue