HRESULT IImpostorable::OnResetDevice(IDirect3DDevice9 *pd3dDevice) { HRESULT hr; InitRenderToSurface(pd3dDevice); V( D3DXCreateTexture( pd3dDevice, SurfaceWidth, SurfaceHeight, 1, D3DUSAGE_RENDERTARGET, SurfaceFormat, D3DPOOL_DEFAULT, &m_pDynamicTexture ) ); m_pDynamicTexture->GetSurfaceLevel( 0, &m_pTextureSurface ); m_bUpdateImpostor = true; m_bUseImpostor = true; // clear the surface alpha to 0 so that it does not bleed into a "blurry" background // this is possible because of the avoidance of blurring in a non-blurred texel if(SUCCEEDED(m_pRenderToSurface->BeginScene(m_pTextureSurface, NULL))) { pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0); m_pRenderToSurface->EndScene( 0 ); } #if 0 // no longer haveing shadows for clouds if(m_pShadowMapEffect) { m_pShadowMapEffect->OnResetDevice(); V( m_pShadowMapEffect->SetFloat("fFarPlane", FARPLANE_DISTANCE) ); V( m_pShadowMapEffect->SetTechnique("Shadow") ); } #endif return S_OK; }
int dxmedia_play_video(const char* filename, bool pUseSound, int canskip, int stretch) { HRESULT hr; useSound = pUseSound; ghWnd = win_get_window(); CoInitialize(NULL); if (!useSound) update_polled_stuff(); hr = RenderFileToMMStream(filename); if (FAILED(hr)) { ExitCode(); CoUninitialize(); return -1; } if (!useSound) update_polled_stuff(); hr = InitRenderToSurface(); if (FAILED(hr)) { ExitCode(); CoUninitialize(); return -1; } newWidth = vscreen->w; newHeight = vscreen->h; if ((stretch == 1) || (vscreen->w > screen->w) || (vscreen->h > screen->h)) { // If they want to stretch, or if it's bigger than the screen, then stretch float widthRatio = (float)vscreen->w / (float)screen->w; float heightRatio = (float)vscreen->h / (float)screen->h; if (widthRatio > heightRatio) { newWidth = vscreen->w / widthRatio; newHeight = vscreen->h / widthRatio; } else { newWidth = vscreen->w / heightRatio; newHeight = vscreen->h / heightRatio; } } //Now set the multimedia stream to RUN hr = g_pMMStream->SetState(STREAMSTATE_RUN); g_bAppactive = TRUE; if (FAILED(hr)) { sprintf(lastError, "Unable to play stream: 0x%08X", hr); ExitCode(); CoUninitialize(); destroy_bitmap (vscreen); return -1; } // in case we're not full screen, clear the background clear(screen); currentlyPlaying = true; gfxDriver->ClearDrawList(); BITMAP *savedBackBuffer = gfxDriver->GetMemoryBackBuffer(); gfxDriver->SetMemoryBackBuffer(screen); while ((g_bAppactive) && (!want_exit)) { while (currentlyPaused) ; next_iteration(); RenderToSurface(vscreen); //Sleep(0); if (rec_kbhit()) { int key = rec_getch(); if ((canskip == 1) && (key == 27)) break; if (canskip >= 2) break; } if ((rec_mgetbutton() >= 0) && (canskip == 3)) break; } dxmedia_abort_video(); gfxDriver->SetMemoryBackBuffer(savedBackBuffer); return 0; }