getScreenSize() bug (Win)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
sawada
Posts: 3
Joined: Thu Mar 20, 2014 4:08 pm

getScreenSize() bug (Win)

Post by sawada »

I've found a bug.

getScreenSize() is expected to return a value of a window's client area.
But, Only when using the external window , getScreenSize() is not that.

because GetWindowRect() is used.
GetClientRect() is correctly.

irrlicht-1.8.1/source/Irrlicht/CIrrDeviceWin32.cpp
line1010-

Code: Select all

 
    else if (CreationParams.WindowId)
    {
        // attach external window
        HWnd = static_cast<HWND>(CreationParams.WindowId);
        RECT r;
        GetWindowRect(HWnd, &r);
        CreationParams.WindowSize.Width = r.right - r.left;
        CreationParams.WindowSize.Height = r.bottom - r.top;
        CreationParams.Fullscreen = false;
        ExternalWindow = true;
    }
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: getScreenSize() bug (Win)

Post by CuteAlien »

Yeah - that looks wrong on first view. Thanks sawada, I'll check it next time I'm working on Windows (I'm a little surprised it doesn't cause troubles already, so I will have to write some test for it first before changing that).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: getScreenSize() bug (Win)

Post by hybrid »

Well, you usually use some frame or render pane inside the actual window as the WindowId given here. That's why you usually don't have to bother with those different sizes. At least that's what our examples do.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: getScreenSize() bug (Win)

Post by thanhle »

Yup, when render to a window or a control, client rectangle is the actual target.
This was the issue I have before, as the mouse position wasn't correct when I do collision test on multiple windows (> 4). But as I fixed it without doing anything to irrlicht for future compatibility.

---Just a side note
If you have MDI render child windows. You might also want to update your mouse referenceRect relative to each window when you move it.

Point p = this->PointToScreen(this->ClientRectangle.Location); //Sorry this was .net for the position of the client window.
core::rect<s32> rec = core::rect<s32>(p.X, p.Y, p.X + this->ClientRectangle.Width, p.Y + this->ClientRectangle.Height);
device->getCursorControl()->setReferenceRect(&rec);
Also reset aspect ratio and call resize when ever you resize your window.
driver->OnResize(newsize);
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: getScreenSize() bug (Win)

Post by CuteAlien »

@hybrid: So... this needs to be fixed or not?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: getScreenSize() bug (Win)

Post by hybrid »

I always thought that you need some extra pane or so to render to and never used mouse controls on such things. But if there's some offset in certain situations, we probably have to fix this. Maybe someone can set up an example where the offset occurs? Can we simplify example 14?
Post Reply