1
Graphics / Using SFML in a resizable QT-Widget
« on: December 27, 2011, 08:24:27 pm »
Okay, I discovered something else. I can put the same code I had in the main message loop of the standalone app, into the OnUpdate() function of the widget, like this:
Maybe this is bad practice, I don't know. But it works ok so far and I like it because I can use almost the exact same code when I detach this from the Qt framework.
If anybody has any reason why this may be bad please let me know
Code: [Select]
void MyCanvas::OnUpdate()
{
sf::Event event;
while ( PollEvent(event) )
{
if ( event.Type == sf::Event::Resized ) {
glViewport(0, 0, event.Size.Width, event.Size.Height);
SetView( sf::View( sf::FloatRect(0,0,m_GetWidth,m_GetHeight) ) );
}
// ... check mouse and keys etc
}
}
Maybe this is bad practice, I don't know. But it works ok so far and I like it because I can use almost the exact same code when I detach this from the Qt framework.
If anybody has any reason why this may be bad please let me know