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

后端 未结 1 656
梦毁少年i
梦毁少年i 2020-12-20 03:43

...because the floats seem to be coming out fine, but there\'s something wrong with the ints.

Essentially I have a struct called \"BlockInstance\" which holds a

相关标签:
1条回答
  • 2020-12-20 04:01
    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.

    0 讨论(0)
提交回复
热议问题