c - HLSL 函数未被识别?未声明的错误

标签 c xna hlsl

float4 PixelShaderFunction(float2 TexCoord: TEXCOORD0) : COLOR0
{
float4 color1 = tex2D(inputSampler, TexCoord);
float numb = TestFunc( 5 );
float4 color3 = color1 + numb;
return color3;
}

float TestFunc(float numb)
{

return numb + 1;
}

我收到一个错误提示 error x3004: undeclared identifier 'TestFunc'

最佳答案

要么在 PixelShaderFunction 中使用它之前声明 TestFunc(),要么在此之前完全移动它。即:

float TestFunc(float);

float PixelShaderFunction()
{
    // ...
}

float TestFunc(float n)
{
    // ...
}

float TestFunc(float n)
{
     // ...
}

float PixelShaderFunction()
{
    // ...
}

关于c - HLSL 函数未被识别?未声明的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11814087/

相关文章:

c++ - 交叉构建,链接问题

无法使用 write 打开的 popen 写入 stdin

c# - 将触摸手势转换为鼠标手势

directx - 像素着色器中的全屏四边形有屏幕坐标吗?

directx - 如何使用着色器常量缓冲区?

c++ - 使用 DirectX 11 API 读取 HLSL 语义和注释?

c - Pix、struct Pix 或 Leptonica 中的 PIX

c - 如何安装gcc交叉编译器

c# - 绘制文本时 XNA 怪异的 3D 绘制

c# - 大量物体的碰撞检测