Fast pixel drawing in WPF

I would like to write a simple ray tracer using WPF. This is a training project, and so I prefer performance tuning (otherwise I would go for C ++).

I still want a relatively fast pixel draw. A previous question in StackOverflow contains code to achieve this in WPF, by getting a GDI bitmap. From the relatively small number that I know about Windows programming,

  • Gdi slow
  • Directx fast
  • WPF uses DirectX from the bottom (not sure which parts of WPF, though)

Is it possible to access at the pixel level using DirectX (not GDI) through a WPF canvas (or similar)?

I will also consider suggestions for including DirectX API calls in the WPF window (along with other WPF controls), if possible.

Thanks in advance.

+8
c # wpf raytracing
source share
3 answers

Interestingly, using raytracing, writing pixels to the screen will (should) not be slow. However, you can use WriteableBitmap for this purpose. It is definitely fast enough for what you want.

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx

(For information, I use it in this emu / IDE - http://0x10c-devkit.com/ - and it can update the low-resolution display with high performance. There is a source for this in the github repository, the LEM1802 plugin.)

Ah, this bit: https://github.com/kierenj/0x10c-DevKit/blob/master/PluginAPI/NyaElektriska.LEM1802/GPU.cs - see UpdateDisplay .

+5
source share

There is an open source project called Called Direct Canvas, which is a hardware accelerated 2D drawing API that supports vector graphics, multimedia files, extensible pixel shaders, blending modes, and more!

http://directcanvas.codeplex.com/

Demo http://www.youtube.com/user/jdollah69#p/u

+2
source share

Another solution is WriteableBitmapEx . It extends the built-in writeablebitmap.

+2
source share

All Articles