Skip to content

Commit

Permalink
Refactor: Implemented an attribute stack (max depth=4)for the engine's
Browse files Browse the repository at this point in the history
font renderer and added the tracking and shadow offset properties to it.
Note that the current font is NOT a member of the attribute stack.

Fixed a couple of invalid font references in Heretic.
  • Loading branch information
danij-deng committed Jun 12, 2011
1 parent 2577903 commit 898ad8e
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 156 deletions.
14 changes: 13 additions & 1 deletion doomsday/engine/api/dd_bitmapfont.h
Expand Up @@ -74,11 +74,24 @@ void FR_ResetTypeInTimer(void);
#define DTF_ONLY_SHADOW (DTF_NO_TYPEIN|DTF_NO_GLITTER)
/*@}*/

#define FR_MAX_ATTRIB_STACK_DEPTH (4)

/// Change the current font.
void FR_SetFont(fontid_t font);

/// Push the attribute stack.
void FR_PushAttrib(void);

/// Pop the attribute stack.
void FR_PopAttrib(void);

/// Load the default attributes at the current stack depth.
void FR_LoadDefaultAttrib(void);

void FR_SetTracking(int tracking);

void FR_SetShadowOffset(int offsetX, int offsetY);

/// @return Unique identifier associated with the current font.
fontid_t FR_GetCurrentId(void);

Expand All @@ -103,7 +116,6 @@ void FR_DrawTextFragment2(const char* string, int x, int y, short flags);
void FR_DrawTextFragment3(const char* string, int x, int y, short flags, int initialCount);
void FR_DrawTextFragment4(const char* string, int x, int y, short flags, int initialCount, float glitterStrength);
void FR_DrawTextFragment5(const char* string, int x, int y, short flags, int initialCount, float glitterStrength, float shadowStrength);
void FR_DrawTextFragment6(const char* string, int x, int y, short flags, int initialCount, float glitterStrength, float shadowStrength, int shadowOffsetX, int shadowOffsetY);

// Utility routines:
void FR_TextFragmentDimensions(int* width, int* height, const char* string);
Expand Down
11 changes: 8 additions & 3 deletions doomsday/engine/api/doomsday.def
@@ -1,6 +1,6 @@
; Doomsday Engine API (Routines exported from Doomsday.exe).
;
; Highest ordinal is currently: --> 512 <--
; Highest ordinal is currently: --> 515 <--
; Other free ordinals: 200

NAME "DOOMSDAY"
Expand Down Expand Up @@ -496,8 +496,14 @@ EXPORTS
FR_SafeFontIdForName @107 NONAME
FR_GetCurrentId @97 NONAME
FR_SetFont @65 NONAME

FR_PushAttrib @513 NONAME
FR_PopAttrib @514 NONAME
FR_LoadDefaultAttrib @515 NONAME

FR_Tracking @198 NONAME
FR_SetTracking @125 NONAME
FR_SetTracking @124 NONAME
FR_SetShadowOffset @125 NONAME
FR_ResetTypeInTimer @131 NONAME

FR_TextDimensions @112 NONAME
Expand All @@ -516,7 +522,6 @@ EXPORTS
FR_DrawTextFragment3 @121 NONAME
FR_DrawTextFragment4 @122 NONAME
FR_DrawTextFragment5 @123 NONAME
FR_DrawTextFragment6 @124 NONAME

FR_DrawChar @202 NONAME
FR_DrawChar2 @203 NONAME
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -505,7 +505,7 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)
if(busyTaskName)
{
FR_SetFont(busyFont);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
glColor4f(1.f, 1.f, 1.f, .66f);
FR_DrawTextFragment2(busyTaskName, x+radius, y, DTF_ALIGN_LEFT|DTF_ONLY_SHADOW);
}
Expand Down Expand Up @@ -619,7 +619,7 @@ void Con_BusyDrawConsoleOutput(void)
}

FR_SetFont(busyFont);
FR_SetTracking(0);
FR_LoadDefaultAttrib();

for(i = 0; i < 2 * LINE_COUNT; ++i, y += busyFontHgt)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/con_main.c
Expand Up @@ -229,7 +229,7 @@ static void resizeHistoryBuffer(void)
{
int cw, maxLength = 70;
FR_SetFont(consoleFont);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
// Do we need to update the console history buffer max line length?
if(0 != (cw = FR_TextFragmentWidth("A")))
{
Expand Down
14 changes: 8 additions & 6 deletions doomsday/engine/portable/src/edit_bias.c
Expand Up @@ -663,7 +663,7 @@ static void SBE_InfoBox(source_t* s, int rightX, char* title, float alpha)
float eye[3];

FR_SetFont(glFontFixed);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
w = 16 + FR_TextFragmentWidth("R:0.000 G:0.000 B:0.000");
th = FR_TextFragmentHeight("Info");
h = 16 + th * 6;
Expand Down Expand Up @@ -691,7 +691,7 @@ static void SBE_InfoBox(source_t* s, int rightX, char* title, float alpha)
// - color

FR_SetFont(glFontFixed);
FR_SetTracking(0);
FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET);
UI_TextOutEx2(title, x, y, UI_Color(UIC_TITLE), alpha, DTF_ALIGN_LEFT|DTF_ONLY_SHADOW);
y += th;

Expand Down Expand Up @@ -753,7 +753,8 @@ static void SBE_DrawLevelGauge(int x, int y, int height)
maxLevel = sector->lightLevel;

FR_SetFont(glFontFixed);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET);
off = FR_TextFragmentWidth("000");

glBegin(GL_LINES);
Expand Down Expand Up @@ -828,7 +829,8 @@ void SBE_DrawHUD(void)
// Overall stats: numSources / MAX (left)
sprintf(buf, "%i / %i (%i free)", numSources, MAX_BIAS_LIGHTS, MAX_BIAS_LIGHTS - numSources);
FR_SetFont(glFontFixed);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET);
w = FR_TextFragmentWidth(buf) + 16;
h = FR_TextFragmentHeight(buf) + 16;
y = theWindow->height - 10 - h;
Expand All @@ -849,7 +851,6 @@ void SBE_DrawHUD(void)
{
int x;
FR_SetFont(glFontFixed);
FR_SetTracking(0);
x = FR_TextFragmentWidth("0") * 26;
SBE_InfoBox(s, x, "Grabbed", alpha);
}
Expand Down Expand Up @@ -920,7 +921,8 @@ static void SBE_DrawIndex(source_t *src)
// Show the index number of the source.
sprintf(buf, "%i", SB_ToIndex(src));
FR_SetFont(glFontFixed);
FR_SetTracking(0);
FR_LoadDefaultAttrib();
FR_SetShadowOffset(UI_SHADOW_OFFSET, UI_SHADOW_OFFSET);
UI_TextOutEx(buf, 2, 2, UI_Color(UIC_TITLE), 1 - M_Distance(src->pos, eye)/2000);

glMatrixMode(GL_MODELVIEW);
Expand Down

0 comments on commit 898ad8e

Please sign in to comment.