Tutorial *32*

If you are using a small computer such as a sub-notebook, you may find that you cannot run quake2 full screen, because the screen is an odd size. The Sony Viao Picturebook C1VFK for example has a screen which is 1024x480 pixels. The only mode that it will run full screen is 640x480 and that leaves black borders to left and right.

This simple engine mod, will allow you to add new video modes. If your screen is a different size to the Viao in my example, then simply change the values in the lines that you add.

1

In the following 4 files
irix\vid_so.c
linux\vid_so.c
null\vid_null.c
win32\vid_dll.c

Change



vidmode_t vid_modes[] =

{

	{ "Mode 0: 320x240",   320, 240,   0 },

	{ "Mode 1: 400x300",   400, 300,   1 },

	{ "Mode 2: 512x384",   512, 384,   2 },

	{ "Mode 3: 640x480",   640, 480,   3 },

	{ "Mode 4: 800x600",   800, 600,   4 },

	{ "Mode 5: 960x720",   960, 720,   5 },

	{ "Mode 6: 1024x768",  1024, 768,  6 },

	{ "Mode 7: 1152x864",  1152, 864,  7 },

	{ "Mode 8: 1280x960",  1280, 960, 8 },

	{ "Mode 9: 1600x1200", 1600, 1200, 9 },

	{ "Mode 10: 2048x1536", 2048, 1536, 10 }

};

to



vidmode_t vid_modes[] =

{

	{ "Mode 0: 320x240",   320, 240,   0 },

	{ "Mode 1: 400x300",   400, 300,   1 },

	{ "Mode 2: 512x384",   512, 384,   2 },

	{ "Mode 3: 640x480",   640, 480,   3 },

	{ "Mode 4: 800x600",   800, 600,   4 },

	{ "Mode 5: 960x720",   960, 720,   5 },

	{ "Mode 6: 1024x768",  1024, 768,  6 },

	{ "Mode 7: 1152x864",  1152, 864,  7 },

	{ "Mode 8: 1280x960",  1280, 960, 8 },

	{ "Mode 9: 1600x1200", 1600, 1200, 9 },

	{ "Mode 10: 2048x1536", 2048, 1536, 10 },  // c14 Add a comma at the end here

	{ "Mode 11: 1024x480", 1024, 480, 11 }     // c14 new line

};

This adds a new mode to the array of vidmode_t structures that the engine knows about. The vidmode_t structure has 4 members, the text name of the mode, the width in pixels, the height in pixels and the mode number. The lines of code after this, define the total number of modes available, and because it is done with reference to the array which we just changed, all of the rest of the code copes with this additional mode just fine.

The 4 files that need changing, are defined for different platforms, if you are building for Windows for example, then only the file

win32\vid_dll.c
will actually have any effect. I recommend you change all 4 now, just in case you decide later to port your code to another platform.

Now you can change mode by typing gl_mode 11 at the console. However, the Video menu does not yet know about the new mode and you cannot select it from the menu. If you are in mode 11 and you call up the video menu, the game will crash.

2

In the following 3 files:
irix\vid_menu.c
linux\vid_menu.c
win32\vid_menu.c

Change



/*

** VID_MenuInit

*/

void VID_MenuInit( void )

{

	static const char *resolutions[] =

	{

		"[320 240  ]",

		"[400 300  ]",

		"[512 384  ]",

		"[640 480  ]",

		"[800 600  ]",

		"[960 720  ]",

		"[1024 768 ]",

		"[1152 864 ]",

		"[1280 960 ]",

		"[1600 1200]",

		"[2048 1536]",

		0

	};

to



/*

** VID_MenuInit

*/

void VID_MenuInit( void )

{

	static const char *resolutions[] =

	{

		"[320 240  ]",

		"[400 300  ]",

		"[512 384  ]",

		"[640 480  ]",

		"[800 600  ]",

		"[960 720  ]",

		"[1024 768 ]",

		"[1152 864 ]",

		"[1280 960 ]",

		"[1600 1200]",

		"[2048 1536]",

		"[1024 480]", // c14 new line

		0

	};

Here we have done a similar thing, in order to tell the video menu about the new mode. This is simply an array of strings which are used to show the various mode options. The end of the array is marked by a null value, so the menu system does not run off the end. When you select a mode, the string is displayed on the screen, and the mode is set. If you pick the 11th item, then the mode is set to mode 11. (The first item is the 0th item really).

That's all there is to it. Compile quake2.exe and run it.

Now you should find a new item on the video menu, this is dealt with by the second change. And it will allow you to select a new mode (mode 11). To change mode from the command line, you can use gl_mode 11 at the console.



 
Not logged in
Sign up
Login:
Passwd: