英文:
Getting screen resolution in SDL 2
问题
我正在尝试获取本机屏幕分辨率,并使用sdl 2(github.com/veandco/go-sdl2/sdl)和go创建一个相同大小的窗口。
这是我尝试过的代码:
var desktop sdl.DisplayMode
sdl.GetDesktopDisplayMode(0, &desktop)
mainwindow := sdl.CreateWindow("Test App", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, desktop.W, desktop.H, sdl.WINDOW_OPENGL | sdl.WINDOW_FULLSCREEN)
当我使用这段代码时,得到的窗口大小始终为0,0。我做错了什么?
平台是x86_64 Linux,使用X服务器。
英文:
I'm trying to get the native screen resolution and create a window of that size using sdl 2 (github.com/veandco/go-sdl2/sdl) and go.
This is what I tried:
var desktop sdl.DisplayMode
sdl.GetDesktopDisplayMode(0, &desktop)
mainwindow := sdl.CreateWindow("Test App", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, desktop.W, desktop.H, sdl.WINDOW_OPENGL | sdl.WINDOW_FULLSCREEN)
When I use this the size of the resulting window is always 0, 0 what am I doing wrong?
Platform is x86_64 Linux using the X-server.
答案1
得分: 0
尝试使用sdl.WINDOW_FULLSCREEN_DESKTOP
而不是sdl.WINDOW_FULLSCREEN
。它应该以当前分辨率全屏显示。
英文:
Try using sdl.WINDOW_FULLSCREEN_DESKTOP instead of sdl.WINDOW_FULLSCREEN. It should go fullscreen at the current resolution.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论