The following code works fine as a proc, but not as a template:
proc BufferData*[T](target:BufferTarget, data:openarray[T], usage:BufferDataUsage) =
glBufferData(target.GLenum,data.len*T.sizeof().GLsizeiptr,data.unsafeAddr,usage.GLenum)
Any obvious reason changing proc to template might go wrong there? It compiles fine, but doesn't run properly.
you can always inspect the generated C code to see what are the differences between them.
One thing I spotted which could be a potential hidden bug is data.unsafeAddr. When the data is an ordinary array, it would be ok. But when it is a seq, crash is almost guaranteed.
safer way to write it would be data[0].unsafeAddr, safe for array and seq