Jump to content
  • Advertisement

Sparhawk42

Member
  • Content Count

    114
  • Joined

  • Last visited

Community Reputation

138 Neutral

About Sparhawk42

  • Rank
    Member
  1. Hello, i try to replay a video directly under Direct3D but somehow I don't get the code working. At the moment I'am stuck with an exception outside of my own code. Maybe some one can help me fix my problem. Thanks a lot guys. Code and example videos can be downloaded here Here is my code: class VideoAllocatorPresenter : public IVMRSurfaceAllocator9, public IVMRImagePresenter9 { public: STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { dbglog() << "QueryInterface " << std::endl; *ppv = this; return S_OK; //GetOwner()->QueryInterface(riid,ppv); /* ppv = NULL; return E_NOINTERFACE;*/ }; STDMETHODIMP_(ULONG) AddRef() { dbglog() << "AddRef" << std::endl; return 1 ;//GetOwner()->AddRef(); }; STDMETHODIMP_(ULONG) Release() { dbglog() << "Release" << std::endl; return 1;//GetOwner()->Release(); }; VideoAllocatorPresenter( IDirect3DDevice9* dev ):d3dDevice_(dev) {}; virtual ~VideoAllocatorPresenter() {}; /*virtual HRESULT */STDMETHODIMP AdviseNotify( IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify ) { dbglog() << "AdviseNotify " << lpIVMRSurfAllocNotify << std::endl; allocNotify_ = lpIVMRSurfAllocNotify; return S_OK; }; /*virtual HRESULT */STDMETHODIMP GetSurface( DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface ) { dbglog() << "GetSurface " << SurfaceIndex << std::endl; SurfaceIndex = 0; *lplpSurface = &surfaces_[SurfaceIndex]; dbglog() << "GetSurface done " << *lplpSurface << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP InitializeDevice( DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers ) { dbglog() << "InitializeDevice " << allocNotify_ << std::endl; surfaces_ = (IDirect3DSurface9*) malloc(sizeof( IDirect3DSurface9) * (*lpNumBuffers) ); IDirect3D9* iD3D9; D3DDEVICE_CREATION_PARAMETERS params; DXUTGetD3DDevice()->GetCreationParameters(&params); DXUTGetD3DDevice()->GetDirect3D( &iD3D9 ); HMONITOR hMonitor = iD3D9->GetAdapterMonitor( params.AdapterOrdinal ); HRESULT hr = allocNotify_->SetD3DDevice( d3dDevice_, hMonitor ); if( FAILED( hr ) ) { dbglog() << "SetD3DDevice: " << hr << std::endl; } //lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface; hr = allocNotify_->AllocateSurfaceHelper( lpAllocInfo, lpNumBuffers, &surfaces_ ); if( FAILED( hr ) ) { dbglog() << "AllocateSurfaceHelper: " << hr << std::endl; } dbglog() << " number buffers: " << (*lpNumBuffers) << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP TerminateDevice( DWORD_PTR dwID ) { dbglog() << "TerminateDevice" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP PresentImage( DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo ) { dbglog() << "PresentImage" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP StartPresenting( DWORD_PTR dwUserID ) { dbglog() << "StartPresenting" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP StopPresenting( DWORD_PTR dwUserID ) { dbglog() << "StopPresenting" << std::endl; return S_OK; }; private: IVMRSurfaceAllocatorNotify9* allocNotify_; IDirect3DSurface9* surfaces_; IDirect3DDevice9* d3dDevice_; }; IMediaControl *m_pMediaControl; std::string getMediaError(HRESULT hr) { if (FAILED(hr)) { TCHAR szErr[MAX_ERROR_TEXT_LEN]; DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN); std::stringstream result; if (res == 0) { result << "Unknown Error: " << hr << " "; } else { result << szErr; } return result.str(); } return ""; } void initVideoRendering() { CoInitializeEx( NULL, 0 ); static VideoAllocatorPresenter allocPresent( DXUTGetD3DDevice() ); //create graph manager dbglog() << "Step 0" << std::endl; IGraphBuilder *m_pGraph; HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&m_pGraph); if FAILED( hr ) dbglog() << "failure 1 " << getMediaError( hr ) << std::endl; // BUILD the VMR9 IBaseFilter* m_pVMRBaseFilter; hr = CoCreateInstance(CLSID_VideoMixingRenderer9, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &m_pVMRBaseFilter); if FAILED( hr ) dbglog() << "failure 2 " << getMediaError( hr ) << std::endl; // ADD the VMR9 to the graph hr = m_pGraph->AddFilter(m_pVMRBaseFilter, L"VMR9"); if FAILED( hr ) dbglog() << "failure 3 " << getMediaError( hr ) << std::endl; IVMRFilterConfig9* m_pVMRFilterConfig; hr = m_pVMRBaseFilter->QueryInterface(IID_IVMRFilterConfig9, (void**) &m_pVMRFilterConfig); if FAILED( hr ) dbglog() << "failure 4 " << getMediaError( hr ) << std::endl; dbglog() << "Step 1" << std::endl; //m_pVMRFilterConfig->SetNumberOfStreams(2); hr = m_pVMRFilterConfig->SetRenderingMode(VMR9Mode_Renderless); if FAILED( hr ) dbglog() << "failure 5 " << getMediaError( hr ) << std::endl; IVMRSurfaceAllocatorNotify9 *surfaceNotify; hr = m_pVMRBaseFilter->QueryInterface(IID_IVMRSurfaceAllocatorNotify9, (void**) &surfaceNotify); if FAILED( hr ) dbglog() << "failure 6 " << getMediaError( hr ) << std::endl; D3DDEVICE_CREATION_PARAMETERS params; DXUTGetD3DDevice()->GetCreationParameters(&params); // Get parameters of D3D IDirect3D9* iD3D9; DXUTGetD3DDevice()->GetDirect3D( &iD3D9 ); HMONITOR hMonitor = iD3D9->GetAdapterMonitor( params.AdapterOrdinal ); hr = surfaceNotify->SetD3DDevice( DXUTGetD3DDevice(), hMonitor ); if FAILED( hr ) dbglog() << "failure 7 " << getMediaError( hr ) << std::endl; hr = surfaceNotify->AdviseSurfaceAllocator( 42,static_cast<IVMRSurfaceAllocator9*>(&allocPresent) ); if FAILED( hr ) dbglog() << "failure 8 " << getMediaError( hr ) << std::endl; hr = allocPresent.AdviseNotify( surfaceNotify ); if FAILED( hr ) dbglog() << "failure 9 " << getMediaError( hr ) << std::endl; //hr = m_pGraph->RenderFile(L"test_cinepak.avi",L""); hr = m_pGraph->RenderFile(L"test_divx6.avi",L""); if FAILED( hr ) dbglog() << "failure 10 " << getMediaError( hr ) << std::endl; hr = m_pGraph->QueryInterface(IID_IMediaControl, (void**)&m_pMediaControl); if FAILED( hr ) dbglog() << "failure 11 " << getMediaError( hr ) << std::endl; IMediaEvent *m_pMediaEvent; dbglog() << "Step 2" << std::endl; hr = m_pGraph->QueryInterface(IID_IMediaEvent, (void**)&m_pMediaEvent); if FAILED( hr ) dbglog() << "failure 12 " << getMediaError( hr ) << std::endl; hr = m_pMediaControl->Run(); if FAILED( hr ) dbglog() << "failure 13 " << getMediaError( hr ) << std::endl; long evCode; m_pMediaEvent->WaitForCompletion(INFINITE, &evCode ); dbglog() << "Step done" << std::endl; } //-------------------------------------------------------------------------------------- // Rejects any devices that aren't acceptable by returning false //-------------------------------------------------------------------------------------- bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext ) { // Typically want to skip backbuffer formats that don't support alpha blending IDirect3D9* pD3D = DXUTGetD3DObject(); if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) ) return false; return true; } //-------------------------------------------------------------------------------------- // Before a device is created, modify the device settings as needed //-------------------------------------------------------------------------------------- bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext ) { return true; } //-------------------------------------------------------------------------------------- // Create any D3DPOOL_MANAGED resources here //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { return S_OK; } //-------------------------------------------------------------------------------------- // Create any D3DPOOL_DEFAULT resources here //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { return S_OK; } //-------------------------------------------------------------------------------------- // Handle updates to the scene //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { } //-------------------------------------------------------------------------------------- // Render the scene //-------------------------------------------------------------------------------------- void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { HRESULT hr; static bool firstCall = true; if( firstCall ) { firstCall = false; initVideoRendering(); } // Clear the render target and the zbuffer V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0) ); // Render the scene if( SUCCEEDED( pd3dDevice->BeginScene() ) ) { V( pd3dDevice->EndScene() ); } } //-------------------------------------------------------------------------------------- // Handle messages to the application //-------------------------------------------------------------------------------------- LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext ) { return 0; } //-------------------------------------------------------------------------------------- // Release resources created in the OnResetDevice callback here //-------------------------------------------------------------------------------------- void CALLBACK OnLostDevice( void* pUserContext ) { } //-------------------------------------------------------------------------------------- // Release resources created in the OnCreateDevice callback here //-------------------------------------------------------------------------------------- void CALLBACK OnDestroyDevice( void* pUserContext ) { } //-------------------------------------------------------------------------------------- // Initialize everything and go into a render loop //-------------------------------------------------------------------------------------- INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // Set the callback functions DXUTSetCallbackDeviceCreated( OnCreateDevice ); DXUTSetCallbackDeviceReset( OnResetDevice ); DXUTSetCallbackDeviceLost( OnLostDevice ); DXUTSetCallbackDeviceDestroyed( OnDestroyDevice ); DXUTSetCallbackMsgProc( MsgProc ); DXUTSetCallbackFrameRender( OnFrameRender ); DXUTSetCallbackFrameMove( OnFrameMove ); // TODO: Perform any application-level initialization here // Initialize DXUT and create the desired Win32 window and Direct3D device for the application DXUTInit( true, true, true ); // Parse the command line, handle the default hotkeys, and show msgboxes DXUTSetCursorSettings( true, true ); // Show the cursor and clip it when in full screen DXUTCreateWindow( L"VideoTutorial" ); DXUTCreateDevice( D3DADAPTER_DEFAULT, true, 640, 480, IsDeviceAcceptable, ModifyDeviceSettings ); // Start the render loop DXUTMainLoop(); // TODO: Perform any application-level cleanup here return DXUTGetExitCode(); } And here my Debug-Output: 25.5.2007-12:6:6 Step 0 Step 1 AddRef QueryInterface QueryInterface QueryInterface AdviseNotify 00F90250 InitializeDevice 00F90250 number buffers: 1 GetSurface 0 GetSurface done 001B2D80 Step 2 GetSurface 43056640 GetSurface done 001B2D80
  2. Hello, I try to get a VideoRenderer for Direct3D Running and just tried this article can anybody tell me what hides behind m_scene? On times he calls a init function with Direct3Device and an other time a DrawScene-funtion with also a device and a texture. Or has anybody else a really good tutorial on this (all msdn pages I've found so far are some how lacking in getting the whole picture to me...each just describes on part of the whole problem...but when you try to get them work together it just doesn't work) By the way all I want is to replay an Avi-Video on a Direct3DSurface (no texture, nothing fancy, just a simple intro video...this should not be so hard?) Thanks a lot.
  3. Sparhawk42

    Designing Movement On A Board Game

    Why don't you use a straight forward design: a board which has just fields and has a function to determine if two fields are adjacent, which should be easy enough be determined by some way of circle function, as all fields you can move too lie on a circle around your field with a distance of 1 field...(if you have the centre point of each field as you draw it, that is it)...
  4. Thanks a lot now it is working fine!!!
  5. I've a small problem with rendering a Mesh to a surface. My Codes works just fine, when I activate the Direct3D_Debug-Mode: But when I activate the retail mode something doesn't work as my RenderTarget now fills the whole window: Here you can download my whole Code And here the essence of my onFrameRender-Method (not yet really tidy...): void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { HRESULT hr; // Clear the render target and the zbuffer V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0) ); // Render the scene if( SUCCEEDED( pd3dDevice->BeginScene() ) ) { IDirect3DSurface9* surface_ = NULL; IDirect3DSurface9* origTarget_ = NULL; pd3dDevice->GetRenderTarget( 0, &origTarget_ ); pd3dDevice->CreateRenderTarget( 320, 240, D3DFMT_X8R8G8B8, origTarget_->MultiSampleType, origTarget_->MultiSampleQuality,false, &surface_, NULL ); RECT DstRect; // scale pciture for actual resolution in Position and size DstRect.left = 0; DstRect.top = 0; DstRect.right = 320; DstRect.bottom = 240; pd3dDevice->SetRenderTarget( 0, surface_ ); pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,30), 1, 0 ); D3DXMATRIXA16 trans; D3DXMatrixRotationY( &trans, timeGetTime()/5000.0f ); D3DXMATRIXA16 trans2; D3DXMatrixRotationZ( &trans2, timeGetTime()/5000.0f ); trans *= trans2; pd3dDevice->SetTransform( D3DTS_WORLD, &trans ); D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f ); D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); D3DXMATRIXA16 matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); pd3dDevice->SetRenderState( D3DRS_AMBIENT, D3DXCOLOR( 1.0, 1.0, 1.0, 1.0 ) ); static D3DMesh* mesh = new D3DMesh( "tiger.x" ); static bool loaded = false; if (!loaded ) { mesh->loadFromFile( pd3dDevice ); loaded = true; } mesh->draw( pd3dDevice ); DstRect.left = 40; DstRect.top = 30; DstRect.right = 360; DstRect.bottom = 270; pd3dDevice->SetRenderTarget( 0, origTarget_ ); IDirect3DSurface9* backBuffer = NULL; if( !FAILED( pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer ) ) ) { pd3dDevice->StretchRect( surface_, NULL, backBuffer, &DstRect, D3DTEXF_NONE ); } if( backBuffer ) backBuffer->Release(); if( surface_ ) surface_->Release(); if( origTarget_ ) origTarget_->Release(); V( pd3dDevice->EndScene() ); } } Thanks for any help!!! I don't really know what goes wrong...especially as does code works fine in Debug-modus... and yes I know Rendering via a texture would be much faster, but this just my first try and I want to use this code mainly for something like a civiliopedia, where only one element is shown at a given time.
  6. Sparhawk42

    autoplay menu authoring tools

    I think most of the time they just writing them for themself, as those are just really small programs...
  7. Sparhawk42

    2d game synchronising

    That is why most games just have on loop overall objects, draw everythin to hidden surface and than when all objects are rendered bring this surface to the display. If you want to know more about mechanism to thread synchronisation read the following thread, there you find some stuff anf if you need more just ask: Win32 Threads
  8. Sparhawk42

    Problem Rendering Mesh to Surface

    No, I don't want to render to a texture... all I want is a second surface, exactly like the backbuffer, to which I can render and then, when done copy the content of this surface to the backbuffer for displaying, just like my code shows you. A texture seems much to complicated for this, as I than need a vertexbuffer to draw this texture...
  9. Hello, I want to render a mesh to surface (for something like a Status display of the actual viewd Spaceship) What I'am doing is the following: IDirect3DSurface9* surface_; DXUTGetD3DDevice()->CreateOffscreenPlainSurface( 200, 150, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface_, NULL ); RECT DstRect; DstRect.left = 0; DstRect.top = 0; DstRect.right = 200; DstRect.bottom = 150; DXUTGetD3DDevice()->ColorFill( surface_, &DstRect, D3DCOLOR_XRGB(0, 0, 30) ); DXUTGetD3DDevice()->SetRenderTarget( 0, surface_ ); // rendering of the mesh DstRect.left = 400; DstRect.top = 400; DstRect.right = 600; DstRect.bottom = 550; IDirect3DSurface9* backBuffer = NULL; if( !FAILED( DXUTGetD3DDevice()->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer ) ) ) { DXUTGetD3DDevice()->StretchRect( surface_, NULL, backBuffer, &DstRect, D3DTEXF_NONE ); } It works aso far as I see the surface and also my mesh, but my mesh is not placed on the surface, so what do I wrong? Thanks a lot!
  10. Sparhawk42

    Help with text adventure in C++

    I think one problem is that you doesn't leave your loops, when you win your fight, as your only using life as loop-criterion, and your life is still greater 0 after winning the fight... The way you thought of, I think is, to put an return in each method after the corresponding adventure::end call like dragonfight::end The same goes for your inner loop here you just checks for the live of your monster and of your hero...so long as your monster stays alive you won't leave the loop... I hope this helps... I would have implemented more of a loop of this way while IamLife and MonsterALife { IAmLife = life > 0; MonsterAlife = drlife > 0; } If IamLife { cout << "You Won"; } If MonsterALife{ cout << "you lost";} I think you get the point.
  11. Hello, i want to access some files from my applet in a browser. I have signed my applet: 137 Sun Dec 11 13:01:28 GMT+01:00 2005 META-INF/MANIFEST.MF 258 Sun Dec 11 13:01:30 GMT+01:00 2005 META-INF/BORG.SF 1044 Sun Dec 11 13:01:30 GMT+01:00 2005 META-INF/BORG.DSA 0 Sun Dec 11 12:53:38 GMT+01:00 2005 META-INF/ sm 3722 Sun Dec 04 11:05:34 GMT+01:00 2005 browser.class s = signature was verified m = entry is listed in manifest k = at least one certificate was found in keystore i = at least one certificate was found in identity scope jar verified. Warning: This jar contains entries whose signer certificate will expire within s ix months. Re-run with the -verbose and -certs options for more details. But every time I call it: <APPLET code="Browser.class" archive="Browser.jar"> </APPLET> I still get an Exception: java.security.AccessControlException: access denied (java.io.FilePermission H:\Projects\meine_HP\borgsoft\index.html read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkRead(Unknown Source) at java.io.File.isDirectory(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.initializeHeaders(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.getHeaderField(Unknown Source) at sun.net.www.URLConnection.getContentType(Unknown Source) at javax.swing.JEditorPane.getStream(Unknown Source) at javax.swing.JEditorPane.setPage(Unknown Source) at javax.swing.JEditorPane.setPage(Unknown Source) at javax.swing.JEditorPane.<init>(Unknown Source) at Browser.<init>(Browser.java:43) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) So what have I to do, to access files from my browser via an applet? Thanks for your help!
  12. Hello I want to render a Video to Direct3D-Surface: Here is what I do: class VideoAllocatorPresenter : public IVMRSurfaceAllocator9, public IVMRImagePresenter9 { public: STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { dbglog() << "QueryInterface " << std::endl; *ppv = this; return S_OK; //GetOwner()->QueryInterface(riid,ppv); ppv = NULL; return E_NOINTERFACE; }; STDMETHODIMP_(ULONG) AddRef() { dbglog() << "AddRef" << std::endl; return 1 ;//GetOwner()->AddRef(); }; STDMETHODIMP_(ULONG) Release() { dbglog() << "Release" << std::endl; return 1;//GetOwner()->Release(); }; VideoAllocatorPresenter() {}; virtual ~VideoAllocatorPresenter() {}; /*virtual HRESULT */STDMETHODIMP AdviseNotify( IVMRSurfaceAllocatorNotify9* lpIVMRSurfAllocNotify ) { dbglog() << "AdviseNotify" << std::endl; allocNotify_ = lpIVMRSurfAllocNotify; return S_OK; }; /*virtual HRESULT */STDMETHODIMP GetSurface( DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface ) { dbglog() << "GetSurface " << SurfaceIndex << std::endl; *lplpSurface = &surfaces_[SurfaceIndex]; dbglog() << "GetSurface done" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP InitializeDevice( DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers ) { dbglog() << "InitializeDevice" << std::endl; surfaces_ = (IDirect3DSurface9*) malloc(sizeof( IDirect3DSurface9) * (*lpNumBuffers) ); if( FAILED( allocNotify_->AllocateSurfaceHelper( lpAllocInfo, lpNumBuffers, &surfaces_ ) ) ) { dbglog() << "failure" << std::endl; } dbglog() << " number buffers: " << (*lpNumBuffers) << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP TerminateDevice( DWORD_PTR dwID ) { dbglog() << "TerminateDevice" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP PresentImage( DWORD_PTR dwUserID, VMR9PresentationInfo* lpPresInfo ) { dbglog() << "PresentImage" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP StartPresenting( DWORD_PTR dwUserID ) { dbglog() << "StartPresenting" << std::endl; return S_OK; }; /*virtual HRESULT */STDMETHODIMP StopPresenting( DWORD_PTR dwUserID ) { dbglog() << "StopPresenting" << std::endl; return S_OK; }; private: IVMRSurfaceAllocatorNotify9* allocNotify_; IDirect3DSurface9* surfaces_; }; IMediaControl *m_pMediaControl; CoInitializeEx( NULL, 0 ); static VideoAllocatorPresenter allocPresent; //create graph manager IGraphBuilder *m_pGraph; HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&m_pGraph); if FAILED( hr ) dbglog() << "failure 1" << std::endl; // BUILD the VMR9 IBaseFilter* m_pVMRBaseFilter; hr = CoCreateInstance(CLSID_VideoMixingRenderer9, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &m_pVMRBaseFilter); if FAILED( hr ) dbglog() << "failure 2" << std::endl; // ADD the VMR9 to the graph hr = m_pGraph->AddFilter(m_pVMRBaseFilter, L"VMR9"); if FAILED( hr ) dbglog() << "failure 3" << std::endl; IVMRFilterConfig9* m_pVMRFilterConfig; hr = m_pVMRBaseFilter->QueryInterface(IID_IVMRFilterConfig9, (void**) &m_pVMRFilterConfig); if FAILED( hr ) dbglog() << "failure 4" << std::endl; //m_pVMRFilterConfig->SetNumberOfStreams(2); hr = m_pVMRFilterConfig->SetRenderingMode(VMR9Mode_Renderless); if FAILED( hr ) dbglog() << "failure 5" << std::endl; IVMRSurfaceAllocatorNotify9 *surfaceNotify; hr = m_pVMRBaseFilter->QueryInterface(IID_IVMRSurfaceAllocatorNotify9, (void**) &surfaceNotify); if FAILED( hr ) dbglog() << "failure 6" << std::endl; D3DDEVICE_CREATION_PARAMETERS params; DXUTGetD3DDevice()->GetCreationParameters(&params); // Get parameters of D3D IDirect3D9* iD3D9; DXUTGetD3DDevice()->GetDirect3D( &iD3D9 ); HMONITOR hMonitor = iD3D9->GetAdapterMonitor( params.AdapterOrdinal ); //hr = surfaceNotify->SetD3DDevice( DXUTGetD3DDevice(), hMonitor ); if FAILED( hr ) dbglog() << "failure 7" << std::endl; hr = surfaceNotify->AdviseSurfaceAllocator( 42,static_cast<IVMRSurfaceAllocator9*>(&allocPresent) ); if FAILED( hr ) dbglog() << "failure 8 " << hr << " " << S_OK << std::endl; hr = allocPresent.AdviseNotify( surfaceNotify ); if FAILED( hr ) dbglog() << "failure 9" << std::endl; hr = m_pGraph->RenderFile(L"video/intro.avi",L""); if FAILED( hr ) dbglog() << "failure 10" << std::endl; hr = m_pGraph->QueryInterface(IID_IMediaControl, (void**)&m_pMediaControl); if FAILED( hr ) dbglog() << "failure 11" << std::endl; IMediaEvent *m_pMediaEvent; hr = m_pGraph->QueryInterface(IID_IMediaEvent, (void**)&m_pMediaEvent); if FAILED( hr ) dbglog() << "failure 12" << std::endl; hr = m_pMediaControl->Run(); if FAILED( hr ) dbglog() << "failure 13" << std::endl; //long evCode; //m_pMediaEvent->WaitForCompletion(INFINITE, &evCode ); And here is the produced logging output 11.11.2005-11:50:44 AddRef QueryInterface QueryInterface QueryInterface AdviseNotify InitializeDevice failure number buffers: 1 GetSurface 0 GetSurface done So can anybody tell me why my call to AllocateSurfaceHelper fails? allocNotify_->AllocateSurfaceHelper( lpAllocInfo, lpNumBuffers, &surfaces_ ) ) Thanks a lot.
  13. Sparhawk42

    [java] Applet Security Problem

    And how do I sign an applet?
  14. I've tried the correct order but than I can't even query the IVMRSurfaceAllocatorNotify9
  15. Finally I have found, where my code fails, but I don't see why: hr = surfaceNotify->AdviseSurfaceAllocator( 42,static_cast<IVMRSurfaceAllocator9*>(&allocPresent) ); if FAILED( hr ) dbglog() << "failure 8 " << hr << std::endl; Produces the following output in my logfile: failure 8 -2147467262 What do I miss? Why does this call fail?
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!