feat: let user do something on each iteration

This commit is contained in:
2026-02-13 09:49:56 +01:00
parent d20f393278
commit 696d55db02
2 changed files with 14 additions and 7 deletions

View File

@@ -299,6 +299,8 @@ private:
wl_egl_window_resize(window->m_egl_window, width, height, 0, 0);
glViewport(0, 0, width, height);
xdg_surface_set_window_geometry(window->m_xsurface, 0, 0, width, height);
window->m_width = width;
window->m_height = height;
}
static void xtoplevel_handle_close(void *data,
@@ -374,16 +376,19 @@ public:
const char *vs_src = "attribute vec2 pos;\n"
"uniform float angle;\n"
"varying vec2 vPos;\n"
"void main() {\n"
" float c = cos(angle);\n"
" float s = sin(angle);\n"
" mat2 rot = mat2(c, -s, s, c);\n"
" gl_Position = vec4(rot * pos, 0.0, 1.0);\n"
" vPos = rot * pos;\n"
"}\n";
const char *fs_src = "precision mediump float;\n"
"varying vec2 vPos;\n"
"void main() {\n"
" gl_FragColor = vec4(1.0, 0.3, 0.2, 1.0);\n"
" gl_FragColor = vec4(vPos, 0.2, 1.0);\n"
"}\n";
m_program = create_program(vs_src, fs_src);
@@ -422,6 +427,8 @@ public:
xdg_toplevel_add_listener(m_toplevel, &m_toplevel_listener, this);
wl_surface_commit(m_wsurface);
m_runnning = true;
}
~Window() {}
@@ -429,11 +436,8 @@ public:
Window(Window &&) = delete;
public:
void Run() {
m_runnning = true;
printf("[DEBUG] Run(): display = %p\n", AppState::GetInstance()->m_display);
while (m_runnning && wl_display_dispatch(AppState::GetInstance()->m_display) != -1) {
}
bool Running() {
return m_runnning && wl_display_dispatch(AppState::GetInstance()->m_display) != -1;
}
private: