private IntPtr CreateContext() { Functions.LoadLibrary("opengl32.dll"); var pf = new PixelFormatDescriptor(); pf.Init(); var pixelFormat = OpenGL.ChoosePixelFormat(DeviceContext, ref pf); if (!OpenGL.SetPixelFormat(DeviceContext, pixelFormat, ref pf)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } IntPtr hglrc; if ((hglrc = OpenGL.wglCreateContext(DeviceContext)) == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } return(hglrc); }
public static extern bool SetPixelFormat(HDC hdc, int iPixelFormat, ref PixelFormatDescriptor ppfd);
public static extern int DescribePixelFormat(HDC hdc, int iPixelFormat, uint nBytes, out PixelFormatDescriptor ppfd);
public static extern int ChoosePixelFormat(HDC hdc, ref PixelFormatDescriptor ppfd);
public static extern int ChoosePixelFormat(IntPtr hdc, [In] ref PixelFormatDescriptor ppfd);