/// <summary>
		/// Initializes a new instance of the <see cref="DeviceContextWGL"/> class.
		/// </summary>
		/// <param name='nativeBuffer'>
		/// A <see cref="INativePBuffer"/> that specifies the P-Buffer used to create the device context.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="nativeBuffer"/> is null.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="nativeBuffer"/> is not an instance created by
		/// <see cref="DeviceContext.CreatePBuffer(DevicePixelFormat, uint, uint)"/>.
		/// </exception>
		/// <exception cref='InvalidOperationException'>
		/// Is thrown when an operation cannot be performed.
		/// </exception>
		public DeviceContextWGL(INativePBuffer nativeBuffer)
		{
			if (nativeBuffer == null)
				throw new ArgumentNullException("nativeBuffer");

			NativePBuffer nativePBuffer = nativeBuffer as NativePBuffer;
			if (nativePBuffer == null)
				throw new ArgumentException("INativePBuffer not created with DeviceContext.CreatePBuffer");

			if (!Wgl.CurrentExtensions.Pbuffer_ARB && !Wgl.CurrentExtensions.Pbuffer_EXT)
				throw new InvalidOperationException("WGL_(ARB|EXT)_pbuffer not supported");

			_WindowHandle = nativePBuffer.Handle;

			if (Wgl.CurrentExtensions.Pbuffer_ARB)
				_DeviceContext = Wgl.GetPbufferDCARB(nativePBuffer.Handle);
			else
				_DeviceContext = Wgl.GetPbufferDCEXT(nativePBuffer.Handle);

			if (_DeviceContext == IntPtr.Zero)
				throw new InvalidOperationException("unable to get device context");
			_DeviceContextPBuffer = true;

			IsPixelFormatSet = true;
		}
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceContextEGL"/> class.
        /// </summary>
        /// <param name='nativeBuffer'>
        /// A <see cref="INativePBuffer"/> that specifies the P-Buffer used to create the device context.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="nativeBuffer"/> is null.
        /// </exception>
        public DeviceContextEGL(INativePBuffer nativeBuffer)
        {
            if (nativeBuffer == null)
            {
                throw new ArgumentNullException("nativeBuffer");
            }

            NativePBuffer nativePBuffer = nativeBuffer as NativePBuffer;

            if (nativePBuffer == null)
            {
                throw new ArgumentException("INativePBuffer not created with DeviceContext.CreatePBuffer");
            }

            _NativeSurface = nativePBuffer;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceContextEGL"/> class.
        /// </summary>
        /// <param name='nativeBuffer'>
        /// A <see cref="INativePBuffer"/> that specifies the P-Buffer used to create the device context.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="nativeBuffer"/> is null.
        /// </exception>
        public DeviceContextEGL(INativePBuffer nativeBuffer)
            : this()
        {
            if (nativeBuffer == null)
            {
                throw new ArgumentNullException(nameof(nativeBuffer));
            }

            NativePBuffer nativePBuffer = nativeBuffer as NativePBuffer;

            if (nativePBuffer == null)
            {
                throw new ArgumentException("INativePBuffer not created with DeviceContext.CreatePBuffer");
            }

            _NativeSurface = nativePBuffer;

            IsPixelFormatSet = true;
        }