imgui docking

This commit is contained in:
det-fys 2024-09-22 11:07:58 +02:00
parent 1e08c45f0c
commit 2c6c38a964
2 changed files with 16 additions and 1 deletions

View File

@ -30,7 +30,7 @@ if(WIN32)
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.91.1 # Latest stable version
GIT_TAG v1.91.2-docking # Latest stable version
)
FetchContent_MakeAvailable(imgui)

View File

@ -23,11 +23,22 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
int main() {
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit()) {
std::cerr << "Failed to initialize GLFW" << std::endl;
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
glfwWindowHint(GLFW_VISIBLE, GL_TRUE);
glfwWindowHint(GLFW_MAXIMIZED, GL_TRUE);
glfwWindowHint(GLFW_DEPTH_BITS, 0);
glfwWindowHint(GLFW_STENCIL_BITS, 0);
// Create a windowed mode window and its OpenGL context
GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui + GLFW + GLAD Example", nullptr, nullptr);
if (!window) {
@ -50,6 +61,8 @@ int main() {
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); //(void)io;
// io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18);
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// Setup Dear ImGui style
ImGui::StyleColorsDark();
@ -69,6 +82,8 @@ int main() {
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::DockSpaceOverViewport();
// Create a simple ImGui window
{
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!"