Search code examples
javarenderinglwjgltruetype

Can't draw any quads after drawing text?


So i am making a 3d game and i am working on 2d on 3d right now but there's just one problem before I'm finished with it and that is: I can't draw any 2d quads after i have drawed a text? Here's the renderer code:

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();

This is the code for 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());
}

And to draw a text:

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();
    }
}

And now here is what my problem is: I want to make a GUI that contains a Quad but it won't draw even thought the other quads draw perfectly fine? I've also tried putting the code for all the quads after drawing text them the quads won't draw at all.


Solution

  • I fixed it, just made myself another renderering technique. Drawing all quads first and the texts at the end.