56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
|
|
#include "imgui.h"
|
||
|
|
#include "backends/imgui_impl_glfw.h"
|
||
|
|
#include "backends/imgui_impl_opengl3.h"
|
||
|
|
#include <GLFW/glfw3.h>
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
if (!glfwInit()) return -1;
|
||
|
|
|
||
|
|
GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui Example no?", NULL,NULL);
|
||
|
|
if (!window) return -1;
|
||
|
|
|
||
|
|
glfwMakeContextCurrent(window);
|
||
|
|
glfwSwapInterval(1);
|
||
|
|
|
||
|
|
IMGUI_CHECKVERSION();
|
||
|
|
ImGui::CreateContext();
|
||
|
|
|
||
|
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||
|
|
|
||
|
|
ImGui::StyleColorsDark();
|
||
|
|
|
||
|
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||
|
|
ImGui_ImplOpenGL3_Init("#version 130");
|
||
|
|
|
||
|
|
while (!glfwWindowShouldClose(window)) {
|
||
|
|
glfwPollEvents();
|
||
|
|
|
||
|
|
ImGui_ImplOpenGL3_NewFrame();
|
||
|
|
ImGui_ImplGlfw_NewFrame();
|
||
|
|
ImGui::NewFrame();
|
||
|
|
|
||
|
|
ImGui::Begin("Hello, ImGui!");
|
||
|
|
ImGui::Text("This is a simple ImGui window.");
|
||
|
|
ImGui::Button("BUTTON!", ImVec2(80,20));
|
||
|
|
ImGui::End();
|
||
|
|
|
||
|
|
ImGui::Render();
|
||
|
|
int display_w, display_h;
|
||
|
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||
|
|
glViewport(0, 0, display_w, display_h);
|
||
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
||
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||
|
|
|
||
|
|
glfwSwapBuffers(window);
|
||
|
|
}
|
||
|
|
|
||
|
|
ImGui_ImplOpenGL3_Shutdown();
|
||
|
|
ImGui_ImplGlfw_Shutdown();
|
||
|
|
ImGui::DestroyContext();
|
||
|
|
|
||
|
|
glfwDestroyWindow(window);
|
||
|
|
glfwTerminate();
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|