【问题标题】:GLSL pow function?GLSL pow 函数?
【发布时间】:2012-05-15 08:08:23
【问题描述】:

我有这个:

    float xExponential = pow(xPingPong, 5);

并且不工作,声称:

错误:0:53:调用函数“pow”没有匹配的重载

我是不是做错了什么? 使用 OpenGL ES 2.0 为 iOS 开发。

【问题讨论】:

    标签: iphone opengl-es glsl fragment-shader


    【解决方案1】:

    你可以试试这个吗?

    float xExponential = pow(xPingPong, 5.0);
    

    【讨论】:

    • 原因是 5 是整数而 5.0 是浮点数(并且 pow 函数没有为 pow(float,int) 定义。GLSL 中没有自动类型转换,但您可以强制正确type by float xExponential = pow(xPingPong, float(5)); - 在这个例子中没有意义。
    • @Geri 如果回答可以帮助您解决问题,则接受它被认为是礼貌的。如果对您有帮助,请在 Mennan 的答案旁边打勾。
    【解决方案2】:

    你的代码很好,只是语法错误

    写入到十进制数字

     float xExponential = pow(xPingPong, 5.0);
    

     float xExponential = pow(xPingPong, 5.);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      相关资源
      最近更新 更多