resizing irr's window, graphic's ratio will be changed!

Discussion about everything. New games, 3d math, development tips...
Post Reply
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

resizing irr's window, graphic's ratio will be changed!

Post by michael520 »

when I resize the window, the graphics ratio will be changed,too. Objects become longer or taller, which I don't want!

I try to drop and recreate the device, than the ratio would be correct.
But recreating device costs too much time and the window would twinkle a lot!

I wonder if there's any way to solve this problem?
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

I tried to account for this by using variables when stating the size of the window and irrlicht device. Although i was putting Irrlicht inside a win32 window to do so.
That was working fine as far as changing the window size and everything looking ok, however, it *really* screwed up the fps camera - you lost control of the camera and it would just move it self upward.
Here's a thread i started in the bug reports section that has a bit of code for the window resizing:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=10742

Feel free to try it out and see what happens for you. It won't work correctly, but maybe it can get you on your way (or maybe you can figure out the camera bug!)
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

I find one way:

Post by michael520 »

after resizing the window, just do the following:
GetClientRect(&rect);
driver->OnResize(irr::core::dimension2d<irr::s32>(rect.right, rect.bottom));
this will tell the driver to set the new window's size correctly!!
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

sorry, the way above still have problems: the model's width-height ratio is still incorrect when resizing window.
mandrav
Posts: 117
Joined: Sat Aug 27, 2005 8:29 pm
Contact:

Post by mandrav »

This is what I have in my OnSize() function:

Code: Select all

void wxIrrlicht::OnSize(wxSizeEvent& event)
{
    s32 w;
    s32 h;
    GetClientSize(&w, &h);

    dimension2d<s32> size(w, h);
    m_pDriver->OnResize(size);

    if (m_pCameraNode)
        m_pCameraNode->setAspectRatio((float)h / (float)w);
}
As you see, besides calling OnResize(), you must also call setAspectRatio() on the camera node...
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

Thanks, mandrav!! It works!!
ultramedia
Posts: 175
Joined: Wed Dec 20, 2006 12:04 pm

Post by ultramedia »

I found the w and h were around the wrong way...
but other than that, extremely useful, ta heaps
humorstar
Posts: 25
Joined: Sat Oct 04, 2008 3:50 am

Post by humorstar »

If I am only using GUI provided by irrlicht, not using wxWidget, MFC or other similar stuff, how can I capture this OnSize or OnResize event, so that I can set my camera setting?

Thank you,
mandrav wrote:This is what I have in my OnSize() function:

Code: Select all

void wxIrrlicht::OnSize(wxSizeEvent& event)
{
    s32 w;
    s32 h;
    GetClientSize(&w, &h);

    dimension2d<s32> size(w, h);
    m_pDriver->OnResize(size);

    if (m_pCameraNode)
        m_pCameraNode->setAspectRatio((float)h / (float)w);
}
As you see, besides calling OnResize(), you must also call setAspectRatio() on the camera node...
Post Reply