Skip to content

Commit

Permalink
Clarify the dependency to OpenGL
Browse files Browse the repository at this point in the history
Dear ImGui itself does not have a dependency on OpenGL::GL because
it has its own customm OpenGL loader.
However, our application has that dependency, because we de not use a
loader (such as glad or gl3w) despite a few OpenGL calls: glClear()
to clear the framebuffer, glGetString() to read GL_VERSION, etc.
  • Loading branch information
pierre-dejoue committed Sep 15, 2024
1 parent 6b73ea0 commit 0b5cad4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Command line interface:
Graphical UI:

* OpenGL
* [GLFW3](http://glfw.sf.net)
* [GLFW](https://www.glfw.org/)
* [Dear ImGui](https://github.com/ocornut/imgui)
* [Portable File Dialogs](https://github.com/samhocevar/portable-file-dialogs)

Expand Down
3 changes: 3 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
option(PICROSS_GUI_IMGUI_DEMO "Show ImGUI demo window" OFF)

# Dependencies
find_package(OpenGL REQUIRED) # Necessary because we do not use a loader (such as gl3w or glad)
include(pfd)

set(GUI_SOURCES
Expand Down Expand Up @@ -53,7 +54,9 @@ target_link_libraries(picross_solver
stdutils
picross::picross
picross::utils
glfw
imgui
OpenGL::GL
pfd
)

Expand Down
4 changes: 1 addition & 3 deletions src/gui/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Dependencies
find_package(OpenGL REQUIRED)
include(glfw)
include(imgui)

Expand Down Expand Up @@ -40,9 +39,8 @@ target_compile_definitions(imgui
)

target_link_libraries(imgui
PUBLIC
PRIVATE
glfw
OpenGL::GL
)

set_property(TARGET imgui PROPERTY FOLDER "third_parties")
14 changes: 12 additions & 2 deletions src/gui/src/imgui_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,21 @@ void DearImGuiContext::render() const

void DearImGuiContext::backend_info(std::ostream& out) const
{
// Dear ImGui
const ImGuiIO& io = ImGui::GetIO();
out << "Dear ImGui " << IMGUI_VERSION
<< " (Backend platform: " << (io.BackendPlatformName ? io.BackendPlatformName : "NULL")
<< ", renderer: " << (io.BackendRendererName ? io.BackendRendererName : "NULL") << ")" << std::endl;

// GLFW
out << "GLFW " << GLFW_VERSION_MAJOR << "." << GLFW_VERSION_MINOR << "." << GLFW_VERSION_REVISION << std::endl;
out << "OpenGL Version " << glGetString(GL_VERSION) << std::endl;
out << "OpenGL Renderer " << glGetString(GL_RENDERER) << std::endl;

// OpenGL
const auto* open_gl_version_str = glGetString(GL_VERSION); // Will return NULL if there is no current OpenGL context!
if (open_gl_version_str)
out << "OpenGL Version: " << open_gl_version_str << std::endl;
const auto* open_gl_vendor_str = glGetString(GL_VENDOR);
const auto* open_gl_renderer_str = glGetString(GL_RENDERER);
if (open_gl_vendor_str && open_gl_renderer_str)
out << "OpenGL Vendor: " << open_gl_vendor_str << "; Renderer: " << open_gl_renderer_str << std::endl;
}
2 changes: 1 addition & 1 deletion src/gui/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <pfd_wrap.h>
#include <GLFW/glfw3.h>
#include "glfw_context.h"
// NB: No OpenGL loader here: This project only relies on the drawing features provided by Dear ImGui.
// NB: No OpenGL loader here: This project mainly 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"

Expand Down

0 comments on commit 0b5cad4

Please sign in to comment.