Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
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
}
Ejemplo n.º 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
}
Ejemplo n.º 4
0
  virtual void Draw()
  {
    // Don't draw name of local player ?
    if (IsVisible() && m_player->GetId() != GetLocalPlayerId())
    {
      //Assert(m_player->GetAABB());
      //DrawAABB(*(m_player->GetAABB()));
 
      // Print name 
      // TODO Do all these in one go, to minimise state changes
      AmjuGL::PushAttrib(AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ);
      AmjuGL::Enable(AmjuGL::AMJU_BLEND);
      AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);

      GuiText text;
      text.SetTextSize(5.0f); // TODO CONFIG
      text.SetText(m_player->GetName());
    
      static const float MAX_NAME_WIDTH = 4.0f; // minimise this to reduce overdraw - calc from text
      text.SetSize(Vec2f(MAX_NAME_WIDTH, 1.0f));
      text.SetJust(GuiText::AMJU_JUST_CENTRE);
      //text.SetInverse(true);
      //text.SetDrawBg(true);
      text.SetFgCol(Colour(1, 1, 1, 1));

      AmjuGL::PushMatrix();
    
      Matrix m;
      m.SetIdentity();

      // Reverse modelview rotation
      Matrix r;
      r.ModelView();
      m = TransposeRot(r);

      Vec3f tr(m_combined[12], m_combined[13], m_combined[14]);
      m.TranslateKeepRotation(tr);
      AmjuGL::MultMatrix(m);
      static const float SCALE_FACTOR = 20.0f;
      float x = MAX_NAME_WIDTH * SCALE_FACTOR * -0.5f;
      AmjuGL::Translate(x, 60.0f, 0); // TODO CONFIG
    
      AmjuGL::Scale(SCALE_FACTOR, SCALE_FACTOR, 10);  

      text.Draw();
      AmjuGL::PopMatrix();
      AmjuGL::PopAttrib();
    }
  }
Ejemplo n.º 5
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(); 
}
Ejemplo n.º 6
0
void Ve1NameNode::Draw()
{
  // Print name 
  // TODO Do all these in one go, to minimise state changes
  AmjuGL::PushAttrib(AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ);
  AmjuGL::Enable(AmjuGL::AMJU_BLEND);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);

  GuiText text;
  text.SetTextSize(5.0f); // TODO CONFIG
  text.SetText(ToString(*m_obj));
    
  static const float MAX_NAME_WIDTH = 4.0f; // minimise this to reduce overdraw - calc from text
  text.SetSize(Vec2f(MAX_NAME_WIDTH, 1.0f));
  text.SetJust(GuiText::AMJU_JUST_CENTRE);
  //text.SetInverse(true);
  //text.SetDrawBg(true);

  AmjuGL::PushMatrix();
    
  Matrix m;
  m.SetIdentity();
  //Vec3f tr(m_local[12], m_local[13], m_local[14]);
  Vec3f tr(m_combined[12], m_combined[13], m_combined[14]);
  m.Translate(tr);
  AmjuGL::MultMatrix(m);
  static const float SCALE_FACTOR = 20.0f;
  float x = MAX_NAME_WIDTH * SCALE_FACTOR * -0.5f;
  AmjuGL::Translate(x, 60.0f, 0); // TODO CONFIG
    
  AmjuGL::Scale(SCALE_FACTOR, SCALE_FACTOR, 10);  

  text.Draw();
  AmjuGL::PopMatrix();
  AmjuGL::PopAttrib();

  /*
  AmjuGL::PushAttrib(
    AmjuGL::AMJU_TEXTURE_2D | AmjuGL:: AMJU_LIGHTING | AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ | AmjuGL::AMJU_DEPTH_WRITE);

  AmjuGL::Enable(AmjuGL::AMJU_TEXTURE_2D);
  AmjuGL::Disable(AmjuGL::AMJU_LIGHTING);
  AmjuGL::Enable(AmjuGL::AMJU_BLEND);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);
  AmjuGL::Disable(AmjuGL::AMJU_DEPTH_WRITE);

  AmjuGL::PushMatrix();
  AmjuGL::SetIdentity();

  AmjuGL::SetMatrixMode(AmjuGL::AMJU_PROJECTION_MATRIX);
  AmjuGL::PushMatrix();
  AmjuGL::SetIdentity();

  MultColour(Colour(0, 0, 1, 1));
  GuiText text;
  text.SetTextSize(0.5f);
  std::string s = "Object " + ToString(m_obj->GetId()) + " " + m_obj->GetTypeName();
  text.SetText(s);
  text.SizeToText();
  text.SetJust(GuiText::AMJU_JUST_LEFT);
  text.SetLocalPos(screenpos);
  text.Draw();


  AmjuGL::PopMatrix();
  AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
  AmjuGL::PopMatrix();

  AmjuGL::PopAttrib();
  */
}