本文整理汇总了Golang中github.com/veandco/go-sdl2/sdl.Renderer.GetRendererOutputSize方法的典型用法代码示例。如果您正苦于以下问题:Golang Renderer.GetRendererOutputSize方法的具体用法?Golang Renderer.GetRendererOutputSize怎么用?Golang Renderer.GetRendererOutputSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/veandco/go-sdl2/sdl.Renderer
的用法示例。
在下文中一共展示了Renderer.GetRendererOutputSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DrawItem
func (m *Menu) DrawItem(renderer *sdl.Renderer, index int) {
var text_surface *sdl.Surface
var text_texture *sdl.Texture
var text_width, text_height int32
var text_rect sdl.Rect
var screen_width, _, _ int = renderer.GetRendererOutputSize()
for index, menu_item := range m.menu_items {
if index == m.selected_item {
text_surface = m.font.RenderText_Solid(menu_item.text, *m.selected_color)
} else {
text_surface = m.font.RenderText_Solid(menu_item.text, *m.unselected_color)
}
text_width = text_surface.W
text_height = text_surface.H
text_texture = renderer.CreateTextureFromSurface(text_surface)
text_rect = sdl.Rect{
int32(screen_width) - 10 - text_width, //X position
(m.font_size_32 * int32(index)),
text_width,
text_height,
}
renderer.Copy(text_texture, nil, &text_rect)
}
}
示例2: DrawTitle
func (m *Menu) DrawTitle(renderer *sdl.Renderer) {
var text_surface *sdl.Surface
var text_texture *sdl.Texture
var text_width, text_height int32
var title_rect sdl.Rect
var _, screen_height, _ int = renderer.GetRendererOutputSize()
text_surface = m.title_font.RenderText_Solid(m.menu_title, *m.title_color)
text_width = text_surface.W
text_height = text_surface.H
text_texture = renderer.CreateTextureFromSurface(text_surface)
title_rect = sdl.Rect{
20, //X position
int32(screen_height) - 20 - text_height, //Y position
text_width,
text_height,
}
renderer.Copy(text_texture, nil, &title_rect)
}