OS X 8bpp desktop bug (?)

I believe I have discovered a bug in SDL for OS X. If I start an SDL
application with my desktop colour depth set to “256 colours” then the
resulting window displays incorrectly, appearing to squash the
graphics to half their correct width and disturbing the colours.

I have recently reported a similar bug in the Allegro for OS X port
and helped test potential fixes. The problem in Allegro turned out to
be that the global desktop colour depth (i.e. 8bpp) was also used to
determine the colour depth of the QuickDraw port used by the Allegro
window but when QuickDraw OS X applications are started in 256 colour
mode they actually obtain a 16bpp buffer - which can be determined by
querying the QuickDraw port for colour depth rather than using the
global, desktop value. Hopefully that will give the developers a
decent clue as to what the problem might be. It is probably a further
clue suggesting the same sort of problem that when in 256 colour mode,
the desktop appears to be dithered.

I’ve uploaded a screenshot of the display produced by SDL for a
minimal test program to
http://img446.imageshack.us/img446/1270/sdlerror2tr.png . The full
source code for the program that produced that image is appended to
this post - it is nothing more than a quick modification of the
default source file in the XCode template to draw a white rectangle
onto the screen.

SDL seems to work correctly if started in a non-8bpp desktop colour
depth and then switched to that colour depth. Testing for the Allegro
bug seems to suggest that doing that may yield a genuinely 8bit
QuickDraw port, but I’m not certain about that.

My system is a 667Mhz G4 Titanium Powerbook, gigabit ethernet edition

  • which means an ATI Mobility Radeon (ATY,RageM6) chipset with 16mb
    VRAM. OS is v10.4.2 (i.e. the very latest). SDL 1.2.9 built with the
    latest version of the Developer Tools.

I apologise if this is not the correct place to report bugs.

Source code used was:

/* Simple program: Create a blank window, wait for keypress, quit.

Please see the SDL documentation for details on using the SDL API:
/Developer/Documentation/SDL/docs.html
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include “SDL.h”

int main(int argc, char argv[])
{
Uint32 initflags = SDL_INIT_VIDEO; /
See documentation for details */
SDL_Surface *screen;
Uint8 video_bpp = 0;
Uint32 videoflags = SDL_SWSURFACE;
int done;
SDL_Event event;

/* Initialize the SDL library */
if ( SDL_Init(initflags) < 0 ) {
	fprintf(stderr, "Couldn't initialize SDL: %s\n",
		SDL_GetError());
	exit(1);
}

/* Set 640x480 video mode */
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
    if (screen == NULL) {
	fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
                    video_bpp, SDL_GetError());
	SDL_Quit();
	exit(2);
}

SDL_Rect dest;
dest.x = 40;
dest.y = 40;
dest.w = 560;
dest.h = 400;
SDL_FillRect(screen, &dest, ~0);
SDL_UpdateRect(screen, 0, 0, 0, 0);

done = 0;
while ( !done ) {

	/* Check for events */
	while ( SDL_PollEvent(&event) ) {
		switch (event.type) {

			case SDL_MOUSEMOTION:
				break;
			case SDL_MOUSEBUTTONDOWN:
				break;
			case SDL_KEYDOWN:
				/* Any keypress quits the app... */
			case SDL_QUIT:
				done = 1;
				break;
			default:
				break;
		}
	}
}

/* Clean up the SDL library */
SDL_Quit();
return(0);

}

-Thomas

Thomas Harte wrote:

I believe I have discovered a bug in SDL for OS X. If I start an SDL
application with my desktop colour depth set to “256 colours” then the
resulting window displays incorrectly, appearing to squash the
graphics to half their correct width and disturbing the colours.

This is fixed in CVS now. Thanks for the bug report!

–ryan.