的笔记

随时随地编辑

code snippet:每个失去CString的coder都是折翼的天使,这样的coder你伤不起

从此,流落人间的天使都带上镶嵌了oss的翅膀
String RenderTarget::writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix)
{
    
struct tm *pTime;
    time_t ctTime; time(
&ctTime);
    pTime 
= localtime( &ctTime );
    Ogre::StringStream oss;
    oss    
<< std::setw(2) << std::setfill('0') << (pTime->tm_mon + 1)
        
<< std::setw(2) << std::setfill('0') << pTime->tm_mday
        
<< std::setw(2) << std::setfill('0') << (pTime->tm_year + 1900)
        
<< "_" << std::setw(2) << std::setfill('0') << pTime->tm_hour
        
<< std::setw(2) << std::setfill('0') << pTime->tm_min
        
<< std::setw(2) << std::setfill('0') << pTime->tm_sec
        
<< std::setw(3) << std::setfill('0') << (mTimer->getMilliseconds() % 1000);
    String filename 
= filenamePrefix + oss.str() + filenameSuffix;
    writeContentsToFile(filename);
    
return filename;

}



Ogre::RenderTarget::FrameStats stats = mWindow->getStatistics();

std::ostringstream oss;
Ogre::String s;

oss 
<< "FPS: " << std::fixed << std::setprecision(1) << stats.lastFPS;
s 
= oss.str();
for (int i = s.length() - 5; i > 5; i -= 3) { s.insert(i, 1, ','); }
mFpsLabel
->setCaption(s);

Ogre::StringVector values;

oss.str(
"");
oss 
<< std::fixed << std::setprecision(1) << stats.avgFPS;
Ogre::String str 
= oss.str();
for (int i = str.length() - 5; i > 0; i -= 3) { str.insert(i, 1, ','); }
values.push_back(s);

posted on 2011-06-19 18:56 的笔记 阅读(416) 评论(0)  编辑 收藏 引用 所属分类: C++