缘起: 朝哥安排我整个游戏内播放视频的功能,那我就玩玩dshow好了
《巨人》的是xoyojank写的
第一个DirectShow程序 DirectShow播放视频环境配置:
用的是Platform SDK for Windows Server 2003 R2,安装后开始菜单如下
VS2005里面的设置
Include
Lib
小试牛刀:
写个最简单的程序爽下,见sdk文档,位置如下
项目配置:
链接Strmiids.lib和Quartz.lib
多线程调试 DLL (/MDd)
截图:
NND,截图截出来是黑的,why?
源码:
#include <dshow.h>
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return -1;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return -1;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// Build the graph. IMPORTANT: Change this string to a file on your system.
// F:\\Program Files\\NVIDIA Corporation\\SDK 9.5\\MEDIA\\textures\\video\\nvidia2.wmv
// C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Samples\\Multimedia\\DirectShow\\Media\\Video\\ruby.avi
hr = pGraph->RenderFile(L"F:\\Program Files\\NVIDIA Corporation\\SDK 9.5\\MEDIA\\textures\\video\\nvidia2.wmv", NULL);
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
return 0;
}
posted on 2008-12-22 23:52
七星重剑 阅读(1099)
评论(1) 编辑 收藏 引用 所属分类:
Game Graphics 、
IDE -- visual c++