Synchronized with trunk

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1201 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-08-14 08:02:57 +00:00
commit 7a8cc0c76a
21 changed files with 2589 additions and 1850 deletions

View File

@ -401,6 +401,12 @@
A01A3AEB0E75181300D0BA9B /* stb_vorbis.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = stb_vorbis.c; path = ../../src/SFML/Audio/stb_vorbis/stb_vorbis.c; sourceTree = SOURCE_ROOT; }; A01A3AEB0E75181300D0BA9B /* stb_vorbis.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = stb_vorbis.c; path = ../../src/SFML/Audio/stb_vorbis/stb_vorbis.c; sourceTree = SOURCE_ROOT; };
A01A3AEC0E75181300D0BA9B /* stb_vorbis.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = stb_vorbis.h; path = ../../src/SFML/Audio/stb_vorbis/stb_vorbis.h; sourceTree = SOURCE_ROOT; }; A01A3AEC0E75181300D0BA9B /* stb_vorbis.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = stb_vorbis.h; path = ../../src/SFML/Audio/stb_vorbis/stb_vorbis.h; sourceTree = SOURCE_ROOT; };
A01C69C80E3E63CE00ED3F04 /* Unicode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Unicode.cpp; path = ../../src/SFML/System/Unicode.cpp; sourceTree = SOURCE_ROOT; }; A01C69C80E3E63CE00ED3F04 /* Unicode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Unicode.cpp; path = ../../src/SFML/System/Unicode.cpp; sourceTree = SOURCE_ROOT; };
A02C68B1102BA16300A77DF4 /* autogen.sh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.sh; path = autogen.sh; sourceTree = "<group>"; };
A02C68B2102BA16300A77DF4 /* license.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = license.txt; sourceTree = "<group>"; };
A02C68B3102BA16300A77DF4 /* Lisez-moi.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Lisez-moi.rtf"; sourceTree = "<group>"; };
A02C68B4102BA16300A77DF4 /* Notes de version.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Notes de version.rtf"; sourceTree = "<group>"; };
A02C68B5102BA16300A77DF4 /* Read Me.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Read Me.rtf"; sourceTree = "<group>"; };
A02C68B6102BA16300A77DF4 /* Release Notes.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "Release Notes.rtf"; sourceTree = "<group>"; };
A04C59A50EDDBA9C00935061 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AppController.h; path = ../../src/SFML/Window/Cocoa/AppController.h; sourceTree = SOURCE_ROOT; }; A04C59A50EDDBA9C00935061 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AppController.h; path = ../../src/SFML/Window/Cocoa/AppController.h; sourceTree = SOURCE_ROOT; };
A04C59A60EDDBA9C00935061 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = AppController.mm; path = ../../src/SFML/Window/Cocoa/AppController.mm; sourceTree = SOURCE_ROOT; }; A04C59A60EDDBA9C00935061 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = AppController.mm; path = ../../src/SFML/Window/Cocoa/AppController.mm; sourceTree = SOURCE_ROOT; };
A04C59A70EDDBA9C00935061 /* Joystick.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Joystick.cpp; path = ../../src/SFML/Window/Cocoa/Joystick.cpp; sourceTree = SOURCE_ROOT; }; A04C59A70EDDBA9C00935061 /* Joystick.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Joystick.cpp; path = ../../src/SFML/Window/Cocoa/Joystick.cpp; sourceTree = SOURCE_ROOT; };
@ -813,6 +819,19 @@
path = ../../src/SFML/Audio/stb_vorbis; path = ../../src/SFML/Audio/stb_vorbis;
sourceTree = SOURCE_ROOT; sourceTree = SOURCE_ROOT;
}; };
A02C68B0102BA16300A77DF4 /* dist */ = {
isa = PBXGroup;
children = (
A02C68B1102BA16300A77DF4 /* autogen.sh */,
A02C68B2102BA16300A77DF4 /* license.txt */,
A02C68B3102BA16300A77DF4 /* Lisez-moi.rtf */,
A02C68B4102BA16300A77DF4 /* Notes de version.rtf */,
A02C68B5102BA16300A77DF4 /* Read Me.rtf */,
A02C68B6102BA16300A77DF4 /* Release Notes.rtf */,
);
path = dist;
sourceTree = "<group>";
};
A04C59A40EDDBA9C00935061 /* Cocoa */ = { A04C59A40EDDBA9C00935061 /* Cocoa */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -834,6 +853,7 @@
A093E3660D8BF860002236B4 = { A093E3660D8BF860002236B4 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A02C68B0102BA16300A77DF4 /* dist */,
A093E3AD0D8BF8AD002236B4 /* SFML */, A093E3AD0D8BF8AD002236B4 /* SFML */,
A093E3B90D8BF8C2002236B4 /* sfml-audio */, A093E3B90D8BF8C2002236B4 /* sfml-audio */,
A093E3BC0D8BF8C7002236B4 /* sfml-graphics */, A093E3BC0D8BF8C7002236B4 /* sfml-graphics */,

10
build/xcode/dist/Lisez-moi.rtf vendored Normal file
View File

@ -0,0 +1,10 @@
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\fs24 \cf0 Pour installer et utiliser SFML avec votre compilateur pr\'e9f\'e9r\'e9, rendez-vous sur la page des tutoriels : \
\
http://www.sfml-dev.org/tutorials/index-fr.php \
}

68
build/xcode/dist/Notes de version.rtf vendored Normal file
View File

@ -0,0 +1,68 @@
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11320\viewh10660\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri1080\ql\qnatural\pardirnatural
\f0\fs24 \cf0 \
\b\fs28 Notes de version pour SFML 1.5
\b0\fs24 \
\
Voici un r\'e9sum\'e9 de ce qui reste \'e0 effectuer, des probl\'e8mes actuellement connus ainsi que quelques informations techniques afin de tirer le meilleur partir du portage pour Mac OS X.\
\
\
\b \'c0 faire :
\b0 \
- la gestion des joysticks\
\
\
\b Probl\'e8mes connus :
\b0 \
- certaines touches ne sont pas ind\'e9pendantes de la configuration du clavier (voici les touches que vous pouvez utiliser sans risque : '*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz\{|\}~ ). Seuls les \'e9v\'e9nements sf::Event::KeyPressed et sf::Event::KeyReleased sont concern\'e9s par ce probl\'e8me, pas les \'e9v\'e9nements sf::Event::TextEntered.\
- les touches Control, Option (Alt), Shift et Command ne produisent pas d'\'e9v\'e9nement de r\'e9p\'e9tition lorsqu'elles sont maintenues enfonc\'e9es\
- \'e9tant donn\'e9 qu'un clavier Mac est diff\'e9rent de celui d'un PC, certains codes sf::Key ne sont pas utilis\'e9s, et d'autres sont manquants\
- l'anticr\'e9n\'e9lage OpenGL est d\'e9sactiv\'e9\
\
\
\b\fs26 Notes techniques :
\b0\fs24 \
\
\b Les touches Control, Option [...] :\
\b0 Mac OS X avertit l'application uniquement lorsque l'\'e9tat d'une de ces touches particuli\'e8res est modifi\'e9, pas lorsqu'elles sont maintenues enfonc\'e9es. De plus, ces touches sont consid\'e9r\'e9es comme des "modifiers" et ne doivent donc pas \'eatre utilis\'e9es seules comme raccourci pour d\'e9clencher une action (ex: Control + E convient mais pas Control tout seul).\
\
\
\b Ind\'e9pendance vis \'e0 vis des configurations de claviers :
\b0 \
Lorsque SFML obtient un \'e9v\'e9nement clavier, elle obtient un code correspondant \'e0 cette touche. Cependant ce code repr\'e9sente la touche elle-m\'eame, et non pas ce qui est imprim\'e9 sur votre clavier, donc des claviers anglais et fran\'e7ais produiront \'97 en consid\'e9rant que vous pressez la touche plac\'e9e exactement au m\'eame endroit \'96 le m\'eame code, quelque soit la configuration de clavier que vous utilisez. Afin de contourner en partie le probl\'e8me, certaines touches sont devin\'e9es \'e0 partir du champ "text" de l'\'e9v\'e9nement et non pas \'e0 partir du code de la touche. Ce n'est pas une solution pleinement satisfaisante mais je n'ai trouv\'e9 aucune meilleure solution jusqu'\'e0 ce jour (davantage de recherches me sont n\'e9cessaires). Si vous voulez \'eatre s\'fbr que l'\'e9v\'e9nement re\'e7u est bien le caract\'e8re que vous voulez, vous devriez uniquement utiliser les \'e9v\'e9nements sf::TextEntered (non concern\'e9s par le probl\'e8me).\
Notez qu'\'e9tant donn\'e9 que le code repr\'e9sente les touches du clavier anglais, les utilisateurs anglophones n'ont pas \'e0 se pr\'e9occuper de ce probl\'e8me.\
\
\b Le chargement des ressources :\
\b0 1. Lorsqu'une application SFML est lanc\'e9e, elle d\'e9signe le dossier Resources (<votre application.app>/Contents/Resources) comme \'e9tant le r\'e9pertoire actuel de travail. Si votre logiciel n'est pas une application paquet, SFML d\'e9signera le dossier contenant votre programme comme \'e9tant le r\'e9pertoire de travail. Par cons\'e9quent, si vous souhaitez charger des ressources, vous pouvez utiliser sans risque des adresses relatives aux dossiers indiqu\'e9s ci-dessus.\
\
2. La d\'e9signation du r\'e9pertoire de travail est effectu\'e9e au moment du chargement du programme avant d'entrer dans la fonction main(). Cependant, si vous d\'e9finissez des variables globales (comme par exemple des objets de type sf::Image) et que vous essayez de charger l'image au moment de la construction de l'objet (donc par l'interm\'e9diaire du constructeur), rien ne vous garantie que le r\'e9pertoire de travail est d\'e9j\'e0 valide. Vous devez donc charger toutes vos ressources apr\'e8s \'eatre entr\'e9 dans la fonction main().\
\
\b \
Les attributs du contexte OpenGL :\
\b0 SFML utilises le partage de contexte OpenGL afin d'\'e9viter de charger plusieurs fois la m\'eame ressource, m\'eame si vous avez plusieurs fen\'eatres SFML. Cela permet d'\'e9conomiser \'e0 la fois de la m\'e9moire et tu temps de traitement, mais cela implique aussi une restriction importante (qui semble \'eatre propre \'e0 Mac OS X) : les contextes partag\'e9s doivent avoir des attributs compatibles. Un point sur lequel je vais m'attarger est le niveau d'anticr\'e9n\'e9lage : vous ne pouvez pas utilisez diff\'e9rents contextes partag\'e9s entre eux avec un niveau d'anticr\'e9n\'e9lage diff\'e9rent. Il faut noter que SFML d\'e9finit un contexte globale partag\'e9, donc si je choisis de ne pas utiliser d'anticr\'e9n\'e9lage pour ce contexte, l'anticr\'e9n\'e9lage ne pourra \'eatre utilis\'e9 pour aucun autre contexte OpenGL (et fen\'eatre SFML). D'un autre c\'f4t\'e9, je pourrais d\'e9finir 2 (ou n'importe quelle autre valeur) niveaux d'anticr\'e9n\'e9lage, mais tous les autres contextes seraient oblig\'e9s d'utiliser aussi le m\'eame niveau de lissage. \'c9tant donn\'e9 que l'anticr\'e9n\'e9lage n'est pas une op\'e9ration l\'e9g\'e8re pour l'unit\'e9 de calcul graphique, il a \'e9t\'e9 d\'e9sactiv\'e9. \'c9carter cette fonctionnalit\'e9 me semble \'eatre une meilleure solution que forcer l'utiliser \'e0 l'utiliser.\
En ce qui concerne les autres attributs, il semblerait qu'ils puissent \'eatre diff\'e9rents. Je ne les ai pas tous test\'e9s mais j'ai pu constater que certains \'e9taient automatiquement modifi\'e9s \'e0 cause de valeurs choisies trop hautes.\
\
\
\b OpenAL :\
\b0 Vous pouvez remarquer la pr\'e9sence du framework OpenAL dans l'image de disque, mais vous savez aussi peut-\'eatre que Mac OS X inclut d\'e9j\'e0 OpenAL (voir /Syst\'e8me/Biblioth\'e8que/Frameworks). Ce framework a \'e9t\'e9 ajout\'e9 au paquet afin de corriger des probl\'e8mes caus\'e9s par celui pr\'e9sent par d\'e9faut. En cons\'e9quence, il est inutile de fournir ce framework si vous n'avez pas l'intention de distribuer votre application pour Mac OS X 10.4.\
\
Pour toutes les questions, rendez-vous sur le forum SFML : http://www.sfml-dev.org/forum-fr/\
\
}

