Topic: Checking the video card for the game engine rendering...  (Read 1002 times)

0 Members and 1 Guest are viewing this topic.

Offline toasty0

  • Application.Quit();
  • Captain
  • *
  • Posts: 8045
  • Gender: Male
Checking the video card for the game engine rendering...
« 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);
MCTS: SQL Server 2005 | MCP: Windows Server 2003 | MCTS: Microsoft Certified Technology Specialist | MCT: Microsoft Certified Trainer | MOS: Microsoft Office Specialist 2003 | VSP: VMware Sales Professional | MCTS: Vista

Offline toasty0

  • Application.Quit();
  • Captain
  • *
  • Posts: 8045
  • Gender: Male
Re: Checking the video card for the game engine rendering...
« Reply #1 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. 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.

MCTS: SQL Server 2005 | MCP: Windows Server 2003 | MCTS: Microsoft Certified Technology Specialist | MCT: Microsoft Certified Trainer | MOS: Microsoft Office Specialist 2003 | VSP: VMware Sales Professional | MCTS: Vista