Call C define function

I find some way call OpenGL in swift but some problem with glad function:

typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type);
GLAPI PFNGLCREATESHADERPROC glad_glCreateShader;
#define glCreateShader glad_glCreateShader

error: cannot find 'glCreateShader' in scope
When use glad_glCreateShader everything ok. I find define doc but not for function.
What best solutuion for this ? Create file C wrap all function or let glCreateShader = glad_glCreateShader!
What are your experiences with organizing this project code structure ?
P/S Sorry for my English.

I haven't found a better way of doing it than just wrapping all of the functions like you suggested.

That might not be the best practice but one doesn't really change the contents of the glad.h/glad.c files that often anyways so it's really a matter of wrapping the functions once and be done with it.

I have done my own version of the wrappers here up to OpenGL 4.6.1 so if you just want to test it out, you can just copy that to your project.
(Note that if you are targeting older versions of OpenGL like OpenGL 3.x.x then you'll need to delete some of the functions in the wrapper file since they might not be defined in your glad.h)

Thank for help. Now I call all function with glad_ for simple and clean in future will build glad swift when more knowerk of swift.

Terms of Service

Privacy Policy

Cookie Policy