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/e4ccf32534eb3d25a1eaFirst, when the app first launches, it looks like the RenderWindow doesn't quite fill it's wxWindow, seen here:
http://i.imgur.com/ovCt6l4h.pngSecondly, sometimes when resizing the AppFrame, again, the RenderWindow appears not to fill the full window:
http://i.imgur.com/8qYvWLVh.pngOf 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