Dynaverse.net

Off Topic => Engineering => Topic started by: toasty0 on August 02, 2005, 05:48:57 pm

Title: Checking the video card for the game engine rendering...
Post by: toasty0 on August 02, 2005, 05:48:57 pm
int adapterOrdinal=Manager.Adapters.Default.Adapter;

         //Get our device capabilities so we can check them to set up the CreatedFlags
         Caps caps=Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware);

         CreateFlags createFlags;

         //Check the capabilities of the graphics card
         //if able to perform the vertex processing operation
         //The HardwareVertexProcessing choice is best
         if(caps.DeviceCaps.SupportsHardwareTransformAndLight)
         {
            createFlags=CreateFlags.HardwareVertexProcessing;
         }
         else
         {
            creatFlags=CreateFlags.SoftwareVertexProcessing;
         }

         //If the graphics card supports vertex processing check if the devive
         //can do rasterization, matrix transformations, lighting and shading operations
         //This combination provides the fastest game experience
         if(caps.DeviceCaps.SupportsPureDevice && createFlags==CreateFlags.HardwareVertexProcessing)
         {
            createFlags!=CreateFlags.PureDevice;
         }

         //Set up the PresentParameters which determine how the device behaves
         PresentParameters presentParams=new PresentParameters();
         presentParams.SwapEffect=SwapEffect.Discard;

         //Make sure we are windowed mode when we debug
#if DEBUG
         presentParams.Windowed=true;
#endif
         //Create the Device
         device= new Device(adapterOrdinal,
            DeviceType.Hardware,
            this,
            createFlags,
            presentParams);
Title: Re: Checking the video card for the game engine rendering...
Post by: toasty0 on August 02, 2005, 09:01:03 pm
Now I have something in the early stages. We can now detect and display our framerate.

For those of you who're interested in seeing the result of the above code click this link for the zip file download. (http://www.toasty0.com/code/BTAlpha.zip) Simply unzip and double click the BattleTankAlpha2005.exe. It ain't much, but this should give you an idea of the amount of coding that goes into a game.