作者:gasperk
项目:pokemon-univers
func (s *Surface) SaveBMP(_file string) {
cfile := C.CString(_file)
defer C.free(unsafe.Pointer(cfile))
cparams := C.CString("wb")
defer C.free(unsafe.Pointer(cparams))
C.SDL_SaveBMP_RW(s.Get(), C.SDL_RWFromFile(cfile, cparams), C.int(1))
}
作者:gasperk
项目:pokemon-univers
func LoadBMP(_file string) *Surface {
cfile := C.CString(_file)
defer C.free(unsafe.Pointer(cfile))
cparams := C.CString("rb")
defer C.free(unsafe.Pointer(cparams))
return (*Surface)(C.SDL_LoadBMP_RW(C.SDL_RWFromFile(cfile, cparams), C.int(1)))
}
作者:TomMurra
项目:go-sdl
func LoadWAV(file string) *Chunk {
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_rb := C.CString("rb")
defer C.free(unsafe.Pointer(_rb))
return (*Chunk)(unsafe.Pointer(C.Mix_LoadWAV_RW(C.SDL_RWFromFile(_file, _rb), 1)))
}
作者:TomMurra
项目:go-sdl
func RWFromFile(file, mode string) *RWops {
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_mode := C.CString(mode)
defer C.free(unsafe.Pointer(_mode))
return (*RWops)(unsafe.Pointer(C.SDL_RWFromFile(_file, _mode)))
}
作者:beora
项目:fung
// Functions to create SDL_RWops structures from various data sources
// Creates an RWOPS from a file
func RWFromFile(file, mode string) *C.SDL_RWops {
cfile := cstr(file)
defer cfile.free()
cmode := cstr(mode)
defer cmode.free()
rw := C.SDL_RWFromFile(cfile, cmode)
return rw
}
作者:kyleconro
项目:gold
func LoadWAV(file string, spec *AudioSpec, audio_buf **uint8, audio_len *uint32) *AudioSpec {
_file := (C.CString)(file)
_spec := (*C.SDL_AudioSpec)(unsafe.Pointer(spec))
_audio_buf := (**C.Uint8)(unsafe.Pointer(audio_buf))
_audio_len := (*C.Uint32)(unsafe.Pointer(audio_len))
return (*AudioSpec)(unsafe.Pointer(C.SDL_LoadWAV_RW(C.SDL_RWFromFile(_file, C.CString("rb")),
1, _spec, _audio_buf, _audio_len)))
}
作者:flaz
项目:go-sdl
// LoadWAV (https://wiki.libsdl.org/SDL_LoadWAV)
func LoadWAV(file string, spec *AudioSpec, audioBuf **uint8, audioLen *uint32) *AudioSpec {
_file := C.CString(file)
_rb := C.CString("rb")
defer C.free(unsafe.Pointer(_file))
defer C.free(unsafe.Pointer(_rb))
_audioBuf := (**C.Uint8)(unsafe.Pointer(audioBuf))
_audioLen := (*C.Uint32)(unsafe.Pointer(audioLen))
return (*AudioSpec)(unsafe.Pointer(C.SDL_LoadWAV_RW(C.SDL_RWFromFile(_file, _rb), 1, spec.cptr(), _audioBuf, _audioLen)))
}
作者:swanteschol
项目:codin
func loadSound(name string) *C.Mix_Chunk {
cfile, rb := C.CString(name), C.CString("rb")
rwop := C.SDL_RWFromFile(cfile, rb)
C.free(unsafe.Pointer(cfile))
C.free(unsafe.Pointer(rb))
chunk := C.Mix_LoadWAV_RW(rwop, 1)
if chunk == nil {
panic(fmt.Sprintf("Unable to load Sound file (%v): %v", name, util.GetMixError()))
}
return chunk
}
作者:pakoha
项目:Go-SD
func LoadWAV(file string) *Chunk {
cfile := C.CString(file)
cchunk := C.Mix_LoadWAV_RW(C.SDL_RWFromFile(cfile, C.CString("rb")), 1)
C.free(unsafe.Pointer(cfile))
if cchunk == nil {
return nil
}
return &Chunk{cchunk}
}
作者:flaz
项目:go-sdl
func LoadWAV(file string) (chunk *Chunk, err error) {
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_rb := C.CString("rb")
defer C.free(unsafe.Pointer(_rb))
// why doesn't this call Mix_LoadWAV ?
chunk = (*Chunk)(unsafe.Pointer(C.Mix_LoadWAV_RW(C.SDL_RWFromFile(_file, _rb), 1)))
if chunk == nil {
err = sdl.GetError()
}
return
}
作者:gnanderso
项目:Go-SD
func RWFromFile(file string, mode int) *RWops {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
cmode := modeFromFlags(mode)
if cmode == nil {
return nil
}
defer C.free(unsafe.Pointer(cmode))
return (*RWops)(C.SDL_RWFromFile(cfile, cmode))
}
作者:DeedleFak
项目:sd
func RWFromFile(file string, mode string) (*RWops, error) {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
cmode := C.CString(mode)
defer C.free(unsafe.Pointer(cmode))
rw := C.SDL_RWFromFile(cfile, cmode)
if rw == nil {
return nil, getError()
}
return &RWops{rw}, nil
}
作者:tanem
项目:go-sdl
// LoadWAV (https://wiki.libsdl.org/SDL_LoadWAV)
func LoadWAV(file string, spec *AudioSpec) ([]byte, *AudioSpec) {
_file := C.CString(file)
_rb := C.CString("rb")
defer C.free(unsafe.Pointer(_file))
defer C.free(unsafe.Pointer(_rb))
var _audioBuf *C.Uint8
var _audioLen C.Uint32
audioSpec := (*AudioSpec)(unsafe.Pointer(C.SDL_LoadWAV_RW(C.SDL_RWFromFile(_file, _rb), 1, spec.cptr(), &_audioBuf, &_audioLen)))
var b []byte
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b))
sliceHeader.Len = (int)(_audioLen)
sliceHeader.Cap = (int)(_audioLen)
sliceHeader.Data = uintptr(unsafe.Pointer(_audioBuf))
return b, audioSpec
}
作者:velou
项目:u
func loadWAV(path string) (*audioData, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
var data *C.Uint8
var len C.Uint32
var s C.SDL_AudioSpec // Apparently just a buffer? SDL just zeroes it, fills it, and returns it.
spec := C.SDL_LoadWAV_RW(C.SDL_RWFromFile(cpath, rb), 1, &s, &data, &len)
if spec == nil {
return nil, sdlError()
}
var err error
data, len, err = convert(spec, data, len)
if err != nil {
return nil, err
}
return &audioData{
path: path,
data: unsafe.Pointer(data),
len: uintptr(len),
}, nil
}
作者:hybridgrou
项目:go-sdl
func LoadWAV(file string) *Chunk {
_file := (C.CString)(file)
return (*Chunk)(unsafe.Pointer(C.Mix_LoadWAV_RW(C.SDL_RWFromFile(_file,
C.CString("rb")), 1)))
}
作者:kerker
项目:gtg15-dem
func RWFromFile(file, mode string) *RWops {
_file := (C.CString)(file)
_mode := (C.CString)(mode)
return (*RWops)(unsafe.Pointer(C.SDL_RWFromFile(_file, _mode)))
}
作者:jbondeso
项目:Go-SDL
func RWFromFile(file string, mode string) *RWops {
cfile, cmode := C.CString(file), C.CString(mode)
defer C.free(unsafe.Pointer(cfile))
defer C.free(unsafe.Pointer(cmode))
return wrapRWops(C.SDL_RWFromFile(cfile, cmode))
}