Skip to content

Commit

Permalink
Add comments regarding the OpenGL initialization
Browse files Browse the repository at this point in the history
Nothing fancy needed for this project since rely entirely on ImGui drawing API.
  • Loading branch information
pierre-dejoue committed Aug 14, 2023
1 parent d22da3a commit aab0140
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/gui/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
#include <picross/picross.h>
#include <stdutils/macros.h>

#include <pfd_wrap.h> // Include before glfw3.h
#include <GLFW/glfw3.h>
// Order matters in this section
#include <imgui_wrap.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <pfd_wrap.h>
#include <GLFW/glfw3.h>
// 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 <cassert>
#include <iostream>
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit aab0140

Please sign in to comment.