You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
964 B

#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
int main()
{
// 初始化窗口和渲染上下文(例如GLFW+OpenGL)
glfwInit();
GLFWwindow *window = glfwCreateWindow(1280, 720, "ImGui Demo", NULL, NULL);
// 初始化ImGui
ImGui::CreateContext();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 130");
while (!glfwWindowShouldClose(window))
{
// 开始新帧
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// 创建UI
ImGui::Begin("Demo Window");
ImGui::Text("Hello, world!");
if (ImGui::Button("Save"))
{
// 按钮点击处理
}
ImGui::End();
// 渲染
ImGui::Render();
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
}