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

Author Topic: Why doesn't my fullscreen window display?  (Read 14365 times)

0 Members and 4 Guests are viewing this topic.

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #15 on: September 06, 2012, 12:17:08 am »
I discovered some things about SFML's fullscreen command via experimentation.

CONFIGURATION AND CODE INFO:
------------------------------------------
Tower PC's monitor = 1680 x 1050 native resolution.  Win7's resolution set to that.
Laptop's screen .... =  1280 x 800 native resolution.  Vista's resolution set to that.

SFML statement:
App.create(sf::VideoMode(1440, 900, 32), "CRAPS", sf::Style::Fullscreen);


PROGRAM EXECUTION:
----------------------------
Tower PC:
=GOOD= Loading a 1440 x 900 image, the image is expanded to 1680 x 1050 and fits perfectly on the fullscreen.
= BAD = Loading a 1024 x 768 image, the image is NOT expanded and remains at 1024 x 768 on screen.
............. Why doesn't the image get expanded to 1200 x 900 to fill the screen vertically with black bars on the sides?

Laptop:
= BAD = Loading a 1440 x 900 image, the image displays full screen but the image size remains at 1440 x 900.  Therefore the right and bottom sides of the image are cut off, since the laptop's screen size is smaller than the image size.
............. IOW, the larger image is not resized down to fit the smaller screen when using the Fullscreen command.

= BAD = Loading a 1024 x 768 image, the image is NOT expanded and remains at 1024 x 768 on screen.
............. Same symptom as on the tower's monitor.


CONCLUSION:
-----------------
I don't see how it's possible to use SFML's "Fullscreen" command to resize one image to fit different sizes and aspect ratios of screens.  Am I doing something wrong?  If you know why, please let me know.

Thanks,
Raptor
« Last Edit: September 06, 2012, 04:08:06 am by Raptor88 »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #16 on: September 06, 2012, 12:21:03 am »
What do you mean by using fullscreen command?!
Also, show us the example you used and how were you resizing the image.
Just saying
App.create(sf::VideoMode(1440, 900, 32), "CRAPS", sf::Style::Fullscreen);
simply won't do.
TBH I don't know what you did but nothing will ever resize automagically on itself, ever.
« Last Edit: September 06, 2012, 12:38:01 am by FRex »
Back to C++ gamedev with SFML in May 2023

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #17 on: September 06, 2012, 01:52:17 am »
What do you mean by using fullscreen command?!
Also, show us the example you used and how were you resizing the image.
Just saying
// Main.cpp

App.create(sf::VideoMode(1440, 900, 32), "CRAPS", sf::Style::Fullscreen);
simply won't do.
TBH I don't know what you did but nothing will ever resize automagically on itself, ever.

Maybe I should have said "Fullscreen Class" instead of Fullscreen command?
Here's the code I'm using:
int _tmain(int argc, _TCHAR* argv[])
{
        int SCREEN_WIDTH = 1440;
        int SCREEN_HEIGHT = 900;

        sf::RenderWindow App;

        App.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "CRAPS", sf::Style::Fullscreen);
        App.setPosition(sf::Vector2i(0, 0));   //Set topleft corner of window to 0, 0.
 

// In MainMenu.cpp

