当前位置: 首页>>代码示例>>C++>>正文


C++ ITimer::GetRealTime方法代码示例

本文整理汇总了C++中ITimer::GetRealTime方法的典型用法代码示例。如果您正苦于以下问题:C++ ITimer::GetRealTime方法的具体用法?C++ ITimer::GetRealTime怎么用?C++ ITimer::GetRealTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITimer的用法示例。


在下文中一共展示了ITimer::GetRealTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnLoadWorldFile


//.........这里部分代码省略.........
		if (retval != MSG_HANDLED)
		{
			m_ToolBox->Log(LOGERROR, _T("Could not get world version!"));
			return MSG_ERROR;
		}
		TCHAR buf[50];
		_stprintf(buf, "%.1f", m_WorldFileVersion);
		CHashString hszNewVersion(buf);
		static DWORD msgHash_SetFileVersion = CHashString(_T("SetFileVersion")).GetUniqueID();
		retval = m_ToolBox->SendMessage(msgHash_SetFileVersion, sizeof(IHashString), &hszNewVersion);
		if (retval != MSG_HANDLED)
		{
			m_ToolBox->Log(LOGERROR, _T("Could not set world version!"));
			return MSG_ERROR;
		}
	}
	// Unknown Version
	else
	{
		EngineGetToolBox()->SetErrorValue(WARN_INVALID_FILE);
		EngineGetToolBox()->Log(LOGWARNING, _T("Invalid world file %s\n"), pFileName);
		Archive->Close();
		static DWORD msgHash_SetFileVersion = CHashString(_T("SetFileVersion")).GetUniqueID();
		m_ToolBox->SendMessage(msgHash_SetFileVersion, sizeof(IHashString), &oldVersion);
		return MSG_ERROR;
	}

	// failure checks
	bool componentFailed = false;
	int failedDepth = 0;

	float secondsPerFrame = 1 / m_fLoadingUpdateFPS;
	ITimer *timer = EngineGetToolBox()->GetTimer();
	float lastLoadTime = timer->GetRealTime();
	float elapsedTime = 0.0f;

	while (Archive->GetNode(szNodeName))
	{
		int currDepth = Archive->GetDepth();
		if (componentFailed == true)
		{
			// current node is child of failed
			if (currDepth > failedDepth)
			{
				continue;
			}
			// if sibling or uncle, reset comp failed flag
			else
			{
				componentFailed = false;
			}
		}

		hszTypeName.Init( szNodeName.c_str() );

		StdString parentName;
		StdString parentType;
		StdString childType;
		Archive->GotoParentNode( parentType );
		Archive->Read( parentName, _T("Name") );
		if ( parentName != _T("") )
		{
			hszParentName = parentName;
		}
		Archive->ReturnToChildNode( childType );
		if( hszTypeName.GetString() != childType )
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:67,代码来源:XMLWorldLoader.cpp

示例2: OnCommitPrecache

DWORD CPrecacheManager::OnCommitPrecache(DWORD size, void *data)
{
	// No need to check this message. No arguments
	static DWORD msgHash_LoadFileByExtension = CHashString(_T("LoadFileByExtension")).GetUniqueID();
	static DWORD msgHash_UnloadFileByExtension = CHashString(_T("UnloadFileByExtension")).GetUniqueID();

	RESOURCEMAP::iterator itrRMapDel;
	RESOURCEMAP::iterator itrRMap = m_ResourceMap.begin();
	UINT mapSize = m_ResourceMap.size();
	UINT pos = 0;

	float secondsPerFrame = 1.0f / m_fLoadingUpdateFPS;
	ITimer *timer = EngineGetToolBox()->GetTimer();
	float lastLoadTime = timer->GetRealTime();
	float elapsedTime = 0.0f;
	// Run thru the list of resources 
	while( itrRMap != m_ResourceMap.end() )
	{
		// If a resource has a ref count > 0 
		if(itrRMap->second.m_iRefCount > 0)
		{
			// If bLoaded == false, Load the resource
			if( itrRMap->second.m_bLoaded == false )
			{
				// hacky mchackington
				static DWORD msgCacheSpawnFile = CHashString(_T("CacheSpawnFile")).GetUniqueID();
				TCHAR ext[_MAX_EXT];
				TCHAR *fileName = (TCHAR*)m_ToolBox->GetHashString( itrRMap->first );
				_tsplitpath(fileName, NULL, NULL, NULL, ext);

				if (!_tcscmp(_T(".sxl"), ext))
				{
					DWORD retval = EngineGetToolBox()->SendMessage(msgCacheSpawnFile, sizeof(TCHAR*), fileName);
					if( retval != MSG_HANDLED )
					{
						// Error Loading Resource. Removing it from the list
						m_ToolBox->Log( LOGWARNING, _T("Could not load resource %s from CommitPrecache call.\n"), m_ToolBox->GetHashString(itrRMap->first) );
						itrRMapDel = itrRMap;
						itrRMap++;
						m_ResourceMap.erase( itrRMapDel );
					}
					else
					{
						itrRMap->second.m_bLoaded = true;
						itrRMap++;
					}
				}
				else
				{
					LOADFILEEXTPARAMS lfep;
					lfep.fileName = fileName;
					lfep.bInternalLoad = true;
					DWORD retval = EngineGetToolBox()->SendMessage(msgHash_LoadFileByExtension, sizeof(LOADFILEEXTPARAMS), &lfep);
					if( retval != MSG_HANDLED )
					{
						// Error Loading Resource. Removing it from the list
						m_ToolBox->Log( LOGWARNING, _T("Could not load resource %s from CommitPrecache call.\n"), m_ToolBox->GetHashString(itrRMap->first) );
						itrRMapDel = itrRMap;
						itrRMap++;
						m_ResourceMap.erase( itrRMapDel );
					}
					else
					{
						itrRMap->second.m_bLoaded = true;
						itrRMap++;
					}

					elapsedTime += timer->GetRealTime() - lastLoadTime;
					lastLoadTime = timer->GetRealTime();
					if (elapsedTime > secondsPerFrame)
					{
						elapsedTime = 0.0f;
						// update the gui, renderer, and audio engines
						LOADINGUPDATEPARAMS lup;
						lup.currentPosition = (DWORD)pos;
						lup.totalSize = (DWORD)mapSize;
						static DWORD msgHash_LoadingUpdate = CHashString(_T("LoadingUpdate")).GetUniqueID();
						m_ToolBox->SendMessage(msgHash_LoadingUpdate, sizeof(LOADINGUPDATEPARAMS), &lup);
					}
				}
			}
			else
			{
				itrRMap++;
			}
			pos++;
		}
		// Else the resource has an ref count of 0. Unload the resource and remove it from the list
		else
		{
			// Commented out because of inter-dependency issues with various resources
			
			LOADFILEEXTPARAMS lfep;
			lfep.fileName = (TCHAR*)m_ToolBox->GetHashString( itrRMap->first );
			lfep.bInternalLoad = true;	
			DWORD retval = EngineGetToolBox()->SendMessage(msgHash_UnloadFileByExtension, sizeof(LOADFILEEXTPARAMS), &lfep);
			if( retval != MSG_HANDLED )
			{
				// Error Loading Resource. Removing it from the list
				m_ToolBox->Log( LOGWARNING, _T("Could not unload resource %s from CommitPrecache call.\n"), m_ToolBox->GetHashString(itrRMap->first) );
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:PrecacheManager.cpp


注:本文中的ITimer::GetRealTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。