Report: DirectDraw in Managed DirectX9
I took a look into Managed DirectX 9 with C#. I finally (after HOURS) managed to plot some lines via DirectDraw.
I'm not asking any questions here, I'm just reporting what I observed.
The documentation is non-existant. In order to know of what type collections that use the IEnumeration interface are you have to use:
Code:
if(en.MoveNext())
Console.WriteLine(en.Current.GetType().FullNam);
because the docs don't mention of which type the objects actually are.
An example is the devices collection of DirectInput.
This also means that I had many guesses and many exceptions before I found out how to correctly initialize DirectDraw.
Then there is something I consider a bug in the Lock method. It returns a 2d byte array that represents the surface memory. This array has the same dimensions as the surface. This is nice if you are in 256-color mode. But in 16-, 24- or 32-bit modes where each pixel takes more than one byte this suddenly has the strange consequence that you can only access a part of the image!
There is a workaround because you can replace that pointer with one of your own.
The whole thing was awfully slow (with abot 5 fps) but that might have been my (very sloppily programmed) framework. I had to write it myself because the DX app wizard for C# doesn't work.
Tomorrow I'm going to profile my framework and see where it eats the speed. Probably in the allocation of the surface memory every frame...
Good job MS :rolleyes: