我正在尝试在屏幕上绘制 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();
}
}
心:
绘制时:
(纹理为 32x32)