你可以通过一个固定大小的数组作为GLSL函数参数? [英] Can you pass a fixed-size array as a GLSL function parameter?

查看:1585
本文介绍了你可以通过一个固定大小的数组作为GLSL函数参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个GLSL着色器,我想创建一个看起来有点像这样的功能:

In a GLSL shader, I want to create a function that looks a bit like this :

void MyFunction(out float results[9])
{
   float value0 = 3.1546;
   float value1 = 42;     // whatever value      
   /* ... long, complicated code ... */

   results[0] = value0;  
   results[1] = value1;
   results[2] = value2;
   ...
}

能否这样的函数签名被使用和GLSL编?结果
如果没有,还有什么办法?

Can such a function signature be used and compiled in GLSL ?
If no, are there any alternatives ?

推荐答案

是的,这是合法的GLSL code。

Yes, this is legal GLSL code.

这并不意味着它肯定会编译,但它是合法的code。话虽这么说,它可能会更好,只是返回数组(你也可以做),而不是把它作为一个输出参数。

That doesn't mean it will certainly compile, but it is legal code. That being said, it's probably better to just return the array (which you can also do), rather than pass it as an output parameter.

这篇关于你可以通过一个固定大小的数组作为GLSL函数参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