最佳答案
自 SDL 2.0.0 起,您可以使用函数 SDL_RenderSetLogicalSize
to set a device independent resolution for rendering .
通过这种方式,您可以使用所需的目标分辨率设置渲染器并绘制所有内容,就好像您正在使用该分辨率一样。
我引用官方documentation :
This is nice in that you can change the logical rendering size to achieve various effects, but the primary use is this: instead of trying to make the system work with your rendering size, we can now make your rendering size work with the system. On my 1920x1200 monitor, this app thinks it's talking to a 640x480 resolution now, but SDL is using the GPU to scale it up to use all those pixels. Note that 640x480 and 1920x1200 aren't the same aspect ratio: SDL takes care of that, too, scaling as much as possible and letterboxing the difference.
请注意,您可以控制 bunch of hints 的缩放方式。 ,例如 SDL_HINT_RENDER_SCALE_QUALITY
。
关于c++ - 如何在 SDL 中更改窗口的分辨率?一切都太大了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34520273/