Skip to content

Commit

Permalink
new optional define IMGUI_IMPL_OPENGL_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilawa committed Oct 23, 2019
1 parent 9994f5b commit aada086
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion examples/imgui_impl_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#undef IMGUI_IMPL_OPENGL_VERSION
#elif defined(__EMSCRIPTEN__)
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#undef IMGUI_IMPL_OPENGL_VERSION
#endif
#endif

Expand Down Expand Up @@ -119,8 +121,36 @@
#endif
#endif

// Define desktop GL version
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
#if defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) && !defined(IMGUI_IMPL_OPENGL_VERSION)
// This attempts to define automatically based on GLAD defines
#if defined(GL_VERSION_4_6)
#define IMGUI_IMPL_OPENGL_VERSION 46
#elif defined(GL_VERSION_4_5)
#define IMGUI_IMPL_OPENGL_VERSION 45
#elif defined(GL_VERSION_4_4)
#define IMGUI_IMPL_OPENGL_VERSION 44
#elif defined(GL_VERSION_4_3)
#define IMGUI_IMPL_OPENGL_VERSION 43
#elif defined(GL_VERSION_4_2)
#define IMGUI_IMPL_OPENGL_VERSION 42
#elif defined(GL_VERSION_4_1)
#define IMGUI_IMPL_OPENGL_VERSION 41
#elif defined(GL_VERSION_4_0)
#define IMGUI_IMPL_OPENGL_VERSION 40
#elif defined(GL_VERSION_3_2)
#define IMGUI_IMPL_OPENGL_VERSION 32
#elif defined(GL_VERSION_3_1)
#define IMGUI_IMPL_OPENGL_VERSION 31
#elif defined(GL_VERSION_3_0)
#define IMGUI_IMPL_OPENGL_VERSION 30
#endif
#endif
#endif

// Desktop GL has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3)
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(IMGUI_IMPL_OPENGL_VERSION) || IMGUI_IMPL_OPENGL_VERSION < 32
#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 0
#else
#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 1
Expand Down

0 comments on commit aada086

Please sign in to comment.