From 7aebbffedcb03e3a82ed31630e509645d365231d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 20 Dec 2002 06:31:01 +0000 Subject: [PATCH] add RageMovieTextureHelper --- stepmania/src/RageMovieTextureHelper.cpp | 85 ++++++++++++++++++++++++ stepmania/src/RageMovieTextureHelper.h | 46 +++++++++++++ stepmania/src/StepMania.dsp | 48 +++++++------ stepmania/src/StepMania.vcproj | 11 ++- 4 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 stepmania/src/RageMovieTextureHelper.cpp create mode 100644 stepmania/src/RageMovieTextureHelper.h diff --git a/stepmania/src/RageMovieTextureHelper.cpp b/stepmania/src/RageMovieTextureHelper.cpp new file mode 100644 index 0000000000..c146bd5506 --- /dev/null +++ b/stepmania/src/RageMovieTextureHelper.cpp @@ -0,0 +1,85 @@ +#include "stdafx.h" +#include "RageMovieTextureHelper.h" +#include "RageUtil.h" +#include "RageLog.h" + +//----------------------------------------------------------------------------- +// Define GUID for Texture Renderer +// {71771540-2017-11cf-AE26-0020AFD79767} +//----------------------------------------------------------------------------- +struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureRenderer; + +static HRESULT CBV_ret; +CTextureRenderer::CTextureRenderer() + : CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer), + NAME("Texture Renderer"), NULL, &CBV_ret) +{ + if( FAILED(CBV_ret) ) + throw RageException( hr_ssprintf(CBV_ret, "Could not create texture renderer object!") ); + + // Store and ARageef the texture for our use. + m_pTexture = NULL; +} + +CTextureRenderer::~CTextureRenderer() +{ + // Do nothing +} + + +HRESULT CTextureRenderer::CheckMediaType(const CMediaType *pmt) +{ + VIDEOINFO *pvi; + + // Reject the connection if this is not a video type + if( *pmt->FormatType() != FORMAT_VideoInfo ) + return E_INVALIDARG; + + // Force the graph to R8G8B8. + pvi = (VIDEOINFO *)pmt->Format(); + if(IsEqualGUID( *pmt->Type(), MEDIATYPE_Video) && + IsEqualGUID( *pmt->Subtype(), MEDIASUBTYPE_RGB24)) + return S_OK; + + return E_FAIL; +} + + +// SetMediaType: Graph connection has been made. +HRESULT CTextureRenderer::SetMediaType(const CMediaType *pmt) +{ + // Retrive the size of this media type + VIDEOINFO *pviBmp; // Bitmap info header + pviBmp = (VIDEOINFO *)pmt->Format(); + m_lVidWidth = pviBmp->bmiHeader.biWidth; + m_lVidHeight = abs(pviBmp->bmiHeader.biHeight); + m_lVidPitch = (m_lVidWidth * 3 + 3); // We are forcing RGB24 + + return S_OK; +} + + +void CTextureRenderer::SetRenderTarget( RageMovieTexture* pTexture ) +{ + m_pTexture = pTexture; +} + +// DoRenderSample: A sample has been delivered. Copy it. +HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample ) +{ + if( m_pTexture == NULL ) + { + LOG->Warn( "DoRenderSample called while m_pTexture was NULL!" ); + return S_OK; + } + + BYTE *pBmpBuffer; // Bitmap buffer + + // Get the video bitmap buffer + pSample->GetPointer( &pBmpBuffer ); + + // Copy the bits + m_pTexture->NewData((char *) pBmpBuffer); + + return S_OK; +} diff --git a/stepmania/src/RageMovieTextureHelper.h b/stepmania/src/RageMovieTextureHelper.h new file mode 100644 index 0000000000..ecd4acd763 --- /dev/null +++ b/stepmania/src/RageMovieTextureHelper.h @@ -0,0 +1,46 @@ +#ifndef RAGEMOVIETEXTURE_HELPER_H +#define RAGEMOVIETEXTURE_HELPER_H + + +// #include +// #include + +//#include "baseclasses/streams.h" +#include "RageMovieTexture.h" + +//----------------------------------------------------------------------------- +// CTextureRenderer Class Declarations +// +// Usage: 1) CheckMediaType is called by the graph +// 2) SetMediaType is called by the graph +// 3) call GetVidWidth and GetVidHeight to get texture information +// 4) call SetRenderTarget +// 5) Do RenderSample is called by the graph +//----------------------------------------------------------------------------- +class CTextureRenderer : public CBaseVideoRenderer +{ +public: + CTextureRenderer(); + ~CTextureRenderer(); + + // overridden methods + HRESULT CheckMediaType(const CMediaType *pmt ); // Format acceptable? + HRESULT SetMediaType(const CMediaType *pmt ); // Video format notification + HRESULT DoRenderSample(IMediaSample *pMediaSample); // New video sample + + // new methods + long GetVidWidth() const { return m_lVidWidth; } + long GetVidHeight() const { return m_lVidHeight; } + void SetRenderTarget( RageMovieTexture* pTexture ); + +protected: + // Video width, height, and pitch. + long m_lVidWidth, m_lVidHeight, m_lVidPitch; + + char *output; + + RageMovieTexture* m_pTexture; // the video surface we will copy new frames to +// D3DFORMAT m_TextureFormat; // Texture format +}; + +#endif diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index ff7fa4a324..ba681c1610 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -60,7 +60,7 @@ IntDir=.\../Release6 TargetDir=\temp\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -95,7 +95,7 @@ IntDir=.\../Debug6 TargetDir=\temp\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -113,27 +113,11 @@ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania # PROP Default_Filter "" # Begin Source File -SOURCE=.\RageSound.cpp +SOURCE=.\RageMovieTextureHelper.cpp # End Source File # Begin Source File -SOURCE=.\RageSound.h -# End Source File -# Begin Source File - -SOURCE=.\RageSoundManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\RageSoundManager.h -# End Source File -# Begin Source File - -SOURCE=.\RageThreads.cpp -# End Source File -# Begin Source File - -SOURCE=.\RageThreads.h +SOURCE=.\RageMovieTextureHelper.h # End Source File # Begin Source File @@ -243,6 +227,14 @@ SOURCE=.\RageNetworkClient.h # End Source File # Begin Source File +SOURCE=.\RageSound.cpp +# End Source File +# Begin Source File + +SOURCE=.\RageSound.h +# End Source File +# Begin Source File + SOURCE=.\RageSoundBass.cpp # End Source File # Begin Source File @@ -251,6 +243,14 @@ SOURCE=.\RageSoundBass.h # End Source File # Begin Source File +SOURCE=.\RageSoundManager.cpp +# End Source File +# Begin Source File + +SOURCE=.\RageSoundManager.h +# End Source File +# Begin Source File + SOURCE=.\RageSoundSample.cpp # End Source File # Begin Source File @@ -283,6 +283,14 @@ SOURCE=.\RageTextureManager.h # End Source File # Begin Source File +SOURCE=.\RageThreads.cpp +# End Source File +# Begin Source File + +SOURCE=.\RageThreads.h +# End Source File +# Begin Source File + SOURCE=.\RageTimer.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index d246a42b52..61f1e4f41f 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -686,6 +686,9 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ + + @@ -1124,7 +1127,13 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ RelativePath="RageMovieTexture.cpp"> + RelativePath="RageMovieTexture.h"> + + + +