10
build/xcode/dist/Read Me.rtf vendored Normal file
View File

@ -0,0 +1,10 @@
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\fs24 \cf0 To install and use SFML with your favorite compiler, go to the tutorials web page : \
\
http://www.sfml-dev.org/tutorials/ \
}

73
build/xcode/dist/Release Notes.rtf vendored Normal file
View File

@ -0,0 +1,73 @@
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11320\viewh10660\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri1080\ql\qnatural\pardirnatural
\f0\fs24 \cf0 \
\b\fs28 SFML 1.5 Release Notes
\b0\fs24 \
\
Here is a summary of what needs to be done, the currently known problems and some technical informations in order to make the best of the Mac OS X port.\
\
\
\b What is still to be done:
\b0 \
- joystick handling\
\
\
\b Known issues:
\b0 \
- not all of the keys are keyboard layout independent (the "safe" characters are: '*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz\{|\}~ ). Only sf::Event::KeyPressed and sf::Event::KeyReleased events are affected. This issue does not concern sf::Event::TextEntered events.\
- the Control, Option (Alt), Shift and Command keys do not produce repeated events when held\
- since a Mac keyboard is different from a PC's one, some sf::Key codes are not used, and some other are missing\
- OpenGL antialiasing is disabled\
\
\
\b\fs26 Technical notes:
\b0\fs24 \
\
\b Control, Option [...] keys:\
\b0 Mac OS X only notifies the application when the state of one of these keys changes, not when they are kept down. Besides, these keys are considered as key modifiers and should therefore not be used as a shorcut for a user action without another real key (ie. Control + E is fine, but not Control alone).\
\
\
\b Layout independant keys:
\b0 \
When SFML catches the key events, it gets a code corresponding to the key. But this code represents the key itself, not what's printed on, so a French and an English keyboard will produce \'97 considering you press a key located exactly at the same place \'97 the same key code, whichever your keyboard layout is. In order to get part of the thing work, some keys are guessed from the "text" field of the event and not from the key code. This is not quite a satisfying solution but nothing better has been found till now (need to do more research on this). If you want to be positive the received event is the right character, you should only use sf::TextEntered events.\
Note that since the key code originally represents the English keyboard layout, English user may not have to worry about this issue.
\b \
\b0 \
\
\b Resources' loading:\
\b0 1. When launched, any SFML application sets the current working directory to its Resources folder (<yourapp.app>/Contents/Resources). If your software is not a bundled application, the working directory is set to the directory containing your program. Therefore if you wish to load resources, you can safely use relative paths according to the previously described specifications.\
\
2. Setting the current working directory is done at executable loading time, before entering the main() function. However, if you define global variables like sf::Image objects and try to load the image at the object construction time, you can't know whether the working directory has already been set. Therefore you must load every resources after entering the main() function.\
\
\
\b OpenGL context attributes (settings):
\b0 \
SFML uses OpenGL context sharing in order to avoid loading the same resources more than once even if you have several SFML windows. This saves both memory and processing time but involves one major restriction (that seems to be particular to Mac OS X): shared contexts must have compatible attributes. One thing I'm going to focus on is the antialiasing level: you can't share contexts with different antialiasing levels. The point is SFML defines a global shared context, so if I choose to set no antialiasing for this context, antialiasing won't be usable for any other OpenGL context (and SFML window). On the other hand, I could define 2 (or whatever you want) antialiasing levels, but therefore every other contexts should use the same amount of antialiasing levels. As antialiasing is not a slight process for the graphic unit, it has been disabled. Dropping this feature seems to be a better solution than force its use.\
\
As far as the other attributes are concerned, it looks like they can be different. I did not test all of them, but I found out that some of them were altered because of too high values.\
\
\
\b OpenAL:\
\b0 You may notice that the package includes an OpenAL framework, but you may also know that Mac OS X already includes OpenAL (see /System/Library/Frameworks). This framework has been added in order to fix troubles caused by the OpenAL framework provided on Mac OS X 10.4. Since then, it is absolutely unnecessary to put it in your application bundle if you don't plan to distribute your software for Mac OS X 10.4.\
\
\
If you have any question, you can ask on the SFML forum: http://www.sfml-dev.org/forum/\
\
}

