public bool InitializeGraphics()
{
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed=true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
sprite = new Sprite(device);
//Image File をロードしてサイズを取得
Bitmap bmp= new Bitmap(ImgFile);
width = bmp.Width;
height = bmp.Height;
bmp.Dispose();
Console.WriteLine("Width={0}, Height={1}", width, height);
ClientSize = new System.Drawing.Size(width, height);
texture = TextureLoader.FromFile(device, ImgFile, width, height, 0,
Usage.None, Format.A8R8G8B8, Pool.Managed, Filter.None, Filter.None, unchecked((int)0xFF000000));
return true;
}
catch (DirectXException)
{
return false;
}
}
|