本文整理匯總了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)
}