gpt4 book ai didi

glsl - 如何在 GLSL 中复制数组?

转载 作者:行者123 更新时间:2023-12-01 06:30:42 30 4
gpt4 key购买 nike

我在 SL 引用中搜索了“copy”,但找不到任何相关内容。

如果我有:

float a[3] = float[3] (1.0,2.0,3.0);
float b[3] = a;

b现在指向 a ?如果我改变 b[0]会不会改变 a[0] ?
如果答案是肯定的,我是否可以使用复制功能来获取 a 的克隆?而不是指向它?谢谢

最佳答案

GLSL - The OpenGL Shading Language 4.6; 5.8. Assignments; page 114

Assignments of values to variable names are done with the assignment operator (=):

lvalue-expression = rvalue-expression

The lvalue-expression evaluates to an l-value. The assignment operator stores the value of r-value-expression into the l-value and returns an r-value with the type and precision of lvalue-expression.



在 glsl 中,没有什么像指针或引用,甚至是“移动”赋值。值总是被复制。

关于glsl - 如何在 GLSL 中复制数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51414054/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com