Skip to content

Commit

Permalink
Added current color to the font renderer attribute stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 16, 2011
1 parent b58b5a7 commit bfc25c9
Show file tree
Hide file tree
Showing 26 changed files with 411 additions and 277 deletions.
33 changes: 33 additions & 0 deletions doomsday/engine/api/dd_fontrenderer.h
Expand Up @@ -46,6 +46,10 @@ typedef uint32_t fontid_t;
*/
#define FR_DEF_ATTRIB_LEADING (.5)
#define FR_DEF_ATTRIB_TRACKING (0)
#define FR_DEF_ATTRIB_COLOR_RED (1)
#define FR_DEF_ATTRIB_COLOR_GREEN (1)
#define FR_DEF_ATTRIB_COLOR_BLUE (1)
#define FR_DEF_ATTRIB_ALPHA (1)
#define FR_DEF_ATTRIB_GLITTER_STRENGTH (.5)
#define FR_DEF_ATTRIB_SHADOW_STRENGTH (.5)
#define FR_DEF_ATTRIB_SHADOW_XOFFSET (2)
Expand Down Expand Up @@ -97,6 +101,35 @@ int FR_Tracking(void);

void FR_SetTracking(int value);

/// Retrieve the current color and alpha factors.
void FR_ColorAndAlpha(float rgba[4]);

void FR_SetColor(float red, float green, float blue);
void FR_SetColorv(const float rgb[3]);

void FR_SetColorAndAlpha(float red, float green, float blue, float alpha);
void FR_SetColorAndAlphav(const float rgba[4]);

/// @return Current red color factor.
float FR_ColorRed(void);

void FR_SetColorRed(float value);

/// @return Current green color factor.
float FR_ColorGreen(void);

void FR_SetColorGreen(float value);

/// @return Current blue color factor.
float FR_ColorBlue(void);

void FR_SetColorBlue(float value);

/// @return Current alpha factor.
float FR_Alpha(void);

void FR_SetAlpha(float value);

/// Retrieve the current shadow offset (attribute).
void FR_ShadowOffset(int* offsetX, int* offsetY);

Expand Down
63 changes: 38 additions & 25 deletions doomsday/engine/api/doomsday.def
@@ -1,6 +1,6 @@
; Doomsday Engine API (Routines exported from Doomsday.exe).
;
; Highest ordinal is currently: --> 518 <--
; Highest ordinal is currently: --> 531 <--
; Other free ordinals: 65

NAME "DOOMSDAY"
Expand Down Expand Up @@ -506,30 +506,43 @@ EXPORTS
FR_SetLeading @120 NONAME
FR_Tracking @121 NONAME
FR_SetTracking @122 NONAME
FR_ShadowOffset @123 NONAME
FR_SetShadowOffset @124 NONAME
FR_ShadowStrength @125 NONAME
FR_SetShadowStrength @131 NONAME
FR_GlitterStrength @197 NONAME
FR_SetGlitterStrength @198 NONAME
FR_CaseScale @199 NONAME
FR_SetCaseScale @200 NONAME

FR_TextDimensions @201 NONAME
FR_TextWidth @202 NONAME
FR_TextHeight @203 NONAME

FR_DrawText @204 NONAME
FR_DrawText2 @205 NONAME
FR_DrawText3 @206 NONAME

FR_DrawChar @513 NONAME
FR_DrawChar2 @514 NONAME
FR_DrawChar3 @515 NONAME

FR_CharDimensions @516 NONAME
FR_CharWidth @517 NONAME
FR_CharHeight @518 NONAME
FR_SetColor @123 NONAME
FR_SetColorv @124 NONAME
FR_ColorAndAlpha @125 NONAME
FR_SetColorAndAlpha @131 NONAME
FR_SetColorAndAlphav @197 NONAME
FR_ColorRed @198 NONAME
FR_SetColorRed @199 NONAME
FR_ColorGreen @200 NONAME
FR_SetColorGreen @201 NONAME
FR_ColorBlue @202 NONAME
FR_SetColorBlue @203 NONAME
FR_Alpha @204 NONAME
FR_SetAlpha @205 NONAME
FR_ShadowOffset @206 NONAME
FR_SetShadowOffset @513 NONAME
FR_ShadowStrength @514 NONAME
FR_SetShadowStrength @515 NONAME
FR_GlitterStrength @516 NONAME
FR_SetGlitterStrength @517 NONAME
FR_CaseScale @518 NONAME
FR_SetCaseScale @519 NONAME

FR_TextDimensions @520 NONAME
FR_TextWidth @521 NONAME
FR_TextHeight @522 NONAME

FR_DrawText @523 NONAME
FR_DrawText2 @524 NONAME
FR_DrawText3 @525 NONAME

FR_DrawChar @526 NONAME
FR_DrawChar2 @527 NONAME
FR_DrawChar3 @528 NONAME

FR_CharDimensions @529 NONAME
FR_CharWidth @530 NONAME
FR_CharHeight @531 NONAME

; Audio.
S_MapChange @225 NONAME
Expand Down
15 changes: 8 additions & 7 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -506,7 +506,7 @@ static void Con_BusyDrawIndicator(float x, float y, float radius, float pos)
{
FR_SetFont(busyFont);
FR_LoadDefaultAttrib();
glColor4f(1.f, 1.f, 1.f, .66f);
FR_SetColorAndAlpha(1.f, 1.f, 1.f, .66f);
FR_DrawText3(busyTaskName, x+radius, y, ALIGN_LEFT, DTF_ONLY_SHADOW);
}

Expand Down Expand Up @@ -620,22 +620,23 @@ void Con_BusyDrawConsoleOutput(void)

FR_SetFont(busyFont);
FR_LoadDefaultAttrib();
FR_SetColor(1.f, 1.f, 1.f);

for(i = 0; i < 2 * LINE_COUNT; ++i, y += busyFontHgt)
{
float color = 1;//lineAlpha[i];
const cbline_t* line = visibleBusyLines[i];
float alpha = 1;

if(!line)
continue;

color = ((y - topY) / busyFontHgt) - (LINE_COUNT - 1);
if(color < LINE_COUNT)
color = MINMAX_OF(0, color/2, 1);
alpha = ((y - topY) / busyFontHgt) - (LINE_COUNT - 1);
if(alpha < LINE_COUNT)
alpha = MINMAX_OF(0, alpha/2, 1);
else
color = 1 - (color - LINE_COUNT);
alpha = 1 - (alpha - LINE_COUNT);

glColor4f(1.f, 1.f, 1.f, color);
FR_SetAlpha(alpha);
FR_DrawText3(line->text, theWindow->width/2, y, ALIGN_TOP, DTF_ONLY_SHADOW);
}

Expand Down

0 comments on commit bfc25c9

Please sign in to comment.