*
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#ifndef IVideoTexture_h__
|
||||
#define IVideoTexture_h__
|
||||
|
||||
#include "render/ITexture2D.h"
|
||||
#include <vector>
|
||||
|
||||
namespace LifeGraphics
|
||||
{
|
||||
class IVideoTexture : public LifeGraphics::ITexture2D
|
||||
{
|
||||
public:
|
||||
float fps;
|
||||
float time;
|
||||
IVideoTexture()
|
||||
:fps(24.0f), time(0.0f)
|
||||
{
|
||||
}
|
||||
~IVideoTexture()
|
||||
{
|
||||
}
|
||||
ISurface* getSurface(int id)
|
||||
{
|
||||
return currTex->getSurface(id);
|
||||
}
|
||||
void AddFrame(ITexture2D* frame)
|
||||
{
|
||||
frames.push_back(frame);
|
||||
currTex = frames[0];
|
||||
}
|
||||
ITexture2D* GetPtr()
|
||||
{
|
||||
return currTex;
|
||||
}
|
||||
//ITexture2D* operator->(){return currTex;}
|
||||
|
||||
LifeCore::IDataRectangle* Map(int level, int read, int write)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void Update(float dt)
|
||||
{
|
||||
time+=dt;
|
||||
int cnt = frames.size();
|
||||
float tpf = 1.0f / fps;
|
||||
int cur = (int)(time / tpf); //-V2003
|
||||
cur = cur%cnt;
|
||||
SelectFrame(cur);
|
||||
}
|
||||
void SelectFrame(int frame)
|
||||
{
|
||||
currTex = frames[frame];
|
||||
}
|
||||
int Width()
|
||||
{
|
||||
return currTex->Width();
|
||||
}
|
||||
int Height()
|
||||
{
|
||||
return currTex->Height();
|
||||
}
|
||||
bool IsVideoTexture()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IRenderTargetView* getRTView()
|
||||
{
|
||||
return currTex->getRTView();
|
||||
}
|
||||
IRenderTargetView* getRTView(int index)
|
||||
{
|
||||
return currTex->getRTView(index);
|
||||
}
|
||||
|
||||
IShaderResourceView* getSRView()
|
||||
{
|
||||
return currTex->getSRView();
|
||||
}
|
||||
IShaderResourceView* getSRView(int index)
|
||||
{
|
||||
return currTex->getSRView(index);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<ITexture2D*> frames;
|
||||
ITexture2D* currTex;
|
||||
};
|
||||
}
|
||||
#endif // IVideoTexture_h__
|
||||
Reference in New Issue
Block a user