Ejemplo n.º 1
0
func (t *Texture) Lock64(r *Rect) (pix []uint64, pitch int, err error) {
	if r == nil {
		_, _, w, h, err := t.Query()
		if err != nil {
			return nil, 0, err
		}

		r = &Rect{
			W: int32(w),
			H: int32(h),
		}
	}

	var cpix unsafe.Pointer
	var cpitch C.int
	if C.SDL_LockTexture(t.c, r.c(), &cpix, &cpitch) != 0 {
		return nil, 0, getError()
	}

	pix = *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(cpix),
		Len:  int(r.W) * int(r.H),
		Cap:  int(r.W) * int(r.H),
	}))

	return pix, int(cpitch), nil
}
Ejemplo n.º 2
0
// Texture (https://wiki.libsdl.org/SDL_LockTexture)
func (texture *Texture) Lock(rect *Rect, pixels *unsafe.Pointer, pitch *int) error {
	_pitch := (*C.int)(unsafe.Pointer(pitch))
	_ret := C.SDL_LockTexture(texture.cptr(), rect.cptr(), pixels, _pitch)
	if _ret < 0 {
		return GetError()
	}
	return nil
}
Ejemplo n.º 3
0
func (texture *Texture) Lock(rect *Rect, pixels unsafe.Pointer, pitch *int) int {
	_texture := (*C.SDL_Texture)(unsafe.Pointer(texture))
	_rect := (*C.SDL_Rect)(unsafe.Pointer(rect))
	_pitch := (*C.int)(unsafe.Pointer(pitch))
	return (int)(C.SDL_LockTexture(_texture, _rect, &pixels, _pitch))
}
Ejemplo n.º 4
0
func (texture *Texture) Lock(rect *Rect, pixels unsafe.Pointer, pitch *int) int {
	_pitch := (*C.int)(unsafe.Pointer(pitch))
	return int(C.SDL_LockTexture(texture.cptr(), rect.cptr(), &pixels, _pitch))
}