SDL_EGLIntArrayCallback(3type)

πŸ’– SDL_EGLIntArrayCallback πŸ’–

okay bestie, welcome to the SDL3 DATATYPES corner of the man pages β€” this one is SDL_EGLIntArrayCallback(3type), and it's genuinely such a neat little type. it's a callback type for EGL surface/context attribute initialization. yes, it's giving very niche. yes, we're obsessed anyway. πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_video.h>

typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void *userdata, SDL_EGLDisplay display, SDL_EGLConfig config);

that's the whole signature, no cap. πŸ’…


🌸 DESCRIPTION 🌸

so here's the vibe: this gets called when SDL is trying to create an EGL surface, and it exists so that your app can sneak extra attributes into its eglCreateWindowSurface() or eglCreateContext calls. like, "hey SDL, lemme add a couple things before you go". iconic behavior honestly. ✨

and for convenience β€” because SDL loves you β€” the EGLDisplay and EGLConfig you should use are handed straight to the callback. no hunting, no guessing, they just show up. 🫢

now, the important part, so listen up:

  • your callback should return a pointer to an EGL attribute array that's terminated with EGL_NONE. that terminator is non-negotiable, it's the whole personality of the array.
  • if this function returns NULL, the SDL_CreateWindow process will fail gracefully β€” so it's not a catastrophe, but it is a no.
  • the returned pointer should be allocated with SDL_malloc() and it will be passed to SDL_free(). so SDL is doing the cleanup for you, bestie. you just have to allocate it the right way. 😭
  • the arrays returned by each callback will be appended to the existing attribute arrays defined by SDL. so you're not replacing anything, you're adding to the pile. more is more. πŸ’…

πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • userdata β€” an app-controlled pointer that is passed to the callback. it's yours, do whatever, SDL's just the messenger. πŸ’–
  • display β€” the EGL display to be used. ✨
  • config β€” the EGL config to be used. 🌈

πŸ’œ RETURN VALUE πŸ’œ

returns a newly-allocated array of attributes, terminated with EGL_NONE. don't forget the terminator, fr fr. πŸŽ€


⭐ AVAILABILITY ⭐

this datatype has been available since SDL 3.2.0. so if you're on something older... girl. πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

go read that one next, it's the whole friend group. 🫢


mwah πŸ’‹ that's the page! brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” stay slaying out there, and may all your attribute arrays end in EGL_NONE. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from