views:

661

answers:

4

Hello,

I have developed a quite large application using MFC. Naturaly, I used GDI for drawing, CCmdTarget for event routing, and the document-view architecture. It was a convenient development path.

Now, the client is interested in converting this application to .Net. I would prefer (and they too) writing the new product in C#.

The application displays and interacts with thousands of graphic objects, so I figured going with GDI+, although seems natuaral, can cause performance issues, So I am thinking of using OpenGL, specifically - OpenTK - as the graphics library (it's 2D).

I know that OpenGL works differently that these Windows APIs, which rely on Invalidation of portion of the screen. OpenGL has a rendering loop which constantly draws to the screen.

My question is: Is this an acceptable way to go, thinking of:

  • performance - will the users need special graphics cards (hardware?). It is graphics intensive, but it's not a high-end game

  • printing and print preview - are these things complex to achienve?

  • multiple selection and context menus

Is this library goes well inside windows forms?

thank you :)

+5  A: 

I don't think so. Use WPF if you can or DirectX if you can't.

I know it might not be fair but if I'm programming on .NET (microsoft) on windows (microsoft) I'd rather use DirectX ... which is also from microsoft.

As a side note: don't reinvent the wheel. Recoding user controls in open-gl can be very time consuming, if you do make sure you have a good reason.

Jorge Córdoba
+1 for WPF, neutral on DirectX/OpenGL
Henk Holterman
A: 

I have no experience with C#, but I have once built a layer system for a drawing program that used openGL for rendering.

To make this layer I asked openGL for the current framebuffer and converted it to an image to use as a texture under the current canvas. So I guess from there its pretty easy to go to printing and print preview.

Emile Vrijdags
A: 

In my experience developing CAD-like software, the benefits of OpenGL and DirectX are fast depth testing, smooth rotation and panning, lighting and powerful texture capabilities. Obviously there are other benefits but, despite what most tutorials would lead you to believe, implementing a rendering system using either of these APIs is a significant undertaking and should not be taken lightly.

Specifically:

  • If it is a 2D app and you already have it implemented in GDI then switching to GDI+ will be much easier. Additionally, on modern hardware, 2D GDI or GDI+ can be about as fast as 2D OpenGL or DirectX. And ultimately, the end-user probably won't notice the difference, especially with double buffered support in GDI+.

  • You do not need (and probably don't want) a continuous rendering loop for your app. In OpenGL and DirectX you can explicitly invalidate the window when your scene changes.

  • If you go with OpenGL or DirectX you will need to consider putting your objects into display lists or vertex arrays (buffers) for fast drawing. This is not difficult but managing objects in this way adds complexity to the system and will most likely significantly change the architecture of your rendering system.

  • Printing in either OpenGL or DirectX can also be tedious. On the one hand you can render to a bitmap and print that out. However, for high quality images you may want vectorized images instead, which are difficult to produce with either of these rendering frameworks.

  • I would also stay away from writing GUIs in OpenGL or DirectX...unless you're really looking for a challenge ;~)

  • Finally, and this is just an annoyance from an install perspective, the Managed DirectX run-time library that must be installed on the user's machine is around 100 MB.

Jeff L
Yaron
A: 

Direct X and Open GL much faster than GDI+.

imam kuncoro