From 2aafb5dd19f8a3e3436f8843071fa2076a6d2716 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 22 Jun 2017 16:32:47 -0400 Subject: Add wlcore/wl_shm (WIP) --- example/CMakeLists.txt | 13 +++++++++++++ example/compositor.c | 43 +++++++++++++++++++++++++++++++++++++++++++ example/shared.h | 1 - 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 example/compositor.c (limited to 'example') diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index fff2e49b..6c53e923 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -65,3 +65,16 @@ target_link_libraries(tablet wlr-render ${XKBCOMMON_LIBRARIES} ) + +add_executable(compositor + compositor + shared.c +) + +target_link_libraries(compositor + wlr-backend + wlr-session + wlr-render + wlr-wlcore + ${XKBCOMMON_LIBRARIES} +) diff --git a/example/compositor.c b/example/compositor.c new file mode 100644 index 00000000..5106ec96 --- /dev/null +++ b/example/compositor.c @@ -0,0 +1,43 @@ +#define _POSIX_C_SOURCE 199309L +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "shared.h" + +struct sample_state { + struct wlr_renderer *renderer; +}; + +void handle_output_frame(struct output_state *output, struct timespec *ts) { + struct compositor_state *state = output->compositor; + struct sample_state *sample = state->data; + struct wlr_output *wlr_output = output->output; + + wlr_renderer_begin(sample->renderer, wlr_output); + // TODO: render surfaces + wlr_renderer_end(sample->renderer); +} + +int main() { + struct sample_state state = { 0 }; + struct compositor_state compositor = { 0, + .data = &state, + .output_frame_cb = handle_output_frame, + }; + compositor_init(&compositor); + + state.renderer = wlr_gles2_renderer_init(); + wlr_wl_shm_init(compositor.display); + + compositor_run(&compositor); +} diff --git a/example/shared.h b/example/shared.h index 37f52dcc..1633f2c8 100644 --- a/example/shared.h +++ b/example/shared.h @@ -126,7 +126,6 @@ struct compositor_state { struct wl_listener output_remove; struct wl_list outputs; - bool exit; void *data; }; -- cgit v1.2.3