imgui-plot 项目使用教程
2024-08-16 17:26:36作者:廉皓灿Ida
1. 项目的目录结构及介绍
imgui-plot 项目的目录结构如下:
imgui-plot/
├── examples/
│ ├── example_glfw_opengl3/
│ └── example_sdl_opengl3/
├── implot/
│ ├── implot.cpp
│ ├── implot.h
│ └── implot_internal.h
├── LICENSE
├── README.md
└── CMakeLists.txt
目录介绍
- examples/: 包含示例代码,展示了如何使用 imgui-plot 库。
- example_glfw_opengl3/: 使用 GLFW 和 OpenGL3 的示例。
- example_sdl_opengl3/: 使用 SDL 和 OpenGL3 的示例。
- implot/: 包含 imgui-plot 的核心文件。
- implot.cpp: imgui-plot 的实现文件。
- implot.h: imgui-plot 的头文件。
- implot_internal.h: imgui-plot 的内部头文件。
- LICENSE: 项目的许可证文件。
- README.md: 项目的说明文档。
- CMakeLists.txt: CMake 配置文件,用于构建项目。
2. 项目的启动文件介绍
项目的启动文件位于 examples/ 目录下,具体为 example_glfw_opengl3/ 和 example_sdl_opengl3/ 目录中的 main.cpp 文件。
example_glfw_opengl3/main.cpp
#include "implot.h"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>
int main() {
// 初始化 GLFW
if (!glfwInit()) {
return -1;
}
// 创建窗口
GLFWwindow* window = glfwCreateWindow(1280, 720, "imgui-plot Example", nullptr, nullptr);
if (window == nullptr) {
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // 启用垂直同步
// 初始化 ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
ImGui::StyleColorsDark();
// 设置 ImGui 后端
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 130");
// 主循环
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
// 开始新帧
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// 绘制图表
if (ImPlot::BeginPlot("Example Plot")) {
ImPlot::PlotLine("Line", x_data, y_data, 1000);
ImPlot::EndPlot();
}
// 渲染
ImGui::Render();
int display_w, display_w;
glfwGetFramebufferSize(window, &display_w, &display_w);
glViewport(0, 0, display_w, display_w);
glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
// 清理
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImPlot::DestroyContext();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
example_sdl_opengl3/main.cpp
#include "implot.h
登录后查看全文
热门项目推荐
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust0172
cann-learning-hubCANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。Jupyter Notebook093
Step-3.7-FlashStep-3.7-Flash是一个拥有 1980 亿参数的稀疏混合专家(MoE)视觉语言模型,由 1960 亿参数的语言主干网络和 18 亿参数的视觉编码器组合而成,具备原生图像理解能力。Python00
BitCPM-CANN-8BBitCPM-CANN 是首个基于华为昇腾 NPU 原生构建的端到端 1.58 位(三值化)大语言模型训练系统。该系统将量化感知训练(QAT)集成到 Megatron-LM 框架中,并结合 MindSpeed 加速,覆盖了从自定义三值算子到基于昇腾 910B 的分布式并行训练的完整训练栈。Python00
MiniCPM5-1BMiniCPM5-1B,这是 MiniCPM5 系列的首款模型。它是一个专为端侧、本地部署和资源受限场景打造的 10 亿参数密集型 Transformer 模型,达到了 10 亿参数级开源模型的 SOTA 水平Jinja00
skillhubopenJiuwen 生态的 Skill 托管与分发开源方案,支持自建与可选 ClawHub 兼容。Python0239
最新内容推荐
项目优选
收起
deepin linux kernel
C
32
16
暂无描述
Dockerfile
749
4.86 K
Claude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed.
Get Started
Rust
1.55 K
172
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
835
1.83 K
Ascend Extension for PyTorch
Python
685
828
CANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。
Jupyter Notebook
207
93
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
450
417
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
1.02 K
1.04 K
暂无简介
Dart
997
258
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
641
1.26 K