mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 21:39:54 +02:00
@ -8,10 +8,16 @@
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#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**)
|
||||
return 1;
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1); // Enable vsync
|
||||
gl3wInit();
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
GLenum err = gl3wInit();
|
||||
if (!err) {
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
GLenum err = glewInit();
|
||||
if (GLEW_OK != err) {
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
GLenum err = gladLoadGL();
|
||||
if (!err) {
|
||||
#endif
|
||||
fprintf(stderr, "Failed to initialize OpenGL\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 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
|
||||
ImGui::Checkbox("Another Window", &show_another_window);
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
@ -146,7 +164,7 @@ int main(int, char**)
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
Reference in New Issue
Block a user