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

Author Topic: Any way to make fullscreen stretch AND keep dimensions?  (Read 9408 times)

0 Members and 3 Guests are viewing this topic.

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Any way to make fullscreen stretch AND keep dimensions?
« on: August 12, 2012, 03:29:44 am »
Hello, I'm developing a game with tiles that are 16x16. I want my tiles to remain a square shape when I put the game in full screen mode. I'm trying to figure out how to do this with video modes.

If I draw a square in a full screen video mode set to my desktop's standards, there isn't any width stretching, but the tiles appear way too small. I want my tiles to be stretched, but equally. If I set the resolution to 800x600, the tiles are stretched to the size I want, but are too wide for my screen and appear as rectangles. I have a very wide HD monitor.

How can I make sure that all my users get a resolution without width stretching and without it being the desktop's default mode?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #1 on: August 12, 2012, 10:57:28 am »
There are various ways to handle diffrent resolutions and for many of them you can find examples in the forum (use the search function).
To keep the ratio you'll have to adjust the view on the window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #2 on: August 13, 2012, 01:16:57 am »
To keep the ratio you'll have to adjust the view on the window.

Ah ok, that's what I was looking for. Thanks!

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #3 on: August 13, 2012, 03:35:45 am »
I'm getting some weird FPS issues using views to maintain the drawing ratio like you suggested. Are there any bugs in SFML that make this happen or is this a problem on my part? It seems really odd to me because with the zoom, it actually uses LESS render calls because I optimized it to not draw tiles outside of the view.

Main Menu State

-GUI (w/o view)
400~ FPS / 8 window.draw() calls

-GUI (w/ views + zooming)
170~ FPS / 8 window.draw() calls

Game State

-Game (w/o view)
300~ FPS / 1875 window.draw() calls (I'm going to optimize this, don't worry :P)

-Game (w/ view)
100~ FPS / 1875 window.draw() calls

-Game (w/ view + zoom)
40 FPS /  768 window.draw() calls


Every loop I go through this in the camera class:

//      Move the camera to the center of the player
        bool changedView = false;
       
        if(you->getSprite().getPosition().x <  x + ((gl::Vars::screenW / 1.5) / 2) - 100)
        {
                changedView = true;
                view.move(-1, 0);
                x-=1;
        }

        else if(you->getSprite().getPosition().x >  100 + x + ((gl::Vars::screenW / 1.5) / 2))
        {
                changedView = true;
                view.move(1, 0);
                x+=1;
        }

        if(you->getSprite().getPosition().y < y + ((gl::Vars::screenH / 1.5) / 2) - 100)
        {
                changedView = true;
                view.move(0, -1);
                y-=1;
        }

        else if(you->getSprite().getPosition().y > 100 + y + ((gl::Vars::screenH / 1.5) / 2))
        {
                changedView = true;
                view.move(0, 1);
                y+=1;
        }

        if(changedView)
        {
                //view.reset(sf::FloatRect(x, y, gl::Vars::screenW / 1.5, gl::Vars::screenH / 1.5));
                gl::Win.setView(view);
        }

It essentially gets the position of the player and if the player goes outside of the bounding box, it moves the camera accordingly.

Suggestions? 40 FPS is not acceptable for me. I should be getting around 400 considering the meager amount of tiles I'm drawing. It also is preventing me from recording my game with FRAPs, as I get only 15 FPS.
« Last Edit: August 13, 2012, 04:02:05 am by Jungletoe »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #4 on: August 13, 2012, 09:38:28 am »
Yes those FPS drops should be that drastic but with the given code we can't judge what's going on, can you provide a complete but minimal example that reproduces the problem on your machine, so we could test it on ours?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #5 on: August 13, 2012, 06:33:11 pm »
I just got it running at 120+ FPS using VertexArrays (400 uncapped). I'm still wondering why that FPS drop happened though.

Sorry to question you, but if this is normal then why do I need to provide a minimal example? I'm sorry-- I know how much you hate when people don't provide the example straight away (I swear I've read through every error report thread on this forum. I use the search function more than you think ;) ), but producing a minimal example would take a while. I'm currently streaming all my tile info and everything from a server, so I'd need to rewrite how my tile maps are loaded if I wanted to provide something you could run without a server.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #6 on: August 13, 2012, 08:56:03 pm »
Oh sorry my bad I once again forgot to append the n't behing should. Such a drastic drop should not happen, specially since you're clipping the things that don't get displayed. ;)

I was asking for an example so I could verify on my PC that's not a hardware/driver issue on your end. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #7 on: August 14, 2012, 12:19:15 am »
Oddly enough, after doing testing, I can't get back up to 400 FPS. I tried disabling the camera, zoom, and everything but it was still the same FPS (I did notice a slight FPS increase when I zoomed though). I'm just going to announce this a mystery about how I got 400 FPS in the first place and give up.

Is 140 uncapped FPS enough though? I only render a few sprites and a few thousand vertices each frame. I'm also on a pretty awesome computer.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #8 on: August 14, 2012, 12:43:08 am »
As you probably already know a normal game should run smoothly on 60fps, so unless you drop under that value in development state you should be fine. It's hard to predict if XXXfps in an early development state is high enough or not, what counts should be the final result.

Have you ever switched to release mode to see if the FPS will go up?
Is your graphics card driver uptodate?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #9 on: August 14, 2012, 04:25:17 am »
As you probably already know a normal game should run smoothly on 60fps, so unless you drop under that value in development state you should be fine. It's hard to predict if XXXfps in an early development state is high enough or not, what counts should be the final result.

Ok thanks :)

Have you ever switched to release mode to see if the FPS will go up?

I'm running release when I test. I only switch to debug if I'm testing for memory leaks.

Is your graphics card driver uptodate?

I just bought this computer in December, so I assume so.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #10 on: August 14, 2012, 09:20:19 am »
I just bought this computer in December, so I assume so.
Must be extremly complicated to quickly find out... ::)
Also December is already 8 month in the past and from my perspective 8 month in the computer world is quite a lot. ;)

I'd be still willing to test the code (even if it's a bit more complicated), if you still want to find out if it's limited to your hardware. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #11 on: August 15, 2012, 01:40:36 am »
I just bought this computer in December, so I assume so.
Must be extremly complicated to quickly find out... ::)
Also December is already 8 month in the past and from my perspective 8 month in the computer world is quite a lot. ;)

I'd be still willing to test the code (even if it's a bit more complicated), if you still want to find out if it's limited to your hardware. :)

Oh ok, thanks! I checked my drivers and they're all up to date. I didn't realize how easy it was to check. I though I'd have to download tons of checking software.

Here are my project files. It's quite large, so feel free not to test it. The only libraries I use are SFML so it should run out of the box.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Any way to make fullscreen stretch AND keep dimensions?
« Reply #12 on: August 15, 2012, 04:47:40 pm »
Here are my project files.
Uhm sorry I'm not willing to sign up to 4shared just to download that zip file... Can you upload it to a better site? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything