FriendsOfCADability/CADability

Reimplementation of PaintToOpenGL

Closed this issue · 0 comments

dsn27 commented

If habe been working on a reimplementation of PaintToOpenGL is the last couple of weeks.
The first result can be seen in this Branch

Advantages

  1. Each instance has it's own OpenGL instance
  2. Each instance is Disposable on it's own
  3. Handle recreation is now possible
  4. Finalizer-Free implementation

Details
1. Each instance has it's own OpenGL instance
Each instance of the CadControl now uses a seperate instance of OpenGL. No resources are shared between different instances.

2. Each instance is Disposable on it's own
Each instance of CadControl can now be disposed seperatly. That means alle OpenGL resources of this instance are released we the Control is disposed.

3. Handle recreation is now possible
It's now possible to use the CadControl even when the Handle needs to be recreated. This can happen in a few scenarios.
See this Stackoverflow page on how to force this.

4. Finalizer-Free implementation
The new implemenation does not contain any Finalizers. One of the disadvantages of Finazlizers is the fact that they are run in a different thread by the GC. This can cause all kind of problems with OpenGL. All cleanup is now done in the Dispose methods.

Most of the work for handling OpenGL resources is now done by the OpenGLResourceManager class.

Open issues:

  1. The HandleDestroyed and HandleCreated event are raised multiple times.
    It is unkown why this happens.

  2. The gDEBugger will report Memory Leaks after recreating the handle. But it's uncertain wether this warning is because of wglShareLists or this is a real problem.

  3. Reinit is not supported yet. If you use the Tabbed View from DevExpress the Control Handle will be destroyed and created without setting RecreatingHandle to true.