I am passing Texture from python to my C++ dll;
I see, that CPTA_uchar data has get_data(); My idea was to get this data, and then somehow extract actual RGB values from it. But it returns std::string, and also throws compiler linkage errors.
Am I actually on the right path here?
CPTA_uchar is basically a vector of unsigned char values. You can use .p() to get an unsigned char pointer back, and .size() to get the length.
Note that the data is ordered BGRA.
Thank you very much for the reply! I was able to move forward, but stuck again for several hours. Basically, no matter what, myImg->might_have_ram_image() returns false;
I decided to be smart, as PNMImage allows me pixel manipulation too, so I created:
self.PNMDF = PNMImage()
and then every frame I do:
and then I have this:
And size is always 0; So its either I can not get ram image, or stuck with 0 size. OnscreenImage shows texture just fine, so I wonder what else am I missing.
Hmm, just a guess, but Panda deletes the texture from RAM (by default) once it has uploaded it to the GPU. Could this be the case for you? Use tex.has_ram_image() to find out if it has an image in RAM.
Keep in mind that if you used render-to-texture, it won’t be in RAM until you asked Panda to transfer it to RAM. You’d have to do that by using the RTMCopyRam mode (or RTMTriggeredCopyRam with trigger_copy()).
Ah, I see now, you were completely right. RTMCopyRam does the trick