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


C# UltravioletContext.QueueWorkItemAndWait方法代码示例

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


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

示例1: OpenGLRenderTarget2D

        /// <summary>
        /// Initializes a new instance of the OpenGLRenderTarget2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="width">The render target's width in pixels.</param>
        /// <param name="height">The render target's height in pixels.</param>
        /// <param name="usage">A <see cref="RenderTargetUsage"/> value specifying whether the 
        /// render target's data is discarded or preserved when it is bound to the graphics device.</param>
        /// <param name="buffers">The collection of render buffers to attach to the target.</param>
        public OpenGLRenderTarget2D(UltravioletContext uv, Int32 width, Int32 height, RenderTargetUsage usage, IEnumerable<RenderBuffer2D> buffers = null)
            : base(uv)
        {
            Contract.EnsureRange(width > 0, nameof(width));
            Contract.EnsureRange(height > 0, nameof(height));

            // NOTE: If we're in an older version of GLES, we need to use glFramebufferTexture2D()
            glFramebufferTextureIsSupported = !gl.IsGLES || gl.IsVersionAtLeast(3, 2);

            glDrawBuffersIsSupported = !gl.IsGLES2 || gl.IsExtensionSupported("GL_ARB_draw_buffers");
            glDrawBufferIsSupported = !gl.IsGLES;

            var framebuffer = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                using (OpenGLState.ScopedCreateFramebuffer(out framebuffer))
                {
                    if (buffers != null)
                    {
                        foreach (OpenGLRenderBuffer2D buffer in buffers)
                        {
                            AttachRenderBuffer(buffer);
                        }
                    }
                }
            });

            this.width = width;
            this.height = height;
            this.framebuffer = framebuffer;
            this.renderTargetUsage = usage;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:42,代码来源:OpenGLRenderTarget2D.cs

示例2: OpenGLSamplerObject

        /// <summary>
        /// Initializes a new instance of the <see cref="OpenGLSamplerObject"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        public OpenGLSamplerObject(UltravioletContext uv)
            : base(uv)
        {
            var sampler = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                sampler = gl.GenSampler();
                gl.ThrowIfError();
            });

            this.sampler = sampler;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:17,代码来源:OpenGLSamplerObject.cs

示例3: OpenGLGeometryStream

        /// <summary>
        /// Initializes a new instance of the OpenGLGeometryStream class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        public OpenGLGeometryStream(UltravioletContext uv)
            : base(uv)
        {
            var vao = 0u;

            if (OpenGLState.SupportsVertexArrayObjects)
            {
                uv.QueueWorkItemAndWait(() =>
                {
                    vao = gl.GenVertexArray();
                    gl.ThrowIfError();
                });
            }

            this.vao = vao;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:20,代码来源:OpenGLGeometryStream.cs

示例4: OpenGLFragmentShader

        /// <summary>
        /// Initializes a new instance of the OpenGLFragmentShader class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="source">The shader source.</param>
        public OpenGLFragmentShader(UltravioletContext uv, String[] source)
            : base(uv)
        {
            Contract.Require(source, nameof(source));

            var shader = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                shader = gl.CreateShader(gl.GL_FRAGMENT_SHADER);
                gl.ThrowIfError();

                var log = String.Empty;
                if (!ShaderCompiler.Compile(shader, source, out log))
                    throw new InvalidOperationException(log);
            });

            this.shader = shader;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:24,代码来源:OpenGLFragmentShader.cs.cs

示例5: OpenGLShaderProgram

        /// <summary>
        /// Initializes a new instance of the OpenGLShaderProgram class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="vertexShader">The program's vertex shader.</param>
        /// <param name="fragmentShader">The program's fragment shader.</param>
        /// <param name="programOwnsShaders">A value indicating whether the program owns the shader objects.</param>
        public OpenGLShaderProgram(UltravioletContext uv, OpenGLVertexShader vertexShader, OpenGLFragmentShader fragmentShader, Boolean programOwnsShaders)
            : base(uv)
        {
            Contract.Require(vertexShader, nameof(vertexShader));
            Contract.Require(fragmentShader, nameof(fragmentShader));

            Ultraviolet.ValidateResource(vertexShader);
            Ultraviolet.ValidateResource(fragmentShader);

            this.vertexShader = vertexShader;
            this.fragmentShader = fragmentShader;
            this.programOwnsShaders = programOwnsShaders;

            var program = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                program = gl.CreateProgram();
                gl.ThrowIfError();

                gl.AttachShader(program, vertexShader.OpenGLName);
                gl.ThrowIfError();

                gl.AttachShader(program, fragmentShader.OpenGLName);
                gl.ThrowIfError();

                gl.LinkProgram(program);
                gl.ThrowIfError();

                var log = gl.GetProgramInfoLog(program);
                gl.ThrowIfError();

                var status = gl.GetProgrami(program, gl.GL_LINK_STATUS);
                gl.ThrowIfError();

                if (status == 0)
                    throw new InvalidOperationException(log);
            });

            this.program = program;
            this.uniforms = CreateUniformCollection();
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:49,代码来源:OpenGLShaderProgram.cs


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