void Canvas::render() { if (_hwnd == NULL) { return; } // RECT rect; GetClientRect(_hwnd, &rect); if (rect.left == rect.right) { return; } if (!_isInitialized()) { _create(); } if (RenderEngineImp::isNull() || NULL == RenderEngineImp::getInstancePtr()->getRenderEngine() || NULL == RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()) { return; } // RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->clear(0, NULL, Euclid::eClearFlags_Target | Euclid::eClearFlags_ZBuffer, RenderEngineImp::getInstancePtr()->getClearColor(), 1.0f, 0L); RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->beginScene(); // _renderGeometry(); // RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->endScene(); RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->present(NULL, NULL, NULL); // _calcFPS(); }
void CTimer::Update() { _CalcDeltaTime(); //Calculate Time since last frame _calcFPS(); //Calculate FPS _SleepUntilUpdate(); //Sleep }
void CViewWindow::onIdle() { if (RenderEngineImp::isNull()) { return; } static u32 oldTime = GetTickCount(); u32 currentTime = GetTickCount(); float delta = currentTime - oldTime; oldTime = currentTime; //_camera.lookAt(Vec3::ZERO); Vec3 pos = _cameraRelativeShpereCoordination.getPosition(); _camera.setPosition(pos); float s = Zen::Basic::Sin(_cameraRelativeShpereCoordination.mAngleUpFromXZ); //进入球的背面 Vec3 lookTaTarget = _cameraRelativeShpereCoordination.mOrigion; if (s < 0) { _camera.lookAt(lookTaTarget, Vec3::NEGATIVE_UNIT_Y); } else { _camera.lookAt(lookTaTarget); } _camera.update(); Mat4 m = _camera.getProjectionMatrix() * _camera.getViewMatrix(); if (_model) { _model->setMatrix("gWorldViewProj", m); Mat4 w = Mat4::IDENTITY; _model->setMatrix("gWorld", w); _model->setMatrix("gWorldInverseTranspose", w); _model->setMatrix("gView", _camera.getViewMatrix()); _model->setMatrix("gProjection", _camera.getProjectionMatrix()); // { Zen::Effect* fx = RenderEngineImp::getInstancePtr()->getRenderEngine()->getEffectManager()->getEffectByFile("shader/aPTSkin.fx"); if (fx) { Vec3 l = _light.mPosition.getPosition(); l.normalise(); Vec4 p(l.x, l.y, l.z, 0); fx->setVector("gLightPosition", &p); } } // _model->update(delta); } Zen::Effect* fx = _material->getEffect(); if (fx) { fx->setMatrix("g_mWorldViewProjection", m); } // { if (gTerrain.getMaterial()) { Zen::Effect* fx = gTerrain.getMaterial()->getEffect(); if (fx) { fx->setMatrix("g_mViewProjection", m); } } } // { if (mSculptor.mMaterial) { Zen::Effect* fx = mSculptor.mMaterial->getEffect(); if (fx) { fx->setMatrix("g_mViewProjection", m); } } } _calcFPS(); // RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->clear(0, NULL, Zen::eClearFlags_Target | Zen::eClearFlags_ZBuffer, Zen::Color::Black, 1.0f, 0L); RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->beginScene(); // _render(); // RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->endScene(); RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->present(NULL, NULL, NULL); }