當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.TTF_RenderUTF8_Solid函數代碼示例

本文整理匯總了Golang中C.TTF_RenderUTF8_Solid函數的典型用法代碼示例。如果您正苦於以下問題:Golang TTF_RenderUTF8_Solid函數的具體用法?Golang TTF_RenderUTF8_Solid怎麽用?Golang TTF_RenderUTF8_Solid使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了TTF_RenderUTF8_Solid函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RenderUTF8_Solid

// Renders UTF-8 text in the specified color and returns an SDL surface.  Solid
// rendering is quick, although not as smooth as the other rendering types.
func RenderUTF8_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_RenderUTF8_Solid(font.cfont, ctext, ccol)
	C.free(unsafe.Pointer(ctext))
	return (*sdl.Surface)(unsafe.Pointer(surface))
}
開發者ID:jgastal,項目名稱:Go-SDL,代碼行數:9,代碼來源:ttf.go

示例2: RenderUTF8Solid

func (f *Font) RenderUTF8Solid(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_RenderUTF8_Solid(f.c, ctext, ccolor)
	if s == nil {
		return nil, getError()
	}
	return (*sdl.Surface)(unsafe.Pointer(s)), nil
}
開發者ID:willemvds,項目名稱:sdl,代碼行數:9,代碼來源:ttf.go

示例3: RenderUTF8_Solid

// RenderUTF8_Solid (https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf_44.html#SEC44)
func (f *Font) RenderUTF8_Solid(text string, color sdl.Color) (*sdl.Surface, error) {
	_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_RenderUTF8_Solid(f.f, _text, _c)))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
開發者ID:veandco,項目名稱:go-sdl2,代碼行數:11,代碼來源:sdl_ttf.go

示例4: GetOutline

/*
func (this Font) GetOutline() int {

}
func (this Font) SetOutline(outline int) {

}
func (this Font) GetHinting() Hinting {

}
func (this Font) SetHinting(hinting Hinting) {

}
func (this Font) Height() int {

}
func (this Font) Ascent() int {

}
func (this Font) Descent() int {

}
func (this Font) LineSkip() int {

}
func (this Font) GetKerning() int {

}
func (this Font) SetKerning(allowed int) {

}
func (this Font) Faces() int64 {

}
func (this Font) FaceIsFixedWidth() bool {

}
func (this Font) FaceFamilyName() string {

}
func (this Font) FaceStyleName() string {

}
func (this Font) SizeText(text string) (width int, height int, err error) {

}
*/
func (this Font) RenderTextSolid(text string, color sdl.Color) (sdl.Surface, error) {
	c_font := (*C.TTF_Font)(this.Ptr)
	c_text := C.CString(text)
	defer C.free(unsafe.Pointer(c_text))
	c_color := *(*C.SDL_Color)(unsafe.Pointer(&color))
	ret := C.TTF_RenderUTF8_Solid(c_font, c_text, c_color)
	if ret == nil {
		return sdl.Surface{}, sdl.GetError()
	}
	return sdl.Surface{unsafe.Pointer(ret)}, nil
}
開發者ID:badgerodon,項目名稱:go,代碼行數:58,代碼來源:ttf.go

示例5: RenderUTF8_Solid

// Renders UTF-8 text in the specified color and returns an SDL surface.  Solid
// rendering is quick, although not as smooth as the other rendering types.
func RenderUTF8_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_RenderUTF8_Solid(font.cfont, ctext, ccol)
	C.free(unsafe.Pointer(ctext))

	font.mutex.Unlock()
	sdl.GlobalMutex.Unlock()

	return wrap(surface)
}
開發者ID:Zwobot,項目名稱:Go-SDL,代碼行數:16,代碼來源:ttf.go

示例6: TTFRenderSolid

// Create an 8-bit palettized surface and render the given text at
// fast quality with the given font and color.  The 0 pixel is the
// colorkey, giving a transparent background, and the 1 pixel is set
// to the text color.
// This function returns the new surface, or NULL if there was an error.
// Works with UTF8 encoded strings.
func TTFRenderSolid(font *C.TTF_Font, text string,
	color C.SDL_Color) *C.SDL_Surface {
	ctext := cstr(text)
	defer ctext.free()
	return C.TTF_RenderUTF8_Solid(font, ctext, color)
}
開發者ID:beoran,項目名稱:fungo,代碼行數:12,代碼來源:ttf.go


注:本文中的C.TTF_RenderUTF8_Solid函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。