Added a null movie class that simply displays a black background instead of a movie.
This commit is contained in:
@@ -2,9 +2,15 @@
|
|||||||
#include "MovieTexture.h"
|
#include "MovieTexture.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
#include "MovieTexture_null.h"
|
||||||
|
|
||||||
|
/* Why is this _WINDOWS and not WIN32?
|
||||||
|
* --steve */
|
||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
#include "MovieTexture_DShow.h"
|
#include "MovieTexture_DShow.h"
|
||||||
|
#define DEFAULT_MOVIE_DRIVER_LIST "DShow"
|
||||||
|
#else
|
||||||
|
#define DEFAULT_MOVIE_DRIVER_LIST "Null"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -59,16 +65,33 @@ static void DumpAVIDebugInfo( CString fn )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Try drivers in order of preference until we find one that works. */
|
/* 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)
|
RageMovieTexture *MakeRageMovieTexture(RageTextureID ID)
|
||||||
{
|
{
|
||||||
DumpAVIDebugInfo( ID.filename );
|
DumpAVIDebugInfo( ID.filename );
|
||||||
|
|
||||||
#if defined(_WINDOWS)
|
CStringArray DriversToTry;
|
||||||
return new MovieTexture_DShow(ID);
|
split(DEFAULT_MOVIE_DRIVER_LIST, ",", DriversToTry, true);
|
||||||
#else
|
ASSERT(DriversToTry.size() != 0);
|
||||||
/* XXX: need a simple null movie texture object */
|
|
||||||
RageException::Throw("xxx");
|
CString Driver;
|
||||||
|
RageMovieTexture *ret = NULL;
|
||||||
|
|
||||||
|
for (unsigned i=0; ret==NULL && i<DriversToTry.size(); ++i) {
|
||||||
|
try {
|
||||||
|
Driver = DriversToTry[i];
|
||||||
|
LOG->Trace("Initializing driver: %s", Driver.c_str());
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
if (!Driver.CompareNoCase("DShow")) ret = new MovieTexture_DShow(ID);
|
||||||
#endif
|
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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 */
|
||||||
Reference in New Issue
Block a user