[glutils,nostalgia] Ptr to ref changes

This commit is contained in:
2023-12-06 23:56:49 -06:00
parent 7e19f45c69
commit db91ea6a63
4 changed files with 29 additions and 22 deletions

View File

@@ -13,10 +13,12 @@
namespace nostalgia::core {
template<bool alpha = false>
ox::Error toPngFile(ox::CStringView const&path, TileSheet::SubSheet const&s, Palette const&pal, int8_t bpp) noexcept {
ox::Error toPngFile(
ox::CStringView const&path, TileSheet::SubSheet const&s, Palette const&pal, int8_t bpp) noexcept {
ox::Vector<uint8_t> pixels;
s.readPixelsTo(&pixels, bpp);
const unsigned rows = s.rows == -1 ? static_cast<unsigned>(pixels.size()) / PixelsPerTile : static_cast<unsigned>(s.rows);
const unsigned rows = s.rows == -1 ?
static_cast<unsigned>(pixels.size()) / PixelsPerTile : static_cast<unsigned>(s.rows);
const unsigned cols = s.columns == -1 ? 1 : static_cast<unsigned>(s.columns);
const auto width = cols * TileWidth;
const auto height = rows * TileHeight;
@@ -35,7 +37,8 @@ ox::Error toPngFile(ox::CStringView const&path, TileSheet::SubSheet const&s, Pal
++idx;
}
constexpr auto fmt = alpha ? LCT_RGBA : LCT_RGB;
return OxError(static_cast<ox::ErrorCode>(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8)));
return OxError(static_cast<ox::ErrorCode>(
lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8)));
}
TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path):
@@ -280,7 +283,7 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept {
const auto winPos = ImGui::GetWindowPos();
const auto fbSizei = ox::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
glutils::resizeInitFrameBuffer(&m_framebuffer, fbSizei.width, fbSizei.height);
glutils::resizeInitFrameBuffer(m_framebuffer, fbSizei.width, fbSizei.height);
m_tileSheetEditor.resizeView(fbSize);
} else if (m_tileSheetEditor.updated()) {
m_tileSheetEditor.ackUpdate();