在SDL 2中获取屏幕分辨率

huangapple go评论88阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2014年7月9日 04:00:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/24640745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定