Advertisement
Guest User

ARNOLD: Qt Driver Callback

a guest
Nov 2nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. void qtIPR(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t* buffer, void* data)
  2. {
  3.     qDebug() << "Status:\t" << AiRenderGetStatus();
  4. //    qDebug() << "RENDERING = " << AI_RENDER_STATUS_RENDERING;
  5. //    qDebug() << "FINISHED = " << AI_RENDER_STATUS_FINISHED;
  6. //    qDebug() << "FAILED = " << AI_RENDER_STATUS_FAILED;
  7.  
  8.     //uint8_t* pixel = (uint8_t*)AiMalloc(x * y * sizeof(uint8_t) * 4);
  9.     uint8_t* pixel = buffer;
  10.  
  11.     if (AiRenderGetStatus() == 5){
  12.         AiFree(&buffer);
  13.         AiFree(&data);
  14.         AiFree(&pixel);
  15.     }
  16.  
  17.     else{
  18.  
  19.     if (buffer != nullptr)
  20.  
  21.     {
  22.  
  23.         try{
  24.  
  25.             qDebug() << "Used Memory:\t" << AiMsgUtilGetUsedMemory() / 1048576 << "MB";
  26.             qDebug() << "X:\t" << x;
  27.             qDebug() << "Y:\t" << y;
  28.             qDebug() << "Width:\t" << width;
  29.             qDebug() << "Height:\t" << height;
  30.             qDebug() << buffer;
  31.             qDebug() << "buffer length" << sizeof (buffer) / sizeof (u_int8_t);
  32.             for(unsigned int i = 0; i < height; ++i) {
  33.                 for(unsigned int j = 0; j < width; ++j, pixel += 3) {
  34.                     float r = pixel[0];
  35.                     float g = pixel[1];
  36.                     float b = pixel[2];
  37.                     float a = pixel[3];
  38.                     qDebug() << "R " << r << "G " << g << "B " << b << "A " << a;
  39.                     // Do something with r, g, b
  40.  
  41.  
  42.                }
  43.  
  44.              }
  45.  
  46.  
  47.             //delete pixel;
  48.             //qDebug() << "Freeing objects";
  49.             //AiFree(&pixel);
  50.  
  51.             if (data != nullptr){
  52.                 qDebug() << "found data:";
  53.                 qDebug() << "Data:\t" << data;
  54.             }
  55.  
  56.     }
  57.         catch(...){
  58.             qDebug() << "Freeing objects";
  59.             AiFree(&buffer);
  60.             AiFree(&data);
  61.  
  62.  
  63.         }
  64.     }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement