Example #1
0
static void draw(void)
{
   show_video_bitmap(pf_active_page);
   if (pf_active_page == pf_page1) {
      pf_active_page = pf_page2;
   } else {
      pf_active_page = pf_page1;
   }
}
Example #2
0
// ==========================================================================
void misc_draw_screen(int mx, int my)
{
    BITMAP * mouse_sprite = glb_ds1edit.mouse_cursor[MOD_T];
    BITMAP * video_bmp    = glb_ds1edit.video_page;

    draw_sprite(glb_ds1edit.screen_buff, mouse_sprite, mx, my);
    blit( glb_ds1edit.screen_buff, video_bmp, 0, 0, 0, 0, glb_config.screen.width, glb_config.screen.height);
    show_video_bitmap(video_bmp);
}
Example #3
0
void uip_displaybank(int bank)
{
  if (bank == -1)
    bank = uip_displaybanknum ^ 1;
  uip_writebank = bank ? uip_bank0 : uip_bank1;
  if (show_video_bitmap(bank ? uip_bank1 : uip_bank0))
    ui_err("Failed to page flip");
  uip_uipinfo->screenmem_w = bank ? uip_uipinfo->screenmem0 :
    uip_uipinfo->screenmem1;
  uip_displaybanknum = bank;
}
Example #4
0
BITMAP* SCREEN::flip_page(void)
{
    if (!doublebuffer) { // page flipping
        // swap pages
        show_video_bitmap(offscreen);
        video_page_offscreen = 1 - video_page_offscreen;
        offscreen = video_page[video_page_offscreen];

        return offscreen;
    }
    else { // double buffering
        blit(video_page[0], screen, 0, 0, 0, 0, w, h);
    }
    gui_set_screen(offscreen); // for the allegro gui routines
    return offscreen;
}
Example #5
0
int main(int argc, char *argv[])
{
   char buf[256];
   PALETTE pal;
   BITMAP *image;
   BITMAP *page[2];
   BITMAP *vimage;
   IMAGE images[MAX_IMAGES];
   int num_images = 4;
   int page_num = 1;
   int done = FALSE;
   int i;

   if (allegro_init() != 0)
      return 1;
   install_keyboard(); 
   install_timer();

   /* see comments in exflip.c */
#ifdef ALLEGRO_VRAM_SINGLE_SURFACE
   if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 2 * 768 + 200) != 0) {
#else
   if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0) != 0) {
#endif
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error setting graphics mode\n%s\n", allegro_error);
      return 1;
   }

   /* read in the source graphic */
   replace_filename(buf, argv[0], "mysha.pcx", sizeof(buf));
   image = load_bitmap(buf, pal);
   if (!image) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error reading %s!\n", buf);
      return 1;
   }

   set_palette(pal);

   /* initialise the images to random positions */
   for (i=0; i<MAX_IMAGES; i++)
      init_image(images+i);

   /* create two video memory bitmaps for page flipping */
   page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
   page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);

   /* create a video memory bitmap to store our picture */
   vimage = create_video_bitmap(image->w, image->h);

   if ((!page[0]) || (!page[1]) || (!vimage)) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Not enough video memory (need two 1024x768 pages "
		      "and a 320x200 image)\n");
      return 1;
   }

   /* copy the picture into offscreen video memory */
   blit(image, vimage, 0, 0, 0, 0, image->w, image->h);

   while (!done) {
      acquire_bitmap(page[page_num]);

      /* clear the screen */
      clear_bitmap(page[page_num]);

      /* draw onto it */
      for (i=0; i<num_images; i++)
	 blit(vimage, page[page_num], 0, 0, images[i].x, images[i].y,
	      vimage->w, vimage->h);

      textprintf_ex(page[page_num], font, 0, 0, 255, -1,
		    "Images: %d (arrow keys to change)", num_images);

      /* tell the user which functions are being done in hardware */
      if (gfx_capabilities & GFX_HW_FILL)
	 textout_ex(page[page_num], font, "Clear: hardware accelerated",
		    0, 16, 255, -1);
      else
	 textout_ex(page[page_num], font, "Clear: software (urgh, this "
		    "is not good!)", 0, 16, 255, -1);

      if (gfx_capabilities & GFX_HW_VRAM_BLIT)
	 textout_ex(page[page_num], font, "Blit: hardware accelerated",
		    0, 32, 255, -1);
      else
	 textout_ex(page[page_num], font, "Blit: software (urgh, this program "
		    "will run too sloooooowly without hardware acceleration!)",
		    0, 32, 255, -1);

      release_bitmap(page[page_num]);

      /* page flip */
      show_video_bitmap(page[page_num]);
      page_num = 1-page_num;

      /* deal with keyboard input */
      while (keypressed()) {
	 switch (readkey()>>8) {

	    case KEY_UP:
	    case KEY_RIGHT:
	       if (num_images < MAX_IMAGES)
		  num_images++;
	       break;

	    case KEY_DOWN:
	    case KEY_LEFT:
	       if (num_images > 0)
		  num_images--;
	       break;

	    case KEY_ESC:
	       done = TRUE;
	       break;
	 }
      }

      /* bounce the images around the screen */
      for (i=0; i<num_images; i++)
	 update_image(images+i);
   }

   destroy_bitmap(image);
   destroy_bitmap(vimage);
   destroy_bitmap(page[0]);
   destroy_bitmap(page[1]);

   return 0;
}

