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
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
解决方案 »
- c# webbroswer控件 获取动态网页的输出内容
- C#的DES加密问题,在线等
- 如何将填在datagridview单元格的内容存入数据库
- C# 窗体 刷新界面的办法
- 象金山词霸、ms Office 2003等大型软件的安装序列号是如何产生的,并且如何制作到安装软件中的?象InstallShield这样的安装制作软件能实
- 强人!在winform datagrid的任意行位置插入一新行
- 从VB转向.NET,介绍一本不是太基础的.NET的书50分相送!谢谢
- C#如何将声音文件路径存到数据库中
- 请问怎么取2003-9-9 12:34:34里面的时间?急!
- 请教,在一个工程里以(.csproj.user), (.csproj), (.sln), (.suo), (.projdata), (.scc)为后缀的文件都是些什么文件,有些什么用?
- C# 调用 C++ DLL传参数问题
- 谁用过明华的读卡器?
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;
}
[email protected]