Skip to content

Commit

Permalink
Fixed|Busy Mode: Font glitch at the start of a busy task
Browse files Browse the repository at this point in the history
For some reason fonts were not rendered properly at the start
of a busy task. Now the font is loaded during the preparations
for switching from normal to busy mode.
  • Loading branch information
skyjake committed Jul 23, 2012
1 parent 10c2d3e commit 4038be5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/render/busyvisual.h
Expand Up @@ -32,6 +32,7 @@ extern "C" {
void BusyVisual_LoadTextures(void);
void BusyVisual_ReleaseTextures(void);

void BusyVisual_PrepareFont(void);
void BusyVisual_PrepareResources(void);

/**
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/busymode.cpp
Expand Up @@ -220,6 +220,7 @@ static void preBusySetup(int initialMode)
LegacyCore_SetLoopRate(60);
LegacyCore_SetLoopFunc(NULL); // don't call main loop's func while busy

BusyVisual_PrepareFont();
BusyVisual_LoadTextures();

Window_SetDrawFunc(Window_Main(), 0);
Expand Down
62 changes: 39 additions & 23 deletions doomsday/engine/portable/src/render/busyvisual.c
Expand Up @@ -98,31 +98,47 @@ void BusyVisual_PrepareResources(void)
// Not in startup, so take a copy of the current frame contents.
acquireScreenshotTexture();
}
}

// Need to load any fonts for log messages etc?
if((task->mode & BUSYF_CONSOLE_OUTPUT) || task->name)
void BusyVisual_PrepareFont(void)
{
/**
* @todo At the moment this is called from preBusySetup() so that the font
* is present throughout the busy mode during all the individual tasks.
* Previously the font was being prepared at the beginning of each task,
* but that was resulting in a rendering glitch where the font GL texture
* was not being properly drawn on screen during the first ~1 second of
* BusyVisual visibility. The exact cause was not determined, but it may be
* due to a conflict with the fonts being prepared from both the main
* thread and the worker thread, or because the GL deferring mechanism is
* interfering somehow.
*/

// These must be real files in the base dir because virtual files haven't
// been loaded yet when the engine startup is done.
struct busyfont_s {
const char* name;
const char* path;
} static const fonts[] = {
{ FN_SYSTEM_NAME":normal12", "}data/fonts/normal12.dfn" },
{ FN_SYSTEM_NAME":normal18", "}data/fonts/normal18.dfn" }
};
int fontIdx = !(Window_Width(theWindow) > 640)? 0 : 1;
Uri* uri = Uri_NewWithPath2(fonts[fontIdx].name, RC_NULL);
font_t* font = R_CreateFontFromFile(uri, fonts[fontIdx].path);
Uri_Delete(uri);

if(font)
{
// These must be real files in the base dir because virtual files haven't
// been loaded yet when the engine startup is done.
struct busyFont {
const char* name;
const char* path;
} static const fonts[] = {
{ FN_SYSTEM_NAME":normal12", "}data/fonts/normal12.dfn" },
{ FN_SYSTEM_NAME":normal18", "}data/fonts/normal18.dfn" }
};
int fontIdx = !(Window_Width(theWindow) > 640)? 0 : 1;
Uri* uri = Uri_NewWithPath2(fonts[fontIdx].name, RC_NULL);
font_t* font = R_CreateFontFromFile(uri, fonts[fontIdx].path);
Uri_Delete(uri);

if(font)
{
busyFont = Fonts_Id(font);
FR_SetFont(busyFont);
FR_LoadDefaultAttrib();
busyFontHgt = FR_SingleLineHeight("Busy");
}
busyFont = Fonts_Id(font);
FR_SetFont(busyFont);
FR_LoadDefaultAttrib();
busyFontHgt = FR_SingleLineHeight("Busy");
}
else
{
busyFont = 0;
busyFontHgt = 0;
}
}

Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/portable/src/render/rend_font.c
Expand Up @@ -192,7 +192,10 @@ void FR_SetFont(fontid_t num)
{
errorIfNotInited("FR_SetFont");
if(!Fonts_ToFont(num))
{
LegacyCore_PrintfLogFragmentAtLevel(DE2_LOG_WARNING, "Requested invalid font %i.\n", num);
return; // No such font.
}
fr.fontNum = num;
}

Expand Down

0 comments on commit 4038be5

Please sign in to comment.