Hi All,
Looking for some suggestions on the best way to optimize the direct update of the contents of images in Tier 2.
Ive put some sample code here that mocks out what im looking to achieve - that explains it best.
agk::CreateRenderImage(img1, 640, 480, 0, 0);
agk::CreateMemblockFromImage(img1MemBlk, img1);
img1MemBlkPtr = agk::GetMemblockPtr(img1MemBlk);
agk::CreateObjectPlane(obj1, 320, 240);
agk::SetObjectPosition(obj1, 0, 0, 0);
agk::SetObjectImage(obj1, img1, 0);
while ( !bExitLoop )
{
// get some image data into buffer imageData []
// its a buffer of 640 x 480 integers - but not really relevant to question
const int16_t* imageData = (const int16_t*)imageFrame.getData();
const int width = imageFrame.getWidth();
const int height = imageFrame.getHeight();
const int length = width * height;
// currently Im using this data to create a grey scale image based on the data
// later it will become a color map with expanded imageData[]
// this loop updates the memblock directly via its pointer - img1MemBlkPtr
for (int i = 0; i < length; i++)
{
const auto value = imageData[i];
// first 12 bytes are allocated for image data
const int rgbaOffset = 12 + ( i * 4 );
img1MemBlkPtr[rgbaOffset] = value;
img1MemBlkPtr[rgbaOffset + 1] = value;
img1MemBlkPtr[rgbaOffset + 2] = value;
img1MemBlkPtr[rgbaOffset + 3] = 255;
}
// this I push the memblock back to the image
agk::CreateImageFromMemblock(img1, img1MemBlk);
}
But it seems like double handling - effectively doing two copies of the data per frame.
So the question really comes down to --- is there a way to directly write to the image itself and tell the system its been updated.
Without having to work through the memblock - or beyond that - maybe directly writing to the OpenGL texture which I assume is happening internally?
Any thoughts or advice would be greatly appreciated
Cheers
Westa