From 91da461caa9e419f0d24596456a3ee56e716e6a1 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Mon, 30 May 2022 12:03:14 -0400 Subject: [PATCH] Use OpenGL2 on MacOS instead of OpenGL3 --- libultraship/Makefile | 2 ++ .../Lib/ImGui/backends/imgui_impl_opengl3.cpp | 4 ++-- libultraship/libultraship/SohImGuiImpl.cpp | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libultraship/Makefile b/libultraship/Makefile index 9f269ea61..b1bc0f691 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -56,6 +56,7 @@ CXX_FILES := \ $(shell find libultraship/Lib/Fast3D -name *.cpp) \ $(shell find libultraship -maxdepth 1 -name *.cpp) \ $(shell find libultraship/Lib/ImGui -maxdepth 1 -name *.cpp) \ + libultraship/Lib/ImGui/backends/imgui_impl_opengl2.cpp \ libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp \ libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \ libultraship/Lib/StrHash64.cpp \ @@ -80,6 +81,7 @@ INC_DIRS := $(addprefix -I, \ libultraship/Lib/Fast3D/U64 \ libultraship/Lib/spdlog \ libultraship/Lib/spdlog/include \ + libultraship/Lib/ImGui \ libultraship \ ) diff --git a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp index 9ff0e80c2..c1d182c07 100644 --- a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp +++ b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp @@ -220,9 +220,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) if (imgl3wInit() != 0) { fprintf(stderr, "Failed to initialize OpenGL loader!\n"); -#ifndef __APPLE__ // this is ok due to shared library cache +//#ifndef __APPLE__ // this is ok due to shared library cache return false; -#endif +//#endif } #endif diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 8e4becaab..84149fcfc 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -27,8 +27,13 @@ #include "Utils/StringHelper.h" #ifdef ENABLE_OPENGL +#ifdef __APPLE__ +#include "Lib/ImGui/backends/imgui_impl_opengl2.h" +#include "Lib/ImGui/backends/imgui_impl_sdl.h" +#else #include "Lib/ImGui/backends/imgui_impl_opengl3.h" #include "Lib/ImGui/backends/imgui_impl_sdl.h" +#endif #endif @@ -153,7 +158,11 @@ namespace SohImGui { void ImGuiBackendInit() { switch (impl.backend) { case Backend::SDL: +#ifdef __APPLE__ + ImGui_ImplOpenGL2_Init(); +#else ImGui_ImplOpenGL3_Init("#version 120"); +#endif break; #if defined(ENABLE_DX11) || defined(ENABLE_DX12) @@ -199,7 +208,11 @@ namespace SohImGui { void ImGuiBackendNewFrame() { switch (impl.backend) { case Backend::SDL: +#ifdef __APPLE__ + ImGui_ImplOpenGL2_NewFrame(); +#else ImGui_ImplOpenGL3_NewFrame(); +#endif break; #if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: @@ -214,7 +227,11 @@ namespace SohImGui { void ImGuiRenderDrawData(ImDrawData* data) { switch (impl.backend) { case Backend::SDL: +#ifdef __APPLE__ + ImGui_ImplOpenGL2_RenderDrawData(data); +#else ImGui_ImplOpenGL3_RenderDrawData(data); +#endif break; #if defined(ENABLE_DX11) || defined(ENABLE_DX12) case Backend::DX11: