コード例 #1
0
ファイル: GuiScreen.java プロジェクト: nocaremc/game
  @Override
  public void render() {
    int width = App.getScreenWidth();
    int height = App.getScreenHeight();

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluOrtho2D(0, width, 0, height);
    glScalef(1, -1, 1);
    glTranslatef(0, -height, 0);
    glMatrixMode(GL_MODELVIEW);
    glDisable(GL_DEPTH_TEST);
    // Draw background
    glBegin(GL_QUADS);
    {
      if (backgroundColor != null) GeneralUtils.glColorShortcut(backgroundColor);

      glVertex2f(0, 0);
      glVertex2f(0, height);
      glVertex2f(width, height);
      glVertex2f(width, 0);
    }
    glEnd();

    for (GuiButton b : buttons) {
      b.render();
      // System.out.println(b.isMouseOver());

    }

    // I don't want to set the same opengl settings for every button.
    // We can reduce a least a tiny bit of overhead by doing it in one go
    font.renderBegin();
    for (GuiButton b : buttons) {
      b.renderText();
    }
    font.renderEnd();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_DEPTH_TEST);
  }