SDL_STANDARD_GRAVITY(3)

✨ SDL_STANDARD_GRAVITY ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸ’– this one's a lil macro that literally just holds a number, but it's a number you're gonna want, so let's go 🫢


πŸŽ€ NAME πŸŽ€

SDL_STANDARD_GRAVITY β€” a constant that represents standard gravity, made specifically for accelerometer sensors. yes it's giving "physics class flashback" but make it C πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_sensor.h>

#define SDL_STANDARD_GRAVITY    9.80665f

that's it. that's the whole vibe. one include, one define, zero drama ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• your accelerometer reports the current acceleration in SI meters per second squared. and like β€” plot twist β€” that measurement includes the force of gravity. so a device that's just chillin', sitting at rest, not moving, living its best life? it'll read an value of SDL_STANDARD_GRAVITY away from the center of the earth 🌍

and the way that shows up is as a positive Y value. iconic. gravity said "up is positive on Y, you're welcome" 😌

fr fr, if your device is at rest and you're getting something wildly different from SDL_STANDARD_GRAVITY on Y, something's up β€” that's your vibe check πŸ‘€

🌈 AVAILABILITY 🌈

this macro has been around since SDL 3.2.0. so if you're on anything older, no it hasn't πŸ’€


Simple Directmedia Layer energy, SDL 3.4.18 version, and that's a wrap bestie πŸ’– slay responsibly, go measure some gravity, mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from