[SDL 3.1.6] SDL_Surface and OpenGL format

If I have a SDL_Surface, how can I read out what format it is in order to pass it to glTexImage2D.

In the first versions you could get around this by omitting surface->format->bytes_per_pixel and surface->format->Rmask

I’m mainly interested in 24 and 32 bit images.