I new in Imgui, so i use the source to made my custom menu using dx11.
I get problem here that, even if i define a size width and height for the window not work.
sorry my bad english.
// Our state
bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
float ImGuiWidth = 100.f;
float ImGuiHight = 100.f;
float ImGuiWidth = 100.f;
float ImGuiHight = 100.f;
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
{
static float f = 0.0f;
static int counter = 0;
auto& style = ImGui::GetStyle();
bool placeholder_true = true;
// not work =/, kepp the defult size windows
ImGui::SetWindowSize(ImVec2((float)ImGuiWidth, (float)ImGuiHight));
ImGui::Begin("Hello, world!",0, ImGuiWindowFlags_NoResize); // Create a window called "Hello, world!" and append into it.
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::Checkbox("Another Window", &show_another_window);
}
Hi @Cesar1986BR
if you read prototype in ImGui.h:
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0);
// (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
In particular it says: call within Begin()/End()
Anyway use SetNextWindowSize() before Begin(): that's just what you need!
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0);
// set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
Just a little note:
Begin() needs to End() (at the end of the window commands/widgets)... and I don't see it before closed brace }
@BrutPitt thx
Closing this as solved. Thank you Michele for the help!
Most helpful comment
Hi @Cesar1986BR
if you read prototype in
ImGui.h:In particular it says: call within Begin()/End()
Anyway use
SetNextWindowSize()before Begin(): that's just what you need!Just a little note:
Begin() needs to End() (at the end of the window commands/widgets)... and I don't see it before closed brace
}