Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../../include/glad/glad.h"
- #include "../../include/imgui/imgui.h"
- #include "../../include/imgui/impl/imgui_impl_opengl3.h"
- #include "../../include/imgui/impl/imgui_impl_glfw.h"
- #include <GLFW/glfw3.h>
- #include <iostream>
- void fbuffer(GLFWwindow *window, int width, int height);
- void processInput(GLFWwindow *window);
- int main(int argc, char const *argv[])
- {
- glfwInit();
- GLFWwindow *window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
- glfwMakeContextCurrent(window);
- glfwSetFramebufferSizeCallback(window, fbuffer);
- bool err = gladLoadGL() == 0;
- IMGUI_CHECKVERSION();
- ImGui::CreateContext();
- ImGuiIO &io = ImGui::GetIO();
- (void)io;
- io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
- ImGui::StyleColorsDark();
- const char *glsl_version = "#version 130";
- ImGui_ImplGlfw_InitForOpenGL(window, true);
- ImGui_ImplOpenGL3_Init(glsl_version);
- bool showDemo = true;
- ImVec4 bg = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
- while (!glfwWindowShouldClose(window))
- {
- processInput(window);
- glfwPollEvents();
- //Start ImGui
- ImGui_ImplOpenGL3_NewFrame();
- ImGui_ImplGlfw_NewFrame();
- ImGui::NewFrame();
- if (showDemo)
- {
- ImGui::ShowDemoWindow(&showDemo);
- }
- //Render
- ImGui::Render();
- glClearColor(bg.x, bg.y, bg.z, bg.w);
- glClear(GL_COLOR_BUFFER_BIT);
- ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
- glfwSwapBuffers(window);
- }
- ImGui_ImplOpenGL3_Shutdown();
- ImGui_ImplGlfw_Shutdown();
- ImGui::DestroyContext();
- glfwTerminate();
- return 0;
- }
- void fbuffer(GLFWwindow *window, int width, int height)
- {
- glViewport(0, 0, width, height);
- }
- void processInput(GLFWwindow *window)
- {
- if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
- glfwSetWindowShouldClose(window, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement