mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 20:59:19 +02:00
make imgui version runtime selectable
This commit is contained in:
@@ -45,7 +45,6 @@ if (APPLE)
|
|||||||
set (CMAKE_FIND_FRAMEWORK LAST)
|
set (CMAKE_FIND_FRAMEWORK LAST)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" ON)
|
|
||||||
option(WITH_OPENGL_MODERN "Compile with OpenGL modern renderer" ON)
|
option(WITH_OPENGL_MODERN "Compile with OpenGL modern renderer" ON)
|
||||||
option(WITH_OPENGL_LEGACY "Compile with OpenGL legacy renderer" ON)
|
option(WITH_OPENGL_LEGACY "Compile with OpenGL legacy renderer" ON)
|
||||||
option(WITH_UART "Compile with libserialport" ON)
|
option(WITH_UART "Compile with libserialport" ON)
|
||||||
@@ -201,13 +200,10 @@ set(SOURCES
|
|||||||
"vr/vr_interface.cpp"
|
"vr/vr_interface.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (USE_IMGUI_GL3)
|
set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp")
|
||||||
set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp")
|
set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl2.cpp")
|
||||||
else()
|
set_source_files_properties("imgui/imgui_impl_opengl3.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
|
||||||
add_definitions(-DEU07_USEIMGUIIMPLOPENGL2)
|
set_source_files_properties("imgui/imgui_impl_opengl2.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
|
||||||
set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl2.cpp")
|
|
||||||
set_source_files_properties("imgui/imgui_impl_opengl2.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (WITH_CRASHPAD)
|
if (WITH_CRASHPAD)
|
||||||
add_definitions(-DWITH_CRASHPAD)
|
add_definitions(-DWITH_CRASHPAD)
|
||||||
|
|||||||
@@ -820,32 +820,23 @@ eu07_application::init_glfw() {
|
|||||||
if (!monitor)
|
if (!monitor)
|
||||||
monitor = glfwGetPrimaryMonitor();
|
monitor = glfwGetPrimaryMonitor();
|
||||||
|
|
||||||
auto const uselegacyrenderer { Global.GfxRenderer != "default" };
|
|
||||||
glfwWindowHint( GLFW_AUTO_ICONIFY, GLFW_FALSE );
|
glfwWindowHint( GLFW_AUTO_ICONIFY, GLFW_FALSE );
|
||||||
if ((Global.gfx_skippipeline || uselegacyrenderer) && Global.iMultisampling > 0) {
|
if ((Global.gfx_skippipeline || Global.LegacyRenderer) && Global.iMultisampling > 0) {
|
||||||
glfwWindowHint( GLFW_SAMPLES, 1 << Global.iMultisampling );
|
glfwWindowHint( GLFW_SAMPLES, 1 << Global.iMultisampling );
|
||||||
}
|
}
|
||||||
|
|
||||||
crashreport_add_info("gfxrenderer", Global.GfxRenderer);
|
crashreport_add_info("gfxrenderer", Global.GfxRenderer);
|
||||||
|
|
||||||
if( false == uselegacyrenderer ) {
|
if( !Global.LegacyRenderer ) {
|
||||||
Global.bUseVBO = true;
|
Global.bUseVBO = true;
|
||||||
// activate core profile for opengl 3.3 renderer
|
// activate core profile for opengl 3.3 renderer
|
||||||
if( !Global.gfx_usegles ) {
|
if( !Global.gfx_usegles ) {
|
||||||
#ifndef EU07_USEIMGUIIMPLOPENGL2
|
|
||||||
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
|
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
|
||||||
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE );
|
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE );
|
||||||
#else
|
|
||||||
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE );
|
|
||||||
#endif
|
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
|
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
|
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
|
||||||
ErrorLog("gles not supported in imgui gl2 build");
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
#ifdef GLFW_CONTEXT_CREATION_API
|
#ifdef GLFW_CONTEXT_CREATION_API
|
||||||
if (m_glfwversion >= 30200)
|
if (m_glfwversion >= 30200)
|
||||||
glfwWindowHint( GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API );
|
glfwWindowHint( GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API );
|
||||||
@@ -861,13 +852,8 @@ eu07_application::init_glfw() {
|
|||||||
}
|
}
|
||||||
Global.gfx_shadergamma = false;
|
Global.gfx_shadergamma = false;
|
||||||
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE );
|
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE );
|
||||||
#ifndef EU07_USEIMGUIIMPLOPENGL2
|
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
|
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 0 );
|
|
||||||
#else
|
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 2 );
|
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 2 );
|
||||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 1 );
|
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 1 );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Global.gfx_gldebug)
|
if (Global.gfx_gldebug)
|
||||||
|
|||||||
@@ -4392,17 +4392,10 @@ opengl_renderer::Init_caps() {
|
|||||||
+ " Vendor: " + gl_vendor
|
+ " Vendor: " + gl_vendor
|
||||||
+ " OpenGL Version: " + gl_version );
|
+ " OpenGL Version: " + gl_version );
|
||||||
|
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
if( !GLAD_GL_VERSION_2_1 ) {
|
||||||
if( !GLAD_GL_VERSION_1_5 ) {
|
ErrorLog( "Requires openGL >= 2.1" );
|
||||||
ErrorLog( "Requires openGL >= 1.5" );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if( !GLAD_GL_VERSION_3_0 ) {
|
|
||||||
ErrorLog( "Requires openGL >= 3.0" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char* extensions = (char*)glGetString( GL_EXTENSIONS );
|
char* extensions = (char*)glGetString( GL_EXTENSIONS );
|
||||||
if (extensions)
|
if (extensions)
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
//#define EU07_USE_DEBUG_CABSHADOWMAP
|
//#define EU07_USE_DEBUG_CABSHADOWMAP
|
||||||
//#define EU07_USE_DEBUG_CAMERA
|
//#define EU07_USE_DEBUG_CAMERA
|
||||||
//#define EU07_USE_DEBUG_SOUNDEMITTERS
|
//#define EU07_USE_DEBUG_SOUNDEMITTERS
|
||||||
//#define EU07_USEIMGUIIMPLOPENGL2
|
|
||||||
//#define EU07_DISABLECABREFLECTIONS
|
//#define EU07_DISABLECABREFLECTIONS
|
||||||
|
|
||||||
// bare-bones render controller, in lack of anything better yet
|
// bare-bones render controller, in lack of anything better yet
|
||||||
|
|||||||
50
uilayer.cpp
50
uilayer.cpp
@@ -19,11 +19,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
|
||||||
#include "imgui/imgui_impl_glfw.h"
|
#include "imgui/imgui_impl_glfw.h"
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
|
||||||
#include "imgui/imgui_impl_opengl2.h"
|
#include "imgui/imgui_impl_opengl2.h"
|
||||||
#else
|
|
||||||
#include "imgui/imgui_impl_opengl3.h"
|
#include "imgui/imgui_impl_opengl3.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
GLFWwindow *ui_layer::m_window{nullptr};
|
GLFWwindow *ui_layer::m_window{nullptr};
|
||||||
ImGuiIO *ui_layer::m_imguiio{nullptr};
|
ImGuiIO *ui_layer::m_imguiio{nullptr};
|
||||||
@@ -241,16 +238,16 @@ bool ui_layer::init(GLFWwindow *Window)
|
|||||||
imgui_style();
|
imgui_style();
|
||||||
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(m_window, false);
|
ImGui_ImplGlfw_InitForOpenGL(m_window, false);
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
if (Global.LegacyRenderer) {
|
||||||
crashreport_add_info("imgui_ver", "gl2");
|
crashreport_add_info("imgui_ver", "gl2");
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
#else
|
} else {
|
||||||
crashreport_add_info("imgui_ver", "gl3");
|
crashreport_add_info("imgui_ver", "gl3");
|
||||||
if (Global.gfx_usegles)
|
if (Global.gfx_usegles)
|
||||||
ImGui_ImplOpenGL3_Init("#version 300 es\nprecision highp float;");
|
ImGui_ImplOpenGL3_Init("#version 300 es\nprecision highp float;");
|
||||||
else
|
else
|
||||||
ImGui_ImplOpenGL3_Init("#version 330 core");
|
ImGui_ImplOpenGL3_Init("#version 330 core");
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -259,11 +256,10 @@ void ui_layer::shutdown()
|
|||||||
{
|
{
|
||||||
ImGui::EndFrame();
|
ImGui::EndFrame();
|
||||||
|
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
if (Global.LegacyRenderer)
|
||||||
ImGui_ImplOpenGL2_Shutdown();
|
ImGui_ImplOpenGL2_Shutdown();
|
||||||
#else
|
else
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
#endif
|
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
}
|
}
|
||||||
@@ -344,11 +340,10 @@ void ui_layer::render_internal()
|
|||||||
{
|
{
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
if (Global.LegacyRenderer)
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
#else
|
else
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_layer::begin_ui_frame()
|
void ui_layer::begin_ui_frame()
|
||||||
@@ -358,11 +353,10 @@ void ui_layer::begin_ui_frame()
|
|||||||
|
|
||||||
void ui_layer::begin_ui_frame_internal()
|
void ui_layer::begin_ui_frame_internal()
|
||||||
{
|
{
|
||||||
#ifdef EU07_USEIMGUIIMPLOPENGL2
|
if (Global.LegacyRenderer)
|
||||||
ImGui_ImplOpenGL2_NewFrame();
|
ImGui_ImplOpenGL2_NewFrame();
|
||||||
#else
|
else
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
#endif
|
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user