diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixelgrid.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixelgrid.cpp index e38cb40b..e84b6f5b 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixelgrid.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixelgrid.cpp @@ -80,6 +80,11 @@ void TileSheetGrid::setBufferObject( } void TileSheetGrid::setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept { + if (subsheet.columns < 1 || subsheet.rows < 1) { + m_bufferSet.elements.clear(); + m_bufferSet.vertices.clear(); + return; + } auto const pixSize = pixelSize(paneSize); auto const set = [&](std::size_t i, ox::Point pt1, ox::Point pt2, Color32 c) { auto const vbo = &m_bufferSet.vertices[i * VertexVboLength]; diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp index b97e9685..fc9551f6 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp @@ -51,7 +51,7 @@ ox::Error TileSheetPixels::buildShader() noexcept { return glutils::buildShaderProgram(s_programSrc).moveTo(m_shader); } -void TileSheetPixels::draw(bool update, ox::Vec2 const&scroll) noexcept { +void TileSheetPixels::draw(bool const update, ox::Vec2 const&scroll) noexcept { glUseProgram(m_shader); glBindVertexArray(m_bufferSet.vao); if (update) { @@ -117,6 +117,11 @@ void TileSheetPixels::setPixelBufferObject( void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept { // set buffer lengths auto const&subSheet = m_model.activeSubSheet(); + if (subSheet.columns < 1 || subSheet.rows < 1) { + m_bufferSet.vertices.clear(); + m_bufferSet.elements.clear(); + return; + } auto const&pal = m_model.pal(); auto const width = subSheet.columns * TileWidth; auto const height = subSheet.rows * TileHeight;