api - opengl当前顶点是什么?

标签 api opengl opengl-es opengl-es-2.0

这是我在 opengl 文档中找到的:

void glGetVertexAttribfv(GLuint index,  GLenum pname,  GLfloat *params);

GL_CURRENT_VERTEX_ATTRIB
             params returns four
        values that represent the current value for the
        generic vertex attribute specified by index. Generic
        vertex attribute 0 is unique in that it has no
        current state, so an error will be generated if
        index is 0. The initial value
        for all other generic vertex attributes is
        (0,0,0,1).
            glGetVertexAttribdv and glGetVertexAttribfv
            return the current attribute values as four single-precision floating-point values;
            glGetVertexAttribiv reads them as floating-point values and
            converts them to four integer values; glGetVertexAttribIiv and
            glGetVertexAttribIuiv read and return them as signed or unsigned
            integer values, respectively; glGetVertexAttribLdv reads and returns
            them as four double-precision floating-point values.

但我的问题是,我不知道当前的顶点是什么。如何设置当前顶点?我可以用它来测试我发送到 opengl 的属性是否包含正确的数据吗?

最佳答案

glGetVertexAttrib 返回与通用顶点属性关联的值,该属性可以使用 glVertexAttrib 函数进行设置。

更详细地说,OpenGL 中有两种可用的属性:

  1. 在执行绘制调用(例如,glDrawArrays)时处理的已启用顶点数组中为每个顶点更新的那些。
  2. 那些行为类似于着色器uniforms,用于为没有关联的启用的设置顶点数组的属性提供值。

例如,假设您使用 glVertexAttribPointerglEnableVertexAttribArray 启用两个数组用作顶点属性,然后通过调用 glDrawArrays( GL_POINTS, 0,点数)。在这种情况下,绑定(bind)的顶点着色器将被执行 NumPoints 次,每次从两个数组中读取一个新值。

但是,如果您仅在数组上启用(例如,顶点数组零),则可以使用 glVertexAttrib 函数为属性 1 设置属性值。如果您再次通过调用 glDrawArrays( GL_POINTS, 0, NumPoints ) 进行渲染,顶点着色器将再次执行 NumPoints 次,属性零的值将使用来自启用顶点属性数组,但属性值是“常量”,并设置为 glVertexAttrib 提供的值。

关于api - opengl当前顶点是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17961990/

相关文章:

c - 在 Windows 上使用 GCC (MinGW) 编译 OpenGL

c++ - 平行于向上 vector 转换阴影时的 LookAt 矩阵

java - LIBGDX - 着色器中不需要的纹理混合

api - Youtube v3 Data Api 按 channel ID 获取类别 ID

javascript - Google map 商店定位器和搜索

api - 用于创建源文件的 TypeScript API : how to get syntactic errors information

c++ - OpenGL程序可编译但无法正确启动

objective-c - 如何用一个顶点数组绘制不连续的线

iphone - 从 3D 建模器到 iPhone 应用程序 - 最佳实践是什么?

api - Facebook Connect 在个人 API 上进行身份验证