try, try again

This commit is contained in:
Seth Alves 2017-05-11 14:10:03 -07:00
parent a26f9c7887
commit ac2bc39a27

View file

@ -39,9 +39,11 @@ StoragePointer Storage::toFileStorage(const QString& filename) const {
}
MemoryStorage::MemoryStorage(size_t size, const uint8_t* data) : _size(size) {
// alloc smallest number of 4-byte chunks that will cover size bytes. The buffer is padded out to a multiple
// of 4 to force an alignment that glTextureSubImage2D can later use.
_data.resize((size + 3) & ~0x3);
// we end up calling glCompressedTextureSubImage2D with this, and the rows of the image are expected
// to be word aligned. This is fine in all cases except for 1x1 images and 2x2 images. For 1x1,
// there is only one row, so the problem is avoided. For 2x2, we add 2 extra bytes so there's
// room for the second row.
_data.resize(size == 4 ? 6 : size);
if (data) {
memcpy(_data.data(), data, size);
}