In this tutorial, you'll learn how to change the sample program (GTEST.EXE)
to let you use the screen resolution that was chosen at the beginning of the demo.
This was written by Ewen.
Most of the changes are not very complicated, but we should probably try to help each other out, and minimise effort
duplication?!?
ok, here we go...remember to give or take a few when it comes to line numbers...
The first change appears in GENVS.C around about line
324.
I have added three lines of code after the line :
DrvList_PickDriver(hInstance, GDemohWnd, Engine, &Driver, &DriverMode);
The purpose of the change is to read the chosen screen resolution into CWidth and
CHeight. Then to create the menus and text sub-system based upon the chosen screen
resolution (note that this requires changes to GMENU.C - see below).
// Start up the engine
//
Engine = geEngine_Create(GDemohWnd, AppName);
if (!Engine)
GenVS_Error("Could not intialize the Genesis engine.\n");
//undone
// Text_Create( Engine ); // moved lower
// GMenu_Create( Engine );
geEngine_EnableFrameRateCounter(Engine, ShowStats);
#if 0
//if (!SetDriverMode("(D3D)3Dfx", CWidth, CHeight))
//if (!SetDriverMode("(D3D)Pri", -1, -1))
//if (!SetDriverMode("(D3D)Pri", CWidth, CHeight))
if (!SetDriverMode("Glide", CWidth, CHeight))
//if (!SetDriverMode("Soft", -1, -1))
//if (!SetDriverMode("Soft", CWidth, CHeight))
GenVS_Error("Could not set driver mode.\n");
#else
DrvList_PickDriver(hInstance, GDemohWnd, Engine, &Driver, &DriverMode);
geDriver_ModeGetWidthHeight(DriverMode, &CWidth,
&CHeight); // added by Ewen (get the mode that was chosen from the driver menu)
Text_Create( Engine );// added by Ewen (moved here so that the menus appear centered)
GMenu_Create( Engine );// added by Ewen (moved here so that the menus appear centered)
The second change appears in DRVLIST.C around about line
89.
To show all of the drivers that were detected by the engine, comment out the line in red below. Then the driver
dialog box will show all the valid video modes.
geDriver_ModeGetWidthHeight(Mode, &Width, &Height);
//if (Width == 640 && Height == 480) //changed
by ewen
{
dinfo = malloc(sizeof(*dinfo));
if (!dinfo)
{
DestroyDriverList(DriverList);
return NULL;
}
dinfo->diNext = DriverList;
DriverList = dinfo;
dinfo->diDriver = Driver;
dinfo->diMode = Mode;
}
Other files that must be changed are:
These files must have the 2 lines :
FINALLY: You must change the Render World function in CLIENT.C around line 2014.
This change makes the client render each frame? at the chosen resolution. //=====================================================================================
// RenderWorld
//=====================================================================================
static geBoolean RenderWorld(Client_Client *Client, Host_Host *Host, float Time)
{
GE_Rect Rect;
assert(Host);
assert(Client);
assert(Host->Engine);
if (!Host->World)
return GE_TRUE;
Rect.Left = 0;
Rect.Right = CWidth - 1; //changed by ewen was
639
Rect.Top = 0;
Rect.Bottom = CHeight - 1; // changed by ewen was
479-60
SetupCamera(Client->Camera, &Rect, &Client->ViewXForm);
if (!geEngine_RenderWorld(Host->Engine, Host->World, Client->Camera, Time))
return GE_FALSE;
}
Now, rebuild the program and run it. You should be able to choose a resolution and then run the program at that
resolution.
Any problems contact Ewen.