Why do different variations of glVertexAttribPointer exist?

前端 未结 3 783
傲寒
傲寒 2020-12-11 01:40

There are

glVertexAttribPointer()
glVertexAttribIPointer()
glVertexAttribLPointer()

As far as I know, glVertexAttribPointer ca

3条回答
  •  孤街浪徒
    2020-12-11 02:19

    I read about this in OpenGL Insights

    When using glVertexAttribPointer() everything gets cast to a float. While glVertexAttribIPointer() can only expose vertex arrays that store integers and glVertexAttribLPointer() is only for doubles.

    As confirmed by a quote on this OpenGL.org page:

    For glVertexAttribPointer, if normalized​ is set to GL_TRUE​, it indicates that values stored in an integer format are to be mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point. Otherwise, values will be converted to floats directly without normalization.

    For glVertexAttribIPointer, only the integer types GL_BYTE​, GL_UNSIGNED_BYTE​, GL_SHORT​, GL_UNSIGNED_SHORT​, GL_INT​, GL_UNSIGNED_INT​ are accepted. Values are always left as integer values.

    glVertexAttribLPointer specifies state for a generic vertex attribute array associated with a shader attribute variable declared with 64-bit double precision components. type​ must be GL_DOUBLE​. index​, size​, and stride​ behave as described for glVertexAttribPointer and glVertexAttribIPointer.

提交回复
热议问题