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

Author Topic: Question  (Read 1811 times)

0 Members and 1 Guest are viewing this topic.

Spellbreaker

  • Newbie
  • *
  • Posts: 33
    • ICQ Messenger - 287156171
    • MSN Messenger - spellbreaker@live.de
    • Yahoo Instant Messenger - Spellbreaker1979
    • View Profile
    • http://www.apeironstudios.com
Question
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question
« Reply #1 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).
Laurent Gomila - SFML developer

Spellbreaker

  • Newbie
  • *
  • Posts: 33
    • ICQ Messenger - 287156171
    • MSN Messenger - spellbreaker@live.de
    • Yahoo Instant Messenger - Spellbreaker1979
    • View Profile
    • http://www.apeironstudios.com
Question
« Reply #2 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();

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Question
« Reply #3 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.
Laurent Gomila - SFML developer

Spellbreaker

  • Newbie
  • *
  • Posts: 33
    • ICQ Messenger - 287156171
    • MSN Messenger - spellbreaker@live.de
    • Yahoo Instant Messenger - Spellbreaker1979
    • View Profile
    • http://www.apeironstudios.com
Question
« Reply #4 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 :)