-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Open
Labels
Description
Version/Branch of Dear ImGui:
Version "master", Branch: docking
Back-ends:
ImGui_ImplGlfw ImGui_ImplOpenGL3
Compiler, OS:
macOS
Full config/build information:
No response
Details:
Hi everyone, I'm trying to make the style of these two windows look the same.
I've changed a few style aspects, but what I just can't manage is to make the corners of the second window rounded.
What am I doing wrong?
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
#include <cstdio>
#include <cstdlib>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui/imgui.hpp>
static void glfwErrorCallback(int error, const char * description) {
fprintf(stderr, "GLFW error (%d): %s\n", error, description);
}
//****************************************************************************//
// main()
//****************************************************************************//
int main() {
// Init finestra
glfwSetErrorCallback(glfwErrorCallback);
if(!glfwInit()) return 1;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
GLFWwindow * gWindow = glfwCreateWindow(1280, 720, "Test", nullptr, nullptr);
if(!gWindow) { glfwTerminate(); return 2; }
glfwMakeContextCurrent(gWindow);
glfwSwapInterval(1);
if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cerr << "GLAD init failed\n"; return 3; }
// ImGui
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::GetIO().ConfigViewportsNoDecoration = true;
ImGui_ImplGlfw_InitForOpenGL(gWindow, true);
ImGui_ImplOpenGL3_Init("#version 330");
while(!glfwWindowShouldClose(gWindow)) {
glfwPollEvents();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGuiWindowFlags mainWinFlags =
ImGuiWindowFlags_NoDecoration
| ImGuiWindowFlags_NoNavFocus
| ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoBringToFrontOnFocus
| ImGuiWindowFlags_NoScrollWithMouse;
ImGuiViewport * viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos (viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
ImGui::Begin("MainWindow", NULL, mainWinFlags);
ImGui::End();
ImGuiWindowFlags secondWinFlags = ImGuiWindowFlags_NoCollapse;
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 20.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowTitleAlign, ImVec2(0.5f, 0.5f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 7.5f));
ImGui::PushStyleColor(ImGuiCol_ResizeGrip, ImVec4(0.f, 0.f, 0.f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImVec4(0.188f, 0.188f, 0.188f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_TitleBg, ImVec4(0.145f, 0.145f, 0.145f, 1.0f));
ImGui::Begin("SecondWindow", NULL, secondWinFlags);
ImGui::End();
ImGui::PopStyleColor(3);
ImGui::PopStyleVar(3);
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
GLFWwindow * backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
glfwSwapBuffers(gWindow);
}
// Shutdown
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(gWindow);
glfwTerminate();
return 0;
}