⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example3dcontainer.cpp

📁 Symbian平台下的一个3D赛车游戏源码
💻 CPP
字号:
   /*
============================================================================
    * Name : Example3DContainer.cpp
    * Part of : Example3D
    * Description : Definition of Example3DContainer
    * Copyright (c) 2005 Nokia Corporation
============================================================================
    */

// INCLUDE FILES
#include "Example3DContainer.h"
#include "CEngine.h"
#include "Example3D.hrh"
#include <eikmenub.h>
#include <eikspane.h>
#include <eikbtgpc.h>
#include <eiktbar.h>
#ifdef __S60__
#include <aknutils.h> 
#endif


void CExample3DContainer::ConstructL( const TRect& aRect )
    {
	CreateWindowL();
#ifndef GLES
	TPoint pos = aRect.iTl;
	TSize size = aRect.Size();

	size.iWidth &= 0xfffffffe;
	SetPosition( pos );
	SetSize( size );
#endif	

	iEngine = CEngine::NewL( SystemGc(), Window(),
							 CCoeEnv::Static()->ScreenDevice()->DisplayMode()
							 );
#ifndef GLES
	MEikAppUiFactory* f = CEikonEnv::Static()->AppUiFactory();
	iStatusPane = f->StatusPane();
	iToolBar = f->ToolBar();
#endif
	ControlEnv()->AddForegroundObserverL( *this );

#ifdef GLES
    // Start in  fullscreen because of problem issue in 3.0 openGL 
    SetExtentToWholeScreen();
    iFullScreen = 1;
#endif
	ActivateL();
	iEngine->Start();
    iEngine->DoGameFrameL();
    }



CExample3DContainer::~CExample3DContainer()
    {
	delete iEngine;
    }



void CExample3DContainer::SizeChanged()
	{
	}

void CExample3DContainer::HandleResourceChange(TInt aType)
    {
    CCoeControl::HandleResourceChange(aType);
    }

void CExample3DContainer::HandleGainingForeground()
	{
	iEngine->Start();
	}



void CExample3DContainer::HandleLosingForeground()
	{
	iEngine->Stop();
	}



TKeyResponse CExample3DContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	// Game's idle timer doesn't allow focuschange too easily,
	// this is to help it a little
	// So when application change key is pressed, the key event comes here
	// but the OS doesn't have enough time to change the application focus
	// This catches the application key press and leaves the thread for one second
	// In that time OS has all the time it needs to change focus.
	if( aKeyEvent.iScanCode == EStdKeyApplication0 )
		{
		User::After( 1000000 );
		return EKeyWasConsumed;
		}
		
	// In all other cases just forward the key presses to the game engine.
	iEngine->KeyEvent( aKeyEvent, aType );
	return EKeyWasConsumed;
	}


void CExample3DContainer::Command( TInt aCommand )
	{
	if( aCommand == EExample3DFullScreen )
		{
		iFullScreen ^= 1;
		if( iFullScreen )
			{
#ifndef GLES
            if( iToolBar )
				{
				iToolBar->SetCommandL( 0, EExample3DFullScreen, _L("Exit\nfullscreen") );
				iToolBar->MakeVisible( EFalse );
				}
			if( iStatusPane )
				{
				iStatusPane->MakeVisible( EFalse );
				}
#endif
			SetExtentToWholeScreen();
			}
		else
			{
#ifndef GLES
			if( iToolBar )
				{
				iToolBar->SetCommandL( 0, EExample3DFullScreen, _L("Fullscreen") );
				iToolBar->MakeVisible( ETrue );
				iToolBar->DrawNow();
				}
			if( iStatusPane )
				{
				iStatusPane->MakeVisible( ETrue );
				}
#endif			
			TRect rect = CEikonEnv::Static()->EikAppUi()->ClientRect();
			SetRect(rect);
#ifndef GLES
			SetPosition( rect.iTl );
			TSize size = rect.Size();
			// make even width
			// odd width CFbsBitmap has unwanted padding bytes
			size.iWidth &= 0xfffffffe;	
			SetSize( size );
#endif
			}
		}
	else
		{
		iEngine->Command( aCommand );
		}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -