Ejemplo n.º 1
0
void draw(void)
{
    int i;
    tFace	*curFace;
    sgVec3	cam;
    

    cam[0] = cam[2] = 0;
    cam[1] = -10000;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ssgSetOrtho(ImgSize, ImgSize);
    for (i = 0; i < NbRows; i++) {
	curFace = GF_TAILQ_FIRST(&(Row[i].faces));
	while (curFace) {
	    if (curFace->isPresent) {
		printf("Drawing face %s\n", curFace->faceName);
		ssgSetNearFar(MIN(curFace->sbbmin[1], curFace->sbbmax[1]) - 1, 
			      MAX(curFace->sbbmin[1], curFace->sbbmax[1]) + 1);
		ssgCullAndDraw((ssgRoot*)curFace->branch);
	    }
	    curFace = GF_TAILQ_NEXT(curFace, link);
	}
    }
    //saveSkin();
}
Ejemplo n.º 2
0
void cGrCloudLayer::draw()
{
  if (!enabled)
	  return;

  ssgCullAndDraw( layer_root );
}
Ejemplo n.º 3
0
void grDrawBackground(class cGrCamera *cam, class cGrBackgroundCam *bgCam)
{
    TRACE_GL("grDrawBackground: ssgCullAndDraw start");

    bgCam->update(cam);
    bgCam->action();

    ssgCullAndDraw(TheBackground);

    TRACE_GL("grDrawBackground: ssgCullAndDraw");
}
Ejemplo n.º 4
0
/** \brief The per-frame OpenGL display routine
 *
 *  This function does the complete OpenGL drawing. First
 *  the 3D scene is drawn, then some 2D overlays
 *  (wind and battery indicator, GUI).
 */
void display()
{
  CRRCMath::Vector3 plane_pos = FDM2Graphics(Global::aircraft->getPos());

  // Prepare the current frame buffer and reset
  // the modelview matrix (for non-SSG drawing)
  GLbitfield clearmask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
   if (vidbits.stencil)
    {
    clearmask |= GL_STENCIL_BUFFER_BIT;
    }
  glClear(clearmask);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glPushMatrix();
  //~ glBlendFunc(GL_ONE, GL_ZERO);
  //~ glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);

  // Set up the viewing transformation (for SSG drawing)
  sgVec3 viewpos, planepos, up;
  
  sgSetVec3(viewpos, player_pos.r[0], player_pos.r[1], player_pos.r[2]);                
  sgSetVec3(planepos, looking_pos.r[0], looking_pos.r[1], looking_pos.r[2]);
  sgSetVec3(up, 0.0, 1.0, 0.0);
  context->setCameraLookAt(viewpos, planepos, up);

  // 3D scene
  if( Global::scenery != NULL)
  {
    // 3D scene: sky sphere
    draw_sky(&viewpos, Global::Simulation->getTotalTime());
  
    // 3D scene: airplane
    if (Global::aircraft->getModel() != NULL)
    {
      // For SSG rendering, this call does not draw anything,
      // but calculates the airplane's transformation matrix
      glDisable(GL_TEXTURE_2D);
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      Global::aircraft->getModel()->draw(Global::aircraft->getFDM());
    }
  
    // 3D scene: scenery
    Global::scenery->draw(Global::Simulation->getTotalTime());
  }
  // Lighting setup. Only needed as long as there are
  // non-SSG parts that modify the light sources.
  sgVec4 lightamb;
  sgSetVec4(lightamb , 0.2f, 0.2f, 0.2f, 1.0f);
  ssgGetLight(0)->setPosition(lightposn);
  ssgGetLight(0)->setColour(GL_AMBIENT, lightamb);

  // Draw the scenegraph (airplane model, shadow)
  ssgCullAndDraw(scene);
  context->forceBasicState();

  // ssgCullAndDraw() ends up with an identity modelview matrix,
  // so we have to set up our own viewing transformation for
  // the thermals
  glLoadIdentity();
  gluLookAt(player_pos.r[0], player_pos.r[1], player_pos.r[2],
            looking_pos.r[0], looking_pos.r[1], looking_pos.r[2],
            0.0, 1.0, 0.0);
  
  if (Global::training_mode==TRUE)
  {
    draw_thermals(Global::aircraft->getPos());
  }
  
  // 3D scene: game-mode-specific stuff (pylons etc.)
  Global::gameHandler->draw();

  glPopMatrix();


  // Overlay: game handler
  Global::gameHandler->display_infos(window_xsize, window_ysize);

  // Overlay: scope for audio interface
  if ( Global::testmode.test_mode
       &&
       (Global::TXInterface->inputMethod() == T_TX_Interface::eIM_audio) )
  {
    GlOverlay::setupRenderingState(window_xsize, window_ysize);
    oscillo();
    GlOverlay::restoreRenderingState();
  }

  // Overlay: wind direction indicator
  {
    double dx  = (plane_pos.r[2] - player_pos.r[2]);
    double dy  = (player_pos.r[0] - plane_pos.r[0]);
    double dir = atan2(dy, dx);

    GlOverlay::setupRenderingState(window_xsize, window_ysize);
    draw_wind(dir);
    GlOverlay::restoreRenderingState();
  }

  // Overlay: battery capacity/fuel left
  {
    int r   = window_ysize >> 5;
    int w   = r >> 1;
    int h   = window_ysize >> 3;
    int ht  = (int)(Global::aircraft->getFDM()->getBatCapLeft() * h);
                    
#if 0
    glDisable(GL_LIGHTING);
    glMatrixMode (GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity ();
    gluOrtho2D (0, window_xsize-1, 0, window_ysize);
#endif
    GlOverlay::setupRenderingState(window_xsize, window_ysize);
    
    // Background
    glColor3f (0, 0, 0);
    glRectf(window_xsize-w, r+ht,
            window_xsize-1, r+h);
    glTranslatef(0,0,0.1);
  
    // Indicator
    glColor3f (0, 1, 0.);
    glRectf(window_xsize-w, r,
            window_xsize-1, r+ht);
    
#if 0
    glPopMatrix();
    glEnable(GL_LIGHTING);    
    glMatrixMode(GL_MODELVIEW);
#endif
    GlOverlay::restoreRenderingState();

  }

  // Overlay: console
  console->render(window_xsize, window_ysize);
  
  // Overlay: gui
  Global::gui->draw();
  
  // check for any OpenGL errors
  evaluateOpenGLErrors();

  // Force pipeline flushing and flip front and back buffer
  glFlush();
  SDL_GL_SwapBuffers();
}
Ejemplo n.º 5
0
void cGrSky::preDraw()
{
  ssgCullAndDraw( pre_root );
}
Ejemplo n.º 6
0
void ModelBasedScenery::draw(double current_time)
{
  ssgCullAndDraw(SceneGraph);
}
Ejemplo n.º 7
0
void grDrawScene(void)
{
    TRACE_GL("refresh: ssgCullAndDraw start");
    ssgCullAndDraw(TheScene);
    TRACE_GL("refresh: ssgCullAndDraw");
}