MainMenu::eMenuResult MainMenu::show (sf::RenderWindow &App)
{
        sf::Texture image;

        if (image.loadFromFile ("Images/Table1440x900.png") != true)
        {
                return EXIT;    // EXIT is not a valid return value.  <<<<< fix this later >>>>>
        }

        sf::Sprite sprite (image);
        App.draw (sprite);
        App.display ();
 

I replace "Images/Table1440x900.png" with "Images/Menu1024x768.png" when I try the 1024x768 image size.

Hope this is the info you asked for,
Raptor

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #18 on: September 06, 2012, 01:58:24 am »
I guess you meant EXIT_FAILURE which is just a macro for 1 anyway.
Do
sprite.setScale(App.getSize().x/image.getSize().x,App.getSize().y/image.getSize().y);  
and see if it makes your images of different sizes strech to fill your window and your requirements.
Back to C++ gamedev with SFML in May 2023

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #19 on: September 06, 2012, 04:11:21 am »
Do
sprite.setScale(App.getSize().x/image.getSize().x,App.getSize().y/image.getSize().y);  
and see if it makes your images of different sizes strech to fill your window and your requirements.

Hi FRex,

I really appreciate your taking the time to help me out.  I'll learn what the code you posted does and try using it.  Will post my results.

Thanks,
Raptor

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #20 on: September 06, 2012, 12:28:03 pm »
Hi FRex,

I really appreciate your taking the time to help me out.  I'll learn what the code you posted does and try using it.  Will post my results.

FRex,

I inserted your code but nothing happened.  The "Menu1024x768.png" image was still displayed as 1024x768 on the Fullscreen display.  I found that (float) has to be inserted in the statement and then it works.

sprite.setScale((float)App.getSize().x/(float)image.getSize().x, (float)App.getSize().y/(float)image.getSize().y);

The quality of the image is degraded when the image is scaled larger.  Also, the aspect ratio of the image is changed depending on the aspect ratio of the user's screen.

I'll play with setScale somemore.  Thanks for letting me know how to use it.
Raptor

« Last Edit: September 06, 2012, 12:30:05 pm by Raptor88 »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #21 on: September 06, 2012, 01:05:37 pm »
Yes, the (float) should be there, my mistake.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #22 on: September 06, 2012, 02:15:30 pm »
Yes, the (float) should be there, my mistake.
Btw it's imho better to use the 'new' C++ casting functionalities static_cast<type>(var) instead of the old C-ish ones (type)var. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #23 on: September 06, 2012, 02:41:51 pm »
Yes, definitely. New style casts make searches quicker and your intentions clear to compiler. I never use c-style casts or function style casts in code that is going to stay(i.e. not quick & dirty temporary test line).
« Last Edit: September 06, 2012, 07:09:23 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #24 on: September 06, 2012, 08:49:43 pm »
Btw it's imho better to use the 'new' C++ casting functionalities static_cast<type>(var) instead of the old C-ish ones (type)var. ;)

Could you post the setScale statement using the new C++ casting functionality you referred to?

Thanks,
Raptor

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #25 on: September 06, 2012, 09:01:02 pm »
I also thought that using fullscreen mode would distort the image if the aspect ratio of the screen was not the same as the aspect ratio of the image.  IOW, I thought it would stretch the image to fill the entire screen even if the aspect ratios didn't match.   I just tried a 4:3 aspect image as full screen on my 16:10 monitor and now see that's not the case.  SFML displays the 4:3 aspect image with a black bar on the right side so it retains the image's aspect ratio as it should.

Need to correct the paragraph above that I previously posted, for folks who might read it later.  What actually happened was that the 4:3 aspect image (1024x768) was not displayed full screen but was displayed at 1024x768 with a black background.  This is discussed after I posted the comments quoted above.

Raptor

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #26 on: September 06, 2012, 09:18:51 pm »
Quote
Could you post the setScale statement using the new C++ casting functionality you referred to?
Seriously?  :o
sprite.setScale(static_cast<float>(App.getSize().x)/static_cast<float>(image.getSize().x),
static_cast<float>(App.getSize().y)/static_cast<float>(image.getSize().y));
Also read that to see why c-style cast should be avoided : http://www.stroustrup.com/bs_faq2.html#static-cast
Back to C++ gamedev with SFML in May 2023

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #27 on: September 06, 2012, 09:28:03 pm »
Quote
Could you post the setScale statement using the new C++ casting functionality you referred to?
Seriously?  :o
sprite.setScale(static_cast<float>(App.getSize().x)/static_cast<float>(image.getSize().x),
static_cast<float>(App.getSize().y)/static_cast<float>(image.getSize().y));
Also read that to see why c-style cast should be avoided : http://www.stroustrup.com/bs_faq2.html#static-cast

FRex,

You are a good and patient person.  Thanks for the answer  :).

Raptor