SDL @VERSION@ for Mac OS X 10.4 Tiger

SDL (Simple DirectMedia Layer) @VERSION@, the newest release of SDL 2,
built for Mac OS X 10.4 on every Mac that runs it: PowerPC (G3, G4 and G5)
and Intel. It is the library many games and emulators are written with:
windows, OpenGL, 2D drawing, sound, the keyboard and the mouse. It is one
universal framework, and needs nothing that Tiger does not have:

  /Library/Frameworks/SDL2.framework
      the library (G3, G4 and Intel) and SDL's headers
  /usr/local/bin/sdl2-config
      the flags a program builds with
  /usr/local/include/SDL2
  /usr/local/lib/libSDL2.dylib
      links to the headers and the library, by the
      names a Unix program looks for (-lSDL2)
  /usr/local/lib/pkgconfig/sdl2.pc
  /usr/local/lib/cmake/SDL2
  /usr/local/share/aclocal/sdl2.m4
      for pkg-config, CMake and autoconf
  /usr/local/share/doc/SDL2-tiger
      this Read Me, SDL's licence and changes,
      update-shell-profile.sh

The framework holds three builds of SDL, and Mac OS X loads the one for
your Mac: on a G4 or G5 the one that uses AltiVec, on a G3 the one that
does not, and on an Intel Mac the Intel one.

The installer adds /usr/local/bin to the PATH in your shell profile, as the
other packages of tiger.v2core.com do, and keeps the old profile beside it
as .sdl2save.

Building a program with it

With Xcode 2.5's GCC, in Terminal:

  gcc -o game game.c `sdl2-config --cflags --libs`

For both PowerPC and Intel, with the 10.4u SDK:

  gcc -arch ppc -arch i386 -mmacosx-version-min=10.4 \
    -isysroot /Developer/SDKs/MacOSX10.4u.sdk \
    -o game game.c `sdl2-config --cflags --libs`

Or as a framework (in Xcode, add /Library/Frameworks/SDL2.framework to the
project): #include "SDL.h" with -I/Library/Frameworks/SDL2.framework/Headers,
and -framework SDL2. A program needs no SDL_main on the Mac. An application
opened in the Finder gets one argument it did not ask for, -psn_ and a
number, as on every Mac before 10.9: a program that reads its arguments
should pass over it.

The library's install name is
@executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2. An
application may carry SDL2.framework in its Contents/Frameworks folder, and
then runs on a Mac without this package. When it does not, or for a
program outside an application bundle, Tiger's dyld looks for the framework
in ~/Library/Frameworks and then /Library/Frameworks, where this package
puts it. A copy in ~/Library/Frameworks needs no administrator.

What works on Tiger

- Windows: made, moved, sized, shown and hidden; bordered or not,
  resizable, always on top, maximized and minimized; their title and icon;
  a menu bar with the application's name, also for a program started from
  Terminal, which becomes an application with a Dock icon.
- Full screen: at another display mode (the display is captured and
  switched, then switched back), and at the desktop's size.
- OpenGL: whatever the Mac's own OpenGL gives, up to 2.1, with vsync.
  SDL's renderers: OpenGL and software.
- Sound: playback through CoreAudio, at any rate, in any of SDL's formats.
- The keyboard, with the keyboard layout in use (Unicode and older ones),
  and text input; the mouse, with relative mode; the clipboard; files
  dropped on a window; message boxes; cursors.
- Threads, timers, paths (SDL_GetPrefPath is ~/Library/Application
  Support), power, locale, opening a URL.

SDL's own test suite (testautomation) passes on Mac OS X 10.4.11 on a G3,
a G4 and a later G4 (7455): 300 tests, and 8 that SDL itself leaves out.

The G4 build uses AltiVec where SDL has code for it, to convert pixels
between 32-bit formats and from 24 to 16 bits, and where the compiler
finds a loop it can. It draws the same pixels as the G3 build: two faults
of SDL's AltiVec code were mended for that. On an Intel
Mac on 10.4.11, two of its render tests read the screen back after a frame
was shown; Tiger's OpenGL there does not keep it, and they fail. With the
software renderer they pass.

On a real Power Mac G4, 14 games that carry this framework were tried with
it. This package, @PKGVERSION@, has three fixes that they found:

- SDL_GetTicks fell back to a small number 443 seconds after a program
  started on a G4 (738 seconds on an emulated one). For as long again,
  SDL's timers stopped, and so did its hold on the screen saver.
- Full screen at a display mode other than the desktop's, the pointer's
  position, SDL_WarpMouseInWindow and the mouse's limits were off by the
  difference between the two screen heights.
- A change of display mode while full screen did not happen: the display
  stayed at the first mode, with the picture scaled.

What Tiger does not have

- Joysticks and game controllers. SDL's drivers for them are made of the
  HID Manager of Mac OS X 10.5. The joystick subsystem starts, and finds
  none; a virtual joystick works.
- Sound recording, which SDL does with Audio Queues (10.5). Playback works.
- Metal, Vulkan and OpenGL ES; full-screen Spaces and Retina displays;
  trackpad touches; a display's colour profile.

The examples

The disk image has four of SDL's test programs as applications, in
Examples: testsprite2, testgl2, testdraw2 and testoverlay2. They use the
installed framework, so install the package first. Escape quits them.

Uninstalling

In Terminal:

  sudo rm -rf /Library/Frameworks/SDL2.framework
  cd /usr/local
  sudo rm bin/sdl2-config include/SDL2 lib/libSDL2*.dylib
  sudo rm lib/pkgconfig/sdl2.pc share/aclocal/sdl2.m4
  sudo rm -rf lib/cmake/SDL2 share/doc/SDL2-tiger
  sudo rm -rf "/Library/Receipts/SDL2 @PKGVERSION@.pkg"

If nothing else you use is in /usr/local/bin, take the "Setting PATH for
SDL 2" lines out of your shell profile.

How it was made

SDL's code for the Mac needs Mac OS X 10.7 and Apple's compiler: it is
written with automatic reference counting, blocks and Grand Central
Dispatch. This build is SDL @VERSION@ with its Mac code changed for Tiger:
references counted by hand again, as SDL did before 2.24; the calls of 10.5
and later made of Tiger's (display modes, keyboard layouts, text input,
window styles, screen saver); and sound through an output unit, since Audio
Queues came with 10.5. It was cross-compiled on Linux with GCC 13.4 for
powerpc-apple-darwin8, once for any G3 and once with AltiVec for a G4, and
for i686-apple-darwin8, against the Mac OS X 10.4u SDK. The package and
this disk image were made on Mac OS X 10.4.11 with its own mkbom, pax and
hdiutil.

Everything it was built from (SDL's release, the patches, the compatibility
files and the build scripts) is in SDL2-@PKGVERSION@-tiger-source.tar.gz,
beside this disk image on https://tiger.v2core.com.

Built @DATE@.
