60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
#pragma once
|
|
#include <Windows.h>
|
|
|
|
#include <functional>
|
|
|
|
#define GLFW_INCLUDE_NONE
|
|
#define GLFW_INCLUDE_VULKAN
|
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include "imgui.h"
|
|
#include "remixicon.h"
|
|
|
|
#define IMGUI_REDRAW_COUNT 3
|
|
|
|
class DrawData {
|
|
public:
|
|
GLFWwindow* window = nullptr;
|
|
HWND window_handle = nullptr;
|
|
ImVec4 clear_color = {};
|
|
ImVec2 window_size = {};
|
|
float frameTimeSetup = 0.f;
|
|
float frameTimeDraw = 0.f;
|
|
float frameTimeRender = 0.f;
|
|
float frameTimeDisplay = 0.f;
|
|
};
|
|
|
|
class ImGuiCallbacks {
|
|
public:
|
|
std::function<void(DrawData&)> initFunc = nullptr;
|
|
std::function<void(DrawData&)> drawFunc = nullptr;
|
|
std::function<void(DrawData&)> cleanupFunc = nullptr;
|
|
};
|
|
|
|
class PerfTimer {
|
|
private:
|
|
LARGE_INTEGER start;
|
|
LARGE_INTEGER end;
|
|
LARGE_INTEGER freq;
|
|
|
|
public:
|
|
LONGLONG resultTicks;
|
|
float resultSeconds;
|
|
|
|
public:
|
|
void Start() {
|
|
QueryPerformanceFrequency(&freq);
|
|
QueryPerformanceCounter(&start);
|
|
}
|
|
void End() {
|
|
QueryPerformanceCounter(&end);
|
|
resultTicks = end.QuadPart - start.QuadPart;
|
|
resultSeconds = static_cast<float>(resultTicks * 1000) / freq.QuadPart;
|
|
}
|
|
};
|
|
|
|
int startImgui(ImGuiCallbacks& callbacks, const char* title, int windowWidth, int windowHeight);
|
|
|
|
ImVec2 getWindowSize(GLFWwindow* window);
|