Skip to content

Commit

Permalink
Put SDF debug images in the temp path
Browse files Browse the repository at this point in the history
  • Loading branch information
timangus committed Oct 24, 2023
1 parent 250c36f commit 3b6c369
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion source/app/rendering/compute/sdfcomputejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,22 @@ void SDFComputeJob::generateSDF()
glBindTexture(GL_TEXTURE_2D_ARRAY, sdfTexture);
glGetTexImage(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());

const char* outFilePrefix = "graphia-SDF";

// Save each layer as its own image for debug
for(size_t layer = 0; layer < numImages; ++layer)
{
auto offset = (static_cast<size_t>(_glyphMap->images().at(0).sizeInBytes()) /
static_cast<size_t>(scaleFactor * scaleFactor)) * layer;
const QImage sdfImage(pixels.data() + offset, renderWidth, renderHeight, QImage::Format_RGBA8888);
sdfImage.save(QDir::currentPath() + "/SDF" + QString::number(layer) + ".png");
sdfImage.save(QDir::tempPath() + "/" + outFilePrefix + QString::number(layer) + ".png");
}

// Print Memory consumption
auto memoryConsumption = static_cast<size_t>(renderWidth * renderHeight * 4) * numImages;
qDebug() << "SDF texture memory consumption MB:" <<
static_cast<float>(memoryConsumption) / (1000.0f * 1000.0f);
qDebug() << "SDF images saved to:" << QString("%1/%2*.png").arg(QDir::tempPath(), outFilePrefix);
}

screenQuadVAO.release();
Expand Down
6 changes: 5 additions & 1 deletion source/app/rendering/glyphmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ void GlyphMap::renderImages(const QFont &font)
// Save Glyphmap(s) for debug purposes if needed
if(u::pref(u"debug/saveGlyphMaps"_s).toBool())
{
const char* outFilePrefix = "graphia-GlyphMap";

for(int i = 0; const auto& debugImage : debugImages)
debugImage.save(QDir::currentPath() + "/GlyphMap" + QString::number(i++) + ".png");
debugImage.save(QDir::tempPath() + "/" + outFilePrefix + QString::number(i++) + ".png");

qDebug() << "Glyph images saved to:" << QString("%1/%2*.png").arg(QDir::tempPath(), outFilePrefix);
}
}

0 comments on commit 3b6c369

Please sign in to comment.