JuicyGraphics/src/SharpGL/RenderContextProviders/ExternalRenderContextProvid...
2019-02-14 15:46:16 +01:00

59 lines
2.0 KiB
C#

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