Example #1
0
func (src *Surface) Blit(srcrect *Rect, dst *Surface, dstrect *Rect) int {
	_src := (*C.SDL_Surface)(unsafe.Pointer(src))
	_srcrect := (*C.SDL_Rect)(unsafe.Pointer(srcrect))
	_dst := (*C.SDL_Surface)(unsafe.Pointer(dst))
	_dstrect := (*C.SDL_Rect)(unsafe.Pointer(dstrect))
	return (int)(C.SDL_BlitSurface(_src, _srcrect, _dst, _dstrect))
}
Example #2
0
//Draws the image at the given coordinates.
func (me *Canvas) DrawImage(img *Image, x, y int) {
	C.SDL_SetAlpha(img.img, C.SDL_SRCALPHA, 255)
	var dest C.SDL_Rect
	dest.x = C.Sint16(x + me.origin.X)
	dest.y = C.Sint16(y + me.origin.Y)
	C.SDL_BlitSurface(img.img, nil, me.pane, &dest)
}
Example #3
0
func (s *Surface) Blit(bounds image.Rectangle, x, y int, target *Surface) {
	mutex.Lock()
	defer mutex.Unlock()

	targetRect := convertRect(image.Rect(x, y, x, y))
	sourceRect := convertRect(bounds)
	C.SDL_BlitSurface(s.ptr, &sourceRect, target.ptr, &targetRect)
}
Example #4
0
func (dst *Surface) Blit(dstrect *Rect, src *Surface, srcrect *Rect) int {
	var ret = C.SDL_BlitSurface(
		(*C.SDL_Surface)(cast(src)),
		(*C.SDL_Rect)(cast(srcrect)),
		(*C.SDL_Surface)(cast(dst)),
		(*C.SDL_Rect)(cast(dstrect)))

	return int(ret)
}
Example #5
0
// Blit performs a fast blit from the source surface to the destination surface.
//
// srcRect represents the rectangle to be copied or image.ZR to copy the entire
// surface.
//
// dstPoint represents the destination position.
func (src *Surface) Blit(srcRect image.Rectangle, dst *Surface, dstPoint image.Point) (err error) {
	cSrcRect := cRect(srcRect)
	cDstRect := new(C.SDL_Rect)
	cDstRect.x = C.int(dstPoint.X)
	cDstRect.y = C.int(dstPoint.Y)
	if C.SDL_BlitSurface(src.cSurface, cSrcRect, dst.cSurface, cDstRect) != 0 {
		return getError()
	}
	return nil
}
Example #6
0
func BlitSurface(src Surface, srcrect *Rect, dst Surface, dstrect *Rect) error {
	c_src := (*C.SDL_Surface)(src.Ptr)
	c_srcrect := (*C.SDL_Rect)(unsafe.Pointer(srcrect))
	c_dst := (*C.SDL_Surface)(dst.Ptr)
	c_dstrect := (*C.SDL_Rect)(unsafe.Pointer(dstrect))
	ret := C.SDL_BlitSurface(c_src, c_srcrect, c_dst, c_dstrect)
	if ret == 0 {
		return nil
	}
	return GetError()
}
Example #7
0
File: sdl.go Project: rwcarlsen/sdl
func (s *Surface) Blit(other *Surface, src, dst *Rect) error {
	csrc := sdlRect(src)
	if src != nil {
		defer C.free(unsafe.Pointer(csrc))
	}

	cdst := sdlRect(dst)
	if dst != nil {
		defer C.free(unsafe.Pointer(cdst))
	}

	status := C.SDL_BlitSurface(s.surf, csrc, other.surf, cdst)
	if status != 0 {
		return sdlerr()
	}
	return nil
}
Example #8
0
func (src *Surface) Blit(srcRect *Rect, dst *Surface, dstRect *Rect) int {
	return int(C.SDL_BlitSurface(src.cptr(), srcRect.cptr(), dst.cptr(), dstRect.cptr()))
}
Example #9
0
// Surface (https://wiki.libsdl.org/SDL_BlitSurface)
func (src *Surface) Blit(srcRect *Rect, dst *Surface, dstRect *Rect) error {
	if C.SDL_BlitSurface(src.cptr(), srcRect.cptr(), dst.cptr(), dstRect.cptr()) != 0 {
		return GetError()
	}
	return nil
}
Example #10
0
//Draws the text at the given coordinates.
func (me *Canvas) DrawText(text *Text, x, y int) {
	var dest C.SDL_Rect
	dest.x = C.Sint16(x + me.origin.X)
	dest.y = C.Sint16(y + me.origin.Y)
	C.SDL_BlitSurface(text.text, nil, me.pane, &dest)
}