Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dear Imgui
#5
Now one thing I have discovered is that my mouse handling systems do not work very well with ImGui, its not impossible to get them working but its a lot of effort and is quite imprecise and will require some trial and error to work out different settings in different resolutions. So I've had a look to see if I could get hold of the Linux Gui's mouse systems, more accuratly the X11 systems, and indeed thats possible
I'm sure there are equivilent ways to do this on Pi 1,2,3 and 3b but I've not looked into it yet, for now this is an X11 system and it also depends on the screen being full size. It should also allow for a variable screen res, but for now I've set SCRWIDTH and SCRHEIGHT to a fixed 1080p res.

Two things not clear here are win and x_display. Those come from the OpenGL set up code where an X11 window is set up, and I made them global to allow access here as I didn't want to pass graphic classes.

This gives much more accurate and totally effective access to the ImGui windows and menus, and is rather effective. I should also try to do a key input system that will let me press keys but for now mouse control is perfect.


Window window_returned; // we don't really care too much about this as we should only have 1 window

int root_x;
int root_y;
int win_x;
int win_y;
uint mask_return;
bool result = XQueryPointer(
x_display,
win,
&window_returned,
&window_returned,

&root_x,
&root_y,
&win_x,
&win_y,
&mask_return);

ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(SCRWIDTH, SCRHEIGHT);
io.DeltaTime = DT;
// we should also pass on mouse and key info into the IO here

io.MousePos = ImVec2(root_x, root_y);
io.MouseDown[0] = mask_return & (1 << 8); // left
io.MouseDown[1] = mask_return & (1 << 10); // right


and now ImGui knows where your mouse is, and when buttons are pressed...have fun
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply


Messages In This Thread
Dear Imgui - by Brian Beuken - 04-09-2019, 08:48 AM
RE: Dear Imgui - by Brian Beuken - 04-10-2019, 01:04 PM
RE: Dear Imgui - by Brian Beuken - 01-07-2020, 12:32 PM
RE: Dear Imgui - by Brian Beuken - 01-07-2020, 01:56 PM
RE: Dear Imgui - by Brian Beuken - 01-10-2020, 10:25 AM
RE: Dear Imgui - by jomoengineer - 01-19-2020, 05:05 AM
RE: Dear Imgui - by Brian Beuken - 02-02-2020, 12:29 AM
RE: Dear Imgui - by Brian Beuken - 11-28-2020, 06:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)