void SampleContext::recoverLastSample() { runSample(mLastSample); mLastSample->restoreState(mLastSampleState); mLastSample = NULL; mLastSampleState.clear(); }
void part2() { // Seed RNG struct timeval tv; gettimeofday(&tv, NULL); srand((unsigned) tv.tv_usec); // Wiping any existing data // FILE* f = fopen("data/data.csv", "w"); // if (f == NULL) { // printf("Error opening file\n"); // return; // } // fclose(f); // f = fopen("data/times.csv", "w"); // if (f == NULL) { // printf("Error opening file\n"); // return; // } // fclose(f); // Collect data 50 times for (int i = 0; i < 50; i++) { printf("%i\n", i); runSample(); break; } }
// // Program starts here // int main( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_pD2DFactory ); hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof( IDWriteFactory ), reinterpret_cast<IUnknown**>( &g_pDWriteFactory ) ); hr = CoInitialize( NULL ); hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, reinterpret_cast<void**>( &g_pWICFactory ) ); g_pHWND = CreateGameWindow(); createDeviceResources(); // // Create a GWEN Direct2D renderer // g_pRenderer = new gwen::Renderer::Direct2D( g_pRT, g_pDWriteFactory, g_pWICFactory ); runSample(); delete g_pRenderer; g_pRenderer = NULL; if ( g_pRT != NULL ) { g_pRT->Release(); g_pRT = NULL; } }
void SampleContext::initApp(Sample* initialSample) { createEnginInstance(); if (!oneTimeConfig()) return; if (!mFirstRun) { mEngine->setRenderSystem(mEngine->getRenderSystemByName(mNextRenderer)); } setup(); if (!mFirstRun) { recoverLastSample(); } else if (initialSample) { runSample(initialSample); } }
bool TestContext::frameEnded(const Ogre::FrameEvent& evt) { // pass a fixed timestep along to the tests Ogre::FrameEvent fixed_evt = Ogre::FrameEvent(); fixed_evt.timeSinceLastFrame = mTimestep; fixed_evt.timeSinceLastEvent = mTimestep; if (mCurrentTest) // if a test is running { if (mCurrentTest->isScreenshotFrame(mCurrentFrame)) { // take a screenshot Ogre::String filename = mOutputDir + mBatch->name + "/" + mCurrentTest->getInfo()["Title"] + "_" + Ogre::StringConverter::toString(mCurrentFrame) + ".png"; // remember the name of the shot, for later comparison purposes mBatch->images.push_back(mCurrentTest->getInfo()["Title"] + "_" + Ogre::StringConverter::toString(mCurrentFrame)); mWindow->writeContentsToFile(filename); } if (mCurrentTest->isDone()) { // continue onto the next test runSample(0); return true; } // standard update function return mCurrentTest->frameEnded(fixed_evt); } else if (mCurrentSample) // if a generic sample is running { return mCurrentSample->frameEnded(evt); } else { // if no more tests are queued, generate output and exit finishedTests(); return false; } }
void TestContext::setup() { // standard setup mWindow = createWindow(); mWindow->setDeactivateOnFocusChange(false); setupInput(false);// grab input, since moving the window seemed to change the results (in Linux anyways) locateResources(); loadResources(); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); mRoot->addFrameListener(this); #if OGRE_PLATFORM != OGRE_PLATFORM_ANDROID Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); #endif // get the path and list of test plugins from the config file Ogre::ConfigFile testConfig; testConfig.load(mFSLayer->getConfigFilePath("tests.cfg")); mPluginDirectory = testConfig.getSetting("TestFolder"); Ogre::ConfigFile::SectionIterator sections = testConfig.getSectionIterator(); // parse for the test sets and plugins that they're made up of for (; sections.hasMoreElements(); sections.moveNext()) { Ogre::String setName = sections.peekNextKey(); if (setName != "") { mTestSets[setName] = Ogre::StringVector(); Ogre::ConfigFile::SettingsMultiMap::iterator it = sections.peekNextValue()->begin(); for (; it != sections.peekNextValue()->end(); ++it) mTestSets[setName].push_back(it->second); } } // timestamp for the filename char temp[25]; time_t raw = time(0); strftime(temp, 19, "%Y_%m_%d_%H%M_%S", gmtime(&raw)); Ogre::String filestamp = Ogre::String(temp); // name for this batch (used for naming the directory, and uniquely identifying this batch) Ogre::String batchName = mTestSetName + "_" + filestamp; // a nicer formatted version for display strftime(temp, 20, "%Y-%m-%d %H:%M:%S", gmtime(&raw)); Ogre::String timestamp = Ogre::String(temp); if (mReferenceSet) batchName = "Reference"; else if (mBatchName != "AUTO") batchName = mBatchName; // set up output directories setupDirectories(batchName); // an object storing info about this set mBatch = new TestBatch(batchName, mTestSetName, timestamp, mWindow->getWidth(), mWindow->getHeight(), mOutputDir + batchName + "/"); mBatch->comment = mComment; OgreBites::Sample* firstTest = loadTests(mTestSetName); runSample(firstTest); }
void OgreApp::setup() { OgreBites::SampleBrowser::setup(); runSample(Ogre::any_cast<OgreBites::Sample*>(mThumbs[0]->getUserAny())); }