24-10-2006

Xcode project including script for building directly a ready to use dmg file

-------------------------------------------------------------------------------
- Makefile.osx added (use Makefile -f Makefile.osx)

- osx directory added contains : 
	+ SDLMain.h and SDLMain.m
	+ *.icns
	+ mkdmg (little script for creating dmg file)

- Warning correction:
	share/gui.c: In function `gui_init':
	share/gui.c:235: warning: passing arg 2 of `glGetIntegerv' from incompatible pointer type	
	share/gui.c (line 231) int m; -> GLint m;

- Fix in ball/main.c (line 100) and putt/main.c (line 106)
	mouse motion events problem 
	suppression of APPLE case : "#ifdef __APPLE__"
	the same code as x86
	
- not real colors in screenshots because BMP file is little endian format
	 change image_snap in share/image.c (take screenshot in 32bits and special stuff for big endian)
	 
	 #include <SDL_endian.h>
	 ...
	 void image_snap(char *filename)
	{
		...
		SDL_Surface *buf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
                                            RMASK,GMASK,255,BMASK );
											
		SDL_Surface *img = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
		#if SDL_BYTEORDER == SDL_LIL_ENDIAN
			RMASK,GMASK,255,BMASK	
		#else
			RMASK,GMASK,BMASK,255 
		#endif
		);									

		glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf->pixels);
		
		for (i = 0; i < h; i++)
			memcpy((GLubyte *) img->pixels + 4 * w * i,
               (GLubyte *) buf->pixels + 4 * w * (h - i), 4 * w);
		...
}

- Multilang support with gettext
	gettext is a linux tool that uses the LANG environement variable
	and LANG as no value is osX 
	so in terminal.app 
		$ export LANG=fr 
		$ open neverball.app
		will launch neverball in french
		
	But when you launch neverball in finder (by double clic) it will use english because LANG var has no value
	To fix LANG in osX add it in .MacOSX/environment.plist by adding 
	
	<?xml version="1.0" encoding="UTF-8"?>
	<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
	<plist version="1.0">
	<dict>
        <key>LANG</key><string>Fr</string>	
	</dict>
	</plist>   
	
	and relaunch user session
	launching neverball in finder will use French
	
	but when launch terminal it will complain about an error (probably because of Fink) when setting locale.
	To avoid this error, add in ~/.bashrc 
	
	unset LANG 
	...
	test -r /sw/bin/init.sh && . /sw/bin/init.sh # fink line
	...
	export LANG=Fr
	
	I notice that Battle for Wesnoth has the same problem. The first launch (in finder) is in english and you can select french language in game preferences that are written in ~/Library/Preferences/Wesnoth/preferences. The next launch will read : locale="fr_FR" in preferences file and launch the game in french.
	