513
build/xcode/dist/autogen.sh vendored Executable file
View File

@ -0,0 +1,513 @@
#!/bin/sh
cd ../../../
SFML_VERSION="1.6"
OS="macosx"
ROOT_DIR=`pwd`
XCODE_C_ROOT_DIR="$ROOT_DIR/CSFML/xcode"
XCODE_CXX_ROOT_DIR="$ROOT_DIR/build/xcode"
XCODE_SAMPLES_ROOT_DIR="$ROOT_DIR/samples/build/xcode"
XCODE_FRAMEWORKS_PROJECT="SFML.xcodeproj"
XCODE_LIBRARIES_PROJECT="SFML-bare.xcodeproj"
XCODE_SAMPLES_PROJECT="samples.xcodeproj"
XCODE_BUILD_STYLE="Release"
XCODE_C_TARGETS=("SFML" "csfml-system" "csfml-network" "csfml-audio" "csfml-window" "csfml-graphics")
XCODE_CXX_TARGETS=("SFML" "sfml-system" "sfml-network" "sfml-audio" "sfml-window" "sfml-graphics")
C_FRAMEWORKS_DIR="$ROOT_DIR/CSFML/lib"
CXX_FRAMEWORKS_DIR="$ROOT_DIR/lib"
CXX_SAMPLES_DIR="$ROOT_DIR/samples/bin"
PACKAGES_ROOT_DIR="$ROOT_DIR/dist"
CXX_SDK_PACKAGE="SFML-$SFML_VERSION-sdk-$OS"
CXX_DEV_PACKAGE="SFML-$SFML_VERSION-dev-$OS"
C_SDK_PACKAGE="SFML-$SFML_VERSION-c-sdk-$OS"
C_DEV_PACKAGE="SFML-$SFML_VERSION-c-dev-$OS"
CXX_SDK_PACKAGE_DIR="$PACKAGES_ROOT_DIR/$CXX_SDK_PACKAGE"
CXX_DEV_PACKAGE_DIR="$PACKAGES_ROOT_DIR/$CXX_DEV_PACKAGE"
C_SDK_PACKAGE_DIR="$PACKAGES_ROOT_DIR/$C_SDK_PACKAGE"
C_SDK_PACKAGE_SUB_DIR="$PACKAGES_ROOT_DIR/$C_SDK_PACKAGE/CSFML"
C_DEV_PACKAGE_DIR="$PACKAGES_ROOT_DIR/$C_DEV_PACKAGE"
C_DEV_PACKAGE_SUB_DIR="$PACKAGES_ROOT_DIR/$C_DEV_PACKAGE/CSFML"
PACKAGES_INFO_FILES_DIR="$XCODE_CXX_ROOT_DIR/dist"
CXX_SDK_DIRS=("build" "src" "include" "lib" "extlibs" "samples" "doc")
CXX_DEV_DIRS=("lib" "extlibs" "build/xcode/templates")
C_SDK_DIRS=("src" "include" "extlibs")
C_SDK_SUB_DIRS=("CSFML/xcode" "CSFML/src" "CSFML/include" "CSFML/lib")
C_DEV_DIRS=("extlibs")
C_DEV_SUB_DIRS=("CSFML/xcode/templates" "CSFML/lib")
PACKAGE_INFO_FILES=("Read Me.rtf" "Release Notes.rtf" "Notes de version.rtf" "license.txt" "Lisez-moi.rtf")
SHOULD_CONSIDER_CXX="yes"
SHOULD_CONSIDER_C="yes"
SHOULD_CONSIDER_SAMPLES="yes"
# Checks that last command ended normally. Prints an error message and exists if not.
check_last_process()
{
if [ $? -eq 0 ]
then
if [ "$1" != "" ]
then
echo "$1"
fi
else
echo "*** Last process did not end properly. Process stopped."
exit 1
fi
}
# User help
print_usage()
{
echo "Usage: $0 [clean | build | build-samples | build-pkg | all]"
echo " Default shows this help"
echo
echo " clean\t\tdeletes the C and C++ frameworks, object files and packages"
echo " build\t\tcompiles all the C and C++ SFML frameworks"
echo " build-samples\tcompiles the SFML samples"
echo " build-pkg\t\tbuilds the packages to be distributed"
echo " all\t\t\tdoes build, build-samples and build-pkg"
echo
echo " Found C++ project : $SHOULD_CONSIDER_CXX"
echo " Found C project : $SHOULD_CONSIDER_C"
echo " Found samples project : $SHOULD_CONSIDER_SAMPLES"
echo " Missing projects will be skiped without further warning."
}
# Checks that the user computer can run this script
check_config()
{
os=`uname -s`
if [ $os != "Darwin" ]
then
echo "You're not running Mac OS X !"
exit 1
fi
if ! test -f "/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp"
then
echo "Missing tool pbxcp needed by this script (should be located at /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp). Make sure Apple Developer Tools are correctly installed."
exit 1
fi
if ! test -f "/usr/bin/xcodebuild"
then
echo "Missing tool xcodebuild needed by this script (should be located at /usr/bin/xcodebuild). Make sure Apple Developer Tools are correctly installed."
exit 1
fi
sdk=`xcodebuild -showsdks | grep "Mac OS X 10.4"`
if [ "$sdk" == "" ]
then
echo "Missing Mac OS X 10.4 SDK needed by SFML. Please install it."
exit 1
fi
if ! test -d "$XCODE_CXX_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
SHOULD_CONSIDER_CXX="no"
fi
if ! test -d "$XCODE_C_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
SHOULD_CONSIDER_C="no"
fi
if ! test -d "$XCODE_SAMPLES_ROOT_DIR/$XCODE_SAMPLES_PROJECT"
then
SHOULD_CONSIDER_SAMPLES="no"
fi
}
# Makes a directory if needed
make_dir()
{
if ! test -d "$1"
then
mkdir -p "$1"
fi
}
# Checks that a directory exists and removes it
remove_dir()
{
if test -d "$1"
then
rm -rfv "$1" > /dev/null
fi
}
# Checks that a file exists and removes it
remove_file()
{
if test -f "$1"
then
rm -f "$1" > /dev/null
fi
}
# Moves a directory, removing the destination before moving if already existing
move_dir()
{
remove_dir "$2"
check_last_process
make_dir "$2/.."
check_last_process
mv "$1" "$2"
check_last_process
}
copy()
{
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude ".*" -exclude codeblocks -exclude *vc2005 -exclude *vc2008 -exclude *mingw -exclude Makefile -exclude Main -exclude "Template for new ports" -exclude Linux -exclude Win32 -exclude win32 -exclude *.build -exclude *.dll -exclude *.dSYM -exclude qt -exclude wxwidgets -exclude X11 -exclude "$USER*" -exclude dist -exclude AL -strip-debug-symbols -resolve-src-symlinks "$1" "$2"
}
# Delete built frameworks and intermediate object files
clean_all()
{
cd "$ROOT_DIR"
# Process cleaning for C++ project
if [ "$SHOULD_CONSIDER_CXX" == "yes" ]
then
printf "Cleaning C++ products..."
if test -d "$XCODE_CXX_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
cd "$XCODE_CXX_ROOT_DIR"
xcodebuild -project "$XCODE_FRAMEWORKS_PROJECT" -target "All" -configuration "$XCODE_BUILD_STYLE" clean > /dev/null
check_last_process " done"
else
if test -d "$XCODE_CXX_ROOT_DIR"
then
echo "*** Missing file $XCODE_CXX_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT. Process stopped."
exit 1
else
echo " not found. Skiped"
fi
fi
fi
# Process cleaning for C project
if [ "$SHOULD_CONSIDER_C" == "yes" ]
then
printf "Cleaning C products..."
if test -d "$XCODE_C_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
cd "$XCODE_C_ROOT_DIR"
xcodebuild -project "$XCODE_FRAMEWORKS_PROJECT" -target "All" -configuration "$XCODE_BUILD_STYLE" clean > /dev/null
check_last_process " done"
else
# Do not produce error if the package does no contain the C stuff
if test -d "$XCODE_C_ROOT_DIR"
then
echo "*** Missing file $XCODE_C_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT. Process stopped."
exit 1
else
echo " not found. Skiped"
fi
fi
fi
# Process cleaning for samples
if [ "$SHOULD_CONSIDER_SAMPLES" == "yes" ]
then
printf "Cleaning samples..."
if test -d "$XCODE_SAMPLES_ROOT_DIR/$XCODE_SAMPLES_PROJECT"
then
cd "$XCODE_SAMPLES_ROOT_DIR"
xcodebuild -project "$XCODE_SAMPLES_PROJECT" -target "All" -configuration "$XCODE_BUILD_STYLE" clean > /dev/null
check_last_process " done"
else
# Do not produce error if the package does not contain the samples
if test -d "$XCODE_SAMPLES_ROOT_DIR"
then
echo "*** Missing file $XCODE_SAMPLES_ROOT_DIR/$XCODE_SAMPLES_PROJECT. Process stopped."
exit 1
else
echo " not found. Skiped"
fi
fi
fi
# Process cleaning for packages
printf "Removing packages..."
remove_dir "$PACKAGES_ROOT_DIR"
check_last_process " done"
}
# Build C and C++ frameworks
build_frameworks()
{
# Go into the C++ project directory
if [ "$SHOULD_CONSIDER_CXX" == "yes" ]
then
cd "$XCODE_CXX_ROOT_DIR"
check_last_process
echo "Building C++ SFML frameworks in $XCODE_BUILD_STYLE mode..."
if test -d "$XCODE_CXX_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
# Build every C++ target (building manually each target to be able to show progress)
for target in "${XCODE_CXX_TARGETS[@]}"
do
printf "Building $target framework..."
xcodebuild -project "$XCODE_FRAMEWORKS_PROJECT" -target "$target" -parallelizeTargets -configuration "$XCODE_BUILD_STYLE" build > /dev/null
check_last_process " done"
done
echo "All C++ SFML frameworks built."
else
echo "*** Missing file $XCODE_CXX_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT. Process stopped."
exit 1
fi
fi
# Go into the C project directory
if [ "$SHOULD_CONSIDER_C" == "yes" ]
then
cd "$XCODE_C_ROOT_DIR"
check_last_process
echo "Building C SFML frameworks in $XCODE_BUILD_STYLE mode..."
if test -d "$XCODE_C_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT"
then
# Build every C target
for target in "${XCODE_C_TARGETS[@]}"
do
printf "Building $target framework..."
xcodebuild -project "$XCODE_FRAMEWORKS_PROJECT" -target "$target" -parallelizeTargets -configuration "$XCODE_BUILD_STYLE" build > /dev/null
check_last_process " done"
done
echo "All C SFML frameworks built."
else
echo "*** Missing file $XCODE_C_ROOT_DIR/$XCODE_FRAMEWORKS_PROJECT. Process stopped."
exit 1
fi
fi
}
# Build the samples
build_samples()
{
# Go into the samples project directory
if [ "$SHOULD_CONSIDER_SAMPLES" == "yes" ]
then
cd "$XCODE_SAMPLES_ROOT_DIR"
check_last_process
printf "Building SFML samples in $XCODE_BUILD_STYLE mode..."
if test -d "$XCODE_SAMPLES_ROOT_DIR/$XCODE_SAMPLES_PROJECT"
then
# Build the samples
xcodebuild -project "$XCODE_SAMPLES_PROJECT" -target "All" -parallelizeTargets -configuration "$XCODE_BUILD_STYLE" build > /dev/null
check_last_process " done"
echo "In order to run the samples, the SFML frameworks (located in \"lib\") must be copied in the /Library/Frameworks directory." > "$CXX_SAMPLES_DIR/README"
check_last_process
else
echo "*** Missing file $XCODE_SAMPLES_ROOT_DIR/$XCODE_SAMPLES_PROJECT. Process stopped."
exit 1
fi
fi
}
# Put the information files in the package
copy_info_files()
{
for file in "${PACKAGE_INFO_FILES[@]}"
do
copy "$PACKAGES_INFO_FILES_DIR/$file" "$1"
check_last_process
done
}
# Build the disk image files of the C and C++ Dev and SDK packages
build_packages()
{
cd "$ROOT_DIR"
make_dir "$PACKAGES_ROOT_DIR"
# Build the C++ SDK package
if [ "$SHOULD_CONSIDER_CXX" == "yes" ]
then
echo "Building C++ SDK package..."
make_dir "$CXX_SDK_PACKAGE_DIR"
for dir in "${CXX_SDK_DIRS[@]}"
do
case "$dir" in
"doc")
if ! test -f "$ROOT_DIR/$dir/html/index.htm"
then
echo "$ROOT_DIR/$dir/html/index.htm not found. Make sure the documentation has been built."
exit 1
fi
;;
esac
copy "$ROOT_DIR/$dir" "$CXX_SDK_PACKAGE_DIR"
check_last_process
done
copy_info_files "$CXX_SDK_PACKAGE_DIR"
check_last_process
# Build the disk image file
printf "Made final folder, building Disk Image File..."
remove_file "$PACKAGES_ROOT_DIR/$CXX_SDK_PACKAGE.dmg"
hdiutil create -format UDBZ -volname "$CXX_SDK_PACKAGE" -srcfolder "$CXX_SDK_PACKAGE_DIR" "$PACKAGES_ROOT_DIR/$CXX_SDK_PACKAGE.dmg" > /dev/null
check_last_process " done"
# Build the C++ Dev package
echo "Building C++ Development package..."
make_dir "$CXX_DEV_PACKAGE_DIR"
for dir in "${CXX_DEV_DIRS[@]}"
do
copy "$ROOT_DIR/$dir" "$CXX_DEV_PACKAGE_DIR"
check_last_process
case $dir in
"build/xcode/templates")
# Special consideration for the templates folder that is to be moved in build/xcode
move_dir "$CXX_DEV_PACKAGE_DIR/templates" "$CXX_DEV_PACKAGE_DIR/build/xcode"
check_last_process
;;
"extlibs")
# Drop the libs-xcode and headers directories
remove_dir "$CXX_DEV_PACKAGE_DIR/extlibs/libs-xcode"
check_last_process
remove_dir "$CXX_DEV_PACKAGE_DIR/extlibs/headers"
check_last_process
;;
*)
;;
esac
done
copy_info_files "$CXX_DEV_PACKAGE_DIR"
# Build the disk image file
printf "Made final folder, building Disk Image File..."
remove_file "$PACKAGES_ROOT_DIR/$CXX_DEV_PACKAGE.dmg"
hdiutil create -format UDBZ -volname "$CXX_DEV_PACKAGE" -srcfolder "$CXX_DEV_PACKAGE_DIR" "$PACKAGES_ROOT_DIR/$CXX_DEV_PACKAGE.dmg" > /dev/null
check_last_process " done"
fi # SHOULD_CONSIDER_CXX
# Build the C SDK package
if [ "$SHOULD_CONSIDER_C" == "yes" ]
then
echo "Building C SDK package..."
make_dir "$C_SDK_PACKAGE_DIR"
for dir in "${C_SDK_DIRS[@]}"
do
copy "$ROOT_DIR/$dir" "$C_SDK_PACKAGE_DIR"
check_last_process
done
make_dir "$C_SDK_PACKAGE_SUB_DIR"
for dir in "${C_SDK_SUB_DIRS[@]}"
do
copy "$ROOT_DIR/$dir" "$C_SDK_PACKAGE_SUB_DIR"
check_last_process
done
copy_info_files "$C_SDK_PACKAGE_DIR"
# Build the disk image file
printf "Made final folder, building Disk Image File..."
remove_file "$PACKAGES_ROOT_DIR/$C_SDK_PACKAGE.dmg"
hdiutil create -format UDBZ -volname "$C_SDK_PACKAGE" -srcfolder "$C_SDK_PACKAGE_DIR" "$PACKAGES_ROOT_DIR/$C_SDK_PACKAGE.dmg" > /dev/null
check_last_process " done"
# Build the C Development package
echo "Building C Development package..."
make_dir "$C_DEV_PACKAGE_DIR"
for dir in "${C_DEV_DIRS[@]}"
do
copy "$ROOT_DIR/$dir" "$C_DEV_PACKAGE_DIR"
check_last_process
case $dir in
"extlibs")
# Drop the libs-xcode and headers directories
remove_dir "$C_DEV_PACKAGE_DIR/extlibs/libs-xcode"
check_last_process
remove_dir "$C_DEV_PACKAGE_DIR/extlibs/headers"
check_last_process
;;
esac
done
make_dir "$C_DEV_PACKAGE_SUB_DIR"
for dir in "${C_DEV_SUB_DIRS[@]}"
do
copy "$ROOT_DIR/$dir" "$C_DEV_PACKAGE_SUB_DIR"
check_last_process
case $dir in
"CSFML/xcode/templates")
# Special consideration for the templates folder that is to be moved in build/xcode
move_dir "$C_DEV_PACKAGE_DIR/CSFML/templates" "$C_DEV_PACKAGE_DIR/CSFML/xcode"
check_last_process
;;
esac
done
copy_info_files "$C_DEV_PACKAGE_DIR"
# Build the disk image file
printf "Made final folder, building Disk Image File..."
remove_file "$PACKAGES_ROOT_DIR/$C_DEV_PACKAGE.dmg"
hdiutil create -format UDBZ -volname "$C_DEV_PACKAGE" -srcfolder "$C_DEV_PACKAGE_DIR" "$PACKAGES_ROOT_DIR/$C_DEV_PACKAGE.dmg" > /dev/null
check_last_process " done"
fi
echo "All packages have been built. See $PACKAGES_ROOT_DIR."
}
main()
{
# First make sure the user will be able to run the script
check_config
# Check which action the user wants to execute (default is help)
action="help"
if test "$1" != ""
then
action="$1"
fi
case $action in
"clean")
clean_all $*
;;
"build")
build_frameworks $*
;;
"build-samples")
build_samples $*
;;
"build-pkg")
build_packages $*
;;
"all")
build_frameworks $*
build_samples $*
build_packages $*
;;
"-h")
print_usage $*
;;
"--help")
print_usage $*
;;
"help")
print_usage $*
;;
*)
echo "Unknow action $action."
print_usage $*
;;
esac
}
main $*

