the widescreen trick (aspect)

Posted By: Anonymous

the widescreen trick (aspect) - 05/30/08 13:29

User of widescreen monitors see a distorted game if the programmer did not offers a necessary resolution.

If you want to offer at least the right aspects for all types of monitors you can use the following code to set the right camera aspect.

Code:
var gv_scr_width;
var gv_scr_height;

//...

// before resolution change
gv_scr_width=sys_metrics(0);
gv_scr_height=sys_metrics(1);	

// set the resolution here
// ...
	
// set aspect
camera.aspect=(screen_size.y/screen_size.x)/(gv_scr_height/gv_scr_width);

Posted By: Pappenheimer

Re: the widescreen trick (aspect) - 06/01/08 20:40

Looks like a nice snippet, but it is only possible with light-c, I guess, isn't it?
Posted By: Anonymous

Re: the widescreen trick (aspect) - 06/02/08 04:10

Hi Pappenheimer!

What part you think wont work with c-script and why? wink
Posted By: Pappenheimer

Re: the widescreen trick (aspect) - 06/02/08 08:32

Sorry, found it in the manual of A7. I'm currently still working with A6 - that's why I didn't find sys_metrics in the manual!
Posted By: Coisox

Re: the widescreen trick (aspect) - 07/21/08 08:08

I cant get it right. All my panels are displayed at the correct ratio but not the 3D objects.

Here's my code:

desktopWidth = sys_metrics(0);
desktopHeight = sys_metrics(1);
video_set(desktopWidth,desktopHeight,0,1);
camera.aspect=(screen_size.y/screen_size.x)/(desktopHeight/desktopWidth);

BTW, doesn't it same between screen_size.y vs desktopHeight?
Posted By: Anonymous

Re: the widescreen trick (aspect) - 07/21/08 08:31

sys_metrics(0) and sys_metrics(1) represents the current monitor resolution (before the Engine starts).

video_set sets the engine window size.

You make the engine window the same size like the monitor size (ignoring the aspects) because you set the size BEFORE getting the aspect ratio.
Afterwards screen_size.y of cause is equal desktopHeight.
Posted By: Coisox

Re: the widescreen trick (aspect) - 07/21/08 09:19

Yeah!! I found my solution and lets share smile
Note: I put this at the first line of main( ) function.

What this code do? Change the resolution to the user native resolution IF, the screen wide up to 1680. If the user use bigger screen, change the resolution into their respective category. If the user use "strange" resolution, just make it window mode to be on the safe side.

The reason I limit the resolution for super big monitor is because they'll have huge advantage. Imagine you make a side scrolling game, of course wider screen will see the enemy sooner and have "more time" to avoid enemy attack.
Code:
desktopWidth = sys_metrics(0);
desktopHeight = sys_metrics(1);

if (desktopWidth<1681) video_set(desktopWidth,desktopHeight,0,1);
else
{
	if 	(desktopWidth/4  == desktopHeight/3)	//Classic
	{
		video_set(1024,768,0,1);
		desktopWidth = 1024;
		desktopHeight = 768;
	}
	else if (desktopWidth/15 == desktopHeight/9)	//BrightView
	{
		video_set(1280,768,0,1);
		desktopWidth = 1280;
		desktopHeight = 768;
	}
	else if (desktopWidth/5  == desktopHeight/4)	//SXGA
	{
		video_set(1280,1024,0,1);
		desktopWidth = 1280;
		desktopHeight = 1024;
	}
	else if (desktopWidth/16 == desktopHeight/10)	//WSXGA+
	{
		video_set(1680,1050,0,1);
		desktopWidth = 1680;
		desktopHeight = 1050;	
	}
	else						//Window Mode
	{
		video_mode = 8;
		video_window(nullvector,nullvector,1,NULL);
		wait(1);	// must put this. not sure the reason
		desktopWidth = screen_size.x;
		desktopHeight = screen_size.y;
	}
}

float fAspect = desktopWidth/desktopHeight;
camera.aspect = fAspect / 1.333333; // Not sure why have to hard code

Posted By: Coisox

Re: the widescreen trick (aspect) - 07/21/08 09:24

Originally Posted By: mercuryus

You make the engine window the same size like the monitor size (ignoring the aspects) because you set the size BEFORE getting the aspect ratio.
Afterwards screen_size.y of cause is equal desktopHeight.


Oh I see... so your solution is like this?

var gv_scr_width;
var gv_scr_height;

// before resolution change
gv_scr_width=sys_metrics(0);
gv_scr_height=sys_metrics(1);

// set aspect
camera.aspect=(screen_size.y/screen_size.x)/(gv_scr_height/gv_scr_width);

// change the resolution here
Posted By: Anonymous

Re: the widescreen trick (aspect) - 07/21/08 09:32

I meant to use the default GS-resoltions (4:3) from video_mode in my initial coding.

© 2024 lite-C Forums