Beispiel #1
0
void GSTitle::Draw2d()
{
  GSGui::Draw2d();

#ifdef SHOW_ENV_INFO
  // Draw env info, etc.
  static GuiText t;

  t.SetSize(Vec2f(1.0f, 0.1f));
  t.SetJust(GuiText::AMJU_JUST_LEFT);
  t.SetDrawBg(true);

  t.SetLocalPos(Vec2f(-1.0f, 0.8f));
  std::string s = "SaveDir: " + GetAppName();
  t.SetText(s);
  t.Draw();

  t.SetLocalPos(Vec2f(-1.0f, 0.7f));
  s = "Server: " + GetServer();
  t.SetText(s);
  t.Draw();

  t.SetLocalPos(Vec2f(-1.0f, 0.6f));
  s = "Env: " + GetEnv();
  t.SetText(s);
  t.Draw();
#endif
}
void TrailCircle::Draw()
{
    static GuiImage* circleImg = 0;
    static GuiText text;

    if (!circleImg)
    {
        circleImg = new GuiImage;
        Texture* tex = (Texture*)TheResourceManager::Instance()->GetRes("circ1.png");
        tex->SetFilter(AmjuGL::AMJU_TEXTURE_NICE);
        circleImg->SetTexture(tex);
        float aspect = (float)Screen::X() / (float)Screen::Y();
        circleImg->SetSize(Vec2f(CIRCLE_SIZE, CIRCLE_SIZE * aspect));

        text.SetSize(Vec2f(0.1f, 0.1f));
    }

    const Colour BLACK(0, 0, 0, 1);
    const Colour WHITE(1, 1, 1, 1);
    const Colour RED(1, 0, 0, 1);

    circleImg->SetLocalPos(Vec2f(m_pos.x - CIRCLE_SIZE * 0.5f, m_pos.y + CIRCLE_SIZE * 0.5f));
    PushColour();
    MultColour(m_incorrect ? RED : (m_clicked ? BLACK : WHITE));
    circleImg->Draw();
    PopColour();

    // Draw number/letter
    text.SetSize(Vec2f(0.2f, 0.1f));
    text.SetJust(GuiText::AMJU_JUST_CENTRE);
    text.SetLocalPos(m_pos + Vec2f(-0.1f, 0.012f));
    text.SetText(m_str);
    text.SetFgCol(m_clicked || m_incorrect ? WHITE : BLACK);
    text.Draw();
}
Beispiel #3
0
void GSMain::Draw2d()
{
  AmjuGL::Viewport(0, 0, Screen::X(), Screen::Y());
  TheHud::Instance()->Draw();
  
  // Store scaled modelview matrix
  float mat[16];
  AmjuGL::GetMatrix(AmjuGL::AMJU_MODELVIEW_MATRIX, mat);

  // Split screen -- draw all screens
  int numVps = TheViewportManager::Instance()->GetNumViewports();
  for (int i = 0; i < numVps; i++)
  {
    AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
    AmjuGL::SetIdentity();
    // Restore scaled mv matrix
    AmjuGL::MultMatrix(mat);

    TheViewportManager::Instance()->GetViewport(i)->Draw2d();
  }
  m_gui->Draw(); // split screen line etc

  TheLurker::Instance()->Draw();

#ifdef GEKKO
  TheCursorManager::Instance()->Draw();
#endif

#ifdef SHOW_INFO
  // TODO Switch on/off
  if (true)
  {
    static GuiText t;
    t.SetFgCol(Colour(1, 1, 1, 1));
    t.SetBgCol(Colour(0, 0, 0, 1));
    t.SetDrawBg(true);
    t.SetFontSize(0.8f); // TODO CONFIG
    t.SetIsMulti(true);
    t.SetLocalPos(Vec2f(-1.0f, -0.8f));
    t.SetSize(Vec2f(1.0f, 0.2f));
    t.SetJust(GuiText::AMJU_JUST_LEFT);

    float playerX = Player::GetPlayer(AMJU_P1)->GetPos().x;

    static std::string old;
    std::string s = "Depth: " + ToString((int)GetCurrentDepth()) +
      " X: " + ToString((int)playerX) + 
      "\nNum Game Objects: " + 
      ToString((int)TheGame::Instance()->GetGameObjects()->size());

    if (old != s)
    {
      t.SetText(s);
    }
    old = s;
    t.Draw();
  }
#endif // SHOW_INFO
}
Beispiel #4
0
void Game::RunOneLoop()
{
#ifdef SHOW_FRAME_TIME
    static std::string fps;
    static int framesThisSec = 0;
    framesThisSec++;
    static int elapsed = 0;
    float e = TheTimer::Instance()->GetElapsedTime(); 

    if ((int)e != elapsed)
    {
      elapsed = (int)e;
      fps = ToString(framesThisSec);
      framesThisSec = 0;
    }

#ifdef WIN32
    unsigned long start = GetTickCount();
#else
    // Get time taken to update/draw/flip, giving the 'real' FPS, not fixed to screen refresh rate
    timeval tbefore;
    gettimeofday(&tbefore, 0);
#endif

#endif //  SHOW_FRAME_TIME

  Update();

#ifdef SHOW_FRAME_TIME
#ifdef WIN32
    unsigned long mid = GetTickCount();
#else
    // Get time taken to update/draw/flip, giving the 'real' FPS, not fixed to screen refresh rate
    timeval mid;
    gettimeofday(&mid, 0);
#endif
#endif //  SHOW_FRAME_TIME

  Draw();

#ifdef SHOW_FRAME_TIME
  if (m_font)
  {
#ifdef WIN32
    unsigned long draw = GetTickCount() - mid;
    unsigned long update = mid - start;
    std::string s = "Draw: " + ToString((unsigned int)draw) + " update: " + ToString((unsigned int)update);

#else
    timeval tafter;
    gettimeofday(&tafter, 0);
    double draw = tafter.tv_sec - mid.tv_sec + (tafter.tv_usec - mid.tv_usec) * 1e-6;
    double update = mid.tv_sec - tbefore.tv_sec + (mid.tv_usec - tbefore.tv_usec) * 1e-6;
    int idraw = (int)(draw * 1000.0f);
    int iupdate = (int)(update * 1000.0f);
    std::string s = std::string("Draw: ") + 
      std::string((idraw < 10 ? "0" : "")) + ToString(idraw) +
      std::string("ms update: ") + std::string((iupdate < 10 ? "0" : "")) + 
      ToString(iupdate) + "ms";
#endif

    s += " fps: " + fps;

    // Display time per frame
    static GuiText t;
    t.SetFont(m_font);
    t.SetScaleX(0.7f);
    t.SetFgCol(Colour(1, 1, 1, 1));
    t.SetLocalPos(Vec2f(-1.0f, 1.0f));
    t.SetSize(Vec2f(2.0f, 0.1f));
    t.SetJust(GuiText::AMJU_JUST_LEFT);
    t.SetText(s);
    AmjuGL::PushAttrib(AmjuGL::AMJU_LIGHTING | AmjuGL::AMJU_TEXTURE_2D);
    AmjuGL::Disable(AmjuGL::AMJU_LIGHTING);
    AmjuGL::Enable(AmjuGL::AMJU_TEXTURE_2D);
    t.Draw(); 
    AmjuGL::PopAttrib();
  }
#endif //  SHOW_FRAME_TIME

  AmjuGL::Flip(); 
}