当我使用DirectX库时,C#表单应用程序上不显示表单屏幕
我有这样的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace Creating_A_Basic_DirectX
{
public partial class Form1 : Form
{
private Device device;
public Form1()
{
InitializeComponent();
InitializeDevice();
}
private void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0);
device.Present();
}
}
}
并且我运行了此代码,但表单屏幕未显示。 当我删除DirectX代码时,其运行。 我更改属性(双击)->构建->平台目标-> x86