本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}