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

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

0 Members and 1 Guest are viewing this topic.

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Why doesn't my fullscreen window display?
« on: September 03, 2012, 02:38:25 pm »
Running SFML 2.0 and Win7.  My monitor's native resolution is 1650 x 1080 pixels which is what Win7's screen resolution is set to.  The .png image I'm trying to display is 1650 x 1080.

When I set screen width=1650 and height=1080, only the console window displays but the RenderWindow does not display.

If I set width=1650 and height=900, the RenderWindow displays.
If I set width=1450 and height=900, the RenderWindow displays.

Why won't SFML's window display when I use width=1650 and height=1080?

Here's the applicable code:
// Main.cpp

int SCREEN_WIDTH = 1650;
int SCREEN_HEIGHT = 1080;

sf::RenderWindow App;

int _tmain(int argc, _TCHAR* argv[])
{
        App.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "CRAPS");

        while (App.isOpen())
        {
                switch (eGameState)
                {
                        case SPLASH:  // Show splash screen.  Wait for user to click mouse, press a key, or click close.
                        {
                                SplashScreen splashScreen;  
                                splashScreen.show(App);    
                                eGameState = MAIN_MENU;        
                                break;
                        }
 


        // SplashScreen.cpp

        sf::Texture image;  
        if (image.loadFromFile ("Images/Table1650x1080.png") != true)
        {
                return;
        }
 

I'm using my splashScreen class to test display of the craptable in 1650x1080 size.

Also, I realize now that the size of the craptable has to be smaller than 1650x1080 to allow for SFML's window frame.  How do I calculate the dimensions of the "Table1650x1080.png" image to fit within the RenderWindow's frame?

Thanks,
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 #1 on: September 03, 2012, 02:47:27 pm »
Do
App.create(sf::VideoMode::getFullscreenModes()[0],"CRAPS",sf::Style::Fullscreen);
instead if you want 'real' full screen and make sure your video mode is not fubar for fullscreening.
App also shouldn't be global but inside main.

If you want to fit sprite of a texture bigger or smaller into entire window then scale sprite with origin 0,0 with window.x/texture.x and window.y/texture.y
« Last Edit: September 03, 2012, 03:03:20 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #3 on: September 03, 2012, 11:10:27 pm »
Hi FRex and Laurent,

Thank you very much for your replies.  I found that my problem was caused by *OPERATOR ERROR* !
I had transposed the screen resolution values.

Should be:  1680 x 1050
I used.....:  1650 x 1080

The problem was that the vertical resolution of 1080 that I used was larger than the actual screen resolution of 1050.  When I use the correct 1680 x 1050 resolution, the window displays, even without using a setPosition statement.

==========

Now I have another problem.  When I use this code, the RenderWindow displays but the upper left corner of the RenderWindow does not display at screen position 0,0.  I'm not referring to the display of the crap table within the SFML window.  I mean the entire SFML window does not display at screen position 0,0.  It displays centered on the screen.
int _tmain(int argc, _TCHAR* argv[])
{
        int SCREEN_WIDTH = 1440;
        int SCREEN_HEIGHT = 900;

        sf::RenderWindow App;  //Levelworld prog puts this before main.

        App.setPosition(sf::Vector2i(0, 0));   //Set topleft corner of window to 0, 0.
 

Is my setPosition code incorrect?

PS:  The image I'm using is 1440x900 in size so the entire crap table displays in the 1440x900 RenderWindow.

Thanks,
Raptor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #4 on: September 03, 2012, 11:25:29 pm »
I'm not really sure what you refere to with 'centered' and 'not display at screen position 0,0'.
The window has a border before the actual rendering part starts, afaik if you set it to 0,0 then the window will be set to 0,0 but it will include the border.

Why don't you just use fullscreen mode, since you want to cover the whole screen?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #5 on: September 03, 2012, 11:32:24 pm »
You call setPosition after creating the window, right?
Laurent Gomila - SFML developer

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 #6 on: September 03, 2012, 11:44:02 pm »
You call setPosition after creating the window, right?
:D :D :D :D
Quote
Why don't you just use fullscreen mode, since you want to cover the whole screen?
This. Also these values for resolution are quite big imo, that'd not fit into my screen, if someone launches your game with smaller desktop resolution it'll not appear or display any error ordo anything at all. Just get one of valid video modes and run in fullscreen.
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 #7 on: September 04, 2012, 12:44:01 am »
Hi eXpl0it3r, Laurent and FRex,

>>> You call setPosition after creating the window, right? <<<
Noob mistake :)  Forgot that RenderWindow does not "create" the window.  Moved setPosition where it should be and it works now.

>>> Why don't you just use fullscreen mode, since you want to cover the whole screen? <<<
>>> This. Also these values for resolution are quite big imo, that'd not fit into my screen, if someone launches your game with smaller desktop resolution it'll not appear or display any error ordo anything at all. Just get one of valid video modes and run in fullscreen. <<<

I created the crap table as 1680 x 1050 since when resizing down, there's no loss of apparent resolution, but resizing say a 640x480 screen larger would have to invent pixels so not look as good.  (I think anyway.)

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.


QUESTIONS:
1. Can I continue to load my 1680x1050 image but use fullscreen mode to accomodate lower res monitors?  Or do I need to load a 640x480 image and have fullscreen mode resize it larger to the user's screen resolution?

2. Is there an example of actual code to convert coordinates when fullscreen mode is used?  (Or could some kind soul write an example here?)  I had a hard time coming up with the actual code when I looked at the SFML 2.0 documentation on that before.  ---  My needs are simple.  I just need to click on different parts of the crap table to choose chip values, make bets on the desired items like passline, field, any craps, etc. where the chip(s) appear where I click, etc.  IOW, no sprite movements or shooting or stuff like that.

Thanks,
Raptor
« Last Edit: September 04, 2012, 12:51:18 am by Raptor88 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #8 on: September 04, 2012, 12:53:49 am »
Btw there's a whole quoting system with quote-tags etc. so you don't need to use some strange looking >>> and <<<... ;)

1. Can I continue to load my 1680x1050 image but use fullscreen mode to accomodate lower res monitors?  Or do I need to load a 640x480 image and have fullscreen mode resize it larger to the user's screen resolution?
You can load the highres image and then resize it to fit the monitor resolution, but it may also be good to have diffrent resolution versions at hand (e.g. mipmapping), because the resize algorithm used by SFML/OpenGL might not be as good looking as one you can use in your favourite image editor. ;)

