Exemple #1
0
void renderpanel(void) {
  int h = Y_MARGIN;
  SDL_FillRect(panel, NULL, g_panel_bg);
  h = renderinfo(h);
  h = renderhold(h);
  h = renderqueue(h);
}
Exemple #2
0
// render head-up display
void renderhud()
   {
   double elev,sea;
   double flattening;
   minicoord eye_llh;

   minicoord hit;
   minicoord hit_llh;
   double dist;

   char str[MAXSTR];

   minilayer *nst=NULL;
   minitile *mt=NULL;

   nst=viewer->getearth()->getnearest(cam->get_eye());
   if (nst!=NULL) mt=nst->getterrain()->getminitile();

   minitext::configure_zfight(1.0f);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0f,1.0f,0.0f,1.0f,-1.0f,1.0f);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
   glEnable(GL_BLEND);

   if (sw_hud)
      {
      glTranslatef(0.0f,0.675f,0.0f);

      glColor4f(1.0f,1.0f,1.0f,0.5f);
      glBegin(GL_QUADS);
      glVertex2f(0.0f,0.0f);
      glVertex2f(1.0f,0.0f);
      glVertex2f(1.0f,0.3f);
      glVertex2f(0.0f,0.3f);
      glEnd();

      glTranslatef(0.033f,0.0f,0.0f);

      elev=viewer->getearth()->getheight(cam->get_eye());
      if (elev==-MAXFLOAT) elev=0.0f;

      flattening=viewer->getearth()->getterrain()->getflattening()*tparams->exaggeration;
      if (flattening!=0.0) elev/=flattening;

      sea=tparams->sealevel;
      if (sea==-MAXFLOAT) sea=0.0f;

      if (nst!=NULL) eye_llh=nst->map_g2t(cam->get_eye());
      if (eye_llh.type!=minicoord::MINICOORD_LINEAR) eye_llh.convert2(minicoord::MINICOORD_LLH);

      snprintf(str,MAXSTR,
               "Position:                \n\n"
               " x= %11.1f\n y= %11.1f\n z= %11.1fm (%.1fm)\n\n dir= %.1f\n yon= %.1f\n\n"
               "Settings:\n\n"
               " farp= %.1fm (f/F)\n\n res= %.1f*%.1f (t/T)\n range= %.1f*%.1fm (r/R)\n\n sea= %.1f (u/U)\n\n gravity= %.1f (g)\n",
               eye_llh.vec.x,eye_llh.vec.y,eye_llh.vec.z,elev,cam->get_angle(),cam->get_pitch(), // position/elevation and direction
               params->farp,tparams->res*tparams->relres1,tparams->relres2,tparams->range*tparams->relrange1*params->farp,tparams->relrange2,sea,gravity); // adjustable parameters

      minitext::drawstring(0.3f,240.0f,1.0f,0.25f,1.0f,str);

      glTranslatef(0.3f,0.0f,0.0f);

      snprintf(str,MAXSTR,
               "Load:                \n\n"
               " fps= %.1fHz (%.1f%%)\n\n mem= %.1fMB\n tex= %.1fMB\n\n"
               "Streaming:\n\n"
               " pending= %d\n\n cache= %.1fMB\n\n"
               "Geometry:\n\n"
               " fans=     %d\n vertices= %d\n",
               1.0/(avg_delta+avg_idle),100*(1.0-avg_idle*params->fps), // actual frame rate and load
               viewer->getearth()->getterrain()->getmem(),viewer->getearth()->getterrain()->gettexmem(), // memory consumed by tilesets
               viewer->getearth()->getterrain()->getpending(), // number of pending tiles
               viewer->getearth()->getterrain()->getcachemem(), // memory foot print of data cache
               viewer->getearth()->getterrain()->getbuffer()->getfancnt(), // rendered triangles fans
               viewer->getearth()->getterrain()->getbuffer()->getvtxcnt()); // rendered vertices

      if (mt!=NULL)
         snprintf(str+strlen(str),MAXSTR-strlen(str),
                  " vis area= [%d-%d]x[%d-%d]\n\n",
                  mt->getvisibleleft(),mt->getvisibleright(),mt->getvisiblebottom(),mt->getvisibletop()); // visible area of nearest tileset

      minitext::drawstring(0.3f,240.0f,1.0f,0.25f,1.0f,str);

      glTranslatef(0.3f,0.0f,0.0f);

      snprintf(str,MAXSTR,
               "Controls:                \n\n"
               " left=       a\n right=      d\n accelerate= w\n decelerate= s\n\n"
               " stop=      spc\n jump=      j\n look down= <\n look up=   >\n\n"
               " hud/hide=  h/H\n crosshair= c\n waypoints= p\n wireframe= l\n\n"
               " load/save= o/O\n quit=      Q esc\n");

      minitext::drawstring(0.3f,240.0f,1.0f,0.25f,1.0f,str);

      rendercompass();
      renderinfo();
      }
   else
      if (sw_hide==0)
         {
         glTranslatef(0.033f,0.95f,0.0f);
         minitext::drawstring(0.3f,240.0f,1.0f,0.25f,1.0f,"[Press h for HUD]",1.0f,0.25f);

         glLoadIdentity();
         rendercompass();
         }

   if (sw_cross!=0 || cam->get_pitch()<-89.9)
      {
      glLoadIdentity();
      glTranslatef(0.5f,0.5f,0.0f);
      glScalef((float)winheight/winwidth,1.0f,1.0f);
      glColor3f(0.0f,0.0f,0.0f);
      glPushMatrix();
      glScalef(0.025f,0.025f,1.0f);
      glBegin(GL_LINES);
      glVertex2f(-1.0,-1.0f);
      glVertex2f(1.0,1.0f);
      glVertex2f(-1.0,1.0f);
      glVertex2f(1.0,-1.0f);
      glEnd();
      glPopMatrix();

      hit=cam->get_hit();
      if (hit!=cam->get_eye())
         {
         nst=viewer->getearth()->getnearest(hit);

         if (nst!=NULL) hit=nst->map_g2t(hit);
         if (hit.type!=minicoord::MINICOORD_LINEAR) hit.convert2(minicoord::MINICOORD_ECEF);

         hit_llh=hit;
         if (hit_llh.type!=minicoord::MINICOORD_LINEAR) hit_llh.convert2(minicoord::MINICOORD_LLH);

         dist=(hit-cam->get_eye()).vec.getlength();

         if (dist<1000.0)
            snprintf(str,MAXSTR,"dist=%3.3fm elev=%3.3fm\nlat=%3.6f lon=%3.6f",
                     dist,hit_llh.vec.z,hit_llh.vec.y/3600.0,hit_llh.vec.x/3600.0);
         else
            snprintf(str,MAXSTR,"dist=%3.3fkm elev=%3.3fm\nlat=%3.6f lon=%3.6f",
                     dist/1000.0,hit_llh.vec.z,hit_llh.vec.y/3600.0,hit_llh.vec.x/3600.0);

         glTranslatef(0.05f,-0.01f,0.0f);
         minitext::drawstring(0.5f,240.0f,1.0f,0.25f,1.0f,str);

         reportpos(hit_llh.vec.y,hit_llh.vec.x,hit_llh.vec.z);
         }
      }

   glDisable(GL_BLEND);
   }