Anderl Posted July 21, 2012 Posted July 21, 2012 Hey guys, This may not be the right place to ask what I need but I already searched on forums/Google about this problem and I didn't find anything. Also no one wants to help .__. So here we go: I'm making some test apps/games in C++ and I just wanted to render a video when the game starts but it does not seem to be working like I wanted. Here is the function: int DirectX9::renderIntro( LPCWSTR filePath, HWND hWnd ) { // declare variables IGraphBuilder* pGraph = NULL; IMediaControl* pControl = NULL; IMediaEvent* pEvent = NULL; IVideoWindow* pVidWin = NULL; // initialize COM library HRESULT hrInitialize = CoInitialize( NULL ); if( FAILED( hrInitialize ) ) { MessageBox( NULL, L"Unable to initialize COM library.", L"Warning", NULL ); return 1; } // create filter HRESULT hrFilter = CoCreateInstance ( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (VOID**) &pGraph ); if( FAILED( hrFilter ) ) { MessageBox( NULL, L"Unable to create filter to render video.", L"Warning", NULL ); return 1; } hrFilter = pGraph->QueryInterface( IID_IMediaControl, (void**)&pControl ); hrFilter = pGraph->QueryInterface( IID_IMediaEvent, (void**)&pEvent ); hrFilter = pGraph->QueryInterface( IID_IVideoWindow, (void**)&pVidWin ); pVidWin->put_Owner( (OAHWND)hWnd ); pVidWin->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS ); //pVidWin->SetWindowPosition( 0, 0, 500, 400 ); //pVidWin->put_MessageDrain( (OAHWND)hWnd ); pVidWin->put_Visible( 1 ); pVidWin->put_FullScreenMode( 1 ); // render video HRESULT hrVideo = pGraph->RenderFile( filePath, NULL ); if( SUCCEEDED( hrVideo ) ) { // run video HRESULT hrVide = pControl->Run(); if( SUCCEEDED( hrVide ) ) { HRESULT hrIntroDone = pEvent->WaitForCompletion( INFINITE, &evCode ); switch( hrIntroDone ) { case S_OK: hrVide = pControl->Stop(); exit(0); break; case E_ABORT: exit(0); break; default: exit(0); break; } } } else { MessageBox( NULL, L"Unable to load video file.", L"Warning", NULL ); switch( hrVideo ) { case S_OK: MessageBox( NULL, L"Everything ok.", L"Warning", NULL ); break; case VFW_S_AUDIO_NOT_RENDERED: MessageBox( NULL, L"Audio not rendered.", L"Warning", NULL ); break; case VFW_S_DUPLICATE_NAME: MessageBox( NULL, L"Filter duplicated name.", L"Warning", NULL ); break; case VFW_S_PARTIAL_RENDER: MessageBox( NULL, L"Stream not supported.", L"Warning", NULL ); break; case VFW_S_VIDEO_NOT_RENDERED: MessageBox( NULL, L"Some part not rendered.", L"Warning", NULL ); break; case E_ABORT: MessageBox( NULL, L"Aborted.", L"Warning", NULL ); break; case E_FAIL: MessageBox( NULL, L"Failure.", L"Warning", NULL ); break; case E_INVALIDARG: MessageBox( NULL, L"Invalid arguments", L"Warning", NULL ); break; case VFW_E_INVALID_FILE_FORMAT: MessageBox( NULL, L"File format invalid.", L"Warning", NULL ); break; case VFW_E_NOT_FOUND: MessageBox( NULL, L"File not found.", L"Warning", NULL ); break; } exit(0); } // release and free memory pControl->Release(); pEvent->Release(); pGraph->Release(); CoUninitialize(); return 0; } I call that function in the "renderStuff" function with this: // render intro char szPath[MAX_PATH]; GetFullPathName( L"movies\\GTAmovie.mpg", sizeof( szPath ), (LPWSTR)szPath, NULL ); if( !DirectX3D->renderIntro( (LPCWSTR)szPath, hWnd ) ) { exit(0); } The problem is that: The video loads in a new window but I want it in the same window... As you can see, I used "pVidWin->put_FullScreenMode( 1 )" and it didn't work Should I use other renderer? If so, what renderer should I use? Should I use VMR-9 with Windowless mode?
Anderl Posted July 23, 2012 Author Posted July 23, 2012 How did you fix it? I forgot that I have to render the movie first
MTA Team qaisjp Posted July 23, 2012 MTA Team Posted July 23, 2012 // render video HRESULT hrVideo = pGraph->RenderFile( filePath, NULL ); then what was that
Anderl Posted July 23, 2012 Author Posted July 23, 2012 I mean, I have to render the movie before set parent window. I only remembered that when I checked result of "pVidWin->put_Owner( (OAHWND)hWnd );".
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now