From 7c7e97872da61d43400786e6da2a8d9d65b2e546 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 26 Apr 2024 01:11:46 -0400 Subject: [PATCH] partial emscripten working --- CMakeLists.txt | 18 ++++++------------ include/blt/gfx/gl_includes.h | 3 +++ libraries/BLT | 2 +- libraries/imgui | 2 +- libraries/openal-soft | 2 +- src/blt/gfx/framebuffer.cpp | 2 ++ src/blt/gfx/texture.cpp | 6 ++++-- src/blt/gfx/window.cpp | 6 ++++-- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c750cb..5400020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.10.1) +set(BLT_GRAPHICS_VERSION 0.10.2) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) @@ -81,8 +81,7 @@ if (${BUILD_GRAPHICS_TESTS}) target_link_libraries(BLT_GRAPHICS_TESTS BLT_WITH_GRAPHICS) - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing) - target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) + include(libraries/BLT/cmake/warnings.cmake) if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address) @@ -109,8 +108,7 @@ if (${BUILD_EXAMPLE_BASIC}) target_link_libraries(${PROJECT_NAME} BLT_WITH_GRAPHICS) - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing) - target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) + include(libraries/BLT/cmake/warnings.cmake) if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address) @@ -138,15 +136,11 @@ if (EMSCRIPTEN) endif () #set_target_properties(FinalProject PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sASSERTIONS=1 -pthread -sPTHREAD_POOL_SIZE=8 -s INITIAL_MEMORY=134217728 -sUSE_GLFW=3 --preload-file 'assets'") - set_target_properties(${TARGETS} PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sASSERTIONS=1 -sUSE_GLFW=3") + set_target_properties(${TARGETS} PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sFULL_ES2=1 -sFULL_ES3 -sASSERTIONS=1 -sUSE_GLFW=3") #set_target_properties(BLT_WITH_GRAPHICS PROPERTIES COMPILE_FLAGS "-pthread") - - target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing) - target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing) else () target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw) target_link_libraries(BLT_WITH_GRAPHICS PUBLIC OpenAL) +endif () - target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) - target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) -endif () \ No newline at end of file +include(libraries/BLT/cmake/warnings.cmake) \ No newline at end of file diff --git a/include/blt/gfx/gl_includes.h b/include/blt/gfx/gl_includes.h index 41fbf90..429d822 100644 --- a/include/blt/gfx/gl_includes.h +++ b/include/blt/gfx/gl_includes.h @@ -13,6 +13,9 @@ #include #else #include + #include + #include + #include #include #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES diff --git a/libraries/BLT b/libraries/BLT index 325508e..1772e9a 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 325508e807f376fb7d287dbb9d80899eddb4e8ff +Subproject commit 1772e9a6d7fe3bd866c4daac5546347634178cb4 diff --git a/libraries/imgui b/libraries/imgui index a1b0682..231cbee 160000 --- a/libraries/imgui +++ b/libraries/imgui @@ -1 +1 @@ -Subproject commit a1b06823fe2d964a62fda99385499b218cf5cea5 +Subproject commit 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65 diff --git a/libraries/openal-soft b/libraries/openal-soft index 6675317..111397c 160000 --- a/libraries/openal-soft +++ b/libraries/openal-soft @@ -1 +1 @@ -Subproject commit 6675317107257c2cc16c947b359d557821d85bf2 +Subproject commit 111397c71a5f1c2c88e05da9c84edfdba2e472a4 diff --git a/src/blt/gfx/framebuffer.cpp b/src/blt/gfx/framebuffer.cpp index 5cafbc7..91b0e23 100644 --- a/src/blt/gfx/framebuffer.cpp +++ b/src/blt/gfx/framebuffer.cpp @@ -170,7 +170,9 @@ namespace blt::gfx glBindFramebuffer(GL_READ_FRAMEBUFFER, fboID); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw.fboID); glReadBuffer(static_cast(attachment_read)); +#ifdef glDrawBuffer glDrawBuffer(static_cast(attachment_write)); +#endif glBlitFramebuffer(srcX, srcY, width_, height_, destX, destY, draw.width_, draw.height_, GL_COLOR_BUFFER_BIT, filter); } diff --git a/src/blt/gfx/texture.cpp b/src/blt/gfx/texture.cpp index e5f47a4..226908b 100644 --- a/src/blt/gfx/texture.cpp +++ b/src/blt/gfx/texture.cpp @@ -173,13 +173,15 @@ blt::gfx::texture_gl2D_multisample::texture_gl2D_multisample(int width, int heig { bind(); setDefaults(); - glTexImage2DMultisample(textureBindType, samples, colorMode, width, height, GL_TRUE); + //glTexImage2DMultisample(textureBindType, samples, colorMode, width, height, GL_TRUE); + glTexStorage2DMultisample(textureBindType, samples, colorMode, width, height, GL_TRUE); } void blt::gfx::texture_gl2D_multisample::resize(int width, int height) { bind(); - glTexImage2DMultisample(textureBindType, samples, textureColorMode, width, height, GL_TRUE); + //glTexImage2DMultisample(textureBindType, samples, textureColorMode, width, height, GL_TRUE); + glTexStorage2DMultisample(textureBindType, samples, textureColorMode, width, height, GL_TRUE); } blt::gfx::gl_texture2D_array::gl_texture2D_array(int width, int height, int layers, GLint colorMode): texture_gl(width, height, layers, colorMode) diff --git a/src/blt/gfx/window.cpp b/src/blt/gfx/window.cpp index 366175c..97df63b 100644 --- a/src/blt/gfx/window.cpp +++ b/src/blt/gfx/window.cpp @@ -194,8 +194,8 @@ namespace blt::gfx /* -- Set Window Specifics + OpenGL -- */ glfwMakeContextCurrent(window_state.window); - glfwSwapInterval(data.sync_interval); #ifndef __EMSCRIPTEN__ + glfwSwapInterval(data.sync_interval); gladLoadGL(glfwGetProcAddress); #endif @@ -204,9 +204,11 @@ namespace blt::gfx /* -- Set up ImGUI -- */ setup_ImGUI(); - + +#ifdef GL_MULTISAMPLE if (data.context.SAMPLES > 0) glEnable(GL_MULTISAMPLE); +#endif /* -- Call User Provided post-window-init function -- */ data.init(data.context);