Skip to content

Commit 5309703

Browse files
committed
Change default roller font style and add command line option
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent fcf1eaa commit 5309703

File tree

1 file changed

+48
-21
lines changed

1 file changed

+48
-21
lines changed

demo.c

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ typedef struct {
8484
Uint8 scroll_color[3]; /* Current scroll color (RGB) */
8585
float scroll_offset; /* Accumulated scroll offset */
8686
float last_frame_time; /* Time of last frame for delta calculation */
87+
int roller_effect; /* Roller text effect: 0=all, 1=no outline, 2=no outline/glow, 3=color outline */
8788
} DemoContext;
8889

8990
/* Plasma effect - optimized with lower resolution and LUT */
@@ -1703,30 +1704,40 @@ void render_scroll_text(DemoContext *ctx)
17031704
int dh = (int)(gcache[ch].h * scale);
17041705
SDL_Rect dest = {(int)char_x, y_pos - dh / 2, dw, dh};
17051706

1706-
/* Outline behind */
1707-
if (gcache[ch].tex_outline) {
1708-
SDL_SetTextureColorMod(gcache[ch].tex_outline, 0, 0, 0);
1709-
SDL_Rect od = dest;
1710-
od.x -= 1;
1711-
od.y -= 1;
1712-
SDL_RenderCopy(ctx->renderer, gcache[ch].tex_outline, NULL, &od);
1707+
/* Outline behind (configurable) */
1708+
if (ctx->roller_effect == 0 || ctx->roller_effect == 3) {
1709+
if (gcache[ch].tex_outline) {
1710+
if (ctx->roller_effect == 3) {
1711+
/* Color outline (thicker text effect) */
1712+
SDL_SetTextureColorMod(gcache[ch].tex_outline, r, g, b);
1713+
} else {
1714+
/* Black outline (drop shadow) */
1715+
SDL_SetTextureColorMod(gcache[ch].tex_outline, 0, 0, 0);
1716+
}
1717+
SDL_Rect od = dest;
1718+
od.x -= 1;
1719+
od.y -= 1;
1720+
SDL_RenderCopy(ctx->renderer, gcache[ch].tex_outline, NULL, &od);
1721+
}
17131722
}
17141723

17151724
/* Main glyph with color */
17161725
SDL_SetTextureColorMod(gcache[ch].tex, r, g, b);
17171726
SDL_RenderCopy(ctx->renderer, gcache[ch].tex, NULL, &dest);
17181727

1719-
/* Soft glow (additive, slightly larger, low alpha) */
1720-
SDL_SetTextureBlendMode(gcache[ch].tex, SDL_BLENDMODE_ADD);
1721-
SDL_SetTextureAlphaMod(gcache[ch].tex, 40);
1722-
SDL_Rect glow = dest;
1723-
glow.x -= 2;
1724-
glow.y -= 2;
1725-
glow.w += 4;
1726-
glow.h += 4;
1727-
SDL_RenderCopy(ctx->renderer, gcache[ch].tex, NULL, &glow);
1728-
SDL_SetTextureAlphaMod(gcache[ch].tex, 255);
1729-
SDL_SetTextureBlendMode(gcache[ch].tex, SDL_BLENDMODE_BLEND);
1728+
/* Soft glow (configurable) */
1729+
if (ctx->roller_effect != 2) {
1730+
SDL_SetTextureBlendMode(gcache[ch].tex, SDL_BLENDMODE_ADD);
1731+
SDL_SetTextureAlphaMod(gcache[ch].tex, 40);
1732+
SDL_Rect glow = dest;
1733+
glow.x -= 2;
1734+
glow.y -= 2;
1735+
glow.w += 4;
1736+
glow.h += 4;
1737+
SDL_RenderCopy(ctx->renderer, gcache[ch].tex, NULL, &glow);
1738+
SDL_SetTextureAlphaMod(gcache[ch].tex, 255);
1739+
SDL_SetTextureBlendMode(gcache[ch].tex, SDL_BLENDMODE_BLEND);
1740+
}
17301741
} else if (ctx->scroll_style == SCROLL_BOUNCE) {
17311742
/* Bouncing characters - each char bounces independently */
17321743
float bounce_phase = ctx->global_time * 4.0f + i * 0.5f;
@@ -1873,6 +1884,7 @@ static int usage(int rc)
18731884
printf("\nPlayback Options:\n");
18741885
printf(" -d, --duration SEC Scene duration in seconds (default: 15)\n");
18751886
printf(" -t, --text FILE Load scroll text from file\n");
1887+
printf(" -r, --roller N Roller effect: 0=all, 1=no outline, 2=clean, 3=color (default: 1)\n");
18761888
printf(" -h, --help Show this help message\n");
18771889
printf("\nScenes:\n");
18781890
printf(" 0 - Starfield 3 - Tunnel 6 - 3D Star Ball\n");
@@ -1902,9 +1914,9 @@ int main(int argc, char *argv[])
19021914
int scene_duration = 15000; /* Default: 15 seconds per scene */
19031915

19041916
/* Default scroll text */
1905-
const char *default_text = "Infix OS - The Container demo"
1917+
const char *default_text = "Infix OS - The Container demo{PAUSE:2}"
19061918
" *** Greetings to the demoscene <3"
1907-
" *** API first: NETCONF + RESTCONF"
1919+
" *** Infix is API first: NETCONF + RESTCONF"
19081920
" *** Say Hi to our mascot, Jack! :-)"
19091921
" *** YANG is the real HERO tho ..."
19101922
" *** Sponsored by Wires in Westeros"
@@ -1921,11 +1933,13 @@ int main(int argc, char *argv[])
19211933
{"window", required_argument, NULL, 'w'},
19221934
{"scale", required_argument, NULL, 's'},
19231935
{"text", required_argument, NULL, 't'},
1936+
{"roller", required_argument, NULL, 'r'},
19241937
{NULL, 0, NULL, 0}
19251938
};
19261939

19271940
int opt;
1928-
while ((opt = getopt_long(argc, argv, "hd:fw:s:t:", long_options, NULL)) != -1) {
1941+
int roller_effect = 1; /* Default: no outline, glow only */
1942+
while ((opt = getopt_long(argc, argv, "hd:fw:s:t:r:", long_options, NULL)) != -1) {
19291943
switch (opt) {
19301944
case 'h':
19311945
return usage(0);
@@ -1974,6 +1988,18 @@ int main(int argc, char *argv[])
19741988
scroll_file_path = optarg;
19751989
break;
19761990

1991+
case 'r':
1992+
roller_effect = atoi(optarg);
1993+
if (roller_effect < 0 || roller_effect > 3) {
1994+
fprintf(stderr, "Error: Invalid roller effect '%s'. Must be 0-3:\n", optarg);
1995+
fprintf(stderr, " 0 = All effects (outline + glow)\n");
1996+
fprintf(stderr, " 1 = No outline (glow only)\n");
1997+
fprintf(stderr, " 2 = No outline/glow (clean)\n");
1998+
fprintf(stderr, " 3 = Colored outline (thicker text)\n");
1999+
return 1;
2000+
}
2001+
break;
2002+
19772003
default:
19782004
return usage(1);
19792005
}
@@ -2033,6 +2059,7 @@ int main(int argc, char *argv[])
20332059
ctx.scroll_style = SCROLL_ROLLER_3D; /* Default scroll style */
20342060
ctx.scroll_offset = 0.0f;
20352061
ctx.last_frame_time = 0.0f;
2062+
ctx.roller_effect = roller_effect;
20362063

20372064
/* Load scroll text from file or use default */
20382065
if (scroll_file_path) {

0 commit comments

Comments
 (0)