allocation of wayland state memory in main
This commit is contained in:
parent
92ce71b5f1
commit
09ac1a0559
3 changed files with 19 additions and 20 deletions
31
wayland.c
31
wayland.c
|
|
@ -156,25 +156,24 @@ static void egl_init(struct client_state *state) {
|
|||
}
|
||||
|
||||
/// Initializes wayland and creates an opengl context
|
||||
struct client_state wayland_init() {
|
||||
void wayland_init(struct client_state *state) {
|
||||
int width = 700, height = 700;
|
||||
struct client_state state = { width, height, 0 };
|
||||
state.wl_display = wl_display_connect(NULL);
|
||||
state.wl_registry = wl_display_get_registry(state.wl_display);
|
||||
wl_registry_add_listener(state.wl_registry, &wl_registry_listener, &state);
|
||||
wl_display_roundtrip(state.wl_display);
|
||||
state->width = width;
|
||||
state->height = height;
|
||||
state->wl_display = wl_display_connect(NULL);
|
||||
state->wl_registry = wl_display_get_registry(state->wl_display);
|
||||
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
||||
wl_display_roundtrip(state->wl_display);
|
||||
|
||||
state.wl_surface = wl_compositor_create_surface(state.wl_compositor);
|
||||
state.xdg_surface = xdg_wm_base_get_xdg_surface(
|
||||
state.xdg_wm_base, state.wl_surface);
|
||||
xdg_surface_add_listener(state.xdg_surface, &xdg_surface_listener, &state);
|
||||
state.xdg_toplevel = xdg_surface_get_toplevel(state.xdg_surface);
|
||||
xdg_toplevel_set_title(state.xdg_toplevel, "GLONKERS!");
|
||||
wl_surface_commit(state.wl_surface);
|
||||
state->wl_surface = wl_compositor_create_surface(state->wl_compositor);
|
||||
state->xdg_surface = xdg_wm_base_get_xdg_surface(
|
||||
state->xdg_wm_base, state->wl_surface);
|
||||
xdg_surface_add_listener(state->xdg_surface, &xdg_surface_listener, state);
|
||||
state->xdg_toplevel = xdg_surface_get_toplevel(state->xdg_surface);
|
||||
xdg_toplevel_set_title(state->xdg_toplevel, "GLONKERS!");
|
||||
wl_surface_commit(state->wl_surface);
|
||||
|
||||
egl_init(&state);
|
||||
|
||||
return state;
|
||||
egl_init(state);
|
||||
}
|
||||
|
||||
/// Swaps front/backbuffers and dispatches pending wayland commands.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue