1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
Description: Use packaged imgui
Use the packaged libimgui -- adapt CMakeLists.txt and to obsolete functions removed
in newer imgui.
Author: Tobias Frost <tobi@debian.org>
Forwarded: https://github.com/RobertBeckebans/RBDOOM-3-BFG/pull/657
Last-Update: 2024-11-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/neo/CMakeLists.txt
+++ b/neo/CMakeLists.txt
@@ -69,6 +69,10 @@
option(USE_SYSTEM_RAPIDJSON
"Use the system rapidjson instead of the bundled one" OFF)
+option(USE_SYSTEM_IMGUI
+ "Use the system imgui instead of the bundled one" OFF)
+
+
set(CPU_TYPE "" CACHE STRING "When set, passes this string as CPU-ID which will be embedded into the binary.")
# SRS - Turn on optimization when cross-compiling from Apple arm64 to x86_64
@@ -355,6 +359,18 @@
endif (JPEG_FOUND)
+if (USE_SYSTEM_IMGUI)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(IMGUI REQUIRED imgui)
+endif()
+
+if(IMGUI_FOUND)
+ include_directories(${IMGUI_INCLUDE_DIRS})
+else()
+ include_directories("libs/imgui/../")
+ set(IMGUI_LIBRARIES "")
+endif()
+
macro(SET_OPTION option value)
set(${option} ${value} CACHE "" INTERNAL FORCE)
endmacro()
@@ -481,7 +497,6 @@
endif (RAPIDJSON_FOUND)
-
add_subdirectory(idlib)
file(GLOB AAS_INCLUDES aas/*.h)
@@ -534,8 +549,13 @@
file(GLOB IRRXML_INCLUDES libs/irrxml/src/*.h)
file(GLOB IRRXML_SOURCES libs/irrxml/src/*.cpp)
+if(NOT USE_SYSTEM_IMGUI)
file(GLOB IMGUI_INCLUDES libs/imgui/*.h)
file(GLOB IMGUI_SOURCES libs/imgui/*.cpp)
+else()
+set(IMGUI_INCLUDES "")
+set(IMGUI_SOURCES "")
+endif()
file(GLOB STB_INCLUDES libs/stb/*.h)
@@ -1867,6 +1887,7 @@
${PNG_LIBRARY}
${JPEG_LIBRARY}
${GLEW_LIBRARY}
+ ${IMGUI_LIBRARIES}
${CMAKE_DL_LIBS}
)
endif()
--- a/neo/imgui/BFGimgui.h
+++ b/neo/imgui/BFGimgui.h
@@ -2,7 +2,7 @@
#ifndef NEO_IMGUI_BFGIMGUI_H_
#define NEO_IMGUI_BFGIMGUI_H_
-#include "libs/imgui/imgui.h"
+#include "imgui/imgui.h"
#include "../idlib/math/Vector.h"
--- a/neo/renderer/GuiModel.cpp
+++ b/neo/renderer/GuiModel.cpp
@@ -31,7 +31,7 @@
#pragma hdrstop
#include "RenderCommon.h"
-#include "libs/imgui/imgui.h"
+#include "imgui/imgui.h"
const float idGuiModel::STEREO_DEPTH_NEAR = 0.0f;
const float idGuiModel::STEREO_DEPTH_MID = 0.5f;
--- a/neo/renderer/Image_intrinsic.cpp
+++ b/neo/renderer/Image_intrinsic.cpp
@@ -30,7 +30,7 @@
#include "precompiled.h"
#pragma hdrstop
-#include "libs/imgui/imgui.h"
+#include "imgui/imgui.h"
#include "RenderCommon.h"
#include "SMAA/AreaTex.h"
@@ -942,7 +942,11 @@
// Store our identifier
//io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
+#if (IMGUI_VERSION_NUM < 19140)
io.Fonts->TexID = ( void* )( intptr_t )declManager->FindMaterial( "_imguiFont" );
+#else
+ io.Fonts->TexID = ( ImTextureID )( intptr_t )declManager->FindMaterial( "_imguiFont" );
+#endif
// Cleanup (don't clear the input data if you want to append new fonts later)
//io.Fonts->ClearInputData();
--- a/neo/renderer/RenderSystem_init.cpp
+++ b/neo/renderer/RenderSystem_init.cpp
@@ -31,7 +31,7 @@
#include "precompiled.h"
#pragma hdrstop
-#include "libs/imgui/imgui.h"
+#include "imgui/imgui.h"
#include "RenderCommon.h"
@@ -1620,7 +1620,11 @@
#if IMGUI_BFGUI
ImGuiIO& io = ImGui::GetIO();
+#if (IMGUI_VERSION_NUM < 19140)
io.Fonts->TexID = ( void* )( intptr_t )tr.imgGuiMaterial;
+#else
+ io.Fonts->TexID = ( ImTextureID )( intptr_t )tr.imgGuiMaterial;
+#endif
#endif
}
--- a/neo/ui/DeviceContext.cpp
+++ b/neo/ui/DeviceContext.cpp
@@ -31,7 +31,7 @@
#include "DeviceContext.h"
-#include "libs/imgui/imgui.h"
+#include "imgui/imgui.h"
#include "../renderer/GuiModel.h"
extern idCVar in_useJoystick;
--- a/neo/imgui/BFGimguiImpl.cpp
+++ b/neo/imgui/BFGimguiImpl.cpp
@@ -249,7 +249,9 @@
g_DisplaySize.y = windowHeight;
io.DisplaySize = g_DisplaySize;
+#if (IMGUI_VERSION_NUM <= 16000)
io.RenderDrawListsFn = idRenderBackend::ImGui_RenderDrawLists;
+#endif
// RB: FIXME double check
io.SetClipboardTextFn = SetClipboardText;
@@ -291,7 +293,11 @@
byte* pixels = NULL;
io.Fonts->GetTexDataAsRGBA32( &pixels, &width, &height );
+#if (IMGUI_VERSION_NUM < 19140)
io.Fonts->TexID = ( void* )image;
+#else
+ io.Fonts->TexID = ( ImTextureID )image;
+#endif
}
}
}
@@ -437,6 +443,10 @@
//ImGui::End();
ImGui::Render();
+#if (IMGUI_VERSION_NUM > 16000)
+ idRenderBackend::ImGui_RenderDrawLists(ImGui::GetDrawData());
+#endif
+
g_haveNewFrame = false;
}
}
--- a/neo/renderer/OpenGL/RenderBackend_GL.cpp
+++ b/neo/renderer/OpenGL/RenderBackend_GL.cpp
@@ -48,7 +48,7 @@
#include "../RenderBackend.h"
#include "../../framework/Common_local.h"
-#include "../../imgui/imgui.h"
+#include "imgui/imgui.h"
idCVar r_drawFlickerBox( "r_drawFlickerBox", "0", CVAR_RENDERER | CVAR_BOOL, "visual test for dropping frames" );
idCVar stereoRender_warp( "stereoRender_warp", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use the optical warping renderprog instead of stereoDeGhost" );
--- a/neo/tools/imgui/lighteditor/LightEditor.cpp
+++ b/neo/tools/imgui/lighteditor/LightEditor.cpp
@@ -714,7 +714,11 @@
#if !IMGUI_BFGUI
ImGui::Image( ( void* )currentTexture->GetImGuiTextureID(), size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
#else
+#if (IMGUI_VERSION_NUM < 19140)
ImGui::Image( ( void* )currentTextureMaterial, size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
+#else
+ ImGui::Image( (ImTextureID)(intptr_t)currentTextureMaterial, size, ImVec2( 0, 0 ), ImVec2( 1, 1 ),
+#endif
#endif
ImColor( 255, 255, 255, 255 ), ImColor( 255, 255, 255, 128 ) );
}
|