コード例 #1
0
        /// <summary>
        /// Create a device context on the specified P-Buffer.
        /// </summary>
        /// <param name="nativeBuffer">
        /// A <see cref="INativePBuffer"/> created with <see cref="CreatePBuffer(DevicePixelFormat, uint, uint)"/> which
        /// the created context shall be able to render on.
        /// </param>
        /// <exception cref='NotSupportedException'>
        /// Exception thrown if the current platform is not supported.
        /// </exception>
        public static DeviceContext Create(INativePBuffer nativeBuffer)
        {
            DeviceContext deviceContext = null;

            if (IsEglRequired == false)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    deviceContext = new DeviceContextWGL(nativeBuffer);
                    break;

                default:
                    throw new NotSupportedException(String.Format("platform {0} not supported", Environment.OSVersion));
                }
            }
            else
            {
                deviceContext = new DeviceContextEGL(nativeBuffer);
            }

            deviceContext._Api = _DefaultApi;

            return(deviceContext);
        }
コード例 #2
0
            /// <summary>
            /// Query the extensions supported by current platform.
            /// </summary>
            /// <param name="deviceContext">
            /// A <see cref="DeviceContextWGL"/> that specifies the device context to query extensions for.
            /// </param>
            /// <exception cref="ArgumentNullException">
            /// Exception thrown if <paramref name="deviceContext"/> is null.
            /// </exception>
            internal void Query(DeviceContextWGL deviceContext)
            {
                if (deviceContext == null)
                {
                    throw new ArgumentNullException("deviceContext");
                }

                LogComment("Query WGL extensions.");

                string wglExtensions = null;

                BindAPIFunction <Wgl>(Library, "wglGetExtensionsStringARB", GetProcAddressGL, null, null);
                BindAPIFunction <Wgl>(Library, "wglGetExtensionsStringEXT", GetProcAddressGL, null, null);

                if (Delegates.pwglGetExtensionsStringARB != null)
                {
                    wglExtensions = GetExtensionsStringARB(deviceContext.DeviceContext);
                }
                else if (Delegates.pwglGetExtensionsStringEXT != null)
                {
                    wglExtensions = GetExtensionsStringEXT();
                }

                Query(Version_100, wglExtensions ?? String.Empty);
            }
コード例 #3
0
        /// <summary>
        /// Create a device context on the specified window.
        /// </summary>
        /// <param name="display">
        /// A <see cref="IntPtr"/> that specifies the display handle associated to <paramref name="windowHandle"/>. Some platforms
        /// ignore this parameter (i.e. Windows or EGL implementation).
        /// </param>
        /// <param name='windowHandle'>
        /// A <see cref="IntPtr"/> that specifies the window handle used to create the device context.
        /// </param>
        /// <exception cref='ArgumentException'>
        /// Is thrown when <paramref name="windowHandle"/> is <see cref="IntPtr.Zero"/>.
        /// </exception>
        /// <exception cref='NotSupportedException'>
        /// Exception thrown if the current platform is not supported.
        /// </exception>
        public static DeviceContext Create(IntPtr display, IntPtr windowHandle)
        {
            DeviceContext deviceContext = null;

            if (IsEglRequired == false)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    deviceContext = new DeviceContextWGL(windowHandle);
                    break;

                case Platform.Id.Linux:
                    deviceContext = new DeviceContextGLX(display, windowHandle);
                    break;

                case Platform.Id.MacOS:
                    if (Glx.IsRequired)
                    {
                        deviceContext = new DeviceContextGLX(display, windowHandle);
                    }
                    else
                    {
                        throw new NotSupportedException("platform MacOS not supported without Glx.IsRequired=true");
                    }
                    break;

                default:
                    throw new NotSupportedException(String.Format("platform {0} not supported", Environment.OSVersion));
                }
            }
            else
            {
                deviceContext = new DeviceContextEGL(windowHandle);
            }

            deviceContext._Api = _DefaultApi;

            return(deviceContext);
        }
コード例 #4
0
            /// <summary>
            /// Query the extensions supported by current platform.
            /// </summary>
            /// <param name="deviceContext">
            /// A <see cref="DeviceContextWGL"/> that specifies the device context to query extensions for.
            /// </param>
            /// <exception cref="ArgumentNullException">
            /// Exception thrown if <paramref name="deviceContext"/> is null.
            /// </exception>
            internal void Query(DeviceContextWGL 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);
            }
コード例 #5
0
        /// <summary>
        /// Create a device context on the specified P-Buffer.
        /// </summary>
        /// <param name="nativeBuffer">
        /// A <see cref="INativePBuffer"/> created with <see cref="CreatePBuffer(DevicePixelFormat, uint, uint)"/> which
        /// the created context shall be able to render on.
        /// </param>
        /// <exception cref='NotSupportedException'>
        /// Exception thrown if the current platform is not supported.
        /// </exception>
        public static DeviceContext Create(INativePBuffer nativeBuffer)
        {
            DeviceContext deviceContext = null;

            if (IsEglRequired == false)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    deviceContext = new DeviceContextWGL(nativeBuffer);
                    break;

                default:
                    throw new NotSupportedException("platform not supported");
                }
            }
            else
            {
                deviceContext = new DeviceContextEGL(nativeBuffer);
            }

            return(deviceContext);
        }
コード例 #6
0
        /// <summary>
        /// Create a device context without a specific window.
        /// </summary>
        /// <exception cref='NotSupportedException'>
        /// Exception thrown if the current platform is not supported.
        /// </exception>
        public static DeviceContext Create()
        {
            Debug.Assert(Gl._NativeWindow != null);

            DeviceContext deviceContext = null;

            if (IsEglRequired == false)
            {
                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    deviceContext = new DeviceContextWGL();
                    break;

                case Platform.Id.Linux:
                    deviceContext = new DeviceContextGLX();
                    break;

                case Platform.Id.MacOS:
                    if (Glx.IsRequired)
                    {
                        deviceContext = new DeviceContextGLX();
                    }
                    else
                    {
                        throw new NotSupportedException("platform MacOS not supported without Glx.IsRequired=true");
                    }
                    break;

                default:
                    throw new NotSupportedException(String.Format("platform {0} not supported", Platform.CurrentPlatformId));
                }
            }
            else
            {
                if (deviceContext == null)
                {
                    INativePBuffer nativeBuffer = Gl._NativeWindow as INativePBuffer;
                    if (nativeBuffer != null)
                    {
                        deviceContext = new DeviceContextEGL(nativeBuffer);
                    }
                }

                if (deviceContext == null)
                {
                    INativeWindow nativeWindow = Gl._NativeWindow as INativeWindow;
                    if (nativeWindow != null)
                    {
                        deviceContext = new DeviceContextEGL(nativeWindow.Handle);
                    }
                }

                if (deviceContext == null)
                {
                    Debug.Fail("unsupported EGL surface");
                    throw new NotSupportedException("EGL surface not supported");
                }
            }

            return(deviceContext);
        }