绘制到屏幕时纹理变形

时间:2013-03-19 20:52:47

标签: java opengl lwjgl

我正在尝试在屏幕上绘制HUD。我目前根据玩家的健康状况显示心脏。图像是透明的,我启用了 glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

代码:

public void drawHUD() {
    for(int i = 1; i <= p.getHealth(); i++) {
        heart.bind();
        float y = 30;
        float x = 35 * i;
        glPushMatrix();
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0);
            glVertex2f(x, y);
            glTexCoord2f(0, 1);
            glVertex2f(x + w.block_size, y);
            glTexCoord2f(1, 1);
            glVertex2f(x + w.block_size, y + w.block_size);
            glTexCoord2f(0, 1);
            glVertex2f(x, y + w.block_size);
        glEnd();
        glPopMatrix();
    }
}

心脏:

enter image description here

绘制时:

enter image description here

(纹理为32x32)

0 个答案:

没有答案