golang版本sdl2显示窗体

    go用syscall调用sdl2,在win10 x64上没问题,其他系统不敢保证。

    见地址

    1. package main
    2. import (
    3. "fmt"
    4. "github.com/moonfdd/sdl2-go/sdl"
    5. "github.com/moonfdd/sdl2-go/sdlcommon"
    6. )
    7. func main() {
    8. sdlcommon.SetSDL2Path("SDL2.dll")
    9. sdl.SDL_Init(sdl.SDL_INIT_VIDEO)
    10. window := sdl.SDL_CreateWindow("微信公众号:福大大架构师每日一题", sdl.SDL_WINDOWPOS_UNDEFINED, sdl.SDL_WINDOWPOS_UNDEFINED, 640, 480, sdl.SDL_WINDOW_OPENGL|sdl.SDL_WINDOW_RESIZABLE)
    11. if window == nil {
    12. fmt.Printf("Can't create window, err:%s", sdl.SDL_GetError())
    13. return
    14. }
    15. fmt.Println(window.SDL_GetWindowTitle())
    16. sdl.SDL_Delay(5000)
    17. window.SDL_DestroyWindow()
    18. sdl.SDL_Quit()
    19. }

    执行结果如下:

    golang版本sdl2显示窗体 - 图1