public void TestGetExtensionsStringARB() { if (Wgl.HasGetExtensionsStringARB == false) { Assert.Inconclusive("WGL_ARB_extensions_string not supported"); } DeviceContextWGL winDeviceContext = (DeviceContextWGL)_DeviceContext; string extensions = Wgl.GetExtensionsStringARB(winDeviceContext.DeviceContext); Assert.IsNotNull(extensions); // No exposed extensions? No more assertion if (extensions == String.Empty) { return; } string[] extensionIds = Regex.Split(extensions, " "); // Filter empty IDs extensionIds = Array.FindAll(extensionIds, delegate(string item) { return(item.Trim().Length > 0); }); Console.WriteLine("Found {0} WGL extensions:", extensionIds.Length); foreach (string extensionId in extensionIds) { Console.WriteLine("- {0}", extensionId); } // Assert.IsTrue(Regex.IsMatch(extensions, @"(WGL_(\w+)( +)?)+")); }
public void TestGetPixelFormatAttribARB() { if (IsWglExtensionSupported("WGL_ARB_pixel_format") == false) { Assert.Inconclusive("OpenGL extension WGL_ARB_pixel_format not supported"); } using (Device device = new Device()) using (new GLContext(device)) { DeviceContextWGL winDeviceContext = (DeviceContextWGL)device.Context; #region List the attributes to query List <int> pfAttributesCodes = new List <int>(); // Minimum requirements pfAttributesCodes.Add(Wgl.SUPPORT_OPENGL_ARB); // Required to be Gl.TRUE pfAttributesCodes.Add(Wgl.ACCELERATION_ARB); // Required to be Wgl.FULL_ACCELERATION or Wgl.ACCELERATION_ARB pfAttributesCodes.Add(Wgl.PIXEL_TYPE_ARB); // Buffer destination pfAttributesCodes.Add(Wgl.DRAW_TO_WINDOW_ARB); pfAttributesCodes.Add(Wgl.DRAW_TO_BITMAP_ARB); pfAttributesCodes.Add(Wgl.DRAW_TO_PBUFFER_ARB); // Multiple buffers pfAttributesCodes.Add(Wgl.DOUBLE_BUFFER_ARB); pfAttributesCodes.Add(Wgl.SWAP_METHOD_ARB); pfAttributesCodes.Add(Wgl.STEREO_ARB); // Pixel description pfAttributesCodes.Add(Wgl.COLOR_BITS_ARB); pfAttributesCodes.Add(Wgl.DEPTH_BITS_ARB); pfAttributesCodes.Add(Wgl.STENCIL_BITS_ARB); // Multisample extension if (HasExtension("GL_ARB_multisample") || HasExtension("WGL_ARB_multisample") || HasExtension("GLX_ARB_multisample")) { pfAttributesCodes.Add(Wgl.SAMPLE_BUFFERS_ARB); pfAttributesCodes.Add(Wgl.SAMPLES_ARB); } #endregion #region Query Attributes int[] pfAttributesValue = new int[pfAttributesCodes.Count]; int formatIndex = 1; while (Wgl.GetPixelFormatAttribARB(winDeviceContext.DeviceContext, formatIndex++, 0, (uint)pfAttributesCodes.Count, pfAttributesCodes.ToArray(), pfAttributesValue)) { } #endregion } }
public new void FixtureSetUp() { try { // Create compatibility profile context if ((_Context = _DeviceContext.CreateContext(IntPtr.Zero)) == IntPtr.Zero) { throw new InvalidOperationException("unable to create compatibility profile OpenGL context"); } // Make OpenGL context current if (_DeviceContext.MakeCurrent(_Context) == false) { throw new InvalidOperationException("unable to make current the OpenGL context"); } // Get OpenGL version if ((_VersionString = Gl.GetString(StringName.Version)) == null) { throw new InvalidOperationException("unable to get the OpenGL version"); } // Extract OpenGL version numbers _Version = KhronosVersion.Parse(_VersionString); // Get OpenGL extensions _GlExtensions.Query(); // Get OpenGL window system extensions // Windows OpenGL extensions DeviceContextWGL windowsDeviceContext = _DeviceContext as DeviceContextWGL; if (windowsDeviceContext != null) { _WglExtensions.Query(windowsDeviceContext); } // GLX OpenGL extensions DeviceContextGLX xserverDeviceContext = _DeviceContext as DeviceContextGLX; if (xserverDeviceContext != null) { _GlxExtensions.Query(xserverDeviceContext); } // EGL OpenGL extensions DeviceContextEGL nativeDeviceContext = _DeviceContext as DeviceContextEGL; if (nativeDeviceContext != null) { _EglExtensions.Query(nativeDeviceContext); } } catch (Exception exception) { Console.WriteLine("Unable to initialize Fixture for OpenGL: " + exception.ToString()); // Release resources manually FixtureTearDown(); throw; } }