private void recreateMesh() {

        Vertex[] vertexes = new Vertex[text.length() * 4];
        int[] indices = new int[6 * text.length()];


        float lastX = 0;

        for(int i=0; i<text.length(); i++){
            Glyph glyph = font.getGlyph((int)text.charAt(i));

            vertexes[0 + i*4] = new Vertex(new Vector3f(lastX -(float)glyph.getOffX()/size,-(float)glyph.getOffY()/size,0),                                                         new Vector2f((float)glyph.getX()/512,(float)(glyph.getY() + glyph.getYs())/512));
            vertexes[1 + i*4] = new Vertex(new Vector3f(lastX -(float)glyph.getOffX()/size,(float)glyph.getYs()/size -(float)glyph.getOffY()/size,0),                                 new Vector2f((float)glyph.getX()/512,(float)glyph.getY()/512));
            vertexes[2 + i*4] = new Vertex(new Vector3f((float)glyph.getXs()/size + lastX -(float)glyph.getOffX()/size,(float)glyph.getYs()/size -(float)glyph.getOffY()/size,0),     new Vector2f((float)(glyph.getX() + glyph.getXs())/512, (float)glyph.getY()/512));
            vertexes[3 + i*4] = new Vertex(new Vector3f((float)glyph.getXs()/size + lastX -(float)glyph.getOffX()/size,-(float)glyph.getOffY()/size,0),                             new Vector2f((float)(glyph.getX() + glyph.getXs())/512, (float)(glyph.getY() + glyph.getYs())/512));

            indices[0 + i*6] = 0 + i*4;
            indices[1 + i*6] = 3 + i*4;
            indices[2 + i*6] = 2 + i*4;
            indices[3 + i*6] = 2 + i*4;
            indices[4 + i*6] = 1 + i*4;
            indices[5 + i*6] = 0 + i*4;

            lastX += (float)glyph.getAdvX()/size;

        }

        this.mesh = new Mesh(vertexes,indices);
    }