END_OF_MAIN()
Example #6
0
int main(void)
{
   BITMAP *buffer;
   BITMAP *page1, *page2;
   BITMAP *active_page;
   int c;

   if (allegro_init() != 0)
      return 1;
   install_timer();
   install_keyboard();

   /* Some platforms do page flipping by making one large screen that you
    * can then scroll, while others give you several smaller, unique
    * surfaces. If you use the create_video_bitmap() function, the same
    * code can work on either kind of platform, but you have to be careful
    * how you set the video mode in the first place. We want two pages of
    * 320x200 video memory, but if we just ask for that, on DOS Allegro
    * might use a VGA driver that won't later be able to give us a second
    * page of vram. But if we ask for the full 320x400 virtual screen that
    * we want, the call will fail when using DirectX drivers that can't do
    * this. So we try two different mode sets, first asking for the 320x400
    * size, and if that doesn't work, for 320x200.
    */
   if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 400) != 0) {
      if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
	 if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
	    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	    allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
	    return 1;
         }
      }
   }

   set_palette(desktop_palette);

   /* allocate the memory buffer */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);

   /* first with a double buffer... */
   clear_keybuf();
   c = retrace_count+32;
   while (retrace_count-c <= SCREEN_W+32) {
      clear_to_color(buffer, makecol(255, 255, 255));
      circlefill(buffer, retrace_count-c, SCREEN_H/2, 32, makecol(0, 0, 0));
      textprintf_ex(buffer, font, 0, 0, makecol(0, 0, 0), -1,
		    "Double buffered (%s)", gfx_driver->name);
      blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

      if (keypressed())
	 break;
   }

   destroy_bitmap(buffer);

   /* now create two video memory bitmaps for the page flipping */
   page1 = create_video_bitmap(SCREEN_W, SCREEN_H);
   page2 = create_video_bitmap(SCREEN_W, SCREEN_H);

   if ((!page1) || (!page2)) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Unable to create two video memory pages\n");
      return 1;
   }

   active_page = page2;

   /* do the animation using page flips... */
   clear_keybuf();
   for (c=-32; c<=SCREEN_W+32; c++) {
      clear_to_color(active_page, makecol(255, 255, 255));
      circlefill(active_page, c, SCREEN_H/2, 32, makecol(0, 0, 0));
      textprintf_ex(active_page, font, 0, 0, makecol(0, 0, 0), -1,
		    "Page flipping (%s)", gfx_driver->name);
      show_video_bitmap(active_page);

      if (active_page == page1)
	 active_page = page2;
      else
	 active_page = page1;

      if (keypressed())
	 break;
   }

   destroy_bitmap(page1);
   destroy_bitmap(page2);

   return 0;
}
/*
 * call-seq:
 *   show_video_bitmap(bitmap) -> int
 *
 * Attempts to page flip the hardware screen to display the specified video
 * bitmap object, which must be the same size as the physical screen, and should
 * have been obtained by calling the create_video_bitmap function.
 *
 * Allegro will handle any necessary vertical retrace synchronisation when page
 * flipping, so you don't need to call vsync before it. This means that
 * show_video_bitmap has the same time delay effects as vsync by default. This
 * can be adjusted with the "disable_vsync" config key in the [graphics] section
 * of allegro.cfg. Example:
 *   video_page = Array.new
 *   ...
 *   # Create pages for page flipping
 *   video_page[0] = create_video_bitmap(SCREEN_W, SCREEN_H)
 *   video_page[1] = create_video_bitmap(SCREEN_W, SCREEN_H)
 *   current_page = 0
 *   ...
 *   # draw the screen and flip pages
 *   draw_screen(video_page[current_page])
 *   show_video_bitmap(video_page[current_page])
 *   current_page = (current_page + 1) % 2
 *   ...
 *
 * Return value: Returns zero on success and non-zero on failure.
 */
VALUE a4r_API_show_video_bitmap(VALUE self, VALUE bitmap)
{
  BITMAP *bmp;
  Data_Get_Struct(bitmap, BITMAP, bmp);
  return INT2FIX(show_video_bitmap(bmp));
}