Open KyleKrein opened 1 year ago
My initial guess here is that this is something related to DPI and that likely the mouse coordinates might not match up with window coordinates. I don't have a macos machine that I can test with, you could try looking at the mouse position sent to ImGui and compare it to the window size that is sent to ImGui and there will likely be some discrepancy.
the mouse coordinates might not match up with window coordinates
I've checked this, and the coordinates are correct. Do you have any other ideas?
Also I forgot to mention, that on start and if I move window, ImGui disappears or becomes a black square
That sounds pretty weird too, my guess is that some event that is called when the window moves is doing something weird. Can you check what events get triggered when you move the window?
Actually there're no events happening. Or at least on Move event in GameWindow.
So I managed to make ImGui use the whole window, not 1/4 part of it. But there's still an issue with window content disappearing when I move it out of the left up corner
That looks like an issue with scissor testing... something where the scissor area gets put too far out
It is happening the same to me, any update on this issue?
Thanks!
In my case, I just fixed it by modifying the scalefactor, line 36
at ImGuiController.cs . I just multiply it by 2.
Previous
...
private System.Numerics.Vector2 _scaleFactor = System.Numerics.Vector2.One;
...
After
...
private System.Numerics.Vector2 _scaleFactor = System.Numerics.Vector2.One * 2;
...
This seems to me like a DPS/Retina thing as the factor is 2. I'm guessing something about how OpenTK/GLFW handles width and height on retina displays differs from how it is handled on other types of displays.
Maybe it's possible to get the scale factor from GLFW directly?
@NogginBops, indeed. I just modified:
@ imGuiController.cs
.
.
.
/// <summary>
/// Constructs a new ImGuiController.
/// </summary>
public ImGuiController(int width, int height, float scaleFactorX=1, float scaleFactorY=1 )
{
_windowWidth = width;
_windowHeight = height;
_scaleFactor.X *= scaleFactorX;
_scaleFactor.Y *= scaleFactorY;
.
.
.
}
.
.
.
@ Window.cs
.
.
.
public class Window : GameWindow
{
ImGuiController _controller;
public Window() : base(GameWindowSettings.Default,
new NativeWindowSettings() {
Size = new Vector2i(1600, 900),
Flags = ContextFlags.ForwardCompatible
})
{ }
protected override void OnLoad()
{
base.OnLoad();
Title += ": OpenGL Version: " + GL.GetString(StringName.Version);
// Initialise the Scale Factor
float scaleFactorX = 0;
float scaleFactorY = 0;
// Get the Scale Factor of the Monitor
this.TryGetCurrentMonitorScale(out scaleFactorX, out scaleFactorY);
// Instanciate the ImGuiController with the right Scale Factor
_controller = new ImGuiController(ClientSize.X, ClientSize.Y, out_width, out_height);
}
.
.
.
}
Patch is working fine on MacOS. I have adjusted ImGUIController in order to have a sample working on MacOS/Win10/Linux : https://github.com/DigitalBox98/Dear-ImGui-OpenTK-Sample
if I try to run your code on Windows, everything works, but on Mac OS there's something wrong with position or scale (or both of them). As you can see on the screenshot, I moved cursor out of the window and only after this one of the ImGui buttons became blue.
Also if I try to move the ImGui demo window, it starts to disappear if it gets out of the left bottom 1/4 part of the window