Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Resizing (Qt) does not work  (Read 4271 times)

0 Members and 1 Guest are viewing this topic.

sNIk

  • Newbie
  • *
  • Posts: 10
    • View Profile
Resizing (Qt) does not work
« on: October 27, 2011, 03:45:32 pm »
hi,

i have troubles resizing the context inside my Qt-window. at first the relevant code-snippet which does the resizing: (ignore the LOG(...) stuff, thats just for testing)

Code: [Select]

void SFMLWidget::resizeEvent(QResizeEvent *e)
{
    LOG("ResizeEvent -> Qt: " << e->size().width() << "x" << e->size().height() );

    SetSize(e->size().width(), e->size().height());

    LOG("ResizeEvent -> SFML: " << GetWidth() << "x" << GetHeight() );
}


SetSize(...) does not have any effect. didnt try that on windows though. the only thing that works, is recreating the entire context, what is a bad idea in this case since the resizeEvent is fired all the time while resizing. native sfml-window works perfectly.

i've uploaded some images to illustrate the problem. the green corners are the window-cornerns, the black area is the window itself. changing the clear-color affects the wohle black area. thats just weird to me. :)



OS: Gentoo Linux
Kernel: 2.6.39

GPU: Radeon HD 3650
CPU: Intel(R) Core(TM)2 Duo CPU     T9400  @ 2.53GHz

uGhster

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Resizing (Qt) does not work
« Reply #1 on: April 12, 2012, 12:17:54 pm »
Hi,

Seems like re-creating the context/window seems to be the only solution for this. I have the same problem with running SFML-context in a wxWidget-Panel. But there seems to be a bug...

When I call upon sf::Window::Create( getSystemHandle() )  in the resizeHandler, I get this funny graphical artifact. (see attachment )


...where it seems like all textures are random-memory.
Please, need help figuring out a solution for this. Do I have to reload every texture?

Btw, using SFML2.0/ArchLinux/ATI

« Last Edit: April 12, 2012, 12:37:12 pm by uGhster »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resizing (Qt) does not work
« Reply #2 on: April 12, 2012, 12:23:02 pm »
Quote
Do I have to reload every texture?
No, SFML always keeps a valid context so that resources are never lost.

Unfortunately I can't test/help with wxWidgets, but it could be a viewport problem.
Laurent Gomila - SFML developer

uGhster

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Resizing (Qt) does not work
« Reply #3 on: April 12, 2012, 11:08:23 pm »
Viewport of the sf::Renderwindow?

uGhster

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Resizing (Qt) does not work
« Reply #4 on: April 15, 2012, 09:36:21 am »
Thanks,

I followed your lead about the viewport. And It is possible, atleast in wxWidget, to resize to PanelSize(wxWidget) by updating both the view and viewport, to get rid of the clipping that is restricted to initial size of widget. So there is no need to call Create() on resize-handler, which is inefficient and fails for wxWidgets. Perhaps this is also true for Qt ?

Now when I resize the window / panel, I maintain coord(0,0) in top/left corner and maintain pixelsize (no streching).

« Last Edit: April 15, 2012, 09:38:42 am by uGhster »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resizing (Qt) does not work
« Reply #5 on: April 15, 2012, 10:06:42 am »
How do you update the viewport?
Laurent Gomila - SFML developer

uGhster

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Resizing (Qt) does not work
« Reply #6 on: April 15, 2012, 10:17:26 am »
   
Code: [Select]
    sf::View view = sf::View(sf::FloatRect(0,0,w,h));
    float a = h/(initialHeight*2);
    view.SetViewport(sf::FloatRect(0,(-a+1),w/initialWidth,h/initialHeight));
    sf::RenderWindow::SetView(view);

Where initialSizes are the initial-size of the wxPanel, as specified in ctor.
Please, give feedback to this solution, since the "a" was created empirically. Works like a charm though.  ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resizing (Qt) does not work
« Reply #7 on: April 15, 2012, 10:54:32 am »
Well, it is not normal. A viewport of [0, 0, 1, 1] should always map to the entire render target :-\
Laurent Gomila - SFML developer

 

anything