void SetupRenderState(ImDrawDataPtr drawData, ID3D11DeviceContext ctx) { var viewport = new Viewport { Width = drawData.DisplaySize.X, Height = drawData.DisplaySize.Y, MinDepth = 0.0f, MaxDepth = 1.0f, }; ctx.RSSetViewports(viewport); int stride = sizeof(ImDrawVert); int offset = 0; ctx.IASetInputLayout(inputLayout); ctx.IASetVertexBuffers(0, 1, new[] { vertexBuffer }, new[] { stride }, new[] { offset }); ctx.IASetIndexBuffer(indexBuffer, sizeof(ImDrawIdx) == 2 ? Format.R16_UInt : Format.R32_UInt, 0); ctx.IASetPrimitiveTopology(PrimitiveTopology.TriangleList); ctx.VSSetShader(vertexShader); ctx.VSSetConstantBuffers(0, constantBuffer); ctx.PSSetShader(pixelShader); ctx.PSSetSamplers(0, fontSampler); ctx.GSSetShader(null); ctx.HSSetShader(null); ctx.DSSetShader(null); ctx.CSSetShader(null); ctx.OMSetBlendState(blendState); ctx.OMSetDepthStencilState(depthStencilState); ctx.RSSetState(rasterizerState); }
public static void PSSetSamplers(this ID3D11DeviceContext context, int startSlot, ID3D11SamplerState[] samplerStates) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (samplerStates == null) { throw new ArgumentNullException(nameof(samplerStates)); } if (samplerStates.Length == 0) { throw new ArgumentException(null, nameof(samplerStates)); } context.PSSetSamplers((uint)startSlot, samplerStates.Length, samplerStates); }