// Called to draw scene
void RenderScene(void)
{
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Save the matrix state and do the rotations
	glPushMatrix();
	glRotatef(xRot, 1.0f, 0.0f, 0.0f);
	glRotatef(yRot, 0.0f, 1.0f, 0.0f);
	glTranslatef(0.0f, 0.0f, zDistance); 

	DrawJet();	
                
	glPopMatrix();
	glutSwapBuffers();
}
Esempio n. 2
0
/****************************************************************************
  Function:
    WORD GOLDrawCallback( void )
  Description:
    This callback is performed at the beginning of the GOLDraw() function.
    Processing that needs to be done on a regular basis and is not triggered
    by a message should be done here.
  Precondition:
    None
  Parameters:
    None
  Returns:
    None
  Remarks:
    All graphic control adding and removing must be done from this function,
    not from the message callback.
  ***************************************************************************/
WORD GOLDrawCallback( void )
{
	
    switch (screenState)
    {
	    // Display Start-up screen and play Welcome message
        case SCREEN_START:
            // Display the start up screen
		    PictCreate(     ID_ICON,                    // ID
		                    0,0,GetMaxX(),GetMaxY(),    // dimension
		                    PICT_DRAW,                  // will be displayed, has frame
		                    1,                          // scale factor is x1
		                    picture,                    // bitmap
		                    NULL );                     // default GOL scheme
        	screenState     = SCREEN_START_DELAY;
            break;
            
        case SCREEN_START_DELAY:
        	if(enableSoundFlag)
        	{
        		while(speakerBusy());
        		// Speaker: Welcome to MPLAB Starter Kit for PIC24H MCU Demonstration
        		speakerActivate(SPEECH_ADDR_WELCOME, SPEECH_SIZE_WELCOME);		
        		Delay(6000);
        	}
        	// Initialize the reference timer
    		TickInit();
			// Initialize the accelerometer
    		AccelerometerInit();
        	screenState     = SCREEN_DISPLAY_MAIN;
        	break;
        
        // Display Main screen                
        case SCREEN_DISPLAY_MAIN:
            ShowScreenMain();            
            screenState         = SCREEN_MAIN;
            displayChangeTime   = tick;
            break;
               	
        case SCREEN_MAIN:
            break;
        
        // Display Accelerometer Tri-axial Outputs graph	            
        case SCREEN_DISPLAY_GRAPH:
            ShowScreenGraph();
            screenState         = SCREEN_GRAPH;
            displayChangeTime   = tick;
            break;

        case SCREEN_GRAPH:
        	AccelerometerStop();			
            UpdateGraph();
            break;
		
		// Display connect External Sensor information
		case SCREEN_DISPLAY_ES_INFO:
		  	ShowScreenESInfo();
		  	screenState 		= SCREEN_ES_INFO;
		  	displayChangeTime   = tick;
		  	break;

		case SCREEN_ES_INFO:
			Delay(2000);
		  	screenState = SCREEN_DISPLAY_ES_GRAPH;
		  	break;
		
		// Display External Sensor output graph   			
        case SCREEN_DISPLAY_ES_GRAPH:
        	AccelerometerStop();
            ShowScreenESGraph();                      
            initESADC();
            screenState         = SCREEN_ES_GRAPH;
            displayChangeTime   = tick;
            break;

        case SCREEN_ES_GRAPH:
	        UpdateESGraph();
            break;
        
        // Display Orientation screen     
        case SCREEN_DISPLAY_ORIENTATION:
            ShowScreenOrientation();
            screenState         = SCREEN_ORIENTATION;
            displayChangeTime   = tick;
            break;

        case SCREEN_ORIENTATION:
            UpdateOrientation();
            break;
 
 		// Display Games screen
        case SCREEN_DISPLAY_GAMES:
            ShowScreenGames();
            screenState         = SCREEN_GAMES;
            displayChangeTime   = tick;
            break;

        case SCREEN_GAMES:
            break;
        
        // Display Bomber Jet screen                         
        case SCREEN_DISPLAY_JET:
            ShowScreenJet();
            AccelerometerStop();
        	AccelerometerInit();    
         	if(enableSoundFlag)
         	{
	         	while(speakerBusy());
				speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); 
				while(speakerBusy());
			}
            screenState         = SCREEN_JET;
            displayChangeTime   = tick;
            break;

        case SCREEN_JET:    	
            DrawJet();
            break;
        
        // Display Snake screen    
        case SCREEN_DISPLAY_SNAKE:
            ShowScreenSnake();
            AccelerometerStop();
        	AccelerometerInit();   
        	if(enableSoundFlag)
         	{
	         	while(speakerBusy());
				speakerActivate(SPEECH_ADDR_START, SPEECH_SIZE_START); 
				while(speakerBusy());
			} 
            screenState         = SCREEN_SNAKE;
            displayChangeTime   = tick;
            break;

        case SCREEN_SNAKE:    	
            DrawSnake();
            break;
            
        // Display Score screen    
        case SCREEN_DISPLAY_SCORE:
            ShowScreenScore();
            if(enableSoundFlag)
            {
				while(speakerBusy());
				speakerActivate(SPEECH_ADDR_GAME, SPEECH_SIZE_GAME); 
				while(speakerBusy());
				speakerActivate(SPEECH_ADDR_OVER, SPEECH_SIZE_OVER); 
			}
            displayChangeTime   = tick;
            screenState         = SCREEN_SCORE;			
            break;

        case SCREEN_SCORE:
            break;
    }

    return 1;   // Callback complete
}