|
1 registered members (Quad),
5,649
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
the widescreen trick (aspect)
#208893
05/30/08 13:29
05/30/08 13:29
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
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.
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);
|
|
|
Re: the widescreen trick (aspect)
[Re: Pappenheimer]
#209236
06/02/08 04:10
06/02/08 04:10
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
Hi Pappenheimer! What part you think wont work with c-script and why? 
|
|
|
Re: the widescreen trick (aspect)
[Re: Coisox]
#217079
07/21/08 08:31
07/21/08 08:31
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
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.
|
|
|
Re: the widescreen trick (aspect)
[Re: Coisox]
#217080
07/21/08 09:19
07/21/08 09:19
|
Joined: Jun 2008
Posts: 91
Coisox
Junior Member
|
Junior Member
Joined: Jun 2008
Posts: 91
|
Yeah!! I found my solution and lets share  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.
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
|
|
|
Re: the widescreen trick (aspect)
[Re: ]
#217081
07/21/08 09:24
07/21/08 09:24
|
Joined: Jun 2008
Posts: 91
Coisox
Junior Member
|
Junior Member
Joined: Jun 2008
Posts: 91
|
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
|
|
|
Re: the widescreen trick (aspect)
[Re: Coisox]
#217082
07/21/08 09:32
07/21/08 09:32
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
I meant to use the default GS-resoltions (4:3) from video_mode in my initial coding.
Last edited by mercuryus; 07/21/08 09:40.
|
|
|
|