liquidev / aglet

A safe, high-level, optimized OpenGL wrapper and context manager.
MIT License
29 stars 2 forks source link

Integer `Vec[T]` VAO Attributes are always passed as `GL_NONE` #15

Closed JohnDoneth closed 3 years ago

JohnDoneth commented 3 years ago

I'm storing color per vertex as Vec[4, system.uint8] to work with ImGui and noticed that the type for the vertex attribute was always being set to GL_NONE which lead me to discover this bug.

https://github.com/liquidev/aglet/blob/b689416f40de38ce727627ec197a4bd3db9110ab/src/aglet/gl.nim#L792

The expression T.toGlEnum will always evaluate to 0 or GL_NONE. It should be TT.toGlEnum instead, to work with the type inside of the Vec.

I will open a PR shortly. Should toGlEnum have a catch all which throws an exception?

liquidev commented 3 years ago

I don't exactly remember how toGlEnum(x) behaves when x is a type, but please make it throw an error for unsupported types using the {.error.} pragma, if it doesn't already do that.