Mouse coordinates shifted in GUI

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Mouse coordinates shifted in GUI

Post by greenya »

I have noticed that Y-coordinate of mouse is shifted ( coordinates that receive IrrLicht engine from the OS ).

I creating a simple dialog box and to close it i have to click on OK button lower of its rectangle by 10-15 pixels. The same thing with moving of the window -- i can move it by clicking on the bottom edge +10 pixels down.

All GUI elements shows OK, but respond on mouse with shifted coordinates.
IrrLicht's "UserInterface" example works just OK.

Besides to select node i have to use "+15" pixels; here is my select-node code:

Code: Select all

ISceneNode* selnode = Game.SceneCollision->getSceneNodeFromScreenCoordinatesBB(
    position2d<s32>(
        Game.Device->getCursorControl()->getPosition().X,
        Game.Device->getCursorControl()->getPosition().Y+15
    )
);
One more thing: this artifact is present only in windowed mode, so if i running in full screen -- all works just fine.

Does anybody know what it could be ?
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

read you code again

Post by harukiblue »

I think it may just be that you are adding 15 to the y axis

Code: Select all

Game.Device->getCursorControl()->getPosition().Y+15 
try this:

Code: Select all

Game.Device->getCursorControl()->getPosition().Y
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Re: Mouse coordinates shifted in GUI

Post by sio2 »

greenya wrote: One more thing: this artifact is present only in windowed mode, so if i running in full screen -- all works just fine.

Does anybody know what it could be ?
Sounds suspiciously like the height of the Windows caption bar - which you don't get fullscreen. Perhaps a bug? Needs some investigation...
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

i just checked all again. in fullscreen i have the same problem. so it is not depends on windowed/fullscreen mode.

2harukiblue
no.
the point is that if i use "+15" --- it pick correctly; if i will write without "+15" ( as it must be ) it will get object on nearly 10-15 pixels down.

also the point is that i can solve problem with picking objects ( by "+15" value ), but i cannot solve the problem with GUI -- IrrLicht engine doesn't allow me to correct mouse-coordinates-values ( -- that is normal of cause, because GUI is fully automated ), BUT this problem really disappointing me :(
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Two bugs that spring to mind-
1) are you setting a viewport before drawing the GUI?
I've got a note here reminding me to investigate GUI picking when a viewport is set, but haven't looked into it yet. Try setting your viewport to the full screen when you draw the GUI.
2) does the operating system resize the window because the screen isn't big enough? this causes mouse picking to get messed up until the window is resized again. this bug happens in both the windows and linux devices, and probably the mac one too
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

I had to make changes to make to cursor position correct when resizing and the window is a child of another window. In my case a child control on a dialog in MFC.
If you want to look at or use my files here they are.
http://www.tronacom.com/downloads/CIrrDeviceWin32.h
http://www.tronacom.com/downloads/CIrrDeviceWin32.cpp

BTW If you can afford or get your hands on ExamDiff Pro it makes viewing and editing differences in code much easier than other merge tools I have used. ( No I am not a salesman or get a commision I just like the tool )
cvf
Posts: 7
Joined: Wed May 16, 2007 12:39 pm

Post by cvf »

I have the same problem in my window:

Image Image
Image Image

I have checked the mouse coordinates I get, and the size of the view with:

Code: Select all

GetWindowRect
getViewPort
getScreenSize
but all seems to be OK, and the size of the view is the same with the 3 functions above...

The offset seems to change when I move the camera and the position of the mouse... This doesn't happen in all cases, before moving the camera all the nodes work perfectly in all zones of the screen. This seems to happen only after moving the camera...

Your code at:
http://www.tronacom.com/downloads/CIrrDeviceWin32.h
http://www.tronacom.com/downloads/CIrrDeviceWin32.cpp
doesn't solve the problem...

Any ideas? Thanks in advance,

Hugo
cvf
Posts: 7
Joined: Wed May 16, 2007 12:39 pm

Post by cvf »

I have found the solution to this problem. I posted it at:
http://irrlicht.sourceforge.net/phpBB2/ ... 895#117895

The problem is the line: cam->setFarValue(10000000.0f);
Post Reply