Date: Sun, 23 Oct 2005 16:39:03 +0200 From: "A. Schmid" To: sdl@libsdl.org Subject: [SDL] no software surfaces with svgalib driver? --- src/video/svga.orig/SDL_svgavideo.c 2004-01-04 17:49:26.000000000 +0100 +++ src/video/svga/SDL_svgavideo.c 2005-09-29 22:39:30.000000000 +0200 @@ -46,6 +46,7 @@ #include #include #include +#include #include "SDL.h" #include "SDL_error.h" @@ -59,6 +60,9 @@ #include "SDL_svgamouse_c.h" +#include +static GraphicsContext *realgc, *virtgc=NULL; + /* Initialization/Query functions */ static int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat); static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); @@ -176,7 +180,7 @@ int i, j; i = modeinfo->bytesperpixel-1; - if ( actually_add ) { + if (( actually_add ) && (i >= 0)) { SDL_Rect saved_rect[2]; int saved_mode[2]; int b; @@ -223,7 +228,7 @@ vga_modeinfo *modeinfo; this->info.wm_available = 0; - this->info.hw_available = 1; + this->info.hw_available = ((virtgc==NULL) ? 1 : 0); modeinfo = vga_getmodeinfo(vga_getcurrentmode()); this->info.video_mem = modeinfo->memory; /* FIXME: Add hardware accelerated blit information */ @@ -246,7 +251,7 @@ } /* Initialize the library */ - vga_disabledriverreport(); +// vga_disabledriverreport(); // why disable it? if ( vga_init() < 0 ) { SDL_SetError("Unable to initialize SVGAlib"); return(-1); @@ -272,7 +277,7 @@ total_modes = 0; for ( mode=vga_lastmodenumber(); mode; --mode ) { if ( vga_hasmode(mode) ) { - if ( SVGA_AddMode(this, mode, 0, 0) ) { + if ( SVGA_AddMode(this, mode, 0, 1) ) { ++total_modes; } } @@ -306,7 +311,7 @@ } for ( mode=vga_lastmodenumber(); mode; --mode ) { if ( vga_hasmode(mode) ) { - SVGA_AddMode(this, mode, 1, 0); + SVGA_AddMode(this, mode, 1, 1); } } SVGA_AddMode(this, G320x200x256, 1, 1); @@ -365,9 +370,25 @@ vgamode=SDL_vgamode[bpp][mode]; if ((vga_setlinearaddressing()<0) && (vgamode!=G320x200x256)) { - SDL_SetError("Unable to set linear addressing"); - return(NULL); + + gl_setcontextvga(SDL_vgamode[bpp][mode]); + realgc = gl_allocatecontext(); + gl_getcontext(realgc); + + gl_setcontextvgavirtual(SDL_vgamode[bpp][mode]); + virtgc = gl_allocatecontext(); + gl_getcontext(virtgc); + + current->flags = (SDL_FULLSCREEN|SDL_SWSURFACE); + flags &= ~SDL_DOUBLEBUF; + current->flags &= ~SDL_DOUBLEBUF; + current->pixels = virtgc->vbuf; +// return(NULL); + } else { + current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); + current->pixels = vga_getgraphmem(); } + modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]); /* Update hardware acceleration info */ @@ -383,7 +404,7 @@ } /* Set up the new mode framebuffer */ - current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); +// current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE); if ( bpp == 8 ) { /* FIXME: What about DirectColor? */ current->flags |= SDL_HWPALETTE; @@ -391,7 +412,7 @@ current->w = width; current->h = height; current->pitch = modeinfo->linewidth; - current->pixels = vga_getgraphmem(); +// current->pixels = vga_getgraphmem(); /* set double-buffering */ if ( flags & SDL_DOUBLEBUF ) @@ -454,6 +475,7 @@ static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface) { + if (virtgc!=NULL) return 0; // for SWSURFACE. don't know who calls this... vga_setdisplaystart(flip_offset[flip_page]); flip_page=!flip_page; surface->pixels=flip_address[flip_page]; @@ -463,6 +485,18 @@ static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) { + if (virtgc==NULL) return; // HWSURFACE then, already there :) + + int i; + SDL_Rect *rect; + +// vga_waitretrace(); + for ( i=0; i < numrects; ++i ) { + rect = &rects[i]; + // copy from virtgc to realgc + gl_copyboxtocontext(rect->x, rect->y, rect->w, rect->h, realgc, rect->x, rect->y); + } + return; } @@ -492,6 +526,8 @@ { int i, j; +// if (virtgc!=NULL) { gl_freecontext(virtgc); virtgc=NULL; }; // hmmm... perhaps better not? + /* Reset the console video mode */ if ( this->screen && (this->screen->w && this->screen->h) ) { vga_setmode(TEXT);