wasm: add a fullscreen button
This commit is contained in:
@@ -7,7 +7,21 @@
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.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
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
@@ -369,6 +383,12 @@ void Application::render() {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (ImGui::SmallButton(js_isFullscreen() ? "Exit Fullscreen" : "Fullscreen")) {
|
||||
js_toggleFullscreen();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Right-aligned status in menu bar
|
||||
{
|
||||
float barW = ImGui::GetWindowWidth();
|
||||
|
||||
Reference in New Issue
Block a user