i have also tried irrExtensions.. but i do not use dev, nor do i want to have to recompile irrlicht.dll, so if anyone has been able to find, or construct a separate avi player using irrlicht (preferably using the texturing method, allowing me to apply it to a mesh) i would greatly appreciate it. so far my code looks like so:
Code: Select all
#include <irrlicht.h>
#include <dshow.h>
#include <mmstream.h>
#include <amstream.h>
#include <ddstream.h>
// Irrlicht Namespaces
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#include <dshow.h>
#include <mmstream.h>
#include <amstream.h>
#include <ddstream.h>
static GUID MY_CLSID_AMMultiMediaStream={0x49C47CE5,0x9BA4,0x11D0,0x82,0x12,0x00,0xC0,0x4F,0xC3,0x2C,0x45};
static GUID MY_IID_IAMMultiMediaStream={0xBEBE595C,0x9A6F,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryVideo={0xA35FF56A,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_IID_IDirectDrawMediaStream={0xF4104FCE,0x9A70,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryAudio={0xA35FF56B,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
class TMovie
{
IAMMultiMediaStream* pAMStream;
IMediaStream* pPrimaryVidStream;
IDirectDrawMediaStream* pDDStream;
IDirectDrawStreamSample* pSample;
IDirectDrawSurface* pSurface;
RECT Movie_rect;
LONG MoviePitch;
void* MovieBuffer;
DWORD time;
DWORD oldtick;
public:
TMovie()
{
CoInitialize(0);
pAMStream = 0;
pPrimaryVidStream = 0;
pDDStream = 0;
pSample = 0;
pSurface = 0;
time = 0;
}
~TMovie()
{
pPrimaryVidStream->Release();
pDDStream->Release();
pSample->Release();
pSurface->Release();
pAMStream->Release();
CoUninitialize();
}
void LoadMovie(char* filename)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP,0,filename,-1,buf,512);
CoCreateInstance(MY_CLSID_AMMultiMediaStream,0,1,MY_IID_IAMMultiMediaStream,(void**)&pAMStream);
pAMStream->Initialize((STREAM_TYPE) 0, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryVideo, 0, NULL);
pAMStream->OpenFile(buf,4);
pAMStream->GetMediaStream( MY_MSPID_PrimaryVideo, &pPrimaryVidStream);
pPrimaryVidStream->QueryInterface(MY_IID_IDirectDrawMediaStream,(void**)&pDDStream);
pDDStream->CreateSample(0,0,0,&pSample);
pSample->GetSurface(&pSurface,&Movie_rect);
pAMStream->SetState((STREAM_STATE)1);
}
void NextMovieFrame()
{
if(GetTickCount()-oldtick < time)return ;
oldtick = GetTickCount();
pSample->Update( 0, NULL, NULL, 0);
}
int MovieWidth() { return (Movie_rect.right - Movie_rect.left);}
int MovieHeight() { return (Movie_rect.bottom - Movie_rect.top);}
void DrawMovie(int x,int y,ITexture* Buf)
{
void* pBits = Buf->lock();
LONG Pitch = Buf->getPitch();
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT , NULL);
int wmin=(Pitch<ddsd.lPitch)?Pitch:ddsd.lPitch;
for(int h=0; h<ddsd.dwHeight; h++)
memcpy((BYTE*)pBits+((y+h)*Pitch)+x*4,(BYTE*)ddsd.lpSurface+h*ddsd.lPitch,wmin);
pSurface->Unlock(NULL);
Buf->unlock();
}
void SetMovieFPS(int fps)
{
time = fps;
}
} ;
int main()
{
IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL, dimension2d<s32>(640,
480), 32, false, false, false, 0);
IVideoDriver* irrVideo = irrDevice->getVideoDriver();
ISceneManager* irrSceneMgr = irrDevice->getSceneManager();
IGUIEnvironment* m_guienv = irrDevice->getGUIEnvironment();
TMovie* movie = new TMovie;
movie->LoadMovie("Internetisforporn.avi");
movie->SetMovieFPS(25);
ITexture* movTxtr;
irrVideo->setTextureCreationFlag(ETCF_ALWAYS_32_BIT , TRUE);
irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, FALSE);
movTxtr = irrVideo->addTexture(dimension2d<s32>(512,256),"imovie");
while(irrDevice->run())
{
irrVideo->beginScene(true, true, SColor(0,200,200,200));
movie->NextMovieFrame();
movie->DrawMovie(0,0,movTxtr);
irrSceneMgr->drawAll();
irrVideo->endScene();
}
irrDevice->drop();
return 0;
}
Please help... Thankyou in advance.
Steve.
EDIT::
i have also tried attaching the texture to a IGUIImage Element, and also using the draw2d method, all to no avail...!!!