示例#1
0
        public void TestGetExtensionsStringARB()
        {
            if (Wgl.HasGetExtensionsStringARB == false)
            {
                Assert.Inconclusive("WGL_ARB_extensions_string not supported");
            }

            WindowsDeviceContext winDeviceContext = (WindowsDeviceContext)_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+)( +)?)+"));
        }
示例#2
0
        public new void FixtureTearDown()
        {
            // Detroy context
            WindowsDeviceContext winDeviceContext = _DeviceContext as WindowsDeviceContext;

            if ((winDeviceContext != null) && (Wgl.DeleteContext(_Context) == false))
            {
                throw new InvalidOperationException("unable to delete OpenGL context");
            }
            _Context = IntPtr.Zero;
        }
示例#3
0
        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
                WindowsDeviceContext windowsDeviceContext = _DeviceContext as WindowsDeviceContext;
                if (windowsDeviceContext != null)
                {
                    _WglExtensions.Query(windowsDeviceContext);
                }
                // GLX OpenGL extensions
                XServerDeviceContext xserverDeviceContext = _DeviceContext as XServerDeviceContext;
                if (xserverDeviceContext != null)
                {
                    _GlxExtensions.Query(xserverDeviceContext);
                }
                // EGL OpenGL extensions
                NativeDeviceContext nativeDeviceContext = _DeviceContext as NativeDeviceContext;
                if (nativeDeviceContext != null)
                {
                    _EglExtensions.Query(nativeDeviceContext);
                }
            } catch {
                // Release resources manually
                FixtureTearDown();

                throw;
            }
        }
        public void TestGetPixelFormatAttribARB()
        {
            if (IsWglExtensionSupported("WGL_ARB_pixel_format") == false)
            {
                Assert.Inconclusive("OpenGL extension WGL_ARB_pixel_format not supported");
            }

            WindowsDeviceContext winDeviceContext = (WindowsDeviceContext)_DeviceContext;

            #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 (IsGlExtensionSupported("GL_ARB_multisample") || IsGlExtensionSupported("WGL_ARB_multisample") || IsGlExtensionSupported("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
        }
示例#5
0
        /// <summary>
        /// Set the pixel format on Windows platform.
        /// </summary>
        private void SetPixelFormatWgl()
        {
            WindowsDeviceContext winDeviceContext = (WindowsDeviceContext)_DeviceContext;

            // Define most compatible pixel format
            Wgl.PIXELFORMATDESCRIPTOR pfd = new Wgl.PIXELFORMATDESCRIPTOR(24);
            int pFormat;

            // Find pixel format match
            pFormat = Wgl.ChoosePixelFormat(winDeviceContext.DeviceContext, ref pfd);
            // Get exact description of the pixel format
            Wgl.DescribePixelFormat(winDeviceContext.DeviceContext, pFormat, (uint)pfd.nSize, ref pfd);
            // Set pixel format before creating OpenGL context
            Wgl.SetPixelFormat(winDeviceContext.DeviceContext, pFormat, ref pfd);
        }