Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The type or namespace name 'Device' could not be found (are you missing a using directive or an assembly reference... what to do to resolve this???

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Samples.DirectX.UtilityToolkit;



namespace BattleTank2005
{
public partial class GameEngine : Form
{
public GameEngine()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque, true);
// Get the ordinal for the default adapter
int adapterOrdinal = Manager.Adapters.Default.Adapter;
// Get our device capabilities so we can check them to set up the
// CreateFlags
Caps caps = Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware);
CreateFlags createFlags;
// Check the capabilities of the graphcis card is capable of
// performing the vertex-processing operations
// The HardwareVertexProcessing choice is the best
if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
{
createFlags = CreateFlags.HardwareVertexProcessing;
}
else
{
createFlags = CreateFlags.SoftwareVertexProcessing;
}
// If the graphics card supports vertex processing check if the device
// can do rasterization, matrix transformations, and 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 in windowed mode when we are debugging
#if DEBUG
presentParams.Windowed = true;
#endif
// Now create the device
device = new Device(adapterOrdinal, DeviceType.Hardware, this,
createFlags, presentParams);
// force the window to a standard size
// the provides the correct aspect ratio of 1.33
this.Size = new Size(800, 600);
}
protected override void OnPaint(PaintEventArgs e)
{
deltaTime = FrameworkTimer.GetElapsedTime();
this.Text = string.Format("The framerate is {0}",FrameRate.CalculateFrameRate());
FrameworkTimer.Start();
device.Clear(ClearFlags.Target, Color.DarkBlue, 1.0f, 0);
device.Present();
this.Invalidate();
}

private void GameEngine_Load(object sender, EventArgs e)
{

}
private double deltaTime;
private Device device;
}
}
Posted
Updated 19-Dec-12 19:24pm
v2
Comments
AshishChaudha 20-Dec-12 1:11am    
Share your Code please..
Abhishek Pant 20-Dec-12 1:13am    
check that Reference has been correctly added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900