SDL_GetCameras(3)

πŸ’– SDL_GetCameras πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual β€” the whole thing lives in the Simple Directmedia Layer docs, and it's all about cameras. Let's get into it πŸŽ€


✨ NAME ✨

SDL_GetCameras β€” get a list of currently connected camera devices πŸ‘€πŸ“·


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_camera.h>

SDL_CameraID * SDL_GetCameras(int *count);

πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • count β€” a pointer that gets filled in with the number of cameras that were returned. and listen, it's totally fine if this is NULL, no pressure πŸ’…

πŸ‘‘ RETURN VALUE πŸ‘‘

So what do you get back? Either:

  • a 0 terminated array of camera instance IDs, slay ✨ β€” the array ends with a zero, that's how you know it's done
  • or NULL if it failed 😭 in which case you gotta call SDL_GetError() for more info, she'll tell you what went wrong
and when you're done with that array, free it with SDL_free(). don't just leave it lying around, that's not the vibe. free your stuff, periodt 🫢

🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. no cap. every thread, all at once, she doesn't care 🌈


⭐ AVAILABILITY ⭐

This function has been available since SDL 3.2.0 β€” so if you're on something older... babe. upgrade πŸ’€


πŸ’œ SEE ALSO πŸ’œ

  • SDL_OpenCamera(3) β€” like, obviously, you get the list and then you open one πŸ™ˆ

and that's the whole page!! mwah πŸ’‹ this one shipped as part of Simple Directmedia Layer, SDL 3.4.18, dated the same β€” so go forth, enumerate your webcams, and stay iconic πŸ‘‘πŸ’–

πŸ“¦ where this page comes from