I have been going through the tutorials on LearnOpengl.com and building up type safe wrappers as I go along such that I can use opengl as if it were more like a native Nim library, removing the need for casting and making it a compile time error should you mix up your opengl id types. Also the compatible GLenum's for functions are put into enums for easy discovery of what your options are. You can see the library code here and some example usage here
It has been a fun way to learn Nim and OpenGL so far. I would love to have some feedback on whether I am going about this well, if anyone sees any obvious ways to do it better, project structure, anything. Also I am curious if something like this exists already, and if not how many people would be interested in it?
because it's not guaranteed
No it is not guaranteed, the C-compiler is free to ignore inline.
But can you give examples where inline pragma does not work fine? Nim copies procs marked with inline pragma into all C files when necessary, so inline works fine over module boundaries. I have not seen examples where inline procs does not work well. (For not exported, locally used small procs Araq once indeed recommended using templates instead of inline procs -- but I think even there was no real reason.)
If the compiler does not inline a proc marked inline it probably has a very good reason, probably related to code being to big or not being in a hot path (and avoids polluting cache lines).
So I think it's fine not to use templates here.
Note: instead of this:
proc rawSeq[T](s: seq[T]): ptr T =
{.emit: "result = `s`->data;".}
Use unsafeAddr(s[0])
Krux02- it looks like you are using a struct with a single field instead of a distinct type for things like shader/program ids. What are the pros/cons of that approach?
Thanks everyone, some good things to think about.