diff --git a/stepmania/src/arch/MovieTexture/MovieTexture.cpp b/stepmania/src/arch/MovieTexture/MovieTexture.cpp index 00d935da6f..939851fb35 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture.cpp @@ -2,9 +2,15 @@ #include "MovieTexture.h" #include "RageUtil.h" #include "RageLog.h" +#include "MovieTexture_null.h" +/* Why is this _WINDOWS and not WIN32? + * --steve */ #if defined(_WINDOWS) #include "MovieTexture_DShow.h" +#define DEFAULT_MOVIE_DRIVER_LIST "DShow" +#else +#define DEFAULT_MOVIE_DRIVER_LIST "Null" #endif #include @@ -59,16 +65,33 @@ static void DumpAVIDebugInfo( CString fn ) } /* Try drivers in order of preference until we find one that works. */ -/* Well, eventually; for now it's DShow or bust.w */ RageMovieTexture *MakeRageMovieTexture(RageTextureID ID) { DumpAVIDebugInfo( ID.filename ); -#if defined(_WINDOWS) - return new MovieTexture_DShow(ID); -#else - /* XXX: need a simple null movie texture object */ - RageException::Throw("xxx"); + CStringArray DriversToTry; + split(DEFAULT_MOVIE_DRIVER_LIST, ",", DriversToTry, true); + ASSERT(DriversToTry.size() != 0); + + CString Driver; + RageMovieTexture *ret = NULL; + + for (unsigned i=0; ret==NULL && iTrace("Initializing driver: %s", Driver.c_str()); +#ifdef _WINDOWS + if (!Driver.CompareNoCase("DShow")) ret = new MovieTexture_DShow(ID); #endif + if (!Driver.CompareNoCase("Null")) ret = new MovieTexture_Null(ID); + if (!ret) + LOG->Warn("Unknown movie driver name: %s", Driver.c_str()); + } catch (const RageException &e) { + LOG->Info("Couldn't load driver %s: %s", Driver.c_str(), e.what()); + } + } + if (!ret) + RageException::Throw("Couldn't create a movie texture"); + return ret; } diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp new file mode 100644 index 0000000000..277a6c3975 --- /dev/null +++ b/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp @@ -0,0 +1,71 @@ +/* + * MovieTexture_null.cpp + * stepmania + * + * Created by Steve Checkoway on Wed Jul 16 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#include "global.h" +#include "RageDisplay.h" +#include "RageTextureManager.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "RageException.h" +#include "MovieTexture_null.h" +#include "SDL_utils.h" + +MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID) { + LOG->Trace("MovieTexture_Null::MovieTexture_Null(ID)"); + texHandle = 0; + + RageTextureID actualID = GetID(); + + actualID.iAlphaBits = 0; + long size = actualID.iMaxSize = min(actualID.iMaxSize, DISPLAY->GetMaxTextureSize()); + m_iSourceWidth = size; + m_iSourceHeight = size; + m_iImageWidth = size; + m_iImageHeight = size; + m_iTextureWidth = power_of_two(size); + m_iTextureHeight = m_iTextureWidth; + m_iFramesWide = 1; + m_iFramesHigh = 1; + + CreateFrameRects(); + + PixelFormat pixfmt; + + switch( TEXTUREMAN->GetMovieColorDepth() ){ + default: + ASSERT(0); + case 16: + if( DISPLAY->SupportsTextureFormat(FMT_RGB5) ) + pixfmt = FMT_RGB5; + else + pixfmt = FMT_RGBA4; // everything supports RGBA4 + break; + case 32: + if( DISPLAY->SupportsTextureFormat(FMT_RGB8) ) + pixfmt = FMT_RGB8; + else if( DISPLAY->SupportsTextureFormat(FMT_RGBA8) ) + pixfmt = FMT_RGBA8; + else if( DISPLAY->SupportsTextureFormat(FMT_RGB5) ) + pixfmt = FMT_RGB5; + else + pixfmt = FMT_RGBA4; // everything supports RGBA4 + break; + } + + const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); + SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, size, size, pfd->bpp, pfd->masks[0], + pfd->masks[1], pfd->masks[2], pfd->masks[3]); + texHandle = DISPLAY->CreateTexture(pixfmt, img); + //DISPLAY->UpdateTexture(texHandle, img, 0, 0, size, size); + SDL_FreeSurface(img); +} + +MovieTexture_Null::~MovieTexture_Null() { + DISPLAY->DeleteTexture(texHandle); +} \ No newline at end of file diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_Null.h b/stepmania/src/arch/MovieTexture/MovieTexture_Null.h new file mode 100644 index 0000000000..f8cccea9c2 --- /dev/null +++ b/stepmania/src/arch/MovieTexture/MovieTexture_Null.h @@ -0,0 +1,37 @@ +#ifndef MOVIE_TEXTURE_NULL +#define MOVIE_TEXTURE_NULL +/* + * MovieTexture_null.h + * stepmania + * + * Created by Steve Checkoway on Wed Jul 16 2003. + * Copyright (c) 2003 Steve Checkoway. All rights reserved. + * + */ + +#include "MovieTexture.h" +#include "RageTexture.h" + +class MovieTexture_Null : public RageMovieTexture { +private: + bool playing; + bool loop; + unsigned texHandle; + +public: + MovieTexture_Null(RageTextureID ID); + virtual ~MovieTexture_Null(); + void Invalidate() { texHandle = 0; } + unsigned GetTexHandle() const { return texHandle; } + void Update(float delta) { } + void Reload() { } + void Play() { playing = true; } + void Pause() { playing = false; } + void Stop() { playing = false; } + void SetPosition(float seconds) { } + void SetPlaybackRate(float rate) { } + bool IsPlaying() const { return playing; } + void SetLooping(bool looping=true) { loop = looping; } +}; + +#endif /* MOVIE_TEXTURE_NULL */