wasm: add a fullscreen button

This commit is contained in:
2026-03-25 22:55:44 +01:00
parent c526f00957
commit 9d30fe3d34

View File

@@ -7,7 +7,21 @@
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#include <emscripten.h> #include <emscripten.h>
#include <emscripten/html5.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
EM_JS(void, js_toggleFullscreen, (), {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
}
});
EM_JS(int, js_isFullscreen, (), {
return document.fullscreenElement ? 1 : 0;
});
#else #else
#include <GL/gl.h> #include <GL/gl.h>
#endif #endif
@@ -369,6 +383,12 @@ void Application::render() {
ImGui::EndMenu(); ImGui::EndMenu();
} }
#ifdef __EMSCRIPTEN__
if (ImGui::SmallButton(js_isFullscreen() ? "Exit Fullscreen" : "Fullscreen")) {
js_toggleFullscreen();
}
#endif
// Right-aligned status in menu bar // Right-aligned status in menu bar
{ {
float barW = ImGui::GetWindowWidth(); float barW = ImGui::GetWindowWidth();