we now get the width and height of a screen when in emscripten mode

main
Brett 2024-04-29 15:31:47 -04:00
parent d2ba28fa1a
commit 0a93fbe055
3 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25)
set(BLT_GRAPHICS_VERSION 0.11.2)
set(BLT_GRAPHICS_VERSION 0.11.3)
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})

View File

@ -74,7 +74,7 @@ namespace blt::gfx
}
};
void init(const window_data& data);
void init(window_data data);
double getMouseX();

View File

@ -17,6 +17,7 @@
#ifdef __EMSCRIPTEN__
#include <emscripten/html5.h>
#include <blt/std/types.h>
#endif
@ -194,14 +195,25 @@ namespace blt::gfx
return false;
}
EM_JS(int, get_screen_width, (), {
return window.innerWidth;
});
EM_JS(int, get_screen_height, (), {
return window.innerHeight;
});
#endif
void init(const window_data& data)
void init(window_data data)
{
#ifdef __EMSCRIPTEN__
blt::logging::setLogOutputFormat("[${{TIME}}] [${{LOG_LEVEL}}] (${{FILE}}:${{LINE}}) ${{STR}}\n");
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, false,
emscripten_resize_callback);
data.width = get_screen_width();
data.height = get_screen_height();
#endif
/* -- Set up Error Callback -- */
glfwSetErrorCallback(error_callback);