add RageMovieTextureHelper

This commit is contained in:
Glenn Maynard
2002-12-20 06:31:01 +00:00
parent b3508e02cf
commit 7aebbffedc
4 changed files with 169 additions and 21 deletions
+85
View File
@@ -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;
}
+46
View File
@@ -0,0 +1,46 @@
#ifndef RAGEMOVIETEXTURE_HELPER_H
#define RAGEMOVIETEXTURE_HELPER_H
// #include <windows.h>
// #include <atlbase.h>
//#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
+28 -20
View File
@@ -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
+10 -1
View File
@@ -686,6 +686,9 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
<File
RelativePath=".\StepMania.RC">
</File>
<File
RelativePath="archutils\Win32\arch_setup.h">
</File>
<File
RelativePath=".\resource.h">
</File>
@@ -1124,7 +1127,13 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
RelativePath="RageMovieTexture.cpp">
</File>
<File
RelativePath=".\RageMovieTexture.h">
RelativePath="RageMovieTexture.h">
</File>
<File
RelativePath="RageMovieTextureHelper.cpp">
</File>
<File
RelativePath="RageMovieTextureHelper.h">
</File>
<File
RelativePath=".\RageMusic.cpp">