本文整理汇总了C#中IContext.DrawElements方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.DrawElements方法的具体用法?C# IContext.DrawElements怎么用?C# IContext.DrawElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.DrawElements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
public unsafe void Decode(IContext context, ManualMipChain target, ManualMipChain temporalDiff, ManualMipChain previous, int mostDetailedMip)
{
var pipeline = context.Pipeline;
fullTextureProcessor.PrepareContext(context);
pipeline.Viewports[0].Set(target.Width, target.Height);
framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, target[0], 0);
pipeline.Framebuffer = framebuffer;
Vector4 mipInfoData;
var mipInfoPtr = (int*)&mipInfoData;
mipInfoPtr[0] = mostDetailedMip;
mipInfoPtr[1] = 1 << mostDetailedMip;
mipInfoBuffer.SetDataByMapping(pclWorkarounds, (IntPtr)mipInfoPtr);
pipeline.UniformBuffers[0] = mipInfoBuffer;
pipeline.Textures[0] = temporalDiff[mostDetailedMip];
pipeline.Samplers[0] = sampler;
pipeline.Textures[1] = previous[0];
pipeline.Samplers[1] = sampler;
pipeline.Textures[2] = previous[mostDetailedMip];
pipeline.Samplers[2] = sampler;
context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
framebuffer.DetachColorStartingFrom(0);
}
示例2: Draw
public unsafe void Draw(IContext context, IRavcGameWindow gameWindow, ITexture2D frameTexture, int x, int y)
{
var pipeline = context.Pipeline;
pipeline.Program = program;
pipeline.VertexArray = vertexArray;
var windowAspectRatio = (float)gameWindow.ClientWidth / Math.Max(gameWindow.ClientHeight, 1);
var textureAspectRatio = (float)frameTexture.Width / Math.Max(frameTexture.Height, 1);
int adjustedTextureWidth = gameWindow.ClientWidth;
int adjustedTextureHeight = gameWindow.ClientHeight;
if (windowAspectRatio > textureAspectRatio)
adjustedTextureWidth = (int)(gameWindow.ClientHeight * textureAspectRatio);
if (windowAspectRatio < textureAspectRatio)
adjustedTextureHeight = (int)(gameWindow.ClientWidth / textureAspectRatio);
int aspectOffsetX = (gameWindow.ClientWidth - adjustedTextureWidth) / 2;
int aspectOffsetY = (gameWindow.ClientHeight - adjustedTextureHeight) / 2;
int adjustedSize = texture.Width * adjustedTextureWidth / frameTexture.Width;
int viewportX = x * adjustedTextureWidth / frameTexture.Width + aspectOffsetX;
int viewportY = gameWindow.ClientHeight - (y * adjustedTextureHeight / frameTexture.Height + aspectOffsetY) - adjustedSize;
pipeline.Viewports[0].Set(viewportX, viewportY, adjustedSize, adjustedSize);
pipeline.Rasterizer.SetDefault();
pipeline.Rasterizer.MultisampleEnable = false;
pipeline.Textures[0] = texture;
pipeline.Samplers[0] = sampler;
pipeline.DepthStencil.SetDefault();
pipeline.DepthStencil.DepthMask = false;
pipeline.Blend.SetDefault(false);
pipeline.Blend.BlendEnable = true;
pipeline.Blend.Targets[0].Color.SrcFactor = BlendFactor.SrcAlpha;
pipeline.Blend.Targets[0].Color.DestFactor = BlendFactor.OneMinusSrcAlpha;
pipeline.Blend.Targets[0].Alpha.SrcFactor = BlendFactor.SrcAlpha;
pipeline.Blend.Targets[0].Alpha.SrcFactor = BlendFactor.OneMinusSrcAlpha;
context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
}
示例3: Process
public unsafe void Process(IContext context, ITexture2D target, ITexture2D texture0, ITexture2D texture1)
{
var pipeline = context.Pipeline;
fullTextureProcessor.PrepareContext(context);
pipeline.Framebuffer = framebuffer;
pipeline.Samplers[0] = sampler;
pipeline.Samplers[1] = sampler;
pipeline.UniformBuffers[0] = mipInfoBuffer;
pipeline.Viewports[0].Set(target.Width, target.Height);
Vector4 mipInfoData;
var mipInfoPtr = (int*)&mipInfoData;
mipInfoPtr[0] = 0;
mipInfoPtr[1] = 1;
mipInfoBuffer.SetDataByMapping(pclWorkarounds, (IntPtr)mipInfoPtr);
framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, target, 0);
pipeline.Textures[0] = texture0;
pipeline.Textures[1] = texture1;
context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
framebuffer.DetachColorStartingFrom(0);
}
示例4: GenerateMips
public unsafe void GenerateMips(IContext context, ManualMipChain target)
{
var pipeline = context.Pipeline;
fullTextureProcessor.PrepareContext(context);
pipeline.Framebuffer = framebuffer;
pipeline.Samplers[0] = sampler;
pipeline.UniformBuffers[0] = mipInfoBuffer;
for (int i = 1; i < EncodingConstants.MipLevels; i++)
{
pipeline.Viewports[0].Set(target.Width >> i, target.Height >> i);
Vector4 mipInfoData;
var mipInfoPtr = (int*)&mipInfoData;
mipInfoPtr[0] = i;
mipInfoBuffer.SetDataByMapping(pclWorkarounds, (IntPtr)mipInfoPtr);
framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, target[i], 0);
pipeline.Textures[0] = target[i - 1];
context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
framebuffer.DetachColorStartingFrom(0);
}
}