From 0f15059ab5da53a3c2091ce09c39b76e9bce35a0 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sat, 15 Dec 2018 14:14:22 +0100 Subject: [PATCH] intermediate commit --- CMakeLists.txt | 13 +++++++++---- src/main.cc | 16 ++++++++++------ src/modules/RenderModule.h | 3 +-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8392bc5..ef6ebbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,9 @@ include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC") elseif(COMPILER_SUPPORTS_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fPIC") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() @@ -29,6 +29,9 @@ endif() # enable strings in GDB set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG") +message(STATUS "Using compiler flags ${CMAKE_CXX_FLAGS}") + + INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} @@ -49,7 +52,7 @@ INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR}/src 3rdparty/imgui - 3rdparty/imgui/examples/opengl3_example + 3rdparty/imgui/examples/ 3rdparty/imgui/examples/libs/gl3w ) @@ -71,9 +74,11 @@ SET ( protot_SRCS 3rdparty/imgui/imgui.cpp 3rdparty/imgui/imgui_draw.cpp + 3rdparty/imgui/imgui_widgets.cpp 3rdparty/imgui/imgui_demo.cpp 3rdparty/imgui/examples/libs/gl3w/GL/gl3w.c - 3rdparty/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.cpp + 3rdparty/imgui/examples/imgui_impl_glfw.cpp + 3rdparty/imgui/examples/imgui_impl_opengl3.cpp 3rdparty/imgui_dock_lumix/imgui_dock.cpp ) diff --git a/src/main.cc b/src/main.cc index f8bc9f0..f76a1f0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,7 +16,8 @@ #include "RuntimeModuleManager.h" #include "imgui/imgui.h" #include "imgui_dock.h" -#include "imgui_impl_glfw_gl3.h" +#include "imgui_impl_glfw.h" +#include "imgui_impl_opengl3.h" #include "FileModificationObserver.h" #include "Serializer.h" @@ -109,6 +110,7 @@ int main(void) glfwSetErrorCallback(error_callback); glfwInit(); + const char* glsl_version = "#version 150"; glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); @@ -142,8 +144,8 @@ int main(void) ImGuiIO& io = ImGui::GetIO(); (void)io; GuiInputState gui_input_state; gGuiInputState = &gui_input_state; - ImGui_ImplGlfwGL3_Init(gWindow, true); - ImGui::LoadDock(); + ImGui_ImplGlfw_InitForOpenGL(gWindow, true); + ImGui_ImplOpenGL3_Init(glsl_version); // FileModificationObserver FileModificationObserver file_modification_observer; @@ -185,7 +187,8 @@ int main(void) glViewport(0, 0, width, height); glfwPollEvents(); - ImGui_ImplGlfwGL3_NewFrame(); + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); if (module_manager.CheckModulesChanged()) { gLog("Detected module update at frame %d. Unloading all modules.", frame_counter); @@ -229,7 +232,7 @@ int main(void) module_manager.Update(gTimer->mDeltaTime); - ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); // Send the application to sleep if we have some time left for this frame double frame_target_time = 1.0 / module_manager.mTargetFPS; @@ -251,7 +254,8 @@ int main(void) ImGui::ShutdownDock(); - ImGui_ImplGlfwGL3_Shutdown(); + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); glfwTerminate(); } diff --git a/src/modules/RenderModule.h b/src/modules/RenderModule.h index 602654d..49e27ff 100644 --- a/src/modules/RenderModule.h +++ b/src/modules/RenderModule.h @@ -7,9 +7,8 @@ #include "math_types.h" -#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. #include "imgui.h" -#include "imgui_impl_glfw_gl3.h" +#include "imgui_impl_opengl3.h" #include "Globals.h" #include "RenderUtils.h"