Skip to content

Commit

Permalink
Fixed emscripten rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Madman10K committed Oct 27, 2024
1 parent 279d32b commit 9d414d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
8 changes: 3 additions & 5 deletions Framework/Renderer/OpenGL/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#include <Renderer.hpp>
#include <ImGui/ImGui.hpp>
#include <Interfaces/WindowInterface.hpp>
#ifndef __APPLE__
#include <glad/include/glad/gl.h>
#elif __EMSCRIPTEN__
#include <glad/include/glad/gles2.h>
#else
#ifdef __APPLE__
#include <OpenGL/GL.h>
#else
#include <glad/include/glad/gl.h>
#endif
#include <GLFW/glfw3.h>
#include <imgui_impl_glfw.h>
Expand Down
8 changes: 3 additions & 5 deletions Framework/Renderer/Window/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
#endif
#endif

#ifndef __APPLE__
#include <glad/include/glad/gl.h>
#elif __EMSCRIPTEN__
#include <glad/include/glad/gles2.h>
#else
#ifdef __APPLE__
#include <OpenGL/GL.h>
#include "macOS/MacOSWindowPlatform.h"
#else
#include <glad/include/glad/gl.h>
#endif
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
Expand Down
18 changes: 11 additions & 7 deletions Framework/Renderer/Window/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#define STB_IMAGE_IMPLEMENTATION
#include "Window.hpp"
#ifndef __APPLE__
#include <glad/include/glad/gl.h>
#elif __EMSCRIPTEN__
#include <glad/include/glad/gles2.h>
#else
#ifdef __APPLE__
#include <OpenGL/GL.h>
#else
#include <glad/include/glad/gl.h>
#endif
#include <GLFW/glfw3.h>

Expand Down Expand Up @@ -196,9 +194,15 @@ void UImGui::WindowInternal::createWindow() noexcept

if (!Renderer::data().bVulkan)
{
#if !__APPLE__ && !__EMSCRIPTEN__
#if !__APPLE__
const int version = gladLoadGL(glfwGetProcAddress);
Logger::log("Successfully loaded OpenGL ", ULOG_LOG_TYPE_SUCCESS, GLAD_VERSION_MAJOR(version), ".", GLAD_VERSION_MINOR(version));
Logger::log(
#ifdef EMSCRIPTEN
"Successfully loaded WebGL ",
#else
"Successfully loaded OpenGL ",
#endif
ULOG_LOG_TYPE_SUCCESS, GLAD_VERSION_MAJOR(version), ".", GLAD_VERSION_MINOR(version));
#endif
glEnable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
Expand Down
9 changes: 2 additions & 7 deletions Framework/cmake/SetupSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ endif ()

if (NOT APPLE)
list(APPEND FRAMEWORK_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/Framework/ThirdParty/glad/include/")
file(GLOB_RECURSE GLAD_SRC "Framework/ThirdParty/glad/src/gl.c")
file(GLOB_RECURSE GLAD_HEAD "Framework/ThirdParty/glad/include/*.h")
endif()

include_directories(${FRAMEWORK_INCLUDE_DIRS})
Expand All @@ -41,9 +43,6 @@ if (EMSCRIPTEN)
"Framework/ThirdParty/imgui/backends/imgui_impl_opengl3.h"
"Framework/ThirdParty/imgui/backends/imgui_impl_wgpu.h"
"Framework/ThirdParty/imgui/backends/imgui_impl_opengl3_loader.h")

file(GLOB_RECURSE GLAD_SRC "Framework/ThirdParty/glad/src/gles2.c")
file(GLOB_RECURSE GLAD_HEAD "Framework/ThirdParty/glad/include/*.h")
else()
file(GLOB_RECURSE IMGUI_SRC "Framework/ThirdParty/imgui/backends/imgui_impl_glfw.cpp"
"Framework/ThirdParty/imgui/backends/imgui_impl_opengl3.cpp"
Expand All @@ -54,10 +53,6 @@ else()
"Framework/ThirdParty/imgui/backends/imgui_impl_opengl3.h" "Framework/ThirdParty/imgui/misc/freetype/*.h"
"Framework/ThirdParty/imgui/backends/imgui_impl_vulkan.h"
"Framework/ThirdParty/imgui/backends/imgui_impl_opengl3_loader.h")
if (NOT APPLE)
file(GLOB_RECURSE GLAD_SRC "Framework/ThirdParty/glad/src/gl.c")
file(GLOB_RECURSE GLAD_HEAD "Framework/ThirdParty/glad/include/*.h")
endif()
endif()

file(GLOB_RECURSE UGUI_SRC "Framework/Core/*.cpp" "Framework/Renderer/*.cpp" ${IMGUI_SRC} ${GLAD_SRC}
Expand Down

0 comments on commit 9d414d8

Please sign in to comment.