Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
639 views
in Technique[技术] by (71.8m points)

opengl - Why do different variations of glVertexAttribPointer exist?

There are

glVertexAttribPointer()
glVertexAttribIPointer()
glVertexAttribLPointer()

As far as I know, glVertexAttribPointer can be used instead of the other two.

If so, why do the I and L variations exist?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...