Author Topic: Different screen resolutions in a 2D game  (Read 13657 times)

0 Members and 1 Guest are viewing this topic.

Offline AntonioR

  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2010
  • Posts: 291
  • Karma: 10
    • My Facebook page
  • Platform: Other
Different screen resolutions in a 2D game
« on: January 27, 2012, 10:51:39 AM »
My problem is handling different screen resolutions. I want to draw a scene of the same size(1024,768) on different screen resolutions. I don't know what technique is usually used for doing this in 2D games.

To see what I want to do look at the screenshots below from a game called Facewound. Here are screenshots when running the game in 640x480 and 1024x768 window size. It is obviously the same scene, and if we count the tiles (32x32), we see that the original scene is 1024 pixels wide and it is somehow rendered to fit on just 640x480 window.

In my game if I change the screen resolution, the size of the scene that will be rendered depends on the size of the bacbuffer.So if it is 640x480, it just renders the upper left corner of the size 640x480. But I want the whole 1024x768 be rendered on 640x480 and not just the upper left part.

I am using ID3DXSprite object to render sprites.

640x480


1024x768


Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. [Albert Einstein]

Offline twobitcoder

  • Administrator
  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2007
  • Posts: 4,931
  • Karma: 69
    • jharbour.com
  • Game: Adventure
  • Genre: RPG
  • Platform: Atari
  • Studio: Activision
Re: Different screen resolutions in a 2D game
« Reply #1 on: January 27, 2012, 12:39:53 PM »
You can scale the output to any resolution by using a third buffer and just doing a quick scale operation on the scene. Take a look at the docs for ID3DXSprite and you'll see options for drawing beyond just the basic version of Draw. You can also do full 2D transforms with ID3DXSprite. There are some examples in my Advanced 2D and Multi-Threaded sources which you can download here from the forum. Just grab those sources and check out the chapters on 2D transforms. Or just look up the help for ID3DXSprite to see how scaling works.

Offline AntonioR

  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2010
  • Posts: 291
  • Karma: 10
    • My Facebook page
  • Platform: Other
Re: Different screen resolutions in a 2D game
« Reply #2 on: January 27, 2012, 03:22:16 PM »
You can scale the output to any resolution by using a third buffer and just doing a quick scale operation on the scene.

If I understand you correctly; I should render the scene to an offscreen buffer/texture, and then render it scaled up/down ?

That was my first idea, but it appears the offscreen buffer can't be bigger than (rendering devices) backbuffer.
So, if my screen/backbuffer is just 640x480, and I make an offscreen buffer 1024x768 big, it will still render on it like it is just 640x480 (the sprites outside this area won't be rendered).
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. [Albert Einstein]

Offline twobitcoder

  • Administrator
  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2007
  • Posts: 4,931
  • Karma: 69
    • jharbour.com
  • Game: Adventure
  • Genre: RPG
  • Platform: Atari
  • Studio: Activision
Re: Different screen resolutions in a 2D game
« Reply #3 on: January 27, 2012, 03:32:03 PM »
Why would you want to do that? If your window or screen is only 640x480, why do you need to render at 1024x768? That's impossible. Either you set it up to 1024x768, or you use some other resolution. If you want to dynamically change the screen size, then that is where you need a new buffer the size of the new screen, and then scale to that.

Offline AntonioR

  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2010
  • Posts: 291
  • Karma: 10
    • My Facebook page
  • Platform: Other
Re: Different screen resolutions in a 2D game
« Reply #4 on: January 27, 2012, 04:18:26 PM »
Why would you want to do that? If your window or screen is only 640x480, why do you need to render at 1024x768?That's impossible

Then how did the guy who made the above game do it ?

I need to see the same part of the map on different resolutions. I don't want that when I play on 640x480 I see a smaller part of the map then when I play on 1280x1024.

Look at the above images once again. First image shows the screenshot at just 640x480 screen size. But, if you count the tiles which are 32x32 pixels large (I opened the tilemaps to check), then that scene is 32 tiles wide and 24 tiles high which is actually 1024x768.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. [Albert Einstein]

Offline twobitcoder

  • Administrator
  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Mar 2007
  • Posts: 4,931
  • Karma: 69
    • jharbour.com
  • Game: Adventure
  • Genre: RPG
  • Platform: Atari
  • Studio: Activision
Re: Different screen resolutions in a 2D game
« Reply #5 on: January 27, 2012, 05:42:23 PM »
Okay, but repeating your question doesn't make it any clearer. Either that game scales the tiles as they are being copied onto the scroll buffer, or the whole scene is being triple buffered to scale up or down to the target resolution.

Offline Axlyon

  • -[ EPIC MEMBER ]-
  • *****
  • Join Date: Oct 2011
  • Posts: 1,343
  • Karma: 5
    • Blogdude's Various Reviews
  • Game: RE4 or MGS2
  • Genre: RPG
  • Platform: PC/Steam
  • Studio: Inti Creates
Re: Different screen resolutions in a 2D game
« Reply #6 on: January 28, 2012, 09:12:41 AM »
there are some(somewhat)common issues in 2D(and/or 3D) games where one part of the game appears in 2D and the rest(or vice versa) in 3D. parts of that game appeared rendered in 3D(ie, the water tower, the vines, the AC/heating unit and pipes, some of the walls on the buildings) whereas the rest appears rendered in a stiff, cartoon like 2D. this comes from me playing a lot of 2D games, not from much rendering experience, so please point out errors where/if you see them. right now i am just being observant.