Patrick
Patrick

Reputation: 2583

Does C# natively use GPU for graphics?

I'd like to draw heavy usage graphics in the fastest way. If I use standard C# graphics callbacks (es.graphics.drawline) am I doing it right? Or am I to use different libraries?

Upvotes: 19

Views: 12658

Answers (1)

adv12
adv12

Reputation: 8551

Graphics.DrawLine is a GDI+ call. If you're using Windows Forms and doing your drawing with the System.Drawing classes, you're using GDI+, which is not hardware-accelerated. To get hardware acceleration, you need to use WPF in place of WinForms or draw with Direct3D/Direct2D. The latter two (Direct3D/Direct2D) are COM-based, so you'll need a .NET wrapper. Microsoft wrapped Direct3D for .NET with Managed DirectX followed by XNA. Both (I believe) are now deprecated. There are also third-party wrappers for the DirectX libraries that are more up-to-date.

Edit: I just learned from @HansPassant's comment that GDI+ is 2D accelerated. I thought that only applied to GDI (as opposed to GDI+) because GDI+ handles things like antialiasing that (as I understood it) 2D hardware didn't do. But apparently I was wrong.

Upvotes: 11

Related Questions