当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsDevice.UseOpenGLCreationContext方法代码示例

本文整理汇总了C#中SiliconStudio.Xenko.Graphics.GraphicsDevice.UseOpenGLCreationContext方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.UseOpenGLCreationContext方法的具体用法?C# GraphicsDevice.UseOpenGLCreationContext怎么用?C# GraphicsDevice.UseOpenGLCreationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SiliconStudio.Xenko.Graphics.GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.UseOpenGLCreationContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GraphicsDeviceFeatures

        internal GraphicsDeviceFeatures(GraphicsDevice deviceRoot)
        {
            mapFeaturesPerFormat = new FeaturesPerFormat[256];

            HasSRgb = true;

            using (deviceRoot.UseOpenGLCreationContext())
            {
                Vendor = GL.GetString(StringName.Vendor);
                Renderer = GL.GetString(StringName.Renderer);
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                SupportedExtensions = GL.GetString(StringName.Extensions).Split(' ');
#else
                int numExtensions;
                GL.GetInteger(GetPName.NumExtensions, out numExtensions);
                SupportedExtensions = new string[numExtensions];
                for (int extensionIndex = 0; extensionIndex < numExtensions; ++extensionIndex)
                {
                    SupportedExtensions[extensionIndex] = GL.GetString(StringName.Extensions, extensionIndex);
                }
#endif
            }

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            var isOpenGLES3 = deviceRoot.versionMajor >= 3;

            deviceRoot.HasDepth24 = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_depth24");
            deviceRoot.HasPackedDepthStencilExtension = SupportedExtensions.Contains("GL_OES_packed_depth_stencil");
            deviceRoot.HasExtTextureFormatBGRA8888 = SupportedExtensions.Contains("GL_EXT_texture_format_BGRA8888")
                                       || SupportedExtensions.Contains("GL_APPLE_texture_format_BGRA8888");
            deviceRoot.HasRenderTargetFloat = SupportedExtensions.Contains("GL_EXT_color_buffer_float");
            deviceRoot.HasRenderTargetHalf = SupportedExtensions.Contains("GL_EXT_color_buffer_half_float");
            deviceRoot.HasVAO = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_vertex_array_object");
            deviceRoot.HasTextureRG = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_texture_rg");

            HasSRgb = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_sRGB");

            // Compute shaders available in OpenGL ES 3.1
            HasComputeShaders = isOpenGLES3 && deviceRoot.versionMinor >= 1;
            HasDoublePrecision = false;
            
            // TODO: from 3.1: draw indirect, separate shader object
            // TODO: check tessellation & geometry shaders: GL_ANDROID_extension_pack_es31a
#else
            deviceRoot.HasVAO = true;

            // Compute shaders available in OpenGL 4.3
            HasComputeShaders = deviceRoot.versionMajor >= 4 && deviceRoot.versionMinor >= 3;
            HasDoublePrecision = SupportedExtensions.Contains("GL_ARB_vertex_attrib_64bit");

            // TODO: from 4.0: tessellation, draw indirect
            // TODO: from 4.1: separate shader object
#endif
            
            HasDriverCommandLists = false;
            HasMultiThreadingConcurrentResources = false;

            // TODO: Enum supported formats in mapFeaturesPerFormat

            // Find shader model based on OpenGL version (might need to check extensions more carefully)
            Profile = OpenGLUtils.GetFeatureLevel(deviceRoot.versionMajor, deviceRoot.versionMinor);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:62,代码来源:GraphicsDeviceFeatures.OpenGL.cs

示例2: GraphicsDeviceFeatures

        internal GraphicsDeviceFeatures(GraphicsDevice deviceRoot)
        {
            mapFeaturesPerFormat = new FeaturesPerFormat[256];

            HasSRgb = true;

            using (deviceRoot.UseOpenGLCreationContext())
            {
                Vendor = GL.GetString(StringName.Vendor);
                Renderer = GL.GetString(StringName.Renderer);
#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
                SupportedExtensions = GL.GetString(StringName.Extensions).Split(' ');
#else
                int numExtensions;
                GL.GetInteger(GetPName.NumExtensions, out numExtensions);
                SupportedExtensions = new string[numExtensions];
                for (int extensionIndex = 0; extensionIndex < numExtensions; ++extensionIndex)
                {
                    SupportedExtensions[extensionIndex] = GL.GetString(StringNameIndexed.Extensions, extensionIndex);
                }
#endif
            }

#if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            var isOpenGLES3 = deviceRoot.currentVersion >= 300;

            deviceRoot.HasDepth24 = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_depth24");
            deviceRoot.HasPackedDepthStencilExtension = SupportedExtensions.Contains("GL_OES_packed_depth_stencil");
            deviceRoot.HasExtTextureFormatBGRA8888 = SupportedExtensions.Contains("GL_EXT_texture_format_BGRA8888")
                                       || SupportedExtensions.Contains("GL_APPLE_texture_format_BGRA8888");
            deviceRoot.HasTextureFloat = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_texture_float");
            deviceRoot.HasTextureHalf = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_texture_half_float");
            deviceRoot.HasRenderTargetFloat = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_color_buffer_float");
            deviceRoot.HasRenderTargetHalf = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_color_buffer_half_float");
            deviceRoot.HasVAO = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_vertex_array_object");
            deviceRoot.HasTextureRG = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_texture_rg");
            deviceRoot.HasKhronosDebug = deviceRoot.currentVersion >= 320 || SupportedExtensions.Contains("GL_KHR_debug");

            // Either 3.2+, or 3.1+ with GL_EXT_texture_buffer
            // TODO: For now we don't have proper ES3 bindings on Android (and possibly iOS)
            deviceRoot.HasTextureBuffers = false;
            //deviceRoot.HasTextureBuffers = (deviceRoot.version >= 320)
            //                            || (deviceRoot.version >= 310 && SupportedExtensions.Contains("GL_EXT_texture_buffer"));

            HasSRgb = isOpenGLES3 || SupportedExtensions.Contains("GL_EXT_sRGB");

            // Compute shaders available in OpenGL ES 3.1
            HasComputeShaders = isOpenGLES3 && deviceRoot.currentVersion >= 1;
            HasDoublePrecision = false;

            HasDepthAsSRV = isOpenGLES3;
            HasDepthAsReadOnlyRT = isOpenGLES3;

            deviceRoot.HasDepthClamp = SupportedExtensions.Contains("GL_ARB_depth_clamp");
  
            // TODO: from 3.1: draw indirect, separate shader object
            // TODO: check tessellation & geometry shaders: GL_ANDROID_extension_pack_es31a
#else
            deviceRoot.HasVAO = true;

            deviceRoot.HasDXT = SupportedExtensions.Contains("GL_EXT_texture_compression_s3tc");
            deviceRoot.HasTextureBuffers = true;
            deviceRoot.HasKhronosDebug = deviceRoot.currentVersion >= 430 || SupportedExtensions.Contains("GL_KHR_debug");

            // Compute shaders available in OpenGL 4.3
            HasComputeShaders = deviceRoot.version >= 430;
            HasDoublePrecision = SupportedExtensions.Contains("GL_ARB_vertex_attrib_64bit");

            HasDepthAsSRV = deviceRoot.version >= 300;
            HasDepthAsReadOnlyRT = deviceRoot.version >= 300;

            deviceRoot.HasDepthClamp = deviceRoot.version >= 300;

            // TODO: from 4.0: tessellation, draw indirect
            // TODO: from 4.1: separate shader object
#endif

            deviceRoot.HasAnisotropicFiltering = SupportedExtensions.Contains("GL_EXT_texture_filter_anisotropic");

            HasResourceRenaming = true;

            HasDriverCommandLists = false;
            HasMultiThreadingConcurrentResources = false;

            // TODO: Enum supported formats in mapFeaturesPerFormat

            // Find shader model based on OpenGL version (might need to check extensions more carefully)
            RequestedProfile = deviceRoot.requestedGraphicsProfile;
            CurrentProfile = OpenGLUtils.GetFeatureLevel(deviceRoot.currentVersion);
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:90,代码来源:GraphicsDeviceFeatures.OpenGL.cs


注:本文中的SiliconStudio.Xenko.Graphics.GraphicsDevice.UseOpenGLCreationContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。