diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 32f2deae..ee977415 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -143,9 +144,9 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend_state* backend, wlr_output->width = width; wlr_output->height = height; wlr_output->scale = 1; - strncpy(wlr_output->make, "wayland-output", sizeof(wlr_output->make)); - strncpy(wlr_output->model, "wayland-output", sizeof(wlr_output->model)); - strncpy(wlr_output->name, "wayland-output", sizeof(wlr_output->name)); + strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make)); + strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model)); + snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d", 1); struct wlr_output_mode mode = { .width = width, diff --git a/example/pointer.c b/example/pointer.c index ddb665a1..1da77b85 100644 --- a/example/pointer.c +++ b/example/pointer.c @@ -110,22 +110,22 @@ int main(int argc, char *argv[]) { .default_color = { 0.25f, 0.25f, 0.25f, 1 }, .clear_color = { 0.25f, 0.25f, 0.25f, 1 } }; - struct compositor_state compositor; - + struct compositor_state compositor = { 0, + .data = &state, + .output_add_cb = handle_output_add, + .output_frame_cb = handle_output_frame, + .keyboard_key_cb = handle_keyboard_key, + .pointer_motion_cb = handle_pointer_motion, + .pointer_button_cb = handle_pointer_button, + .pointer_axis_cb = handle_pointer_axis, + }; compositor_init(&compositor); - compositor.output_add_cb = handle_output_add; - compositor.output_frame_cb = handle_output_frame; - compositor.keyboard_key_cb = handle_keyboard_key; - compositor.pointer_motion_cb = handle_pointer_motion; - compositor.pointer_button_cb = handle_pointer_button; - compositor.pointer_axis_cb = handle_pointer_axis; state.renderer = wlr_gles3_renderer_init(); state.cat_texture = wlr_render_surface_init(state.renderer); wlr_surface_attach_pixels(state.cat_texture, GL_RGBA, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor.data = &state; compositor_run(&compositor); wlr_surface_destroy(state.cat_texture); diff --git a/example/rotation.c b/example/rotation.c index f4b7625e..a1c77013 100644 --- a/example/rotation.c +++ b/example/rotation.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -193,22 +194,23 @@ static void parse_args(int argc, char *argv[], struct wl_list *config) { int main(int argc, char *argv[]) { struct sample_state state = { 0 }; - struct compositor_state compositor; wl_list_init(&state.config); parse_args(argc, argv, &state.config); + struct compositor_state compositor = { 0, + .data = &state, + .output_add_cb = handle_output_add, + .output_remove_cb = handle_output_remove, + .output_frame_cb = handle_output_frame, + .keyboard_key_cb = handle_keyboard_key, + }; compositor_init(&compositor); - compositor.output_add_cb = handle_output_add; - compositor.output_remove_cb = handle_output_remove; - compositor.output_frame_cb = handle_output_frame; - compositor.keyboard_key_cb = handle_keyboard_key; state.renderer = wlr_gles3_renderer_init(); state.cat_texture = wlr_render_surface_init(state.renderer); wlr_surface_attach_pixels(state.cat_texture, GL_RGBA, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor.data = &state; compositor_run(&compositor); wlr_surface_destroy(state.cat_texture); diff --git a/example/shared.c b/example/shared.c index be1bdee7..0fe7270f 100644 --- a/example/shared.c +++ b/example/shared.c @@ -418,8 +418,6 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { } void compositor_init(struct compositor_state *state) { - memset(state, 0, sizeof(struct compositor_state)); - state->display = wl_display_create(); state->event_loop = wl_display_get_event_loop(state->display); state->session = wlr_session_start(state->display); @@ -457,14 +455,14 @@ void compositor_init(struct compositor_state *state) { state->backend = wlr; clock_gettime(CLOCK_MONOTONIC, &state->last_frame); -} -void compositor_run(struct compositor_state *state) { if (!wlr_backend_init(state->backend)) { fprintf(stderr, "Failed to initialize backend\n"); exit(1); } +} +void compositor_run(struct compositor_state *state) { while (!state->exit) { wl_event_loop_dispatch(state->event_loop, 0); } diff --git a/example/simple.c b/example/simple.c index 5a5a1300..f3a66db9 100644 --- a/example/simple.c +++ b/example/simple.c @@ -50,11 +50,11 @@ int main() { .color = { 1.0, 0.0, 0.0 }, .dec = 0, }; - struct compositor_state compositor; - + struct compositor_state compositor = { 0, + .data = &state, + .output_frame_cb = handle_output_frame, + .keyboard_key_cb = handle_keyboard_key, + }; compositor_init(&compositor); - compositor.output_frame_cb = handle_output_frame; - compositor.keyboard_key_cb = handle_keyboard_key; - compositor.data = &state; compositor_run(&compositor); } diff --git a/example/tablet.c b/example/tablet.c index 3c5b583e..6be006f0 100644 --- a/example/tablet.c +++ b/example/tablet.c @@ -145,19 +145,19 @@ int main(int argc, char *argv[]) { .tool_color = { 1, 1, 1, 1 }, .pad_color = { 0.75, 0.75, 0.75, 1.0 } }; - struct compositor_state compositor; - + struct compositor_state compositor = { 0, + .data = &state, + .output_frame_cb = handle_output_frame, + .keyboard_key_cb = handle_keyboard_key, + .tool_axis_cb = handle_tool_axis, + .tool_proximity_cb = handle_tool_proximity, + .tool_button_cb = handle_tool_button, + .pad_button_cb = handle_pad_button, + }; compositor_init(&compositor); - compositor.output_frame_cb = handle_output_frame; - compositor.keyboard_key_cb = handle_keyboard_key; - compositor.tool_axis_cb = handle_tool_axis; - compositor.tool_proximity_cb = handle_tool_proximity; - compositor.tool_button_cb = handle_tool_button; - compositor.pad_button_cb = handle_pad_button; state.renderer = wlr_gles3_renderer_init(); - compositor.data = &state; compositor_run(&compositor); wlr_renderer_destroy(state.renderer); diff --git a/example/touch.c b/example/touch.c index 46eddf62..1b4233bb 100644 --- a/example/touch.c +++ b/example/touch.c @@ -100,21 +100,21 @@ int main(int argc, char *argv[]) { struct sample_state state = { .touch_points = list_create() }; - struct compositor_state compositor; - + struct compositor_state compositor = { 0, + .data = &state, + .output_frame_cb = handle_output_frame, + .keyboard_key_cb = handle_keyboard_key, + .touch_down_cb = handle_touch_down, + .touch_up_cb = handle_touch_up, + .touch_motion_cb = handle_touch_motion, + }; compositor_init(&compositor); - compositor.output_frame_cb = handle_output_frame; - compositor.keyboard_key_cb = handle_keyboard_key; - compositor.touch_down_cb = handle_touch_down; - compositor.touch_up_cb = handle_touch_up; - compositor.touch_motion_cb = handle_touch_motion; state.renderer = wlr_gles3_renderer_init(); state.cat_texture = wlr_render_surface_init(state.renderer); wlr_surface_attach_pixels(state.cat_texture, GL_RGBA, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor.data = &state; compositor_run(&compositor); wlr_surface_destroy(state.cat_texture); diff --git a/render/gles3/renderer.c b/render/gles3/renderer.c index b0056193..d029c0fb 100644 --- a/render/gles3/renderer.c +++ b/render/gles3/renderer.c @@ -71,6 +71,7 @@ static void init_default_shaders() { if (!compile_program(quad_vertex_src, ellipse_fragment_src, &shaders.ellipse)) { goto error; } + wlr_log(L_DEBUG, "Compiled default shaders"); return; error: wlr_log(L_ERROR, "Failed to set up default shaders!"); @@ -141,8 +142,10 @@ static bool wlr_gles3_render_surface(struct wlr_renderer_state *state, GL_CALL(glUseProgram(shaders.rgba)); break; default: + wlr_log(L_ERROR, "No shader for this surface format"); return false; } + gles3_flush_errors(); GL_CALL(glBindVertexArray(vao)); GL_CALL(glBindBuffer(GL_ARRAY_BUFFER, vbo)); GL_CALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo));