-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImgui-path-viewer.cpp
More file actions
98 lines (77 loc) · 2.5 KB
/
Imgui-path-viewer.cpp
File metadata and controls
98 lines (77 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#define GLFW_EXPOSE_NATIVE_WIN32
#include "GLFW/glfw3.h"
#include "GLFW/glfw3native.h"
#include <windows.h>
#include "resource.h"
#include <iostream>
#include "MyUI.h"
// Main code
// Main Function
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// GLFW initialisieren
if (!glfwInit())
{
std::cerr << "Fehler: GLFW konnte nicht initialisiert werden!\n";
return -1;
}
// OpenGL Version setzen (3.0+ für ImGui)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
// Fenster erzeugen
GLFWwindow* window = glfwCreateWindow(1280, 720, "WINDOWS PATH VIEWER", nullptr, nullptr);
if (window == nullptr)
{
std::cerr << "Fehler: Fenster konnte nicht erstellt werden!\n";
glfwTerminate();
return -1;
}
// Nach dem Fenster erstellen:
HWND hwnd = glfwGetWin32Window(window); // Nur unter Windows verfügbar
HICON hIcon = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_APP_ICON));
if (hIcon)
{
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // V-Sync aktivieren
// ImGui Context erzeugen
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = nullptr; // <- deaktiviert imgui.ini komplett
// Style setzen
ImGui::StyleColorsDark();
// ImGui Backends initialisieren
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 130");
// Main loop
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// UI rendern
RenderPathViewer();
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
// Aufräumen
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}