本文整理汇总了Golang中sdl.Event.Resize方法的典型用法代码示例。如果您正苦于以下问题:Golang Event.Resize方法的具体用法?Golang Event.Resize怎么用?Golang Event.Resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sdl.Event
的用法示例。
在下文中一共展示了Event.Resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
var done bool
var keys []uint8
sdl.Init(sdl.INIT_VIDEO)
var screen = sdl.SetVideoMode(640, 480, 16, sdl.OPENGL|sdl.RESIZABLE)
if screen == nil {
sdl.Quit()
panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
}
sdl.WM_SetCaption("Gears", "gears")
init_()
reshape(int(screen.W), int(screen.H))
done = false
for !done {
var event sdl.Event
idle()
for event.Poll() {
switch event.Type {
case sdl.VIDEORESIZE:
screen = sdl.SetVideoMode(int(event.Resize().W), int(event.Resize().H), 16,
sdl.OPENGL|sdl.RESIZABLE)
if screen != nil {
reshape(int(screen.W), int(screen.H))
} else {
panic("we couldn't set the new video mode??")
}
break
case sdl.QUIT:
done = true
break
}
}
keys = sdl.GetKeyState()
handleKeyPress(keys)
if keys[sdl.K_ESCAPE] != 0 {
done = true
}
draw()
}
sdl.Quit()
return
}
示例2: eventLoop
func (win *window) eventLoop() {
if win.ec == nil {
win.ec = make(chan interface{})
}
eloop:
for win.events {
var ev sdl.Event
for ev.Poll() {
switch ev.Type {
case sdl.KEYUP:
key := ev.Keyboard().Keysym.Sym
win.ec <- gui.KeyEvent{int(-key)}
case sdl.KEYDOWN:
key := ev.Keyboard().Keysym.Sym
win.ec <- gui.KeyEvent{int(key)}
case sdl.MOUSEMOTION:
m := ev.MouseMotion()
win.ec <- gui.MouseEvent{
Buttons: int(m.State),
Loc: image.Pt(int(m.X), int(m.Y)),
Nsec: time.Nanoseconds(),
}
case sdl.MOUSEBUTTONUP, sdl.MOUSEBUTTONDOWN:
m := ev.MouseButton()
win.ec <- gui.MouseEvent{
Buttons: int(sdl.GetMouseState(nil, nil)),
Loc: image.Pt(int(m.X), int(m.Y)),
Nsec: time.Nanoseconds(),
}
case sdl.VIDEORESIZE:
r := ev.Resize()
win.ec <- gui.ConfigEvent{image.Config{
win.Screen().ColorModel(),
int(r.W),
int(r.H),
}}
case sdl.QUIT:
break eloop
}
}
}
close(win.ec)
}
示例3: main
func main() {
flag.Parse()
var done bool
var keys []uint8
sdl.Init(sdl.INIT_VIDEO)
var screen = sdl.SetVideoMode(300, 300, 16, sdl.OPENGL|sdl.RESIZABLE)
if screen == nil {
sdl.Quit()
panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
}
sdl.WM_SetCaption("Gears", "gears")
init_()
reshape(int(screen.W), int(screen.H))
done = false
for !done {
var event sdl.Event
idle()
for event.Poll() {
switch event.Type {
case sdl.VIDEORESIZE:
screen = sdl.SetVideoMode(int(event.Resize().W), int(event.Resize().H), 16,
sdl.OPENGL|sdl.RESIZABLE)
if screen != nil {
reshape(int(screen.W), int(screen.H))
} else {
panic("we couldn't set the new video mode??")
}
break
case sdl.QUIT:
done = true
break
}
}
keys = sdl.GetKeyState()
if keys[sdl.K_ESCAPE] != 0 {
done = true
}
if keys[sdl.K_UP] != 0 {
view_rotx += 5.0
}
if keys[sdl.K_DOWN] != 0 {
view_rotx -= 5.0
}
if keys[sdl.K_LEFT] != 0 {
view_roty += 5.0
}
if keys[sdl.K_RIGHT] != 0 {
view_roty -= 5.0
}
if keys[sdl.K_z] != 0 {
if (sdl.GetModState() & sdl.KMOD_RSHIFT) != 0 {
view_rotz -= 5.0
} else {
view_rotz += 5.0
}
}
draw()
}
sdl.Quit()
return
}