Use OpenGL2 on MacOS instead of OpenGL3

This commit is contained in:
Jeffrey Crowell 2022-05-30 12:03:14 -04:00
commit 91da461caa
3 changed files with 21 additions and 2 deletions

View file

@ -56,6 +56,7 @@ CXX_FILES := \
$(shell find libultraship/Lib/Fast3D -name *.cpp) \ $(shell find libultraship/Lib/Fast3D -name *.cpp) \
$(shell find libultraship -maxdepth 1 -name *.cpp) \ $(shell find libultraship -maxdepth 1 -name *.cpp) \
$(shell find libultraship/Lib/ImGui -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_opengl3.cpp \
libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \ libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \
libultraship/Lib/StrHash64.cpp \ libultraship/Lib/StrHash64.cpp \
@ -80,6 +81,7 @@ INC_DIRS := $(addprefix -I, \
libultraship/Lib/Fast3D/U64 \ libultraship/Lib/Fast3D/U64 \
libultraship/Lib/spdlog \ libultraship/Lib/spdlog \
libultraship/Lib/spdlog/include \ libultraship/Lib/spdlog/include \
libultraship/Lib/ImGui \
libultraship \ libultraship \
) )

View file

@ -220,9 +220,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
if (imgl3wInit() != 0) if (imgl3wInit() != 0)
{ {
fprintf(stderr, "Failed to initialize OpenGL loader!\n"); 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; return false;
#endif //#endif
} }
#endif #endif

View file

@ -27,8 +27,13 @@
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#ifdef ENABLE_OPENGL #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_opengl3.h"
#include "Lib/ImGui/backends/imgui_impl_sdl.h" #include "Lib/ImGui/backends/imgui_impl_sdl.h"
#endif
#endif #endif
@ -153,7 +158,11 @@ namespace SohImGui {
void ImGuiBackendInit() { void ImGuiBackendInit() {
switch (impl.backend) { switch (impl.backend) {
case Backend::SDL: case Backend::SDL:
#ifdef __APPLE__
ImGui_ImplOpenGL2_Init();
#else
ImGui_ImplOpenGL3_Init("#version 120"); ImGui_ImplOpenGL3_Init("#version 120");
#endif
break; break;
#if defined(ENABLE_DX11) || defined(ENABLE_DX12) #if defined(ENABLE_DX11) || defined(ENABLE_DX12)
@ -199,7 +208,11 @@ namespace SohImGui {
void ImGuiBackendNewFrame() { void ImGuiBackendNewFrame() {
switch (impl.backend) { switch (impl.backend) {
case Backend::SDL: case Backend::SDL:
#ifdef __APPLE__
ImGui_ImplOpenGL2_NewFrame();
#else
ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplOpenGL3_NewFrame();
#endif
break; break;
#if defined(ENABLE_DX11) || defined(ENABLE_DX12) #if defined(ENABLE_DX11) || defined(ENABLE_DX12)
case Backend::DX11: case Backend::DX11:
@ -214,7 +227,11 @@ namespace SohImGui {
void ImGuiRenderDrawData(ImDrawData* data) { void ImGuiRenderDrawData(ImDrawData* data) {
switch (impl.backend) { switch (impl.backend) {
case Backend::SDL: case Backend::SDL:
#ifdef __APPLE__
ImGui_ImplOpenGL2_RenderDrawData(data);
#else
ImGui_ImplOpenGL3_RenderDrawData(data); ImGui_ImplOpenGL3_RenderDrawData(data);
#endif
break; break;
#if defined(ENABLE_DX11) || defined(ENABLE_DX12) #if defined(ENABLE_DX11) || defined(ENABLE_DX12)
case Backend::DX11: case Backend::DX11: