You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, SdlSurface expects all Surfaces to be SDL_PIXELFORMAT_RGBA32, which is a problem when interacting with other libraries, such as SDL image.
For example, to load an image, one needs to do:
defloadImage(path: CString):RamSurface=valoriginalSurface=IMG_Load(path)
if (originalSurface ==null) thrownewRuntimeException("Failed to load image")
valformattedSurface=SDL_ConvertSurfaceFormat(originalSurface, SDL_PixelFormatEnum.SDL_PIXELFORMAT_RGBA32.uint, 0.toUInt)
valramSurface=SdlSurface.withRawData(formattedSurface)(_.toRamSurface())
SDL_FreeSurface(originalSurface)
SDL_FreeSurface(formattedSurface)
ramSurface
There should at least be some helper to convert a Ptr[SDL_Surface] to a RamSurface and take care of converting the surface if needed and free any temporary objects.
A smart constructor (or multiple SdlSurface implementations that support different formats) could also be nice, as views over surfaces can also be broken.
The text was updated successfully, but these errors were encountered:
Right now,
SdlSurface
expects all Surfaces to beSDL_PIXELFORMAT_RGBA32
, which is a problem when interacting with other libraries, such as SDL image.For example, to load an image, one needs to do:
There should at least be some helper to convert a
Ptr[SDL_Surface]
to aRamSurface
and take care of converting the surface if needed and free any temporary objects.A smart constructor (or multiple
SdlSurface
implementations that support different formats) could also be nice, as views over surfaces can also be broken.The text was updated successfully, but these errors were encountered: