本文整理汇总了Golang中github.com/veandco/go-sdl2/sdl.Window类的典型用法代码示例。如果您正苦于以下问题:Golang Window类的具体用法?Golang Window怎么用?Golang Window使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Window类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Render
func (this *WorldRenderer) Render(ww *gamestate.World, options *settings.BoolOptions, window *sdl.Window) {
camera := ww.Player.Camera
p0 := camera.Pos4f()
w, h := window.GetSize()
camera.MoveRelative(mgl.Vec4{-0.1, 0, 0, 0})
this.View = (ww.PortalTransform(p0, camera.Pos4f()).Mul4(camera.Model())).Inv()
viewport := Viewport{0, 0, w / 2, h}
viewport.Activate()
this.render(ww, options, viewport, 0, nil)
camera.MoveRelative(mgl.Vec4{+0.2, 0, 0, 0})
this.View = (ww.PortalTransform(p0, camera.Pos4f()).Mul4(camera.Model())).Inv()
viewport.X = w / 2
viewport.Activate()
this.render(ww, options, viewport, 0, nil)
gl.Viewport(0, 0, w, h)
gl.ActiveTexture(gl.TEXTURE0)
this.Framebuffer[0].RenderTexture.Bind(gl.TEXTURE_RECTANGLE)
this.ScreenQuadRenderer.Render(this.ScreenQuad, this.Proj, this.View, this.ClippingPlane_ws, nil)
if this.screenShot {
this.screenShot = false
helpers.SaveTexture(gl.TEXTURE_RECTANGLE, 0, "screenshot.png")
}
}
开发者ID:krux02,项目名称:turnt-octo-wallhack,代码行数:29,代码来源:WorldRenderer.go
示例2: NewGameState
func NewGameState(window *sdl.Window, world *World) (gamestate *GameState) {
gl.ClearColor(0., 0., 0.4, 0.0)
gl.Enable(gl.DEPTH_TEST)
bar := tw.NewBar("TweakBar")
gamestate = &GameState{
Window: window,
Camera: nil,
Bar: bar,
World: world,
Fps: 0,
Options: settings.BoolOptions{},
}
opt := &gamestate.Options
opt.Load()
gamestate.Camera = gamestate.World.Player.GetCamera()
tw.Define(" GLOBAL help='This example shows how to integrate AntTweakBar with SDL2 and OpenGL.' ")
bar.AddVarRO("fps", tw.TYPE_FLOAT, unsafe.Pointer(&gamestate.Fps), "")
opt.CreateGui(bar)
for i, portal := range gamestate.World.KdTree {
ptr := &(portal.(*Portal).Orientation)
bar.AddVarRW(fmt.Sprintf("Rotation %d", i), tw.TYPE_QUAT4F, unsafe.Pointer(ptr), "")
}
//window.GetSize(w, h)
w, h := window.GetSize()
tw.WindowSize(w, h)
return
}
开发者ID:krux02,项目名称:turnt-octo-wallhack,代码行数:35,代码来源:GameState.go
示例3: CreateMenus
func CreateMenus(window *sdl.Window, surface *sdl.Surface, renderer *sdl.Renderer, controlManager *inputManager.ControlManager) inputManager.Update {
progress := float64(0)
mutex := sync.Mutex{}
dx := 4 * surface.W / 8
startRect := sdl.Rect{surface.W / 4, 4 * surface.H / 7, 0, 2 * surface.H / 7}
midBackgroundRect := sdl.Rect{surface.W / 4, 4 * surface.H / 7, dx, 2 * surface.H / 7}
backgroundRect := sdl.Rect{surface.W/4 - 5, 4*surface.H/7 - 5, dx + 10, 2*surface.H/7 + 10}
var mainMenu *Menu
go asyncMenuCreator(renderer, &mutex, &progress, &mainMenu, surface.W, surface.H, window, controlManager)
return func(state int) int {
if controlManager.Player1.BF || controlManager.Player2.BF {
controlManager.Running = false
return -1
}
mutex.Lock()
startRect.W = int32(float64(dx) * progress)
surface.FillRect(&backgroundRect, 0xffff0000)
surface.FillRect(&midBackgroundRect, 0xff000000)
surface.FillRect(&startRect, 0xffff0000)
window.UpdateSurface()
if progress == 1 {
menuInfo := MenuInfo{0, controlManager, renderer, &sdl.Rect{0, 0, surface.W, surface.H}}
inputManager.UpdateFunctions = append(inputManager.UpdateFunctions, mainMenu.Open(0, &menuInfo))
return -1
}
mutex.Unlock()
return 0
}
}
开发者ID:ITR13,项目名称:campusFighterI,代码行数:29,代码来源:CreateMenus.go
示例4: createMainWindow
func createMainWindow() {
var err error
var mainWindow *sdl.Window
gc := gamecontext.GContext
gc.WindowWidth = 800
gc.WindowHeight = 600
mainWindow, err = sdl.CreateWindow("Eggdrop!", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, int(gc.WindowWidth), int(gc.WindowHeight), sdl.WINDOW_SHOWN)
if err != nil {
panic(err)
}
gc.MainSurface, err = mainWindow.GetSurface()
if err != nil {
panic(err)
}
gc.PixelFormatEnum, err = mainWindow.GetPixelFormat()
if err != nil {
panic(err)
}
gc.PixelFormat, err = sdl.AllocFormat(uint(gc.PixelFormatEnum)) // TODO why the cast? Seems to work?
if err != nil {
panic(err)
}
gc.MainWindow = mainWindow
}
开发者ID:beejjorgensen,项目名称:eggdrop,代码行数:30,代码来源:main.go
示例5: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var event sdl.Event
var running bool
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
var peepArray []sdl.Event = make([]sdl.Event, 5)
running = true
for running {
sdl.PumpEvents()
numEventsRetrieved := sdl.PeepEvents(peepArray, sdl.PEEKEVENT, sdl.FIRSTEVENT, sdl.LASTEVENT)
if numEventsRetrieved < 0 {
fmt.Printf("PeepEvents error: %s\n", sdl.GetError())
} else {
for i := 0; i < numEventsRetrieved; i++ {
fmt.Printf("Event Peeked Value: %v\n", peepArray[i]) // primitive printing of event
}
}
for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\ttype:%d\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel)
case *sdl.MouseButtonEvent:
fmt.Printf("[%d ms] MouseButton\ttype:%d\tid:%d\tx:%d\ty:%d\tbutton:%d\tstate:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.Button, t.State)
case *sdl.MouseWheelEvent:
fmt.Printf("[%d ms] MouseWheel\ttype:%d\tid:%d\tx:%d\ty:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y)
case *sdl.KeyUpEvent:
fmt.Printf("[%d ms] Keyboard\ttype:%d\tsym:%c\tmodifiers:%d\tstate:%d\trepeat:%d\n",
t.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)
}
}
sdl.Delay(1000 / 30)
}
renderer.Destroy()
window.Destroy()
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:57,代码来源:PeepEvents_peek.go
示例6: run
func run() int {
var window *sdl.Window
var renderer *sdl.Renderer
var points []sdl.Point
var rect sdl.Rect
var rects []sdl.Rect
window, err := sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", err)
return 1
}
defer window.Destroy()
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", err)
return 2
}
defer renderer.Destroy()
renderer.Clear()
renderer.SetDrawColor(255, 255, 255, 255)
renderer.DrawPoint(150, 300)
renderer.SetDrawColor(0, 0, 255, 255)
renderer.DrawLine(0, 0, 200, 200)
points = []sdl.Point{{0, 0}, {100, 300}, {100, 300}, {200, 0}}
renderer.SetDrawColor(255, 255, 0, 255)
renderer.DrawLines(points)
rect = sdl.Rect{300, 0, 200, 200}
renderer.SetDrawColor(255, 0, 0, 255)
renderer.DrawRect(&rect)
rects = []sdl.Rect{{400, 400, 100, 100}, {550, 350, 200, 200}}
renderer.SetDrawColor(0, 255, 255, 255)
renderer.DrawRects(rects)
rect = sdl.Rect{250, 250, 200, 200}
renderer.SetDrawColor(0, 255, 0, 255)
renderer.FillRect(&rect)
rects = []sdl.Rect{{500, 300, 100, 100}, {200, 300, 200, 200}}
renderer.SetDrawColor(255, 0, 255, 255)
renderer.FillRects(rects)
renderer.Present()
sdl.Delay(2000)
return 0
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:56,代码来源:render.go
示例7: GetMouseDirection
func GetMouseDirection(window *sdl.Window, mx, my int) (dir_cs mgl.Vec4) {
if !sdl.GetRelativeMouseMode() {
W, H := window.GetSize()
x := (2*float32(mx) - float32(W)) / float32(H)
y := (float32(H) - 2*float32(my)) / float32(H)
dir_cs = mgl.Vec4{x, y, -1, 0}
} else {
dir_cs = mgl.Vec4{0, 0, -1, 0}
}
return
}
开发者ID:krux02,项目名称:turnt-octo-wallhack,代码行数:11,代码来源:Input.go
示例8: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var points []sdl.Point
var rect sdl.Rect
var rects []sdl.Rect
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
renderer.SetDrawColor(255, 255, 255, 255)
renderer.DrawPoint(150, 300)
renderer.SetDrawColor(0, 0, 255, 255)
renderer.DrawLine(0, 0, 200, 200)
points = []sdl.Point{{0, 0}, {100, 300}, {100, 300}, {200, 0}}
renderer.SetDrawColor(255, 255, 0, 255)
renderer.DrawLines(points)
rect = sdl.Rect{300, 0, 200, 200}
renderer.SetDrawColor(255, 0, 0, 255)
renderer.DrawRect(&rect)
rects = []sdl.Rect{{400, 400, 100, 100}, {550, 350, 200, 200}}
renderer.SetDrawColor(0, 255, 255, 255)
renderer.DrawRects(rects)
rect = sdl.Rect{250, 250, 200, 200}
renderer.SetDrawColor(0, 255, 0, 255)
renderer.FillRect(&rect)
rects = []sdl.Rect{{500, 300, 100, 100}, {200, 300, 200, 200}}
renderer.SetDrawColor(255, 0, 255, 255)
renderer.FillRects(rects)
renderer.Present()
sdl.Delay(2000)
renderer.Destroy()
window.Destroy()
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:53,代码来源:render.go
示例9: main
func main() {
var winTitle string = "Go-SDL2 + Go-GL"
var winWidth, winHeight int = 800, 600
var window *sdl.Window
var context sdl.GLContext
var event sdl.Event
var running bool
var err error
if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
if err = gl.Init(); err != nil {
panic(err)
}
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_OPENGL)
if err != nil {
panic(err)
}
defer window.Destroy()
context, err = sdl.GL_CreateContext(window)
if err != nil {
panic(err)
}
defer sdl.GL_DeleteContext(context)
gl.Enable(gl.DEPTH_TEST)
gl.ClearColor(0.2, 0.2, 0.3, 1.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Viewport(0, 0, int32(winWidth), int32(winHeight))
running = true
for running {
for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n", t.Timestamp, t.Which, t.X, t.Y, t.XRel, t.YRel)
}
}
drawgl()
sdl.GL_SwapWindow(window)
}
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:50,代码来源:opengl.go
示例10: run
func run() int {
var window *sdl.Window
var renderer *sdl.Renderer
var texture *sdl.Texture
var src, dst sdl.Rect
var err error
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", err)
return 1
}
defer window.Destroy()
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", err)
return 2
}
defer renderer.Destroy()
image, err := img.Load(imageName)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load PNG: %s\n", err)
return 3
}
defer image.Free()
texture, err = renderer.CreateTextureFromSurface(image)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create texture: %s\n", err)
return 4
}
defer texture.Destroy()
src = sdl.Rect{0, 0, 512, 512}
dst = sdl.Rect{100, 50, 512, 512}
renderer.Clear()
renderer.SetDrawColor(255, 0, 0, 255)
renderer.FillRect(&sdl.Rect{0, 0, int32(winWidth), int32(winHeight)})
renderer.Copy(texture, &src, &dst)
renderer.Present()
sdl.Delay(2000)
return 0
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:49,代码来源:texture_png.go
示例11: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var event sdl.Event
var running bool
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
running = true
for running {
event = sdl.WaitEventTimeout(1000) // wait here until an event is in the event queue
if event == nil {
fmt.Println("WaitEventTimeout timed out")
continue
}
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\ttype:%d\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel)
case *sdl.MouseButtonEvent:
fmt.Printf("[%d ms] MouseButton\ttype:%d\tid:%d\tx:%d\ty:%d\tbutton:%d\tstate:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.Button, t.State)
case *sdl.MouseWheelEvent:
fmt.Printf("[%d ms] MouseWheel\ttype:%d\tid:%d\tx:%d\ty:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y)
case *sdl.KeyUpEvent:
fmt.Printf("[%d ms] Keyboard\ttype:%d\tsym:%c\tmodifiers:%d\tstate:%d\trepeat:%d\n",
t.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)
}
}
renderer.Destroy()
window.Destroy()
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:48,代码来源:WaitEventTimeout.go
示例12: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var texture *sdl.Texture
var src, dst sdl.Rect
window = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if window == nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", sdl.GetError())
os.Exit(1)
}
renderer = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if renderer == nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", sdl.GetError())
os.Exit(2)
}
image := img.Load(imageName)
if image == nil {
fmt.Fprintf(os.Stderr, "Failed to load PNG: %s\n", sdl.GetError())
os.Exit(3)
}
texture = renderer.CreateTextureFromSurface(image)
if texture == nil {
fmt.Fprintf(os.Stderr, "Failed to create texture: %s\n", sdl.GetError())
os.Exit(4)
}
src = sdl.Rect{0, 0, 512, 512}
dst = sdl.Rect{100, 50, 512, 512}
renderer.Clear()
renderer.SetDrawColor(255, 0, 0, 255)
renderer.FillRect(&sdl.Rect{0, 0, int32(winWidth), int32(winHeight)})
renderer.Copy(texture, &src, &dst)
renderer.Present()
sdl.Delay(2000)
image.Free()
texture.Destroy()
renderer.Destroy()
window.Destroy()
}
开发者ID:JalfResi,项目名称:go-sdl2,代码行数:47,代码来源:texture_png.go
示例13: Draw
func Draw(window *sdl.Window, parsedInput *ParsedInput, loop *bool) inputManager.Update {
surface, err := window.GetSurface()
if err != nil {
panic(err)
}
surface.FillRect(&sdl.Rect{0, 0, surface.W, surface.H}, 0xff000000)
var player2Rects [6]sdl.Rect
for i := 0; i < 6; i++ {
player2Rects[i] = sdl.Rect{(256 + player1Rects[i].X), (player1Rects[i].Y), (player1Rects[i].W), (player1Rects[i].H)}
}
return func(state int) int {
if *loop {
for i := 0; i < 6; i++ {
if parsedInput[i] {
surface.FillRect(&player1Rects[i], 0xffff0000)
} else {
surface.FillRect(&player1Rects[i], 0xffffff00)
}
if parsedInput[i+6] {
surface.FillRect(&player2Rects[i], 0xffff0000)
} else {
surface.FillRect(&player2Rects[i], 0xffffff00)
}
}
if parsedInput[12] {
surface.FillRect(&sdl.Rect{192, 160, 64, 64}, 0xffff0000)
} else {
surface.FillRect(&sdl.Rect{192, 160, 64, 64}, 0xffffff00)
}
if parsedInput[13] {
surface.FillRect(&sdl.Rect{192, 224, 64, 64}, 0xffff0000)
} else {
surface.FillRect(&sdl.Rect{192, 224, 64, 64}, 0xffffff00)
}
err := window.UpdateSurface()
if err != nil {
panic(err)
}
} else {
return -1
}
return 0
}
}
开发者ID:ITR13,项目名称:campusFighterI,代码行数:46,代码来源:Graphics.go
示例14: main
func main() {
var window *sdl.Window
var renderer *sdl.Renderer
var image *sdl.Surface
var texture *sdl.Texture
var src, dst sdl.Rect
var err error
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", err)
os.Exit(1)
}
defer window.Destroy()
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", err)
os.Exit(2)
}
defer renderer.Destroy()
image, err = sdl.LoadBMP(imageName)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load BMP: %s\n", err)
os.Exit(3)
}
defer image.Free()
texture, err = renderer.CreateTextureFromSurface(image)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create texture: %s\n", err)
os.Exit(4)
}
defer texture.Destroy()
src = sdl.Rect{0, 0, 512, 512}
dst = sdl.Rect{100, 50, 512, 512}
renderer.Clear()
renderer.Copy(texture, &src, &dst)
renderer.Present()
sdl.Delay(2000)
}
开发者ID:flazz,项目名称:go-sdl2,代码行数:46,代码来源:texture.go
示例15: run
func run() int {
var window *sdl.Window
var renderer *sdl.Renderer
var event sdl.Event
var running bool
var err error
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
winWidth, winHeight, sdl.WINDOW_SHOWN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", err)
return 1
}
defer window.Destroy()
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create renderer: %s\n", err)
return 2
}
defer renderer.Destroy()
running = true
for running {
for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseMotionEvent:
fmt.Printf("[%d ms] MouseMotion\ttype:%d\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel)
case *sdl.MouseButtonEvent:
fmt.Printf("[%d ms] MouseButton\ttype:%d\tid:%d\tx:%d\ty:%d\tbutton:%d\tstate:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y, t.Button, t.State)
case *sdl.MouseWheelEvent:
fmt.Printf("[%d ms] MouseWheel\ttype:%d\tid:%d\tx:%d\ty:%d\n",
t.Timestamp, t.Type, t.Which, t.X, t.Y)
case *sdl.KeyUpEvent:
fmt.Printf("[%d ms] Keyboard\ttype:%d\tsym:%c\tmodifiers:%d\tstate:%d\trepeat:%d\n",
t.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)
}
}
}
return 0
}
开发者ID:tianon,项目名称:gb-integration-tests,代码行数:46,代码来源:events.go
示例16: DestroyWindow
// DestroyWindow closes the window, freeing any resources as it does so.
// It must be called for each window that has been created before the program
// exists.
//
// DestroyWindow will panic if:
//
// 1. The toolbox has not been initialised.
//
// 2. The window is invalid
//
// 3. CreateWindow has not been called.
func DestroyWindow(window Window) {
if !initialised {
// this stops execution here, so ne need for an else after the if
panic(notInitialisedMessage)
}
if renderer == nil {
// this stops execution here, so ne need for an else after the if
panic(windowNotInitialisedMessage)
}
if window == nil {
panic("The Window is invalid. Have you used toolbox.CreateWindow(...)?")
}
var w *sdl.Window
w = window
if renderer != nil { // should always be true - see createWindow - but be defensive
renderer.Destroy()
}
w.Destroy()
}
开发者ID:gophercoders,项目名称:toolbox,代码行数:30,代码来源:toolbox.go
示例17: createWindow
// Create the graphics window using the SDl library or crash trying
func createWindow(w, h int, title string) *sdl.Window {
var window *sdl.Window
var err error
window, err = sdl.CreateWindow(title, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
w, h, sdl.WINDOW_SHOWN)
if err != nil {
panic(err)
}
// we're all good to create the renderer....
renderer, err = createRenderer(window)
if err != nil {
// Oops, we failed to create the renderer failed
// cleanup the window before we panic
window.Destroy()
panic(err)
}
// at this point we have both a good renderer and a good window
return window
}
开发者ID:gophercoders,项目名称:toolbox,代码行数:22,代码来源:toolbox.go
示例18: main
func main() {
var window *sdl.Window
var info sdl.SysWMInfo
var subsystem string
var err error
window, err = sdl.CreateWindow("", 0, 0, 0, 0, sdl.WINDOW_HIDDEN)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create window: %s\n", err)
os.Exit(1)
}
defer window.Destroy()
sdl.VERSION(&info.Version)
if window.GetWMInfo(&info) {
switch info.Subsystem {
case sdl.SYSWM_UNKNOWN:
subsystem = "An unknown system!"
case sdl.SYSWM_WINDOWS:
subsystem = "Microsoft Windows(TM)"
case sdl.SYSWM_X11:
subsystem = "X Window System"
case sdl.SYSWM_DIRECTFB:
subsystem = "DirectFB"
case sdl.SYSWM_COCOA:
subsystem = "Apple OS X"
case sdl.SYSWM_UIKIT:
subsystem = "UIKit"
}
fmt.Printf("This program is running SDL version %d.%d.%d on %s\n",
info.Version.Major,
info.Version.Minor,
info.Version.Patch,
subsystem)
} else {
fmt.Fprintf(os.Stderr, "Couldn't get window information: %s\n", sdl.GetError())
}
}
开发者ID:flazz,项目名称:go-sdl2,代码行数:40,代码来源:syswminfo.go
示例19: main
func main() {
var (
err error
window *sdl.Window
context sdl.GLContext
)
if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_COMPATIBILITY)
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
if err != nil {
panic(err)
}
defer window.Destroy()
context, err = sdl.GL_CreateContext(window)
if err != nil {
panic(err)
}
defer sdl.GL_DeleteContext(context)
if err = sdl.GL_MakeCurrent(window, context); err != nil {
panic(err)
}
if err = gl.Init(); err != nil {
panic(err)
}
sdl.GL_SetSwapInterval(1)
printGLInfo()
setupGL()
windowLoop(window)
}
开发者ID:sweco-secfbr,项目名称:octatron,代码行数:40,代码来源:debugger.go
示例20: main
func main() {
var (
err error
window *sdl.Window
context sdl.GLContext
)
if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
sdl.GL_SetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 3)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 2)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE)
window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
if err != nil {
panic(err)
}
defer window.Destroy()
context, err = sdl.GL_CreateContext(window)
if err != nil {
panic(err)
}
defer sdl.GL_DeleteContext(context)
if err = sdl.GL_MakeCurrent(window, context); err != nil {
panic(err)
}
if err = gl.Init(); err != nil {
panic(err)
}
printGLInfo()
cameraMatrixUniform := setupGL()
windowLoop(window, cameraMatrixUniform)
}
开发者ID:sweco-secfbr,项目名称:octatron,代码行数:40,代码来源:raytracer.go
注:本文中的github.com/veandco/go-sdl2/sdl.Window类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论