【问题标题】:How do I fill the screen with a rectangle in OpenGL ortho mode?如何在 OpenGL 正交模式下用矩形填充屏幕?
【发布时间】:2010-12-21 23:48:28
【问题描述】:

我有一个需要填满屏幕的 640x480 纹理。到目前为止,我可以让它使用方形纹理,但不能使用矩形纹理。

glViewport(0, 0, display->w, display->h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

double aspectRatio = (double)display->w / (double)display->h;

if (display->w <= display->h)
    glOrtho(-1, 1, -1 / aspectRatio, 1 / aspectRatio, -1, 1);
else
    glOrtho(-1 * aspectRatio, 1 * aspectRatio, -1, 1, -1, 1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

我需要进行哪些修改才能使其适合屏幕的任何纹理,无论其纵横比如何?

【问题讨论】:

    标签: c opengl fullscreen textures aspect-ratio


    【解决方案1】:

    这可能有一些相关性。

    Tiling texture bmp file as texture onto a rectangle in OpenGL?

    您可能希望将 ARB 扩展纹理矩形视为(假设为 glTexImage2D?)http://glprogramming.com/red/chapter09.html

    的替代方法

    【讨论】:

    • 如果我正确理解所有内容(我可能没有,因为这是我第一次使用 OpenGL),如果我的卡不支持非 power-of,我只需要纹理矩形扩展- 两种纹理。我已经能够创建纹理并将其显示在屏幕上,但我的正交设置正在制作四边形。我认为我的计算只是需要调整,但我不确定需要做什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-31
    • 2014-03-26
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多