Ejemplo n.º 1
0
func CreateCursor(data []uint8, mask []uint8, w, h, hx, hy int) (*Cursor, error) {
	wh := w * h
	if len(data) < wh {
		return nil, errors.New("len(data) < w * h")
	}
	if (len(mask) < wh) && (len(mask) > 0) {
		return nil, errors.New("len(mask) < w * h and > 0")
	}

	var mp *C.Uint8
	if len(mask) > 0 {
		mp = (*C.Uint8)(unsafe.Pointer(&mask[0]))
	}

	c := C.SDL_CreateCursor(
		(*C.Uint8)(unsafe.Pointer(&data[0])),
		mp,
		C.int(w),
		C.int(h),
		C.int(hx),
		C.int(hy),
	)
	if c == nil {
		return nil, getError()
	}

	return &Cursor{c}, nil
}
Ejemplo n.º 2
0
func CreateCursor(data, mask *uint8, w, h, hot_x, hot_y int) *Cursor {
	_data := (*C.Uint8)(unsafe.Pointer(data))
	_mask := (*C.Uint8)(unsafe.Pointer(mask))
	_w := (C.int)(w)
	_h := (C.int)(h)
	_hot_x := (C.int)(hot_x)
	_hot_y := (C.int)(hot_y)
	return (*Cursor)(C.SDL_CreateCursor(_data, _mask, _w, _h, _hot_x, _hot_y))
}
Ejemplo n.º 3
0
// CreateCursor (https://wiki.libsdl.org/SDL_CreateCursor)
func CreateCursor(data, mask *uint8, w, h, hotX, hotY int) *Cursor {
	_data := (*C.Uint8)(unsafe.Pointer(data))
	_mask := (*C.Uint8)(unsafe.Pointer(mask))
	return (*Cursor)(C.SDL_CreateCursor(_data, _mask, C.int(w), C.int(h), C.int(hotX), C.int(hotY)))
}