karim.salama Posted July 18, 2022 Share Posted July 18, 2022 Hi, I'm trying to convert images from OpenSceneGraph to Unigine, the code currently looks like this : auto osg_image = ...; auto unigine_image = Unigine::Image::create(); img->create2D(osg_image->s(), osg_image->t(), Unigine::Image::FORMAT_RGB8); auto data = osg_image->data(); unigine_image->setPixels(data); This crashes in Unigine::Image::setPixels, in an assert at line 7285. I've verified : data is not null. Am I missing something here? Thanks in advance! Link to comment
silent Posted July 18, 2022 Share Posted July 18, 2022 Hi Karim, Could you please provide us a minimal test sample with this crash? It's hard to tell what's going on here without a proper repro. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
karim.salama Posted July 18, 2022 Author Share Posted July 18, 2022 It would be complicated to send all the dlls and the proprietary content that is used in the sample. But here is a simple code example where the problem occurs : auto img = Unigine::Image::create(); img->create2D(2, 2, Unigine::Image::FORMAT_RGB8, 1, 0); unsigned char data[12] = { 0xff,0x00,0x00, 0x00,0xff,0x00, 0x00,0x00,0xff, 0xff,0xff,0xff }; img->setPixels(data); I create a 2x2 image with with the RGB8 format, it crashes when trying to set the pixels values with the setPixel function. Link to comment
sweetluna Posted July 18, 2022 Share Posted July 18, 2022 Hi karim, Just add false as the last argument for create2D. img->create2D(2, 2, Unigine::Image::FORMAT_RGB8, 1, false, false); Hope it helps! May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
karim.salama Posted July 18, 2022 Author Share Posted July 18, 2022 Hi all, Thanks sweetluna! I think I understand what was going wrong with the implementation. I think that Unigine::Image protects its allocated data by default, except when it doesn't allocate anything. Apparently setPixels only sets the value of the data pointer and doesn't do any copying. I ended up doing a memcpy on the pointer I get from Unigine::Image::getPixels as a destination and this seems to work very well. Thanks. 1 Link to comment
Recommended Posts