5#include <emscripten/html5.h>
9 WebWindow::WebWindow(
const WindowProps& props)
14 void WebWindow::GetCanvasSize(
unsigned int& width,
unsigned int& height)
17 emscripten_get_element_css_size(
"#canvas", &w, &h);
18 width =
static_cast<unsigned int>(w);
19 height =
static_cast<unsigned int>(h);
22 void WebWindow::Init(
const WindowProps& props)
25 unsigned int width, height;
26 GetCanvasSize(width, height);
27 WindowProps webProps(props.Title, width, height, props.VSync);
28 EE_CORE_INFO(
"Initializing WebWindow with canvas size: {}x{}", width, height);
31 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,
this, EM_TRUE,
32 [](
int et,
const EmscriptenUiEvent* uiEvent,
void* ud) -> EM_BOOL {
33 WebWindow* window =
static_cast<WebWindow*
>(ud);
34 unsigned int width = 0;
35 unsigned int height = 0;
36 window->GetCanvasSize(width, height);
37 window->SetWindowSize(width, height);
39 GLFWwindow* nativeWin =
static_cast<GLFWwindow*
>(window->GetNativeWindow());
40 glfwSetWindowSize(nativeWin, width, height);
virtual void Init(const WindowProps &props) override