morb
This commit is contained in:
parent
b20f48ebc0
commit
e934c1f61d
3 changed files with 63 additions and 32 deletions
|
|
@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
|
||||||
render(&renderer, width, height, time, shader_path, 0);
|
render(&renderer, width, height, time, shader_path, 0);
|
||||||
printf("about to 🦬 swap buf %p\n", event.data.draw.surface);
|
printf("about to 🦬 swap buf %p\n", event.data.draw.surface);
|
||||||
swap_buffers(&state, event.data.draw.surface);
|
swap_buffers(&state, event.data.draw.surface);
|
||||||
printf("🦬🦬🦬 swaping a buffalo\n");
|
printf("🦬🦬🦬 swaped a buffalo\n");
|
||||||
}
|
}
|
||||||
if (event.type == EVENT_NONE) {
|
if (event.type == EVENT_NONE) {
|
||||||
printf("nothing, absolutely nothing\n");
|
printf("nothing, absolutely nothing\n");
|
||||||
|
|
|
||||||
91
wayland.c
91
wayland.c
|
|
@ -330,6 +330,7 @@ void wayland_init(struct client_state *state, int output_type) {
|
||||||
state->wl_display = wl_display_connect(NULL);
|
state->wl_display = wl_display_connect(NULL);
|
||||||
state->wl_registry = wl_display_get_registry(state->wl_display);
|
state->wl_registry = wl_display_get_registry(state->wl_display);
|
||||||
state->surface_list = NULL;
|
state->surface_list = NULL;
|
||||||
|
state->surface_list_next = NULL;
|
||||||
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
||||||
wl_display_roundtrip(state->wl_display);
|
wl_display_roundtrip(state->wl_display);
|
||||||
|
|
||||||
|
|
@ -363,55 +364,83 @@ void commit(struct client_state *state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct event wait_for_event(struct client_state *state) {
|
struct event wait_for_event(struct client_state *state) {
|
||||||
for (;;) {
|
// before dispatch: check that there is nothing elese to do
|
||||||
// before dispatch: check that there is nothing elese to do
|
// check for dirty surface
|
||||||
// check for dirty surface
|
struct surface_list *next = state->surface_list_next;
|
||||||
struct surface_list *next = state->surface_list;
|
// keep track of one loop.
|
||||||
printf("checking for events\n");
|
struct surface_list *original = next;
|
||||||
while (next != NULL) {
|
while (true) {
|
||||||
if (next->data.dirty) {
|
if (next == NULL) {
|
||||||
next->data.dirty = false;
|
next = state->surface_list;
|
||||||
printf("dirty\n");
|
}
|
||||||
|
|
||||||
if (eglMakeCurrent(state->egl_display, next->data.egl_surface,
|
// do here
|
||||||
next->data.egl_surface, state->egl_context)) {
|
if (next->data.dirty) {
|
||||||
} else {
|
next->data.dirty = false;
|
||||||
fprintf(stderr, "Made current failed\n");
|
state->surface_list->next = next->next;
|
||||||
}
|
|
||||||
struct event event = {
|
printf("dirty %p\n", &next->data);
|
||||||
.type = EVENT_DRAW,
|
|
||||||
.data = {
|
if (eglMakeCurrent(state->egl_display, next->data.egl_surface,
|
||||||
.draw = {
|
next->data.egl_surface, state->egl_context)) {
|
||||||
.width = next->data.width,
|
} else {
|
||||||
.height = next->data.height,
|
fprintf(stderr, "Made current failed\n");
|
||||||
.surface = &next->data,
|
}
|
||||||
}
|
struct event event = {
|
||||||
}
|
.type = EVENT_DRAW,
|
||||||
};
|
.data = {
|
||||||
return event;
|
.draw = {
|
||||||
}
|
.width = next->data.width,
|
||||||
next = next->next;
|
.height = next->data.height,
|
||||||
|
.surface = &next->data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
next = next->next;
|
||||||
|
if (next == original) {
|
||||||
|
state->surface_list_next = next;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
wl_display_dispatch(state->wl_display);
|
|
||||||
}
|
}
|
||||||
|
wl_display_dispatch(state->wl_display);
|
||||||
|
struct event event = {
|
||||||
|
.type = EVENT_NONE,
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_surface_list(struct client_state *state) {
|
||||||
|
struct surface_list *next = state->surface_list;
|
||||||
|
printf("[\n");
|
||||||
|
while (next != NULL) {
|
||||||
|
printf("ITEM: %p\n", &next->data);
|
||||||
|
next = next->next;
|
||||||
|
}
|
||||||
|
printf("]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap_buffers(struct client_state *state, struct surface *surface) {
|
void swap_buffers(struct client_state *state, struct surface *surface) {
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
|
print_surface_list(state);
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
|
printf("going to swap buffers 🐃🐃🐃: %p, surface: %p\n", &next->data, surface);
|
||||||
if (&next->data == surface) {
|
if (&next->data == surface) {
|
||||||
printf("swapping this buffer 🐃: %p\n", &next->data);
|
printf("swapping this buffer 🐃: %p\n", &next->data);
|
||||||
eglSwapBuffers(state->egl_display, next->data.egl_surface);
|
eglSwapBuffers(state->egl_display, next->data.egl_surface);
|
||||||
// maybe unecessary TODO maybe really bad?
|
// maybe unecessary TODO maybe really bad?
|
||||||
wl_display_dispatch(state->wl_display);
|
//wl_display_dispatch(state->wl_display);
|
||||||
|
|
||||||
/* Request another frame */
|
/* Request another frame */
|
||||||
//struct wl_callback *cb = wl_surface_frame(surface->wl_surface);
|
//struct wl_callback *cb = wl_surface_frame(surface->wl_surface);
|
||||||
//wl_callback_add_listener(cb, &wl_surface_frame_listener, surface);
|
//wl_callback_add_listener(cb, &wl_surface_frame_listener, surface);
|
||||||
|
printf("done swapping\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
printf("next BUF: %p\n", next->next);
|
||||||
next = next->next;
|
next = next->next;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "didn't find surface for buffer swap\n");
|
fprintf(stderr, "didn't find surface for buffer swap\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ struct client_state {
|
||||||
struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1;
|
struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1;
|
||||||
|
|
||||||
struct surface_list *surface_list;
|
struct surface_list *surface_list;
|
||||||
|
/// Next in queue to check if it wants to be rendered.
|
||||||
|
struct surface_list *surface_list_next;
|
||||||
|
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
EGLConfig egl_config;
|
EGLConfig egl_config;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue