public void Dispose() { lock (this.object_0) { if (!(this.intptr_2 != IntPtr.Zero)) { return; } if (WGL.wglDeleteContext(this.intptr_2) == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception(lastWin32Error, string.Format("OpenGL DeleteContext call was not successful, error code: {0}", (object)lastWin32Error)); } this.intptr_2 = IntPtr.Zero; if (this.bool_0) { if (WGL.DeleteDC(this.intptr_1) == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception(lastWin32Error, string.Format("OpenGL DeleteDC call was not successful, error code: {0}", (object)lastWin32Error)); } } else if (WGL.ReleaseDC(this.intptr_0, this.intptr_1) == 0) { int lastWin32Error = Marshal.GetLastWin32Error(); throw new Win32Exception(lastWin32Error, string.Format("OpenGL ReleaseDC call was not successful, error code: {0}", (object)lastWin32Error)); } this.intptr_0 = IntPtr.Zero; this.intptr_1 = IntPtr.Zero; this.int_0 = 0; } }
public static RenderingContext FromBitmapInfo( BitmapInfo bitmapInfo, PixelFormatDescriptor pfd, out IntPtr bitmapHandle) { IntPtr dc = WGL.GetDC(IntPtr.Zero); IntPtr compatibleDc = WGL.CreateCompatibleDC(dc); WGL.ReleaseDC(IntPtr.Zero, dc); IntPtr ppvBits; bitmapHandle = WGL.CreateDIBSection(compatibleDc, ref bitmapInfo, DIBDataType.RgbColors, out ppvBits, IntPtr.Zero, 0U); if (bitmapHandle == IntPtr.Zero) { throw new InternalException("Error in CreateDIBSection", (Exception) new Win32Exception(Marshal.GetLastWin32Error())); } if (WGL.SelectObject(compatibleDc, bitmapHandle) == IntPtr.Zero) { throw new InternalException("SelectObject failed"); } int pixelFormatIndex = RenderingContext.smethod_0(compatibleDc, pfd); IntPtr context = WGL.wglCreateContext(compatibleDc); if (context == IntPtr.Zero) { throw new InternalException("Error in wglCreateContext", (Exception) new Win32Exception(Marshal.GetLastWin32Error())); } return(new RenderingContext(IntPtr.Zero, compatibleDc, true, context, pixelFormatIndex)); }