Esempio n. 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)))
}
Esempio n. 2
0
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
}
Esempio n. 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))
}
Esempio n. 4
0
// 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

}
Esempio n. 5
0
func RWFromMem(m []byte) *RWops {
	return (*RWops)(C.SDL_RWFromMem(unsafe.Pointer(&m[0]), C.int(len(m))))
}
Esempio n. 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
}