Hi :)
i'm trying to make a screenshot cleaner, with CreateTexture2D hook but it's not working properly, i have tried a lot of things no sucess.
I need your help :)
so here the code :
Something like that should work no?
but the screenshot in my game folder are not all the same. (I use command Screenshot.Render)
Thanks for your help :)
i'm trying to make a screenshot cleaner, with CreateTexture2D hook but it's not working properly, i have tried a lot of things no sucess.
I need your help :)
so here the code :
PHP Code:
//typedef
typedef HRESULT(__stdcall *tCreateTexture2D)(ID3D11Device *pDevice, const D3D11_TEXTURE2D_DESC *pDesc, const D3D11_SUBRESOURCE_DATA *pInitialData, ID3D11Texture2D **ppTexture2D);
tCreateTexture2D oCreateTexture2D = 0;
//record one screenshot
bool firstCleanScreenshot = false;
ID3D11Texture2D *pClean = NULL;
HRESULT __stdcall myCreateTexture2D(ID3D11Device *pDevice, D3D11_TEXTURE2D_DESC *pDesc, D3D11_SUBRESOURCE_DATA *pInitialData, ID3D11Texture2D **ppTexture2D)
{
if (!firstCleanScreenshot&& pDesc->CPUAccessFlags == D3D11_CPU_ACCESS_READ) //When the game record a frame, the flag is CPU_ACESS_READ
{
DxRenderer::GetInstance()->m_pScreen->m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pClean); // set the render target as the back buffer
oCreateTexture2D(pDevice, pDesc, NULL, &pClean); //Use original CreateTexture2D and save the frame into pClean
printf("ScreenShot clean recorded!\n");
firstCleanScreenshot= true; //don't do it the next screenshot
return oCreateTexture2D(pDevice, pDesc, pInitialData, ppTexture2D);
}
else
{
if (pDesc->CPUAccessFlags == D3D11_CPU_ACCESS_READ)
{
printf("Width: %d Height: %d \n", pDesc->Width, pDesc->Height);
HRESULT hRet = oCreateTexture2D(pDevice, pDesc, pInitialData, ppTexture2D);
DxRenderer::GetInstance()->m_pContext->CopyResource(*ppTexture2D, pClean); //copy pClean into ppTexture2D
return hRet;
}
}
return oCreateTexture2D(pDevice, pDesc, pInitialData, ppTexture2D);
}
but the screenshot in my game folder are not all the same. (I use command Screenshot.Render)
Thanks for your help :)
Aucun commentaire:
Enregistrer un commentaire