Tech Off Thread

119 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Discuss the Beginning Game Development series on Coding 4 Fun

Back to Forum: Tech Off
  • User profile image
    Minh

    I think the problem stems from using VS 2005 with the samples. There seems to be some confustion, and I've got my own. The latest DirectX SDK includes Managed DirectX based on the .Net CLR 2.0 that ships with VS 2005. But Tom Miller indicated that it only works on VS 2005 Beta 2.

    So, the safest bet is to install the DirectX SDK PRIOR to the latest version (latest is Oct-2005, I believe) and use VS 2003.

    Otherwise, wait for the next SDK in December if you want to use VS 2005 with it. Warning, the syntax of Managed DirectX will probably have changed significantly enought so that older Code4Fun articles will no longer compile. Hopefully, they'll have updated ones by then.

  • User profile image
    AndyC

    The latest DirectX comes with two versions of managed DirectX the old 1.1 version and a 2.0 beta (which doesn't seem to play nice with 2.0RTM)

    If, when you add the DirectX references, you avoid adding the v2.0 Microsoft.DirectX library and instead only add the older versions (marked v1.1.4322) then everything seems to work okay.

    There do seem to have been a few breaking changes between versions though so if the code was written against the 2.0 beta you might have to amend it slighty or use the beta 2.0 runtime (at least until a new DirectX SDK comes out, which will hopefully not be too long!)

  • User profile image
    tnsneff

       Did you find the toolkit in vb format anywhere? I'd rather not have to d/l c# just to compile this.

       Thanks
          Tom

  • User profile image
    tnsneff

    Hi lordrhys,

       Did you find the toolkit in vb format anywhere? I'd rather not have to d/l c# just to compile it.

       Thanks
          Tom

  • User profile image
    arulk

    Hi,

     I am trying to follow the series in this section.  Can someone tell me how to install Directx SDK for managed code?  I installed direct sdk  9.0 full sdk and followed that by august 2005 update and octorbe 2005 update. However, when I look at the GAC there is only one DLL registered for version 2.0 of CLR. 

     

    Trying to compile the code as given in the article is also giving build errors.

     

    What am I missing?

     

    -Arul

     

  • User profile image
    Minh

    arulk wrote:

    Hi,

     I am trying to follow the series in this section.  Can someone tell me how to install Directx SDK for managed code?  I installed direct sdk  9.0 full sdk and followed that by august 2005 update and octorbe 2005 update. However, when I look at the GAC there is only one DLL registered for version 2.0 of CLR. 

     

    Trying to compile the code as given in the article is also giving build errors.

     

    What am I missing?

     

    -Arul

     

    The DirectX SDK should be all you need. But the Managed DirectX API changes quite frequently -- it's still very young after all. I don't know which SDK version the Code4Fun samples used, but it's entirely possible that the latest SDK breaks those samples. Does any one know if the SDK ships with all older MDX libraries? Or just the latest one?

  • User profile image
    retroGamer

    I think this is one of the best resources that I've seen for building a 3d game in C#. It's much more direct and to the point than any of the books I've seen on the subject.
    When will part 6 come out? it looks as though the earlier parts came out about once a month, but it's been 2 months since part 5 came out. Derek, if your reading this, please post part 6 soon!

  • User profile image
    ngbrito

    I downloaded the sample code and found out that there is a bug in the VB sample:

    In the GameEngine_Load event handler, instead of:

    Me.SetStyle(ControlStyles.AllPaintingInWmPaint And ControlStyles.Opaque, True)

    It should be:

    Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)

    i.e. "Or" instead of "And"

  • User profile image
    aJanuary

    Anyone know how I would go about rendering it properly to a panel. I have set it up so that the device is linked to the panel, but I want to not only render the device, but also render the rest of the controls as normal.
    If I use the OnPaint method, Windows takes over and repaints the panel itself. If I use the DoEvents, the application becomes very sluggish (and tbh, I've not been able to get it to render properly with a while loop anyway, Windows still takes over the painting).


    [UPDATE]
    I got round it by creating my own control that inherits from UserControl (I didn't really need the panel behaviour). This has the added advantage of abstracting all my code into one componant (including device initialisation and rendering).

  • User profile image
    ngbrito

    Hi,

    In part IV, the GameEngine.CheckForInput method is not prepared to handle Mouse.MouseButtons returning null which is what happens if you lose the device because you reacquire it but don't refresh the _state and _buttonBuffer internal variables.

  • User profile image
    ngbrito

    In the code you normally have:

    _device.Acquire();
    _device.Properties.AxisModeAbsolute = false;

    At least in my PC (Windows 2000) the second line always causes an exception! Apparently, you may only change this property before acquiring the device and as such the code should be:

    _device.Properties.AxisModeAbsolute = false;
    _device.Acquire();

  • User profile image
    ngbrito

    Hello,

    Since all the vertex buffers, materials and textures of all the units of a certain class (e.g. tank) are exactly the same, shouldn't that data be stored in static variables to avoid memory duplication?

    Bye

  • User profile image
    ngbrito

    Hello,

    I'm not sure what is going on but I'm sure that there is something wrong in the program.

    When the pitch is -PI/2 (-90º) or PI/2 (90º) you should be looking straight down/up and as such you should have the bottom/top skybox face stright in front which means that you should only see the bottom/top face. But if you look at the application you will notice of you see exactly half of the bottom/up and side faces which means that you pitch is only but instead you will see that it is appearing at an angle of -PI/4 (-45º) or PI/4 (45º).

    What is going on here?

  • User profile image
    MadKiwi

    Great tutorials, I have learnt a lot.

    I noticed a couple of things:

    The formula for strafing in the Tutorial 6 C# code seems to be wrong.

    Change this line in the MoveCameraPosition method:

    _z += z * (float)Math.Cos(_heading) + x * (float)Math.Sin(_heading);

    to:

    _z += z * (float)Math.Cos(_heading) - x * (float)Math.Sin(_heading);

    Also, because of the rounding in this division the camera doesn't move when you move the mouse slowly. To change this change the following (in GameEngine.cs):

    _camera.MoveCameraLeftRight(_mouse.State.X / 10); _camera.MoveCameraUpDown(_mouse.State.Y / 10);

    to:

    _camera.MoveCameraLeftRight(_mouse.State.X / 10f); _camera.MoveCameraUpDown(_mouse.State.Y / 10f);

  • User profile image
    rauhanlinna​ke

    I found these articles yesterday, and they seems to be gewd Big Smile

    I noticed, that fullscreen mode doesen't work in the article. You must alter the device creation just a little:

    #if DEBUG
    presentParams.Windowed = true;
    #else
    presentParams.Windowed = false;
    presentParams.DeviceWindow = this;
    presentParams.BackBufferFormat = Format.X8R8G8B8;
    presentParams.BackBufferHeight = this.Size.Height;
    presentParams.BackBufferWidth = this.Size.Width;
    presentParams.PresentationInterval = PresentInterval.Default;
    #endif

    And if you set DEBUG in VS Express, you can't start full screen mode with CTRL+F5, so I myself did not define DEBUG.

  • User profile image
    A Programmer


    gopakumator wrote:im getting some error while comiling the code in Article III (DirectX II):
    Im using VS.NEt 2004 and i have .NET Framework 1.1 redistrutable installed.
    The eroor i get is this...
    An unhandled exception of type 'Microsoft.DirectX.Direct3D.InvalidCallException' occurred in system.windows.forms.dll



    "I'm getting the same error. I believe it is because we're trying to compile this tutorial using Visual Studio 2003 instead of the recommended Visual Studio 2005."


    I'm using Visual C#2005 Express Edition and finding the same sort of problem.

    The solution is to download and install the code for each session and go back through it to find the bits and pieces that the author forgot to mention in the article. I found a couple of lines here and there he forgot to mention in the last two articles.

    This last error was particularly weird in that the apparent fix was to add the "angle" variable and assignment statement. It doesn't look like it is actually used anywhere in the default code, but adding it fixed the exception! Perplexed

  • User profile image
    A Programmer

    I downloaded, built and ran the C# code included with the latest (session 6) edition of the article. The results were not quite what I had expected:

    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="BattleTank2005"
      StackTrace:
           at BattleTank2005.GameEngine.Render() in E:\Documents and Settings\Michael\My Documents\MSDN\BattleTank 2005 Part VI - CS\BattleTank2005\GameEngine.cs:line 72
           at BattleTank2005.GameEngine.OnPaint(PaintEventArgs e) in E:\Documents and Settings\Michael\My Documents\MSDN\BattleTank 2005 Part VI - CS\BattleTank2005\GameEngine.cs:line 64
           at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
           at System.Windows.Forms.Control.WmPaint(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.ContainerControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at BattleTank2005.Program.Main() in E:\Documents and Settings\Michael\My Documents\MSDN\BattleTank 2005 Part VI - CS\BattleTank2005\Program.cs:line 22
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

  • User profile image
    A Programmer

    Something very strange is happening on my system. After adding the code to fix the full screen mode (mentioned above), but NOT disabling DEBUG - which means that the code should NOT be compiled and therefore should make no practical difference - the game now works.

    Yes, the C# Express IDE showed the new code as greyed out.

    The only difference between then (when it didn't work) and now is that my XP Professional system has been rebooted.


    This PC has been running for years and has been in a production state all that time. Something tells me that something is not quite right with this IDE!

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.