当前位置: 首页>>代码示例>>Golang>>正文


Golang C.TTF_RenderText_Solid函数代码示例

本文整理汇总了Golang中C.TTF_RenderText_Solid函数的典型用法代码示例。如果您正苦于以下问题:Golang TTF_RenderText_Solid函数的具体用法?Golang TTF_RenderText_Solid怎么用?Golang TTF_RenderText_Solid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TTF_RenderText_Solid函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: RenderText_Solid

// 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))
}
开发者ID:jgastal,项目名称:Go-SDL,代码行数:9,代码来源:ttf.go

示例2: RenderText_Solid

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
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:7,代码来源:sdl_ttf.go

示例3: RenderTextSolid

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
}
开发者ID:willemvds,项目名称:sdl,代码行数:9,代码来源:ttf.go

示例4: RenderText_Solid

// 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)
}
开发者ID:Zwobot,项目名称:Go-SDL,代码行数:16,代码来源:ttf.go


注:本文中的C.TTF_RenderText_Solid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。