38
build/xcode/dist/license.txt vendored Normal file
View File

@ -0,0 +1,38 @@
SFML
----
SFML - Copyright (c) 2007-2009 Laurent Gomila - laurent.gom@gmail.com
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
External libraries used by SFML
-------------------------------
* OpenAL-Soft is under the LGPL license
* libsndfile is under the LGPL license
* stb_vorbis is public domain
* libjpeg is public domain
* libpng is under the zlib/png license
* zlib is under the zlib/png license
* SOIL is public domain
* freetype is under the FreeType license or the GPL license

3
doc/build/Doxyfile vendored
View File

@ -604,7 +604,6 @@ FILE_PATTERNS = *.c \
*.ipp \ *.ipp \
*.i++ \ *.i++ \
*.inl \ *.inl \
*.h \
*.hh \ *.hh \
*.hxx \ *.hxx \
*.hpp \ *.hpp \
@ -615,8 +614,6 @@ FILE_PATTERNS = *.c \
*.php \ *.php \
*.php3 \ *.php3 \
*.inc \ *.inc \
*.m \
*.mm \
*.dox \ *.dox \
*.py *.py

View File

@ -142,7 +142,7 @@ namespace Key
F15, F15,
Pause, Pause,
Count // For internal use Count // Keep last -- total number of keyboard keys
}; };
} }
@ -160,7 +160,7 @@ namespace Mouse
XButton1, XButton1,
XButton2, XButton2,
Count // For internal use Count // Keep last -- total number of mouse buttons
}; };
} }
@ -180,7 +180,7 @@ namespace Joy
AxisV, AxisV,
AxisPOV, AxisPOV,
Count // For internal use Count // Keep last -- total number of joystick axis
}; };
} }
@ -286,7 +286,9 @@ public :
MouseLeft, MouseLeft,
JoyButtonPressed, JoyButtonPressed,
JoyButtonReleased, JoyButtonReleased,
JoyMoved JoyMoved,
Count // Keep last -- total number of event types
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -135,12 +135,12 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
A07D7D6A0EE82B6F006712A3 /* sfml-audio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-audio.framework"; path = "/Library/Frameworks/sfml-audio.framework"; sourceTree = "<absolute>"; }; A07D7D6A0EE82B6F006712A3 /* sfml-audio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-audio.framework"; path = "../../../lib/sfml-audio.framework"; sourceTree = "<group>"; };
A07D7D6B0EE82B6F006712A3 /* sfml-network.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-network.framework"; path = "/Library/Frameworks/sfml-network.framework"; sourceTree = "<absolute>"; }; A07D7D6B0EE82B6F006712A3 /* sfml-network.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-network.framework"; path = "../../../lib/sfml-network.framework"; sourceTree = "<group>"; };
A07D7D6C0EE82B6F006712A3 /* sfml-graphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-graphics.framework"; path = "/Library/Frameworks/sfml-graphics.framework"; sourceTree = "<absolute>"; }; A07D7D6C0EE82B6F006712A3 /* sfml-graphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-graphics.framework"; path = "../../../lib/sfml-graphics.framework"; sourceTree = "<group>"; };
A07D7D6D0EE82B6F006712A3 /* sfml-system.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-system.framework"; path = "/Library/Frameworks/sfml-system.framework"; sourceTree = "<absolute>"; }; A07D7D6D0EE82B6F006712A3 /* sfml-system.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-system.framework"; path = "../../../lib/sfml-system.framework"; sourceTree = "<group>"; };
A07D7D6E0EE82B6F006712A3 /* sfml-window.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-window.framework"; path = "/Library/Frameworks/sfml-window.framework"; sourceTree = "<absolute>"; }; A07D7D6E0EE82B6F006712A3 /* sfml-window.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-window.framework"; path = "../../../lib/sfml-window.framework"; sourceTree = "<group>"; };
A07D7D6F0EE82B6F006712A3 /* SFML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SFML.framework; path = /Library/Frameworks/SFML.framework; sourceTree = "<absolute>"; }; A07D7D6F0EE82B6F006712A3 /* SFML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SFML.framework; path = ../../../lib/SFML.framework; sourceTree = "<group>"; };
A07D7DDA0EE82B93006712A3 /* Ftp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Ftp.cpp; sourceTree = "<group>"; }; A07D7DDA0EE82B93006712A3 /* Ftp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Ftp.cpp; sourceTree = "<group>"; };
A07D7DDF0EE82B93006712A3 /* OpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenGL.cpp; sourceTree = "<group>"; }; A07D7DDF0EE82B93006712A3 /* OpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenGL.cpp; sourceTree = "<group>"; };
A07D7DE20EE82B93006712A3 /* Pong.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Pong.cpp; sourceTree = "<group>"; }; A07D7DE20EE82B93006712A3 /* Pong.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Pong.cpp; sourceTree = "<group>"; };
@ -802,6 +802,7 @@
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
CONFIGURATION_BUILD_DIR = ../../bin; CONFIGURATION_BUILD_DIR = ../../bin;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../lib\"";
OBJROOT = build; OBJROOT = build;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SYMROOT = ../../bin; SYMROOT = ../../bin;
@ -815,6 +816,7 @@
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
CONFIGURATION_BUILD_DIR = ../../bin; CONFIGURATION_BUILD_DIR = ../../bin;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../lib\"";
OBJROOT = build; OBJROOT = build;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SYMROOT = ../../bin; SYMROOT = ../../bin;

View File

@ -46,15 +46,15 @@ Sound::Sound()
/// Construct the sound from its parameters /// Construct the sound from its parameters
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) : Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) :
myBuffer(&buffer) myBuffer(NULL)
{ {
ALCheck(alGenSources(1, &mySource)); ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei (mySource, AL_BUFFER, buffer.myBuffer)); SetBuffer(buffer);
ALCheck(alSourcei (mySource, AL_LOOPING, loop)); SetLoop(loop);
ALCheck(alSourcef (mySource, AL_PITCH, pitch)); SetPitch(pitch);
ALCheck(alSourcef (mySource, AL_GAIN, volume * 0.01f)); SetVolume(volume);
ALCheck(alSource3f(mySource, AL_POSITION, position.x, position.y, position.z)); SetPosition(position);
} }
@ -62,15 +62,19 @@ myBuffer(&buffer)
/// Copy constructor /// Copy constructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Sound::Sound(const Sound& copy) : Sound::Sound(const Sound& copy) :
myBuffer(copy.myBuffer) myBuffer(NULL)
{ {
ALCheck(alGenSources(1, &mySource)); ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei (mySource, AL_BUFFER, myBuffer ? myBuffer->myBuffer : 0)); if (copy.myBuffer)
ALCheck(alSourcei (mySource, AL_LOOPING, copy.GetLoop())); SetBuffer(*copy.myBuffer);
ALCheck(alSourcef (mySource, AL_PITCH, copy.GetPitch())); SetLoop(copy.GetLoop());
ALCheck(alSourcef (mySource, AL_GAIN, copy.GetVolume() * 0.01f)); SetPitch(copy.GetPitch());
ALCheck(alSource3f(mySource, AL_POSITION, copy.GetPosition().x, copy.GetPosition().y, copy.GetPosition().z)); SetVolume(copy.GetVolume());
SetPosition(copy.GetPosition());
SetRelativeToListener(copy.IsRelativeToListener());
SetMinDistance(copy.GetMinDistance());
SetAttenuation(copy.GetAttenuation());
} }

View File

@ -131,13 +131,24 @@ Socket::Status SocketTCP::Connect(unsigned short port, const IPAddress& host, fl
time.tv_sec = static_cast<long>(timeout); time.tv_sec = static_cast<long>(timeout);
time.tv_usec = (static_cast<long>(timeout * 1000) % 1000) * 1000; time.tv_usec = (static_cast<long>(timeout * 1000) % 1000) * 1000;
// Wait for something to write on our socket (would mean the connection has been accepted) // Wait for something to write on our socket (which means that the connection request has returned)
if (select(static_cast<int>(mySocket + 1), NULL, &selector, NULL, &time) > 0) if (select(static_cast<int>(mySocket + 1), NULL, &selector, NULL, &time) > 0)
{ {
// Connection succeeded // At this point the connection may have been either accepted or refused.
// To know whether it's a success or a failure, we try to retrieve the name of the connected peer
SocketHelper::LengthType size = sizeof(sockAddr);
if (getpeername(mySocket, reinterpret_cast<sockaddr*>(&sockAddr), &size) != -1)
{
// Connection accepted
status = Socket::Done; status = Socket::Done;
} }
else else
{
// Connection failed
status = SocketHelper::GetErrorStatus();
}
}
else
{ {
// Failed to connect before timeout is over // Failed to connect before timeout is over
status = SocketHelper::GetErrorStatus(); status = SocketHelper::GetErrorStatus();

View File

@ -30,8 +30,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#define SharedAppController [AppController sharedController]
// Fade operations // Fade operations
enum { enum {
FillScreen, FillScreen,

View File

@ -33,9 +33,6 @@
#import <iostream> #import <iostream>
// AppController singleton object
static AppController *shared = nil;
/* setAppleMenu disappeared from the headers in 10.4 */ /* setAppleMenu disappeared from the headers in 10.4 */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
@ -83,6 +80,11 @@ static AppController *shared = nil;
// Make the app autorelease pool // Make the app autorelease pool
myMainPool = [[NSAutoreleasePool alloc] init]; myMainPool = [[NSAutoreleasePool alloc] init];
if (!myMainPool) {
[self release];
throw std::bad_alloc();
}
// Don't go on if the user handles the app // Don't go on if the user handles the app
if (![NSApp isRunning]) if (![NSApp isRunning])
{ {
@ -96,7 +98,10 @@ static AppController *shared = nil;
} }
// Make the app // Make the app
[NSApplication sharedApplication]; if (![NSApplication sharedApplication]) {
[self release];
throw std::bad_alloc();
}
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// I want to go back to the desktop mode // I want to go back to the desktop mode
@ -134,7 +139,7 @@ static AppController *shared = nil;
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[myFullscreenWrapper release]; [myMainPool release];
[super dealloc]; [super dealloc];
} }
@ -144,9 +149,8 @@ static AppController *shared = nil;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+ (AppController *)sharedController + (AppController *)sharedController
{ {
if (nil == shared) // AppController singleton object
shared = [[AppController alloc] init]; static AppController *shared = [[AppController alloc] init];
return shared; return shared;
} }
@ -216,10 +220,6 @@ static AppController *shared = nil;
{ {
if (myFullscreenWrapper) if (myFullscreenWrapper)
[self setFullscreenWindow:nil mode:NULL]; [self setFullscreenWindow:nil mode:NULL];
// FIXME: should I really do this ? what about the user owned windows ?
// And is this really useful as the application is about to exit ?
[NSApp makeWindowsPerform:@selector(close) inOrder:NO];
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -266,10 +266,10 @@ static AppController *shared = nil;
keyEquivalent:@"h"]; keyEquivalent:@"h"];
// + 'Hide other' menu item // + 'Hide other' menu item
menuItem = reinterpret_cast <NSMenuItem *> ([appleMenu addItemWithTitle:@"Hide Others" menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:) action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]); keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; [menuItem setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask];
// + 'Show all' menu item // + 'Show all' menu item
[appleMenu addItemWithTitle:@"Show All" [appleMenu addItemWithTitle:@"Show All"

View File

@ -34,7 +34,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@interface GLContext : NSOpenGLContext @interface GLContext : NSOpenGLContext
{ {
GLContext *mySharedContext;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -94,27 +94,13 @@
@end @end
////////////////////////////////////////////////////////////
/// Cocoa window implementation to let fullscreen windows
/// catch key events
////////////////////////////////////////////////////////////
@interface GLWindow : NSWindow
////////////////////////////////////////////////////////////
/// Technical note: this class must neither contain new members
/// nor methods. It is used transparently as a NSWindow object
/// by WindowWrapper. Not following this rule could result
/// in a segmentation fault or data corruption.
////////////////////////////////////////////////////////////
@end
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// WindowWrapper class : handles both imported and self-built windows /// WindowWrapper class : handles both imported and self-built windows
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@interface WindowWrapper : NSObject @interface WindowWrapper : NSObject
{ {
GLWindow *myWindow; NSWindow *myWindow;
GLView *myView; GLView *myView;
sf::VideoMode myFullscreenMode; sf::VideoMode myFullscreenMode;
bool myIsFullscreen; bool myIsFullscreen;

View File

@ -29,7 +29,6 @@
#import <SFML/Window/Cocoa/AppController.h> #import <SFML/Window/Cocoa/AppController.h>
#import <SFML/Window/VideoMode.hpp> #import <SFML/Window/VideoMode.hpp>
#import <SFML/Window/WindowStyle.hpp> #import <SFML/Window/WindowStyle.hpp>
#import <SFML/System/Sleep.hpp>
#import <OpenGL/gl.h> #import <OpenGL/gl.h>
#import <iostream> #import <iostream>
@ -39,26 +38,21 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@implementation GLContext @implementation GLContext
static GLContext *sharedCtx = nil;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Return the shared OpenGL context instance (making one if needed) /// Return the shared OpenGL context instance (making one if needed)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+ (id)sharedContext + (id)sharedContext
{
if (sharedCtx == nil)
{ {
// Make a new context with the default parameters // Make a new context with the default parameters
sf::WindowSettings params(0, 0, 0); sf::WindowSettings params;
sharedCtx = [[GLContext alloc] initWithAttributes:params sharedContext:nil]; static GLContext *sharedCtx = [[GLContext alloc] initWithAttributes:params sharedContext:nil];
}
return sharedCtx; return sharedCtx;
} }
- (void)dealloc - (void)dealloc
{ {
[mySharedContext release]; [[GLContext sharedContext] release];
[super dealloc]; [super dealloc];
} }
@ -66,7 +60,7 @@ static GLContext *sharedCtx = nil;
/// Make a new OpenGL context according to the @attribs settings /// Make a new OpenGL context according to the @attribs settings
/// and the shared context @context /// and the shared context @context
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
- (id)initWithAttributes:(sf::WindowSettings&)attribs sharedContext:(GLContext *)context - (id)initWithAttributes:(sf::WindowSettings&)attribs sharedContext:(GLContext *)sharedContext
{ {
// Note about antialiasing and other context attributes : // Note about antialiasing and other context attributes :
// OpenGL context sharing does not allow the shared contexts to use different attributes. // OpenGL context sharing does not allow the shared contexts to use different attributes.
@ -94,15 +88,15 @@ static GLContext *sharedCtx = nil;
// windowed context (even fullscreen mode uses a window) // windowed context (even fullscreen mode uses a window)
ctxtAttribs[idx++] = NSOpenGLPFAWindow; ctxtAttribs[idx++] = NSOpenGLPFAWindow;
// Color size ; usually 32 bits per pixel // Color buffer bits ; usually 32 bits per pixel
ctxtAttribs[idx++] = NSOpenGLPFAColorSize; ctxtAttribs[idx++] = NSOpenGLPFAColorSize;
ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) sf::VideoMode::GetDesktopMode().BitsPerPixel; ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) sf::VideoMode::GetDesktopMode().BitsPerPixel;
// Z-buffer size // Depth buffer size
ctxtAttribs[idx++] = NSOpenGLPFADepthSize; ctxtAttribs[idx++] = NSOpenGLPFADepthSize;
ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) attribs.DepthBits; ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) attribs.DepthBits;
// Stencil bits (I don't really know what's that...) // Stencil buffer bits
ctxtAttribs[idx++] = NSOpenGLPFAStencilSize; ctxtAttribs[idx++] = NSOpenGLPFAStencilSize;
ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) attribs.StencilBits; ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) attribs.StencilBits;
@ -110,9 +104,7 @@ static GLContext *sharedCtx = nil;
if (myPixelFormat) { if (myPixelFormat) {
self = [super initWithFormat:myPixelFormat self = [super initWithFormat:myPixelFormat
shareContext:context]; shareContext:[sharedContext retain]];
mySharedContext = [context retain];
// Get the effective properties from our OpenGL context // Get the effective properties from our OpenGL context
GLint tmpDepthSize = 0, tmpStencilBits = 0, tmpAntialiasingLevel = 0; GLint tmpDepthSize = 0, tmpStencilBits = 0, tmpAntialiasingLevel = 0;
@ -172,7 +164,13 @@ static GLContext *sharedCtx = nil;
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
// make the OpenGL context // make the OpenGL context
myGLContext = [[GLContext alloc] initWithAttributes:settings sharedContext:sharedCtx]; myGLContext = [[GLContext alloc] initWithAttributes:settings
sharedContext:[GLContext sharedContext]];
if (!myGLContext) {
[self release];
return nil;
}
// We need to update the OpenGL view when it's resized // We need to update the OpenGL view when it's resized
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
@ -417,10 +415,10 @@ static GLContext *sharedCtx = nil;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Cocoa window implementation to let fullscreen windows /// Cocoa window category to let fullscreen windows
/// catch key events /// catch key events
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@implementation GLWindow @implementation NSWindow (GLWindow)
- (BOOL)canBecomeKeyWindow - (BOOL)canBecomeKeyWindow
{ {
@ -501,7 +499,7 @@ static GLContext *sharedCtx = nil;
if (self) if (self)
{ {
if (window) { if (window) {
myWindow = (GLWindow *)[window retain]; myWindow = [window retain];
} else { } else {
assert(title != nil); assert(title != nil);
@ -563,7 +561,7 @@ static GLContext *sharedCtx = nil;
// Now we make the window with the values we got // Now we make the window with the values we got
// Note: defer flag set to NO to be able to use OpenGL in our window // Note: defer flag set to NO to be able to use OpenGL in our window
myWindow = [[GLWindow alloc] initWithContentRect:frame myWindow = [[NSWindow alloc] initWithContentRect:frame
styleMask:mask styleMask:mask
backing:NSBackingStoreBuffered backing:NSBackingStoreBuffered
defer:NO]; defer:NO];
@ -646,7 +644,7 @@ static GLContext *sharedCtx = nil;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
- (void)dealloc - (void)dealloc
{ {
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
// Remove the notification observer // Remove the notification observer
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
@ -654,10 +652,13 @@ static GLContext *sharedCtx = nil;
[self show:false]; [self show:false];
// Release the window and view // Release the window and view
[myView removeFromSuperviewWithoutNeedingDisplay];
[myView release]; [myView release];
[myWindow release]; [myWindow release];
[super dealloc]; [super dealloc];
[localPool release];
} }
@ -758,7 +759,7 @@ static GLContext *sharedCtx = nil;
// Wanna open the closed window // Wanna open the closed window
if (myIsFullscreen) { if (myIsFullscreen) {
[SharedAppController setFullscreenWindow:self mode:&myFullscreenMode]; [[AppController sharedController] setFullscreenWindow:self mode:&myFullscreenMode];
} else { } else {
// Show the window // Show the window
[myWindow makeKeyAndOrderFront:nil]; [myWindow makeKeyAndOrderFront:nil];
@ -767,7 +768,7 @@ static GLContext *sharedCtx = nil;
// Wanna close the opened window // Wanna close the opened window
if (myIsFullscreen) { if (myIsFullscreen) {
[SharedAppController setFullscreenWindow:nil mode:NULL]; [[AppController sharedController] setFullscreenWindow:nil mode:NULL];
} else { } else {
// Close the window // Close the window
[myWindow close]; [myWindow close];
@ -849,7 +850,7 @@ static GLContext *sharedCtx = nil;
{ {
NSWindow *sender = [notification object]; NSWindow *sender = [notification object];
if (!([sender styleMask] & NSTitledWindowMask)) if (myIsFullscreen)
[sender center]; [sender center];
} }

View File

@ -33,8 +33,10 @@
#include <string> #include <string>
#ifdef __OBJC__ #ifdef __OBJC__
#import <Cocoa/Cocoa.h>
@class WindowWrapper; @class WindowWrapper;
typedef WindowWrapper* WindowWrapperRef;
#else
typedef void* WindowWrapperRef;
#endif #endif
namespace sf namespace sf
@ -190,13 +192,7 @@ private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
WindowWrapperRef myWrapper;
#ifdef __OBJC__
WindowWrapper *myWrapper;
#else
void *myWrapper;
#endif
bool myUseKeyRepeat; bool myUseKeyRepeat;
bool myMouseIn; bool myMouseIn;
float myWheelStatus; float myWheelStatus;

View File

@ -31,9 +31,6 @@
#import <SFML/Window/Cocoa/GLKit.h> #import <SFML/Window/Cocoa/GLKit.h>
#import <SFML/Window/WindowStyle.hpp> #import <SFML/Window/WindowStyle.hpp>
#import <SFML/System.hpp> #import <SFML/System.hpp>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
#import <CoreFoundation/CoreFoundation.h>
#import <iostream> #import <iostream>
@ -54,16 +51,16 @@ __done = 1;\
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Private function declarations /// Private function declarations
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Key::Code KeyForVirtualCode(unsigned short vCode); namespace {
static Key::Code KeyForUnicode(unsigned short uniCode); Key::Code KeyForVirtualCode(unsigned short vCode);
static bool IsTextEvent(NSEvent *event); Key::Code KeyForUnicode(unsigned short uniCode);
} // anonymous namespace
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// Default constructor
/// (creates a dummy window to provide a valid OpenGL context) /// (creates a dummy window to provide a valid OpenGL context)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static WindowImplCocoa *globalWin = NULL;
WindowImplCocoa::WindowImplCocoa() : WindowImplCocoa::WindowImplCocoa() :
myWrapper(nil), myWrapper(nil),
myUseKeyRepeat(false), myUseKeyRepeat(false),
@ -133,7 +130,8 @@ myWheelStatus(0.0f)
{ {
// Create a new window with given size, title and style // Create a new window with given size, title and style
// First we define some objects used for our window // First we define some objects used for our window
NSString *title = [NSString stringWithUTF8String:(Title.c_str()) ? (Title.c_str()) : ""]; NSString *title = [NSString stringWithCString:(Title.c_str()) ? (Title.c_str()) : ""
encoding:NSASCIIStringEncoding];
// We create the window // We create the window
myWrapper = [[WindowWrapper alloc] initWithSettings:params myWrapper = [[WindowWrapper alloc] initWithSettings:params
@ -228,18 +226,20 @@ void WindowImplCocoa::HandleKeyDown(void *eventRef)
// convert the characters // convert the characters
// note: using CFString in order to keep compatibility with Mac OS X 10.4 // note: using CFString in order to keep compatibility with Mac OS X 10.4
// (NSUTF32StringEncoding only defined since Mac OS X 10.5) // (as NSUTF32StringEncoding is only being defined in Mac OS X 10.5 and later)
if (!CFStringGetCString ((CFStringRef)[event characters], if (!CFStringGetCString ((CFStringRef)[event characters],
(char *)utf32Characters, (char *)utf32Characters,
sizeof(utf32Characters), sizeof(utf32Characters),
kCFStringEncodingUTF32)) kCFStringEncodingUTF32))
{ {
const char *utf8Char = NULL; char asciiChar[3] = {0};
if ([[event characters] lengthOfBytesUsingEncoding:NSUTF8StringEncoding]) if ([[event characters] lengthOfBytesUsingEncoding:NSASCIIStringEncoding])
utf8Char = [[event characters] UTF8String]; [[event characters] getCString:asciiChar
maxLength:3
encoding:NSASCIIStringEncoding];
std::cerr << "Error while converting character to UTF32 : " std::cerr << "Error while converting character to UTF32 : \""
<< ((utf8Char) ? utf8Char : "(undefined)") << std::endl; << asciiChar << "\"" << std::endl;
} }
else else
{ {
@ -359,7 +359,9 @@ void WindowImplCocoa::HandleMouseDown(void *eventRef)
{ {
NSEvent *event = reinterpret_cast <NSEvent *> (eventRef); NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
Event sfEvent; Event sfEvent;
NSPoint loc = {0, 0};
// Get mouse position relative to the window
NSPoint loc = [myWrapper mouseLocation];
unsigned mods = [event modifierFlags]; unsigned mods = [event modifierFlags];
switch ([event type]) { switch ([event type]) {
@ -373,9 +375,6 @@ void WindowImplCocoa::HandleMouseDown(void *eventRef)
sfEvent.MouseButton.Button = Mouse::Left; sfEvent.MouseButton.Button = Mouse::Left;
} }
// Get mouse position relative to the window
loc = [myWrapper mouseLocation];
sfEvent.MouseButton.X = (int) loc.x; sfEvent.MouseButton.X = (int) loc.x;
sfEvent.MouseButton.Y = (int) loc.y; sfEvent.MouseButton.Y = (int) loc.y;
@ -387,9 +386,6 @@ void WindowImplCocoa::HandleMouseDown(void *eventRef)
sfEvent.Type = Event::MouseButtonPressed; sfEvent.Type = Event::MouseButtonPressed;
sfEvent.MouseButton.Button = Mouse::Right; sfEvent.MouseButton.Button = Mouse::Right;
// Get mouse position relative to the window
loc = [myWrapper mouseLocation];
sfEvent.MouseButton.X = (int) loc.x; sfEvent.MouseButton.X = (int) loc.x;
sfEvent.MouseButton.Y = (int) loc.y; sfEvent.MouseButton.Y = (int) loc.y;
@ -410,7 +406,9 @@ void WindowImplCocoa::HandleMouseUp(void *eventRef)
{ {
NSEvent *event = reinterpret_cast <NSEvent *> (eventRef); NSEvent *event = reinterpret_cast <NSEvent *> (eventRef);
Event sfEvent; Event sfEvent;
NSPoint loc = {0, 0};
// Get mouse position relative to the window
NSPoint loc = [myWrapper mouseLocation];
unsigned mods = [event modifierFlags]; unsigned mods = [event modifierFlags];
switch ([event type]) { switch ([event type]) {
@ -424,9 +422,6 @@ void WindowImplCocoa::HandleMouseUp(void *eventRef)
sfEvent.MouseButton.Button = Mouse::Left; sfEvent.MouseButton.Button = Mouse::Left;
} }
// Get mouse position relative to the window
loc = [myWrapper mouseLocation];
sfEvent.MouseButton.X = (int) loc.x; sfEvent.MouseButton.X = (int) loc.x;
sfEvent.MouseButton.Y = (int) loc.y; sfEvent.MouseButton.Y = (int) loc.y;
@ -438,9 +433,6 @@ void WindowImplCocoa::HandleMouseUp(void *eventRef)
sfEvent.Type = Event::MouseButtonReleased; sfEvent.Type = Event::MouseButtonReleased;
sfEvent.MouseButton.Button = Mouse::Right; sfEvent.MouseButton.Button = Mouse::Right;
// Get mouse position relative to the window
loc = [myWrapper mouseLocation];
sfEvent.MouseButton.X = (int) loc.x; sfEvent.MouseButton.X = (int) loc.x;
sfEvent.MouseButton.Y = (int) loc.y; sfEvent.MouseButton.Y = (int) loc.y;
@ -460,9 +452,7 @@ void WindowImplCocoa::HandleMouseUp(void *eventRef)
void WindowImplCocoa::HandleMouseMove(void *eventRef) void WindowImplCocoa::HandleMouseMove(void *eventRef)
{ {
Event sfEvent; Event sfEvent;
NSPoint loc = {0, 0}; NSPoint loc = [myWrapper mouseLocation];
loc = [myWrapper mouseLocation];
sfEvent.Type = Event::MouseMoved; sfEvent.Type = Event::MouseMoved;
sfEvent.MouseMove.X = (int) loc.x; sfEvent.MouseMove.X = (int) loc.x;
@ -547,7 +537,7 @@ void WindowImplCocoa::Display()
void WindowImplCocoa::ProcessEvents() void WindowImplCocoa::ProcessEvents()
{ {
// Forward event handling call to the application controller // Forward event handling call to the application controller
[SharedAppController processEvents]; [[AppController sharedController] processEvents];
} }
@ -557,7 +547,18 @@ void WindowImplCocoa::ProcessEvents()
void WindowImplCocoa::SetActive(bool Active) const void WindowImplCocoa::SetActive(bool Active) const
{ {
// Forward the call to the window // Forward the call to the window
if (myWrapper)
[myWrapper setActive:Active]; [myWrapper setActive:Active];
else {
// Or directly activate the shared OpenGL context if we're not using a window
if (Active) {
if ([NSOpenGLContext currentContext] != [GLContext sharedContext])
[[GLContext sharedContext] makeCurrentContext];
} else {
if ([NSOpenGLContext currentContext] == [GLContext sharedContext])
[NSOpenGLContext clearCurrentContext];
}
}
} }
@ -656,10 +657,11 @@ void WindowImplCocoa::SetIcon(unsigned int Width, unsigned int Height, const Uin
} }
namespace {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Return the SFML key corresponding to a key code /// Return the SFML key corresponding to a key code
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Key::Code KeyForVirtualCode(unsigned short vCode) Key::Code KeyForVirtualCode(unsigned short vCode)
{ {
static struct { static struct {
unsigned short code; unsigned short code;
@ -732,7 +734,7 @@ static Key::Code KeyForVirtualCode(unsigned short vCode)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Return the SFML key corresponding to a unicode code /// Return the SFML key corresponding to a unicode code
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Key::Code KeyForUnicode(unsigned short uniCode) Key::Code KeyForUnicode(unsigned short uniCode)
{ {
// TODO: find a better way to get the language independant key // TODO: find a better way to get the language independant key
static struct { static struct {
@ -815,6 +817,8 @@ static Key::Code KeyForUnicode(unsigned short uniCode)
return result; return result;
} }
} // anonymous namespace
} // namespace priv } // namespace priv

View File

@ -45,6 +45,7 @@ void Joystick::Initialize(unsigned int index)
myIndex = JOYSTICKID1; myIndex = JOYSTICKID1;
myNbAxes = 0; myNbAxes = 0;
myNbButtons = 0; myNbButtons = 0;
myIsConnected = false;
// Get the Index-th connected joystick // Get the Index-th connected joystick
MMRESULT error; MMRESULT error;
@ -60,6 +61,7 @@ void Joystick::Initialize(unsigned int index)
if (found == index) if (found == index)
{ {
// Ok : store its parameters and return // Ok : store its parameters and return
myIsConnected = true;
JOYCAPS caps; JOYCAPS caps;
joyGetDevCaps(myIndex, &caps, sizeof(caps)); joyGetDevCaps(myIndex, &caps, sizeof(caps));
myNbAxes = caps.wNumAxes; myNbAxes = caps.wNumAxes;
@ -84,6 +86,8 @@ JoystickState Joystick::UpdateState()
{ {
JoystickState state = {0}; JoystickState state = {0};
if (myIsConnected)
{
// Get the joystick caps (for range conversions) // Get the joystick caps (for range conversions)
JOYCAPS caps; JOYCAPS caps;
if (joyGetDevCaps(myIndex, &caps, sizeof(caps)) == JOYERR_NOERROR) if (joyGetDevCaps(myIndex, &caps, sizeof(caps)) == JOYERR_NOERROR)
@ -110,6 +114,7 @@ JoystickState Joystick::UpdateState()
state.Buttons[i] = (pos.dwButtons & (1 << i)) != 0; state.Buttons[i] = (pos.dwButtons & (1 << i)) != 0;
} }
} }
}
return state; return state;
} }

View File

@ -78,6 +78,7 @@ private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool myIsConnected; ///< Is there a joystick connected?
unsigned int myIndex; ///< Windows ID of the joystick unsigned int myIndex; ///< Windows ID of the joystick
unsigned int myNbAxes; ///< Number of axis supported by the joystick unsigned int myNbAxes; ///< Number of axis supported by the joystick
unsigned int myNbButtons; ///< Number of buttons supported by the joystick unsigned int myNbButtons; ///< Number of buttons supported by the joystick