Mail Archives: djgpp/1997/05/23/14:34:38
On 23 May 1997 01:45:03 GMT, "Alex Kain" <syntaxlogic AT earthlink DOT net>
wrote:
> Is using the translucence/lighting procedure in Allegro possible and/or
> practical in 640x480x256 svga? I'd like to know how fast such a task would
> take, if it is possible.
It is possible. Here is a patch for ex24.c from allegro2.2 sources.
To apply this patch, go to the directory where you unpack allegro
(there should be `examples' directory with ex24.c in it) and do:
patch < ex24.dif
Changes are:
1. you can choose video mode
2. background bitmap is scaled to the size of screen
To make it faster/smoother use different techniques for redrawing,
say, dirty rectangles.
--- start of ex24.dif ---
*** examples/ex24.c Sun Jan 19 17:50:14 1997
--- examples/ex24.c~ Mon May 12 19:37:56 1997
***************
*** 35,44 ****
--- 35,46 ----
int main(int argc, char *argv[])
{
+ int c, w, h;
PALLETE pal;
BITMAP *s;
BITMAP *temp;
BITMAP *spotlight;
+ BITMAP *old_background;
BITMAP *background;
int i, x, y;
char buf[80];
***************
*** 47,52 ****
--- 49,55 ----
allegro_init();
install_keyboard();
install_mouse();
+ install_timer ();
/* load the main screen image */
if (argc > 1)
***************
*** 57,64 ****
filename = buf;
}
! background = load_bitmap(filename, pal);
! if (!background) {
printf("Error reading %s!\n", filename);
return 1;
}
--- 60,67 ----
filename = buf;
}
! old_background = load_bitmap(filename, pal);
! if (!old_background) {
printf("Error reading %s!\n", filename);
return 1;
}
***************
*** 77,88 ****
create_trans_table(&trans_table, pal, 128, 128, 128,
callback_func);
set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
set_pallete(pal);
! s = create_bitmap(320, 200);
spotlight = create_bitmap(128, 128);
temp = create_bitmap(128, 128);
/* generate a spotlight image */
clear(spotlight);
for(i=0; i<256; i++)
--- 80,110 ----
create_trans_table(&trans_table, pal, 128, 128, 128,
callback_func);
set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
+ set_palette (desktop_palette);
+ if (!gfx_mode_select (&c, &w, &h))
+ {
+ allegro_exit ();
+ exit (1);
+ }
+
+ if (set_gfx_mode (c, w, h, 0, 0) != 0)
+ {
+ allegro_exit ();
+ printf ("error: can not set mode\n");
+ exit (1);
+ }
+
set_pallete(pal);
! s = create_bitmap(w, h);
spotlight = create_bitmap(128, 128);
temp = create_bitmap(128, 128);
+ background = create_bitmap (w, h);
+ stretch_blit (old_background, background,
+ 0, 0, old_background->w, old_background->h,
+ 0, 0, w, h);
+
/* generate a spotlight image */
clear(spotlight);
for(i=0; i<256; i++)
***************
*** 101,114 ****
blit(background, s, x, y, x, y, 128, 128);
draw_trans_sprite(s, spotlight, x, y);
! blit(s, screen, 0, 0, 0, 0, 320, 200);
} while (!keypressed());
readkey();
/* generate an overlay image (just shrink the main image) */
! stretch_blit(background, spotlight, 0, 0, 320, 200, 0, 0, 128,
128);
/* select the translucency table */
color_map = &trans_table;
--- 123,138 ----
blit(background, s, x, y, x, y, 128, 128);
draw_trans_sprite(s, spotlight, x, y);
! blit(s, screen, 0, 0, 0, 0, w, h);
} while (!keypressed());
readkey();
/* generate an overlay image (just shrink the main image) */
! stretch_blit(old_background, spotlight,
! 0, 0, old_background->w, old_background->h,
! 0, 0, 128, 128);
/* select the translucency table */
color_map = &trans_table;
***************
*** 118,127 ****
x = mouse_x - 64;
y = mouse_y - 64;
! blit(background, s, 0, 0, 0, 0, 320, 200);
draw_trans_sprite(s, spotlight, x, y);
! blit(s, screen, 0, 0, 0, 0, 320, 200);
} while (!keypressed());
--- 142,151 ----
x = mouse_x - 64;
y = mouse_y - 64;
! blit(background, s, 0, 0, 0, 0, w, h);
draw_trans_sprite(s, spotlight, x, y);
! blit(s, screen, 0, 0, 0, 0, w, h);
} while (!keypressed());
--- end of ex24.dif ---
- Raw text -