dsdxlibrary-codemother Mailing List for DSDX Library (Page 2)
Status: Alpha
Brought to you by:
jtennant
You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(38) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <jte...@us...> - 2010-07-22 20:03:31
|
Revision: 13
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=13&view=rev
Author: jtennant
Date: 2010-07-22 20:03:25 +0000 (Thu, 22 Jul 2010)
Log Message:
-----------
Updated interface reference docs to use tables.
Modified Paths:
--------------
Documentation/dsdx_doc_reference_interfaces_idsdxaudiorenderer.txt
Documentation/dsdx_doc_reference_interfaces_idsdxbase.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer10.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer11.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer9.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderergeneric.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-22 18:59:33
|
Revision: 12
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=12&view=rev
Author: jtennant
Date: 2010-07-22 18:59:26 +0000 (Thu, 22 Jul 2010)
Log Message:
-----------
Breaking documentation into many files which can be loaded by a single javascripted html file--much like the msdn online library.
Added Paths:
-----------
Documentation/
Documentation/dsdx_doc_about.txt
Documentation/dsdx_doc_appendix.txt
Documentation/dsdx_doc_intro.txt
Documentation/dsdx_doc_reference.txt
Documentation/dsdx_doc_reference_enum.txt
Documentation/dsdx_doc_reference_functions.txt
Documentation/dsdx_doc_reference_guids.txt
Documentation/dsdx_doc_reference_interfaces.txt
Documentation/dsdx_doc_reference_interfaces_idsdxaudiorenderer.txt
Documentation/dsdx_doc_reference_interfaces_idsdxbase.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer10.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer11.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderer9.txt
Documentation/dsdx_doc_reference_interfaces_idsdxvideorenderergeneric.txt
Documentation/dsdx_doc_reference_structures.txt
Documentation/dsdx_doc_reference_supportaudio.txt
Documentation/dsdx_doc_reference_supportvideo.txt
Documentation/dsdx_doc_samples.txt
Documentation/dsdx_doc_using.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-22 05:27:09
|
Revision: 11
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=11&view=rev
Author: jtennant
Date: 2010-07-22 05:27:03 +0000 (Thu, 22 Jul 2010)
Log Message:
-----------
Fleshing out much of the reference pages for the documentation. The interfaces are covered, though their methods do not have their own definition pages yet. There's a need to make the docs available online and offline. Perhaps I'll write them in html instead of pdf.
Modified Paths:
--------------
dsdx_documentation.wps
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-21 19:14:47
|
Revision: 10
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=10&view=rev
Author: jtennant
Date: 2010-07-21 19:14:41 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Sketched out the documentation's skeleton, with some preliminary paragraphs in the earlier docs. The next focus will be on the reference pages for the interfaces, structures, enums, consts and GUIDs, and coclass interfaces supported.
Modified Paths:
--------------
dsdx_documentation.wps
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-21 03:45:50
|
Revision: 9
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=9&view=rev
Author: jtennant
Date: 2010-07-21 03:45:42 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Adding preliminary documentation outline in Microsoft Works format. Final format will be pdf.
Added Paths:
-----------
dsdx_documentation.wps
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-20 05:43:25
|
Revision: 8
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=8&view=rev
Author: jtennant
Date: 2010-07-20 05:43:19 +0000 (Tue, 20 Jul 2010)
Log Message:
-----------
Updated a few dx9 tests. Created a dx11 test. Use '_main11.cpp' instead of '_main.cpp', and 'demo shapes11.cpp' instead of 'demo shapes.cpp'. Fixed dx11 part of video renderer.
Modified Paths:
--------------
ClientTestExe/_main.cpp
ClientTestExe/demo shapes.cpp
ClientTestExe/demo shapes.h
VideoRendererDll/CDSDXVideoRenderer.cpp
Added Paths:
-----------
ClientTestExe/HPCounter.h
ClientTestExe/_main11.cpp
ClientTestExe/demo shapes11.cpp
ClientTestExe/demo shapes11.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-18 10:48:20
|
Revision: 7
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=7&view=rev
Author: jtennant
Date: 2010-07-18 10:48:14 +0000 (Sun, 18 Jul 2010)
Log Message:
-----------
Updated ClientTestExe demo shapes to descend from a standard DXTestRender::DXTestRenderObject, abstracting drawing etc. from main program. This lends to easier exchanging between directx versions.
Modified Paths:
--------------
ClientTestExe/_main.cpp
ClientTestExe/demo shapes.cpp
ClientTestExe/demo shapes.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-17 05:34:36
|
Revision: 6
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=6&view=rev
Author: jtennant
Date: 2010-07-17 05:34:30 +0000 (Sat, 17 Jul 2010)
Log Message:
-----------
Updated ClientTestExe to use simpler test initializers and renderers, so that moving to dx10 and dx11 requires minimal adjustment. Hmm, ended up removing std.fx alot faster than I thought.
Modified Paths:
--------------
ClientTestExe/_main.cpp
ClientTestExe/demo shapes.cpp
ClientTestExe/demo shapes.h
Added Paths:
-----------
ClientTestExe/DXTestD3D.h
ClientTestExe/DXTestRender.h
ClientTestExe/DXTestSound.h
ClientTestExe/DXTestWindow.h
Removed Paths:
-------------
ClientTestExe/SmartRef.h
ClientTestExe/jsl_DxDevice.cpp
ClientTestExe/jsl_DxDevice.h
ClientTestExe/jsl_SwapChain.cpp
ClientTestExe/jsl_SwapChain.h
ClientTestExe/jsl_Window.cpp
ClientTestExe/jsl_Window.h
ClientTestExe/std.fx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-17 04:53:42
|
Revision: 5
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=5&view=rev
Author: jtennant
Date: 2010-07-17 04:53:36 +0000 (Sat, 17 Jul 2010)
Log Message:
-----------
Somehow missed uploading this effect file for the client test. This will soon be replaced anyways...
Added Paths:
-----------
ClientTestExe/std.fx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-17 04:47:54
|
Revision: 4
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=4&view=rev
Author: jtennant
Date: 2010-07-17 04:47:48 +0000 (Sat, 17 Jul 2010)
Log Message:
-----------
Fixed some dx9 breaks, switched over to IDirect3DDevice9::StretchRect() instead of UpdateTexture(). Updated the client test to reflect changes.
Modified Paths:
--------------
ClientTestExe/_main.cpp
VideoRendererDll/CDSDXVideoRenderer.cpp
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-17 01:17:01
|
Revision: 3
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=3&view=rev
Author: jtennant
Date: 2010-07-17 01:13:39 +0000 (Sat, 17 Jul 2010)
Log Message:
-----------
Updated interfaces on video renderer, supporting more dx10 and dx11 functionality. These are breaking changes.
Modified Paths:
--------------
ClientTestExe/IDSDXVideoRenderer.h
HelperLib/IDSDXVideoRenderer.h
VideoRendererDll/CDSDXVideoRenderer.cpp
VideoRendererDll/CDSDXVideoRenderer.h
VideoRendererDll/IDSDXVideoRenderer.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jte...@us...> - 2010-07-16 16:40:48
|
Revision: 2
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=2&view=rev
Author: jtennant
Date: 2010-07-16 16:40:40 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
Adding initial files to folders. Will need to consolidate duplicate files to a common directory, ie. root.
Added Paths:
-----------
AudioRendererDll/CDSDXAudioRenderer.cpp
AudioRendererDll/CDSDXAudioRenderer.h
AudioRendererDll/CDSDXAudioRendererFactory.cpp
AudioRendererDll/CDSDXAudioRendererFactory.h
AudioRendererDll/DSDXAudioRendererDLLGlobals.h
AudioRendererDll/DSDXAudioRendererServer.cpp
AudioRendererDll/DSDXAudioRendererServer.def
AudioRendererDll/IDSDXAudioRenderer.h
AudioRendererDll/smartptr.h
ClientTestExe/DSDXDemo.h
ClientTestExe/DSDXHelper.h
ClientTestExe/IDSDXAudioRenderer.h
ClientTestExe/IDSDXVideoRenderer.h
ClientTestExe/SmartRef.h
ClientTestExe/_main.cpp
ClientTestExe/demo shapes.cpp
ClientTestExe/demo shapes.h
ClientTestExe/jsl_DxDevice.cpp
ClientTestExe/jsl_DxDevice.h
ClientTestExe/jsl_SwapChain.cpp
ClientTestExe/jsl_SwapChain.h
ClientTestExe/jsl_Window.cpp
ClientTestExe/jsl_Window.h
ClientTestExe/smartptr.h
HelperLib/DSDXHelper.cpp
HelperLib/DSDXHelper.h
HelperLib/IDSDXAudioRenderer.h
HelperLib/IDSDXVideoRenderer.h
VideoRendererDll/CDSDXVideoRenderer.cpp
VideoRendererDll/CDSDXVideoRenderer.h
VideoRendererDll/CDSDXVideoRendererFactory.cpp
VideoRendererDll/CDSDXVideoRendererFactory.h
VideoRendererDll/DSDXVideoRendererDLLGlobals.h
VideoRendererDll/DSDXVideoRendererServer.cpp
VideoRendererDll/DSDXVideoRendererServer.def
VideoRendererDll/HPCounter.h
VideoRendererDll/IDSDXVideoRenderer.h
VideoRendererDll/smartptr.h
Added: AudioRendererDll/CDSDXAudioRenderer.cpp
===================================================================
--- AudioRendererDll/CDSDXAudioRenderer.cpp (rev 0)
+++ AudioRendererDll/CDSDXAudioRenderer.cpp 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,191 @@
+#include "CDSDXAudioRenderer.h"
+#include "DSDXAudioRendererDLLGlobals.h"
+
+#ifdef _DEBUG
+#pragma comment(lib, "strmbasd.lib")
+#else
+#pragma comment(lib, "strmbase.lib")
+#endif
+#pragma comment(lib, "strmiids.lib")
+#pragma comment(lib, "quartz.lib")
+#pragma comment(lib, "winmm.lib")
+
+CDSDXAudioRenderer::CDSDXAudioRenderer(HRESULT *phr)
+: CBaseRenderer(CLSID_DSDXAudioRenderer, TEXT("DSDXAudioRenderer"), NULL, phr),
+m_pSource(NULL), m_pPresent(NULL), m_bDSDXInitialized(FALSE)
+{
+ g_uDllLockCount++;
+ ::ZeroMemory(&m_format, sizeof(m_format));
+}
+
+CDSDXAudioRenderer::~CDSDXAudioRenderer()
+{
+ if(m_pSource)
+ m_pSource->DestroyVoice();
+ m_pSource = NULL;
+ if(m_pPresent)
+ m_pPresent->DestroyVoice();
+ m_pPresent = NULL;
+ m_engine = NULL;
+ g_uDllLockCount--;
+}
+
+HRESULT CDSDXAudioRenderer::PrepareVoices()
+{
+ //CAutoLock cFilterLock(&m_InterfaceLock);
+ if(!m_bDSDXInitialized)
+ return E_FAIL;
+
+ if(m_engine == NULL)
+ return E_FAIL;
+
+ if(m_pSource)
+ {
+ m_pSource->DestroyVoice();
+ m_pSource = NULL;
+ }
+ if(m_pPresent)
+ {
+ m_pPresent->DestroyVoice();
+ m_pPresent = NULL;
+ }
+
+ HRESULT hret = S_OK;
+
+ hret = m_engine->CreateSubmixVoice(&m_pPresent, m_format.nChannels, m_format.nSamplesPerSec);
+ if(FAILED(hret))
+ return hret;
+
+ XAUDIO2_SEND_DESCRIPTOR vsdesc[] = { { 0, m_pPresent } };
+ XAUDIO2_VOICE_SENDS vs = { 1, vsdesc };
+ hret = m_engine->CreateSourceVoice(&m_pSource, &m_format, XAUDIO2_VOICE_NOPITCH, 1.0f, &m_voiceCallback, &vs, NULL);
+ if(FAILED(hret))
+ return hret;
+
+ hret = m_pSource->Start();
+
+ return hret;
+}
+
+
+//CUnknown overrides
+
+STDMETHODIMP CDSDXAudioRenderer::NonDelegatingQueryInterface(const IID &riid, void **pvOut)
+{
+ if(IsBadWritePtr(pvOut, sizeof(void*)))
+ return E_POINTER;
+
+ *pvOut = NULL;
+
+ if(InlineIsEqualGUID(riid, IID_IDSDXAudioRenderer))
+ {
+ *pvOut = (IDSDXAudioRenderer*)this;
+ }
+ else
+ return CBaseRenderer::NonDelegatingQueryInterface(riid, pvOut);
+
+ this->AddRef();
+ return S_OK;
+}
+
+
+//CBaseRenderer overrides
+
+HRESULT CDSDXAudioRenderer::CheckMediaType(const CMediaType *pmt)
+{
+ if(pmt == NULL)
+ return E_POINTER;
+
+ if(IsEqualGUID(pmt->majortype, MEDIATYPE_Audio))
+ {
+ if(!IsEqualGUID(pmt->subtype, MEDIASUBTYPE_PCM))
+ return E_FAIL;
+ }
+ else
+ return E_FAIL;
+
+ if(IsEqualGUID(pmt->formattype, FORMAT_WaveFormatEx))
+ {
+ m_format = *(WAVEFORMATEX*)pmt->pbFormat;
+ }
+
+ PrepareVoices();
+ return S_OK;
+}
+
+HRESULT CDSDXAudioRenderer::DoRenderSample(IMediaSample *pMediaSample)
+{
+ if(m_pSource == NULL)
+ return S_OK;
+ if(pMediaSample == NULL)
+ return E_POINTER;
+
+ pMediaSample->AddRef();
+
+ HRESULT hret = S_OK;
+ BYTE* pData = NULL;
+
+ hret = pMediaSample->GetPointer(&pData);
+ if(FAILED(hret))
+ return hret;
+
+ XAUDIO2_BUFFER buffer = { 0, pMediaSample->GetActualDataLength(), pData, 0, 0, 0, 0, 0, (void*)pMediaSample };
+ hret = m_pSource->SubmitSourceBuffer(&buffer);
+
+ return hret;
+}
+
+
+//IDSDXAudioRenderer overrides
+
+STDMETHODIMP CDSDXAudioRenderer::Initialize(IXAudio2 *pEngine)
+{
+ if(pEngine == NULL)
+ return E_POINTER;
+ m_engine = pEngine;
+
+ m_bDSDXInitialized = TRUE;
+
+ return S_OK;
+}
+
+STDMETHODIMP CDSDXAudioRenderer::OnCriticalError()
+{
+ CAutoLock cRendererLock(&m_InterfaceLock);
+ if(m_pSource)
+ m_pSource->DestroyVoice();
+ m_pSource = NULL;
+ if(m_pPresent)
+ m_pPresent->DestroyVoice();
+ m_pPresent = NULL;
+ m_engine = NULL;
+
+ return S_OK;
+}
+
+STDMETHODIMP CDSDXAudioRenderer::OnResetDevice(IXAudio2 *pEngine)
+{
+ if(pEngine == NULL)
+ return E_POINTER;
+ m_engine = pEngine;
+ if(m_bDSDXInitialized)
+ return PrepareVoices();
+
+ return S_OK;
+}
+
+STDMETHODIMP CDSDXAudioRenderer::GetEngine(IXAudio2 **ppEngine)
+{
+ if(IsBadWritePtr(ppEngine, sizeof(IXAudio2*)))
+ return E_POINTER;
+ *ppEngine = m_engine;
+ return S_OK;
+}
+
+STDMETHODIMP CDSDXAudioRenderer::GetPresentationVoice(IXAudio2SubmixVoice **ppSubmixVoice)
+{
+ if(IsBadWritePtr(ppSubmixVoice, sizeof(IXAudio2SubmixVoice*)))
+ return E_POINTER;
+ *ppSubmixVoice = m_pPresent;
+ return S_OK;
+}
\ No newline at end of file
Added: AudioRendererDll/CDSDXAudioRenderer.h
===================================================================
--- AudioRendererDll/CDSDXAudioRenderer.h (rev 0)
+++ AudioRendererDll/CDSDXAudioRenderer.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,75 @@
+//CDSDXAudioRenderer.h
+//by Jay Tennant 5/30/10
+//coclass for directshow to directx audio renderer
+
+#pragma once
+
+#include <windows.h>
+#include <DShow.h>
+#include <streams.h>
+#include <xaudio2.h>
+#include "smartptr.h"
+
+#include "IDSDXAudioRenderer.h"
+
+class CDSDXAudioRendererXAudio2VoiceCallback : public IXAudio2VoiceCallback
+{
+public:
+ // Called just before this voice's processing pass begins.
+ STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT BytesRequired) {}
+
+ // Called just after this voice's processing pass ends.
+ STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
+
+ // Called when this voice has just finished playing a buffer stream
+ // (as marked with the XAUDIO2_END_OF_STREAM flag on the last buffer).
+ STDMETHOD_(void, OnStreamEnd) () {}
+
+ // Called when this voice is about to start processing a new buffer.
+ STDMETHOD_(void, OnBufferStart) (void* pBufferContext) {}
+
+ // Called when this voice has just finished processing a buffer.
+ // The buffer can now be reused or destroyed.
+ STDMETHOD_(void, OnBufferEnd) (void* pBufferContext) {if(pBufferContext != NULL) ((IMediaSample*)pBufferContext)->Release();}
+
+ // Called when this voice has just reached the end position of a loop.
+ STDMETHOD_(void, OnLoopEnd) (void* pBufferContext) {}
+
+ // Called in the event of a critical error during voice processing,
+ // such as a failing xAPO or an error from the hardware XMA decoder.
+ // The voice may have to be destroyed and re-created to recover from
+ // the error. The callback arguments report which buffer was being
+ // processed when the error occurred, and its HRESULT code.
+ STDMETHOD_(void, OnVoiceError) (void* pBufferContext, HRESULT Error) {}
+};
+
+class CDSDXAudioRenderer : public CBaseRenderer, public IDSDXAudioRenderer
+{
+protected:
+ SmartPtr<IXAudio2> m_engine;
+ IXAudio2SourceVoice* m_pSource;
+ IXAudio2SubmixVoice* m_pPresent;
+ BOOL m_bDSDXInitialized;
+ WAVEFORMATEX m_format;
+ CDSDXAudioRendererXAudio2VoiceCallback m_voiceCallback;
+ HRESULT PrepareVoices();
+public:
+ DECLARE_IUNKNOWN;
+ CDSDXAudioRenderer(HRESULT* phr);
+ virtual ~CDSDXAudioRenderer();
+
+ //CUnknown overrides
+ STDMETHOD(NonDelegatingQueryInterface)(REFIID riid, void** pvOut);
+
+ //CBaseRenderer overrides
+ virtual HRESULT CheckMediaType(const CMediaType *pmt);
+ virtual HRESULT DoRenderSample(IMediaSample *pMediaSample);
+
+ //IDSDXAudioRenderer overrides
+ STDMETHOD(Initialize)(IXAudio2* pEngine);
+ STDMETHOD(OnCriticalError)();
+ STDMETHOD(OnResetDevice)(IXAudio2* pEngine);
+
+ STDMETHOD(GetEngine)(IXAudio2** ppEngine);
+ STDMETHOD(GetPresentationVoice)(IXAudio2SubmixVoice** ppSubmixVoice);
+};
\ No newline at end of file
Added: AudioRendererDll/CDSDXAudioRendererFactory.cpp
===================================================================
--- AudioRendererDll/CDSDXAudioRendererFactory.cpp (rev 0)
+++ AudioRendererDll/CDSDXAudioRendererFactory.cpp 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,84 @@
+#include "CDSDXAudioRendererFactory.h"
+#include "DSDXAudioRendererDLLGlobals.h"
+
+CDSDXAudioRendererFactory::CDSDXAudioRendererFactory() : m_nRefCount(0)
+{
+ g_uDllLockCount++;
+}
+
+CDSDXAudioRendererFactory::~CDSDXAudioRendererFactory()
+{
+ g_uDllLockCount--;
+}
+
+STDMETHODIMP_(ULONG) CDSDXAudioRendererFactory::AddRef()
+{
+ return ++m_nRefCount;
+}
+
+STDMETHODIMP_(ULONG) CDSDXAudioRendererFactory::Release()
+{
+ ULONG ret = --m_nRefCount;
+ if(ret == 0)
+ delete this;
+ return ret;
+}
+
+STDMETHODIMP CDSDXAudioRendererFactory::QueryInterface(const IID &riid, void **ppv)
+{
+ if(IsBadWritePtr(ppv, sizeof(void*)))
+ return E_POINTER;
+
+ *ppv = NULL;
+ HRESULT hret = S_OK;
+
+ if(InlineIsEqualGUID(riid, IID_IUnknown))
+ {
+ *ppv = (IUnknown*)this;
+ }
+ else if(InlineIsEqualGUID(riid, IID_IClassFactory))
+ {
+ *ppv = (IClassFactory*)this;
+ }
+ else
+ hret = E_NOINTERFACE;
+
+ if(S_OK == hret)
+ {
+ this->AddRef();
+ }
+
+ return hret;
+}
+
+STDMETHODIMP CDSDXAudioRendererFactory::CreateInstance(IUnknown *pUnkOuter, const IID &riid, void **ppv)
+{
+ HRESULT hret = S_OK;
+ CDSDXAudioRenderer* pAudioRenderer = NULL;
+
+ if(pUnkOuter != NULL)
+ return CLASS_E_NOAGGREGATION;
+
+ if(IsBadWritePtr(ppv, sizeof(void*)))
+ return E_POINTER;
+
+ *ppv = NULL;
+
+ pAudioRenderer = new CDSDXAudioRenderer(&hret);
+
+ if(pAudioRenderer == NULL)
+ return E_OUTOFMEMORY;
+
+ hret = pAudioRenderer->QueryInterface(riid, ppv);
+
+ if(FAILED(hret))
+ delete pAudioRenderer;
+
+ return hret;
+}
+
+STDMETHODIMP CDSDXAudioRendererFactory::LockServer(BOOL fLock)
+{
+ fLock ? g_uDllLockCount++ : g_uDllLockCount--;
+ return S_OK;
+}
\ No newline at end of file
Added: AudioRendererDll/CDSDXAudioRendererFactory.h
===================================================================
--- AudioRendererDll/CDSDXAudioRendererFactory.h (rev 0)
+++ AudioRendererDll/CDSDXAudioRendererFactory.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,25 @@
+//CDSDXVideoRendererFactory.h
+//by Jay Tennant 5/30/10
+//manages class factory for CDSDXAudioRenderer
+
+#pragma once
+
+#include "CDSDXAudioRenderer.h"
+
+class CDSDXAudioRendererFactory : public IClassFactory
+{
+protected:
+ ULONG m_nRefCount;
+public:
+ CDSDXAudioRendererFactory();
+ virtual ~CDSDXAudioRendererFactory();
+
+ // IUnknown overrides
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+ STDMETHOD(QueryInterface)(REFIID riid, void** ppv);
+
+ // IClassFactory overrides
+ STDMETHOD(CreateInstance)(IUnknown* pUnkOuter, REFIID riid, void** ppv);
+ STDMETHOD(LockServer)(BOOL fLock);
+};
\ No newline at end of file
Added: AudioRendererDll/DSDXAudioRendererDLLGlobals.h
===================================================================
--- AudioRendererDll/DSDXAudioRendererDLLGlobals.h (rev 0)
+++ AudioRendererDll/DSDXAudioRendererDLLGlobals.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,8 @@
+//DSDXAudioRendererDLLGlobals.h
+//by Jay Tennant 5/30/10
+//defines dll globals
+
+#pragma once
+
+extern HINSTANCE g_hinstThisDll; // Our DLL's HINSTANCE
+extern UINT g_uDllLockCount; // The module lock count
Added: AudioRendererDll/DSDXAudioRendererServer.cpp
===================================================================
--- AudioRendererDll/DSDXAudioRendererServer.cpp (rev 0)
+++ AudioRendererDll/DSDXAudioRendererServer.cpp 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,124 @@
+#include "CDSDXAudioRendererFactory.h"
+#include "DSDXAudioRendererDLLGlobals.h"
+
+HINSTANCE g_hinstThisDll;
+UINT g_uDllLockCount;
+
+BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
+{
+ switch(ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ {
+ g_hinstThisDll = hModule;
+ DisableThreadLibraryCalls(hModule);
+ } break;
+ case DLL_PROCESS_DETACH:
+ break;
+ default:;
+ }
+
+ return TRUE;
+}
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ HRESULT hret = S_OK;
+ CDSDXAudioRendererFactory* pFactory = NULL;
+
+ if(!InlineIsEqualGUID(CLSID_DSDXAudioRenderer, rclsid))
+ return CLASS_E_CLASSNOTAVAILABLE;
+
+ if(IsBadWritePtr(ppv, sizeof(void*)))
+ return E_POINTER;
+
+ *ppv = NULL;
+
+ pFactory = new CDSDXAudioRendererFactory;
+
+ if(pFactory == NULL)
+ return E_OUTOFMEMORY;
+
+ pFactory->AddRef();
+
+ hret = pFactory->QueryInterface(riid, ppv);
+
+ pFactory->Release();
+
+ return hret;
+}
+
+STDAPI DllCanUnloadNow()
+{
+ return g_uDllLockCount > 0 ? S_FALSE : S_OK;
+}
+
+STDAPI DllRegisterServer()
+{
+ HKEY hCLSIDKey = NULL;
+ HKEY hInProcServerKey = NULL;
+ LONG lRet;
+ TCHAR szModulePath[MAX_PATH];
+ TCHAR szClassDescription[] = TEXT("DSDXAudioRenderer");
+ TCHAR szThreadingModel[] = TEXT("Both");
+
+
+ lRet = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Classes\\CLSID\\{BB0B01C0-9736-4fbd-BF64-63B2B1B6FB07}"), 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_SET_VALUE | KEY_CREATE_SUB_KEY, NULL, &hCLSIDKey, NULL);
+
+ if(ERROR_SUCCESS != lRet)
+ {
+ MessageBox(0, TEXT("CLSID key creation failed!"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return HRESULT_FROM_WIN32(lRet);
+ }
+
+ lRet = RegSetValueEx(hCLSIDKey, NULL, 0, REG_SZ, (const BYTE*)szClassDescription, sizeof(szClassDescription));
+
+ if(ERROR_SUCCESS != lRet)
+ {
+ MessageBox(0, TEXT("CLSID key setting failed!"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return HRESULT_FROM_WIN32(lRet);
+ }
+
+ lRet = RegCreateKeyEx(hCLSIDKey, TEXT("InProcServer32"), 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_SET_VALUE, NULL, &hInProcServerKey, NULL);
+
+ if(ERROR_SUCCESS != lRet)
+ {
+ MessageBox(0, TEXT("InProcServer32 key creation failed!"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return HRESULT_FROM_WIN32(lRet);
+ }
+
+ GetModuleFileName(g_hinstThisDll, szModulePath, MAX_PATH);
+
+ lRet = RegSetValueEx(hInProcServerKey, NULL, 0, REG_SZ, (const BYTE*)szModulePath, sizeof(TCHAR) * (lstrlen(szModulePath)+1) );
+
+ if(ERROR_SUCCESS != lRet)
+ {
+ MessageBox(0, TEXT("InProcServer32 key setting default failed!"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return HRESULT_FROM_WIN32(lRet);
+ }
+
+ lRet = RegSetValueEx(hInProcServerKey, TEXT("ThreadingModel"), 0, REG_SZ, (const BYTE*)szThreadingModel, sizeof(szThreadingModel));
+
+ if(ERROR_SUCCESS != lRet)
+ {
+ MessageBox(0, TEXT("InProcServer32 key setting ThreadingModel failed!"), TEXT("Error"), MB_OK | MB_ICONEXCLAMATION);
+ return HRESULT_FROM_WIN32(lRet);
+ }
+
+ if(hCLSIDKey != NULL)
+ RegCloseKey(hCLSIDKey);
+ if(hInProcServerKey != NULL)
+ RegCloseKey(hInProcServerKey);
+
+ return S_OK;
+}
+
+STDAPI DllUnregisterServer()
+{
+ RegDeleteKey(HKEY_CURRENT_USER, TEXT("Software\\Classes\\CLSID\\{BB0B01C0-9736-4fbd-BF64-63B2B1B6FB07}\\InProcServer32"));
+ RegDeleteKey(HKEY_CURRENT_USER, TEXT("Software\\Classes\\CLSID\\{BB0B01C0-9736-4fbd-BF64-63B2B1B6FB07}"));
+
+ return S_OK;
+}
\ No newline at end of file
Added: AudioRendererDll/DSDXAudioRendererServer.def
===================================================================
--- AudioRendererDll/DSDXAudioRendererServer.def (rev 0)
+++ AudioRendererDll/DSDXAudioRendererServer.def 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,6 @@
+EXPORTS
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+ DllGetClassObject PRIVATE
+ DllCanUnloadNow PRIVATE
+
\ No newline at end of file
Added: AudioRendererDll/IDSDXAudioRenderer.h
===================================================================
--- AudioRendererDll/IDSDXAudioRenderer.h (rev 0)
+++ AudioRendererDll/IDSDXAudioRenderer.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,34 @@
+//IDSDXAudioRenderer.h
+//by Jay Tennant 5/27/10
+//describes com interfaces for a DirectShow to DirectX audio renderer
+
+#pragma once
+
+//forward declarations
+typedef interface IDSDXAudioRenderer IDSDXAudioRenderer;
+
+//IID's defined
+#define IID_IDSDXAudioRenderer __uuidof(IDSDXAudioRenderer)
+
+//implementation declaration
+class DECLSPEC_UUID("{BB0B01C0-9736-4fbd-BF64-63B2B1B6FB07}") CDSDXAudioRenderer;
+
+//CLSID defined
+#define CLSID_DSDXAudioRenderer __uuidof(CDSDXAudioRenderer)
+
+
+#ifndef DSDX_NO_DIRECTX
+
+MIDL_INTERFACE("{C2ECB4B0-E889-4524-BFDC-5D7858AE0033}")
+IDSDXAudioRenderer : public IUnknown
+{
+public:
+ STDMETHOD(Initialize)(IXAudio2* pEngine) PURE; //starts up the audio renderer with the IXAudio2 engine
+ STDMETHOD(OnCriticalError)() PURE; //releases the created voices and the IXAudio2 engine
+ STDMETHOD(OnResetDevice)(IXAudio2* pEngine) PURE; //restarts the audio renderer with the re-initialized IXAudio2 engine
+
+ STDMETHOD(GetEngine)(IXAudio2** ppEngine) PURE; //returns the engine
+ STDMETHOD(GetPresentationVoice)(IXAudio2SubmixVoice** ppSubmixVoice) PURE; //retrieves the presentation voice
+};
+
+#endif //DSDX_NO_XAUDIO2
\ No newline at end of file
Added: AudioRendererDll/smartptr.h
===================================================================
--- AudioRendererDll/smartptr.h (rev 0)
+++ AudioRendererDll/smartptr.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,192 @@
+// SmartPtr.h
+//
+// Defines a smart pointer class that does not depend on any ATL headers
+
+#pragma once
+
+///////////////////////////////////////////////////////////////////////
+// Name: AreCOMObjectsEqual [template]
+// Desc: Tests two COM pointers for equality.
+///////////////////////////////////////////////////////////////////////
+
+template <class T1, class T2>
+bool AreComObjectsEqual(T1 *p1, T2 *p2)
+{
+ bool bResult = false;
+ if (p1 == NULL && p2 == NULL)
+ {
+ // Both are NULL
+ bResult = true;
+ }
+ else if (p1 == NULL || p2 == NULL)
+ {
+ // One is NULL and one is not
+ bResult = false;
+ }
+ else
+ {
+ // Both are not NULL. Compare IUnknowns.
+ IUnknown *pUnk1 = NULL;
+ IUnknown *pUnk2 = NULL;
+ if (SUCCEEDED(p1->QueryInterface(IID_IUnknown, (void**)&pUnk1)))
+ {
+ if (SUCCEEDED(p2->QueryInterface(IID_IUnknown, (void**)&pUnk2)))
+ {
+ bResult = (pUnk1 == pUnk2);
+ pUnk2->Release();
+ }
+ pUnk1->Release();
+ }
+ }
+ return bResult;
+}
+
+// _NoAddRefOrRelease:
+// This is a version of our COM interface that dis-allows AddRef
+// and Release. All ref-counting should be done by the SmartPtr
+// object, so we want to dis-allow calling AddRef or Release
+// directly. The operator-> returns a _NoAddRefOrRelease pointer
+// instead of returning the raw COM pointer. (This behavior is the
+// same as ATL's CComPtr class.)
+template <class T>
+class _NoAddRefOrRelease : public T
+{
+private:
+ STDMETHOD_(ULONG, AddRef)() = 0;
+ STDMETHOD_(ULONG, Release)() = 0;
+};
+
+template <class T>
+class SmartPtr
+{
+public:
+
+ // Ctor
+ SmartPtr() : m_ptr(NULL)
+ {
+ }
+
+ // Ctor
+ SmartPtr(T *ptr)
+ {
+ m_ptr = ptr;
+ if (m_ptr)
+ {
+ m_ptr->AddRef();
+ }
+ }
+
+ // Copy ctor
+ SmartPtr(const SmartPtr& sptr)
+ {
+ m_ptr = sptr.m_ptr;
+ if (m_ptr)
+ {
+ m_ptr->AddRef();
+ }
+ }
+
+ // Dtor
+ ~SmartPtr()
+ {
+ if (m_ptr)
+ {
+ m_ptr->Release();
+ }
+ }
+
+ // Assignment
+ SmartPtr& operator=(const SmartPtr& sptr)
+ {
+ // Don't do anything if we are assigned to ourselves.
+ if (!AreComObjectsEqual(m_ptr, sptr.m_ptr))
+ {
+ if (m_ptr)
+ {
+ m_ptr->Release();
+ }
+
+ m_ptr = sptr.m_ptr;
+ if (m_ptr)
+ {
+ m_ptr->AddRef();
+ }
+ }
+ return *this;
+ }
+
+ // address-of operator
+ T** operator&()
+ {
+ return &m_ptr;
+ }
+
+ // dereference operator
+ _NoAddRefOrRelease<T>* operator->()
+ {
+ return (_NoAddRefOrRelease<T>*)m_ptr;
+ }
+
+ // coerce to underlying pointer type.
+ operator T*()
+ {
+ return m_ptr;
+ }
+
+ // Templated version of QueryInterface
+
+ template <class Q> // Q is another interface type
+ HRESULT QueryInterface(Q **ppQ)
+ {
+ return m_ptr->QueryInterface(__uuidof(Q), (void**)ppQ);
+ }
+
+ // safe Release() method
+ ULONG Release()
+ {
+ T *ptr = m_ptr;
+ ULONG result = 0;
+ if (ptr)
+ {
+ m_ptr = NULL;
+ result = ptr->Release();
+ }
+ return result;
+ }
+
+ // Attach to an existing interface (does not AddRef)
+ void Attach(T* p)
+ {
+ if (m_ptr)
+ {
+ m_ptr->Release();
+ }
+ m_ptr = p;
+ }
+
+
+
+ // Detach the interface (does not Release)
+ T* Detach()
+ {
+ T* p = m_ptr;
+ m_ptr = NULL;
+ return p;
+ }
+
+
+ // equality operator
+ bool operator==(T *ptr) const
+ {
+ return AreComObjectsEqual(m_ptr, ptr);
+ }
+
+ // inequality operator
+ bool operator!=(T *ptr) const
+ {
+ return !operator==(ptr);
+ }
+
+private:
+ T *m_ptr;
+};
Added: ClientTestExe/DSDXDemo.h
===================================================================
--- ClientTestExe/DSDXDemo.h (rev 0)
+++ ClientTestExe/DSDXDemo.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,134 @@
+//headers
+#include <windows.h>
+#include <DShow.h>
+#include <d3d9.h>
+#include <xaudio2.h>
+#include "SmartPtr.h"
+#include <comutil.h>
+
+#include "DSDXHelper.h"
+#include "IDSDXAudioRenderer.h"
+#define DSDX_VR9 //makes the directx9 interface available
+#include "IDSDXVideoRenderer.h"
+
+//libraries
+#pragma comment(lib, "d3d9.lib")
+#pragma comment(lib, "quartz.lib")
+#pragma comment(lib, "strmiids.lib")
+
+#ifdef _DEBUG
+#pragma comment(lib, "DSDXHelperd.lib")
+#pragma comment(lib, "comsuppwd.lib")
+#else
+#pragma comment(lib, "DSDXHelper.lib")
+#pragma comment(lib, "comsuppw.lib")
+#endif
+
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ //load COM Library; can be COINIT_APARTMENTTHREADED
+ CoInitializeEx(NULL, COINIT_MULTITHREADED);
+
+ //Register DSDXVR.dll and DSDXAR.dll using regsvr32.exe
+ DSDXRegisterComDll();
+
+ {
+ HRESULT hr = S_OK;
+
+ //...do window and d3ddevice initialization, and xaudio2 initialization...
+
+
+ //Create the VideoRenderer in 2 steps: get the IUnknown handle, Query for the interface
+ SmartPtr<IUnknown> vrUnknown;
+ hr = DSDXCreateVideoRenderer(&vrUnknown);
+ if(FAILED(hr))
+ goto End;
+
+ SmartPtr<IDSDXVideoRenderer9> vr9;
+ hr = vrUnknown->QueryInterface(IID_IDSDXVideoRenderer9, (void**)&vr9);
+ if(FAILED(hr))
+ goto End;
+
+ //Optionally, instead of DSDXCreateVideoRenderer(), one can obtain the interface intended directly as:
+ //hr = CoCreateInstance(CLSID_DSDXVideoRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IDSDXVideoRenderer9, (void**)&vr9);
+
+
+ //Initialize the video renderer
+ vr9->Initialize(d3ddev9);
+
+ //Create the AudioRenderer in 2 steps: get the IUnknown handle, Query for the interface
+ SmartPtr<IUnknown> arUnknown;
+ hr = DSDXCreateAudioRenderer(&arUnknown);
+ if(FAILED(hr))
+ goto End;
+
+ SmartPtr<IDSDXAudioRenderer> ar;
+ hr = arUnknown->QueryInterface(IID_IDSDXAudioRenderer, (void**)&ar);
+ if(FAILED(hr))
+ goto End;
+
+ //Optionally, instead of DSDXCreateAudioRenderer(), one can obtain the interface intended directly as:
+ //hr = CoCreateInstance(CLSID_DSDXAudioRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IDSDXAudioRenderer, (void**)&ar);
+
+
+ //Initialize the audio renderer
+ ar->Initialize(xaudio2engine);
+
+
+ //Create the render graph, render a file, and use the created renderers
+ //Optionally, do not send an audio renderer; the system default DirectSound renderer is used
+ SmartPtr<IMediaControl> control;
+ SmartPtr<IMediaSeeking> seek;
+ hr = DSDXCreateGraphAndRenderAVI( _bstr_t("SomeAviFile.avi"), &control, &seek, (IDSDXVideoRenderer9*)vr9, (IDSDXAudioRenderer*)ar );
+ if(FAILED(hr))
+ goto End;
+
+ //If one wished, one could QueryInterface() on either vr9 or ar for the IBaseFilter interface
+ //and connect the filter to a graph of his/her own
+
+
+ //Run the graph
+ control->Run();
+
+ MSG msg;
+ IDirect3DTexture9* pTexture = NULL;
+ IXAudio2SubmixVoice* pSubmix = NULL;
+ while(true)
+ {
+ if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ if(msg.message == WM_QUIT)
+ break;
+ }
+ else
+ {
+ //do stuff with submix voice; 3D transformations can be applied, though not doppler shift
+ ar->GetPresentationVoice(&pSubmix);
+
+ //do stuff with presetation texture; use it in shaders
+ vr9->GetPresentationTexture(&pTexture);
+
+ d3ddev9->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
+ d3ddev9->BeginScene();
+
+ //must call IDSDXVideoRenderer*::Present() within IDirect3DDevice9::BeginScene() / EndScene() pairs
+ //this restriction is only for DirectX 9
+ vr9->Present();
+
+ d3ddev9->EndScene();
+ d3ddev9->Present(0,0,0,0);
+ }
+ }
+ }
+
+End:
+ //unregister DSDXVR.dll and DSDXAR.dll using regsvr32.exe
+ DSDXUnregisterComDll();
+
+ //unload COM library
+ CoUninitialize();
+ return 0;
+}
\ No newline at end of file
Added: ClientTestExe/DSDXHelper.h
===================================================================
--- ClientTestExe/DSDXHelper.h (rev 0)
+++ ClientTestExe/DSDXHelper.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,27 @@
+//DSDXHelper.h
+//by Jay Tennant 5/28/10
+//exposes helper functions for DSDX registration, graph building
+
+#pragma once
+
+#include <windows.h>
+#include <DShow.h>
+
+extern "C"
+{
+ //creates a video renderer; use QueryInterface() to obtain the desired interface
+ HRESULT DSDXCreateVideoRenderer(IUnknown** ppVideoRenderer);
+
+ //creates an audio renderer; use QueryInterface() to obtain the desired interface
+ HRESULT DSDXCreateAudioRenderer(IUnknown** ppAudioRenderer);
+
+ //registers DSDXVR.dll and DSDXAR.dll, or DSDXVRd.dll and DSDXARd.dll (debug versions)
+ HRESULT DSDXRegisterComDll();
+
+ //unregisters DSDXVR.dll and DSDXAR.dll, or DSDXVRd.dll and DSDXARd.dll (debug versions)
+ HRESULT DSDXUnregisterComDll();
+
+ //creates a filter graph and renders avi files; returns a IMediaControl and IMediaSeeking interface for controlling playback;
+ //accepts a pointer to a video renderer, and an optional audio renderer; if no audio renderer is specified, the default is provided
+ HRESULT DSDXCreateGraphAndRenderAVI(BSTR szFile, IMediaControl** ppControl, IMediaSeeking** ppSeeking, IUnknown* pVideoRenderer, IUnknown* pAudioRenderer);
+}
\ No newline at end of file
Added: ClientTestExe/IDSDXAudioRenderer.h
===================================================================
--- ClientTestExe/IDSDXAudioRenderer.h (rev 0)
+++ ClientTestExe/IDSDXAudioRenderer.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,35 @@
+//IDSDXAudioRenderer.h
+//by Jay Tennant 5/27/10
+//describes com interfaces for a DirectShow to DirectX audio renderer
+
+#pragma once
+
+//forward declarations
+typedef interface IDSDXAudioRenderer IDSDXAudioRenderer;
+
+//IID's defined
+#define IID_IDSDXAudioRenderer __uuidof(IDSDXAudioRenderer)
+
+//implementation declaration
+class DECLSPEC_UUID("{BB0B01C0-9736-4fbd-BF64-63B2B1B6FB07}") CDSDXAudioRenderer;
+
+//CLSID defined
+#define CLSID_DSDXAudioRenderer __uuidof(CDSDXAudioRenderer)
+
+
+#ifndef DSDX_NO_DIRECTX
+
+MIDL_INTERFACE("{C2ECB4B0-E889-4524-BFDC-5D7858AE0033}")
+IDSDXAudioRenderer : public IUnknown
+{
+public:
+ STDMETHOD(Initialize)(IXAudio2* pEngine) PURE; //starts up the audio renderer with the IXAudio2 engine
+ STDMETHOD(Shutdown)() PURE; //shuts down the audio renderer
+ STDMETHOD(OnCriticalError)() PURE; //releases the created voices and the IXAudio2 engine
+ STDMETHOD(OnResetDevice)(IXAudio2* pEngine) PURE; //restarts the audio renderer with the re-initialized IXAudio2 engine
+
+ STDMETHOD(GetEngine)(IXAudio2** ppEngine) PURE; //returns the engine
+ STDMETHOD(GetPresentationVoice)(IXAudio2SubmixVoice** ppSubmixVoice) PURE; //retrieves the presentation voice
+};
+
+#endif //DSDX_NO_DIRECTX
\ No newline at end of file
Added: ClientTestExe/IDSDXVideoRenderer.h
===================================================================
--- ClientTestExe/IDSDXVideoRenderer.h (rev 0)
+++ ClientTestExe/IDSDXVideoRenderer.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,121 @@
+//IDSDXVideoRenderer.h
+//by Jay Tennant 5/24/10
+//describes com interfaces for a DirectShow to DirectX filter
+
+#pragma once
+
+//forward declarations
+typedef interface IDSDXBase IDSDXBase;
+typedef interface IDSDXVideoRendererGeneric IDSDXVideoRendererGeneric;
+typedef interface IDSDXVideoRenderer9 IDSDXVideoRenderer9;
+typedef interface IDSDXVideoRenderer10 IDSDXVideoRenderer10;
+typedef interface IDSDXVideoRenderer11 IDSDXVideoRenderer11;
+
+//IID definitions, using __uuidof
+#define IID_IDSDXBase __uuidof(IDSDXBase)
+#define IID_IDSDXVideoRendererGeneric __uuidof(IDSDXVideoRendererGeneric)
+#define IID_IDSDXVideoRenderer9 __uuidof(IDSDXVideoRenderer9)
+#define IID_IDSDXVideoRenderer10 __uuidof(IDSDXVideoRenderer10)
+#define IID_IDSDXVideoRenderer11 __uuidof(IDSDXVideoRenderer11)
+
+//implementation forward declarations
+class DECLSPEC_UUID("{5FA9A497-5E52-4793-956E-9303DA164C67}") CDSDXVideoRenderer;
+
+//CLSID definitions, using __uuidof
+#define CLSID_DSDXVideoRenderer __uuidof(CDSDXVideoRenderer)
+
+enum DSDXVIDEORENDERER_TYPE
+{
+ DSDXVRT_UNKNOWN = 0,
+ DSDXVRT_9 = 1, //directx 9
+ DSDXVRT_10 = 2, //directx 10
+ DSDXVRT_11 = 3, //directx 11
+};
+
+enum DSDX_FORMAT
+{
+ DSDXFMT_UNKNOWN = 0x0, //unknown format
+
+ DSDXFMT_A8R8G8B8 = 0x1, //32bit, D3DFMT_A8R8G8B8, DXGI_FORMAT_B8G8R8A8_UNORM
+ DSDXFMT_X8R8G8B8 = 0x2, //32bit, D3DFMT_X8R8G8B8, DXGI_FORMAT_B8G8R8X8_UNORM
+ DSDXFMT_32BIT = DSDXFMT_A8R8G8B8 | DSDXFMT_X8R8G8B8,
+
+ DSDXFMT_R5G6B5 = 0x4, //16bit, D3DFMT_R5G6B5, DXGI_FORMAT_B5G6R5_UNORM
+ DSDXFMT_R8G8_B8G8 = 0x8, //16bit pixel pairs, like UYVY, D3DFMT_R8G8_B8G8, DXGI_FORMAT_R8G8_B8G8_UNORM
+ DSDXFMT_G8R8_G8B8 = 0x10, //16bit pixel pairs, like YUY2, D3DFMT_G8R8_G8B8, DXGI_FORMAT_G8R8_G8B8_UNORM
+ DSDXFMT_16BIT = DSDXFMT_R5G6B5 | DSDXFMT_R8G8_B8G8 | DSDXFMT_G8R8_G8B8,
+};
+#define DSDX_FORMAT_IS_32BIT(fmt) (DSDXFMT_32BIT & fmt) ? 1 : 0
+#define DSDX_FORMAT_IS_16BIT(fmt) (DSDXFMT_16BIT & fmt) ? 1 : 0
+
+
+MIDL_INTERFACE("{FB422CC0-F067-4c22-A5BF-ADB74CCA2972}")
+IDSDXBase : public IUnknown
+{
+public:
+ STDMETHOD(Present)() PURE; //updates the video memory texture from system memory
+
+ STDMETHOD(OnLostDevice)() PURE; //releases texture in video memory
+ STDMETHOD(OnResetDevice)() PURE; //creates texture in video memory
+
+ STDMETHOD(GetStreamDimensions)(RECT* pRect) PURE; //the dimensions of the media samples being rendered
+};
+
+#ifndef DSDX_NO_DIRECTX
+
+MIDL_INTERFACE("{1B06ABC2-A793-475a-9D69-3501CB63B53E}")
+IDSDXVideoRendererGeneric : public IDSDXBase
+{
+public:
+ STDMETHOD(Initialize)(DSDXVIDEORENDERER_TYPE vrType, void* pDevice, void* pContext) PURE; //initializes the video renderer with a dx version and dx device
+ STDMETHOD(GetVideoRenderType)(DWORD* pVrType) PURE; //gets the video render type, DSDXVIDEORENDERER_TYPE
+
+ STDMETHOD(GetDevice)(void** ppDevice) PURE; //returns the dx device
+ STDMETHOD(GetDeviceContext)(void** ppContext) PURE; //returns the dx device context (specific to dx11)
+ STDMETHOD(GetPresentationTexture)(void** ppTexture) PURE; //returns the "presentation" texture, the one used in the shader stages
+ STDMETHOD(IsSquareTextureRequired)(BOOL* pBool) PURE; //reveals whether square textures are required
+ STDMETHOD(IsPow2TextureRequired)(BOOL* pBool) PURE; //reveals whether power of 2 textures are required
+ STDMETHOD(GetHiTextureCoordinates)(D3DXVECTOR2* pVec2) PURE; //returns the high texture coordinates (not 0,0), accounting for square or power of 2 requirements
+};
+
+#ifdef DSDX_VR9
+MIDL_INTERFACE("{A3B747B7-7352-44e9-842D-ABFC596003DE}")
+IDSDXVideoRenderer9 : public IDSDXBase
+{
+public:
+ STDMETHOD(Initialize)(IDirect3DDevice9* pDevice) PURE; //initializes the renderer to use the dx9 device
+
+ STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice) PURE; //returns the dx9 device
+ STDMETHOD(GetPresentationTexture)(IDirect3DTexture9** ppTexture) PURE; //returns the "presentation" texture, the one used in the shader stages
+ STDMETHOD(IsSquareTextureRequired)(BOOL* pBool) PURE; //reveals whether square textures are required
+ STDMETHOD(IsPow2TextureRequired)(BOOL* pBool) PURE; //reveals whether power of 2 textures are required
+ STDMETHOD(GetHiTextureCoordinates)(D3DXVECTOR2* pVec2) PURE; //returns the high texture coordinates (not 0,0), accounting for square or power of 2 requirements
+};
+#endif
+
+#ifdef DSDX_VR10
+MIDL_INTERFACE("{0A645800-DC2F-430a-B643-5BFDC00DA38D}")
+IDSDXVideoRenderer10 : public IDSDXBase
+{
+public:
+ STDMETHOD(Initialize)(ID3D10Device* pDevice) PURE; //initializes the renderer to use the dx10 device
+
+ STDMETHOD(GetDevice)(ID3D10Device** ppDevice) PURE; //returns the dx10 device
+ STDMETHOD(GetPresentationTexture)(ID3D10Texture2D** ppTexture) PURE; //returns the "presentation" texture, the one used in the shader stages
+};
+#endif
+
+#ifdef DSDX_VR11
+MIDL_INTERFACE("{772B6ED8-3B31-4212-8620-44173F9A1E90}")
+IDSDXVideoRenderer11 : public IDSDXBase
+{
+public:
+ STDMETHOD(Initialize)(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) PURE; //initializes the renderer to use the dx11 device
+
+ STDMETHOD(GetDevice)(ID3D11Device** ppDevice) PURE; //returns the dx11 device
+ STDMETHOD(GetDeviceContext)(ID3D11DeviceContext** ppContext) PURE; //returns the dx11 device context
+ STDMETHOD(GetPresentationTexture)(ID3D11Texture2D** ppTexture) PURE; //returns the "presentation" texture, the one used in the shader stages
+};
+#endif
+
+#endif //DSDX_NO_DIRECTX
\ No newline at end of file
Added: ClientTestExe/SmartRef.h
===================================================================
--- ClientTestExe/SmartRef.h (rev 0)
+++ ClientTestExe/SmartRef.h 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,95 @@
+//SmartRef.h
+//by Jay Tennant 9/6/09; updated 1/26/10
+//like SmartPtr, but for Base.h; thread safe
+
+#ifndef SMARTREF_H
+#define SMARTREF_H
+
+template <class T>
+class _NoAddRefOrRelease_SmartRef : public T
+{
+private:
+ virtual unsigned int AddRef() = 0;
+ virtual unsigned int Release() = 0;
+};
+
+template <class T>
+class SmartRef
+{
+private:
+ T* m_ptr;
+public:
+ SmartRef() : m_ptr(0) {}
+ SmartRef(T* ptr) : m_ptr(ptr)
+ {
+ if(m_ptr)
+ m_ptr->AddRef();
+ }
+ SmartRef(const SmartRef& rhs) : m_ptr(rhs.m_ptr)
+ {
+ if(m_ptr)
+ m_ptr->AddRef();
+ }
+ ~SmartRef()
+ {
+ if(m_ptr)
+ m_ptr->Release();
+ }
+
+ SmartRef& operator= (const SmartRef& rhs)
+ {
+ if(m_ptr == rhs.m_ptr)
+ return *this;
+ if(m_ptr)
+ m_ptr->Release();
+ m_ptr = rhs.m_ptr;
+ if(m_ptr)
+ m_ptr->AddRef();
+ return *this;
+ }
+ T** operator&()
+ {
+ return &m_ptr;
+ }
+ _NoAddRefOrRelease_SmartRef<T>* operator->()
+ {
+ return (_NoAddRefOrRelease_SmartRef<T>*)m_ptr;
+ }
+ operator T*()
+ {
+ return m_ptr;
+ }
+ unsigned int Release() //safe release
+ {
+ T* ptr = m_ptr;
+ m_ptr = 0;
+ unsigned int nResult = 0;
+ if(ptr)
+ {
+ nResult = ptr->Release();
+ }
+ return nResult;
+ }
+ void Attach(T* ptr) //attaches pointer, no AddRef()
+ {
+ if(m_ptr)
+ m_ptr->Release();
+ m_ptr = ptr;
+ }
+ T* Detach() //detaches pointer, no Release()
+ {
+ T* ptr = m_ptr;
+ m_ptr = 0;
+ return ptr;
+ }
+ bool operator== (T* ptr) const
+ {
+ return m_ptr == ptr;
+ }
+ bool operator!= (T* ptr) const
+ {
+ return !operator==(ptr);
+ }
+};
+
+#endif //SMARTREF_H
\ No newline at end of file
Added: ClientTestExe/_main.cpp
===================================================================
--- ClientTestExe/_main.cpp (rev 0)
+++ ClientTestExe/_main.cpp 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,457 @@
+#include "jsl_Window.h"
+#include "jsl_DxDevice.h"
+#include "jsl_SwapChain.h"
+#include "SmartRef.h"
+
+#include "XAudio2.h"
+//#pragma comment(lib, "XAudio2.lib")
+
+#define DSDX_VR9
+#include "IDSDXVideoRenderer.h"
+#include "IDSDXAudioRenderer.h"
+
+#include "DShow.h"
+#pragma comment(lib, "quartz.lib")
+#pragma comment(lib, "strmiids.lib")
+
+#include "DSDXHelper.h"
+#include <comutil.h>
+
+#include "demo shapes.h"
+#include <d3dx9.h>
+
+#ifdef _DEBUG
+#pragma comment(lib, "d3d9.lib")
+#pragma comment(lib, "d3dx9d.lib")
+#pragma comment(lib, "DSDXHelperd.lib")
+#pragma comment(lib, "comsuppwd.lib")
+#else
+#pragma comment(lib, "d3d9.lib")
+#pragma comment(lib, "d3dx9.lib")
+#pragma comment(lib, "DSDXHelper.lib")
+#pragma comment(lib, "comsuppw.lib")
+#endif
+
+BOOL g_bQuadTextured = TRUE;
+BOOL g_bCylinderTextured = TRUE;
+BOOL g_bFlagTextured = TRUE;
+BOOL g_bQuitting = FALSE;
+
+struct DSDXRenderers
+{
+ DSDXRenderers() : pVideoTex(NULL), pAudio(NULL) {}
+ SmartPtr<IDSDXVideoRenderer9> vr9;
+ SmartPtr<IDSDXAudioRenderer> ar;
+ SmartPtr<IUnknown> unknownLoader;
+ SmartPtr<IMediaControl> control;
+ SmartPtr<IMediaSeeking> seek;
+ IDirect3DTexture9* pVideoTex;
+ IXAudio2SubmixVoice* pAudio;
+};
+
+LRESULT CALLBACK MyWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(Msg)
+ {
+ case WM_CHAR:
+ if(wParam == 'q' || wParam == 'Q')
+ g_bQuadTextured = !g_bQuadTextured;
+ else if(wParam == 'c' || wParam == 'C')
+ g_bCylinderTextured = !g_bCylinderTextured;
+ else if(wParam == 'f' || wParam == 'F')
+ g_bFlagTextured = !g_bFlagTextured;
+ else
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+ }
+ return 0;
+}
+
+class MyWindow : public jsl::Window
+{
+public:
+ virtual HRESULT Initialize(HINSTANCE hInstance) //override to build window; end with "return Window::Initialize(hInstance);"
+ {
+ m_hInstance = hInstance;
+
+ ::ZeroMemory(&m_wc, sizeof(m_wc));
+ m_wc.cbSize = sizeof(WNDCLASSEX);
+ m_wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ m_wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ m_wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+ m_wc.hInstance = hInstance;
+ m_wc.lpfnWndProc = (WNDPROC)MyWndProc;
+ m_wc.lpszClassName = TEXT("MyWindowClass");
+ m_wc.style = CS_HREDRAW | CS_VREDRAW;
+
+ RegisterClassEx(&m_wc);
+
+ m_hWnd = CreateWindowEx(0, TEXT("MyWindowClass"), TEXT("Client test"), WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, hInstance, NULL);
+
+ ShowWindow(m_hWnd, 1);
+ UpdateWindow(m_hWnd);
+ return Window::Initialize(hInstance);
+ }
+};
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ CoInitializeEx(NULL, COINIT_MULTITHREADED);
+ DSDXRegisterComDll();
+
+ {
+ HRESULT hr = S_OK;
+
+ SmartRef<MyWindow> win;
+ win.Attach(new MyWindow);
+
+ win->Initialize(hInstance);
+ win->SetClientSize(800, 600);
+ win->CenterWindow();
+
+ SmartRef<jsl::DxDevice> d3d;
+ d3d.Attach(new jsl::DxDevice);
+ d3d->Initialize(hInstance, win->GetWindowHandle());
+ d3d->GetSwapChain(win->GetWindowHandle())->SetVSync(false);
+ IDirect3DDevice9* d3ddev = d3d->GetD3DDevice();
+
+ //d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);
+ //d3ddev->SetRenderState(D3DRS_ZENABLE, FALSE);
+ //d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE);
+ //d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
+ //d3ddev->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
+ Quad quad(d3ddev);
+ Cylinder cylinder(d3ddev);
+ Flag flag(d3ddev);
+
+ SmartPtr<ID3DXEffect> fx;
+ SmartPtr<ID3DXBuffer> errorBuffer;
+ if(FAILED(D3DXCreateEffectFromFile(d3ddev, TEXT("std.fx"), NULL, NULL, 0, NULL, &fx, &errorBuffer)))
+ {
+ if(errorBuffer != NULL)
+ MessageBoxA(NULL, (char*)errorBuffer->GetBufferPointer(), "Error", MB_OK);
+ goto End;
+ }
+
+ D3DXHANDLE hTechnique = fx->GetTechniqueByName("stdTech");
+ D3DXHANDLE hTexture = fx->GetParameterByName(0, "g_Texture");
+ D3DXHANDLE hWVP = fx->GetParameterByName(0, "g_WVP");
+
+ SmartPtr<IXAudio2> engine;
+#ifdef _DEBUG
+ hr = XAudio2Create(&engine, XAUDIO2_DEBUG_ENGINE);
+#else
+ hr = XAudio2Create(&engine, 0);
+#endif
+ if(FAILED(hr))
+ {
+ MessageBox(0, TEXT("Engine creation failed!"), TEXT("Error"), MB_OK);
+ goto End;
+ }
+
+ IXAudio2MasteringVoice* pMaster = NULL;
+ hr = engine->CreateMasteringVoice(&pMaster, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE);
+ if(FAILED(hr))
+ {
+ MessageBox(0, TEXT("Master creation failed!"), TEXT("Error"), MB_OK);
+ goto End;
+ }
+
+ engine->StartEngine();
+
+
+
+ //loading video 1
+ DSDXRenderers vid1;
+ hr = DSDXCreateVideoRenderer(&vid1.unknownLoader);
+ if(FAILED(hr))
+ goto End;
+ hr = vid1.unknownLoader->QueryInterface(IID_IDSDXVideoRenderer9, (void**)&vid1.vr9);
+ if(FAILED(hr))
+ goto End;
+ hr = DSDXCreateAudioRenderer(&vid1.unknownLoader);
+ if(FAILED(hr))
+ goto End;
+ hr = vid1.unknownLoader->QueryInterface(IID_IDSDXAudioRenderer, (void**)&vid1.ar);
+ if(FAILED(hr))
+ goto End;
+ vid1.vr9->Initialize(d3ddev);
+ vid1.ar->Initialize(engine);
+ hr = DSDXCreateGraphAndRenderAVI( _bstr_t("MOV000002.avi"), &vid1.control, &vid1.seek, (IDSDXVideoRenderer9*)vid1.vr9, (IDSDXAudioRenderer*)vid1.ar );
+ if(FAILED(hr))
+ goto End;
+ vid1.vr9->GetPresentationTexture(&vid1.pVideoTex);
+ vid1.ar->GetPresentationVoice(&vid1.pAudio);
+ vid1.control->Run();
+
+
+ //loading video 2
+ //DSDXRenderers vid2;
+ //hr = DSDXCreateVideoRenderer(&vid2.unknownLoader);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = vid2.unknownLoader->QueryInterface(IID_IDSDXVideoRenderer9, (void**)&vid2.vr9);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = DSDXCreateAudioRenderer(&vid2.unknownLoader);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = vid2.unknownLoader->QueryInterface(IID_IDSDXAudioRenderer, (void**)&vid2.ar);
+ //if(FAILED(hr))
+ // goto End;
+ //vid2.vr9->Initialize(d3ddev);
+ //vid2.ar->Initialize(engine);
+ //hr = DSDXCreateGraphAndRenderAVI( _bstr_t("Oblivion.avi"), &vid2.control, &vid2.seek, (IDSDXVideoRenderer9*)vid2.vr9, (IDSDXAudioRenderer*)vid2.ar );
+ //if(FAILED(hr))
+ // goto End;
+ //vid2.vr9->GetPresentationTexture(&vid2.pVideoTex);
+ //vid2.ar->GetPresentationVoice(&vid2.pAudio);
+ //vid2.control->Run();
+
+
+ //loading video 3
+ //DSDXRenderers vid3;
+ //hr = DSDXCreateVideoRenderer(&vid3.unknownLoader);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = vid3.unknownLoader->QueryInterface(IID_IDSDXVideoRenderer9, (void**)&vid3.vr9);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = DSDXCreateAudioRenderer(&vid3.unknownLoader);
+ //if(FAILED(hr))
+ // goto End;
+ //hr = vid3.unknownLoader->QueryInterface(IID_IDSDXAudioRenderer, (void**)&vid3.ar);
+ //if(FAILED(hr))
+ // goto End;
+ //vid3.vr9->Initialize(d3ddev);
+ //vid3.ar->Initialize(engine);
+ //hr = DSDXCreateGraphAndRenderAVI( _bstr_t("MOV000002.avi"), &vid3.control, &vid3.seek, (IDSDXVideoRenderer9*)vid3.vr9, (IDSDXAudioRenderer*)vid3.ar );
+ //if(FAILED(hr))
+ // goto End;
+ //vid3.vr9->GetPresentationTexture(&vid3.pVideoTex);
+ //vid3.ar->GetPresentationVoice(&vid3.pAudio);
+ //vid3.control->Run();
+
+ //SmartPtr<IUnknown> vrUnknown;
+ //hr = DSDXCreateVideoRenderer(&vrUnknown);
+ //if(FAILED(hr))
+ // goto End;
+
+ //SmartPtr<IDSDXVideoRenderer9> vr9;
+ //hr = vrUnknown->QueryInterface(IID_IDSDXVideoRenderer9, (void**)&vr9);
+ //if(FAILED(hr))
+ // goto End;
+
+ //vr9->Initialize(d3ddev);
+
+ //SmartPtr<IMediaControl> control;
+ //SmartPtr<IMediaSeeking> seek;
+
+ //SmartPtr<IUnknown> arUnknown;
+ //hr = DSDXCreateAudioRenderer(&arUnknown);
+ //if(FAILED(hr))
+ // goto End;
+
+ //SmartPtr<IDSDXAudioRenderer> ar;
+ //hr = arUnknown->QueryInterface(IID_IDSDXAudioRenderer, (void**)&ar);
+ //if(FAILED(hr))
+ //{
+ // MessageBox(0, TEXT("DSDXAudioRenderer creation failed!"), TEXT("Error"), MB_OK);
+ // goto End;
+ //}
+
+
+ //ar->Initialize(engine);
+
+ //hr = DSDXCreateGraphAndRenderAVI( _bstr_t("TankUniversal.avi"), &control, &seek, (IDSDXVideoRenderer9*)vr9, (IDSDXAudioRenderer*)ar );
+ //if(FAILED(hr))
+ //{
+ // MessageBox(0, TEXT("Graph failed!"), TEXT("Error"), MB_OK);
+ // pMaster->DestroyVoice();
+ // goto End;
+ //}
+
+ //IXAudio2SubmixVoice* pSubmix = NULL;
+ //ar->GetPresentationVoice(&pSubmix);
+ //pSubmix->SetVolume(.15f);
+
+ //control->Run();
+
+ MSG msg;
+ SmartPtr<IDirect3DTexture9> testTexture;
+ hr = ::D3DXCreateTexture(d3ddev, 2, 2, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &testTexture);
+ if(FAILED(hr))
+ {
+ pMaster->DestroyVoice();
+ goto End;
+ }
+ D3DLOCKED_RECT lockedRect;
+ testTexture->LockRect(0, &lockedRect, 0, 0);
+ ((DWORD*)lockedRect.pBits)[0] = 0xffff77ff;
+ ((DWORD*)lockedRect.pBits)[1] = 0xff77ffff;
+ ((DWORD*)lockedRect.pBits)[2] = 0xffffff77;
+ ((DWORD*)lockedRect.pBits)[3] = 0xff7777ff;
+ testTexture->UnlockRect(0);
+
+ //IDirect3DTexture9* pTexture = NULL;
+ //SmartPtr<IDirect3DTexture9> stretchedVideo;
+ //hr = ::D3DXCreateTexture(d3ddev, 64, 64, 0, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &stretchedVideo);
+
+ D3DXMATRIX matTranslation, matRotationX, matRotationY, matRotationZ, matScale, matWorld, matView, matProjection;
+ ::D3DXMatrixPerspectiveFovLH(&matProjection, D3DX_PI / 4.0f, 800.0f/600.0f, 1.0f, 1000.0f);
+ ::D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(0, 0, -25), &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,1,0));
+ float theta = 0.0f;
+ //IDirect3DSurface9* pSurface = NULL;
+ //SmartPtr<IDirect3DSurface9> pBackbuffer;
+ //d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackbuffer);
+ while(true)
+ {
+ if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ if(msg.message == WM_QUIT)
+ {
+ g_bQuitting = TRUE;
+ break;
+ }
+ }
+ else
+ {
+
+ //LONGLONG t1, t2;
+ //hr = vid1.seek->GetPositions(&t1, &t2);
+ //if((t2-t1) < 10)
+ //{
+ // t1 = 0;
+ // t2 = 0;
+ // hr = vid1.seek->SetPositions(&t1, AM_SEEKING_AbsolutePositioning, &t2, AM_SEEKING_RelativePositioning);
+ //}
+ //hr = vid2.seek->GetPositions(&t1, &t2);
+ //if((t2-t1) < 10)
+ //{
+ // t1 = 0;
+ // t2 = 0;
+ // hr = vid2.seek->SetPositions(&t1, AM_SEEKING_AbsolutePositioning, &t2, AM_SEEKING_RelativePositioning);
+ //}
+
+ d3ddev->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
+ //vr9->GetPresentationTexture(&pTexture);
+ //if(pTexture != NULL)
+ //{
+ // SmartPtr<IDirect3DSurface9> srcSurface, destSurface;
+ // pTexture->GetSurfaceLevel(0, &srcSurface);
+ // stretchedVideo->GetSurfaceLevel(0, &destSurface);
+ // hr = d3ddev->StretchRect(srcSurface, NULL, destSurface, NULL, D3DTEXF_LINEAR);
+ //}
+ d3ddev->BeginScene();
+
+ //vr9->Present();
+ vid1.vr9->Present();
+ //vid2.vr9->Present();
+ //vid3.vr9->Present();
+
+
+ UINT nPasses = 0;
+
+ //Quad
+ D3DXMatrixScaling(&matScale, 1, 1, 1);
+ D3DXMatrixRotationY(&matRotationX, theta * .5f);
+ D3DXMatrixRotationY(&matRotationY, theta * .1f);
+ D3DXMatrixTranslation(&matTranslation, 6, 3, -6);
+ matWorld = matScale * matRotationX * matTranslation * matRotationY;
+
+ hr = d3ddev->SetVertexDeclaration(quad.GetDeclaration());
+ hr = d3ddev->SetStreamSource(0, quad.GetVertexBuffer(), 0, sizeof(ShapeLayout));
+ hr = d3ddev->SetIndices(quad.GetIndexBuffer());
+
+ hr = fx->SetTexture(hTexture, g_bQuadTextured ? vid1.pVideoTex : (IDirect3DTexture9*)testTexture);
+ hr = fx->SetTechnique(hTechnique);
+ hr = fx->Begin(&nPasses, 0);
+ hr = fx->SetMatrix(hWVP, &(matWorld*matView*matProjection));
+ hr = fx->CommitChanges();
+ for(int i = 0; i < nPasses; i++)
+ {
+ hr = fx->BeginPass(i);
+ hr = d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, quad.GetVertNumber(), 0, quad.GetPrimCount());
+ hr = fx->EndPass();
+ }
+ hr = fx->End();
+
+ //Cylinder
+ D3DXMatrixRotationZ(&matRotationZ, theta * .2f);
+ D3DXMatrixScaling(&matScale, 1, 1, 3);
+ D3DXMatrixRotationX(&matRotationX, D3DX_PI / 6.0f);
+ D3DXMatrixRotationY(&matRotationY, theta * .1f);
+ D3DXMatrixTranslation(&matTranslation, 0, 0, -6);
+ matWorld = matScale * matRotationZ * matRotationX * matRotationY * matTranslation;
+
+ hr = d3ddev->SetVertexDeclaration(cylinder.GetDeclaration());
+ hr = d3ddev->SetStreamSource(0, cylinder.GetVertexBuffer(), 0, sizeof(ShapeLayout));
+ hr = d3ddev->SetIndices(cylinder.GetIndexBuffer());
+
+ hr = fx->SetTexture(hTexture, g_bCylinderTextured ? vid1.pVideoTex : (IDirect3DTexture9*)testTexture);
+ hr = fx->SetTechnique(hTechnique);
+ hr = fx->Begin(&nPasses, 0);
+ hr = fx->SetMatrix(hWVP, &(matWorld*matView*matProjection));
+ hr = fx->CommitChanges();
+ for(int i = 0; i < nPasses; i++)
+ {
+ hr = fx->BeginPass(i);
+ hr = d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, cylinder.GetVertNumber(), 0, cylinder.GetPrimCount());
+ hr = fx->EndPass();
+ }
+ hr = fx->End();
+
+ //Flag
+ flag.Animate(.01f);
+
+ D3DXMatrixScaling(&matScale, .9, .9, 1);
+ D3DXMatrixRotationX(&matRotationX, D3DX_PI);
+ D3DXMatrixRotationY(&matRotationY, 0.0f);
+ D3DXMatrixTranslation(&matTranslation, -8, -10, 30);
+ matWorld = matScale * matRotationX * matRotationY * matTranslation;
+
+ hr = d3ddev->SetVertexDeclaration(flag.GetDeclaration());
+ hr = d3ddev->SetStreamSource(0, flag.GetVertexBuffer(), 0, sizeof(ShapeLayout));
+ hr = d3ddev->SetIndices(flag.GetIndexBuffer());
+
+ hr = fx->SetTexture(hTexture, g_bFlagTextured ? vid1.pVideoTex : (IDirect3DTexture9*)testTexture);
+ hr = fx->SetTechnique(hTechnique);
+ hr = fx->Begin(&nPasses, 0);
+ hr = fx->SetMatrix(hWVP, &(matWorld*matView*matProjection));
+ hr = fx->CommitChanges();
+ for(int i = 0; i < nPasses; i++)
+ {
+ hr = fx->BeginPass(i);
+ hr = d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, flag.GetVertNumber(), 0, flag.GetPrimCount());
+ hr = fx->EndPass();
+ }
+ hr = fx->End();
+
+ hr = d3ddev->EndScene();
+ hr = d3ddev->Present(0,0,0,0);
+
+ theta += .1f;
+ }
+ }
+
+
+ engine->StopEngine();
+ vid1.ar->OnCriticalError();
+ //vid2.ar->OnCriticalError();
+ //vid3.ar->OnCriticalError();
+ //ar->OnCriticalError();
+ pMaster->DestroyVoice();
+ }
+
+End:
+ DSDXUnregisterComDll();
+ CoUninitialize();
+ return 0;
+}
\ No newline at end of file
Added: ClientTestExe/demo shapes.cpp
===================================================================
--- ClientTestExe/demo shapes.cpp (rev 0)
+++ ClientTestExe/demo shapes.cpp 2010-07-16 16:40:40 UTC (rev 2)
@@ -0,0 +1,422 @@
+#include "demo shapes.h"
+
+IDirect3DDevice9* Shape::s_d3ddev = NULL;
+SmartPtr<IDirect3DVertexDeclaration9> Shape::s_vertDecl;
+BOOL Shape::s_bInitialized = FALSE;
+BOOL Shape::s_bLostDevice = FALSE;
+
+void Shape::Initialize(IDirect3DDevice9 *device)
+{
+ if(s_bInitialized)
+ return;
+ s_d3ddev = device;
+
+ //setting to lost device so that OnResetDevice_Static() executes
+ //it clears lost device state anyway
+ s_bLostDevice = TRUE;
+ OnResetDevice_Static();
+
+ if(s_vertDecl == NULL)
+ return;
+ s_bInitialized = TRUE;
+}
+
+void Shape::OnLostDevice_Static()
+{
+ s_vertDecl = NULL;
+ s_bLostDevice = TRUE;
+}
+
+void Shape::OnResetDevice_Static()
+{
+ if(!s_bLostDevice)
+ return;
+ s_bLostDevice = FALSE;
+
+ if(s_d3ddev == NULL)
+ return;
+
+ D3DVERTEXELEMENT9 vertElem[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 3*sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
+ D3DDECL_END(),
+ };
+
+ if(FAILED(s_d3ddev->CreateVertexDeclaration(vertElem, &s_vertDecl)))
+ return;
+}
+
+IDirect3DDevice9* Shape::GetDevice()
+{
+ return s_d3ddev;
+}
+
+IDirect3DVertexDeclaration9* Shape::GetDeclaration()
+{
+ return s_vertDecl;
+}
+
+Shape::Shape(IDirect3DDevice9 *d3ddevice) : m_bShapeCreated(FALSE)
+{
+ Initialize(d3ddevice);
+}
+
+Shape::~Shape()
+{
+}
+
+void Shape::Animate(float dt)
+{
+}
+
+void Shape::CreateShape()
+{
+}
+
+void Shape::DestroyShape()
+{
+}
+
+UINT Shape::GetVertNumber()
+{
+ return 0;
+}
+
+UINT Shape::GetPrimCount()
+{
+ return 0;
+}
+
+void Shape::OnLostDevice()
+{
+ OnLostDevice_Static();
+}
+
+void Shape::OnResetDevice()
+{
+ OnResetDevice_Static();
+}
+
+IDirect3DVertexBuffer9* Shape::GetVertexBuffer()
+{
+ return m_vert;
+}
+
+IDirect3DIndexBuffer9* Shape::GetIndexBuffer()
+{
+ return m_index;
+}
+
+
+
+//Quad
+
+Quad::Quad(IDirect3DDevice9 *d3ddev) : Shape(d3ddev)
+{
+ CreateShape();
+}
+
+Quad::~Quad()
+{
+ DestroyShape();
+}
+
+void Quad::CreateShape()
+{
+ if(s_bInitialized && !s_bLostDevice)
+ {
+ HRESULT hr = S_OK;
+
+ ShapeLayout layout[] =
+ {
+ ShapeLayout(-1.0f, 1.0f, 0.0f, 0.0f, 1.0f),
+ ShapeLayout(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f),
+ ShapeLayout(1.0f, 1.0f, 0.0f, 1.0f, 1.0f),
+ ShapeLayout(1.0f, -1.0f, 0.0f, 1.0f, 0.0f),
+ };
+ int nVertices = sizeof(layout) / sizeof(layout[0]);
+
+ WORD index[] =
+ {
+ 0, 2, 1,
+ 1, 2, 3,
+ 3, 2, 1,
+ 1, 2, 0,
+ };
+ int nIndices = sizeof(index) / sizeof(index[0]);
+
+ hr = s_d3ddev->CreateVertexBuffer(nVertices*sizeof(ShapeLayout), 0, 0, D3DPOOL_MANAGED, &m_vert, NULL);
+ if(FAILED(hr))
+ return;
+
+ ShapeLayout* pVertData = NULL;
+ hr = m_vert->Lock(0, 0, (void**)&pVertData, 0);
+ if(FAILED(hr))
+ return;
+ memcpy_s((void*)pVertData, nVertices*sizeof(ShapeLayout), (void*)layout, nVertices*sizeof(ShapeLayout));
+ m_vert->Unlock();
+
+ hr = s_d3ddev->CreateIndexBuffer(nIndices*sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_index, NULL);
+ if(FAILED(hr))
+ return;
+
+ WORD* pIndexData = NULL;
+ hr = m_index->Lock(0, 0, (void**)&pIndexData, 0);
+ if(FAILED(hr))
+ return;
+ memcpy_s((void*)pIndexData, nIndices*sizeof(WORD), (void*)index, nIndices*sizeof(WORD));
+ m_index->Unlock();
+
+ m_bShapeCreated = TRUE;
+ }
+}
+
+void Quad::DestroyShape()
+{
+ m_bShapeCreated = FALSE;
+
+ m_vert = NULL;
+ m_index = NULL;
+}
+
+UINT Quad::GetVertNumber()
+{
+ return 4;
+}
+
+UINT Quad::GetPrimCount()
+{
+ return 2*2;
+}
+
+
+//Cylinder
+Cylinder::Cylinder(IDirect3DDevice9 *d3ddev) : Shape(d3ddev)
+{
+ CreateShape();
+}
+
+Cylinder::~Cylinder()
+{
+ DestroyShape();
+}
+
+void Cylinder::CreateShape()
+{
+ if(s_bInitialized && !s_bLostDevice)
+ {
+ ShapeLayout layout[CYLINDER_VERT_COUNT];
+ int nVertices = sizeof(layout) / sizeof(layout[0]);
+
+ for(int i = 0; i < nVertices/2; i++)
+ layout[i] = ShapeLayout( cos( (float)i / (float)(nVertices/2-1) * (2*D3DX_PI) ), sin( (float)i / (float)(nVertices/2-1) * (2*D3DX_PI) ),
+ -1.0f, 0.0f, (float)i / (float)(nVertices/2-1) );
+
+ for(int i = nVertices/2; i < nVertices; i++)
+ layout[i] = ShapeLayout( cos( (float)(i-nVertices/2) / (float)(nVertices/2-1) * (2*D3DX_PI) ), sin( (float)(i-nVertices/2) / (float)(nVertices/2-1) * (2*D3DX_PI) ),
+ 1.0f, 1.0f, (float)(i-nVertices/2) / (float)(nVertices/2-1) );
+
+ WORD index[3*2*2*CYLINDER_VERT_COUNT];
+ int nIndices = sizeof(index) / sizeof(index[0]);
+ int indexPosition = 0;
+ for(int i = 0; i < nVertices/2; i++)
+ {
+ index[indexPosition+0] = i + 0;
+ index[indexPosition+1] = i + 1;
+ index[indexPosition+2] = i + 0 + nVertices/2;
+ index[indexPosition+3] = i + 0 + nVertices/2;
+ index[indexPosition+4] = i + 1;
+ index[indexPosition+5] = i + 1 + nVertices/2;
+ indexPosition += 6;
+ }
+ for(int i = 0; i < nVertices/2; i++)
+ {
+ index[indexPosition+0] = i + 1 + nVertices/2;
+ index[indexPosition+1] = i + 1;
+ index[indexPosition+2] = i + 0 + nVertices/2;
+ index[indexPosition+3] = i + 0 + nVertices/2;
+ index[indexPosition+4] = i + 1;
+ index[indexPosition+5] = i + 0;
+ indexPosition += 6;
+ }
+
+ if(FAILED( s_d3ddev->CreateVertexBuffer(nVertices*sizeof(ShapeLayout), 0, 0, D3DPOOL_MANAGED, &m_vert, NULL) ))
+ return;
+
+ ShapeLayout* pVertData = NULL;
+ if(FAILED( m_vert->Lock(0, 0, (void**)&pVertData, 0) ))
+ return;
+ memcpy_s((void*)pVertData, nVertices*sizeof(ShapeLayout), (void*)layout, nVertices*sizeof(ShapeLayout));
+ m_vert->Unlock();
+
+ if(FAILED( s_d3ddev->CreateIndexBuffer(nIndices*sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_index, NULL) ))
+ return;
+
+ WORD* pIndexData = NULL;
+ if(FAILED( m_index->Lock(0, 0, (void**)&pIndexData, 0) ))
+ return;
+ memcpy_s((void*)pIndexData, nIndices*sizeof(WORD), (void*)index, nIndices*sizeof(WORD));
+ m_index->Unlock();
+
+ m_bShapeCreated = TRUE;
+ }
+}
+
+void Cylinder::DestroyShape()
+{
+ m_bShapeCreated = FALSE;
+
+ m_vert = NULL;
+ m_index = NULL;
+}
+
+UINT Cylinder::GetVertNumber()
+{
+ return CYLINDER_VERT_COUNT;
+}
+
+UINT Cylinder::GetPrimCount()
+{
+ return CYLINDER_VERT_COUNT*2;
+}
+
+
+//Sphere
+Flag::Flag(IDirect3DDevice9 *d3ddev) : Shape(d3ddev), m_time(1.0f)
+{
+ CreateShape();
+}
+
+Flag::~Flag()
+{
+ DestroyShape();
+}
+
+void Flag::Animate(float dt)
+{
+ m_time += dt;
+
+ for(int j = 1; j < FLAG_VERT_WIDTH; j++)
+ {
+ float wMag = (float)j / (float)(FLAG_VERT_WIDTH-1);
+ for(int i = 0; i < FLAG_VERT_HEIGHT; i++)
+ {
+ m_grid[i*FLAG_VERT_WIDTH + j].z =
+ wMag * cos(FLAG_PHASE_SHIFT * 2.0f*D3DX_PI * (m_time + wMag))
+ + m_grid[i*FLAG_VERT_WIDTH + j-1].z;
+ m_grid[i*FLAG_VERT_WIDTH + j].x =
+ acos(m_grid[i*FLAG_VERT_WIDTH + j-1].z - m_grid[i*FLAG_VERT_WIDTH + j].z)
+ + m_grid[i*FLAG_VERT_WIDTH + j-1].x;
+ }
+ }
+
+ if(s_bInitialized && !s_bLostDevice && m_bShapeCreated)
+ {
+ ShapeLayout* pVertData = NULL;
+ if(FAILED( m_vert->Lock(0, 0, (void**)&pVertData, 0) ))
+ return;
+ memcpy_s((void*)pVertData, FLAG_VERT_COUNT*sizeof(ShapeLayout), (void*)m_grid, FLAG_VERT_COUNT*sizeof(ShapeLayout));
+ m_vert->Unlock();
+ }
+}
+
+void Flag::CreateShape()
+{
+ if(s_bInitialized && !s_bLostDevice)
+ {
+ ShapeLayout layout[FLAG_VERT_COUNT];
+ int nVertices = sizeof(layout) / sizeof(layout[0]);
+
+ for(int i = 0; i < FLAG_VERT_HEIGHT; i++)
+ for(int j = 0; j < FLAG_VERT_WIDTH; j++)
+ layout[i*FLAG_VERT_WIDTH + j] = ShapeLayout( j - FLAG_VERT_WIDTH/2,
+ i - FLAG_VERT_HEIGHT/2,
+ 0.0f,
+ 2.0f * (float)j / (float)FLAG_VERT_WIDTH,
+ 2.0f * (1.0f - (float)i / (float)FLAG_VERT_HEIGHT));
+
+ memcpy_s((void*)m_grid, nVertices*sizeof(ShapeLayout), (void*)layout, nVertices*sizeof(ShapeLayout));
+
+ WORD index[3*2*2*(FLAG_VERT_WIDTH-1)*(FLAG_VERT_HEIGHT-1)];
+ int nIndices = sizeof(index) / sizeof(index[0]);
+
+ int indexPosition = 0;
+ for(int i = 0; i < FLAG_VERT_HEIGHT-1; i++)
+ {
+ for(int j = 0; j < FLAG_VERT_WIDTH-1; j++)
+ {
+ index[indexPosition+0] = (i+0)*FLAG_VERT_WIDTH + (j+0);
+ index[indexPosition+1] = (i+1)*FLAG_VERT_WIDTH + (j+0);
+ index[indexPosition+2] = (i+0)*FLAG_VERT_WIDTH + (j+1);
...
[truncated message content] |
|
From: <jte...@us...> - 2010-07-13 06:45:58
|
Revision: 1
http://dsdxlibrary.svn.sourceforge.net/dsdxlibrary/?rev=1&view=rev
Author: jtennant
Date: 2010-07-13 06:45:52 +0000 (Tue, 13 Jul 2010)
Log Message:
-----------
Empty folder setup.
Added Paths:
-----------
AudioRendererDll/
ClientTestExe/
HelperLib/
VideoRendererDll/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|