當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.SDL_RWFromFile函數代碼示例

本文整理匯總了Golang中C.SDL_RWFromFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang SDL_RWFromFile函數的具體用法?Golang SDL_RWFromFile怎麽用?Golang SDL_RWFromFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SDL_RWFromFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SaveBMP

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))
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:7,代碼來源:image.go

示例2: LoadBMP

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)))
}
開發者ID:gasperko,項目名稱:pokemon-universe,代碼行數:7,代碼來源:image.go

示例3: LoadWAV

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)))
}
開發者ID:TomMurray,項目名稱:go-sdl2,代碼行數:7,代碼來源:sdl_mixer.go

示例4: RWFromFile

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)))
}
開發者ID:TomMurray,項目名稱:go-sdl2,代碼行數:7,代碼來源:sdl_rwops.go

示例5: RWFromFile

// 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
}
開發者ID:beoran,項目名稱:fungo,代碼行數:10,代碼來源:sdl.go

示例6: LoadWAV

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)))
}
開發者ID:kyleconroy,項目名稱:golds,代碼行數:8,代碼來源:sdl_audio.go

示例7: LoadWAV

// 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)))
}
開發者ID:flazz,項目名稱:go-sdl2,代碼行數:10,代碼來源:audio.go

示例8: loadSound

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
}
開發者ID:swantescholz,項目名稱:coding,代碼行數:11,代碼來源:sound.go

示例9: LoadWAV

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}
}
開發者ID:pakohan,項目名稱:Go-SDL,代碼行數:11,代碼來源:mixer.go

示例10: LoadWAV

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
}
開發者ID:flazz,項目名稱:go-sdl2,代碼行數:12,代碼來源:sdl_mixer.go

示例11: RWFromFile

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))
}
開發者ID:gnanderson,項目名稱:Go-SDL,代碼行數:12,代碼來源:sdl.go

示例12: RWFromFile

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
}
開發者ID:DeedleFake,項目名稱:sdl,代碼行數:14,代碼來源:rwops.go

示例13: LoadWAV

// 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
}
開發者ID:tanema,項目名稱:go-sdl2,代碼行數:18,代碼來源:audio.go

示例14: loadWAV

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
}
開發者ID:velour,項目名稱:ui,代碼行數:24,代碼來源:audio.go

示例15: LoadWAV

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)))
}
開發者ID:hybridgroup,項目名稱:go-sdl2,代碼行數:5,代碼來源:sdl_mixer.go


注:本文中的C.SDL_RWFromFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。