This is a snippet that can mirror swf file on texture. Based on FlashWidget from Popcap framework and quite straightforward.
header:
- Code: Select all
#ifndef __NODEFLASH_H__
#define __NODEFLASH_H__
struct IOleObject;
struct IOleInPlaceObjectWindowless;
namespace ShockwaveFlashObjects
{
struct IShockwaveFlash;
}
class FlashSink;
class ControlSite;
class FlashListener
{
public:
virtual void FlashAnimEnded(int theId) {}
virtual void FlashCommand(int theId, const _string& theCommand, const _string& theParam) {}
};
class CSpriteNode_Flash
{
public:
enum
{
STATE_IDLE,
STATE_PLAYING,
STATE_STOPPED
};
enum
{
QUALITY_LOW,
QUALITY_MEDIUM,
QUALITY_HIGH
};
public:
s32 mWidth;
s32 mHeight;
int mState;
int mId;
FlashListener* mFlashListener;
HMODULE mFlashLibHandle;
ControlSite* mControlSite;
FlashSink* mFlashSink;
ShockwaveFlashObjects::IShockwaveFlash* mFlashInterface;
IOleObject* mOleObject;
IOleInPlaceObjectWindowless* mWindowlessObject;
int mCOMCount;
int mPauseCount;
int mHasLostFocus;
_rcti mDirtyRect;
bool mFlashDirty;
_rcti GetRect();
bool mAutoPause;
SColor mBkgColor;
CSpriteNode* targetNode;
public:
BYTE* bitmap_pData;
BYTE* bitmap_pData_Original;
BITMAPINFO bitmap_pbi;
HBITMAP bitmap;
void CleanupImages();
void RebuildImages();
void InitializeFlash();
public:
CSpriteNode_Flash(int theId, FlashListener* theFlashListener, CSpriteNode* targetNode);
~CSpriteNode_Flash();
static double GetFlashVersion();
bool StartAnimation(const _string& theFileName);
void SetQuality(int theQuality);
void Pause();
void Unpause();
bool IsPlaying();
void Rewind();
void Back();
void Forward();
void GotoFrame(int theFrameNum);
int GetCurrentFrame();
_string GetCurrentLabel(const _string& theTimeline);
void CallFrame(const _string& theTimeline, int theFrameNum);
void CallLabel(const _string& theTimeline, const _string& theLabel);
_string GetVariable(const _string& theName);
void SetVariable(const _string& theName, const _string& theValue);
virtual void Resize(int theX, int theY, int theWidth, int theHeight);
virtual void Update();
virtual void Draw();
virtual void MouseDown(int x, int y, int theBtnNum, int theClickCount);
virtual void MouseUp(int x, int y, int theBtnNum, int theClickCount);
virtual void MouseMove(int x, int y);
virtual void MouseDrag(int x, int y);
virtual void MouseLeave();
virtual void SysColorChanged();
void MarkDirty();
};
class CFlashAnimation:public INodeAnimator
{
public:
CSpriteNode_Flash* flashCOM;
CSpriteNode* targetNode;
CString sPath;
CFlashAnimation(CSpriteNode* _targetNode, const CString& _sPath);
~CFlashAnimation();
virtual void stepAnimation(CNodeBasement* node, u32 timeMs);
};
#endif //__NODEFLASH_H__
this is a rip from game frawork (over Irrlicht) so some classes that is used here are: CSpriteNode,CNodeBasement -> billboard, CString, string_ -> core::string.
Usage:
- Code: Select all
sprite->addAnimator(new CFlashAnimation(sprite, sPathToFlashFile));
As long as this animator "animating" billboard, it will flush swf content into it first texture




