In my project (see french H.E.L.P.), I need to display a trailer at the begining of the game (with video and pefectly synchronised sound) into the irrlicht render window. I give you my way. Hope that may help Irrlicht users.
In fact, it is based on DirectShow sample code from MSDN (I don't even understand how it works in detail). Skilled DirectShow developers will probably extend the few possibilities, I suggested here after.
Important : You must create an irrlicht device. Movie is just displayed over the irrlicht viewport without transparency. And you can adjust the size and the position of the "movie render window".
INITIALISATION :
Code: Select all
// find "irrlicht render window" handler
irr::video::SExposedVideoData exposedData = driver->getExposedVideoData();
HWND hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
// init DirectShow pointers
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
IMediaSeeking * pSeek = NULL;
IVideoWindow *pVW ;
// init COM client/server
CoInitialize(NULL);
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
// get DirectShow interfaces
pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pSeek);
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVW);
// init render (passing movie file)
pGraph->RenderFile(L"trailer.avi", NULL);
// make parent
pVW->put_Owner((OAHWND)hWnd);
// Adjust "movie render window" to "irrlicht render window" dimensions
RECT grc;
GetClientRect(hWnd, &grc);
pVW->SetWindowPosition(0,0, grc.right, grc.bottom);
pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
// keep focus "irrlicht render window"
SetFocus(hWnd);
SetForegroundWindow(hWnd);
Code: Select all
// display "movie render window"
pVW->put_Visible(OATRUE);
//pVW->put_Owner((OAHWND)hWnd);
Code: Select all
// hiding "movie render window"
pVW->put_Visible(OAFALSE);
//pVW->put_Owner(NULL);
Code: Select all
// (re)start movie
pControl->Run();
Code: Select all
// stop movie
pControl->Stop();
Code: Select all
// (re)start movie
REFERENCE_TIME rtNow = 0;
pSeek->SetPositions( &rtNow, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning );
Code: Select all
// release
pVW->put_Owner(NULL);
pVW->Release();
pSeek->Release();
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
Include headers : dshow.h, mmstream.h, amstream.h, ddstream.h.
Link with libs : uuid, ole32, user32, strmiids, and .... have a guess : irrlicht !
I update this post when I have found enough time to build an easy to use c++ class for irrlicht.....But I have a "smooth first and third person" camera scene node to update and post here, before !
Xterm-in'Hate