Function gles31::load_gl_functions

source ·
pub unsafe fn load_gl_functions(
    load_fn: &dyn Fn(*const u8) -> *const c_void
) -> Result<(), Vec<&'static str>>
Expand description

Loads all GL function pointers.

In general, one cannot statically or dynamically link to GL functions. The functions are often specific to a particular GL context, and so they can only be loaded at runtime, once a GL context has been created and made current.

This module stores one static address value per GL function. When you call a GL function from this module, it loads the address out of the static, and if the address is non-null it calls that address (if the address is null it will panic).

Calling load_gl_functions allows you to initialize all of the static address values. This should generally be done just once, after your GL context is created and made current.

Safety

  • The load_fn you provide is passed the start of a zero-terminated string naming each GL command. It must use this pointer to load that GL command’s pointer using the appropriate platform function, then return that value.
  • When the platform loader fails to load a GL function it will generally return the null address, though error addresses of 1, 2, 3, and -1 have also been seen on some systems. All of these addresses are treated as failed loads, and will store null into the static.

Failure

  • Returns Ok when all functions load successfully. Otherwise you will get an Err with a list of all functions that failed to load.
  • The loading process does not “early return”. It will always attempt to load all functions, only returning the list of errors at the end.