public void drawElement(HudElement e, Point2D origin) {
		Texture tex;
		if(!e.isVisible())
			return;
		switch(e.getType()) {
		case BUTTON:
		case PANEL:
			PanelElement p = (PanelElement)e;
			OpenGLDraw.fillPoly(p.getBackColour(),
					origin.x + e.getPos().x,
					origin.y + e.getPos().y,
					e.getShape(), 1);
			tex = TextureLoader.getInstance().getTexture(p.getImage());
			if(tex!=null) {
				OpenGLDraw.bindTexture(tex);
				OpenGLDraw.drawTexture(
						origin.x + e.getPos().x + e.getShape().getMinX(),
						origin.y + e.getPos().y + e.getShape().getMinY(),
						e.getShape().getMaxX() - e.getShape().getMinX(),
						e.getShape().getMaxY() - e.getShape().getMinY());
				OpenGLDraw.unbindTexture();
			}
			OpenGLDraw.drawPoly(p.getLineColour(),
					origin.x + e.getPos().x,
					origin.y + e.getPos().y,
					e.getShape(), 1);
			break;
		case TEXTENTRY:
			float baseLine = origin.y + e.getPos().y + e.getShape().getMinY() + FontManager.getFont(FontType.FONT_32).getHeight()*Frame.FONT_SCALE;
			String text = ((TextEntryElement)e).getText();
			if(e == focus) text += "|";
			FontManager.getFont(FontType.FONT_32).drawString(Color.WHITE, origin.x + e.getPos().x + e.getShape().getMinX(),
					baseLine, text, Frame.FONT_SCALE,-Frame.FONT_SCALE,FontAlign.ALIGN_LEFT);
			break;
		case TEXT:
			TextElement te = ((TextElement)e);
			TrueTypeFont font = FontManager.getFont(te.getFontType());
			baseLine = origin.y + te.getPos().y + te.getShape().getMinY() + font.getHeight()*Frame.FONT_SCALE;
			font.drawString(te.getColour(),
					origin.x + te.getPos().x + te.getShape().getMinX(),
					baseLine, te.getText(), Frame.FONT_SCALE,-Frame.FONT_SCALE,te.getAlignment());	
			break;
		}
		
		for(HudElement child: e.getElements()) {
			if(!child.isVisible()) continue;
			drawElement(child, e.getPos());
		}
	}