progress
This commit is contained in:
parent
3311810666
commit
0f1b028fca
3 changed files with 28 additions and 1 deletions
|
|
@ -66,6 +66,10 @@ int main(int argc, char *argv[]) {
|
||||||
int width = event.data.draw.width;
|
int width = event.data.draw.width;
|
||||||
int height = event.data.draw.height;
|
int height = event.data.draw.height;
|
||||||
render(&renderer, width, height, time, shader_path, 0);
|
render(&renderer, width, height, time, shader_path, 0);
|
||||||
|
swap_buffers(&state, event.data.draw.surface);
|
||||||
|
}
|
||||||
|
if (event.type == EVENT_NONE) {
|
||||||
|
printf("nothing, absolutely nothing\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//while (state.running) {
|
//while (state.running) {
|
||||||
|
|
|
||||||
23
wayland.c
23
wayland.c
|
|
@ -50,6 +50,8 @@ static void xdg_toplevel_configure (
|
||||||
next->data.height = height;
|
next->data.height = height;
|
||||||
printf("🧟🧟🧟\n");
|
printf("🧟🧟🧟\n");
|
||||||
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
||||||
|
// draw new frame!
|
||||||
|
next->data.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) {
|
static void xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) {
|
||||||
|
|
@ -381,16 +383,24 @@ struct event wait_for_event(struct client_state *state) {
|
||||||
// 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;
|
struct surface_list *next = state->surface_list;
|
||||||
printf("listtttt\n");
|
printf("checking for events\n");
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
if (next->data.dirty) {
|
if (next->data.dirty) {
|
||||||
printf("dirty\n");
|
printf("dirty\n");
|
||||||
|
|
||||||
|
if (eglMakeCurrent(state->egl_display, next->data.egl_surface,
|
||||||
|
next->data.egl_surface, state->egl_context)) {
|
||||||
|
fprintf(stderr, "Made current\n");
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Made current failed\n");
|
||||||
|
}
|
||||||
struct event event = {
|
struct event event = {
|
||||||
.type = EVENT_DRAW,
|
.type = EVENT_DRAW,
|
||||||
.data = {
|
.data = {
|
||||||
.draw = {
|
.draw = {
|
||||||
.width = next->data.width,
|
.width = next->data.width,
|
||||||
.height = next->data.height,
|
.height = next->data.height,
|
||||||
|
.surface = &next->data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -402,3 +412,14 @@ struct event wait_for_event(struct client_state *state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swap_buffers(struct client_state *state, struct surface *surface) {
|
||||||
|
struct surface_list *next = state->surface_list;
|
||||||
|
while (next != NULL) {
|
||||||
|
if (&next->data == surface) {
|
||||||
|
eglSwapBuffers(state->egl_display, next->data.egl_surface);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "didn't find surface for buffer swap\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ struct event {
|
||||||
/// EVENT_DRAW
|
/// EVENT_DRAW
|
||||||
struct {
|
struct {
|
||||||
int width, height;
|
int width, height;
|
||||||
|
struct surface *surface;
|
||||||
} draw;
|
} draw;
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
|
@ -66,4 +67,5 @@ void wayland_init(struct client_state *state, int output_type);
|
||||||
void commit(struct client_state *state);
|
void commit(struct client_state *state);
|
||||||
/// Provide pointer to be filled.
|
/// Provide pointer to be filled.
|
||||||
struct event wait_for_event(struct client_state *state);
|
struct event wait_for_event(struct client_state *state);
|
||||||
|
void swap_buffers(struct client_state *state, struct surface *surface);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue