Graphics rendering in C #

Is there any other way to render graphics in C # outside of GDI + and XNA ?

(To develop a tile map editor.)

+7
c # gdi + xna rendering
Sep 12 '08 at 2:56
source share
6 answers

SDL.NET is a solution that I love. If you need 3D on top of it, you can use Tao.OpenGL to render inside it. It is a fast, industry standard ( SDL , that is) and cross-platform.

+8
Sep 12 '08 at 2:59
source share

Yes, I wrote a Windows Forms control that wraps DirectX 9.0 and provides direct pixel level control on the video surface.

Actually, I wrote another post on Stack Overflow asking if there are other more suitable approaches: Unsafe C # and pointers for 2D rendering, good or bad?

While this is relatively high performance, it requires an unsafe compiler option because it uses pointers to access memory efficiently. Hence the reason for this earlier post.

This is a high level of necessary steps:

  • Download the DirectX SDK.
  • Create a new C # Windows Forms project and refer to the installed Microsoft DirectX build.
  • Initialize a new DirectX device object with presentation parameters (window, rear buffering, etc.).
  • Create the device, taking care of the recording of the β€œStep” surface and the current display mode (bits per pixel).
  • When you need to display something, Lock backbuffer surface and save the returned pointer to the beginning of the surface memory.
  • Use pointer arithmetic, calculate the actual pixel position in the data based on the height of the surface, bits per pixel and the actual x / y pixel coordinate.
  • In my case, for simplicity, I stick with 32 bpp, that is, setting a pixel is as simple as: * (surfacePointer + (y * pitch + x)) = Color.FromARGB (255,0,0);
  • When finished drawing, Unlock surface of the back buffer. Imagine a surface.
  • Repeat step 5 as necessary.

Remember that with this approach, you need to be very careful in checking the current display mode (step and bit per pixel) of the target surface. You will also need to have a strategy to solve the problem of resizing the window or changing the screen format while your program is running.

+3
Sep 12 '08 at 3:02
source share
  • Managed DirectX (Microsoft.DirectX namespace) for faster 3D graphics. This is a solid .NET cover over the DirectX API that has little performance for creating .NET objects and sorting. If you have not written a fully functional modern 3D engine, it will work fine.

  • Window Presentation Foundation (WPF) (Windows.Media namespace) is the best choice for 2D graphics. Also has limited 3D capabilities. Designed to replace Windows Forms with a vector, hardware accelerated resolution-independent frame. Very convenient, it supports several options for user controls, resources, data binding, events and commands ... also has several WTFs. Speed ​​is usually faster than GDI and slower than DirectX, and largely depends on how you do something (something works 60 times faster after rewriting in a smart way). We have successfully implemented 3 1280x1024 screens, full of real-time indicators, graphs and charts on one (and not the best) PC.

+2
Sep 12 '08 at 4:33
source share

You can try looking in WPF using Visual Studio and / or Expression Blend. I'm not sure how sophisticated you are, but it should be able to handle a simple editor. Check out this MSDN article for more information.

+1
Sep 12 '08 at 3:21
source share

You can look at the Cairo graphic library . The Mono project has bindings for C #.

0
Nov 13 '08 at 13:09
source share

Cairo is an option. I am currently rewriting my mapping software using both GDI + and Cairo. Other features include a tile map generator.

0
Mar 30 '09 at 13:37
source share



All Articles