Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for dynamically loading GL extensions #2

Open
nrdvana opened this issue Feb 10, 2022 · 0 comments
Open

API for dynamically loading GL extensions #2

nrdvana opened this issue Feb 10, 2022 · 0 comments

Comments

@nrdvana
Copy link

nrdvana commented Feb 10, 2022

Since OpenGL supports loading function pointers on demand, and this varies per platform, it seems reasonable to abstract this behavior in the Alien:: module. There is an entire separate project "GLEW" to deal with this problem, which we might or might not want to include. The main theme of GLEW is just to declare a lot of global pointer-to-function, and then lazy-load them on demand. I came up with a (greatly) simplified version of their loader for my OpenGL::Sandbox project, dealing with only the functions I needed, and named it "glducktape". I think the giant table of function pointers might be too much for the alien module (maybe best saved for a OpenGL::GLEW module), but wrapping the C loader function with a platform-neutral API would be small-ish and quite useful for the perl ecosystem.

The loader I wrote (linked above) is

void* glducktape_initProcAddress(const char *name, void **fnptr);

and implemented for Linux, Mac, and Win32. It is just a wrapper around dlsym, GetProcAddress, or glXGetProcAccress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant