Пример #1
0
        public void FixtureSetUp()
        {
            try {
                // Support ES tests
                Egl.IsRequired = IsEsTest;

                // Create window
                Form = new TestForm(this);
                // Create device context
                _DeviceContext = DeviceContextFactory.Create(Form);

                // Set pixel format
                if (_DeviceContext is WindowsDeviceContext)
                {
                    SetPixelFormatWgl();
                }
                else if (_DeviceContext is NativeDeviceContext)
                {
                    SetPixelFormatEgl();
                }
                else
                {
                    throw new NotImplementedException("platform not supported");
                }
            } catch {
                // Release resources manually
                FixtureTearDown();

                throw;
            }
        }
Пример #2
0
        private void CreateDeviceContext()
        {
            this.DeviceContext = DeviceContextFactory.Create(this.Handle);
            this.DeviceContext.IncRef();

            // Set pixel format
            var pixelFormats     = this.DeviceContext.PixelsFormats;
            var controlReqFormat = new DevicePixelFormat
            {
                ColorBits       = (int)this.ColorBits,
                DepthBits       = (int)this.DepthBits,
                StencilBits     = (int)this.StencilBits,
                MultisampleBits = (int)this.MultisampleBits,
                DoubleBuffer    = this.DoubleBuffer
            };

            var matchingPixelFormats = pixelFormats.Choose(controlReqFormat);

            if (matchingPixelFormats.Count == 0)
            {
                throw new InvalidOperationException("unable to find a suitable pixel format");
            }

            this.DeviceContext.SetPixelFormat(matchingPixelFormats[0]);
        }
Пример #3
0
        public void FixtureSetUp()
        {
            try {
                // Create window
                Form = new TestForm(this);
                // Create device context
                _DeviceContext = DeviceContextFactory.Create(Form);
                // Set pixel format
                SetPixelFormatWgl();
            } catch {
                // Release resources manually
                FixtureTearDown();

                throw;
            }
        }