OpenGL 4.0++ 核心配置文件中固定功能管道的属性位置是什么? [英] What are the Attribute locations for fixed function pipeline in OpenGL 4.0++ core profile?

查看:19
本文介绍了OpenGL 4.0++ 核心配置文件中固定功能管道的属性位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 nVidia OpenGL 驱动程序的固定管道(未附加着色器)内的属性位置:

glVertex = 0颜色= 3glNormal = ?glTexCoord = ?glMultiTexCoord 0..7 = ?glSecondaryColor = ?雾霾 = ?

根据经验,我找到了 Vertex 和 Primary Color 的位置,但仍然很高兴能够了解它们.

如果您想知道原因,那么出于兼容性原因,甚至是 GLSL 调试(只是为了查看在着色器尚未工作时我是否将正确的数据传递到正确的位置)等等...

解决方案

在 NVIDIA 驱动程序之外,这不起作用(可靠).兼容的驱动程序只会将 glVertexPointer (...) 别名为属性槽 0.NV 以其无穷的智慧在多年前设计了一个标准的非标准方案,其中他们将所有固定功能指针别名为某些属性位置,但我不知道新的 NV 驱动程序是否支持这一点(老实说,我从来没有足够关心尝试,这是一种糟糕的做法).您可能仍然可以找到 NV 的别名映射文档,但您不会通过利用他们的非标准行为而使任何人受益.

虽然其他驱动程序也可能将固定函数指针别名为通用顶点属性位置,但不存在其映射的文档.与 NV 不同,我不相信映射不会在驱动程序版本、硬件或平台之间发生变化.事实上,即使使用 NV 驱动程序,您也不应该利用这一点 - 它旨在促进传统支持,而不是作为用于新软件的功能.

最重要的是,改用通用顶点属性或使用兼容性配置文件和 GLSL 版本,该版本仍然支持专为获取固定函数顶点数据而设计的预声明变量(例如 gl_Colorgl_Normalgl_MultiTexCoord0...7、...).但不要混合搭配您所描述的方式.

还要花一些时间来查看 .我特别提到 NV 的唯一原因是因为他们选择在 GLSL 中重用别名,而其他供应商的兼容实现将只尊重第一个别名 (glVertexPointer (...) to 0) 在 GLSL 中.

I would like to know the attribute locations inside fixed pipeline (no shader attached) for nVidia OpenGL drivers:

glVertex = 0
glColor = 3
glNormal = ?
glTexCoord = ?
glMultiTexCoord 0..7 = ?
glSecondaryColor = ?
glFog = ?

Empirically I found the Vertex and primary Color locations but still will be nice to know them all.

If you want to know why, then for compatibility reasons and even for GLSL debugging (just to see if I pass the correct data to correct locations when shader not works yet) and so on ...

解决方案

Outside of NVIDIA drivers, this does not work (reliably). Compliant drivers will only alias glVertexPointer (...) to attribute slot 0. NV in their infinite wisdom devised a standard non-standard scheme many years ago where they aliased all of the fixed-function pointers to certain attribute locations, but I do not know if new NV drivers support this (I honestly have never cared enough to try, it is such a bad practice). You might still be able to find NV's documentation for their alias mappings, but you are not benefiting anyone by taking advantage of their non-standard behavior.

While other drivers may also alias the fixed-function pointers to generic vertex attribute locations, no documentation exists for their mappings. Unlike NV, I would not trust that the mapping would not change between driver versions, hardware or platform. In fact, even using NV drivers you should not take advantage of this - it was intended to promote legacy support and not as a feature used for new software.

The bottom line is, use generic vertex attributes instead or use a compatibility profile and a version of GLSL that still supports the pre-declared variables that are specifically designed for getting fixed-function vertex data (e.g. gl_Color, gl_Normal, gl_MultiTexCoord0...7, ...). But do not mix-and-match both the way you are describing.

Also take some time to review glGetPointerv (...). If you want to get information about the fixed-function pointers outside of GLSL, this is the proper way to do it. Do not rely on vertex attribute aliasing, because the concept of attribute locations is fundamentally a programmable pipeline feature. It did not even exist in unextended OpenGL prior to 2.0 (it was introduced with the ARB Vertex Program assembly language and promoted into core with GLSL).


Update:

While I still strongly advise against using this information, I was able to find exactly what you wanted:

Release Notes for NVIDIA OpenGL Shading Language Support - November 9, 2006 - pp. 7-8

Vertex Attribute Aliasing

GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA’s hardware approach and necessary for maintaining compatibility with existing OpenGL applications that NVIDIA customers rely on.

NVIDIA’s GLSL implementation therefore does not allow built-in vertex attributes to collide with a generic vertex attributes that is assigned to a particular vertex attribute index with glBindAttribLocation. For example, you should not use gl_Normal (a built-in vertex attribute) and also use glBindAttribLocation to bind a generic vertex attribute named "whatever" to vertex attribute index 2 because gl_Normal aliases to index 2.

  

In case you were wondering, this is also outlined in Table X.1 of the ARB Vertex Program extension specification. The only reason I mentioned NV specifically is because they chose to re-use the aliasing in GLSL whereas compliant implementations from other vendors will only honor the first alias (glVertexPointer (...) to 0) in GLSL.

这篇关于OpenGL 4.0++ 核心配置文件中固定功能管道的属性位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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