Skip to content

Commit 8e367e2

Browse files
committed
Examples: Use imgui_impl_opengl3_loader.h instead of gl3w (thedmd#264)
1 parent 3ed93be commit 8e367e2

File tree

10 files changed

+1325
-7408
lines changed

10 files changed

+1325
-7408
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ v0.9.4 (WIP):
44

55
BUGFIX: Editor: Don't duplicated ImVec2/ImVec3 == != operators defined since ImGui r19002 (#268)
66

7+
BUGFIX: Examples: Use imgui_impl_opengl3_loader.h instead of gl3w (#264)
8+
79
v0.9.3 (2023-10-14):
810

911
CHANGE: Canvas: Use ImDrawCallback_ImCanvas macro as draw callback sentinel (#256), thanks @nspitko

examples/application/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,12 @@ endif()
6969
if (OpenGL_FOUND)
7070
set(HAVE_OPENGL YES)
7171

72-
find_package(gl3w REQUIRED)
73-
# Explicitly select embedded GL3W loader
74-
target_compile_definitions(application PRIVATE IMGUI_IMPL_OPENGL_LOADER_GL3W)
75-
7672
target_include_directories(application PRIVATE ${OPENGL_INCLUDE_DIR})
77-
target_link_libraries(application PRIVATE ${OPENGL_gl_LIBRARY} gl3w)
73+
target_link_libraries(application PRIVATE ${OPENGL_gl_LIBRARY})
7874
list(APPEND _Application_Sources
7975
source/imgui_impl_opengl3.cpp
8076
source/imgui_impl_opengl3.h
77+
source/imgui_impl_opengl3_loader.h
8178
)
8279
endif()
8380

examples/application/source/imgui_impl_opengl3.cpp

Lines changed: 484 additions & 227 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
1+
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
22
// - Desktop GL: 2.x 3.x 4.x
33
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4-
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
4+
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
55

66
// Implemented features:
77
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8-
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
8+
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
99

10-
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
11-
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
12-
// https://github.com/ocornut/imgui
10+
// About WebGL/ES:
11+
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
12+
// - This is done automatically on iOS, Android and Emscripten targets.
13+
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
1314

14-
// About Desktop OpenGL function loaders:
15-
// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
16-
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
17-
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
15+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
16+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
17+
// Learn about Dear ImGui:
18+
// - FAQ https://dearimgui.com/faq
19+
// - Getting Started https://dearimgui.com/getting-started
20+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
21+
// - Introduction, links and more at the top of imgui.cpp
1822

1923
// About GLSL version:
20-
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
24+
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
2125
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
2226
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
2327

2428
#pragma once
2529
#include "imgui.h" // IMGUI_IMPL_API
30+
#ifndef IMGUI_DISABLE
2631

2732
// Backend API
28-
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
33+
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
2934
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
3035
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
3136
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
@@ -40,48 +45,22 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
4045
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
4146
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
4247

43-
// Attempt to auto-detect the default Desktop GL loader based on available header files.
44-
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
45-
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
46-
// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
48+
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
4749
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
48-
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
49-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
50-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
51-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
52-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2) \
53-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
54-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
55-
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
50+
&& !defined(IMGUI_IMPL_OPENGL_ES3)
5651

5752
// Try to detect GLES on matching platforms
5853
#if defined(__APPLE__)
59-
#include "TargetConditionals.h"
54+
#include <TargetConditionals.h>
6055
#endif
6156
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
6257
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
63-
#elif defined(__EMSCRIPTEN__)
58+
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
6459
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
65-
66-
// Otherwise try to detect supported Desktop OpenGL loaders..
67-
#elif defined(__has_include)
68-
#if __has_include(<GL/glew.h>)
69-
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
70-
#elif __has_include(<glad/glad.h>)
71-
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
72-
#elif __has_include(<glad/gl.h>)
73-
#define IMGUI_IMPL_OPENGL_LOADER_GLAD2
74-
#elif __has_include(<GL/gl3w.h>)
75-
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
76-
#elif __has_include(<glbinding/glbinding.h>)
77-
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
78-
#elif __has_include(<glbinding/Binding.h>)
79-
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
80-
#else
81-
#error "Cannot detect OpenGL loader!"
82-
#endif
8360
#else
84-
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
61+
// Otherwise imgui_impl_opengl3_loader.h will be used.
8562
#endif
8663

8764
#endif
65+
66+
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)