void KX_KetsjiEngine::Render() { if(m_usedome){ RenderDome(); return; } KX_Scene* firstscene = *m_scenes.begin(); const RAS_FrameSettings &framesettings = firstscene->GetFramingType(); m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_RENDER); // hiding mouse cursor each frame // (came back when going out of focus and then back in again) if (m_hideCursor) m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); // clear the entire game screen with the border color // only once per frame m_canvas->BeginDraw(); if (m_drawingmode == RAS_IRasterizer::KX_TEXTURED) { m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight()); if (m_overrideFrameColor) { // Do not use the framing bar color set in the Blender scenes m_canvas->ClearColor( m_overrideFrameColorR, m_overrideFrameColorG, m_overrideFrameColorB, 1.0 ); } else { // Use the framing bar color set in the Blender scenes m_canvas->ClearColor( framesettings.BarRed(), framesettings.BarGreen(), framesettings.BarBlue(), 1.0 ); } // clear the -whole- viewport m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); } m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE); // BeginFrame() sets the actual drawing area. You can use a part of the window if (!BeginFrame()) return; KX_SceneList::iterator sceneit; for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) // for each scene, call the proceed functions { KX_Scene* scene = *sceneit; KX_Camera* cam = scene->GetActiveCamera(); // pass the scene's worldsettings to the rasterizer SetWorldSettings(scene->GetWorldInfo()); // this is now done incrementatlly in KX_Scene::CalculateVisibleMeshes //scene->UpdateMeshTransformations(); // shadow buffers RenderShadowBuffers(scene); // Avoid drawing the scene with the active camera twice when it's viewport is enabled if(cam && !cam->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, cam); } list<class KX_Camera*>* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while(it != cameras->end()) { if((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, (*it)); } it++; } } // only one place that checks for stereo if(m_rasterizer->Stereo()) { m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_RIGHTEYE); if (!BeginFrame()) return; for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) // for each scene, call the proceed functions { KX_Scene* scene = *sceneit; KX_Camera* cam = scene->GetActiveCamera(); // pass the scene's worldsettings to the rasterizer SetWorldSettings(scene->GetWorldInfo()); if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); //pass the scene, for picking and raycasting (shadows) m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering //RenderFrame(scene); RenderFrame(scene, cam); list<class KX_Camera*>* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while(it != cameras->end()) { if((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, (*it)); } it++; } } } // if(m_rasterizer->Stereo()) EndFrame(); }
void KX_KetsjiEngine::RenderDome() { GLuint viewport[4]={0}; glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); m_dome->SetViewPort(viewport); KX_Scene* firstscene = *m_scenes.begin(); const RAS_FrameSettings &framesettings = firstscene->GetFramingType(); m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true); // hiding mouse cursor each frame // (came back when going out of focus and then back in again) if (m_hideCursor) m_canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); // clear the entire game screen with the border color // only once per frame m_canvas->BeginDraw(); // BeginFrame() sets the actual drawing area. You can use a part of the window if (!BeginFrame()) return; KX_SceneList::iterator sceneit; int n_renders=m_dome->GetNumberRenders();// usually 4 or 6 for (int i=0;i<n_renders;i++){ m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); sceneit++) // for each scene, call the proceed functions { KX_Scene* scene = *sceneit; KX_Camera* cam = scene->GetActiveCamera(); m_rendertools->BeginFrame(m_rasterizer); // pass the scene's worldsettings to the rasterizer SetWorldSettings(scene->GetWorldInfo()); // shadow buffers if (i == 0){ RenderShadowBuffers(scene); } // Avoid drawing the scene with the active camera twice when it's viewport is enabled if(cam && !cam->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering m_dome->RenderDomeFrame(scene,cam, i); } list<class KX_Camera*>* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); while(it != cameras->end()) { if((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); m_rendertools->SetAuxilaryClientInfo(scene); // do the rendering m_dome->RenderDomeFrame(scene, (*it),i); } it++; } } m_dome->BindImages(i); } m_canvas->EndFrame();//XXX do we really need that? m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight()); if (m_overrideFrameColor) //XXX why do we want { // Do not use the framing bar color set in the Blender scenes m_canvas->ClearColor( m_overrideFrameColorR, m_overrideFrameColorG, m_overrideFrameColorB, 1.0 ); } else { // Use the framing bar color set in the Blender scenes m_canvas->ClearColor( framesettings.BarRed(), framesettings.BarGreen(), framesettings.BarBlue(), 1.0 ); } m_dome->Draw(); // run the 2dfilters and motion blur once for all the scenes PostRenderFrame(); EndFrame(); }