在GLSL-ES 2.0中,顶点属性是否可能是数组? [英] Is it possible for a vertex attribute to be an array in GLSL-ES 2.0?

查看:130
本文介绍了在GLSL-ES 2.0中,顶点属性是否可能是数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GLSL-ES中,可能有数组.例如, GLSL ES规范提供了以下统一变量示例,数组:

In GLSL-ES it's possible to have arrays. For example, the GLSL ES Specification gives the following example of a uniform variable that's an array:

uniform vec4 lightPosition[4];

是否可能具有作为数组的顶点属性?换句话说,根据规范,以下法律是否合法?

Is it possible to have vertex attributes that are arrays? In other words, is the following legal according to the spec?

attribute vec4 foo[3];  // three vec4s per vertex

GLSL ES规范中的任何地方是否明确提到答案(是或否)? (我找不到它,但是我没有阅读规范的每一行.)

Is the answer (either yes or no) explicitly mentioned anywhere in the GLSL ES Specification? (I can't find it, but I haven't read every line of the spec.)

此外,如果合法,那么如何使用OpenGL ES 2.0 API初始化这样的属性? (假设使用glVertexAttribPointer,顶点/数组元素/向量元素的布局是什么?)

Also, if it is legal, how does one initialize such an attribute using the OpenGL ES 2.0 API? (Assuming glVertexAttribPointer would be used, what is the layout of the vertices/array-elements/vector-elements?)

推荐答案

The GLSL ES 2.0 specification states that attributes cannot be declared as arrays.

在桌面GL中,您可以具有属性数组.当为属性分配属性索引时(使用glBindAttribLocation或通过链接的着色器自动进行索引),它将获得连续的属性,从您使用glBindAttribLocation时所请求的属性开始.因此,如果给foo位置5,则foo[0]将为5,foo[1]将为6,而foo[2]将为7.

In desktop GL, you can have attribute arrays. When the attribute is assigned an attribute index (either with glBindAttribLocation or automatically by the shader being linked), it will get consecutive attributes, starting with the one you requested if you used glBindAttribLocation. So if foo was given the location 5, foo[0] would be 5, foo[1] would be 6, and foo[2] would be 7.

如果有一些ES 2.0扩展允许属性数组,则可能会像这样工作.

If there is some ES 2.0 extension to allow attribute arrays, it would likely work like this.

这篇关于在GLSL-ES 2.0中,顶点属性是否可能是数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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