src/glRenderer.cpp

changeset 1135
8e0691be0b6f
parent 1134
daa9808d626e
equal deleted inserted replaced
1134:daa9808d626e 1135:8e0691be0b6f
711 pixelData.resize(4 * numpixels); 711 pixelData.resize(4 * numpixels);
712 712
713 // Read pixels from the color buffer. 713 // Read pixels from the color buffer.
714 glReadPixels(x0, height() - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data()); 714 glReadPixels(x0, height() - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
715 715
716 QSet<int32_t> indices; 716 QSet<qint32> indices;
717 717
718 // Go through each pixel read and add them to the selection. 718 // Go through each pixel read and add them to the selection.
719 // Each pixel maps to an LDObject index injectively. 719 // Each pixel maps to an LDObject index injectively.
720 // Note: black is background, those indices are skipped. 720 // Note: black is background, those indices are skipped.
721 for (unsigned char *pixelCursor = pixelData.begin(); pixelCursor < pixelData.end(); pixelCursor += 4) 721 for (unsigned char *pixelCursor = pixelData.begin(); pixelCursor < pixelData.end(); pixelCursor += 4)
722 { 722 {
723 int32_t index = pixelCursor[0] * 0x10000 + 723 qint32 index = pixelCursor[0] * 0x10000 + pixelCursor[1] * 0x100 + pixelCursor[2] * 0x1;
724 pixelCursor[1] * 0x100 +
725 pixelCursor[2] * 0x1;
726 if (index != 0) 724 if (index != 0)
727 indices.insert(index); 725 indices.insert(index);
728 } 726 }
729 727
730 // For each index read, resolve the LDObject behind it and add it to the selection. 728 // For each index read, resolve the LDObject behind it and add it to the selection.
731 for (int32_t index : indices) 729 for (qint32 index : indices)
732 { 730 {
733 LDObject* object = LDObject::fromID(index); 731 LDObject* object = LDObject::fromID(index);
734 732
735 if (object != nullptr) 733 if (object != nullptr)
736 newSelection.insert(object); 734 newSelection.insert(object);

mercurial