Пример #1
0
func wrap(cSurface *C.SDL_Surface) *sdl.Surface {
	var s *sdl.Surface

	if cSurface != nil {
		var surface sdl.Surface
		surface.SetCSurface(unsafe.Pointer(cSurface))
		s = &surface
	} else {
		s = nil
	}

	return s
}
Пример #2
0
func (renderer *SDLRenderer) renderLine(pos int, line string) {
	x := renderer.commandLineRect.X
	y := int16(renderer.commandLineRect.Y) - int16(renderer.fontHeight*uint(pos))
	w := renderer.commandLineRect.W
	h := renderer.commandLineRect.H

	renderer.internalSurface.FillRect(&sdl.Rect{x, y, w, h}, 0)

	if len(line) == 0 {
		return
	}

	var textSurface *sdl.Surface
	if renderer.Blended {
		textSurface = ttf.RenderUTF8_Blended(renderer.Font, line, renderer.Color)
	} else {
		textSurface = ttf.RenderUTF8_Solid(renderer.Font, line, renderer.Color)
	}

	if textSurface != nil {
		renderer.internalSurface.Blit(&sdl.Rect{x, y, w, h}, textSurface, nil)
		textSurface.Free()
	}
}