Beispiel #1
0
func GetError() error {
	e := C.IMG_GetError()
	if e == nil {
		return nil
	}
	return errors.New(C.GoString(e))
}
Beispiel #2
0
func LoadImageRW(_data *[]byte, _size int) *Surface {
	rawImage := C.SDL_RWFromMem(unsafe.Pointer(&((*_data)[0])), C.int(_size))
	img := C.IMG_Load_RW(rawImage, C.int(0))
	if img == nil {
		fmt.Printf("ImageRW load error: %v", C.GoString(C.IMG_GetError()))
	}
	return (*Surface)(cast(img))
}
Beispiel #3
0
func LoadImage(_file string) *Surface {
	cfile := C.CString(_file)
	defer C.free(unsafe.Pointer(cfile))
	img := C.IMG_Load(cfile)
	if img == nil {
		fmt.Printf("Image load error: %v", C.GoString(C.IMG_GetError()))
	}
	return (*Surface)(cast(img))
}
Beispiel #4
0
func LoadImage(_file string) (*Surface, error) {
	cfile := C.CString(_file)
	defer C.free(unsafe.Pointer(cfile))
	img := C.IMG_Load(cfile)
	if img == nil {
		return nil, errors.New("Image load error: " + C.GoString(C.IMG_GetError()))
	}
	return (*Surface)(cast(img)), nil
}