void mainLoop() { setupScene(); UpdateWindow(m_wnd); ShowWindow(m_wnd, SW_SHOW); DWORD lastTick = GetTickCount(); MSG msg; for (;;) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } else { DWORD now = GetTickCount(); float elapse = (now - lastTick) / 1000.0f; lastTick = now; onUpdate(elapse); onUpdateDX(elapse); onDisplayDX(); // WaitMessage(); } } cleanupScene(); }
int main() { int w = 400, h = 300; cout << "Input image's width,height:" << endl; cin >> w >> h; assert(w > 0 && h > 0); std::vector<char> buf; buf.resize(w * h * 4); setupScene(); { clock_t c = clock(); onDrawBuffer(&buf[0], w, h, w * 4); cout << "cost time : " << (clock() - c) / 1000.f << endl; } cleanupScene(); saveImage("scene.png", &buf[0], w, h, w * 4); { cout << "Press any key to continue..." << endl; char buf[32]; cin.getline(buf, sizeof(buf)); cin.getline(buf, sizeof(buf)); } }
UIGDetailsModel::~UIGDetailsModel() { /* Cleanup root: */ cleanupRoot(); /* Cleanup scene: */ cleanupScene(); }
int main(int argc, char* argv[]) { //test(); //test2(); //return 0; //setup the scene printf("Setup...\n"); setupScene(); //render stuff printf("Begin Render\n"); #ifdef __linux__ struct timeval start, end; gettimeofday(&start, NULL); #endif render(); #ifdef __linux__ gettimeofday(&end, NULL); long seconds = end.tv_sec - start.tv_sec; long useconds = end.tv_usec - start.tv_usec; long mtime = static_cast<long>((seconds * 1000 + useconds / 1000.0f) + 0.5f); printf("Render Complete, Time Taken: %ld ms\n", mtime); #else printf("Render Complete\n"); #endif //output the render result printf("Writing Image\n"); outputImage(); //cleanup everything printf("Cleanup\n"); cleanupScene(); return 0; }