/// <summary> /// Creates an OpenGL context from a Windows platform. /// </summary> /// <returns> /// A <see cref="IDeviceContext"/> that specify the device context. /// </returns> private static IntPtr CreateWinSimpleContext(IDeviceContext rDevice) { WindowsDeviceContext winDeviceContext = (WindowsDeviceContext)rDevice; IntPtr rContext; // Define most compatible pixel format Wgl.PIXELFORMATDESCRIPTOR pfd = new Wgl.PIXELFORMATDESCRIPTOR(24); int pFormat; bool res; // Find pixel format match pfd.dwFlags |= Wgl.PixelFormatDescriptorFlags.DepthDontCare | Wgl.PixelFormatDescriptorFlags.DoublebufferDontCare | Wgl.PixelFormatDescriptorFlags.StereoDontCare; pFormat = Wgl.ChoosePixelFormat(winDeviceContext.DeviceContext, ref pfd); Debug.Assert(pFormat != 0); // Get exact description of the pixel format res = Wgl.DescribePixelFormat(winDeviceContext.DeviceContext, pFormat, (uint)pfd.nSize, ref pfd); Debug.Assert(res); // Set pixel format before creating OpenGL context res = Wgl.SetPixelFormat(winDeviceContext.DeviceContext, pFormat, ref pfd); Debug.Assert(res); // Create a dummy OpenGL context to retrieve initial informations. rContext = winDeviceContext.CreateContext(IntPtr.Zero); Debug.Assert(rContext != IntPtr.Zero); return(rContext); }
/// <summary> /// Query the extensions supported by current platform. /// </summary> /// <param name="deviceContext"> /// A <see cref="WindowsDeviceContext"/> that specifies the device context to query extensions for. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="deviceContext"/> is null. /// </exception> public void Query(WindowsDeviceContext deviceContext) { if (deviceContext == null) throw new ArgumentNullException("deviceContext"); LogComment("Query WGL extensions."); string wglExtensions = null; if (Delegates.pwglGetExtensionsStringARB != null) { wglExtensions = GetExtensionsStringARB(deviceContext.DeviceContext); } else if (Delegates.pwglGetExtensionsStringEXT != null) { wglExtensions = GetExtensionsStringEXT(); } Query(new KhronosVersion(1, 0), wglExtensions ?? String.Empty); }
/// <summary> /// Query OpenGL implementation extensions. /// </summary> /// <param name="ctx"></param> /// <returns></returns> public static GraphicsCapabilities Query(GraphicsContext ctx, IDeviceContext deviceContext) { GraphicsCapabilities graphicsCapabilities = new GraphicsCapabilities(); KhronosApi.LogComment("Query OpenGL extensions."); #region Platform Extension Reload // Since at this point there's a current OpenGL context, it's possible to use // {glx|wgl}GetExtensionsString to retrieve platform specific extensions switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: case PlatformID.Win32Windows: case PlatformID.Win32S: case PlatformID.WinCE: // Wgl.SyncDelegates(); break; } #endregion // OpenGL extensions graphicsCapabilities._GlExtensions.Query(); // Windows OpenGL extensions WindowsDeviceContext windowsDeviceContext = deviceContext as WindowsDeviceContext; if (windowsDeviceContext != null) { graphicsCapabilities._WglExtensions.Query(windowsDeviceContext); } // GLX OpenGL extensions XServerDeviceContext xserverDeviceContext = deviceContext as XServerDeviceContext; if (xserverDeviceContext != null) { graphicsCapabilities._GlxExtensions.Query(xserverDeviceContext); } // Query implementation limits graphicsCapabilities._GraphicsLimits = GraphicsLimits.Query(graphicsCapabilities._GlExtensions); return(graphicsCapabilities); }
/// <summary> /// Query the extensions supported by current platform. /// </summary> /// <param name="deviceContext"> /// A <see cref="WindowsDeviceContext"/> that specifies the device context to query extensions for. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="deviceContext"/> is null. /// </exception> public void Query(WindowsDeviceContext deviceContext) { if (deviceContext == null) { throw new ArgumentNullException("deviceContext"); } LogComment("Query WGL extensions."); string wglExtensions = null; if (Delegates.pwglGetExtensionsStringARB != null) { wglExtensions = GetExtensionsStringARB(deviceContext.DeviceContext); } else if (Delegates.pwglGetExtensionsStringEXT != null) { wglExtensions = GetExtensionsStringEXT(); } Query(Version_100, wglExtensions ?? String.Empty); }