namespace SharpGL.RenderContextProviders { using System; /// /// Render context provider for working with an external render context /// public class ExternalRenderContextProvider : RenderContextProvider { /// /// The window handle. /// protected IntPtr windowHandle = IntPtr.Zero; /// /// Initializes a new instance of the class. /// /// The existing window handle. /// The handle to the existing render context. /// The handle to the existing device context. public ExternalRenderContextProvider(IntPtr windowHandle, IntPtr renderContextHandle, IntPtr deviceContextHandle) { this.windowHandle = windowHandle; this.deviceContextHandle = deviceContextHandle; this.renderContextHandle = renderContextHandle; } /// /// Destroys the render context provider instance. /// public override void Destroy() { // Don't destroy the external context! // base.Destroy(); } /// /// Blit the rendered data to the supplied device context. /// /// The HDC. public override void Blit(IntPtr hdc) { if (this.deviceContextHandle != IntPtr.Zero || this.windowHandle != IntPtr.Zero) { //Swap the buffers. // Win32.SwapBuffers(deviceContextHandle); } } /// /// Makes the render context current. /// public override void MakeCurrent() { // if (renderContextHandle != IntPtr.Zero) // Win32.wglMakeCurrent(deviceContextHandle, renderContextHandle); } } }