OpenGL ES Shading Language : array

本文介绍了OpenGL ES着色语言中矩阵构造的基本规则,包括如何通过单一标量创建对角矩阵,以及如何使用多个向量或标量构建矩阵。此外,还讨论了OpenGL ES着色语言中数组使用的限制,如不允许使用编译时未知值的变量进行索引,以及数组初始化的特殊语法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

For matrix construction, the language is very flexible. These basic rules
describe how matrices can be constructed:
• If only one scalar argument is provided to a matrix constructor, that
value is placed in the diagonal of the matrix. For example mat4(1.0)
will create a 4 × 4 identity matrix.
• A matrix can be constructed out of multiple vector arguments, for
example a mat2 can be constructed from two vec2s.
• A matrix can be constructed out of multiple scalar arguments, one for

each value in the matrix, consumed from left to right.


There are two important things to note about the use of arrays in the
OpenGL ES Shading Language. The first is that many OpenGL ES implementations
will not allow an array to be indexed with a variable with an
unknown value at compile time. That is, OpenGL ES only mandates that
array indexing be supported by constant integral expressions (there is an
exception to this, which is the indexing of uniform variables in vertex shaders
that is discussed in Chapter 8).


The other note about arrays is that there is no syntax in the OpenGL ES
Shading Language to initialize an array at creation time. The elements of the
array need to be initialized one-by-one and also arrays cannot be const qualified
because there is no syntax for initializing such an array.


The comparison operators (==, !=, <, etc.) can only be performed on scalar
values.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值