void CSplash::Show() { g_graphicsContext.Lock(); g_graphicsContext.Clear(); g_graphicsContext.Flip(); #ifndef _WIN32 g_graphicsContext.Clear(); g_graphicsContext.Flip(); g_graphicsContext.Clear(); g_graphicsContext.Flip(); #endif float w = g_graphicsContext.GetWidth(); float h = g_graphicsContext.GetHeight(); if(g_graphicsContext.GetRenderLowresGraphics()) { RESOLUTION res = g_graphicsContext.GetGraphicsResolution(); w = g_settings.m_ResInfo[res].iWidth; h = g_settings.m_ResInfo[res].iHeight; } CGUIImage* image = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName); image->SetAspectRatio(CAspectRatio::AR_KEEP); image->AllocResources(); //render splash image g_Windowing.BeginRender(); image->Render(); image->FreeResources(); delete image; //show it on screen g_Windowing.EndRender(); g_graphicsContext.Flip(); g_graphicsContext.Unlock(); }
void CSplash::Process() { D3DGAMMARAMP newRamp; D3DGAMMARAMP oldRamp; g_graphicsContext.Lock(); g_graphicsContext.Get3DDevice()->Clear(0, NULL, D3DCLEAR_TARGET, 0, 0, 0); g_graphicsContext.SetCameraPosition(CPoint(0, 0)); float w = g_graphicsContext.GetWidth(); float h = g_graphicsContext.GetHeight(); CGUIImage* image = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName); CGUIImage* image2 = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName2); image->SetAspectRatio(CAspectRatio::AR_STRETCH); image2->SetAspectRatio(CAspectRatio::AR_STRETCH); image->AllocResources(); image2->AllocResources(); // Store the old gamma ramp g_graphicsContext.Get3DDevice()->GetGammaRamp(&oldRamp); float fade = 0.5f; for (int i = 0; i < 256; i++) { newRamp.red[i] = (int)((float)oldRamp.red[i] * fade); newRamp.green[i] = (int)((float)oldRamp.red[i] * fade); newRamp.blue[i] = (int)((float)oldRamp.red[i] * fade); } g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp); //render splash image #ifndef HAS_XBOX_D3D g_graphicsContext.Get3DDevice()->BeginScene(); #endif image->Render(); image2->Render(); image->FreeResources(); image2->FreeResources(); delete image; delete image2; //show it on screen #ifdef HAS_XBOX_D3D g_graphicsContext.Get3DDevice()->BlockUntilVerticalBlank(); #else g_graphicsContext.Get3DDevice()->EndScene(); #endif g_graphicsContext.Get3DDevice()->Present( NULL, NULL, NULL, NULL ); g_graphicsContext.Unlock(); //fade in and wait untill the thread is stopped while (!m_bStop) { if (fade <= 1.f) { for (int i = 0; i < 256; i++) { newRamp.red[i] = (int)((float)oldRamp.red[i] * fade); newRamp.green[i] = (int)((float)oldRamp.green[i] * fade); newRamp.blue[i] = (int)((float)oldRamp.blue[i] * fade); } g_graphicsContext.Lock(); Sleep(3); g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp); g_graphicsContext.Unlock(); fade += 0.01f; } else { Sleep(10); } } g_graphicsContext.Lock(); // fade out for (float fadeout = fade - 0.01f; fadeout >= 0.f; fadeout -= 0.01f) { for (int i = 0; i < 256; i++) { newRamp.red[i] = (int)((float)oldRamp.red[i] * fadeout); newRamp.green[i] = (int)((float)oldRamp.green[i] * fadeout); newRamp.blue[i] = (int)((float)oldRamp.blue[i] * fadeout); } Sleep(3); g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp); } //restore original gamma ramp g_graphicsContext.Get3DDevice()->Clear(0, NULL, D3DCLEAR_TARGET, 0, 0, 0); g_graphicsContext.Get3DDevice()->SetGammaRamp(0, &oldRamp); g_graphicsContext.Get3DDevice()->Present( NULL, NULL, NULL, NULL ); g_graphicsContext.Unlock(); }