Hi,
I’m trying to save a image of the viewport. I’m using this code. The format of the screen would be RGBA. I think I have the right code but something is missing.
// Set to the active camera
Image * OutputImage(new Image(context_));
Texture2D * pRenderTexture(new Texture2D(context_));
Texture2D * pDepthTexture(new Texture2D(context_));
// Set width and height
const unsigned int outputHeight = 900;
const unsigned int outputWidth = 1440;
// Set Image
OutputImage->SetSize(outputWidth, outputHeight, 4);
// Create necessary texture
pRenderTexture->SetSize(outputHeight, outputWidth, m_textureFormat, TEXTURE_RENDERTARGET);
pDepthTexture->SetSize(outputHeight, outputWidth, Graphics::GetDepthStencilFormat(), TEXTURE_DEPTHSTENCIL);
// Set parameneters
pRenderTexture->SetFilterMode(FILTER_NEAREST);
pDepthTexture->SetFilterMode(FILTER_NEAREST);
RenderSurface * pRenderSurface = pRenderTexture->GetRenderSurface();
// Set Render Surface
pRenderSurface->SetViewport(0, m_pCameraViewport);
pRenderSurface->SetUpdateMode(SURFACE_UPDATEALWAYS);
pRenderSurface->SetLinkedDepthStencil(pDepthTexture->GetRenderSurface());
// Queue Update
pRenderSurface->QueueUpdate();
unsigned char* _ImageData = new unsigned char[outputWidth*outputHeight*4];
pRenderTexture->GetData(0, _ImageData);
OutputImage->SetData(_ImageData);
OutputImage->SaveTGA("snapshoot.tga");
pRenderTexture->SaveTGA("test.tga");
Vivienne