fix emscript logging settings

main
Brett 2025-04-11 16:13:29 -04:00
parent ebcdbeb172
commit 1808af68b5
3 changed files with 419 additions and 381 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.25)
include(FetchContent)
set(BLT_GRAPHICS_VERSION 2.0.9)
set(BLT_GRAPHICS_VERSION 2.0.10)
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})

@ -1 +1 @@
Subproject commit 9a05c86b02c9c45c2b384c531007416148ec4b56
Subproject commit e2dc35fea98cc62897169cfc50dbf59fd820cd0e

View File

@ -35,12 +35,10 @@ void gl_error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, G
return;
if (type == GL_DEBUG_TYPE_ERROR)
{
BLT_ERROR("[OpenGL Error] message = '{}', type = 0x{:x}, severity = 0x{:x}, source = 0x{:x}, id = {}",
message, type, severity, source, id);
BLT_ERROR("[OpenGL Error] message = '{}', type = 0x{:x}, severity = 0x{:x}, source = 0x{:x}, id = {}", message, type, severity, source, id);
} else
{
BLT_WARN("[OpenGL Error] message = '{}', type = 0x{:x}, severity = 0x{:x}, source = 0x{:x}, id = {}",
message, type, severity, source, id);
BLT_WARN("[OpenGL Error] message = '{}', type = 0x{:x}, severity = 0x{:x}, source = 0x{:x}, id = {}", message, type, severity, source, id);
}
}
@ -115,7 +113,9 @@ namespace blt::gfx
});
/* Setup mouse scroll callback */
glfwSetScrollCallback(window_state.window, [](GLFWwindow*, double, double s) { window_state.inputManager.updateScroll(s); });
glfwSetScrollCallback(window_state.window, [](GLFWwindow*, double, double s) {
window_state.inputManager.updateScroll(s);
});
/* Setup drop input callback */
glfwSetDropCallback(window_state.window, [](GLFWwindow*, int count, const char** paths) {
@ -150,8 +150,7 @@ namespace blt::gfx
io.Fonts->AddFontFromMemoryCompressedTTF(fontAwesomeSolid_compressed_data, static_cast<int>(fontAwesomeSolid_compressed_size), 13.0, &config,
icon_ranges);
io.Fonts->AddFontFromMemoryCompressedTTF(fontAwesomeBrands_compressed_data, static_cast<int>(fontAwesomeBrands_compressed_size), 13.0,
&config,
icon_ranges);
&config, icon_ranges);
//ImGui::StyleColorsLight();
@ -215,13 +214,9 @@ namespace blt::gfx
return false;
}
EM_JS(int, get_screen_width, (), {
return document.body.clientWidth;
});
EM_JS(int, get_screen_width, (), { return document.body.clientWidth; });
EM_JS(int, get_screen_height, (), {
return document.body.clientHeight;
});
EM_JS(int, get_screen_height, (), { return document.body.clientHeight; });
#endif
@ -229,9 +224,10 @@ namespace blt::gfx
{
window_state.data = &data; // NOLINT
#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);
logging::get_global_config().set_log_format(
std::string("[") + logging::tags::FULL_TIME + "] [" + logging::tags::LOG_LEVEL + "] (" + logging::tags::FILE + ":" + logging::tags::LINE +
") " + logging::tags::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();
@ -311,25 +307,39 @@ namespace blt::gfx
}
double getMouseX()
{ return window_state.inputManager.mouseX; }
{
return window_state.inputManager.mouseX;
}
double getMouseY()
{ return window_state.inputManager.mouseY; }
{
return window_state.inputManager.mouseY;
}
double getMouseDX()
{ return window_state.inputManager.deltaX; }
{
return window_state.inputManager.deltaX;
}
double getMouseDY()
{ return window_state.inputManager.deltaY; }
{
return window_state.inputManager.deltaY;
}
void lockCursor()
{ glfwSetInputMode(window_state.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); }
{
glfwSetInputMode(window_state.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
void unlockCursor()
{ glfwSetInputMode(window_state.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); }
{
glfwSetInputMode(window_state.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
bool isCursorLocked()
{ return glfwGetInputMode(window_state.window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED; }
{
return glfwGetInputMode(window_state.window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
}
bool isCursorInWindow()
{
@ -361,46 +371,74 @@ namespace blt::gfx
}
void setClipboard(const std::string& str)
{ glfwSetClipboardString(window_state.window, str.c_str()); }
{
glfwSetClipboardString(window_state.window, str.c_str());
}
std::string getClipboard()
{ return glfwGetClipboardString(window_state.window); }
{
return glfwGetClipboardString(window_state.window);
}
bool isMousePressed(int button)
{ return window_state.inputManager.isMousePressed(button); }
{
return window_state.inputManager.isMousePressed(button);
}
bool isKeyPressed(int key)
{ return window_state.inputManager.isKeyPressed(key); }
{
return window_state.inputManager.isKeyPressed(key);
}
double getFrameDeltaSeconds()
{ return window_state.nanoDelta; }
{
return window_state.nanoDelta;
}
double getFrameDeltaMilliseconds()
{ return window_state.millisDelta; }
{
return window_state.millisDelta;
}
i64 getFrameDelta()
{ return window_state.deltaTime; }
{
return window_state.deltaTime;
}
bool mouseMovedLastFrame()
{ return window_state.inputManager.mouse_moved; }
{
return window_state.inputManager.mouse_moved;
}
bool mousePressedLastFrame()
{ return window_state.inputManager.mouse_pressed; }
{
return window_state.inputManager.mouse_pressed;
}
bool keyPressedLastFrame()
{ return window_state.inputManager.key_pressed; }
{
return window_state.inputManager.key_pressed;
}
i32 getWindowHeight()
{ return window_state.height; }
{
return window_state.height;
}
i32 getWindowWidth()
{ return window_state.width; }
{
return window_state.width;
}
bool keyReleasedLastFrame()
{ return window_state.inputManager.key_released; }
{
return window_state.inputManager.key_released;
}
bool mouseReleaseLastFrame()
{ return window_state.inputManager.mouse_released; }
{
return window_state.inputManager.mouse_released;
}
void setWindowSize(const i32 width, const i32 height)
{