随笔 - 505  文章 - 1034  trackbacks - 0
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 894804
  • 排名 - 14

最新随笔

最新评论

阅读排行榜

评论排行榜

该是自己动手来写的时候了,最简单的代码能突出重点。
自己建个win32项目,选择空项目。

CMovie类来自于
Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\VMR9\VMRPlayer\
中的vcdplyer.h,做了一点修改。

程序主体代码用了Direct3D Tutorial 3: Using Matrices的部分代码。

截图:
        播放

        不播放


项目配置:

#include <streams.h>
位于Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses

链接:只有这三个d3d9.lib Strmiids.lib Quartz.lib

使用 Unicode 字符集
多线程调试 DLL (/MDd)


核心代码:

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
    
// Register the window class
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L0L
        GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
        L
"D3D Tutorial", NULL };
    RegisterClassEx( 
&wc );

    
// Create the application's window
    g_hwnd = CreateWindow( L"D3D Tutorial", L"DShow CMovie Test"
        WS_OVERLAPPEDWINDOW, 
100100300300,
        NULL, NULL, wc.hInstance, NULL );

    g_pMovie 
= new CMovie(g_hwnd);
    g_pMovie
->OpenMovie(L"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Samples\\Multimedia\\DirectShow\\Media\\Video\\ruby.avi"
);
    g_pMovie
->
PlayMovie();

    
// Initialize Direct3D
    if( SUCCEEDED( InitD3D( g_hwnd ) ) )
    { 
        
// Show the window
        ShowWindow( g_hwnd, SW_SHOWDEFAULT );
        UpdateWindow( g_hwnd );

        
// Enter the message loop
        MSG msg; 
        ZeroMemory(
&msg, sizeof(msg));
        
while(msg.message != WM_QUIT)
        {
            
if( PeekMessage( &msg, NULL, 00, PM_REMOVE ) )
            {
                TranslateMessage( 
&msg );
                DispatchMessage( 
&msg );
            }
            
else
            {
                Render();
            }
        }
    }

    UnregisterClass( L
"D3D Tutorial", wc.hInstance );
    
return 0;
}
视频播放时d3d不渲染,不播放的时候才渲染
VOID Render()
{

    
if(g_pMovie->IsPlaying())
    {
        RECT rc;
        ::GetClientRect(g_hwnd, 
&
rc);
        g_pMovie
->PutMoviePosition(rc.left, rc.top, rc.right - rc.left, rc.bottom -
 rc.top);
        g_pMovie
->
RepaintVideo(g_hwnd, ::GetDC(g_hwnd));
    }

    
else
    {
        
if( NULL == g_pd3dDevice )
            
return;

        
// Clear the backbuffer to a blue color
        g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f0 );

        
// Begin the scene
        if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
        {
            
// Rendering of scene objects can happen here
            
// End the scene
            g_pd3dDevice->EndScene();
        }

        
// Present the backbuffer contents to the display
        g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
    }
}

代码下载:
         dshow.cmovie.rar
Reference:
         DirectShow播放视频
posted on 2008-12-24 00:25 七星重剑 阅读(1342) 评论(0)  编辑 收藏 引用 所属分类: Game GraphicsIDE -- visual c++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理