// Renders Latin-1 text in the specified color and returns an SDL surface. Solid // rendering is quick, although not as smooth as the other rendering types. func RenderText_Solid(font *Font, text string, color sdl.Color) *sdl.Surface { ctext := C.CString(text) ccol := C.SDL_Color{C.Uint8(color.R), C.Uint8(color.G), C.Uint8(color.B), C.Uint8(color.Unused)} surface := C.TTF_RenderText_Solid(font.cfont, ctext, ccol) C.free(unsafe.Pointer(ctext)) return (*sdl.Surface)(unsafe.Pointer(surface)) }
func (f *Font) RenderText_Solid(text string, color sdl.Color) *sdl.Surface { _text := C.CString(text) defer C.free(unsafe.Pointer(_text)) _c := C.SDL_Color{C.Uint8(color.R), C.Uint8(color.G), C.Uint8(color.B), C.Uint8(color.A)} surface := (*sdl.Surface)(unsafe.Pointer(C.TTF_RenderText_Solid(f.f, _text, _c))) return surface }
func (f *Font) RenderTextSolid(text string, fg sdl.Color) (*sdl.Surface, error) { ctext := C.CString(text) ccolor := C.SDL_Color{C.Uint8(fg.R), C.Uint8(fg.G), C.Uint8(fg.B), C.Uint8(255)} s := C.TTF_RenderText_Solid(f.c, ctext, ccolor) if s == nil { return nil, getError() } return (*sdl.Surface)(unsafe.Pointer(s)), nil }
// Renders Latin-1 text in the specified color and returns an SDL surface. Solid // rendering is quick, although not as smooth as the other rendering types. func RenderText_Solid(font *Font, text string, color sdl.Color) *sdl.Surface { sdl.GlobalMutex.Lock() // Because 'C.TTF_Render*' uses 'C.SDL_CreateRGBSurface' font.mutex.Lock() // Use a write lock, because 'C.TTF_Render*' may update font's internal caches ctext := C.CString(text) ccol := C.SDL_Color{C.Uint8(color.R), C.Uint8(color.G), C.Uint8(color.B), C.Uint8(color.Unused)} surface := C.TTF_RenderText_Solid(font.cfont, ctext, ccol) C.free(unsafe.Pointer(ctext)) font.mutex.Unlock() sdl.GlobalMutex.Unlock() return wrap(surface) }