Author Topic: [C++] Determing Aspect Ratio And Resolution  (Read 11356 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
[C++] Determing Aspect Ratio And Resolution
« on: October 11, 2010 »
My team are moaning at me as they've got widescreen HD monitors and I haven't ( not fair, hehe )

How would in this framework allow for 4:3 / 16:9 displays?
And are these the common aspect ratios? What would those settings be too, if they are used.

Many thanks,
Clyde.
« Last Edit: October 12, 2010 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #1 on: October 11, 2010 »
The aspect ratio depends more on how you set up your 3d camera, and less on the pixel size.  Particularly, if you keep the usual 90degree horizontal viewing angle it changes the vertical viewing angle to be less.
If you're just doing 2d then you need to design your scene for the aspect ratio and be able to letterbox or pillarbox when the display doesn't match.
So, nothing to do with the framework other than picking the right res.

Other aspect ratios you will see
4:3 CRT
5:4 LCD
16:9 Wide CRT and LCD
16:10 Wide CRT and LCD
There will be more, and some people run their screens vertically, but I'd not worry about any than the above.

Jim

« Last Edit: October 11, 2010 by Jim »
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #2 on: October 11, 2010 »
so, say a user opts for 16:9, I just add in a top and bottom border?
for example:

Code: [Select]
int border=32;
int screen_height=600;

for ( int y=border; y<=screen_height-(1+border); y++ )
{
      //....insert clever code
}

Or including the height plus the border x 2

Could you give us an exmple please dude. thanks.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #3 on: October 12, 2010 »
If they opt for 16:9 and they have a 4:3 screen and your demo is designed for 16:9, then just don't draw the top and bottom scanlines.
If they opt for 16:9 and they have a 16:9 screen and your demo is designed for 4:3, then just don't draw the left and right scanlines.
etc.

Without knowing all 3 pieces of information, and possibly the screen resolution, you can't get it right.

So, is your demo designed in 4:3 aspect or 16:9 aspect?  What's the pixel size you are drawing it at?

If I was doing 2d I'd always render to a buffer in memory the size I designed for, say 1024x600 or 640x480.  Then I'd look at the screen res/aspect ratio and blit my memory buffer in the most appropriate way, with letterbox or pillarbox and/or a resize or pixeldouble.

But there's no help in this little library for that.

Jim
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #4 on: October 12, 2010 »
I've only got a crt I do all my stuff in 4:3.

They have a 16:9.

I have my 2d stuff set at a fixed res for the time being.
I use x2 rendering for some stuff.

it might be along these lines.

screen_wwidth=640
screen_height=480
screen_ratio=43
screen_user_ratio=169

screen_buffer( screen_wwidth * screen_height )

if screen_user_ratio=43 and screen_ratio=43
//do as normal.

if screen_user_ratio=169 and screen_ratio=43
//

dont really know on this score, even harder when I don't have a means of testing at home.
I might just tell them to keep quiet and run in window mode for now until later next year I get one.

I did think that maybe there was a way to resize the windows class style. likewize, im still in the early chapters.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #5 on: October 12, 2010 »
Let's say your friends have 1920x1080 screens (full HD).  If you fill a buffer of 640x480 with your demo, then you can blit it at 2x size (1280x960) at the position 320,60 == (1920-2*640)/2,(1080-480*2)/2.
That will give you a lot of pillarbox down the sides, and a small letterbox across the top and bottom, without distorting your display.
Obviously everybody's displays are going to be different, mine is 1680x1050 for example, meaning you could manage a 2x size one at 200,45.
My netbook is 1024x600 meaning you can't quite double up.  You might decide to just blit it at 1x size to 192,60.
Anyway, the important thing is to separate the resolution of your demo from the resolution of the display you'll be copying it on to. 

Jim
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #6 on: October 12, 2010 »
If you do not mind it being stretched you can render to texture and just draw one quad that takes up the entire screen.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #7 on: October 12, 2010 »
Thanks guys for the response.

With using GetSystemMetrics, can I not use that to determing the resolution of the screen, aspect ratios? I have used it to set the position of the window and center it if not in fullscreen.

I'd like help to come up with something as this would benefit alot of people I'd of imagined.

Cheers.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #8 on: October 12, 2010 »
Quote
If you do not mind it being stretched you can render to texture and just draw one quad that takes up the entire screen
This is exactly the problem Clyde wants to fix - he's setting his mates' 16:9 screens into 640x480 and it's stretching.

Clyde, we discussed doing the screen pixel size/aspect ratio determination here.  But I think in the end we said the only sure-fire way of getting it right is to have a configuration dialog up front.

Jim
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #9 on: October 13, 2010 »
At the moment I'd suggest to design your stuff in 16:9 and add black borders to top & bottom for all other aspect ratios.
16:9 makes sense because most people have their eyes side by side and not on top of each other.
We're also used to top/bottom-borders from tv while left/right-borders look "wrong".
On the other hand 2.39:1-screens could be popular in a few years...
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #10 on: October 13, 2010 »
I agree, 16:9 is where you should be aiming, and then fitting into other displays.

I think 2.39:1 (equiv 20:9) might make sense for tellies for movie watchers but I'd hate that in a computer monitor. [1]

Jim

[1] Actually, my colleagues would probably hate it more as I already use 1920x1080 with Terminal 8 font and some of my code lines are 200chars+.  I reckon I could get 400chars of Linq on a 2.39 to 1.  :P Sorry guys!
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #11 on: October 17, 2010 »
just left to do is somehow make the tinyptc dx9 framework, incorparate the new settings. based on the program designed in a res and the users selections. but stumpped.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #12 on: October 17, 2010 »
What would you like the method to look like?
The things I suspect you need are
a) buffer resolution
b) scale factor?
c) position?
d) filtering method?

Jim
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #13 on: October 17, 2010 »
top of me head a) b) and c)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #14 on: October 19, 2010 »
The main problem of all this aspect and resolution mystification is:
- you're rendering at one fixed resolution
- you want to convert it to another resolution
- the other resolution may take up a different space
  (because the screen uses scaling or letterboxing)

So the best solution is to make your effects resolution-independent in the first place.
(if you're using carefully pixeled graphics this might be impossible, though)
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #15 on: October 20, 2010 »
I've got a little C++ Intro 88% done.
Just need to know on going about this, it's something new and fun this aspect & res biz, and I will need people to test it - once I know what im doing, as I've no means of access to a wide screen / HD monitor. I come from a poor family :p
 
Do you mean by the above reply, that rather than have ptc_update work out the final rendering dimensions, have it in any effects loops?
« Last Edit: October 20, 2010 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Determing Aspect Ratio And Resolution
« Reply #16 on: October 20, 2010 »
I suggested to design your effects in a such a way that they can run in any resolution and always produce the same result - just with more detail if you pick a higher resolution.
Challenge Trophies Won: