diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/CMakeLists.txt | 13 | ||||
-rw-r--r-- | example/compositor.c | 43 | ||||
-rw-r--r-- | example/shared.h | 1 |
3 files changed, 56 insertions, 1 deletions
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 <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <inttypes.h> +#include <wayland-server.h> +#include <wlr/backend.h> +#include <wlr/session.h> +#include <wlr/render.h> +#include <wlr/render/gles2.h> +#include <wlr/types/wlr_output.h> +#include <wlr/wlcore/wl_shm.h> +#include <xkbcommon/xkbcommon.h> +#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; }; |