SDL bug?

Does that patch make sense to somebody else but me ?

I think there is a problem in SDL 1.1 that prevents the correct allocation of
shadow surfaces. That showed up while I was developing the AAlib driver and
SMPEG got wrong offsets, because those offsets were not initialized for the
automatically allocated shadow surface, but for the actual surface (which is
8bpp for instance, while SMPEG requests a 16bpp surface).

This patch fixes it… And the AAlib driver is getting in good shape :)–
Stephane Peter
Programmer
Loki Entertainment Software

“Microsoft has done to computers what McDonald’s has done to gastronomy”
-------------- next part --------------
Index: SDL_video.c

RCS file: /cvs/SDL/src/video/SDL_video.c,v
retrieving revision 1.13.2.28
diff -u -r1.13.2.28 SDL_video.c
— SDL_video.c 2000/02/26 20:23:23 1.13.2.28
+++ SDL_video.c 2000/02/29 23:24:54
@@ -534,27 +537,7 @@
SDL_VideoSurface = NULL; /* In case it’s freed by driver */
mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
SDL_VideoSurface = mode;

  • if ( (mode != NULL) && (!is_opengl) ) {
  •   if ( (mode->w < width) || (mode->h < height) ) {
    
  •   	SDL_SetError("Video mode smaller than requested");
    
  •   	return(NULL);
    
  •   }
    
  •   mode->offset = 0;
    
  •   SDL_ClearSurface(mode);
    
  •   offset_x = (mode->w-width)/2;
    
  •   offset_y = (mode->h-height)/2;
    
  •   mode->offset = offset_y*mode->pitch +
    
  •   		offset_x*mode->format->BytesPerPixel;
    

-#ifdef DEBUG_VIDEO

  • fprintf(stderr,
  • “Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n”,
  •   width, height, bpp,
    
  •   mode->w, mode->h, mode->format->BitsPerPixel, mode->offset);
    

-#endif

  •   mode->w = width;
    
  •   mode->h = height;
    
  •   SDL_SetClipping(mode, 0, 0, 0, 0);
    
  • }
  • SDL_ResetCursor();
    SDL_UnlockCursor();

@@ -595,6 +578,28 @@
SDL_PublicSurface = SDL_ShadowSurface;
} else {
SDL_PublicSurface = SDL_VideoSurface;

  • }
  • if ( (SDL_PublicSurface != NULL) && (!is_opengl) ) {
  •   if ( (SDL_PublicSurface->w < width) || (SDL_PublicSurface->h < height) ) {
    
  •   	SDL_SetError("Video mode smaller than requested");
    
  •   	return(NULL);
    
  •   }
    
  •   SDL_PublicSurface->offset = 0;
    
  •   SDL_ClearSurface(SDL_PublicSurface);
    
  •   offset_x = (SDL_PublicSurface->w-width)/2;
    
  •   offset_y = (SDL_PublicSurface->h-height)/2;
    
  •   SDL_PublicSurface->offset = offset_y*SDL_PublicSurface->pitch +
    
  •   		offset_x*SDL_PublicSurface->format->BytesPerPixel;
    

+#ifdef DEBUG_VIDEO

  • fprintf(stderr,
  • “Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n”,
  •   width, height, bpp,
    
  •   SDL_PublicSurface->w, SDL_PublicSurface->h, SDL_PublicSurface->format->BitsPe
    

rPixel, SDL_PublicSurface->offset);
+#endif

  •   SDL_PublicSurface->w = width;
    
  •   SDL_PublicSurface->h = height;
    
  •   SDL_SetClipping(SDL_PublicSurface, 0, 0, 0, 0);
    

    }

    /* Reset the mouse cursor and grab for new video mode */

Does that patch make sense to somebody else but me ?

I think there is a problem in SDL 1.1 that prevents the correct allocation of
shadow surfaces. That showed up while I was developing the AAlib driver and
SMPEG got wrong offsets, because those offsets were not initialized for the
automatically allocated shadow surface, but for the actual surface (which is
8bpp for instance, while SMPEG requests a 16bpp surface).

This patch fixes it… And the AAlib driver is getting in good shape :slight_smile:

Forget this patch, it turned out that it was actually a bug in the AAlib driver
itself. D’oh !On 29-Feb-00 Stephane Peter wrote:


Stephane Peter
Programmer
Loki Entertainment Software