LWJGL 2D Hud Just Wont Budge

时间:2014-11-11 09:34:28

标签: java opengl 2d lwjgl

出于某种原因,我无法解决我的生活,这可以说明我在这里做错了什么。我想在我的3d东西上渲染一个2d的正交hud,它通过着色器渲染而不是绘制调用。我花了将近8个小时,我很好,请帮助。控制台中没有错误!

EngineWindow.bindAsRenderTarget(); //Set render target to display.

    glDepthMask(false);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_CLAMP);
    glEnable(GL_BLEND);
    glEnable(GL_TEXTURE_2D);

    glPushMatrix();

    glViewport(0, 0, width, height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, height, 0, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    System.out.println(this.x + " " + this.y + " " + this.width + " " + this.height); //Its at the right position too.

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    texture.bind(); //Binds blue texture with writing.

    glBegin(GL_QUADS);
    glVertex2i(x, y);
    glTexCoord2f(0f, 0f);
    glVertex2i(x, y+height);
    glTexCoord2f(0f, 1f);
    glVertex2i(x+width, y+height);
    glTexCoord2f(1f, 1f);
    glVertex2i(x+width, y);
    glTexCoord2f(1f, 0f);
    glEnd();

    glPopMatrix();

    glDepthFunc(GL_LESS);
    glDepthMask(true);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glDisable(GL_BLEND);
    glEnable(GL_DEPTH_CLAMP);

0 个答案:

没有答案