External window resize


#1

I use external window handles for rendering. Most things seems to work. Except resizing the window.
The only way I found to make it work somewhat is to call the bsf window resize function in my window resized callback. On Linux it kinda works but when dragging the window size it behaves really strangely, the window height increases when it shouldn’t. On windows the program freezes when resizing.

I looked but I didn’t find any kind of status notification functions for bs::RenderWindow. There are just functions that actually perform a resize (which I’m using) or fullscreen toggle. And no functions for just notifying the window that “hey, your size has changed”. So I need there to be new methods added to bs::RenderWindow for notifying it about size change etc.


#2

There is RenderWindow::onResize event (derived from RenderTarget. Would that do the job?


#3

That event seems to not resize the internal render things. When I skip the resize call and just have
BSFWindow->onResized(); the image becomes blurry when I resize the window. Leading me to believe that BSF does not react to that event in the way I need it to work.

Edit: this is my code:

    // BSFWindow->resize(width, height);

	BSFWindow->onResized();

#4

I found void RenderWindow::_notifyWindowEvent(WindowEventType type)
void::RenderWindow_windowMovedOrResized which may work for my use case. I didn’t have time to test them yet, but thought I’d post an update.


#5

@BearishSun I tried both this:

    BSFWindow->_notifyWindowEvent(bs::WindowEventType::Resized);

and this:

    BSFWindow->_windowMovedOrResized(); 

Neither of them correctly resized the rendered area of the window.


#6

Try listening on the onResized event and re-applying the render target to the Camera’s viewport. Doing that (or changing any other camera setting really) should force the renderer to rebuild its view.


#7

I tried this code (placed after that _notifyWindowEvent):

    pimpl->WorldCamera->getViewport()->setTarget(window->GetBSFWindow());

It doesn’t seem to work:

(this happens after resizing, the bottom left thing should cover the entire window, it is rendered by a RendererExtension)


#8

I’m guessing some internal window property doesn’t get its size updated, but I haven’t dealt with external window handles to know what would be the most appropriate way to resolve it, it found require more investigation.


#9

Should I open an issue on Github or something?


#10

Yeah feel free, I can’t guarantee when I’ll get around to it though. Will happily accept a PR that extends the functionality when dealing with external windows to handle this case.


#11