convert while() loop to for() loop

This commit is contained in:
iikare 2022-07-05 13:37:28 -07:00
parent 7b27628dfc
commit 191dc08564
No known key found for this signature in database
GPG Key ID: 4906067E1F6AAB8C

View File

@ -690,7 +690,6 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
float guessSize = sqrtf(requiredArea)*1.4f; float guessSize = sqrtf(requiredArea)*1.4f;
int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT int imageSize = (int)powf(2, ceilf(logf((float)guessSize)/logf(2))); // Calculate next POT
int currentRepeatCount = 0;
const int maxRepeatCount = 2; const int maxRepeatCount = 2;
bool undersizedAtlasFlag = false; bool undersizedAtlasFlag = false;
@ -708,7 +707,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
// When the guesstimate of the atlas size is determined to be undersized, // When the guesstimate of the atlas size is determined to be undersized,
// repeat the atlas generation process with an atlas data texture of a size // repeat the atlas generation process with an atlas data texture of a size
// that is double the previous size, up to a limit of `maxRepeatCount` times // that is double the previous size, up to a limit of `maxRepeatCount` times
while (currentRepeatCount < maxRepeatCount) for (int currentRepeatCount = 0; currentRepeatCount <= maxRepeatCount; currentRepeatCount++)
{ {
if (currentRepeatCount > 0) if (currentRepeatCount > 0)
{ {
@ -761,13 +760,12 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
if (offsetY > (atlas.height - fontSize - padding)) if (offsetY > (atlas.height - fontSize - padding))
{ {
// The current atlas is too small to hold all glyphs, so move to the next atlas size // The current atlas is too small to hold all glyphs, so move to the next atlas size
currentRepeatCount++;
undersizedAtlasFlag = true; undersizedAtlasFlag = true;
// If the process repeats more times than the defined limit, abort and log the unpackaged characters // If the process repeats more times than the defined limit, abort and log the unpackaged characters
for(int j = i + 1; j < glyphCount; j++) for(int j = i + 1; j < glyphCount; j++)
{ {
if (currentRepeatCount > maxRepeatCount) if (currentRepeatCount == maxRepeatCount)
{ {
TRACELOG(LOG_WARNING, "FONT: Failed to package character (%i)", j); TRACELOG(LOG_WARNING, "FONT: Failed to package character (%i)", j);
} }