From aab0140164559a2aaa883ab9c5341ddaac62eb23 Mon Sep 17 00:00:00 2001 From: Pierre Dejoue Date: Mon, 14 Aug 2023 18:57:31 +0200 Subject: [PATCH] Add comments regarding the OpenGL initialization Nothing fancy needed for this project since rely entirely on ImGui drawing API. --- src/gui/src/main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 2fe16a7..6826a5b 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -12,11 +12,15 @@ #include #include -#include // Include before glfw3.h -#include +// Order matters in this section #include #include #include +#include +#include +// NB: No OpenGL loader here: this project only relies on the drawing features provided by Dear ImGui. +// Dear ImGui embeds its own minimal loader for the OpenGL 3.x functions it needs. +// See: https://github.com/ocornut/imgui/issues/4445 "OpenGL backend now embeds its own GL loader" #include #include @@ -65,18 +69,14 @@ int main(int argc, char *argv[]) std::stringstream picross_title; picross_title << "Picross Solver " << picross::get_version_string(); std::cout << picross_title.str() << std::endl; - std::cout << "Dear ImGui " << IMGUI_VERSION << std::endl; // Setup main window glfwSetErrorCallback(glfw_error_callback); if (!glfwInit()) return 1; - - // GL 3.0 + GLSL 130 const char* glsl_version = "#version 130"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - GLFWwindow* window = glfwCreateWindow(1280, 720, picross_title.str().c_str(), nullptr, nullptr); if (window == nullptr) return 1; @@ -93,6 +93,11 @@ int main(int argc, char *argv[]) ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init(glsl_version); + // Print out version information + std::cout << "Dear ImGui " << IMGUI_VERSION << std::endl; + std::cout << "GLFW " << GLFW_VERSION_MAJOR << "." << GLFW_VERSION_MINOR << "." << GLFW_VERSION_REVISION << std::endl; + std::cout << "OpenGL " << glGetString(GL_VERSION) << std::endl; + // Style bool imgui_dark_mode = false; imgui_set_style(imgui_dark_mode);