veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.21k stars 221 forks source link

sdl: expose SDL_BYTESPERPIXEL and SDL_BITSPERPIXEL macros #404

Closed flga closed 5 years ago

flga commented 5 years ago

Currently, the only way to compute these values is to allocate a new PixelFormat and query it. Now, the existing macros are exposed as top level functions.

They could be implemented in go, but that would need maintenance, I opted to use cgo instead. The values in the test are the ones returned by the c implementation.

The documentation is a bit stuttery "xPerPixel returns the number of x per pixel", if anyone comes up with better wording, do tell!

veeableful commented 5 years ago

Thanks @flga for the work! I think the comments are just fine so I'll merge this :smiley: