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

Author Topic: Resizing a RenderWindow embedded in wxWidgets app, best practices?  (Read 2005 times)

0 Members and 1 Guest are viewing this topic.

nelsk

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Hi,

I'm working on integrating SFML 2.3.1 (release .so libs) into a wxWidgets 3.0 app, which I've successfully done. Now I'm trying to resize the RenderWindow-based wxControl on AppFrame resize events so that I can maintain a margin around my SFML canvas. I almost have it working, but I'm having some minor issues. I've boiled it down to a demo, here's the full source:

https://gist.github.com/eriknelson/e4ccf32534eb3d25a1ea

First, when the app first launches, it looks like the RenderWindow doesn't quite fill it's wxWindow, seen here:

http://i.imgur.com/ovCt6l4h.png

Secondly, sometimes when resizing the AppFrame, again, the RenderWindow appears not to fill the full window:

http://i.imgur.com/8qYvWLVh.png

Of particular interest is Canvas::onResize at line 87. I had originally tried simply setting the inherited RenderWindow size with
this->setSize(...)
, but that didn't work at all. Then I tried recreating the RenderWindow, which is where I'm at now. I'm almost positive what I'm doing is not advised since it's recreating the RenderWindow *on each resize event*. That seems terribly inefficient to me, and obviously does not perform well.

A couple specific questions:
- What is the right way to resize the RenderWindow on a wxWindow resize event? Should its size be changed, or does it, in fact, need to be recreated?
- If I'm on the right track, why the strange behavior seen in the screenshots?

I'm also open to any general critique of my code, I'd like to set a solid foundation and do this the right way.

Additional info:
OS: Arch Linux
Compiler: clang++ 3.6.2
Build tool: cmake 3.2.3
« Last Edit: July 20, 2015, 05:26:17 am by nelsk »

victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Resizing a RenderWindow embedded in wxWidgets app, best practices?
« Reply #1 on: July 19, 2015, 09:25:36 pm »
SFML 2.3 has problems with GTK+ (wxWidgets uses GTK+ under Linux). Especially when trying to resize the render window. See http://en.sfml-dev.org/forums/index.php?topic=18536.0

nelsk

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Resizing a RenderWindow embedded in wxWidgets app, best practices?
« Reply #2 on: July 19, 2015, 09:29:12 pm »
Interesting, thanks for the tip. I'll downgrade to 2.2 and see if I get some different results.

EDIT: I downgraded to 2.2 and patched my original code with the following:

https://gist.github.com/eriknelson/e4ccf32534eb3d25a1ea#file-convert_to_2_2-patch

Looks like this works by resizing both the host wxWindow and the sf::RenderWindow as I originally tried, which must be a better approach than repeatedly recreating the RenderWindow. Is this known to the SFML devs and a confirmed 2.3 issue?
« Last Edit: July 20, 2015, 02:51:39 am by nelsk »

 

anything