// AllocFormat creates a PixelFormat structure from a uint. // AllocFormat (https://wiki.libsdl.org/SDL_AllocFormat) func AllocFormat(format uint) (*PixelFormat, error) { r := (*PixelFormat)(unsafe.Pointer(C.SDL_AllocFormat(C.Uint32(format)))) if r == nil { return nil, GetError() } return r, nil }
func AllocFormat(f uint32) (*PixelFormat, error) { p := C.SDL_AllocFormat(C.Uint32(f)) if p == nil { return nil, getError() } return (*PixelFormat)(unsafe.Pointer(p)), nil }
func NewSurface(w, h int) (*Surface, error) { var curr C.SDL_DisplayMode if C.SDL_GetCurrentDisplayMode(0, &curr) != 0 { return nil, sdlerr() } pixfmt := C.SDL_AllocFormat(curr.format) s := C.SDL_CreateRGBSurface(0, C.int(w), C.int(h), C.int(pixfmt.BitsPerPixel), pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask, pixfmt.Amask) if s == nil { return nil, sdlerr() } surf := &Surface{s, pixfmt} runtime.SetFinalizer(surf, freesurf) return surf, nil }