DirectX Interoperability Technology SampleThis suite of samples shows the .NET Framework interoperability features by using the DirectX components DirectDraw and DirectMusic.Readme Locations
For more information, see the Readme files at <SDK>v1.1\Samples\Technologies\Interop\Basic\DirectX\DirectDraw and<SDK>v1.1\Samples\Technologies\Interop\Basic\DirectX\DirectMusic

解决方案 »

  1.   

    this is VB, C# is same.
      

  2.   

    去下一个DirectX的.net开发包,在英文的msdn上,里面有例子。
      

  3.   

    记得DirectX9下有.net的开发包了。
      

  4.   

    using Microsoft.DirectX;
    using Microsoft.DirectX.DirectDraw;
            private void InitializeDirectDraw()
            {
                SurfaceDescription description = new SurfaceDescription(); // Describes a surface.
                Random randomNumber = new Random(); // Random number for position and velocity.
                ColorKeyFlags flags = new ColorKeyFlags();            displayDevice = new Device(); // Create a new DirectDrawDevice.
                displayDevice.SetCooperativeLevel(this, CooperativeLevelFlags.FullscreenExclusive); // Set the cooperative level.            try
                {
                    displayDevice.SetDisplayMode(screenWidth, screenHeight, 8, 0, false); // Set the display mode width and height, and 8 bit color depth.
                }
                catch(UnsupportedException)
                {
                    MessageBox.Show("Device doesn't support required mode. Sample will now exit.", "UnsupportedException caught");
                    Close();
                    return;
                }
                
                description.SurfaceCaps.PrimarySurface = description.SurfaceCaps.Flip = description.SurfaceCaps.Complex = true;         
                description.BackBufferCount = 1; // Create 1 backbuffer.            front = new Surface(description, displayDevice); // Create the surface using the description above.            SurfaceCaps caps = new SurfaceCaps();
                caps.BackBuffer = true; // Caps of the surface.
                back = front.GetAttachedSurface(caps); // Get the attached surface that matches the caps, which will be the backbuffer.            pal = new Palette(displayDevice, bitmapFileName); // Create a new palette, using the bitmap file.
                pe = pal.GetEntries(0, 256); // Store the palette entries.
                front.Palette = pal; // The front surface will use this palette.
                
                description.Clear(); // Clear the data out from the SurfaceDescription class.
                surfaceLogo = new Surface(bitmapFileName, description, displayDevice); // Create the sprite bitmap surface.
                
                ColorKey key = new ColorKey(); // Create a new colorkey.
                key.ColorSpaceHighValue = key.ColorSpaceLowValue = 0;
                flags = ColorKeyFlags.SourceDraw;
                surfaceLogo.SetColorKey(flags, key); // Set the colorkey to the bitmap surface. 144 is the index used for the colorkey, which is black in this palette.            description.Clear();
                description.SurfaceCaps.OffScreenPlain = true;
                description.Width = 200; // Set the width and height of the surface.
                description.Height = 20;
                
                text = new Surface(description, displayDevice); // Create the surface using the above description.
                text.ForeColor = Color.FromArgb(indexWhite); // Because this is a palettized environment, the app needs to use index based colors, which
                                                             // do not correspond to pre-defined color values. For this reason, the indexWhite variable exists
                                                             // and contains the index where the color white is stored in the bitmap's palette. The app makes use
                                                             // of the static FromArgb() method to convert the index to a Color value.
                text.ColorFill(indexBlack);
                text.DrawText(0, 0, textHelp, false);            for (int i=0; i < numSprites; i++)
                {
                    // Set the sprite's position and velocity
                    sprite[i].posX = (randomNumber.Next()  % screenWidth);
                    sprite[i].posY = (randomNumber.Next() % screenHeight);                 sprite[i].velX = 500.0f * randomNumber.Next() / Int32.MaxValue - 250.0f;
                    sprite[i].velY = 500.0f * randomNumber.Next() / Int32.MaxValue - 250.0f;
                }
      

  5.   

    有.net的开发包,MSDN上面也有类似的例子。
      

  6.   

    有,dx9有,我用过的,是2003summer版的发布的sdkupdate里开始有了
      

  7.   

    2003summer里的那个例子可以给我发一个吗?我装的2004里面没有例子
    [email protected]