Code4Fun Framework Timer compile issue

Hi,

I am attempting to make use of the QueryPerformanceCounter timer, as detailed in the Coding4FunTutorial.

After following the steps, add a new folder, copy the dxmutmisc.cs file to the project.

I get 133 errors most saying "The type or namespace name DirectX does not exist in the namespace Microsoft( are you missing an assembly reference?)"

ANy direction would be appreciated.

Thanks

Jeff

[446 byte] By [Hooper] at [2007-12-23]
# 1
You need to add DirectX references to your project. Do this by going into the project explorer/solution explorer window, find "references", right-clicking it and selecting "add references". Then select all DirectX assemblies that you need.

-Niko

Nik02 at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

Hi Niko,

Wel I have done that now and the compiler errors have been reduced from 133 to 5, going in the right direction here.

4 of the 5 errors are saying Unsafe code may appear if compiling with /unsafe. And the other says,

The Type or namespace 'Framework' could not be found( are you missing a using directive or an assmbly reference?)

They all refer to the file, dxmutmisc.cs, lines 1365,1694, 2189, 2364, and 2398. Line 2189 is the namespace error and the other 4 are the unsafe items.

Not sure what to make of this.

My first experience with DirectX.

Thanks for the response

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 3

Hi Niko,

I am down to 1 error, the type or namespace name 'Framework' could not be found. I fixed the others by choosing the Allow unsafe code option.

I am thinking I need to add another file to my project from the DirectX common area. Do you know where the Framework namespace might be found?

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 4

If you have a look at the main namespace in the dxmutmisc.cs you will need to add a using statement that references this namespace.

GlennWilson at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 5
There's no need to use QueryPerfomanceCounter if you are using .Net 2.0 use System.Diagnostics.Stopwatch instead.
TheZMan at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 6

Hi Glenn,

That is the namespace that I am using,

using Microsoft.Samples.DirectX.UtilityToolkit;

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 7

Hi ZMan,

I do have .net 2.0 but System.Diagnostics does not have a Stopwatch. Just CodeAnalysis and SymbolStore.

I am thinking that the situation here is that one cannot just add dxmutmisc.sc to a project without adding some related file(s). Not sure though.

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 8

Hi,

I am wondering if there is anything else I need to install to use DirectX besides the SDK? I am pretty much going in circles here trying to resolve the compiler errors. They all point to the.cs files, add a file to the project to get rid of one error and another crops up. Has anyone had any similar problems with the June 2006 release?

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 9

1. No the SDK has everything you need. Since all of the samples use the dx*.cs files they must be complete and working. I've had no problems with the June06 samples. To be honest the June06 samples haven't changed since Dec05.

2. Microsoft.Samples.DirectX.UtilityTookit is probbly not meant to be used alone. All of the samples have the entire dx*.cs set of files added. So yes it probably does need more files.

3. You need to have

using System.Diagnostics

at the top of your file and then you can say

Stopwatch s = new StopWatch();

Check out the GDI samples on MSDN that I did http://blogs.msdn.com/danielfe/archive/2006/05/16/599054.aspx, specifically http://msdn.microsoft.com/coding4fun/gamedevelopment/tenniscs/default.aspx (scroll down to 'Implementing time based animation')

TheZMan at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 10

Hi ZMan,

Adding using System.Diagnostics; does let me create an instance of Stopwatch().

The system timers that I have tried can create an EventHandler(), which is where I have the main portion of my code. The Stopwatch() does not look like it can do that though. Does not have an interval property either.

That second link is pretty decent. I think I will have to check out MSDN also to see how I can make a call every 20ms.

Even after I add all the DirectX .cs files from the common directory I still have various compile issues. Not sure what to make of that. I have added some DirectX references to the project but there are quite a few, not sure which should be added or not.

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 11

Have you added System.Diagnostics to your references? The only other reason That won't work is if you are somehow using .Net 1.1. This is very odd.

Stopwatch is not something that works with events. It just tells you very accuratly how much time has passed. Typically games do not work on ticks, you just run flat out and base your animations on the current times. As you ae finisng the ticking timers are not always accurate anyway. The stuff on MSDN is all GDI but I wrote it with an eye for how to do games in managed DirectX. So the priciples will work just the same.

To see what you need to add to make everything work select the EmptyProject from the DirectX sample browser - it will make a project with all the right references and also include the dx*.cs files. That file will compile and run 100%.Make sure you don't use the EmptyProject for managed DirectX 2 beta.

TheZMan at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 12

Hi,

I am able to create an instance of the Stopwatch by adding using System.Diagnostics; , there is not a reference selection though.

I have VS2005 and .NET 2.0.

That System Browser looks nice. I am going to try that out.

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 13

Hi,

One other note. That empty project did compile and run.

And the files and references in it are the same as the one I have that does not work.

Thanks

Jeff

Hooper at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...