2. Is there an example of actual code to convert coordinates when fullscreen mode is used?  (Or could some kind soul write an example here?)  I had a hard time coming up with the actual code when I looked at the SFML 2.0 documentation on that before.
I'm not quite sure what you're asking here. What exactly do you want to convert?
When you're in fullscreen mode you 'own' the whole screen, i.e. the top left pixel is the 0,0 position of the rendering part.

If you want to prevent the stretching of the rendering area on widescreen monitors, then you should take a look at sf::View. I've written a tutorial on it that also includes a code example. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #9 on: September 04, 2012, 02:01:47 am »
Quote from: eXpl0it3r
Btw there's a whole quoting system with quote-tags etc. so you don't need to use some strange looking >>> and <<<... ;)

Yup, used the quoting system before.  Was in a hurry (a "honey-do" now) thing so used the >>> <<< for multiple quotes from different people.

Quote from: eXpl0it3r
You can load the highres image and then resize it to fit the monitor resolution, but it may also be good to have diffrent resolution versions at hand (e.g. mipmapping), because the resize algorithm used by SFML/OpenGL might not be as good looking as one you can use in your favourite image editor. ;)

That's why I was thinking of having 3 or 4 different image resolutions available and use the one to fit the user's screen.

2. Is there an example of actual code to convert coordinates when fullscreen mode is used?  (Or could some kind soul write an example here?)  I had a hard time coming up with the actual code when I looked at the SFML 2.0 documentation on that before.

Quote from: eXpl0it3r
I'm not quite sure what you're asking here. What exactly do you want to convert?
When you're in fullscreen mode you 'own' the whole screen, i.e. the top left pixel is the 0,0 position of the rendering part.

If you want to prevent the stretching of the rendering area on widescreen monitors, then you should take a look at sf::View. I've written a tutorial on it that also includes a code example. ;)

What exactly do you want to convert?

Say a button on my crap table is at coordinate 700x, 700y on my 1680x1050 image.  When I use fullscreen on a smaller monitor, won't that button be located at a different coordinate?  Won't I have to convert coordinates for the smaller screen?

I'll take a look at your tutorial.

Thanks for the help!
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 #10 on: September 04, 2012, 11:44:08 am »
That's what convertcoords is for in render window, it'll give you the position of the click in sfml coordinates from sf::mouse or sf::event coordinates.
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 #11 on: September 05, 2012, 04:01:38 am »
That's what convertcoords is for in render window, it'll give you the position of the click in sfml coordinates from sf::mouse or sf::event coordinates.

Thank you FRex. 
I'm trying to figure out how to code convertCoords since I don't really understand how to decipher the class statements given in the SFML 2.0 documentation.  Like:

Vector2f    convertCoords (const Vector2i &point) const
    Convert a point from target coordinates to view coordinates.

Thanks,
Raptor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #12 on: September 05, 2012, 06:18:53 am »
There's also an explenation of it in my tutorial I linked earlier. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Why doesn't my fullscreen window display?
« Reply #13 on: September 05, 2012, 08:31:03 am »
There's also an explenation of it in my tutorial I linked earlier. ;)

I did download your code and looked at it.  The line with convertCoords from it is:

ss << "<" << pos.x << ", " << pos.y << ">\t<" << window.convertCoords(pos, standard).x << ", " << window.convertCoords(pos, standard).y << ">";"

I couldn't figure out how you got:

window.convertCoords(pos, standard).x <=============== your code
- from -
Vector2f    convertCoords (const Vector2i &point) const <===== SFML 2.0 documentation

Thanks,
Raptor


« Last Edit: September 05, 2012, 08:43:10 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 #14 on: September 05, 2012, 11:04:13 am »
There's an overload that takes a vector 2i and a view, the 1 argument version uses window's current view.
Back to C++ gamedev with SFML in May 2023

 

anything