JD2022-TU1/main/extern/Camcam/LIBS/Input/SNAP.cpp

69 lines
1.2 KiB
C++

#include "SCENE.h"
#include "MEDIA.h"
/*
MEDIA TYPE "SNAP"
Take a snapshot of current frame buffer when asked by LUA
*/
class SNAP:public INPUT_IO
{
public:
WORLD *pScene;
u32 IsConnectedToDriver;
int INIT (class WORLD*pscn);
int FRAME ();
int END (void);
IOTYPE GetType() {return IOtype_SNAP;};
};
int SNAP::END()
{
Image.Delete();
return 0;
}
int SNAP::INIT(class WORLD*pscn)
{
IsValidForMosaique = 0;
pScene = pscn;
return 0;
};
int SNAP::FRAME()
{
return 0;
}
void MEDIA_UpdateSnapshot(WORLD *pScene,INPUT_IO *Snap,s32 X,s32 Y,s32 SX,s32 SY,u32 UpdateSoft)
{
if (Snap)
{
if (Snap->Image.SetSize(SX, SY, 1))
{
if (Snap->ulAssociatedTextureIndex != -1) pScene->DI->DestroyTexture(Snap->ulAssociatedTextureIndex);
Snap->ulAssociatedTextureIndex = pScene->DI->CreateTexture(&Snap->Image,Snap->ulColorMode, true);
}
pScene->DI->UpdateTexture_HW_2_BM(Snap->ulAssociatedTextureIndex,UpdateSoft,X,Y) ;
}
}
INPUT_IO *SNAP_CREATE(WORLD *pScene,char *Name)
{
SNAP *Ret;
Ret = new(SNAP);
Ret->INIT(pScene);
Ret->Image.SetSize(256, 256, 1);
Ret->dTotalTime = 0;
Ret->dAvgFramePerSecond = 30.0;
return (INPUT_IO *)Ret;
};