anholt / libepoxy

Epoxy is a library for handling OpenGL function pointer management for you
Other
677 stars 161 forks source link

Help understanding #286

Open ghost opened 1 year ago

ghost commented 1 year ago

Hi there I'm struggling to understand how to use libepoxy.

If I cat /usr/local/include/epoxy/egl_generated.h

Then I can see lines like this:

#define eglBindAPI epoxy_eglBindAPI
#define eglBindTexImage epoxy_eglBindTexImage
#define eglChooseConfig epoxy_eglChooseConfig
#define eglClientSignalSyncEXT epoxy_eglClientSignalSyncEXT
#define eglClientWaitSync epoxy_eglClientWaitSync
#define eglClientWaitSyncKHR epoxy_eglClientWaitSyncKHR
#define eglClientWaitSyncNV epoxy_eglClientWaitSyncNV
#define eglCompositorBindTexWindowEXT epoxy_eglCompositorBindTexWindowEXT
#define eglCompositorSetContextAttributesEXT epoxy_eglCompositorSetContextAttributesEXT
#define eglCompositorSetContextListEXT epoxy_eglCompositorSetContextListEXT
#define eglCompositorSetSizeEXT epoxy_eglCompositorSetSizeEXT
#define eglCompositorSetWindowAttributesEXT epoxy_eglCompositorSetWindowAttributesEXT
#define eglCompositorSetWindowListEXT epoxy_eglCompositorSetWindowListEXT
#define eglCompositorSwapPolicyEXT epoxy_eglCompositorSwapPolicyEXT
#define eglCopyBuffers epoxy_eglCopyBuffers

Am I mean to be able to directly call these epoxy_ prefixed functions in my code?

Currently in my code I have this sort of thing, but it appears to be duplicating what I can see above?

// epoxy function pointers
PFNEGLDESTROYSTREAMKHRPROC epoxy_eglDestroyStreamKHR;
PFNEGLCREATESTREAMKHRPROC epoxy_eglCreateStreamKHR;
PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC epoxy_eglGetStreamFileDescriptorKHR;
PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC epoxy_eglCreateStreamFromFileDescriptorKHR;
PFNEGLGETPLATFORMDISPLAYEXTPROC epoxy_eglGetPlatformDisplayEXT;

void load_epoxy_function_pointers() {
    epoxy_eglDestroyStreamKHR = (PFNEGLDESTROYSTREAMKHRPROC) epoxy_eglGetProcAddress("eglDestroyStreamKHR");
    epoxy_eglCreateStreamKHR = (PFNEGLCREATESTREAMKHRPROC) epoxy_eglGetProcAddress("eglCreateStreamKHR");
    epoxy_eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC) epoxy_eglGetProcAddress("eglGetPlatformDisplayEXT");
    epoxy_eglGetStreamFileDescriptorKHR = (PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) epoxy_eglGetProcAddress(
            "eglGetStreamFileDescriptorKHR");
    epoxy_eglCreateStreamFromFileDescriptorKHR = (PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) epoxy_eglGetProcAddress(
            "eglCreateStreamFromFileDescriptorKHR");
}

What is the "correct" way to set up and use egl extensions with libepoxy? I can't find any examples or documentation in this repository that says.

thanks!