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 GLSkyPortal::DrawContents() { bool drawBoth = false; // We have no use for Doom lighting special handling here, so disable it for this function. int oldlightmode = glset.lightmode; if (glset.lightmode == 8) { glset.lightmode = 2; gl_RenderState.SetSoftLightLevel(-1); } gl_RenderState.ResetColor(); gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); bool oldClamp = gl_RenderState.SetDepthClamp(true); gl_MatrixStack.Push(gl_RenderState.mViewMatrix); GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); } else { gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; if (origin->texture[0]) { gl_RenderState.SetTextureMode(TM_OPAQUE); RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER); gl_RenderState.SetTextureMode(TM_MODULATE); } gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f); if (origin->doublesky && origin->texture[1]) { RenderDome(origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER); } if (skyfog>0 && gl_fixedcolormap == CM_DEFAULT && (origin->fadecolor & 0xffffff) != 0) { PalEntry FadeColor = origin->fadecolor; FadeColor.a = clamp<int>(skyfog, 0, 255); gl_RenderState.EnableTexture(false); gl_RenderState.SetObjectColor(FadeColor); gl_RenderState.Apply(); glDrawArrays(GL_TRIANGLES, 0, 12); gl_RenderState.EnableTexture(true); gl_RenderState.SetObjectColor(0xffffffff); } gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); } gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); gl_RenderState.ApplyMatrices(); glset.lightmode = oldlightmode; gl_RenderState.SetDepthClamp(oldClamp); }
//----------------------------------------------------------------------------- // // // //----------------------------------------------------------------------------- void GLSkyPortal::DrawContents() { bool drawBoth = false; int CM_Index; PalEntry FadeColor(0,0,0,0); // We have no use for Doom lighting special handling here, so disable it for this function. int oldlightmode = glset.lightmode; if (glset.lightmode == 8) glset.lightmode = 2; if (gl_fixedcolormap) { CM_Index=gl_fixedcolormap<CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()? gl_fixedcolormap:CM_DEFAULT; } else { CM_Index=CM_DEFAULT; FadeColor=origin->fadecolor; } gl_RenderState.EnableFog(false); gl_RenderState.EnableAlphaTest(false); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_MODELVIEW); glPushMatrix(); GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) { if (gl_fixedcolormap != CM_DEFAULT) { float rr,gg,bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R=rr; G=gg; B=bb; } else R=G=B=1.f; RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index, origin->sky2); gl_RenderState.EnableAlphaTest(true); } else { if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; if (origin->texture[0]) { gl_RenderState.SetTextureMode(TM_OPAQUE); RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, CM_Index); gl_RenderState.SetTextureMode(TM_MODULATE); } gl_RenderState.EnableAlphaTest(true); gl_RenderState.AlphaFunc(GL_GEQUAL,0.05f); if (origin->doublesky && origin->texture[1]) { secondlayer=true; RenderDome(FNullTextureID(), origin->texture[1], origin->x_offset[1], origin->y_offset, false, CM_Index); secondlayer=false; } if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b)) { gl_RenderState.EnableTexture(false); foglayer=true; glColor4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); RenderDome(FNullTextureID(), NULL, 0, 0, false, CM_DEFAULT); gl_RenderState.EnableTexture(true); foglayer=false; } } glPopMatrix(); glset.lightmode = oldlightmode; }
//----------------------------------------------------------------------------- // // // //----------------------------------------------------------------------------- void GLSkyPortal::DrawContents() { bool drawBoth = false; int CM_Index; PalEntry FadeColor(0,0,0,0); if (gl_fixedcolormap) { CM_Index=gl_fixedcolormap<CM_LIMIT? gl_fixedcolormap:CM_DEFAULT; } else { CM_Index=CM_DEFAULT; FadeColor=origin->fadecolor; } gl_EnableFog(false); gl.Disable(GL_ALPHA_TEST); gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl.PushMatrix(); gl_SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1), true); if (origin->texture[0] && origin->texture[0]->bSkybox) { if (fixedcolormap) { float rr,gg,bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R=rr; G=gg; B=bb; } else R=G=B=1.f; RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index); gl.Enable(GL_ALPHA_TEST); } else { if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; gl.Translatef(0.f, -1000.f, 0.f); if (origin->texture[0]) { gl_SetTextureMode(TM_OPAQUE); RenderDome(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->y_offset, CM_Index); gl_SetTextureMode(TM_MODULATE); } gl.Enable(GL_ALPHA_TEST); gl.AlphaFunc(GL_GEQUAL,0.05f); if (origin->doublesky && origin->texture[1]) { secondlayer=true; RenderDome(0, origin->texture[1], origin->x_offset[1], origin->y_offset, CM_Index); secondlayer=false; } if (skyfog>0 && (FadeColor.r ||FadeColor.g || FadeColor.b)) { gl_EnableTexture(false); foglayer=true; gl.Color4f(FadeColor.r/255.0f,FadeColor.g/255.0f,FadeColor.b/255.0f,skyfog/255.0f); RenderDome(0, NULL, 0, 0, CM_DEFAULT); gl_EnableTexture(true); foglayer=false; } } gl.PopMatrix(); }