void FxPlayerTiny::DisplayGameScreen()
{
	if(NULL == pDevice) return;

	Render();
	DisplayHUD();

	pDevice->Present(NULL, NULL, NULL, NULL);
}
Exemple #2
0
static void DisplayCallback(void)
{
    unsigned int MAXLATENCY=2000*1000; //2seconds rendering time is terrible

    //If we were Paused ( a.k.a. economy mode )
    //All the time passed since the last draw operation could lead to jerky movement
    //So we won't track time as we do regularly but "pretend" the last frame was 1ms ago
    //This will ensure smoothness and eye-candy for the user :)
    if (frame.onNextDrawAssumeWeWerePaused)
    {
      gettimeofday(&last_frame,0x0);
      time_passed_microseconds = 1000;
      frame.onNextDrawAssumeWeWerePaused = 0;
    } else
    {
    // Regular per frame time keeping
    /*KEEP TRACK OF TIME -----------------*/
    gettimeofday(&this_frame,0x0);
    time_passed_microseconds = timeval_diff(&difference,&this_frame,&last_frame);
    if (time_passed_microseconds>MAXLATENCY)
     {
      fprintf(stderr,"FRAME DELAYED %u msecs\n",time_passed_microseconds/1000);
      fprintf(stderr,"to keep things from freaking out we will pretend We were paused and only 1 ms passed\n");
      time_passed_microseconds=1000;
     }
    last_frame = this_frame;
    /*---------------------------------------*/
    }



    /* FRAME RATE COUNTING
       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	framecount+=1;
	timenow=glutGet(GLUT_ELAPSED_TIME);
	frame.tick_count=timenow; // <- Slideshow triggering
	if (timenow - timebase>1000)
	{
	    float real_fps = (framecount * 1000.0) / (timenow-timebase);
	    fps = (unsigned int) real_fps ;
	    frame.fps=fps; // <- Store in slideshow
	 	timebase = timenow;
		framecount = 0;
	}
    /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

    /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   /* Texture binding via OpenGL , it can only be done in this thread , before actually rendering  >>>>>>>>>>>>>>>>>>>>>>*/
   /* This code only counts textures to be created , they are actually loaded on the end of this function >>>>>>>>>>>>>>>*/

   /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */


    /* OPEN GL DRAWING >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
   // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // <- This causes screen tearing..! | GL_DEPTH_BUFFER_BIT
	  glPushMatrix();
       //glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

          glRotatef(frame.angle_x,-1.0,0,0); // Peristrofi gyrw apo ton x
          glRotatef(frame.angle_y,0,-1.0,0); // Peristrofi gyrw apo ton y
          glRotatef(frame.angle_z,0,0,-1.0);
          glTranslatef(-frame.vx, -frame.vy, -frame.vz);

             MainDisplayFunction();

             Render_3DObjects();

             DrawEffects();

          glTranslatef(frame.vx,frame.vy,frame.vz);
       glPopMatrix();
     /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */


   /* DRAW APPLICATION HUD */
        if (frame.show_time>0)
        {
           unsigned int diff_ms=time_passed_microseconds/1000;
           if (frame.show_time>diff_ms) { frame.show_time-=diff_ms; } else
                                        { frame.show_time=0; }
          DisplayHUD(2);
        }else
        if (frame.show_information>0)
        {
           unsigned int diff_ms=time_passed_microseconds/1000;
           if (frame.show_information>diff_ms) { frame.show_information-=diff_ms; } else
                                               { frame.show_information=0; }
          DisplayHUD(1);
        }else
        if ( frame.distance_barrier_after_considered_close<frame.desired_z )
        {
          /* Display HUD only if not zoomed */
          DisplayHUD(0);
        }
   /* -  -  -  -  -  -  -  */
   glFinish(); // Thats all the drawing
   glutSwapBuffers();

   /*STATE MANAGMENT ----------------------------------------------------*/
   AutomaticSlideShowControl_if_needed(); /* if automatic slide show is enabled it will relay commands */

   /*  THIS COMMAND MOVES THE CAMERA ACCORDING TO THE USER/COMPUTER INPUT*/
   PerformCameraMovement(time_passed_microseconds);
   PerformPicturesMovement(time_passed_microseconds);

   Run3DObjects(time_passed_microseconds);


   /* Texture binding via OpenGL , it can only be done in this thread , while not rendering
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
   ManageCreatingTexturesMemory_OpenGLThread(0);
   /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */




  /* Changes on display behaviour  >>>>>>>>>>>>>>>>>>>>>>*/
  if ( !framerate_limiter() ) /* helps smoothing out framerate */
    {
      usleep(10); /*Some dead time */
    }


    glFlush(); //This is needed for Discrete GPU / ( Optimus ) to be working (!)
}