예제 #1
0
파일: render.go 프로젝트: willemvds/sdl
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
}
예제 #2
0
파일: render.go 프로젝트: emlai/go-sdl2
// 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
}
예제 #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))
}
예제 #4
0
파일: render.go 프로젝트: JalfResi/go-sdl2
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))
}