#include<GL/gl3w.h> // This example is using gl3w to access OpenGL functions. You may use another OpenGL loader/header such as: glew, glext, glad, glLoadGen, etc.
//#include <glew.h>
//#include <glext.h>
//#include <glad/glad.h>
// This example is using gl3w to access OpenGL functions. You may use another OpenGL loader/header such as: glew, glext, glad, glLoadGen, etc.
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
#include<GL/gl3w.h>
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
#include<GL/glew.h>
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#include<glad/glad.h>
#else
#pragma error("Cannot use custom loader for example application.")
#endif
#include<GLFW/glfw3.h> // Include glfw3.h after our OpenGL definitions
@ -50,7 +56,19 @@ int main(int, char**)
return1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);// Enable vsync
gl3wInit();
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
GLenumerr=gl3wInit();
if(!err){
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
GLenumerr=glewInit();
if(GLEW_OK!=err){
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
GLenumerr=gladLoadGL();
if(!err){
#endif
fprintf(stderr,"Failed to initialize OpenGL\n");
return1;
}
// Setup Dear ImGui binding
IMGUI_CHECKVERSION();
@ -67,8 +85,8 @@ int main(int, char**)
//ImGui::StyleColorsClassic();
// Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Read 'misc/fonts/README.txt' for more instructions and details.
@ -115,7 +133,7 @@ int main(int, char**)
ImGui::Checkbox("Demo Window",&show_demo_window);// Edit bools storing our window open/close state
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
glBindSampler(0,0);// We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
#endif
// Recreate the VAO every time
// Recreate the VAO every time
// (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)