Hi everyone,
Can't get how exactly cache works. Is it just map of shared pointers, wrapped in own methods and classes, or something more?
I was trying to implement moon phases, so I planned to:
- Create empty image with desired mode and size
- Fill image with certain data
- Set created image as moon's image
Code:
ImagePtr originalImage = UID(...);
ImagePtr maskedImage = UID(...);
auto height = originalImage()->h();
auto width = originalImage()->w();
auto depth = originalImage()->d();
// maskedMoonImage is ImagePtr class instance
maskedMoonImage = new Image(width, height, depth, IMAGE_R8G8B8A8, IMAGE_2D);
originalImage()->lockRead();
maskedImage()->lockRead();
maskedMoonImage()->lock(LOCK_WRITE);
// some operations
originalImage()->unlock();
maskedImage()->unlock();
maskedMoonImage()->unlock();
originalImage = NULL;
maskedImage = NULL;
// moon points exactly at object in Astro container, no doubt
moon->image = maskedMoonImage;
And I stuck on 3rd step.
I'm sure that "maskedMoonImage" filled with correct data - data can be exported to png file perfectly, but in application moon not renders. On each frame
moon->image points to correct data, but engine shows no image.
Moreover,
Images.contains(maskedMoonImage); call returns false.
On the other hand, if I create maskedMoonImage as
Image class instance and fill it with data, everything works fine, but setting
moon->image = maskedMoonImage; seems to be impossible - cache know nothing about Image object and I can't retrieve pointer CacheElementPointer to maskedMoonImage, or convert C++ pointer to maskedMoonImage to CacheElementPointer.
So my questions are:
- Does EE cache mapped directly to files and can't store plain data?
- If so, how can I bypass it and correctly use cache with non-file data?