Exemple #1
0
void
vgainit(void)
{
    {int b=0; while (b);}
    if (geteuid() != 0) {
	fprintf(stderr, "The current graphics console architecture only permits " \
		"super-user to access it, therefore you either have to obtain such permissions" \
	  "or ask your sysadmin to put set-user-id on digger executable.\n");
	exit(1);
    }
    if (VGLInit(SW_VESA_CG640x400) != 0) {
	fprintf(stderr, "WARNING! Could not initialise VESA mode. " \
		"Trying to fallback to the VGA 640x480 mode\n");
	if (VGLInit(SW_CG640x480) == 0)
		yoffset = 40;		/* Center the image */
	else  {
		fprintf(stderr, "WARNING! Could not initialise VGA mode either. " \
		"Please check your kernel.\n");
		exit(1);
	}
    }
    vgl_inited = 1;

    sVGLDisplay = VGLBitmapCreate(MEMBUF, 640, 400, NULL);
    VGLBitmapAllocateBits(sVGLDisplay);
    VGLClear(sVGLDisplay, 0);

    /*
     * Since the VGL library doesn't provide a default way to restore console
     * and keyboard after uncatched by the program signal, we should try to
     * catch at least what we could catch and pray to God that he would not
     * send SIGKILL to us.
     */
    signal(SIGHUP, catcher);
    signal(SIGINT, catcher);
    signal(SIGQUIT, catcher);
    signal(SIGABRT, catcher);
    signal(SIGTERM, catcher);
    signal(SIGSEGV, catcher);
    signal(SIGBUS, catcher);
    signal(SIGILL, catcher);
}
Exemple #2
0
int
main(int argc, char *argv[])
{
	int i,j,k;
	char c;
	int res=0;
	int x,y;
	char buttons;
	struct termios t_new,t_old;
	FILE *fsc;

	char buf[100];

	progname=argv[0];
	screen_gamma=1.5;
#ifdef DEBUG
	log=fopen("/png/view.log","w");
#endif
	while((c=getopt(argc,argv,"r:g:"))!=-1) {
		switch(c) {
		case 'r':
			res=atoi(optarg);
			if(res>0) max_screen_colors=256;
			break;
		case 'g':
			screen_gamma=atof(optarg);
			break;
		case '?':
		default:
			usage();
			exit(0);
		}
	}
	switch(res) {
	case 0:
		VGLInit(SW_CG640x480);
		break;
	case 1:
		VGLInit(SW_VGA_CG320);
		break;
	case 2:
		VGLInit(SW_VGA_MODEX);
		break;
	default:
		fprintf(stderr,"No such resolution!\n");
		usage();
		exit(-1);
	}
#ifdef DEBUG
	fprintf(log,"VGL initialised\n");
#endif
	VGLSavePalette();
	if(argc>optind) {
		res=png_load(argv[optind]);
	} else {
		VGLEnd();
		usage();
		exit(0);
	}
	if(res) {
		/* Hmm... Script? */
		fsc=fopen(argv[optind],"r");
#ifdef DEBUG
		fprintf(log,"Trying script %s\n",argv[optind]);
#endif
		fgets(buf,99,fsc);
		buf[strlen(buf)-1]='\0';
		if(strncmp("VIEW SCRIPT",buf,11)!=NULL) {
			VGLEnd();
			usage();
		}
		if(strlen(buf)>12) {
			auto_chg=atoi(buf+12);
		}
		fgets(buf,99,fsc);
		buf[strlen(buf)-1]='\0';
		nimg=atoi(buf);
		if(nimg==0) {
			VGLEnd();
			usage();
		}
		pres=(char **)calloc(nimg,sizeof(char *));
		for(i=0;i<nimg;i++) {
			fgets(buf,99,fsc);
			buf[strlen(buf)-1]='\0';
			pres[i]=strdup(buf);
		}
		fclose(fsc);
		cur_img=0;
#ifdef DEBUG
		fprintf(log,"Script with %d entries\n",nimg);
#endif
		png_load(pres[cur_img]);
	}
	VGLMouseInit(VGL_MOUSEHIDE);
	/* Prepare the keyboard */
	tcgetattr(0,&t_old);
	memcpy(&t_new,&t_old,sizeof(struct termios));
	cfmakeraw(&t_new);
	tcsetattr(0,TCSAFLUSH,&t_new);
	fcntl(0,F_SETFL,O_ASYNC);
	/* XXX VGLClear doesn't work.. :-(( Prepare a blank background */
	bkg.Bitmap=(byte *)calloc(VGLDisplay->Xsize*VGLDisplay->Ysize,1);
	bkg.Xsize=VGLDisplay->Xsize;
	bkg.Ysize=VGLDisplay->Ysize;
	bkg.Type=VGLDisplay->Type;
	signal(SIGIO,kbd_handler);
	a.zoom=1;
	a.Xshift=(VGLDisplay->Xsize-pic.Xsize)/2;
	a.Yshift=(VGLDisplay->Ysize-pic.Ysize)/2;
	a.rotate=0;
	quit=0;
	changed=0;
	display(&pic,pal_red,pal_green,pal_blue,&a);
	while(!quit) {
		if(act) {
#ifdef DEBUG
			fprintf(log,"kbd_action(%c)\n",act);
#endif
			kbd_action(x,y,act);
		}
		if(quit) break;
		if(changed) {
#ifdef DEBUG
			fprintf(log,"changed, redisplaying\n");
#endif
			display(&pic,pal_red,pal_green,pal_blue,&a);
			changed=0;
		}
		if(auto_chg) {
			sleep(auto_chg);
			kbd_action(x,y,'n');
		} else {
			pause();
		}
		VGLMouseStatus(&x,&y,&buttons);
		if(buttons & MOUSE_BUTTON3DOWN) {
#ifdef DEBUG
			fprintf(log,"pop_up called\n");
#endif
			pop_up("View",x,y);
		}
	}
	VGLEnd();
#ifdef DEBUG
	fclose(log);
#endif
	exit(0);
}
Exemple #3
0
int
main(int argc, char **argv)
{
  int y, xsize, ysize, i,j;
  VGLBitmap *tmp;

  // set graphics mode, here 320x240 256 colors
  // supported modes are (from <sys/consio.h>):
  // SW_VGA_CG320:      std VGA 320x200 256 colors
  // SW_VGA_MODEX:      Modex VGA 320x240 256 colors
  // SW_VGA_VG640:      std VGA 640x480 16 colors
  VGLInit(SW_VGA_MODEX);

  // initialize mouse and show pointer
  VGLMouseInit(VGL_MOUSESHOW);

  // VGLDisplay is a ptr to a struct Bitmap defined and initialized by
  // libvgl. The Bitmap points directly to screen memory etc.
  xsize=VGLDisplay->Xsize;
  ysize=VGLDisplay->Ysize;

  // alloc a new bitmap
  tmp = VGLBitmapCreate(MEMBUF, 256, 256, NULL);
  VGLBitmapAllocateBits(tmp);
  VGLClear(tmp, 0);

  // fill the screen with colored lines
  for (y=0; y<ysize; y++)
    VGLLine(VGLDisplay, 0, y, xsize-1, y, y/2 % 256);

  // draw some lines and circles just to show off
  VGLLine(VGLDisplay, 0, 0, xsize-1, ysize-1, 63);
  VGLLine(VGLDisplay, 0, ysize-1, xsize-1, 0, 63);
  VGLLine(VGLDisplay, 0, 0, 0, ysize-1, 63);
  VGLLine(VGLDisplay, xsize-1, 0, xsize-1, ysize-1, 63);
  VGLEllipse(VGLDisplay, 256, 0, 256, 256, 63);
  VGLEllipse(VGLDisplay, 0, 256, 256, 256, 0);

  // some text is also useful
  VGLBitmapString(VGLDisplay, 100,100,
    "This is text", 63, 0, 0, VGL_DIR_RIGHT);
  sleep(2);
  VGLBitmapString(VGLDisplay, 100,100,
    "This is text", 63, 0, 0, VGL_DIR_UP);
  sleep(2);
  VGLBitmapString(VGLDisplay, 100,100,
    "This is text", 63, 0, 0, VGL_DIR_LEFT);
  sleep(2);
  VGLBitmapString(VGLDisplay, 100,100,
    "This is text", 63, 0, 0, VGL_DIR_DOWN);
  sleep(2);

  // now show some simple bitblit
  for (i=0; i<256; i++)
    for (j=0; j<256; j++)
      tmp->Bitmap[i+256*j] = i%16;
  VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 0, 0, 128, 128);
  for (i=0; i<256; i++)
    for (j=0; j<256; j++)
      tmp->Bitmap[i+256*j] = j%16;
  VGLBitmapCopy(tmp, 0, 0, VGLDisplay, 3, 128, 128, 128);
  sleep(2);
  VGLBitmapCopy(VGLDisplay, 237, 311, tmp, 64, 64, 128, 128);
  VGLBitmapCopy(tmp, 32, 32, VGLDisplay, 400, 128, 128, 128);
  sleep(2);
  VGLBitmapCopy(VGLDisplay, 300, 300, VGLDisplay, 500, 128, 128, 128);
  sleep(5);
  i=0;

  // loop around drawing and copying
  while (++i) {
    VGLBitmapCopy(VGLDisplay, rand()%xsize, rand()%ysize,
                  VGLDisplay, rand()%xsize, rand()%ysize,
                  rand()%xsize, rand()%ysize);
    VGLLine(VGLDisplay,  rand()%xsize, rand()%ysize, 
            rand()%xsize, rand()%ysize, rand()%256);
    VGLEllipse(VGLDisplay, rand()%xsize, rand()%ysize,
               rand()%xsize/2, rand()%ysize/2, rand()%256);
    rand();
    if (i > 1000) break;
  }

  // restore screen to its original mode
  VGLEnd();
  return 0;
}
SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current,
			      int width, int height, int bpp, Uint32 flags)
{
	int mode_found;
	int i;
	VGLMode **modes;

	modes = VGLListModes(bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
	mode_found = 0;
	for (i = 0; modes[i] != NULL; i++) {
		if ((modes[i]->ModeInfo.Xsize == width) &&
		    (modes[i]->ModeInfo.Ysize == height) &&
		    ((modes[i]->ModeInfo.Type == VIDBUF8) ||
		     (modes[i]->ModeInfo.Type == VIDBUF16) ||
		     (modes[i]->ModeInfo.Type == VIDBUF32))) {
			mode_found = 1;
			break;
		}
	}
	if (mode_found == 0) {
		SDL_SetError("No matching video mode found");
		return NULL;
	}

	
	if (VGLCurMode != NULL)
		VGLEnd();

	
	if (VGLInit(modes[i]->ModeId) != 0) {
		SDL_SetError("Unable to switch to requested mode");
		return NULL;
	}

	VGLCurMode = SDL_realloc(VGLCurMode, sizeof(VGLMode));
	VGLCurMode->ModeInfo = *VGLDisplay;
	VGLCurMode->Depth = modes[i]->Depth;
	VGLCurMode->ModeId = modes[i]->ModeId;
	VGLCurMode->Rmask = modes[i]->Rmask;
	VGLCurMode->Gmask = modes[i]->Gmask;
	VGLCurMode->Bmask = modes[i]->Bmask;

	
	if (VGLCurMode->ModeInfo.PixelBytes == 0)
		(VGLCurMode->ModeInfo.PixelBytes = 1);

	current->w = VGLCurMode->ModeInfo.Xsize;
	current->h = VGLCurMode->ModeInfo.Ysize;
	current->pixels = VGLCurMode->ModeInfo.Bitmap;
	current->pitch = VGLCurMode->ModeInfo.Xsize *
			 VGLCurMode->ModeInfo.PixelBytes;
	current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);

	
	if (VGLCurMode->ModeInfo.Type == VIDBUF8)
		current->flags |= SDL_HWPALETTE;

	
	if (flags & SDL_DOUBLEBUF) {
		if (VGLCurMode->ModeInfo.Xsize * 2 <=
		    VGLCurMode->ModeInfo.VYsize) {
			current->flags |= SDL_DOUBLEBUF;
			flip_page = 0;
			flip_address[0] = (byte *)current->pixels;
			flip_address[1] = (byte *)current->pixels +
					  current->h * current->pitch;
			VGL_FlipHWSurface(this, current);
		}
	}

	if (! SDL_ReallocFormat(current, modes[i]->Depth, VGLCurMode->Rmask,
				VGLCurMode->Gmask, VGLCurMode->Bmask, 0)) {
		return NULL;
	}

	
	VGL_UpdateVideoInfo(this);

	
	this->UpdateRects = VGL_DirectUpdate;

	
	return current;
}
Exemple #5
0
int GGI_vgl_setmode(ggi_visual *vis, ggi_mode *tm)
{ 
	struct vgl_priv *priv = VGL_PRIV(vis);
	ggi_graphtype gt = tm->graphtype;
	video_info_t modeinfo;
	unsigned long modenum = 0;
	char sugname[GGI_MAX_APILEN];
	char args[GGI_MAX_APILEN];
	int err = 0;
	int id, i;
	int pixelBytes;

	err = GGI_vgl_checkmode(vis, tm);
	if (err) return err;

	/* reset the modeinfo structure as expected by query_mode */
	memset(&modeinfo, 0, sizeof(modeinfo));
	
	switch(gt) {
	case GT_1BIT : modeinfo.vi_depth = 1; pixelBytes = 1; break;
	case GT_4BIT : modeinfo.vi_depth = 4; pixelBytes = 1; break;
	case GT_8BIT : modeinfo.vi_depth = 8; pixelBytes = 1; break;
	case GT_16BIT: modeinfo.vi_depth = 16; pixelBytes = 2; break;
	case GT_32BIT: modeinfo.vi_depth = 32; pixelBytes = 4; break;

	/* Unsupported mode depths */
	case GT_15BIT:
	case GT_24BIT:
	default:
		return GGI_ENOMATCH;
	}

	modeinfo.vi_width = tm->visible.x;
	modeinfo.vi_height = tm->visible.y;

	/* XXX should be added to libvgl */
	if (ioctl(0, FBIO_FINDMODE, &modeinfo))
		return -1;

	DPRINT("Setting VGLlib mode %d (0x%x)\n",
			modeinfo.vi_mode, modeinfo.vi_mode);

	/* Terminate any current mode before initialising another */
	if (priv->vgl_init_done) {
		priv->vgl_init_done = 0;
		VGLEnd();
	}

	/* XXX should be in VGL */
	if ((modeinfo.vi_mode >= M_B40x25) && (modeinfo.vi_mode <= M_VGA_M90x60))
		modenum = _IO('S', modeinfo.vi_mode);
	if ((modeinfo.vi_mode >= M_TEXT_80x25) && (modeinfo.vi_mode <= M_TEXT_132x60))
		modenum = _IO('S', modeinfo.vi_mode);
	if ((modeinfo.vi_mode >= M_VESA_CG640x400) &&
		(modeinfo.vi_mode <= M_VESA_FULL_1280))
		modenum = _IO('V', modeinfo.vi_mode - M_VESA_BASE);

	if ((err = VGLInit(modenum)) != 0) {
		DPRINT("display-vgl: setting mode 0x%x failed with error %d\n",
			modeinfo.vi_mode, err);
		return GGI_EFATAL;
	}

	priv->vgl_init_done = 1;

	if (priv->vgl_use_db) {
		_GGI_vgl_freedbs(vis);

		/* Set up DirectBuffer(s) */
		for (i = 0; i<tm->frames; i++) {
			if (LIBGGI_FB_SIZE(tm) >
				(unsigned)(VGLDisplay->Xsize*VGLDisplay->Ysize*
					pixelBytes)) {
				fprintf(stderr, "display-vgl: framebuffer too large! (%d > %d*%d*%d)\n",
					LIBGGI_FB_SIZE(tm),
					VGLDisplay->Xsize, VGLDisplay->Ysize, 
					pixelBytes);
				return GGI_ENOMEM;
			}

			_ggi_db_add_buffer(LIBGGI_APPLIST(vis), _ggi_db_get_new());

			LIBGGI_APPBUFS(vis)[i]->frame = i;
			LIBGGI_APPBUFS(vis)[i]->type = GGI_DB_NORMAL | GGI_DB_SIMPLE_PLB;
			LIBGGI_APPBUFS(vis)[i]->read = VGLDisplay->Bitmap;
			LIBGGI_APPBUFS(vis)[i]->write = VGLDisplay->Bitmap;
			LIBGGI_APPBUFS(vis)[i]->layout = blPixelLinearBuffer;
			LIBGGI_APPBUFS(vis)[i]->buffer.plb.stride
				= GT_ByPPP(tm->virt.x, tm->graphtype);
		}
	}

	/* Save mode info returned by the VESA driver */
	bcopy(&modeinfo, &priv->modeinfo, sizeof(priv->modeinfo));

	/* Palette */
	if (vis->palette) {
		free(vis->palette);
		vis->palette = NULL;
	}
	if (priv->savepalette) {
		free(priv->savepalette);
		priv->savepalette = NULL;
	}
	if (GT_SCHEME(tm->graphtype) == GT_PALETTE) {
		int len = 1 << GT_DEPTH(tm->graphtype);

		vis->palette = malloc(len * sizeof(ggi_color));
		if (vis->palette == NULL) return GGI_EFATAL;
		priv->savepalette = malloc(sizeof(int) * (len*3));
		if (priv->savepalette == NULL) return GGI_EFATAL;

		/* Set an initial palette */
		ggiSetColorfulPalette(vis);
	}

	/* Set up pixel format */
	memset(LIBGGI_PIXFMT(vis), 0, sizeof(ggi_pixelformat));
	LIBGGI_PIXFMT(vis)->size  = GT_SIZE(gt);
	LIBGGI_PIXFMT(vis)->depth = GT_DEPTH(gt);

	switch (GT_SCHEME(gt)) {

	case GT_PALETTE:
	case GT_GREYSCALE:
		LIBGGI_PIXFMT(vis)->clut_mask = (1 << GT_DEPTH(gt)) - 1;
		break;

	case GT_TRUECOLOR:
		DPRINT_MODE("display-vgl: RGB %d:%d:%d offsets %d:%d:%d\n",
			priv->modeinfo.vi_pixel_fsizes[VGL_RED_INDEX],
			priv->modeinfo.vi_pixel_fsizes[VGL_GREEN_INDEX],
			priv->modeinfo.vi_pixel_fsizes[VGL_BLUE_INDEX],
			priv->modeinfo.vi_pixel_fields[VGL_RED_INDEX],
			priv->modeinfo.vi_pixel_fields[VGL_GREEN_INDEX],
			priv->modeinfo.vi_pixel_fields[VGL_BLUE_INDEX]);

		LIBGGI_PIXFMT(vis)->red_mask =
		((1 << priv->modeinfo.vi_pixel_fsizes[VGL_RED_INDEX]) - 1) <<
			priv->modeinfo.vi_pixel_fields[VGL_RED_INDEX];

		LIBGGI_PIXFMT(vis)->green_mask =
		((1 << priv->modeinfo.vi_pixel_fsizes[VGL_GREEN_INDEX]) - 1) <<
			priv->modeinfo.vi_pixel_fields[VGL_GREEN_INDEX];
			
		LIBGGI_PIXFMT(vis)->blue_mask =
		((1 << priv->modeinfo.vi_pixel_fsizes[VGL_BLUE_INDEX]) - 1) <<
			priv->modeinfo.vi_pixel_fields[VGL_BLUE_INDEX];
		break;

	case GT_TEXT:
		/* Assumes VGA text */
		LIBGGI_PIXFMT(vis)->texture_mask = 0x00ff;
		LIBGGI_PIXFMT(vis)->fg_mask = 0x0f00;
		LIBGGI_PIXFMT(vis)->bg_mask = 0xf000;
		break;
	}
	_ggi_build_pixfmt(LIBGGI_PIXFMT(vis));

	memcpy(LIBGGI_MODE(vis),tm,sizeof(ggi_mode));

	_ggiZapMode(vis, 0);

	for(id = 1; 0 == GGI_vgl_getapi(vis, id, sugname, args); id++) {
		if (_ggiOpenDL(vis, _ggiGetConfigHandle(), sugname, args, NULL)) {
			fprintf(stderr,"display-vgl: Can't open the %s (%s) library.\n",
				sugname, args);
			return GGI_EFATAL;
		} else {
			DPRINT("Success in loading %s (%s)\n", sugname, args);
		}
	}

	if (!priv->vgl_use_db) {
		vis->opdraw->putpixel		= GGI_vgl_putpixel;
		vis->opdraw->putpixel_nc	= GGI_vgl_putpixel_nc;
		vis->opdraw->getpixel		= GGI_vgl_getpixel;
		vis->opdraw->drawpixel		= GGI_vgl_drawpixel;
		vis->opdraw->drawpixel_nc	= GGI_vgl_drawpixel_nc;
		vis->opdraw->drawhline		= GGI_vgl_drawhline;
		vis->opdraw->drawhline_nc	= GGI_vgl_drawhline_nc;
		vis->opdraw->drawvline		= GGI_vgl_drawvline;
		vis->opdraw->drawvline_nc	= GGI_vgl_drawvline_nc;
		vis->opdraw->drawbox		= GGI_vgl_drawbox;
		vis->opdraw->drawline		= GGI_vgl_drawline;
		vis->opdraw->puthline		= GGI_vgl_puthline;
		vis->opdraw->putbox		= GGI_vgl_putbox;
	} else {
		vis->opdraw->setorigin		= GGI_vgl_setorigin;
	}

	if (GT_SCHEME(tm->graphtype) == GT_PALETTE) {
		vis->opcolor->setpalvec = GGI_vgl_setpalvec;
	}

	if(priv->vgl_use_db) {
		for(i = 0; i<tm->frames; i++)
			LIBGGI_APPBUFS(vis)[i]->buffer.plb.pixelformat =
								LIBGGI_PIXFMT(vis);
	}

	ggiIndicateChange(vis, GGI_CHG_APILIST);

	return 0;
}
Exemple #6
0
SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current,
			      int width, int height, int bpp, Uint32 flags)
{
	int mode_found;
	int i;
	VGLMode **modes;

	modes = VGLListModes(bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
	mode_found = 0;
	for (i = 0; modes[i] != NULL; i++) {
		if ((modes[i]->ModeInfo.Xsize == width) &&
		    (modes[i]->ModeInfo.Ysize == height) &&
		    ((modes[i]->ModeInfo.Type == VIDBUF8) ||
		     (modes[i]->ModeInfo.Type == VIDBUF16) ||
		     (modes[i]->ModeInfo.Type == VIDBUF32))) {
			mode_found = 1;
			break;
		}
	}
	if (mode_found == 0) {
		SDL_SetError("No matching video mode found");
		return NULL;
	}

	/* Shutdown previous videomode (if any) */
	if (VGLCurMode != NULL)
		VGLEnd();

	/* Try to set the requested linear video mode */
	if (VGLInit(modes[i]->ModeId) != 0) {
		SDL_SetError("Unable to switch to requested mode");
		return NULL;
	}

	VGLCurMode = SDL_realloc(VGLCurMode, sizeof(VGLMode));
	VGLCurMode->ModeInfo = *VGLDisplay;
	VGLCurMode->Depth = modes[i]->Depth;
	VGLCurMode->ModeId = modes[i]->ModeId;
	VGLCurMode->Rmask = modes[i]->Rmask;
	VGLCurMode->Gmask = modes[i]->Gmask;
	VGLCurMode->Bmask = modes[i]->Bmask;

	/* Workaround a bug in libvgl */
	if (VGLCurMode->ModeInfo.PixelBytes == 0)
		(VGLCurMode->ModeInfo.PixelBytes = 1);

	current->w = VGLCurMode->ModeInfo.Xsize;
	current->h = VGLCurMode->ModeInfo.Ysize;
	current->pixels = VGLCurMode->ModeInfo.Bitmap;
	current->pitch = VGLCurMode->ModeInfo.Xsize *
			 VGLCurMode->ModeInfo.PixelBytes;
	current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);

	/* Check if we are in a pseudo-color mode */
	if (VGLCurMode->ModeInfo.Type == VIDBUF8)
		current->flags |= SDL_HWPALETTE;

	/* Check if we can do doublebuffering */
	if (flags & SDL_DOUBLEBUF) {
		if (VGLCurMode->ModeInfo.Xsize * 2 <=
		    VGLCurMode->ModeInfo.VYsize) {
			current->flags |= SDL_DOUBLEBUF;
			flip_page = 0;
			flip_address[0] = (byte *)current->pixels;
			flip_address[1] = (byte *)current->pixels +
					  current->h * current->pitch;
			VGL_FlipHWSurface(this, current);
		}
	}

	if (! SDL_ReallocFormat(current, modes[i]->Depth, VGLCurMode->Rmask,
				VGLCurMode->Gmask, VGLCurMode->Bmask, 0)) {
		return NULL;
	}

	/* Update hardware acceleration info */
	VGL_UpdateVideoInfo(this);

	/* Set the blit function */
	this->UpdateRects = VGL_DirectUpdate;

	/* We're done */
	return current;
}