Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: va!n on February 14, 2008

Title: Screen Aspect Ratio
Post by: va!n on February 14, 2008
Quote
Please consider making the demo's target resolution and aspect ratio selectable.  Widescreen displays with 16:10 aspect ratio and HDTV screens with 16:9 aspect ratio are increasingly common - your demo should support this properly if possible.

Atm i am working on a windows project, using DX9 and 800x600 on a widescreen notebook, where the screen looks good.

Some mins ago, i saw my program on an older 4:3 monitor and i was really shocked because the screen looks like shit due fact of the aspect ratio changing to a widescreen.

I would like to add a setup where the user can select screenmode and aspect ratio but i dont really know how to manage this.

As example we have following PsydoCode:


InitScreen( 800, 600, 32 )                ; width, height, depth
Repeat
    DrawTexture(   0,   0, 800, 120 )     ; x,y,width, height
    DrawTexture(   0, 480, 800, 120 ) 
    DrawText   ( 100, 100,  50, "Text" )  ; x, y, FontSize, String
Until


The question is, how and where must i change the psydocode to fit my screens on any aspect ratio like ( 4:3, 16:9, 16:10 ) ? Does someone has experience with this and know how to solve this problem on an easy way? thanks
Title: Re: Screen Aspect Ratio
Post by: Jim on February 15, 2008
First, decide whether you are designing your demo in widescreen or 4:3.  Then you need to fix the viewport accordingly.  So if you are widescreen and the user selects 4:3, you need to set the viewport to leave black borders at the top and bottom.  Otherwise if you do a 4:3 demo and you're running on a 16:9 display, you need to pillar box.  I would say that only in special cases do you need to distinguish between 16:9 and 16:10, just bear in mind if you're doing a demo based around circles they'll get all stretched.

Jim
Title: Re: Screen Aspect Ratio
Post by: taj on February 16, 2008
Re circles: if you match your field of view to your aspect ratio, circles wont get distorted.

Do you have glu in Basic? If so have a look at gluPerspective command. One of the parameters is the aspect ratio of your field of view. You can set this to either SCREENY/SCREENX, or SCREENX/SCREENY ... I forget which right now.

http://www.cs.utk.edu/~vose/c-stuff/opengl/gluPerspective.html
Title: Re: Screen Aspect Ratio
Post by: va!n on February 19, 2008
thanks guys. i will take a look later to this stuff. atm i will work first on some other important parts of my projects ^^