//------------------------------------------------------------------------- // r u n //------------------------------------------------------------------------- void CApplication::run() { ITimer* timer = m_device->getTimer(); u32 current, last = timer->getRealTime(); u32 delta = 0; m_running = true; while(m_device->run() && m_running) { // calc seconds since last frame current = timer->getRealTime(); delta = current-last; last = current; m_videoDriver->beginScene(true, true, SColor(255,100,101,140)); preRender(delta); m_sceneManager->drawAll(); m_gui->drawAll(); postRender(); m_videoDriver->endScene(); } logMessage("Exiting Run Loop"); stringc msg = "Frame Rate - Avg: "; msg += m_fpsAvg; msg += ", Min: "; msg += m_fpsMin; msg += ", Max: "; msg += m_fpsMax; logMessage(msg); }
int main(int argc, char* argv[]) { stringc sceneDirectory, saveDir; irr::io::path sceneFileName; UserDataSerializer serializer; if(argc < 2) { printf("error scene file name missing:\n"); printf(" irrbPhysics <input scene filename>\n"); return -1; } // initialize Irrlicht m_device = _createDevice(); if(!m_device) return -1; m_fileSystem = m_device->getFileSystem(); m_videoDriver = m_device->getVideoDriver(); m_sceneManager = m_device->getSceneManager(); m_gui = m_device->getGUIEnvironment(); m_debugNode = new CDebugNode(m_sceneManager); // create debug panel (text area) core::dimension2du screen = m_videoDriver->getScreenSize(); m_debugPanel = m_gui->addStaticText(L"",rect<s32>(screen.Width-202,0,screen.Width-2,100)); m_debugPanel->setBackgroundColor(SColor(128, 30, 30, 30)); m_debugPanel->setDrawBorder(true); IGUIFont* font=m_debugPanel->getOverrideFont(); if(!font) font = m_gui->getSkin()->getFont(); m_charHeight = font->getDimension(L"Ay").Height; s32 idx=0; m_charHeight += font->getKerningHeight(); // create help panel (text area) m_helpPanel = m_gui->addStaticText(L"",rect<s32>(2,0,202,200)); m_helpPanel->setBackgroundColor(SColor(128, 30, 30, 30)); m_helpPanel->setDrawBorder(true); _addHelpText("F1 - Toggle Help"); _addHelpText("F3 - Cycle Wire, Points, Solid"); _addHelpText("F4 - Toggle Physics Debug"); _addHelpText("F5 - Warp To Start Position"); _addHelpText("F9 - Detach Camera"); // turn hardware cursor off m_device->getCursorControl()->setVisible(false); #if defined(USE_BULLET) m_device->setWindowCaption(L"irrb Collision/Physics example - Using Bullet"); #elif defined(USE_IRRPHYSX) m_device->setWindowCaption(L"irrb Collision/Physics example - Using IrrPhysx"); #else m_device->setWindowCaption(L"irrb Collision/Physics example - Using Irrlicht"); #endif m_camera = m_sceneManager->addCameraSceneNodeFPS(0, 100.0f, m_moveSpeed, -1, keyMap, 5, true, m_jumpSpeed); m_camera->setPosition(vector3df(0,10,0)); m_camera->setFOV(core::PI / 2.5f); m_camera->setNearValue(.1f); m_camera->setFarValue(1000.f); // save off animator core::list<ISceneNodeAnimator*>::ConstIterator anims=m_camera->getAnimators().begin(); while(anims != m_camera->getAnimators().end()) { if ((*anims)->getType() == ESNAT_CAMERA_FPS) { m_fpsAnimator = (ISceneNodeAnimatorCameraFPS*)*anims; break; } ++anims; } // init physics library _initPhysicsLibrary(); m_displayPhysicsDebug = true; _enablePhysicsDebug(true); m_debugNode->setVisible(true); // load scene sceneFileName = argv[1]; sceneDirectory = m_fileSystem->getFileDir(sceneFileName); saveDir = m_fileSystem->getWorkingDirectory(); m_fileSystem->changeWorkingDirectoryTo(sceneDirectory); m_sceneManager->loadScene(sceneFileName.c_str(), &serializer); m_fileSystem->changeWorkingDirectoryTo(saveDir); // if the scene also contained a camera, set the active // camera to our fps camera and update the fps pos/rot. if(m_camera && (m_camera != m_sceneManager->getActiveCamera())) { ICameraSceneNode* anode = m_sceneManager->getActiveCamera(); m_camera->setPosition(anode->getPosition()); m_camera->setRotation(anode->getRotation()); m_sceneManager->setActiveCamera(m_camera); m_startPos = m_camera->getPosition(); _warp(m_startPos); } ITimer* timer = m_device->getTimer(); u32 current, last = timer->getRealTime(); u32 delta = 0; while(m_device->run() && m_running) { _clearDebugText(); m_videoDriver->beginScene(true, true, SColor(255,100,101,140)); // calc milliseconds since last frame current = timer->getRealTime(); delta = current-last; last = current; // update collision/physics simulation _stepSimulation(delta); m_sceneManager->drawAll(); static char buf[64]; sprintf(buf, "FPS: %d", m_videoDriver->getFPS()); _updateDebugText(0, buf); m_gui->drawAll(); m_videoDriver->endScene(); } m_device->drop(); delete m_eventReceiver; return 0; }
/* Update one frame */ bool CApp::update() { using namespace irr; video::IVideoDriver* videoDriver = Device->getVideoDriver(); if ( !Device->run() ) return false; // Figure out delta time since last frame ITimer * timer = Device->getTimer(); u32 newTick = timer->getRealTime(); f32 deltaTime = RealTimeTick > 0 ? f32(newTick-RealTimeTick)/1000.0 : 0.f; // in seconds RealTimeTick = newTick; if ( Device->isWindowActive() || Config.RenderInBackground ) { gui::IGUIEnvironment* guiEnv = Device->getGUIEnvironment(); scene::ISceneManager* smgr = Device->getSceneManager(); gui::IGUISkin * skin = guiEnv->getSkin(); // update our controls MeshMaterialControl.update(SceneNode, SceneNode2T, SceneNodeTangents); LightControl.update(NodeLight); // Update vertices if ( ControlVertexColors->isDirty() ) { MeshManipulator->setVertexColors (SceneNode->getMesh(), ControlVertexColors->getColor()); MeshManipulator->setVertexColors (SceneNode2T->getMesh(), ControlVertexColors->getColor()); MeshManipulator->setVertexColors (SceneNodeTangents->getMesh(), ControlVertexColors->getColor()); ControlVertexColors->resetDirty(); } // update ambient light settings if ( GlobalAmbient->isDirty() ) { smgr->setAmbientLight( GlobalAmbient->getColor() ); GlobalAmbient->resetDirty(); } // Let the user move the light around const float zoomSpeed = 10.f * deltaTime; const float rotationSpeed = 100.f * deltaTime; if ( KeysPressed[KEY_PLUS] || KeysPressed[KEY_ADD]) ZoomOut(NodeLight, zoomSpeed); if ( KeysPressed[KEY_MINUS] || KeysPressed[KEY_SUBTRACT]) ZoomOut(NodeLight, -zoomSpeed); if ( KeysPressed[KEY_RIGHT]) RotateHorizontal(NodeLight, rotationSpeed); if ( KeysPressed[KEY_LEFT]) RotateHorizontal(NodeLight, -rotationSpeed); UpdateRotationAxis(NodeLight, LightRotationAxis); if ( KeysPressed[KEY_UP]) RotateAroundAxis(NodeLight, rotationSpeed, LightRotationAxis); if ( KeysPressed[KEY_DOWN]) RotateAroundAxis(NodeLight, -rotationSpeed, LightRotationAxis); // Let the user move the camera around if (MousePressed) { gui::ICursorControl* cursorControl = Device->getCursorControl(); const core::position2d<s32>& mousePos = cursorControl->getPosition (); RotateHorizontal(Camera, rotationSpeed * (MouseStart.X - mousePos.X)); RotateAroundAxis(Camera, rotationSpeed * (mousePos.Y - MouseStart.Y), CameraRotationAxis); MouseStart = mousePos; } // draw everything video::SColor bkColor( skin->getColor(gui::EGDC_APP_WORKSPACE) ); videoDriver->beginScene(true, true, bkColor); smgr->drawAll(); guiEnv->drawAll(); if ( MeshMaterialControl.isLightingEnabled() ) { // draw a line from the light to the target video::SMaterial lineMaterial; lineMaterial.Lighting = false; videoDriver->setMaterial(lineMaterial); videoDriver->setTransform(video::ETS_WORLD, core::IdentityMatrix); videoDriver->draw3DLine(NodeLight->getAbsolutePosition(), SceneNode->getAbsolutePosition()); } videoDriver->endScene(); } // be nice Device->sleep( 5 ); return true; }
//! Test both the accuracy and speed of Irrlicht's fast_atof() implementation. bool fast_atof(void) { bool accurate = true; accurate &= testCalculation("340282346638528859811704183484516925440.000000"); accurate &= testCalculation("3.402823466e+38F"); accurate &= testCalculation("3402823466e+29F"); accurate &= testCalculation("-340282346638528859811704183484516925440.000000"); accurate &= testCalculation("-3.402823466e+38F"); accurate &= testCalculation("-3402823466e+29F"); accurate &= testCalculation("34028234663852885981170418348451692544.000000"); accurate &= testCalculation("3.402823466e+37F"); accurate &= testCalculation("3402823466e+28F"); accurate &= testCalculation("-34028234663852885981170418348451692544.000000"); accurate &= testCalculation("-3.402823466e+37F"); accurate &= testCalculation("-3402823466e+28F"); accurate &= testCalculation(".00234567"); accurate &= testCalculation("-.00234567"); accurate &= testCalculation("0.00234567"); accurate &= testCalculation("-0.00234567"); accurate &= testCalculation("1.175494351e-38F"); accurate &= testCalculation("1175494351e-47F"); accurate &= testCalculation("1.175494351e-37F"); accurate &= testCalculation("1.175494351e-36F"); accurate &= testCalculation("-1.175494351e-36F"); accurate &= testCalculation("123456.789"); accurate &= testCalculation("-123456.789"); accurate &= testCalculation("0000123456.789"); accurate &= testCalculation("-0000123456.789"); accurate &= testCalculation("-0.0690462109446526"); if(!accurate) { logTestString("Calculation is not accurate, so the speed is irrelevant\n"); return false; } IrrlichtDevice* device = createDevice(video::EDT_NULL); if (!device) return false; ITimer* timer = device->getTimer(); enum { ITERATIONS = 100000 }; int i; f32 value; u32 then = timer->getRealTime(); for(i = 0; i < ITERATIONS; ++i) value = (f32)atof("-340282346638528859811704183484516925440.000000"); const u32 atofTime = timer->getRealTime() - then; then += atofTime; for(i = 0; i < ITERATIONS; ++i) value = fast_atof("-340282346638528859811704183484516925440.000000"); const u32 fastAtofTime = timer->getRealTime() - then; then += fastAtofTime; for(i = 0; i < ITERATIONS; ++i) value = old_fast_atof("-340282346638528859811704183484516925440.000000"); const u32 oldFastAtofTime = timer->getRealTime() - then; logTestString(" atof time = %d\n fast_atof Time = %d\nold fast_atof time = %d\n", atofTime, fastAtofTime, oldFastAtofTime); device->drop(); if(fastAtofTime > (1.2f*atofTime)) { logTestString("The fast method is slower than atof()\n"); return false; } return true; }
//! Test both the accuracy and speed of Irrlicht's strtol10() implementation. bool test_strtol(void) { bool accurate = true; accurate &= testCalculation_strtol("340282346638528859811704183484516925440"); accurate &= testCalculation_strtol("3402823466"); accurate &= testCalculation_strtol("3402823466e+29F"); accurate &= testCalculation_strtol("-340282346638528859811704183484516925440"); accurate &= testCalculation_strtol("-3402823466"); accurate &= testCalculation_strtol("-3402823466e+29F"); accurate &= testCalculation_strtol("402823466385288598117"); accurate &= testCalculation_strtol("402823466"); accurate &= testCalculation_strtol("402823466e+28F"); accurate &= testCalculation_strtol("402823466385288598117"); accurate &= testCalculation_strtol("-402823466"); accurate &= testCalculation_strtol("-402823466e+28F"); accurate &= testCalculation_strtol(".00234567"); accurate &= testCalculation_strtol("-234567"); accurate &= testCalculation_strtol("234567"); accurate &= testCalculation_strtol("-234567"); accurate &= testCalculation_strtol("1175494351"); accurate &= testCalculation_strtol("11754943512"); accurate &= testCalculation_strtol("11754943513"); accurate &= testCalculation_strtol("11754943514"); accurate &= testCalculation_strtol("-1175494351"); accurate &= testCalculation_strtol("123456789"); accurate &= testCalculation_strtol("-123456789"); accurate &= testCalculation_strtol("123456.789"); accurate &= testCalculation_strtol("-123456.789"); accurate &= testCalculation_strtol("-109446526"); if(!accurate) { logTestString("Calculation is not accurate, so the speed is irrelevant\n"); return false; } IrrlichtDevice* device = createDevice(video::EDT_NULL); if (!device) return false; ITimer* timer = device->getTimer(); const int ITERATIONS = 1000000; int i; s32 value; u32 then = timer->getRealTime(); for(i = 0; i < ITERATIONS; ++i) value = strtol("-3402823466", 0, 10); const u32 strtolTime = timer->getRealTime() - then; then += strtolTime; for(i = 0; i < ITERATIONS; ++i) value = strtol10("-3402823466"); const u32 strtol10Time = timer->getRealTime() - then; then += strtol10Time; for(i = 0; i < ITERATIONS; ++i) value = old_strtol10("-3402823466"); const u32 oldstrtol10Time = timer->getRealTime() - then; logTestString("Speed test\n strtol time = %d\n strtol10 time = %d\nold strtol10 time = %d\n", strtolTime, strtol10Time, oldstrtol10Time); device->closeDevice(); device->run(); device->drop(); if (strtol10Time > (1.2f*strtolTime)) { logTestString("The fast method is slower than strtol()\n"); return false; } return true; }
s32 main( s32 argc, c8** argv) { const c8* MY_TITLE = "CGUIPlot (c) 2013 by [email protected]"; video::E_DRIVER_TYPE DriverType = video::EDT_OPENGL; // we like to have some choice //DriverType = driverChoiceConsole(true); /// create NullDevice SIrrlichtCreationParameters params; params.DriverType = video::EDT_NULL; params.LoggingLevel = ELL_NONE; params.Fullscreen = false; IrrlichtDevice* nulldev = createDeviceEx( params ); if (nulldev) { video::IVideoModeList* videoModes = nulldev->getVideoModeList(); //params.WindowSize = videoModes->getDesktopResolution(); //params.WindowSize -= core::dimension2du(100,100); params.WindowSize = core::dimension2du(800,600); params.Bits = videoModes->getDesktopDepth(); nulldev->drop(); } else { printf("Could not create Null device\n"); exit(-1); } /// create Device params.LoggingLevel = ELL_INFORMATION; params.DriverType = DriverType; params.AntiAlias = video::EAAM_QUALITY; params.EventReceiver = 0; params.HighPrecisionFPU = true; params.Doublebuffer = true; params.Vsync = false; params.Fullscreen = false; // params.ZBufferBits = 32; // params.Stencilbuffer = true; // params.WithAlphaChannel = false; IrrlichtDevice* device = createDeviceEx( params ); if (!device) { printf("Could not create device\n"); exit(-2); } MyEventReceiver receiver( device ); gui::IGUIEnvironment* env = device->getGUIEnvironment(); video::IVideoDriver* driver = device->getVideoDriver(); core::dimension2du screen = driver->getScreenSize(); scene::ISceneManager* smgr = device->getSceneManager(); ITimer* timer = device->getTimer(); device->setResizable( true ); device->setWindowCaption( core::stringw( MY_TITLE ).c_str() ); //gui::IGUIFont* font = env->getBuiltInFont(); /// create some functions of time f(t) CSineOscillator<f32> vco_0(1, 0, 3); CSineOscillator<f32> vco_1(2, 0, 2); CSineOscillator<f32> vco_2(3, 0, 1); CRectangleOscillator<f32> vco_3(1, 0.1f, 0.4f, 2, -1); CSawOscillator<f32> vco_4(1, 0, 0.5f, -0.5f); CSawOscillator<f32> vco_5(3, 0.5f, 3, 0); CADSREnvelope<f32> adsr(1,3,0.7,2, CADSREnvelope<f32>::EMTT_LINEAR); /// create IGUIWindow as container for CGUIPlot gui::IGUIWindow* plotWindow = env->addWindow( core::recti( 100,100,screen.Width-100, screen.Height-100 ), false, L"CGUIPlot Window", env->getRootGUIElement(), -1); /// create CGUIPlot gui::CGUIPlotManager* plotMgr = new gui::CGUIPlotManager( env, plotWindow, -1, plotWindow->getClientRect()); gui::CGUIPlot* plot = plotMgr->addPlot( new gui::CGUIPlot( smgr, env, plotMgr, -1, plotMgr->getClientRect() ) ); // left, bottom, right, top plot->setZoomRect( core::rectf( -1,-3,10,3) ); plot->setDrawBackground( true ); plot->setBackgroundColor( video::SColor(128,255,255,255) ); scene::ISceneNode* smgrRoot = smgr->getRootSceneNode(); /// PolyLine { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(vco_0), -1, 10, 2048, video::SColor(255,255,0,0), 0.75f, 0xfcfc ); if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "VCO_0", node ); } /// PolyLine { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(vco_1), 0, 5, 2048, video::SColor(255,255,255,0), 1.5f, 0xdddd ); if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "VCO_1", node ); } /// PolyLine { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(vco_2), 0, 5, 2048, video::SColor(255,0,0,255), .5f, 0xffff ); if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "VCO_2", node ); } /// PolyLine { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(vco_3), 2, 8, 2048, video::SColor(255,255,0,255), 1.5f, 0xffff ); if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "VCO_3", node ); } /// PolyLine { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(vco_4), 0, 8, 1024, video::SColor(255,0,192,0), .5f, 0xffff ); if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "VCO_4", node ); } /// PolyLine [ADSR-curve] { scene::ISceneNode* node = createPolyLine<f32>( smgr, smgrRoot, Functor_f32_f32(adsr), 0, 8, 1024, video::SColor(255,192,0,192), .5f, 0xffff ); // if (node) node->setDebugDataVisible( scene::EDS_BBOX ); plot->addShape( "ADSR-Curve", node ); } /// [main loop] u32 timeLastWindowTitleUpate(0); u32 timeWaitWindowTitleUpate(500); while (device->run()) { /// Resize-Event if (screen != driver->getScreenSize() ) { screen = driver->getScreenSize(); scene::ICameraSceneNode* camera = smgr->getActiveCamera(); if (camera) { f32 aspect = (f32)screen.Width / (f32)screen.Height; camera->setAspectRatio( aspect ); } } /// if window is active ( can be minimized but still active ) if (device->isWindowActive()) { /// if window is active ( can be minimized but still active ) if (device->isWindowFocused()) { /// render all driver->beginScene( true, true, video::SColor(255,225,225,225) ); smgr->drawAll(); env->drawAll(); driver->endScene(); /// window-title update if ( timer->getRealTime() - timeLastWindowTitleUpate > timeWaitWindowTitleUpate ) { core::stringw txt = core::stringw( MY_TITLE ); txt += L" | fps( "; txt += driver->getFPS(); txt += L" ), poly( "; txt += driver->getPrimitiveCountDrawn(); txt += L" / "; txt += driver->getMaximalPrimitiveCount(); txt += L" ), "; // scene::ICameraSceneNode* cam = smgr->getActiveCamera(); // if (cam) // { // const core::vector3df& pos = cam->getAbsolutePosition(); // txt += L"cam( pos("; // txt += core::round32(pos.X); txt += L","; // txt += core::round32(pos.Y); txt += L","; // txt += core::round32(pos.Z); txt += L"), "; // // const core::vector3df& eye = cam->getTarget(); // txt += L"eye("; // txt += core::round32(eye.X); txt += L","; // txt += core::round32(eye.Y); txt += L","; // txt += core::round32(eye.Z); txt += L"), "; // txt += L"near("; // txt += cam->getNearValue(); // txt += L"), far("; // txt += core::round32(cam->getFarValue() ); txt += L")"; // txt += L" )"; // } device->setWindowCaption( txt.c_str() ); timeLastWindowTitleUpate = timer->getRealTime(); } } else { device->yield(); } } else { device->yield(); } } if (device) device->drop(); return 0; }
s32 main( s32 argc, c8** argv) { /// we like to have some choice //video::E_DRIVER_TYPE myDriverType = driverChoiceConsole(true); /// create NullDevice SIrrlichtCreationParameters params; params.LoggingLevel = ELL_NONE; params.DriverType = video::EDT_NULL; IrrlichtDevice* nulldev = createDeviceEx( params ); if (nulldev) { video::IVideoModeList* videoModes = nulldev->getVideoModeList(); params.WindowSize = videoModes->getDesktopResolution(); params.WindowSize -= core::dimension2du(100,100); params.Bits = videoModes->getDesktopDepth(); nulldev->drop(); } else { printf("Could not create Null device\n"); exit(-1); } /// create OpenGL Device params.LoggingLevel = ELL_INFORMATION; params.DriverType = video::EDT_OPENGL; params.AntiAlias = video::EAAM_QUALITY; params.EventReceiver = 0; params.HighPrecisionFPU = true; params.Doublebuffer = true; params.Vsync = false; params.Fullscreen = false; // params.ZBufferBits = 32; // params.Stencilbuffer = true; // params.WithAlphaChannel = false; IrrlichtDevice* device = createDeviceEx( params ); if (!device) { printf("Could not create OpenGL device\n"); exit(-2); } device->setResizable( true ); /// IRunable IRunable* runable = 0; /// IRenderable ICustomRenderer* customRenderer = 0; /// create App AudioAnimator3d app0( device ); runable = &app0; customRenderer = &app0; /// some pointers and variables gui::IGUIEnvironment* env = device->getGUIEnvironment(); video::IVideoDriver* driver = device->getVideoDriver(); core::dimension2du screen = driver->getScreenSize(); scene::ISceneManager* smgr = device->getSceneManager(); ITimer* timer = device->getTimer(); u32 timeLastWindowTitleUpate(0); u32 timeWaitWindowTitleUpate(500); /// testing CLinearColorGradientTable video::CLinearColorGradientTable table; table.addColor( video::SColor(0,255,255,255), 0.0f ); table.addColor( video::SColor(255,255,255,0), 0.5f ); table.addColor( video::SColor(255,255,0,0), 0.8f ); table.addColor( video::SColor(255,255,255,255), 1.0f ); table.setTableSize( 100 ); table.updateTable(); /// testing CGUIImageViewer // gui::IGUIWindow* win0 = env->addWindow( // core::recti( 100, 100, screen.Width-300, screen.Height-300 ), // false, L"CGUIImageViewer", env->getRootGUIElement(), -1 ); // // gui::CGUIImageViewer* viewer0 = new gui::CGUIImageViewer( // env, win0, -1, win0->getClientRect() ); /// testing CGUIDataPlot // gui::IGUIWindow* win1 = env->addWindow( // core::recti( 200, 200, screen.Width-200, screen.Height-200 ), // false, L"CGUIDataPlot", env->getRootGUIElement(), -1 ); // // gui::CGUIDataPlot* viewer1 = new gui::CGUIDataPlot( // env, win1, -1, win1->getClientRect() ); /// main loop while (device->run()) { /// Resize-Event if (screen != driver->getScreenSize() ) { screen = driver->getScreenSize(); scene::ICameraSceneNode* camera = smgr->getActiveCamera(); if (camera) { f32 aspect = (f32)screen.Width / (f32)screen.Height; camera->setAspectRatio( aspect ); } } /// run injected Application class if (runable) runable->run(); /// if window is active ( can be minimized but still active ) if (device->isWindowActive()) { /// if window is active ( can be minimized but still active ) if (device->isWindowFocused()) { /// render all driver->beginScene( true, true, video::SColor(255,0,0,0) ); smgr->drawAll(); // render, if exist if (customRenderer) customRenderer->render(); env->drawAll(); driver->endScene(); /// window-title update if ( timer->getRealTime() - timeLastWindowTitleUpate > timeWaitWindowTitleUpate ) { core::stringw txt = MY_TITLE; txt += L" | fps( "; txt += driver->getFPS(); txt += L" ), poly( "; txt += driver->getPrimitiveCountDrawn(); txt += L" / "; txt += driver->getMaximalPrimitiveCount(); txt += L" ), "; scene::ICameraSceneNode* cam = smgr->getActiveCamera(); if (cam) { const core::vector3df& pos = cam->getAbsolutePosition(); txt += L"cam( pos("; txt += core::round32(pos.X); txt += L","; txt += core::round32(pos.Y); txt += L","; txt += core::round32(pos.Z); txt += L"), "; const core::vector3df& eye = cam->getTarget(); txt += L"eye("; txt += core::round32(eye.X); txt += L","; txt += core::round32(eye.Y); txt += L","; txt += core::round32(eye.Z); txt += L"), "; txt += L"near("; txt += cam->getNearValue(); txt += L"), far("; txt += core::round32(cam->getFarValue() ); txt += L")"; txt += L" )"; } device->setWindowCaption( txt.c_str() ); timeLastWindowTitleUpate = timer->getRealTime(); } } else { device->yield(); } } else { device->yield(); } } if (device) device->drop(); return 0; }