|
|
|
@ -12,47 +12,13 @@
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include "../overlay.h"
|
|
|
|
|
|
|
|
|
|
// About Desktop OpenGL function loaders:
|
|
|
|
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
|
|
|
|
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
|
|
|
|
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
|
|
|
|
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
|
|
|
|
#include "GL/gl3w.h" // Initialize with gl3wInit()
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
|
|
|
|
#include <GL/glew.h> // Initialize with glewInit()
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
|
|
|
|
#include <glad/glad.h> // Initialize with gladLoadGL()
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
|
|
|
|
#include <glad/gl.h> // Initialize with gladLoadGL(...) or gladLoaderLoadGL()
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
|
|
|
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
|
|
|
|
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
|
|
|
|
|
#include <glbinding/gl/gl.h>
|
|
|
|
|
using namespace gl;
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
|
|
|
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
|
|
|
|
#include <glbinding/glbinding.h>// Initialize with glbinding::initialize()
|
|
|
|
|
#include <glbinding/gl/gl.h>
|
|
|
|
|
using namespace gl;
|
|
|
|
|
#else
|
|
|
|
|
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Include glfw3.h after our OpenGL definitions
|
|
|
|
|
#include <GL/glew.h>
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
|
|
#define GLFW_EXPOSE_NATIVE_X11
|
|
|
|
|
#include <GLFW/glfw3native.h>
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
|
|
|
|
|
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
|
|
|
|
// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
|
|
|
|
// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio.
|
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
|
|
|
|
|
#pragma comment(lib, "legacy_stdio_definitions")
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void glfw_error_callback(int error, const char* description)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
|
|
|
@ -133,23 +99,9 @@ int main(int, char**)
|
|
|
|
|
glfwSwapInterval(1); // Enable vsync
|
|
|
|
|
|
|
|
|
|
// Initialize OpenGL loader
|
|
|
|
|
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
|
|
|
|
bool err = gl3wInit() != 0;
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
|
|
|
|
|
|
|
|
|
bool err = glewInit() != GLEW_OK;
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
|
|
|
|
bool err = gladLoadGL() == 0;
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
|
|
|
|
bool err = gladLoadGL(glfwGetProcAddress) == 0; // glad2 recommend using the windowing library loader instead of the (optionally) bundled one.
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
|
|
|
|
bool err = false;
|
|
|
|
|
glbinding::Binding::initialize();
|
|
|
|
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
|
|
|
|
bool err = false;
|
|
|
|
|
glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)glfwGetProcAddress(name); });
|
|
|
|
|
#else
|
|
|
|
|
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
|
|
|
|
@ -160,12 +112,7 @@ int main(int, char**)
|
|
|
|
|
IMGUI_CHECKVERSION();
|
|
|
|
|
ImGui::CreateContext();
|
|
|
|
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
|
|
|
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
|
|
|
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
|
|
|
|
|
|
|
|
|
// Setup Dear ImGui style
|
|
|
|
|
ImGui::StyleColorsDark();
|
|
|
|
|
//ImGui::StyleColorsClassic();
|
|
|
|
|
|
|
|
|
|
// Setup Platform/Renderer backends
|
|
|
|
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
|
|
|
@ -189,13 +136,6 @@ int main(int, char**)
|
|
|
|
|
// Main loop
|
|
|
|
|
while (!glfwWindowShouldClose(window))
|
|
|
|
|
{
|
|
|
|
|
// Poll and handle events (inputs, window resize, etc.)
|
|
|
|
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
|
|
|
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
|
|
|
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
|
|
|
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
|
|
|
|
glfwPollEvents();
|
|
|
|
|
|
|
|
|
|
// Start the Dear ImGui frame
|
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
|