-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backends: OpenGL3: Embed our own minimal GL loader (amends). (#4445)
- Loading branch information
Showing
15 changed files
with
41 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
// CHANGELOG | ||
// (minor and older changes stripped away, please see git history for details) | ||
// 2021-08-19: OpenGL: Embed and use our own minimal GL loader (imgui_impl_opengl3_loader.h), removing requirement and support for third-party loader. | ||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). | ||
// 2021-06-25: OpenGL: Use OES_vertex_array extension on Emscripten + backup/restore current state. | ||
// 2021-06-21: OpenGL: Destroy individual vertex/fragment shader objects right after they are linked into the main shader. | ||
|
@@ -108,16 +109,15 @@ | |
#else | ||
#include <GLES3/gl3.h> // Use GL ES 3 | ||
#endif | ||
#else | ||
// About Desktop OpenGL function loaders: | ||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. | ||
// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w. | ||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. | ||
// If you happen to be developing a new feature for this backend, you may want to get a unstripped version of | ||
// imgui_impl_opengl3_loader.h from https://github.com/dearimgui/gl3w_stripped/releases/ and use that temporarily. | ||
// When done, changes using new APIs should be accompanied by regenerated stripped loader version (instructions in | ||
// gl3w_stripped README.rst). | ||
#define IMGL3W_IMPL 1 | ||
#elif !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ocornut
Author
Owner
|
||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. | ||
// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w. | ||
// In the rest of your app/engine, you can use another loader of your choice (gl3w, glew, glad, glbinding, glext, glLoadGen, etc.). | ||
// If you happen to be developing a new feature for this backend (imgui_impl_opengl3.cpp): | ||
// - You may need to regenerate imgui_impl_opengl3_loader.h to add new symbols. See https://github.com/dearimgui/gl3w_stripped | ||
// - You can temporarily use an unstripped version. See https://github.com/dearimgui/gl3w_stripped/releases | ||
// Changes to this backend using new APIs should be accompanied by a regenerated stripped loader version. | ||
#define IMGL3W_IMPL | ||
#include "imgui_impl_opengl3_loader.h" | ||
#endif | ||
|
||
|
@@ -188,6 +188,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) | |
ImGuiIO& io = ImGui::GetIO(); | ||
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); | ||
|
||
// Initialize our loader | ||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) | ||
if (imgl3wInit() != 0) | ||
{ | ||
|
@@ -241,6 +242,11 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) | |
strcpy(bd->GlslVersionString, glsl_version); | ||
strcat(bd->GlslVersionString, "\n"); | ||
|
||
// Make an arbitrary GL call (we don't actually need the result) | ||
// IF YOU GET A CRASH HERE: it probably means the OpenGL function loader didn't do its job. Let us know! | ||
GLint current_texture; | ||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); | ||
|
||
// Detect extensions we support | ||
bd->HasClipOrigin = (bd->GlVersion >= 450); | ||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. | ||
@set OUT_DIR=Debug | ||
@set OUT_EXE=example_glfw_opengl3 | ||
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I..\libs\gl3w | ||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c | ||
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include | ||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp | ||
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib | ||
mkdir %OUT_DIR% | ||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
How is the IMGUI_IMPL_OPENGL_LOADER_CUSTOM meant to be used now that the line
is no longer present (removed in 459de65)?