• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
AntonioR

Different screen resolutions in a 2D game

7 posts in this topic

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 DirectX and ID3DXSprite object to render sprites. All, I need is the idea/principle how stuff like this are made, not the code.

640x480
[img]http://i.imgur.com/tOdNy.jpg[/img]

1024x768
[img]http://i.imgur.com/Va6xw.jpg[/img]
0

Share this post


Link to post
Share on other sites
You can render the backbuffer in the optimal resolution of your game (in your case 1024x768) and then use [b]IDirect3DDevice9::StretchRect()[/b] method to scale the entire frame according your output resolution.

I have never done this myself, but it should work since both your backbuffer and your primary buffer are Direct3D surfaces. [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Marvel Magnum' timestamp='1327689413' post='4906803']
You can render the backbuffer in the optimal resolution of your game (in your case 1024x768) and then use [b]IDirect3DDevice9::StretchRect()[/b] method to scale the entire frame according your output resolution.[/quote]

But, how will I render my 1024x768 scene, if my backbuffer/screen/window size is just 640x480 ? The scene outside 640x480 won't be rendered at all. That is my problem, rendering a scene bigger than the screen size.
0

Share this post


Link to post
Share on other sites
Can't stretch be used to down-res as well? So, you blit to your back buffer that's 1024x768, but when you blit to the final, on-screen buffer, it is 640x480, and it gets scaledd down on the final buffer.
0

Share this post


Link to post
Share on other sites
You need to setup your projection matrix correctly. I've forgotten how to do this exactly, it's been awhile.

IIRC, you need to setup your projection matrix in your own units, rather than pixels. Instead of specifying 640x480, you specify, for example 4.0x3.0, and everything else in your game (units movement, distance calculation, etc) must conform to that measurement you've set. That means a unit that moves at 4.0/sec will move across the screen in one second.

It becomes resolution independent. If your game is run on 1440x900, which as 1.6 aspect ratio, your game sprites will appear stretched.
0

Share this post


Link to post
Share on other sites
[b]IDirect3DDevice9::StretchRect() [/b]method can be used to scale to both up-res and down-res. So you can stretch a 1024x768 screen to 640x480 or 1920x1080 or to any resolution and it will scale appropriately.

[quote name='alnite' timestamp='1327705859' post='4906882']
you need to setup your projection matrix in your own units, rather than pixels. Instead of specifying 640x480, you specify, for example 4.0x3.0, and everything else in your game (units movement, distance calculation, etc) must conform to that measurement you've set. That means a unit that moves at 4.0/sec will move across the screen in one second.
[/quote]

Also using this method, you will not have to take adjusting speed into account like alnite suggested which would normally be required. This is because you are always calculating for your native 1024x768 resolution that is being generated in the backbuffer. The display is just an appropriately scaled output along with which the movement, etc will automatically be scaled.
0

Share this post


Link to post
Share on other sites
[quote name='Marvel Magnum' timestamp='1327730254' post='4906935']
[b]IDirect3DDevice9::StretchRect() [/b]method can be used to scale to both up-res and down-res. So you can stretch a 1024x768 screen to 640x480...[/quote]

This would require me to render the scene on a 1024x768 texture/surface, and then scale it down to my 640x480 screen.
But, I can't do that. I can't make a render texture bigger than my screen size. I tried that.

[CODE]
g_engine->p_device->CreateTexture(1024,768
1,D3DUSAGE_RENDERTARGET,D3DFMT_R5G6B5,D3DPOOL_DEFAULT,&this->p_RenderTexture,NULL);

this->p_RenderTexture->GetSurfaceLevel(0,&this->p_RenderSurface);
[/CODE]

When I render on it and scale it down, even though I put 1024x768, it still renders only 640x480 part of the scene.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0