Game Development Community

Changing the Default Window Size from 800x600 to another Size

by Pisal Setthawong · 05/14/2008 (8:25 am) · 0 comments

Without an existing Preference file, TGE will create windows at the size of 800x600. As modern monitors and LCDs can get a much higher resolution, it might be preferable to generate the default pref that it would create a window with a higher default resolution. This article explains shortly how to modify that behavior by modifying the core of TGE. (might only works in Win32 platform)

In the file engine/platformWin32/winWindow.cc there is a function that deals with the initialization of the TGE game window: static void InitOpenGL().

In the function you will notice the following code in the function:
// Get the video settings from the prefs:
   const char* resString = Con::getVariable( "$pref::Video::resolution" );
   char* tempBuf = new char[dStrlen( resString ) + 1];
   dStrcpy( tempBuf, resString );
   char* temp = dStrtok( tempBuf, " x[[4f3a036551ac1]]" );
   U32 width = ( temp ? dAtoi( temp ) : 800 );
   temp = dStrtok( NULL, " x[[4f3a036551ac1]]" );
   U32 height = ( temp ? dAtoi( temp ) : 600 );
   temp = dStrtok( NULL, "[[4f3a036551ac1]]" );
   U32 bpp = ( temp ? dAtoi( temp ) : 16 );
   delete [] tempBuf;

Basically the function will try to query if there is an existing $pref::Video::resolution in your game. If it doesn't find it, it will generate a new default resolution. If you want to change the default width, height, and resolution, change the constants from 800, 600, 16 respectively. When the game ends normally, this pref is over-written with your corrent resolution.

This is useful if you don't want to modify the display resolution after clearing the pref files.

For a short note, I've only tested this in a Win32 machine on TGE 1.5.2.

About the author

An Educator moonlighting as the Technical Lead at the indie game development studio called Flying Pig Game Studio