Add support for most standard and widescreen resolutions

Posted By: mpdeveloper_B

Add support for most standard and widescreen resolutions - 06/26/08 20:28

I've just finished a code that will allow you to change to widescreen (16:9 and 16:10) resolutions as well as most 4:3 Standard resolutions.

First off, add this somewhere near the beginning of your code:

Code:
////////wide should be set to:
////////0 - Standard
////////1 - 16:9 Widescreen
////////2 - 16:10 Widescreen
function set_resolution(res_,wide_,_depth,_window)
{
	var new_ratio;
	var x_;
	var y_;
	var view_aspect;
	if (res_ == 0) { video_set(0,0,_depth, _window); return; }
	if (wide_ == 0 || _window == 2)
	{
		if (res_ == 1)
		{
			x_ = 640;
			y_ = 480;
		}
		if (res_ == 2)
		{
			x_ = 800;
			y_ = 600;
		}
		if (res_ == 3)
		{
			x_ = 1024;
			y_ = 768;
		}
		if (res_ == 4)
		{
			x_ = 1280;
			y_ = 960;
		}
		if (res_ == 5)
		{
			x_ = 1280;
			y_ = 1024;
		}
		if (res_ == 6)
		{
			x_ = 1400;
			y_ = 1050;
		}
		if (res_ == 7)
		{
			x_ = 1600;
			y_ = 1200;
		}
	}
	else
	{
		if (wide_ == 1)
		{
			if (res_ == 1)
			{
				x_ = 848;
				y_ = 480;
			}
			if (res_ == 2)
			{
				x_ = 960;
				y_ = 600;
			}
			if (res_ == 3)
			{
				x_ = 1088;
				y_ = 612;
			}
			if (res_ == 4)
			{
				x_ = 1280;
				y_ = 720;
			}
			if (res_ == 5)
			{
				x_ = 1360;
				y_ = 768;
			}
			if (res_ == 6)
			{
				x_ = 1600;
				y_ = 900;
			}
			if (res_ == 7)
			{
				x_ = 1920;
				y_ = 1080;
			}
		}
		if (wide_ == 2)
		{
			if (res_ == 1)
			{
				x_ = 640;
				y_ = 400;
			}
			if (res_ == 2)
			{
				x_ = 960;
				y_ = 600;
			}
			if (res_ == 3)
			{
				x_ = 1280;
				y_ = 768;
			}
			if (res_ == 4)
			{
				x_ = 1280;
				y_ = 800;
			}
			if (res_ == 5)
			{
				x_ = 1600;
				y_ = 1024;
			}
			if (res_ == 6)
			{
				x_ = 1680;
				y_ = 1050;
			}
			if (res_ == 7)
			{
				x_ = 1920;
				y_ = 1200;
			}
		}
	}
	video_set(x_, y_, _depth, _window);
	wait(1);
	new_ratio = x_ / y_;
	view_aspect = new_ratio / (4/3);
	camera.aspect = view_aspect;
}


Explanation of use:

set_resolution (res_number, widescreen, video_depth, window);

Res_Number: This area sets the resolution, similar to video_switch, the resolutions are as follows:

0 - No change in resolution

If widescreen set to 0 (4:3 Standard):
1 - 640x480
2 - 800x600
3 - 1024x768
4 - 1280x960
5 - 1280x1024
6 - 1400x1050
7 - 1600x1200

If widescreen set to 1 (16:9 Widescreen):
1 - 848x480
2 - 960x600
3 - 1088x612
4 - 1280x720
5 - 1360x768
6 - 1600x900
7 - 1920x1080

If widescreen set to 2 (16:10 Widescreen):
1 - 640x400
2 - 960x600
3 - 1280x768
4 - 1280x800
5 - 1600x1024
6 - 1680x1050
7 - 1920x1200

Widescreen: When this is set it will allow you to change the res_number to use widescreen resolutions rather than 4:3.

Use:
0 - Use 4:3 Standard aspect ratio
1 - Use 16:9 Widescreen aspect ratio
2 - Use 16:10 Widescreen aspect ratio

Video_Depth : set the video depth:
0 - No change
16 - 16-bit mode
32 - 32-bit mode

Window:
0 - Don't change window mode
1 - Set to fullscreen mode
2 - Set to windowed mode

The code is intended to kind of "replace" the video_switch function and should be used in the same way. Hopefully this is a good enough explanation. If it's possible could this become a sticky? I think this would be really helpful.
Special thanks to Grafton, Inestical, and FlorianP for submitting resolutions.
This is based on Xarthor's aspect ratio fix, so thanks to him as well.
Posted By: Xarthor

Re: Add support for most standard and widescreen resolutions - 06/26/08 20:48

Thanks for this code contribution, but it lacks one important thing:
the view.aspect value remains unchanged, but it needs to be change to have a real widescreen resolution, otherwise its just "stretched" and doesn't look right.
Posted By: mpdeveloper_B

Re: Add support for most standard and widescreen resolutions - 06/26/08 21:26

i'll be adding the aspect thing you contributed to jazzDude smile

also if anyone wants to convert it to lite-c as well it'd be helpful for any lite-c users

edit: aspect fix done
Posted By: Quad

Re: Add support for most standard and widescreen resolutions - 06/26/08 22:37

change function to this and it goes lite-c laugh

function set_resolution(int res_,int wide_,int _depth,int _window)
Posted By: mpdeveloper_B

Re: Add support for most standard and widescreen resolutions - 06/26/08 23:53

laugh i'll add that in the post, or you could post it in lite-c contributions laugh
Posted By: MichaelGale

Re: Add support for most standard and widescreen resolutions - 07/19/08 08:28

Please don't use the "notify moderator" button if you wish to make a post sticky. If the moderator team or an administrator considers a post especially useful or important, we will make it sticky. This post, however, is useful, but not useful enough to become a sticky post. To be honest, I think this request was a bit ridiculous wink
Posted By: Michael_Schwarz

Re: Add support for most standard and widescreen resolutions - 07/19/08 13:43

Just saw this, awesomeness!

Thanks for the contribution!
© 2024 lite-C Forums