Jump to content
  • Advertisement
Sign in to follow this  
MrChristianLaws

DirectShow and Direct3D 9 - I'm going NUTS!!!

This topic is 2762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello peeps,

I've tried to find something about rendering videos to Direct3D 9 surfaces, but everything that's ever been there has gone, all that's left are USELESS code snippets. Now I'm trying to alter this function that renders to a window:


extern "C" DLLFUNCTION bool IDIRECTX::PlayVideo(WCHAR* name)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;

HRESULT hr = CoInitialize(NULL);

if (FAILED(hr))
{
return false;
}

hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
return false;
}

hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
hr = pGraph->RenderFile(name, NULL);

if (SUCCEEDED(hr))
{
hr = pControl->Run();
if (SUCCEEDED(hr))
{
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
}
}

pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();

return true;
}




What do I have to change to get it to render onto a Direct3D 9 surface?

Thanks for your help!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by MrChristianLaws
I've tried to find something about rendering videos to Direct3D 9 surfaces, but everything that's ever been there has gone, all that's left are USELESS code snippets.
Have you looked at the NVSDK (9)? If memory serves, the demo is "VideoFilter" or something like that (peraphs "Video Effects"). It renders files to D3D9 textures with some shaders. The code is surprisingly compact and encapsulated in an object.

That function you post won't likely work with minor modification (if memory serves) as you need to build the graph yourself using the DSToD3DTex9 (or whatever you'll call it) filter as the output filter at the end of the chain.

Share this post


Link to post
Share on other sites
Quote:
Original post by Krohm
Quote:
Original post by MrChristianLaws
I've tried to find something about rendering videos to Direct3D 9 surfaces, but everything that's ever been there has gone, all that's left are USELESS code snippets.
Have you looked at the NVSDK (9)? If memory serves, the demo is "VideoFilter" or something like that (peraphs "Video Effects"). It renders files to D3D9 textures with some shaders. The code is surprisingly compact and encapsulated in an object.


Thanks for that, I'll have a look. Unfortunately, objects are often very difficult to 'dismember' and I strongly dislike using other people's 'libraries', I love piecing together my own stuff. On the other hand, if the code is compact as you say, it might be quite easy to extract what I need, thanks heaps for that!

Quote:
Original post by Krohm
That function you post won't likely work with minor modification (if memory serves) as you need to build the graph yourself using the DSToD3DTex9 (or whatever you'll call it) filter as the output filter at the end of the chain.


Yeah, I gathered that it'll require some serious tweaking, I intend to use the VMR9 filter. It would be a lot easier if you could still find the old "Texture3D" DirectShow sample, but it's gone.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!