示例#1
0
func RWFromMem(mem unsafe.Pointer, size int) *RWops {
	if mem == nil {
		return nil
	}
	_size := (C.int)(size)
	return (*RWops)(unsafe.Pointer(C.SDL_RWFromMem(mem, _size)))
}
示例#2
0
文件: rwops.go 项目: DeedleFake/sdl
func RWFromMem(data []byte) (*RWops, error) {
	rw := C.SDL_RWFromMem(unsafe.Pointer(&data[0]), C.int(len(data)))
	if rw == nil {
		return nil, getError()
	}

	return &RWops{rw}, nil
}
示例#3
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))
}
示例#4
0
文件: rwops.go 项目: neagix/Go-SDL
// Creates an RWops from memory.
func RWFromMem(buf []byte) *RWops {
	GlobalMutex.Lock()
	defer GlobalMutex.Unlock()

	p := C.SDL_RWFromMem(unsafe.Pointer(&buf[0]), C.int(len(buf)))
	var rwops RWops
	rwops.cRWops = (*C.SDL_RWops)(p)
	rwops.gcBytes = buf
	return &rwops

}
示例#5
0
文件: sdl.go 项目: gnanderson/Go-SDL
func RWFromMem(m []byte) *RWops {
	return (*RWops)(C.SDL_RWFromMem(unsafe.Pointer(&m[0]), C.int(len(m))))
}
示例#6
0
func RWFromMem(mem []byte) *RWops {
	rw := wrapRWops(C.SDL_RWFromMem(unsafe.Pointer(&mem[0]), C.int(len(mem))))
	rw.mem = mem
	return rw
}