【问题标题】:Allegro 5 game: How do I set a resolution that is appropriate for the aspect ratio of the screen?Allegro 5 游戏:如何设置适合屏幕纵横比的分辨率?
【发布时间】:2009-08-02 04:11:48
【问题描述】:

使用 Allegro 5,如何在全屏模式下初始化游戏,使其尊重屏幕格式(宽屏 16:9 与普通 3:4)

al_create_display (w, h)

让您选择所需的任何比率。例如,您可以设置 640x480,而不管屏幕大小。但在宽屏显示器上看起来会很奇怪。 你怎么知道使用哪个比率?

【问题讨论】:

    标签: fullscreen resolution widescreen allegro5


    【解决方案1】:

    嗯,我也可以回答这个问题 - 使用 al_get_monitor_info()

    al_get_monitor_info(0, &info);
    w = info.x2 - info.x1; /* Assume this is 1366 */
    h = info.y2 - info.y1; /* Assume this is 768 */
    al_create_display(w, h);
    

    现在,您可以在 640x480 矩形中渲染所有内容,以 1366x768 为中心,使其看起来像素完美,或者将图形放大 768/480,并在左右两侧保留两个黑条。如果使用 OpenGL 进行渲染,只需更改投影矩阵即可轻松实现。

    【讨论】:

      猜你喜欢
      • 2011-10-27
      • 2012-10-06
      • 2021-09-05
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多