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

Author Topic: SFML+wxWidgets-Call to setSize() not reflected in subsequent call to getSize()?  (Read 1292 times)

0 Members and 1 Guest are viewing this topic.

mbrown3391

  • Newbie
  • *
  • Posts: 1
    • View Profile
I created a derived class, MyCanvas, from the wxSFMLCanvas class found here http://sfml-dev.org/tutorials/1.6/graphics-wxwidgets.php. Now when I call MyCanvas::setSize(), the rendering area appears to resize as expected, however a subsequent call to MyCanvas::getSize() returns the original size. As a result, graphics do not render properly.

Here is a condensed version of the class:
Quote

class MyCanvas : public wxSFMLCanvas
{
public:
   Canvas(wxWindow* Parent, int Id, const wxPoint& Position, long Style)
      : wxSFMLCanvas(Parent, Id, Position, wxSize(500, 500), Style)
   {
      sf::Vector2u currentSize = this->getSize(); //currentSize = (496,496)
   }

   ~Canvas(void) {}

private:
   sf::View view;

   void OnUpdate(void) override
   {
      view.reset(sf::FloatRect(0,0,250,250));
      this->setSize(Vector2u(250, 250));
      this->setView(view);

      sf::Vector2u currentSize = this->getSize(); //currentSize = (496,496)
   }
}

As you can see, the RenderWindow thinks that it is at the original size, even though it now displays at the new size. I'm not sure what I am doing wrong here. Any ideas? I am using SFML 2.1 on 64-bit Windows 8.