绘制文字后无法绘制任何四边形?

时间:2016-09-13 15:10:59

标签: java rendering lwjgl true-type-fonts

所以我正在制作一个3D游戏,我现在正在3D上工作2d但是在我完成它之前只有一个问题,那就是:我无法绘制任何我画了一个文字后的2d四边形? 这是渲染器代码:

changeto2D();
    for (Face2D face : tds){
        face.initializeEdges();
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glColor4f(face.c.red, face.c.green, face.c.blue, (float) Math.sin(Math.toRadians(face.transparency)));
        for (Location l : face.edges){
            GL11.glVertex2f(l.x, l.y);
        }
        GL11.glEnd();
    }
    for (Text t : texts){
        t.draw();
    }
    fps++;
    for (GUI gui : openGUIs){
        gui.draw();
    }
    for (GUI gui : removing){
        if (openGUIs.contains(gui)) openGUIs.remove(gui);
    }
    removing.clear();

这是changeTo2D();的代码:

public void changeto2D() {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
}

并绘制文字:

public Text(Location loc, String text, float size, Color color){
    try {
        InputStream inputStream = ResourceLoader.getResourceAsStream("res\\AGENCYR.TTF");

        Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        awtFont2 = awtFont2.deriveFont(size);
        font = new TrueTypeFont(awtFont2, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    c = new org.newdawn.slick.Color(color.red, color.green, color.blue);
    this.loc = loc;
    this.text = text;
    this.size = size;
}
public void draw(){
    font.drawString(loc.x, loc.y, text, c);
    if (td != null){
        td.draw();
    }
}

现在我的问题是: 我想制作一个包含Quad的GUI,但即使其他四边形画得很好,它也不会画画?我还试图在绘制文本之后为所有四边形放置代码,四边形根本不会绘制。

1 个答案:

答案 0 :(得分:1)

我修复它,只是让自己成为另一种渲染技术。首先绘制所有四边形,最后绘制文本。