SDL_GETCAMERASUPPORTEDFORMATS(3)
π SDL_GetCameraSupportedFormats β the SDL3 functions girlies know this one π
okay bestie, so you know that camera of yours? the one that's been sitting there giving main character energy this whole time? yeah. this function is how you find out what it can actually do. it's SDL_GetCameraSupportedFormats(3) and it's iconic, no cap.
β¨ NAME β¨
SDL_GetCameraSupportedFormats β get the list of native formats/sizes a camera supports. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_camera.h>
SDL_CameraSpec ** SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count);
literally that's it. one call. slay.
πΈ DESCRIPTION πΈ
so what this does is: it hands you back a list of every format and frame size that one specific camera can offer you. and likeβ¦ why do you care? because if your app is the kind of chill app that can accept a bunch of different image formats and sizes, you're gonna wanna hunt down the optimal spec β the one that needs zero conversion. no extra work, no glow-up needed, it's already perfect. β¨
ngl, this function isn't strictly required. not mandatory. optional queen behavior. π
because here's the tea: if you call SDL_OpenCamera with a NULL spec, SDL will just pick a native format for you, like a friend choosing your outfit. and if you do specify a desired format? SDL will transparently convert to the requested format on your behalf. so either way you're covered, but knowing your options is always better, iykyk.
if count is not NULL, it gets filled in with the number of elements in the returned array. that's it, that's the deal. π
big note: it's completely legal for a camera to hand you an empty list. not a bug, not a glitch, just vibes. this is exactly what happens on Emscripten builds, because that platform won't tell you _anything_ about available cameras until you've already opened one. and it won't even tell you if there _is_ a camera until the user has given you permission to check β through a scary warning popup. π the popup is giving final boss energy fr fr.
π FUNCTION PARAMETERS π
instance_idβ the camera device instance ID. which camera we talkin' about bestie.countβ a pointer filled in with the number of elements in the list. may beNULL. it's giving optional.
π₯ RETURN VALUE π₯
returns a NULL terminated array of pointers to SDL_CameraSpec, or NULL on failure. π if it fails, call SDL_GetError() for more info, she'll tell you what went wrong.
heads up: this is a single allocation and you gotta free it with SDL_free() when you no longer need it. don't ghost your memory, bestie. free it. π«Ά
π§ THREAD SAFETY π§
it is safe to call this function from any thread. periodt. go off wherever you want. π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on an older version, sorry babe, upgrade. π
π SEE ALSO π
and that's the whole page, bestie!! go forth and interrogate your webcam π
~ with love from Simple Directmedia Layer, SDL 3.4.18, dated right there in the footer of the original SDL_GetCameraSupportedFormats(3) page ~ π¦β¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms