diff --git a/Outputs/CRT/Internals/TextureBuilder.cpp b/Outputs/CRT/Internals/TextureBuilder.cpp index 29c0f87b1..89efc616e 100644 --- a/Outputs/CRT/Internals/TextureBuilder.cpp +++ b/Outputs/CRT/Internals/TextureBuilder.cpp @@ -43,6 +43,7 @@ TextureBuilder::TextureBuilder(size_t bytes_per_pixel, GLenum texture_unit) : write_areas_start_y_(0), is_full_(false), did_submit_(false), + has_write_area_(false), number_of_write_areas_(0) { image_.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight); @@ -105,6 +106,7 @@ uint8_t *TextureBuilder::allocate_write_area(size_t required_length) else write_areas_.push_back(next_write_area); number_of_write_areas_++; + has_write_area_ = true; return pointer_to_location(next_write_area.x, next_write_area.y); } @@ -116,8 +118,9 @@ bool TextureBuilder::is_full() void TextureBuilder::reduce_previous_allocation_to(size_t actual_length) { - if(is_full_) return; + if(is_full_ || !has_write_area_) return; + has_write_area_ = false; WriteArea &write_area = write_areas_[number_of_write_areas_-1]; write_area.length = (uint16_t)actual_length; diff --git a/Outputs/CRT/Internals/TextureBuilder.hpp b/Outputs/CRT/Internals/TextureBuilder.hpp index d200a9b97..93777ac92 100644 --- a/Outputs/CRT/Internals/TextureBuilder.hpp +++ b/Outputs/CRT/Internals/TextureBuilder.hpp @@ -69,6 +69,7 @@ class TextureBuilder { size_t number_of_write_areas_; bool is_full_; bool did_submit_; + bool has_write_area_; inline uint8_t *pointer_to_location(uint16_t x, uint16_t y); // Usually: the start position for the current batch of write areas.