对于制服和顶点属性,OpenGL 索引和位置是否相同? [英] Are OpenGL indices and locations the same thing for uniforms and vertex attributes?

查看:62
本文介绍了对于制服和顶点属性,OpenGL 索引和位置是否相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 OpenGL 参考页面中,一些函数被标记使用统一位置,而其他函数被标记为使用统一指数.这些是同一回事吗?

In the OpenGL Reference Pages, some functions are marked as using uniform locations, while other functions are marked as using uniform indices. Are these the same thing?

与顶点属性类似,一些函数被标记为使用顶点属性索引,而 other 函数被标记为使用顶点属性位置.这些都一样吗?

Similarly for vertex attributes, some functions are marked as using vertex attribute indices, while other functions are marked as using vertex attribute locations. Are these the same?

推荐答案

在你的第一种情况下,Uniform 的 locationindex 不同>glGetActiveUniform().

In your first case, the location for an Uniform is different from the index used for glGetActiveUniform().

对于 glGetActiveUniform() 情况,索引只是一个介于 0 和您从 glGetProgram( GL_ACTIVE_UNIFORMS,...) 获得的值之间减去 1 的值.此 API 允许您查询程序的任何资源,并且您可以使用该方法迭代所有活动的制服.统一位置可能不是从 0 开始,也可能根本不连续.

For glGetActiveUniform() case, index is just a value between 0 and the value you get from glGetProgram( GL_ACTIVE_UNIFORMS,...) minus one. This API allows you to query any resources of the program, and you can iterate over all active uniforms with that method. The uniform locations may not start at 0, and may not be consecutive at all.

在您的第二个示例中,glGetAttribLocation()glEnableVertexAttribArray() 都引用相同的索引.GL 有一组通用属性,通常由它们的索引引用,从 0 开始.但是,为了让事情变得更有趣,还有 glGetActiveAttrib() 类似于 glGetActiveUniform() 一:这里,索引仅指活动属性的列表(范围从 0 到您从 glGetProgram( GL_ACTIVE_ATTRIBUTES,...) 获得的值减去 1,not 到实际的属性索引/位置.同样,此 API 允许您迭代所有存在(和活动)的属性.

In your second example, glGetAttribLocation() and glEnableVertexAttribArray() both refer to the same index. The GL has a set of generic attributes, which are generally referenced by their indices, starting from 0. However, to make things a little bit more interesting, there is also glGetActiveAttrib() which is similiar to the glGetActiveUniform() one: here, the index refers just to the list of active attributes (in the range 0 to the value you get from glGetProgram( GL_ACTIVE_ATTRIBUTES,...) minus one, and not to the actual attribute index/location. Again, this API allows you to iterate over all attributes which are present (and active).

这篇关于对于制服和顶点属性,OpenGL 索引和位置是否相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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