Can I pack both floats and ints into the same array buffer?

你离开我真会死。 提交于 2019-11-29 12:42:17
layout (location = 4) in int TexIndex;

There's your problem.

glVertexAttribPointer is used to send data that will be converted to floating-point values. It's used to feed floating-point attributes. Passing integers is possible, but those integers are converted to floats, because that's what glVertexAttribPointer is for.

What you need is glVertexAttribIPointer (notice the I). This is used for providing signed and unsigned integer data.

So if you declare a vertex shader input as a float or some non-prefixed vec, you use glVertexAttribPointer to feed it. If you declare the input as int, uint, ivec or uvec, then you use glVertexAttribIPointer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!