夏普DX:未找到方法 'get_BufferPointer()'

SharpDX: Method not found 'get_BufferPointer()'

本文关键字:get BufferPointer DX 方法 夏普      更新时间:2023-10-16

我已经从indiedev的教程中构建了一个简单的SharpDX项目(#1,#2,#3)。

现在我遇到了一个错误方法没有找到'IntPtr SharpDX.D3DCompiler.ShaderBytecode.get_BufferPointer()'当我启动应用程序。

我有一个参考下列SharpDX dll的:

  • SharpDX。D3DCompiler
  • SharpDX。Direct3D11
  • SharpDX。DXGI
  • SharpDX

以下代码是主循环:

public void Run()
{
   //...
   Initialize();
   LoadContent();
   RenderLoop.Run(renderWindow, () =>
   {
      //....
   }
   //...
}
public override void LoadContent()
{
   ShaderBytecode vertexShaderByteCode = ShaderBytecode.CompileFromFile("shaders.hlsl", "VShader", "vs_4_0");
   ShaderBytecode pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders.hlsl", "PShader", "ps_4_0");
    vertexShader = new VertexShader(Device, vertexShaderByteCode); //--> error
    pixelShader = new PixelShader(Device, pixelShaderByteCode);
    //...
 }

shaders.hlsl:

struct VOut
{
  float4 position : SV_POSITION;
  float4 color    : COLOR;
};
VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
  VOut output;
  output.position = position;
  output.color = color;
  return output;
}
float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
  return color;
}

我要添加什么到着色器。hlsl文件?

此问题是程序集版本较旧的原因。正如Chris Mantle所提到的,它有助于通过NuGet更新到最新版本。你可以从这里取。

这是没有问题的着色器。hlsl文件。