SlimDX loading Image?
I am trying to load an image with SlimDX and render it/display it.
Here is my code:
MessagePump.Run(form, () =>
{
device.Clear(SlimDX.Direct3D9.ClearFlags.Target,
Color.Black, 1.0f, 0);
device.BeginScene();
SlimDX.Direct3D9.Texture tx =
SlimDX.Direct3D9.Texture.FromFile(device,
@"C:\d.jpg");
sprite.Begin(SlimDX.Direct3D9.SpriteFlags.None);
sprite.Draw(tx, new Color4(0.5f, 0.5f, 1.0f));
sprite.End();
device.EndScene();
});
And the initialization of the device
SlimDX.Direct3D9.PresentParameters presentParams = new
SlimDX.Direct3D9.PresentParameters
{
BackBufferWidth = form.Width,
BackBufferHeight = form.Height,
DeviceWindowHandle = form.Handle,
BackBufferCount = 3,
Windowed = true
};
device = new SlimDX.Direct3D9.Device(new SlimDX.Direct3D9.Direct3D(), 0,
SlimDX.Direct3D9.DeviceType.Hardware, form.Handle,
SlimDX.Direct3D9.CreateFlags.HardwareVertexProcessing, presentParams);
Now i am new to this directx stuff. But from what i can it, it should
work. I get a texture, draw it with a sprite. And the device is running at
that time.
Though that being said, i am not fully clear to what´s going on behind the
scenes here, but i think that loading an image and display it shouldn´t be
That hard to do, so hopefully i am not totally lost with it.
No comments:
Post a Comment