Sign in to follow this  

[.net] Using DirectX9

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone ! I wanted to start using DirectX with C#, but I've got a (major) problem. In the tutorial, they say to use the following code:
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
The problem is that my compiler doesn't recognize neither DirectX nor Direct3D. I downloaded the DirectX SDK while I was programming in C++ but now I am going toward C# so it must not be the problem... unless there is a DirectX SDK for C# too... which would be a real pain since I'm on 56kbps and these downloads are something like 50Mo+ ... is there something really stupid I didn't see yet ? I used the following code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace DirectX_Tutorial
{
     public class WinForm : System.Windows.Forms.Form
     {
         private Device device;
         private System.ComponentModel.Container components = null;

         public WinForm()
         {
              InitializeComponent();
         }

         protected override void Dispose (bool disposing)
         {
              if (disposing)
              {
                   if (components != null)
                   {
                        components.Dispose();
                   }
              }
              base.Dispose(disposing);
         }


         private void InitializeComponent()
         {
              this.components = new System.ComponentModel.Container();
              this.Size = new System.Drawing.Size(500,500);
              this.Text = "DirectX Tutorial";
         }

         static void Main() 
         {
              using (WinForm our_dx_form = new WinForm())
              {
                   Application.Run(our_dx_form);
              }
         }
     }
}

Share this post


Link to post
Share on other sites
MS bundles the managed and unmanaged version of the SDK into 1 package. If you have indeed downloaded the latest SDK, just be sure you made references to the DX libraries in your C# projects.

Share this post


Link to post
Share on other sites
How would I do that ? I referenced the libraries through Tools=>Options=>Projects in MSV... I even referenced a lot more folders than I should have but I thought it would fix my problem but it didn't. What exact folder would I have to link ?

[Edited by - White Scorpion on January 1, 2005 12:33:20 AM]

Share this post


Link to post
Share on other sites
I'm using the C# Express but I know adding references in other IDE's are straightforward. There's no need to use the Tools menu. I do the following
1) Open a project
2) On the Solution Explorer, right click the "Reference" node, then click "Add Reference",
3) Find the DirectX assemblies under the .NET tab.
4) click OK

That would be all. You should see new nodes under the "Reference" besides the default System, System.Windows.Forms, System.Drawing

If you can't see any DX assemblies, then you don't have the managed version of DX. Be sure to download the latest SDK. It's big file though :(

Share this post


Link to post
Share on other sites
::I even referenced a lot more folders than I should have

In C# you do not reference FOLDERS, but DLL's. Assemblies. Directly.

And you do not do yo through the fancy dialog you did, but through the references node IN the project. Just look at the project in the Solutions explorer. There is a node "references". THere you can add additional references.

And while you search, please at least have ONE look at the documentation. Helps to find your way around the IDE without making too stupid mistakes.

Share this post


Link to post
Share on other sites
you have to add them on every project

avoid using wizard or DX project templates if you're just starting to program directx, so this means you have to manually load the reference

enjoy!!!

Share this post


Link to post
Share on other sites

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this