SFML community forums

Help => Window => Topic started by: Spellbreaker on August 19, 2010, 11:17:22 pm

Title: Question
Post by: Spellbreaker on August 19, 2010, 11:17:22 pm
Hey there!

I have a question about SetSize: Does it only "strech" the window, or does it really create a new render region?

I am developing a little game, and there are left-right scrolling levels, and up/down scrolling, so I have to change the window from 407x594 to 594x407 while the game is running.

Is that done with SetSize() ?


Sincerly,

Spellbreaker.
Title: Question
Post by: Laurent on August 19, 2010, 11:33:22 pm
SetSize changes the size of the window. What is displayed inside has nothing to do with that, it is controlled by the current view (see sf::View).
Title: Question
Post by: Spellbreaker on August 20, 2010, 09:04:17 am
Hi again,

now, I am using the following code to "reset" the Main Window, but after that all draw commands do not seem to work :| The screen keeps beeing white. When I cut that code out, drawing / refreshing works fine.


Code: [Select]
                   
sf::View tmpView = app.GetView();
sf::FloatRect tmpRect;
sf::VideoMode vMode;
vMode = vMode.GetDesktopMode();
sf::Uint32 posL = (vMode.Width/2) - (width/2);
sf::Uint32 posT = (vMode.Height/2) - (height/2);
tmpRect.Top = 0;
tmpRect.Bottom = height;
tmpRect.Left = 0;
tmpRect.Right = width;
tmpView.SetFromRect(tmpRect);
app.SetView(tmpView);
app.SetSize(width, height);
app.SetPosition(posL, posT);
app.Clear(sf::Color(255,255,255));
app.Display();
Title: Question
Post by: Laurent on August 20, 2010, 09:07:46 am
Quote
app.SetView(tmpView);

Be careful, the view must remain alive as long as it is used, the window stores a pointer to it, not a copy.
Title: Question
Post by: Spellbreaker on August 20, 2010, 09:11:53 am
Thanks, that was my problem :) So i simply added the view as a class member, now I can reset the window without problems :)