by hellofunk · 10y ago · 0 comments
glBindBuffer(GLenum(GL_ARRAY_BUFFER), bufferIds[1])
glBufferData(GLenum(GL_ARRAY_BUFFER), sizeof(Float) * tcSize, tc, GLenum(GL_STATIC_DRAW))
That just looks silly to me.
#define GL_ARRAY_BUFFER 0x8892
Instead of a proper constant. Therefore, Swift interprets it as an integer, which is fairly reasonable. GLEnum is: typedef uint32_t GLenum;
Which is not compatible with Int in Swift, thus the "cast".If GL_ARRAY_BUFFER was:
extern GLenum GL_ARRAY_BUFFER;
It would work as expected.Regarding the post in your other comment, none of that really has anything to do with C interop. C doesn't even have generics, so the whole thrust of the article (that it's hard to build a generic function that works on all integer types) doesn't apply.
For numeric types that have a clear equivalence in C-land, Swift is seamless.