Example #1
0
void Game::Render(void) {
  glClear(GL_COLOR_BUFFER_BIT);
  if(_inTitleScreen) {
    RenderTitle();
  } else {
    RenderGame();
  }
}
Example #2
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occurred
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevant OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2IntroducingPrint3D::RenderScene()
{
	// Clears the color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	unsigned long ulCurrentTime = PVRShellGetTime() - m_ulStartTime;

	// Draw star background
	m_BG.Draw(m_uiStarTex);
	 
	// Render the 'Introducing Print3D' title for the first n seconds.
	if(ulCurrentTime < INTRO_TIME)
	{
		float fFadeAmount = 1.0f;
		
		// Fade in
		if(ulCurrentTime < INTRO_FADE_TIME)	
		{
			fFadeAmount = ulCurrentTime / (float)INTRO_FADE_TIME;
		}
		// Fade out
		else if(ulCurrentTime > INTRO_TIME - INTRO_FADE_TIME)
		{
			fFadeAmount = 1.0f - ((ulCurrentTime - (INTRO_TIME - INTRO_FADE_TIME)) / (float)INTRO_FADE_TIME);
		}

		RenderTitle(fFadeAmount);		
	}
	// Render the 3D text.
	else
	{
		RenderText();
	}

	/*
		Here we are passing in a wide-character string to Print3D function. This allows
		Unicode to be compiled in to string-constants, which this code snippet
		demonstrates.
		Because we are not setting a projection or a model-view matrix the default projection 
		matrix is used.
	*/
	unsigned int uiTitleLang = (unsigned int) ((ulCurrentTime / 1000) / (TITLE_TIME / 1000)) % eLang_Size;
	unsigned int uiNextLang  = (uiTitleLang + 1) % eLang_Size;
	unsigned int ulModTime   = (unsigned int) ulCurrentTime % TITLE_TIME;
	float fTitlePerc = 1.0f;
	float fNextPerc  = 0.0f;
	if(ulModTime > TITLE_TIME - TITLE_FADE_TIME)
	{
		fTitlePerc = 1.0f - ((ulModTime - (INTRO_TIME - INTRO_FADE_TIME)) / (float)INTRO_FADE_TIME);
		fNextPerc = 1.0f - fTitlePerc;
	}
	unsigned int uiTitleCol = (((unsigned int)(fTitlePerc * 255)) << 24) | 0xFFFFFF;
	unsigned int uiNextCol  = (((unsigned int)(fNextPerc  * 255)) << 24) | 0xFFFFFF;
	m_TitleText.Print3D(0, 0, 1, uiTitleCol, c_pwzTitles[uiTitleLang]);
	m_TitleText.Print3D(0, 0, 1, uiNextCol, c_pwzTitles[uiNextLang]);
	m_TitleText.Flush();
		
	/*
		DisplayDefaultTitle() writes a title and description text on the top left of the screen.
		It can also display the PVR logo (ePVRTPrint3DLogoPowerVR), the IMG logo (ePVRTPrint3DLogoIMG) or both (ePVRTPrint3DLogoPowerVR | ePVRTPrint3DLogoIMG)
		which is what we are using the function for here.
		Set this last parameter to NULL not to display the logos.
		Passing NULL for the first two parameters will not display any text.
	*/
	m_Print3D.DisplayDefaultTitle(NULL, NULL, ePVRTPrint3DSDKLogo);

	// Tells Print3D to do all the pending text rendering now
	m_Print3D.Flush();
	
	return true;
}