[AD] Removing progress callbacks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Any halfway decent computer is able to execute create_rgb_table() and create_light_table() in the blink of an eye. I propose to remove the progress callbacks on calls to these functions in the examples. They aren't needed any more and it makes the examples simpler.

Additionally, progress callbacks can be removed from the colormap and rgbmap tools, and test. Actually, the rgbmap tool could be removed entirely (and colormap nearly so), but I'm not proposing that just yet.

Patch attached.

Peter
Index: examples/ex3d.c
===================================================================
RCS file: /cvsroot/alleg/allegro/examples/ex3d.c,v
retrieving revision 1.12
diff -u -r1.12 ex3d.c
--- examples/ex3d.c	2 Aug 2004 11:33:09 -0000	1.12
+++ examples/ex3d.c	14 Oct 2004 09:40:03 -0000
@@ -350,20 +350,6 @@
 
 
 
-void print_progress(int pos)
-{
-   #ifdef ALLEGRO_CONSOLE_OK
-
-      if ((pos & 3) == 3) {
-	 printf("*");
-	 fflush(stdout);
-      }
-
-   #endif
-}
-
-
-
 int main(void)
 {
    BITMAP *buffer;
@@ -401,37 +387,16 @@
       pal[c].r = pal[c].g = pal[c].b = (c-128)/2;
 
    /* build rgb_map table */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("Generating rgb_map table:\n");
-      printf("<................................................................>\r<");
-   #endif
-
-   create_rgb_table(&rgb_table, pal, print_progress);
+   create_rgb_table(&rgb_table, pal, NULL);
    rgb_map = &rgb_table;
 
    /* build a lighting table */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n\n");
-      printf("Generating lighting table:\n");
-      printf("<................................................................>\r<");
-   #endif
-
-   create_light_table(&light_table, pal, 0, 0, 0, print_progress);
+   create_light_table(&light_table, pal, 0, 0, 0, NULL);
    color_map = &light_table;
 
    /* build a transparency table */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n\n");
-      printf("Generating transparency table:\n");
-      printf("<................................................................>\r<");
-   #endif
-
    /* textures are 25% transparent (75% opaque) */
-   create_trans_table(&trans_table, pal, 192, 192, 192, print_progress);
-
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n");
-   #endif
+   create_trans_table(&trans_table, pal, 192, 192, 192, NULL);
 
    /* set up the truecolor blending functions */
    /* textures are 25% transparent (75% opaque) */
Index: examples/excolmap.c
===================================================================
RCS file: /cvsroot/alleg/allegro/examples/excolmap.c,v
retrieving revision 1.12
diff -u -r1.12 excolmap.c
--- examples/excolmap.c	2 Aug 2004 11:33:09 -0000	1.12
+++ examples/excolmap.c	14 Oct 2004 09:40:03 -0000
@@ -24,19 +24,6 @@
 
 
 
-/* progress indicator for the color table calculations */
-void callback_func(int pos)
-{
-   #ifdef ALLEGRO_CONSOLE_OK
-
-      printf(".");
-      fflush(stdout);
-
-   #endif
-}
-
-
-
 /* Here comes our custom function. It's designed to take the input colors
  * (red, green & blue) and return a greyscale color for it. This way, when
  * any drawing function draws say over green, it draws the greyscale color
@@ -117,30 +104,14 @@
    generate_background();
 
    /* this isn't needed, but it speeds up the color table calculations */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("Generating RGB Table (3.25 lines to go)\n");
-   #endif
-
-   create_rgb_table(&rgb_table, pal, callback_func);
+   create_rgb_table(&rgb_table, pal, NULL);
    rgb_map = &rgb_table;
 
    /* build a color lookup table for greyscale effect */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n\nGenerating Greyscale Table (3.25 lines to go)\n");
-   #endif
-
-   create_color_table(&greyscale_table, pal, return_grey_color, callback_func);
+   create_color_table(&greyscale_table, pal, return_grey_color, NULL);
 
    /* build a color lookup table for negative effect */
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n\nGenerating Negative Table (3.25 lines to go)\n");
-   #endif
-
-   create_color_table(&negative_table, pal, return_negative_color, callback_func);
-
-   #ifdef ALLEGRO_CONSOLE_OK
-      printf("\n\n");
-   #endif
+   create_color_table(&negative_table, pal, return_negative_color, NULL);
 
    if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
       if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
Index: tests/test.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tests/test.c,v
retrieving revision 1.31
diff -u -r1.31 test.c
--- tests/test.c	22 Aug 2004 01:57:15 -0000	1.31
+++ tests/test.c	14 Oct 2004 09:40:08 -0000
@@ -157,53 +157,29 @@
 
 
 
-void table_callback(int pos)
-{
-   rect(screen, (SCREEN_W-256)/2-1, 128, (SCREEN_W+256)/2+1, 140, palette_color[255]);
-   rectfill(screen, (SCREEN_W-256)/2, 129, (SCREEN_W-256)/2+pos, 139, palette_color[1]);
-}
-
-
-
 int check_tables(void)
 {
    if (bitmap_color_depth(screen) > 8) {
       set_trans_blender(0, 0, 0, 128);
    }
    else if ((!rgb_map) || (!trans_map) || (!light_map)) {
-      scare_mouse();
-
       if (!rgb_map) {
-	 acquire_screen();
-	 clear_to_color(screen, palette_color[0]);
-	 textout_centre_ex(screen, font, "Creating RGB table", SCREEN_W/2, 64, palette_color[255], palette_color[0]);
 	 rgb_map = malloc(sizeof(RGB_MAP));
-	 create_rgb_table(rgb_map, mypal, table_callback);
-	 release_screen();
+	 create_rgb_table(rgb_map, mypal, NULL);
       }
 
       if (!trans_map) {
-	 acquire_screen();
-	 clear_to_color(screen, palette_color[0]);
-	 textout_centre_ex(screen, font, "Creating translucency table", SCREEN_W/2, 64, palette_color[255], palette_color[0]);
 	 trans_map = malloc(sizeof(COLOR_MAP));
-	 create_trans_table(trans_map, mypal, 96, 96, 96, table_callback);
-	 release_screen();
+	 create_trans_table(trans_map, mypal, 96, 96, 96, NULL);
       }
 
       if (!light_map) {
-	 acquire_screen();
-	 clear_to_color(screen, palette_color[0]);
-	 textout_centre_ex(screen, font, "Creating lighting table", SCREEN_W/2, 64, palette_color[255], palette_color[0]);
 	 light_map = malloc(sizeof(COLOR_MAP));
-	 create_light_table(light_map, mypal, 0, 0, 0, table_callback);
-	 release_screen();
+	 create_light_table(light_map, mypal, 0, 0, 0, NULL);
       }
 
       color_map = trans_map;
 
-      unscare_mouse();
-
       return D_REDRAW;
    }
 
Index: tools/colormap.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/colormap.c,v
retrieving revision 1.5
diff -u -r1.5 colormap.c
--- tools/colormap.c	2 Aug 2004 11:33:09 -0000	1.5
+++ tools/colormap.c	14 Oct 2004 09:40:08 -0000
@@ -52,16 +52,6 @@
 
 
 
-void print_progress(int pos)
-{
-   if ((pos & 3) == 3) {
-      printf("*");
-      fflush(stdout);
-   }
-}
-
-
-
 int check_color_value(char *s, int def, int min, int max, char *t)
 {
    int val;
@@ -196,9 +186,8 @@
 
       printf("Solidity: red=%d%%, green=%d%%, blue=%d%%\n", rval*100/255, gval*100/255, bval*100/255);
       printf("Creating translucency color map\n");
-      printf("<................................................................>\r<");
 
-      create_trans_table(&the_map, the_pal, rval, gval, bval, print_progress);
+      create_trans_table(&the_map, the_pal, rval, gval, bval, NULL);
    }
    else {
       rval = check_color_value(r, 0, 0, 63, "red");
@@ -207,13 +196,10 @@
 
       printf("Light color: red=%d, green=%d, blue=%d\n", rval, gval, bval);
       printf("Creating lighting color map\n");
-      printf("<................................................................>\r<");
 
-      create_light_table(&the_map, the_pal, rval, gval, bval, print_progress);
+      create_light_table(&the_map, the_pal, rval, gval, bval, NULL);
    }
 
-   printf("\n");
-
    while (i < argc)
       modifier(argv[i++]);
 
Index: tools/rgbmap.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/rgbmap.c,v
retrieving revision 1.5
diff -u -r1.5 rgbmap.c
--- tools/rgbmap.c	2 Aug 2004 11:33:09 -0000	1.5
+++ tools/rgbmap.c	14 Oct 2004 09:40:08 -0000
@@ -36,16 +36,6 @@
 
 
 
-void print_progress(int pos)
-{
-   if ((pos & 3) == 3) {
-      printf("*");
-      fflush(stdout);
-   }
-}
-
-
-
 PALETTE the_pal;
 RGB_MAP the_map;
 
@@ -75,10 +65,8 @@
 
    printf("Palette read from '%s'\n", argv[1]);
    printf("Creating RGB map\n");
-   printf("<................................................................>\r<");
 
-   create_rgb_table(&the_map, the_pal, print_progress);
-   printf("\n");
+   create_rgb_table(&the_map, the_pal, NULL);
 
    f = pack_fopen(argv[2], F_WRITE);
    if (!f) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/