feat: on frame listener

This commit is contained in:
2026-02-13 13:53:47 +01:00
parent 7f9de651d4
commit 2912ebb91c
5 changed files with 40 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
#include <stdio.h>
#include <wayland-client-core.h>
#include "state/wayland.h"
#include "window.h"
#include "window/wayland.h"
#include "renderer.h"
@@ -88,19 +90,24 @@ WaylandWindowImpl::WaylandWindowImpl(size_t width, size_t height)
m_toplevel_listener.close = xtoplevel_handle_close;
m_toplevel_listener.wm_capabilities = xtoplevel_handle_wm_capabilities;
xdg_toplevel_add_listener(m_toplevel, &m_toplevel_listener, this);
wl_surface_commit(m_wsurface);
m_running = true;
}
WaylandWindowImpl::~WaylandWindowImpl() { m_running = false; }
bool WaylandWindowImpl::Dispatch() {
return m_running &&
wl_display_dispatch(WaylandState::GetInstance()->m_display) != -1;
void WaylandWindowImpl::OnFrame(IFrameListener fn) {
m_on_frame = fn;
}
bool WaylandWindowImpl::Dispatch() {
wl_surface_commit(m_wsurface);
m_running = true;
auto display = WaylandState::GetInstance()->m_display;
// wl_display_dispatch_pending(display);
return wl_display_dispatch(display) != -1; }
size_t WaylandWindowImpl::GetWidth() const {
return m_width;
}
@@ -125,6 +132,8 @@ void WaylandWindowImpl::handle_frame_callback(void *data,
wl_callback_add_listener(frame_callback, &window->m_frame_listener, window);
if (window->m_on_frame) window->m_on_frame();
GLint angle_loc = glGetUniformLocation(window->m_program, "angle");
static float angle = 0.0f;