From 9cda5d04744e5a6412f9b779b334f0a9ad6c56c1 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Tue, 16 Aug 2011 08:11:36 +0200 Subject: [PATCH 01/42] Fixed Texture::LoadFromXxx functions not working when loading a sub-rectangle of the image --- src/SFML/Graphics/Texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index e623e325f..9e4cdbca5 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -194,12 +194,12 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area) if (Create(rectangle.Width, rectangle.Height)) { // Copy the pixels to the texture, row by row - const Uint8* pixels = image.GetPixelsPtr() + rectangle.Left + (width * rectangle.Top); + const Uint8* pixels = image.GetPixelsPtr() + 4 * (rectangle.Left + (width * rectangle.Top)); GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); for (int i = 0; i < rectangle.Height; ++i) { GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, myWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); - pixels += width; + pixels += 4 * width; } return true; From d541f5f5b05ca7cefb8fc8656b14691825c81aac Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 19 Aug 2011 18:28:08 +0200 Subject: [PATCH 02/42] Minor fixes in documentation --- include/SFML/System/Thread.hpp | 6 +++--- include/SFML/Window/Window.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/SFML/System/Thread.hpp b/include/SFML/System/Thread.hpp index b3eec7c0b..aece4c7a0 100644 --- a/include/SFML/System/Thread.hpp +++ b/include/SFML/System/Thread.hpp @@ -66,7 +66,7 @@ public : /// void operator()(); /// }; /// \endcode - /// Note: this does *not* run the thread, use Run(). + /// Note: this does *not* run the thread, use Launch(). /// /// \param function Functor or free function to use as the entry point of the thread /// @@ -93,7 +93,7 @@ public : /// void operator()(std::string arg); /// }; /// \endcode - /// Note: this does *not* run the thread, use Run(). + /// Note: this does *not* run the thread, use Launch(). /// /// \param function Functor or free function to use as the entry point of the thread /// \param argument argument to forward to the function @@ -116,7 +116,7 @@ public : /// void function(); /// }; /// \endcode - /// Note: this does *not* run the thread, use Run(). + /// Note: this does *not* run the thread, use Launch(). /// /// \param function Entry point of the thread /// \param object Pointer to the object to use diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 060f8ea9b..14f040ae3 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -176,7 +176,7 @@ public : unsigned int GetWidth() const; //////////////////////////////////////////////////////////// - /// Get the height of the rendering region of the window + /// \brief Get the height of the rendering region of the window /// /// The height doesn't include the titlebar and borders /// of the window. From 1e2aca6e4997a7e4dd1e727871d933f4954bd2b6 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 19 Aug 2011 18:28:21 +0200 Subject: [PATCH 03/42] Fixed sf::Texture copy constructor --- src/SFML/Graphics/Texture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 9e4cdbca5..b7a80d335 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -61,7 +61,8 @@ myTexture (0), myIsSmooth (copy.myIsSmooth), myPixelsFlipped(false) { - LoadFromImage(copy.CopyToImage()); + if (copy.myTexture) + LoadFromImage(copy.CopyToImage()); } From e5d635350e0fad382117cc3fc3be82db7bf824a9 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 19 Aug 2011 18:44:46 +0200 Subject: [PATCH 04/42] Fixed sf::Music::GetDuration() --- src/SFML/Audio/Music.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 747d79c85..36dc8822f 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -139,7 +139,8 @@ void Music::OnSeek(Uint32 timeOffset) void Music::Initialize() { // Compute the music duration - myDuration = static_cast(1000 * myFile->GetSamplesCount() / myFile->GetSampleRate() / myFile->GetChannelsCount()); + Uint64 samples = myFile->GetSamplesCount(); + myDuration = static_cast(1000 * samples / myFile->GetSampleRate() / myFile->GetChannelsCount()); // Resize the internal buffer so that it can contain 1 second of audio samples mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount()); From e09db44906022fdb208fe1fff915864ed476d55a Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 20 Aug 2011 12:14:55 +0200 Subject: [PATCH 05/42] Cmake now is able to build SFML libraries as frameworks (closes #12) Cmake can now automatically install the Xcode templates --- CMakeLists.txt | 101 +++++++++++++++++++++++++++++------ cmake/Macros.cmake | 29 +++++++--- cmake/Modules/FindSFML.cmake | 7 ++- 3 files changed, 113 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2496cb9bd..9cfe2e691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,20 @@ set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to i set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it") # Mac OS X specific options -if (MACOSX AND MACOSX_VERSION GREATER 5) - # add an option to build against 10.5 SDK if current OS X version is greater than 10.5 - set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile with default SDK") +if(MACOSX) + if(MACOSX_VERSION GREATER 5) + # add an option to build against 10.5 SDK if current OS X version is greater than 10.5 + set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile with default SDK") + endif() + + # add an option to build frameworks instead of dylibs (release only) + set(BUILD_FRAMEWORKS FALSE CACHE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS") + + # add an option to let the user specify a custom directory for frameworks installation (SFML, sndfile, ...) + set(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" CACHE STRING "Frameworks installation directory") + + # add an option to automatically install Xcode 4 templates + set(INSTALL_XCODE4_TEMPLATES FALSE CACHE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it") endif() # define SFML_STATIC if the build type is not set to 'shared' @@ -65,9 +76,10 @@ endif() # disable the rpath stuff set(CMAKE_SKIP_BUILD_RPATH TRUE) -# Setup Mac OS X multi arch/SDK support. -if (MACOSX) - if (NOT CMAKE_OSX_ARCHITECTURES) +# Setup Mac OS X stuff +if(MACOSX) + # multi arch support + if(NOT CMAKE_OSX_ARCHITECTURES) # Default : i386 and x86_64 set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") else() @@ -76,13 +88,31 @@ if (MACOSX) message("You're on your own : I won't change your settings.") endif() - # use 10.5 SDK ? - if (BUILD_LEOPARD) + # multi SDK support + if(BUILD_LEOPARD) # Use 10.5 SDK : override default value set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5") else() # Default SDK, let either the user or CMake decide which one to use. + endif() + + # BUILD_FRAMEWORKS needs two things : + # first, it's available only for release + # (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible) + # secondly, it works only with BUILD_SHARED_LIBS enabled + if(BUILD_FRAMEWORKS) + # requirement #1 + if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") + message(WARNING "CMAKE_BUILD_TYPE should be \"Release\" when BUILD_FRAMEWORKS is TRUE") + return() + endif() + + # requirement #2 + if(NOT BUILD_SHARED_LIBS) + message(WARNING "BUILD_SHARED_LIBS should be TRUE when BUILD_FRAMEWORKS is TRUE") + return() + endif() endif() endif() @@ -95,13 +125,50 @@ if(BUILD_DOC) add_subdirectory(doc) endif() -# setup the install rules -install(DIRECTORY include - DESTINATION . - COMPONENT devel - PATTERN ".svn" EXCLUDE) +# setup the install rules +if(NOT BUILD_FRAMEWORKS) + install(DIRECTORY include + DESTINATION . + COMPONENT devel + PATTERN ".svn" EXCLUDE) +else() + # find only "root" headers + file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*") + + # in fact we have to fool cmake to copy all the headers in subdirectories + # to do that we have to add the "root" headers to the PUBLIC_HEADER + # then we can run a post script to copy the remaining headers + + # we need a dummy file in order to compile the framework + set(SFML_SOURCES ${SFML_HEADERS}) + list(APPEND SFML_SOURCES dummy.cpp) + + # create SFML.framework + add_library(SFML ${SFML_SOURCES}) + + # edit target properties + set_target_properties(SFML PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.SFML + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + PUBLIC_HEADER "${SFML_HEADERS}") + + # add the remaining headers + add_custom_command(TARGET SFML + POST_BUILD + COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* SFML.framework/Versions/2.0.0/Headers) + + # install rule + install(TARGETS SFML + FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} + COMPONENT devel) +endif() + install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${CMAKE_ROOT}/Modules) -install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) +install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) + if(WINDOWS) if(ARCH_32BITS) install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin) @@ -111,5 +178,9 @@ if(WINDOWS) install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin) endif() elseif(MACOSX) - install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION /Library/Frameworks PATTERN ".svn" EXCLUDE) + install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) + + if(INSTALL_XCODE4_TEMPLATES) + install(DIRECTORY xcode/templates/SFML DESTINATION $ENV{HOME}/Library/Developer/Xcode/Templates) + endif() endif() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index d94f4b070..0488f5249 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -138,17 +138,29 @@ macro(sfml_add_library target) target_link_libraries(${target} ${THIS_DEPENDS}) endif() + # build frameworks or dylibs + if(MACOSX AND BUILD_SHARED_LIBS) + if(BUILD_FRAMEWORKS) + # adapt target to build frameworks instead of dylibs + set_target_properties(${target} PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + else() + # adapt install directory to allow distributing dylibs in user’s frameworks + set_target_properties(${target} PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_NAME_DIR "@executable_path/../Frameworks") + endif() + endif() + # link the target to its external dependencies if(THIS_EXTERNAL_LIBS) if(BUILD_SHARED_LIBS) # in shared build, we use the regular linker commands - target_link_libraries(${target} ${THIS_EXTERNAL_LIBS}) - - if (MACOSX) - set_target_properties(${target} PROPERTIES - BUILD_WITH_INSTALL_RPATH 1 - INSTALL_NAME_DIR "@executable_path/../Frameworks") - endif() + target_link_libraries(${target} ${THIS_EXTERNAL_LIBS}) else() # in static build there's no link stage, but with some compilers it is possible to force # the generated static library to directly contain the symbols from its dependencies @@ -160,7 +172,8 @@ macro(sfml_add_library target) install(TARGETS ${target} RUNTIME DESTINATION bin COMPONENT bin LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel) + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel + FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin) endmacro() diff --git a/cmake/Modules/FindSFML.cmake b/cmake/Modules/FindSFML.cmake index dac0132ff..5e4f727bf 100644 --- a/cmake/Modules/FindSFML.cmake +++ b/cmake/Modules/FindSFML.cmake @@ -11,7 +11,12 @@ # - SFML_INCLUDE_DIR, the path where SFML headers are located (the directory containing the SFML/Config.hpp file) # # By default, the dynamic libraries of SFML will be found. To find the static ones instead, -# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...). +# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...). +# +# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless +# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details. +# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which +# are available for both release and debug modes. # # If SFML is not installed in a standard path, you can use the SFMLDIR CMake variable or environment variable # to tell CMake where SFML is. From 71277f06e53e05c5a87c326b1d8d716e5b0cf7b8 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 20 Aug 2011 12:16:08 +0200 Subject: [PATCH 06/42] Updated Cocoa example --- xcode/example/Cocoa/CocoaAppDelegate.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xcode/example/Cocoa/CocoaAppDelegate.mm b/xcode/example/Cocoa/CocoaAppDelegate.mm index 9e5026474..ce2f7b07c 100644 --- a/xcode/example/Cocoa/CocoaAppDelegate.mm +++ b/xcode/example/Cocoa/CocoaAppDelegate.mm @@ -43,7 +43,9 @@ struct SFMLmainWindow NSLog(@"Couldn't load the logo image"); } - sprite.SetImage(logo, true); + logo.SetSmooth(true); + + sprite.SetTexture(logo, true); sprite.SetOrigin(sprite.GetSize() / 2.f); sprite.Scale(0.3, 0.3); @@ -56,7 +58,7 @@ struct SFMLmainWindow sf::RenderWindow renderWindow; sf::Text text; - sf::Image logo; + sf::Texture logo; sf::Sprite sprite; sf::Color background; }; From 0580cba0cd78cd309f02eeea8b23efbd862ec7d2 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 20 Aug 2011 12:19:00 +0200 Subject: [PATCH 07/42] Xcode templates can be configured to use framework or dylibs Xocde templates now disable objective-c garbage collector --- .../ResourcePath.hpp | 0 .../ResourcePath.mm | 0 .../TemplateInfo.plist | 183 ++++++++++++------ .../cute_image.jpg | Bin .../nice_music.ogg | Bin .../sansation.ttf | Bin .../TemplateIcon.icns | Bin .../TemplateInfo.plist | 0 .../TemplateInfo.plist | 140 +++++++++----- .../cute_image.jpg | Bin .../nice_music.ogg | Bin .../sansation.ttf | Bin .../TemplateIcon.icns | Bin .../TemplateInfo.plist | 0 xcode/templates/readme.txt | 63 ++++-- 15 files changed, 265 insertions(+), 121 deletions(-) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/ResourcePath.hpp (100%) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/ResourcePath.mm (100%) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/TemplateInfo.plist (78%) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/cute_image.jpg (100%) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/nice_music.ogg (100%) rename xcode/templates/{ => SFML}/SFML Application Base.xctemplate/sansation.ttf (100%) rename xcode/templates/{ => SFML}/SFML Application.xctemplate/TemplateIcon.icns (100%) rename xcode/templates/{ => SFML}/SFML Application.xctemplate/TemplateInfo.plist (100%) rename xcode/templates/{ => SFML}/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist (82%) rename xcode/templates/{ => SFML}/SFML Command Line Tool Base.xctemplate/cute_image.jpg (100%) rename xcode/templates/{ => SFML}/SFML Command Line Tool Base.xctemplate/nice_music.ogg (100%) rename xcode/templates/{ => SFML}/SFML Command Line Tool Base.xctemplate/sansation.ttf (100%) rename xcode/templates/{ => SFML}/SFML Command Line Tool.xctemplate/TemplateIcon.icns (100%) rename xcode/templates/{ => SFML}/SFML Command Line Tool.xctemplate/TemplateInfo.plist (100%) diff --git a/xcode/templates/SFML Application Base.xctemplate/ResourcePath.hpp b/xcode/templates/SFML/SFML Application Base.xctemplate/ResourcePath.hpp similarity index 100% rename from xcode/templates/SFML Application Base.xctemplate/ResourcePath.hpp rename to xcode/templates/SFML/SFML Application Base.xctemplate/ResourcePath.hpp diff --git a/xcode/templates/SFML Application Base.xctemplate/ResourcePath.mm b/xcode/templates/SFML/SFML Application Base.xctemplate/ResourcePath.mm similarity index 100% rename from xcode/templates/SFML Application Base.xctemplate/ResourcePath.mm rename to xcode/templates/SFML/SFML Application Base.xctemplate/ResourcePath.mm diff --git a/xcode/templates/SFML Application Base.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist similarity index 78% rename from xcode/templates/SFML Application Base.xctemplate/TemplateInfo.plist rename to xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist index c6bfcd297..137453a33 100644 --- a/xcode/templates/SFML Application Base.xctemplate/TemplateInfo.plist +++ b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist @@ -42,6 +42,64 @@ subject to the following restrictions: Options + + + Identifier + libraryType + Name + Use frameworks + Description + Indicates whether frameworks should be used instead of dylibs or not. + Type + checkbox + SortOrder + 1 + Default + false + Units + + + true + + + Project + + SharedSettings + + SFML_LINK_PREFIX + $(SFML_LINK_FRAMEWORKS_PREFIX) + + SFML_LINK_SUFFIX + $(SFML_LINK_FRAMEWORKS_SUFFIX) + + HEADER_SEARCH_PATHS + $(HEADER_SEARCH_PATHS) + + + + + false + + + Project + + SharedSettings + + SFML_LINK_PREFIX + $(SFML_LINK_DYLIBS_PREFIX) + + SFML_LINK_SUFFIX + $(SFML_LINK_DYLIBS_SUFFIX) + + HEADER_SEARCH_PATHS + $(HEADER_SEARCH_PATHS) /usr/local/include/ + + + + + + + Identifier @@ -66,11 +124,8 @@ subject to the following restrictions: SharedSettings - WINDOW_RELEASE - -lsfml-window - - WINDOW_DEBUG - -lsfml-window-d + SFML_WINDOW + $(SFML_LINK_PREFIX)sfml-window$(SFML_LINK_SUFFIX) @@ -99,10 +154,7 @@ subject to the following restrictions: SharedSettings - WINDOW_RELEASE - - - WINDOW_DEBUG + SFML_WINDOW @@ -157,11 +209,8 @@ subject to the following restrictions: SharedSettings - GRAPHICS_RELEASE - -lsfml-graphics - - GRAPHICS_DEBUG - -lsfml-graphics-d + SFML_GRAPHICS + $(SFML_LINK_PREFIX)sfml-graphics$(SFML_LINK_SUFFIX) @@ -256,10 +305,7 @@ text.SetColor(sf::Color::Black); SharedSettings - GRAPHICS_RELEASE - - - GRAPHICS_DEBUG + SFML_GRAPHICS @@ -307,11 +353,8 @@ text.SetColor(sf::Color::Black); SharedSettings - AUDIO_RELEASE - -lsfml-audio - - AUDIO_DEBUG - -lsfml-audio-d + SFML_AUDIO + $(SFML_LINK_PREFIX)sfml-audio$(SFML_LINK_SUFFIX) @@ -354,10 +397,7 @@ music.Play(); SharedSettings - AUDIO_RELEASE - - - AUDIO_DEBUG + SFML_AUDIO @@ -402,11 +442,8 @@ music.Play(); SharedSettings - NETWORK_RELEASE - -lsfml-network - - NETWORK_DEBUG - -lsfml-network-d + SFML_NETWORK + $(SFML_LINK_PREFIX)sfml-network$(SFML_LINK_SUFFIX) @@ -427,10 +464,7 @@ music.Play(); SharedSettings - NETWORK_RELEASE - - - NETWORK_DEBUG + SFML_NETWORK @@ -560,13 +594,23 @@ while (window.IsOpened()) PRODUCT_NAME $(TARGET_NAME) - SYSTEM_RELEASE - -lsfml-system - SYSTEM_DEBUG - -lsfml-system-d - - HEADER_SEARCH_PATHS - $(HEADER_SEARCH_PATHS) /usr/local/include/ + SFML_LINK_DYLIBS_PREFIX + -l + + SFML_LINK_FRAMEWORKS_PREFIX + -framework + + SFML_SYSTEM + $(SFML_LINK_PREFIX)sfml-system$(SFML_LINK_SUFFIX) + + SFML_LINK_FRAMEWORKS_SUFFIX + + + CLANG_ENABLE_OBJC_ARC + + + GCC_ENABLE_OBJC_GC + unsupported Configurations @@ -574,16 +618,22 @@ while (window.IsOpened()) Debug + SFML_LINK_DYLIBS_SUFFIX + -d + OTHER_LDFLAGS -$(OTHER_LDFLAGS) $(SYSTEM_DEBUG) $(WINDOW_DEBUG) $(GRAPHICS_DEBUG) $(AUDIO_DEBUG) $(NETWORK_DEBUG) + $(OTHER_LDFLAGS) $(SFML_SYSTEM) $(SFML_WINDOW) $(SFML_GRAPHICS) $(SFML_AUDIO) $(SFML_NETWORK) Release + SFML_LINK_DYLIBS_SUFFIX + + OTHER_LDFLAGS -$(OTHER_LDFLAGS) $(SYSTEM_RELEASE) $(WINDOW_RELEASE) $(GRAPHICS_RELEASE) $(AUDIO_RELEASE) $(NETWORK_RELEASE) + $(OTHER_LDFLAGS) $(SFML_SYSTEM) $(SFML_WINDOW) $(SFML_GRAPHICS) $(SFML_AUDIO) $(SFML_NETWORK) @@ -606,8 +656,16 @@ while (window.IsOpened()) /bin/sh ShellScript - # This shell script simply copies required sfml dylibs into the application bundle frameworks folder -# NB : this script assumes that if moduleX is required in release mode then it is also required in debug mode. + # This shell script simply copies required sfml dylibs/frameworks into the application bundle frameworks folder. +# If you're using static libraries (which is not recommended) you should remove this script from your project. + +# Are we building a project that uses framework or dylibs ? +if [ $SFML_LINK_PREFIX = $SFML_LINK_FRAMEWORKS_PREFIX ] +then + frameworks=1 +else + frameworks=0 +fi require () # $1 is a SFML module like 'system' or 'audio' { @@ -616,45 +674,58 @@ require () # $1 is a SFML module like 'system' or 'audio' echo "no parameter! ERROR!" exit else - if [ $CONFIGURATION = "Debug" ] + # clean potentially old stuff + rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1.2.dylib + rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1-d.2.dylib + rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sfml-$1.framework + + # copy SFML libraries + if [ $frameworks ] + then + ditto /Library/Frameworks/sfml-$1.framework $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sfml-$1.framework + elif [ $CONFIGURATION = "Debug" ] then - rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1.2.dylib ditto /usr/local/lib/libsfml-$1-d.2.dylib $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1-d.2.dylib else - rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1-d.2.dylib ditto /usr/local/lib/libsfml-$1.2.dylib $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1.2.dylib fi + + if [ $1 = "audio" ] + then + # copy sndfile framework too + ditto /Library/Frameworks/sndfile.framework $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sndfile.framework + fi fi } -if [ -n "$SYSTEM_RELEASE" ] +if [ -n "$SFML_SYSTEM" ] then require "system" fi -if [ -n "$AUDIO_RELEASE" ] +if [ -n "$SFML_AUDIO" ] then require "audio" fi -if [ -n "$NETWORK_RELEASE" ] +if [ -n "$SFML_NETWORK" ] then require "network" fi -if [ -n "$WINDOW_RELEASE" ] +if [ -n "$SFML_WINDOW" ] then require "window" fi -if [ -n "$GRAPHICS_RELEASE" ] +if [ -n "$SFML_GRAPHICS" ] then require "graphics" fi RunOnlyForDeploymentPostprocessing - NO + YES diff --git a/xcode/templates/SFML Application Base.xctemplate/cute_image.jpg b/xcode/templates/SFML/SFML Application Base.xctemplate/cute_image.jpg similarity index 100% rename from xcode/templates/SFML Application Base.xctemplate/cute_image.jpg rename to xcode/templates/SFML/SFML Application Base.xctemplate/cute_image.jpg diff --git a/xcode/templates/SFML Application Base.xctemplate/nice_music.ogg b/xcode/templates/SFML/SFML Application Base.xctemplate/nice_music.ogg similarity index 100% rename from xcode/templates/SFML Application Base.xctemplate/nice_music.ogg rename to xcode/templates/SFML/SFML Application Base.xctemplate/nice_music.ogg diff --git a/xcode/templates/SFML Application Base.xctemplate/sansation.ttf b/xcode/templates/SFML/SFML Application Base.xctemplate/sansation.ttf similarity index 100% rename from xcode/templates/SFML Application Base.xctemplate/sansation.ttf rename to xcode/templates/SFML/SFML Application Base.xctemplate/sansation.ttf diff --git a/xcode/templates/SFML Application.xctemplate/TemplateIcon.icns b/xcode/templates/SFML/SFML Application.xctemplate/TemplateIcon.icns similarity index 100% rename from xcode/templates/SFML Application.xctemplate/TemplateIcon.icns rename to xcode/templates/SFML/SFML Application.xctemplate/TemplateIcon.icns diff --git a/xcode/templates/SFML Application.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Application.xctemplate/TemplateInfo.plist similarity index 100% rename from xcode/templates/SFML Application.xctemplate/TemplateInfo.plist rename to xcode/templates/SFML/SFML Application.xctemplate/TemplateInfo.plist diff --git a/xcode/templates/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist similarity index 82% rename from xcode/templates/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist rename to xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist index 428e6d18c..8746f3bd0 100644 --- a/xcode/templates/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist +++ b/xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/TemplateInfo.plist @@ -42,6 +42,64 @@ subject to the following restrictions: Options + + + Identifier + libraryType + Name + Use frameworks + Description + Indicates whether frameworks should be used instead of dylibs or not. + Type + checkbox + SortOrder + 1 + Default + false + Units + + + true + + + Project + + SharedSettings + + SFML_LINK_PREFIX + $(SFML_LINK_FRAMEWORKS_PREFIX) + + SFML_LINK_SUFFIX + $(SFML_LINK_FRAMEWORKS_SUFFIX) + + HEADER_SEARCH_PATHS + $(HEADER_SEARCH_PATHS) + + + + + false + + + Project + + SharedSettings + + SFML_LINK_PREFIX + $(SFML_LINK_DYLIBS_PREFIX) + + SFML_LINK_SUFFIX + $(SFML_LINK_DYLIBS_SUFFIX) + + HEADER_SEARCH_PATHS + $(HEADER_SEARCH_PATHS) /usr/local/include/ + + + + + + + Identifier @@ -66,11 +124,8 @@ subject to the following restrictions: SharedSettings - WINDOW_RELEASE - -lsfml-window - - WINDOW_DEBUG - -lsfml-window-d + SFML_WINDOW + $(SFML_LINK_PREFIX)sfml-window$(SFML_LINK_SUFFIX) @@ -99,10 +154,7 @@ subject to the following restrictions: SharedSettings - WINDOW_RELEASE - - - WINDOW_DEBUG + SFML_WINDOW @@ -157,11 +209,8 @@ subject to the following restrictions: SharedSettings - GRAPHICS_RELEASE - -lsfml-graphics - - GRAPHICS_DEBUG - -lsfml-graphics-d + SFML_GRAPHICS + $(SFML_LINK_PREFIX)sfml-graphics$(SFML_LINK_SUFFIX) @@ -256,10 +305,7 @@ text.SetColor(sf::Color::Black); SharedSettings - GRAPHICS_RELEASE - - - GRAPHICS_DEBUG + SFML_GRAPHICS @@ -307,11 +353,8 @@ text.SetColor(sf::Color::Black); SharedSettings - AUDIO_RELEASE - -lsfml-audio - - AUDIO_DEBUG - -lsfml-audio-d + SFML_AUDIO + $(SFML_LINK_PREFIX)sfml-audio$(SFML_LINK_SUFFIX) @@ -354,10 +397,7 @@ music.Play(); SharedSettings - AUDIO_RELEASE - - - AUDIO_DEBUG + SFML_AUDIO @@ -399,11 +439,8 @@ music.Play(); SharedSettings - NETWORK_RELEASE - -lsfml-network - - NETWORK_DEBUG - -lsfml-network-d + SFML_NETWORK + $(SFML_LINK_PREFIX)sfml-network$(SFML_LINK_SUFFIX) @@ -424,10 +461,7 @@ music.Play(); SharedSettings - NETWORK_RELEASE - - - NETWORK_DEBUG + SFML_NETWORK @@ -554,13 +588,23 @@ while (window.IsOpened()) PRODUCT_NAME $(TARGET_NAME) - SYSTEM_RELEASE - -lsfml-system - SYSTEM_DEBUG - -lsfml-system-d - - HEADER_SEARCH_PATHS - $(HEADER_SEARCH_PATHS) /usr/local/include/ + SFML_LINK_DYLIBS_PREFIX + -l + + SFML_LINK_FRAMEWORKS_PREFIX + -framework + + SFML_SYSTEM + $(SFML_LINK_PREFIX)sfml-system$(SFML_LINK_SUFFIX) + + SFML_LINK_FRAMEWORKS_SUFFIX + + + CLANG_ENABLE_OBJC_ARC + + + GCC_ENABLE_OBJC_GC + unsupported Configurations @@ -568,16 +612,22 @@ while (window.IsOpened()) Debug + SFML_LINK_DYLIBS_SUFFIX + -d + OTHER_LDFLAGS -$(OTHER_LDFLAGS) $(SYSTEM_DEBUG) $(WINDOW_DEBUG) $(GRAPHICS_DEBUG) $(AUDIO_DEBUG) $(NETWORK_DEBUG) + $(OTHER_LDFLAGS) $(SFML_SYSTEM) $(SFML_WINDOW) $(SFML_GRAPHICS) $(SFML_AUDIO) $(SFML_NETWORK) Release + SFML_LINK_DYLIBS_SUFFIX + + OTHER_LDFLAGS -$(OTHER_LDFLAGS) $(SYSTEM_RELEASE) $(WINDOW_RELEASE) $(GRAPHICS_RELEASE) $(AUDIO_RELEASE) $(NETWORK_RELEASE) + $(OTHER_LDFLAGS) $(SFML_SYSTEM) $(SFML_WINDOW) $(SFML_GRAPHICS) $(SFML_AUDIO) $(SFML_NETWORK) diff --git a/xcode/templates/SFML Command Line Tool Base.xctemplate/cute_image.jpg b/xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/cute_image.jpg similarity index 100% rename from xcode/templates/SFML Command Line Tool Base.xctemplate/cute_image.jpg rename to xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/cute_image.jpg diff --git a/xcode/templates/SFML Command Line Tool Base.xctemplate/nice_music.ogg b/xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/nice_music.ogg similarity index 100% rename from xcode/templates/SFML Command Line Tool Base.xctemplate/nice_music.ogg rename to xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/nice_music.ogg diff --git a/xcode/templates/SFML Command Line Tool Base.xctemplate/sansation.ttf b/xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/sansation.ttf similarity index 100% rename from xcode/templates/SFML Command Line Tool Base.xctemplate/sansation.ttf rename to xcode/templates/SFML/SFML Command Line Tool Base.xctemplate/sansation.ttf diff --git a/xcode/templates/SFML Command Line Tool.xctemplate/TemplateIcon.icns b/xcode/templates/SFML/SFML Command Line Tool.xctemplate/TemplateIcon.icns similarity index 100% rename from xcode/templates/SFML Command Line Tool.xctemplate/TemplateIcon.icns rename to xcode/templates/SFML/SFML Command Line Tool.xctemplate/TemplateIcon.icns diff --git a/xcode/templates/SFML Command Line Tool.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Command Line Tool.xctemplate/TemplateInfo.plist similarity index 100% rename from xcode/templates/SFML Command Line Tool.xctemplate/TemplateInfo.plist rename to xcode/templates/SFML/SFML Command Line Tool.xctemplate/TemplateInfo.plist diff --git a/xcode/templates/readme.txt b/xcode/templates/readme.txt index ce2d4b30d..ee41b9d68 100644 --- a/xcode/templates/readme.txt +++ b/xcode/templates/readme.txt @@ -1,43 +1,66 @@ XCODE 4 TEMPLATES ================= -These are templates to create easily a new project in Xcode 4. +These are templates to create easily a new SFML project in Xcode 4. Features -------- * You can choose between command line tool or bundle application. - * You can select or not each module of SFML you'll use into your project. - * A basic example is inserted automatically into your project's code. + * You can choose between using SFML libraries as dylibs or frameworks. + * You can add independently each SFML module you'll use into your project. + * A basic example is included automatically into your project's code. Install ------- -Copy the four folders into ~/Library/Developer/Xcode/Templates folder (you might need to create it first). +If you are building SFML from sources you can set CMake's INSTALL_XCODE4_TEMPLATES variable to TRUE to install the templates automatically. Otherwise proceed as follow : + 1. Make sure "~/Library/Developer/Xcode/Templates/" folder exists; + 2. Copy "SFML" folder into the above folder. Usage ----- To use these templates follow these steps : - * open Xcode 4, - * select «create a new Xcode project» from the «Welcome to Xcode» window or select menu File > New > New Project, - * select «Templates» under «Mac OS X», - * then select either «SFML Application» or «SFML Command Line Tool», - * fill in the requested information and you're done. + 1. open Xcode 4, + 2. select "create a new Xcode project" from the "Welcome to Xcode" window or select menus File > New > New Project, + 3. select "SFML" subsection under "Mac OS X", + 4. then select either "SFML Application" or "SFML Command Line Tool", + 5. fill in the requested information and you're done. -Note ----- +Question & Answer +----------------- -If you wish to add/remove any module of SFML from your project without rebuilding a new one follow these steps : + * I would like to add/remove a module of SFML from my current project without creating a new one. How can I do that ? - * select your project from the project navigator panel (cmd+1), - * select your project's target on the main area, - * go to the «Build Settings» tab, - * go down to the bottom, - * edit any MODULEX_CONFIG variable (e.g. AUDIO_DEBUG, NETWORK_RELEASE) you want to. + 1. select your project from the project navigator panel, + 2. select your project's target on the main area, + 3. go to the "Build Settings" tab, + 4. go down to the bottom, + 5. set SFML_XXX variable, where XXX is the name of the module to add/remove to "$(SFML_LINK_PREFIX)sfml-XXX$(SFML_LINK_SUFFIX)" to add it or to "" (nothing) to remove it. -Examples : - * to disable the audio module simply erase the content of AUDIO_DEBUG and AUDIO_RELEASE. - * to add the network module set NETWORK_DEBUG to '-lsfml-network-d' and NETWORK_RELEASE to '-lsfml-network'. + * I changed my mind and would like to switch from dylibs to frameworks or vice versa. How can I do that ? + + 1. select your project from the project navigator panel, + 2. select your project's target on the main area, + 3. go to the "Build Settings" tab, + 4. go down to the bottom, + 5. update SFML_LINK_PREFIX and SFML_LINK_SUFFIX as follow : + * if you want to use frameworks, then + 1. set SFML_LINK_PREFIX to "$(SFML_LINK_FRAMEWORKS_PREFIX)", + 2. set SFML_LINK_SUFFIX to "$(SFML_LINK_FRAMEWORKS_SUFFIX)" + * if you want to use dylibs, then + 1. set SFML_LINK_PREFIX to "$(SFML_LINK_DYLIBS_PREFIX)", + 2. set SFML_LINK_SUFFIX to "$(SFML_LINK_DYLIBS_SUFFIX)" + + + * I want to use the static version of SFML. Is it possible ? + + Short answer : Don't do that! + + We strongly recommend you to use either dylibs or frameworks on Mac OS X. Please refer to Apple documentation for information about static vs shared libraries debate. + + If you really need/want to use static libraries proceed as follow. First, set your project to use dylibs (see above Q & A). Then set SFML_LINK_DYLIBS_SUFFIX to "-s-d" in debug mode and to "-s" in release mode. Finally, remove the script automatically generated by the application template (see Build Phases tab). + From 7d919f4344e127102eedcf7e2b47931439f59394 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sun, 21 Aug 2011 20:15:55 +0200 Subject: [PATCH 08/42] Fixed frameworks compilation --- CMakeLists.txt | 2 +- src/dummy.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/dummy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cfe2e691..ec6efe84e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ else() # we need a dummy file in order to compile the framework set(SFML_SOURCES ${SFML_HEADERS}) - list(APPEND SFML_SOURCES dummy.cpp) + list(APPEND SFML_SOURCES src/dummy.cpp) # create SFML.framework add_library(SFML ${SFML_SOURCES}) diff --git a/src/dummy.cpp b/src/dummy.cpp new file mode 100644 index 000000000..bdce26935 --- /dev/null +++ b/src/dummy.cpp @@ -0,0 +1,28 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2011 Marco Antognini (antognini.marco@gmail.com), +// 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. +// +//////////////////////////////////////////////////////////// + +// This file is intentionally empty. Its only purpose it to be +// used to produce a valid SFML.framework (at least one +// compilation unit is required) on Mac OS X. From b9b38887884fa9ad0b87e648dc16e27cad84d609 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 21 Aug 2011 21:13:23 +0200 Subject: [PATCH 09/42] Minor fix in comments --- include/SFML/Graphics/Image.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 96e867f5f..ff5830ed4 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -120,8 +120,6 @@ public : /// The supported image formats are bmp, png, tga, jpg, gif, /// psd, hdr and pic. Some format options are not supported, /// like progressive jpeg. - /// The maximum size for an image depends on the graphics - /// driver and can be retrieve with the GetMaximumSize function. /// If this function fails, the image is left unchanged. /// /// \param stream Source stream to read from From 78afc38501ed4827d3ff7d90cb0fd5e50b476fe9 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 26 Aug 2011 18:42:54 +0200 Subject: [PATCH 10/42] Minor fixes to the doc --- include/SFML/Network/Ftp.hpp | 2 +- include/SFML/Network/Http.hpp | 2 +- include/SFML/Network/Socket.hpp | 2 +- include/SFML/Network/TcpSocket.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index ad0905a72..e4a81d79e 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -369,7 +369,7 @@ public : Response ChangeDirectory(const std::string& directory); //////////////////////////////////////////////////////////// - /// Go to the parent directory of the current one + /// \brief Go to the parent directory of the current one /// /// \return Server response to the request /// diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp index 93c3ed55d..02f0d2573 100644 --- a/include/SFML/Network/Http.hpp +++ b/include/SFML/Network/Http.hpp @@ -117,7 +117,7 @@ public : void SetUri(const std::string& uri); //////////////////////////////////////////////////////////// - /// \brief Set the HTTP version fo the request + /// \brief Set the HTTP version for the request /// /// The HTTP version is 1.0 by default. /// diff --git a/include/SFML/Network/Socket.hpp b/include/SFML/Network/Socket.hpp index fefd10f4e..980252179 100644 --- a/include/SFML/Network/Socket.hpp +++ b/include/SFML/Network/Socket.hpp @@ -94,7 +94,7 @@ public : void SetBlocking(bool blocking); //////////////////////////////////////////////////////////// - /// \brief Tell whether the socket is blocking or non-blocking mode + /// \brief Tell whether the socket is in blocking or non-blocking mode /// /// \return True if the socket is blocking, false otherwise /// diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp index 45fafa721..94cc87535 100644 --- a/include/SFML/Network/TcpSocket.hpp +++ b/include/SFML/Network/TcpSocket.hpp @@ -109,7 +109,7 @@ public : Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Uint32 timeout = 0); //////////////////////////////////////////////////////////// - /// \brief Disconnect the connect from its remote peer + /// \brief Disconnect the socket from its remote peer /// /// This function gracefully closes the connection. If the /// socket is not connected, this function has no effect. From 18cebde155f62d6ffa39bf9f28e2b944807fa1b6 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 2 Sep 2011 19:26:18 +0200 Subject: [PATCH 11/42] Minor fix in comments --- include/SFML/Audio/SoundBuffer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index 07a717f02..31c291945 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -200,7 +200,7 @@ public : //////////////////////////////////////////////////////////// /// \brief Get the number of channels used by the sound /// - /// If the sound is mono then the number ofchannels will + /// If the sound is mono then the number of channels will /// be 1, 2 for stereo, etc. /// /// \return Number of channels From 7f390367f186db5fbe14c48c05976939cc3150de Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 2 Sep 2011 19:26:49 +0200 Subject: [PATCH 12/42] OpenGL.hpp now includes windows.h only with VC++ --- include/SFML/OpenGL.hpp | 6 +++++- src/SFML/Window/Win32/WglContext.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/SFML/OpenGL.hpp b/include/SFML/OpenGL.hpp index f325dced8..20c8c9579 100644 --- a/include/SFML/OpenGL.hpp +++ b/include/SFML/OpenGL.hpp @@ -38,7 +38,11 @@ //////////////////////////////////////////////////////////// #if defined(SFML_SYSTEM_WINDOWS) - #include + // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them + #ifdef _MSC_VER + #include + #endif + #include #include diff --git a/src/SFML/Window/Win32/WglContext.hpp b/src/SFML/Window/Win32/WglContext.hpp index 7b315e362..7d7781f20 100644 --- a/src/SFML/Window/Win32/WglContext.hpp +++ b/src/SFML/Window/Win32/WglContext.hpp @@ -30,6 +30,7 @@ //////////////////////////////////////////////////////////// #include #include +#include namespace sf From c51e22cb5263b146cdffa49b08e02dad6a7173ee Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 2 Sep 2011 23:03:46 +0200 Subject: [PATCH 13/42] Fixed sf::Mouse::IsButtonPressed and sf::Keyboard::IsKeyPressed incorrectly returning true on Windows --- src/SFML/Window/Win32/InputImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/Win32/InputImpl.cpp b/src/SFML/Window/Win32/InputImpl.cpp index 8122e581a..c3cf5c658 100644 --- a/src/SFML/Window/Win32/InputImpl.cpp +++ b/src/SFML/Window/Win32/InputImpl.cpp @@ -145,7 +145,7 @@ bool InputImpl::IsKeyPressed(Keyboard::Key key) case Keyboard::Pause: vkey = VK_PAUSE; break; } - return GetAsyncKeyState(vkey) != 0; + return (GetAsyncKeyState(vkey) & 0x8000) != 0; } @@ -162,7 +162,7 @@ bool InputImpl::IsMouseButtonPressed(Mouse::Button button) case Mouse::XButton2: vkey = VK_XBUTTON2; break; } - return GetAsyncKeyState(vkey) != 0; + return (GetAsyncKeyState(vkey) & 0x8000) != 0; } From 9205942917e76a5d9b552ed7c878a00226d5cd18 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 3 Sep 2011 10:18:09 +0200 Subject: [PATCH 14/42] Minor fix in API documentation --- include/SFML/Window/Event.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp index e294cc0e2..2b6d56f63 100644 --- a/include/SFML/Window/Event.hpp +++ b/include/SFML/Window/Event.hpp @@ -223,7 +223,7 @@ public : /// window.Close(); /// /// // The escape key was pressed -/// if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape)) +/// if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape)) /// window.Close(); /// /// // The window was resized From d6a40cf06202de4d05fb83e08844ebec6a6b8b43 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 4 Sep 2011 14:46:36 +0200 Subject: [PATCH 15/42] Fixed IpAddress::GetLocalAddress() (was incorrectly returning 127.0.0.1) --- src/SFML/Network/IpAddress.cpp | 4 ++-- src/SFML/Network/Unix/SocketImpl.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index 73cf6a1e2..ae3d90cb9 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -139,13 +139,13 @@ IpAddress IpAddress::GetLocalAddress() return localAddress; // Connect the socket to localhost on any port - sockaddr_in address = priv::SocketImpl::CreateAddress(INADDR_LOOPBACK, 0); + sockaddr_in address = priv::SocketImpl::CreateAddress(ntohl(INADDR_LOOPBACK), 0); if (connect(sock, reinterpret_cast(&address), sizeof(address)) == -1) { priv::SocketImpl::Close(sock); return localAddress; } - + // Get the local address of the socket connection priv::SocketImpl::AddrLength size = sizeof(address); if (getsockname(sock, reinterpret_cast(&address), &size) == -1) diff --git a/src/SFML/Network/Unix/SocketImpl.cpp b/src/SFML/Network/Unix/SocketImpl.cpp index bf6c86a31..1cf503240 100644 --- a/src/SFML/Network/Unix/SocketImpl.cpp +++ b/src/SFML/Network/Unix/SocketImpl.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace sf @@ -39,7 +39,7 @@ namespace priv sockaddr_in SocketImpl::CreateAddress(unsigned long address, unsigned short port) { sockaddr_in addr; - memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); + std::memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); addr.sin_addr.s_addr = htonl(address); addr.sin_family = AF_INET; addr.sin_port = htons(port); From 32563cdc6f08ecf869dd0de1043daace9ec4afeb Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Tue, 30 Aug 2011 18:27:40 +0200 Subject: [PATCH 16/42] Improved SFML integration with Cocoa --- src/SFML/Window/OSX/AutoreleasePoolWrapper.mm | 8 ++++---- src/SFML/Window/OSX/HIDJoystickManager.cpp | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm index 854f44ffb..4a2a6cff5 100644 --- a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm +++ b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm @@ -109,12 +109,12 @@ PoolWrapper::~PoolWrapper() #ifdef SFML_DEBUG if (count < 0) { sf::Err() << "~PoolWrapper : count is less than zero! " - "You called ReleasePool from a thread too many times." - << std::endl; + "You called ReleasePool from a thread too many times." + << std::endl; } else if (count > 0) { sf::Err() << "~PoolWrapper : count is greater than zero! " - "You called ReleasePool from a thread to few times." - << std::endl; + "You called ReleasePool from a thread to few times." + << std::endl; } else { // count == 0 sf::Err() << "~PoolWrapper is HAPPY!" << std::endl; } diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp index aaab48424..fcb97309c 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.cpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp @@ -29,6 +29,17 @@ #include #include +//////////////////////////////////////////////////////////// +// Private data +//////////////////////////////////////////////////////////// +namespace +{ + // Using a custom run loop mode solve some issues that appears when SFML + // is used with Cocoa. + CFStringRef const runLoopMode = CFSTR("SFML_RUN_LOOP_MODE"); +} + + namespace sf { namespace priv @@ -74,7 +85,7 @@ HIDJoystickManager::HIDJoystickManager() IOHIDManagerScheduleWithRunLoop(myHIDManager, CFRunLoopGetCurrent(), - kCFRunLoopDefaultMode); + runLoopMode); IOHIDManagerOpen(myHIDManager, kIOHIDOptionsTypeNone); } @@ -85,7 +96,7 @@ HIDJoystickManager::~HIDJoystickManager() { IOHIDManagerUnscheduleFromRunLoop(myHIDManager, CFRunLoopGetCurrent(), - kCFRunLoopDefaultMode); + runLoopMode); IOHIDManagerRegisterDeviceMatchingCallback(myHIDManager, NULL, 0); IOHIDManagerRegisterDeviceRemovalCallback(myHIDManager, NULL, 0); @@ -100,7 +111,7 @@ void HIDJoystickManager::Update() SInt32 status = kCFRunLoopRunHandledSource; while (status == kCFRunLoopRunHandledSource) { - status = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); + status = CFRunLoopRunInMode(runLoopMode, 0, true); } } From 6c0535db4529e9a68a5b13a5ba01d4758c4b3729 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Thu, 1 Sep 2011 22:01:54 +0200 Subject: [PATCH 17/42] Fixed OSX/ShowMouseCursor --- src/SFML/Window/OSX/WindowImplCocoa.hpp | 3 ++- src/SFML/Window/OSX/WindowImplCocoa.mm | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index cadf97c2e..7c3895159 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -311,7 +311,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - WindowImplDelegateRef myDelegate; ///< Implementation in Obj-C. + WindowImplDelegateRef myDelegate; ///< Implementation in Obj-C. + bool myShowCursor; ///< Is the cursor displayed or hidden ? }; } // namespace priv diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 84c4ae827..7697e2eb0 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -44,6 +44,7 @@ namespace priv //////////////////////////////////////////////////////////// WindowImplCocoa::WindowImplCocoa(WindowHandle handle) +: myShowCursor(true) { // Ask for a pool. RetainPool(); @@ -91,6 +92,7 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle) WindowImplCocoa::WindowImplCocoa(VideoMode mode, const std::string& title, unsigned long style) +: myShowCursor(true) { // Transform the app process. SetUpProcess(); @@ -183,6 +185,10 @@ void WindowImplCocoa::WindowResized(unsigned int width, unsigned int height) //////////////////////////////////////////////////////////// void WindowImplCocoa::WindowLostFocus(void) { + if (!myShowCursor) { + [myDelegate showMouseCursor]; // Make sur the cursor is visible + } + Event event; event.Type = Event::LostFocus; @@ -193,6 +199,10 @@ void WindowImplCocoa::WindowLostFocus(void) //////////////////////////////////////////////////////////// void WindowImplCocoa::WindowGainedFocus(void) { + if (!myShowCursor) { + [myDelegate hideMouseCursor]; // Restore user's setting + } + Event event; event.Type = Event::GainedFocus; @@ -255,6 +265,10 @@ void WindowImplCocoa::MouseWheelScrolledAt(float delta, int x, int y) //////////////////////////////////////////////////////////// void WindowImplCocoa::MouseMovedIn(void) { + if (!myShowCursor) { + [myDelegate hideMouseCursor]; // Restore user's setting + } + Event event; event.Type = Event::MouseEntered; @@ -264,6 +278,10 @@ void WindowImplCocoa::MouseMovedIn(void) //////////////////////////////////////////////////////////// void WindowImplCocoa::MouseMovedOut(void) { + if (!myShowCursor) { + [myDelegate showMouseCursor]; // Make sur the cursor is visible + } + Event event; event.Type = Event::MouseLeft; @@ -330,7 +348,9 @@ WindowHandle WindowImplCocoa::GetSystemHandle() const //////////////////////////////////////////////////////////// void WindowImplCocoa::ShowMouseCursor(bool show) { - if (show) { + myShowCursor = show; + + if (myShowCursor) { [myDelegate showMouseCursor]; } else { [myDelegate hideMouseCursor]; From 0063eef5207537adeebe591b3e211527b1db77bc Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Fri, 2 Sep 2011 12:35:25 +0200 Subject: [PATCH 18/42] Fixed Xcode templates script --- .../TemplateInfo.plist | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist index 137453a33..a9bb42bc2 100644 --- a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist +++ b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist @@ -669,31 +669,33 @@ fi require () # $1 is a SFML module like 'system' or 'audio' { + dest=$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Contents/Frameworks + if [ -z $1 ] then echo "no parameter! ERROR!" exit else # clean potentially old stuff - rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1.2.dylib - rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1-d.2.dylib - rm -f $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sfml-$1.framework + rm -f $dest/libsfml-$1.2.dylib + rm -f $dest/libsfml-$1-d.2.dylib + rm -f $dest/sfml-$1.framework # copy SFML libraries if [ $frameworks ] then - ditto /Library/Frameworks/sfml-$1.framework $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sfml-$1.framework + ditto /Library/Frameworks/sfml-$1.framework $dest/sfml-$1.framework elif [ $CONFIGURATION = "Debug" ] then - ditto /usr/local/lib/libsfml-$1-d.2.dylib $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1-d.2.dylib + ditto /usr/local/lib/libsfml-$1-d.2.dylib $dest/libsfml-$1-d.2.dylib else - ditto /usr/local/lib/libsfml-$1.2.dylib $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/libsfml-$1.2.dylib + ditto /usr/local/lib/libsfml-$1.2.dylib $dest/libsfml-$1.2.dylib fi if [ $1 = "audio" ] then # copy sndfile framework too - ditto /Library/Frameworks/sndfile.framework $BUILT_PRODUCTS_DIR/test.app/Contents/Frameworks/sndfile.framework + ditto /Library/Frameworks/sndfile.framework $dest/sndfile.framework fi fi } From b834787946778d5bb6ea1af3a94be3d4d788e1ba Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 3 Sep 2011 13:43:43 +0200 Subject: [PATCH 19/42] Removed dummy.cpp --- CMakeLists.txt | 5 ++++- src/dummy.cpp | 28 ---------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 src/dummy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6efe84e..4375b03b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,8 +140,11 @@ else() # then we can run a post script to copy the remaining headers # we need a dummy file in order to compile the framework + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp + COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp) + set(SFML_SOURCES ${SFML_HEADERS}) - list(APPEND SFML_SOURCES src/dummy.cpp) + list(APPEND SFML_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp) # create SFML.framework add_library(SFML ${SFML_SOURCES}) diff --git a/src/dummy.cpp b/src/dummy.cpp deleted file mode 100644 index bdce26935..000000000 --- a/src/dummy.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2011 Marco Antognini (antognini.marco@gmail.com), -// 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. -// -//////////////////////////////////////////////////////////// - -// This file is intentionally empty. Its only purpose it to be -// used to produce a valid SFML.framework (at least one -// compilation unit is required) on Mac OS X. From 95a01263713bf9f29fc62744f6e7a8a793061f80 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 3 Sep 2011 15:44:16 +0200 Subject: [PATCH 20/42] Improved cmake : autodetect available OS X SDK --- CMakeLists.txt | 51 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4375b03b3..117af1ace 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,6 @@ set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to # Mac OS X specific options if(MACOSX) - if(MACOSX_VERSION GREATER 5) - # add an option to build against 10.5 SDK if current OS X version is greater than 10.5 - set(BUILD_LEOPARD FALSE CACHE BOOL "TRUE to build SFML for OS X 10.5, FALSE to compile with default SDK") - endif() - # add an option to build frameworks instead of dylibs (release only) set(BUILD_FRAMEWORKS FALSE CACHE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS") @@ -78,23 +73,39 @@ set(CMAKE_SKIP_BUILD_RPATH TRUE) # Setup Mac OS X stuff if(MACOSX) - # multi arch support - if(NOT CMAKE_OSX_ARCHITECTURES) - # Default : i386 and x86_64 - set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") - else() - # We got some conflict with custom user settings ; let him know his on his own. - message("CMAKE_OSX_ARCHITECTURES is not empty.") - message("You're on your own : I won't change your settings.") + # multi arch support - by default : i386 and x86_64 + if(NOT CMAKE_OSX_ARCHITECTURES) + set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE) endif() - # multi SDK support - if(BUILD_LEOPARD) - # Use 10.5 SDK : override default value - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk") - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5") - else() - # Default SDK, let either the user or CMake decide which one to use. + # multi SDK support - by default we choose the older SDK available starting by 10.5 SDK + if(NOT OSX_CONFIG_HAS_BEEN_RUN_BEFORE) + if(EXISTS /Developer/SDKs/MacOSX10.5.sdk) + # target 10.5 system + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk" + CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value." + FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" + CACHE STRING "Minimum OS X version to target for deployment (at runtime); ewer APIs weak linked." + FORCE) + elseif(EXISTS /Developer/SDKs/MacOSX10.6.sdk) + # target 10.6 system + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk" + CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value." + FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" + CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked." + FORCE) + else() + # use default SDK. + endif() + + # note : we use OSX_CONFIG_HAS_BEEN_RUN_BEFORE to be able to let the user set his/her custom settings + # so we don't always have to FORCE the value of CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT + set(OSX_CONFIG_HAS_BEEN_RUN_BEFORE TRUE + CACHE BOOL "Don't edit this value; you should instead empty your cache." + FORCE) + mark_as_advanced(OSX_CONFIG_HAS_BEEN_RUN_BEFORE) endif() # BUILD_FRAMEWORKS needs two things : From ecaafa9a18dda57dc99d88caad16ae14be40f043 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Mon, 5 Sep 2011 00:43:06 +0200 Subject: [PATCH 21/42] Fixed sf::Window::Create on OS X (Closes #86) --- src/SFML/Window/OSX/AutoreleasePoolWrapper.h | 8 +++++ src/SFML/Window/OSX/AutoreleasePoolWrapper.mm | 34 +++++++++++++++++-- src/SFML/Window/OSX/SFContext.mm | 10 +++--- src/SFML/Window/OSX/WindowImplCocoa.mm | 6 +++- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/SFML/Window/OSX/AutoreleasePoolWrapper.h b/src/SFML/Window/OSX/AutoreleasePoolWrapper.h index 47197877f..cce8ea0d3 100644 --- a/src/SFML/Window/OSX/AutoreleasePoolWrapper.h +++ b/src/SFML/Window/OSX/AutoreleasePoolWrapper.h @@ -41,3 +41,11 @@ void RetainPool(void); //////////////////////////////////////////////////////////// void ReleasePool(void); +//////////////////////////////////////////////////////////// +/// \brief Drain the pool. +/// +/// ReleasePool must be called at least once before DrainPool. +/// +//////////////////////////////////////////////////////////// +void DrainPool(); + diff --git a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm index 4a2a6cff5..3bf375412 100644 --- a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm +++ b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm @@ -84,6 +84,12 @@ public : //////////////////////////////////////////////////////////// void Release(); + //////////////////////////////////////////////////////////// + /// \brief Drain the pool + /// + //////////////////////////////////////////////////////////// + void Drain(); + private: //////////////////////////////////////////////////////////// @@ -149,8 +155,7 @@ void PoolWrapper::Release() // Drain pool if required. if (count == 0) { - [pool drain]; - pool = 0; + Drain(); } #ifdef SFML_DEBUG @@ -160,6 +165,16 @@ void PoolWrapper::Release() #endif } +void PoolWrapper::Drain() +{ + [pool drain]; + pool = 0; + + if (count != 0) { + pool = [[NSAutoreleasePool alloc] init]; + } +} + } // namespace priv @@ -207,3 +222,18 @@ void ReleasePool(void) #endif } + +//////////////////////////////////////////////////////////// +void DrainPool() +{ + if (localPool != NULL) { + localPool->Drain(); + } +#ifdef SFML_DEBUG + else { + sf::Err() << "ReleasePool must be called at least one before DrainPool" + << std::endl; + } +#endif +} + diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index a9f50df20..8469208e3 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -39,20 +39,22 @@ namespace priv //////////////////////////////////////////////////////////// SFContext::SFContext(SFContext* shared) - : myView(0), myWindow(0) +: myView(0), myWindow(0) { // Ask for a pool. RetainPool(); // Create the context - CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0)); + CreateContext(shared, + VideoMode::GetDesktopMode().BitsPerPixel, + ContextSettings(0, 0, 0)); } //////////////////////////////////////////////////////////// SFContext::SFContext(SFContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) - : myView(0), myWindow(0) +: myView(0), myWindow(0) { // Ask for a pool. RetainPool(); @@ -68,7 +70,7 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings, SFContext::SFContext(SFContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) - : myView(0), myWindow(0) +: myView(0), myWindow(0) { // Ensure the process is setup in order to create a valid window. WindowImplCocoa::SetUpProcess(); diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 7697e2eb0..3eacbd154 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -45,7 +45,7 @@ namespace priv //////////////////////////////////////////////////////////// WindowImplCocoa::WindowImplCocoa(WindowHandle handle) : myShowCursor(true) -{ +{ // Ask for a pool. RetainPool(); @@ -118,6 +118,10 @@ WindowImplCocoa::~WindowImplCocoa() [myDelegate release]; ReleasePool(); + + DrainPool(); // Make sure everything was freed + // This solve some issue when sf::Window::Create is called for the + // second time (nothing was render until the function was called again) } From dad362bf698d4c680de5501a297c5d9d553e95fc Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Thu, 8 Sep 2011 08:16:37 +0200 Subject: [PATCH 22/42] Fixed Listener::GetGlobalVolume returning wrong values --- src/SFML/Audio/Listener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFML/Audio/Listener.cpp b/src/SFML/Audio/Listener.cpp index 9e2f94900..cc2bc1943 100644 --- a/src/SFML/Audio/Listener.cpp +++ b/src/SFML/Audio/Listener.cpp @@ -48,7 +48,7 @@ float Listener::GetGlobalVolume() float volume = 0.f; ALCheck(alGetListenerf(AL_GAIN, &volume)); - return volume; + return volume * 100; } From c942e576c12833664fe93ed4005fa01d5640f6a9 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Thu, 8 Sep 2011 12:03:09 +0200 Subject: [PATCH 23/42] fixed creation of frameworks and a minor error in xcode 4 template script --- cmake/Macros.cmake | 10 +++++----- .../TemplateInfo.plist | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 0488f5249..83be942e2 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -148,12 +148,12 @@ macro(sfml_add_library target) MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target} MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - else() - # adapt install directory to allow distributing dylibs in user’s frameworks - set_target_properties(${target} PROPERTIES - BUILD_WITH_INSTALL_RPATH 1 - INSTALL_NAME_DIR "@executable_path/../Frameworks") endif() + + # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks + set_target_properties(${target} PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_NAME_DIR "@executable_path/../Frameworks") endif() # link the target to its external dependencies diff --git a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist index a9bb42bc2..d197a5489 100644 --- a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist +++ b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist @@ -679,7 +679,7 @@ require () # $1 is a SFML module like 'system' or 'audio' # clean potentially old stuff rm -f $dest/libsfml-$1.2.dylib rm -f $dest/libsfml-$1-d.2.dylib - rm -f $dest/sfml-$1.framework + rm -fr $dest/sfml-$1.framework # copy SFML libraries if [ $frameworks ] From d6c1fda5bd46befb2154b23cd39db7ebe66dbb6d Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Fri, 9 Sep 2011 15:24:09 +0200 Subject: [PATCH 24/42] fixed creation of SFML.framework --- CMakeLists.txt | 6 ++++++ cmake/Macros.cmake | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 117af1ace..4ac5b1288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,12 @@ else() POST_BUILD COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* SFML.framework/Versions/2.0.0/Headers) + # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle + # NOTE : it's not required to link agains SFML.framework + set_target_properties(SFML PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_NAME_DIR "@executable_path/../Frameworks") + # install rule install(TARGETS SFML FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 83be942e2..348c918e6 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -150,7 +150,7 @@ macro(sfml_add_library target) MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) endif() - # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks + # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path/../Frameworks") From 78a625de22d3237a93fe2a12cc04d73f448565ad Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 10 Sep 2011 18:36:12 +0200 Subject: [PATCH 25/42] CMake configuration is now stopped if the Xrandr library (Linux) is not found --- src/SFML/Window/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index ae3d63d9c..b332b3510 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -66,13 +66,13 @@ else() # MACOSX ${SRCROOT}/OSX/cpp_objc_conversion.h ${SRCROOT}/OSX/cpp_objc_conversion.mm ${SRCROOT}/OSX/cg_sf_conversion.hpp - ${SRCROOT}/OSX/cg_sf_conversion.cpp + ${SRCROOT}/OSX/cg_sf_conversion.cpp ${SRCROOT}/OSX/InputImpl.mm - ${SRCROOT}/OSX/InputImpl.hpp - ${SRCROOT}/OSX/HIDInputManager.hpp - ${SRCROOT}/OSX/HIDInputManager.mm - ${SRCROOT}/OSX/HIDJoystickManager.hpp - ${SRCROOT}/OSX/HIDJoystickManager.cpp + ${SRCROOT}/OSX/InputImpl.hpp + ${SRCROOT}/OSX/HIDInputManager.hpp + ${SRCROOT}/OSX/HIDInputManager.mm + ${SRCROOT}/OSX/HIDJoystickManager.hpp + ${SRCROOT}/OSX/HIDJoystickManager.cpp ${SRCROOT}/OSX/JoystickImpl.cpp ${SRCROOT}/OSX/JoystickImpl.hpp ${SRCROOT}/OSX/SFApplication.h @@ -100,6 +100,9 @@ endif() find_package(OpenGL REQUIRED) if(LINUX) find_package(X11 REQUIRED) + if(NOT X11_Xrandr_FOUND) + message(FATAL_ERROR "Xrandr library not found") + endif() endif() # build the list of external libraries to link From a647c68a7f554e26542c927853a6891980cd52d8 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Wed, 14 Sep 2011 17:58:51 +0200 Subject: [PATCH 26/42] Fixed CMake files failing on FreeBSD --- cmake/Config.cmake | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 4b80e57eb..c0e700803 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -4,16 +4,19 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(WINDOWS 1) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(LINUX 1) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + # FreeBSD compile path is the same as Linux + set(LINUX 1) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(MACOSX 1) - - # detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.) - EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW) - STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}") - if(${MACOSX_VERSION} LESS 5) - message(WARNING "Unsupported version of OS X : ${MACOSX_VERSION_RAW}") - return() - endif() + set(MACOSX 1) + + # detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.) + EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW) + STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}") + if(${MACOSX_VERSION} LESS 5) + message(WARNING "Unsupported version of OS X : ${MACOSX_VERSION_RAW}") + return() + endif() else() message(WARNING "Unsupported operating system") From 91d56172b0e3ac804ef383bb3df4725c9363cb6b Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sun, 18 Sep 2011 10:41:59 +0200 Subject: [PATCH 27/42] Improved SFML integration with Cocoa --- src/SFML/Window/OSX/SFOpenGLView.mm | 108 +++++++++++++++++++--------- 1 file changed, 75 insertions(+), 33 deletions(-) diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index a1ac49c16..9686ee023 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -286,6 +286,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseDown:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] mouseDown:theEvent]; } @@ -294,6 +297,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseUp:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] mouseUp:theEvent]; } @@ -302,17 +308,23 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseDragged:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] mouseMoved:theEvent]; } //////////////////////////////////////////////////////// -(void)scrollWheel:(NSEvent *)theEvent { - if (myRequester == 0) return; + if (myRequester != 0) { + NSPoint loc = [self cursorPositionFromEvent:theEvent]; + + myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, loc.y); + } - NSPoint loc = [self cursorPositionFromEvent:theEvent]; - - myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, loc.y); + // Transmit to non-SFML responder + [[self nextResponder] scrollWheel:theEvent]; } @@ -343,6 +355,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseDown:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] rightMouseDown:theEvent]; } @@ -351,46 +366,51 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseUp:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] rightMouseUp:theEvent]; } //////////////////////////////////////////////////////// -(void)otherMouseDown:(NSEvent *)theEvent { - if (myRequester == 0) return; - - NSPoint loc = [self cursorPositionFromEvent:theEvent]; - sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent]; - if (button != sf::Mouse::ButtonCount) { - myRequester->MouseDownAt(button, loc.x, loc.y); + if (myRequester != 0) { + NSPoint loc = [self cursorPositionFromEvent:theEvent]; + + if (button != sf::Mouse::ButtonCount) { + myRequester->MouseDownAt(button, loc.x, loc.y); + } + } + + // If the event is not forwarded by mouseDown or rightMouseDown... + if (button != sf::Mouse::Left && button != sf::Mouse::Right) { + // ... transmit to non-SFML responder + [[self nextResponder] otherMouseDown:theEvent]; } -//#ifdef SFML_DEBUG -// else { -// sf::Err() << "Unknown mouse button released." << std::endl; -// } -//#endif } //////////////////////////////////////////////////////// -(void)otherMouseUp:(NSEvent *)theEvent { - if (myRequester == 0) return; - - NSPoint loc = [self cursorPositionFromEvent:theEvent]; - sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent]; - if (button != sf::Mouse::ButtonCount) { - myRequester->MouseUpAt(button, loc.x, loc.y); + if (myRequester != 0) { + NSPoint loc = [self cursorPositionFromEvent:theEvent]; + + if (button != sf::Mouse::ButtonCount) { + myRequester->MouseUpAt(button, loc.x, loc.y); + } + } + + // If the event is not forwarded by mouseUp or rightMouseUp... + if (button != sf::Mouse::Left && button != sf::Mouse::Right) { + // ... transmit to non-SFML responder + [[self nextResponder] otherMouseUp:theEvent]; } -//#ifdef SFML_DEBUG -// else { -// sf::Err() << "Unknown mouse button released." << std::endl; -// } -//#endif } @@ -399,6 +419,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseDragged:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] rightMouseDragged:theEvent]; } @@ -407,20 +430,30 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); { // Forward to... [self otherMouseDragged:theEvent]; + + // Transmit to non-SFML responder + [[self nextResponder] mouseDragged:theEvent]; } //////////////////////////////////////////////////////// -(void)otherMouseDragged:(NSEvent *)theEvent { - if (myRequester == 0) return; + if (myRequester != 0) { + // If the event is not useful. + if (!myMouseIsIn) return; + + NSPoint loc = [self cursorPositionFromEvent:theEvent]; + + myRequester->MouseMovedAt(loc.x, loc.y); + } - // If the event is not useful. - if (!myMouseIsIn) return; - - NSPoint loc = [self cursorPositionFromEvent:theEvent]; - - myRequester->MouseMovedAt(loc.x, loc.y); + // If the event is not forwarded by mouseDragged or rightMouseDragged... + sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent]; + if (button != sf::Mouse::Left && button != sf::Mouse::Right) { + // ... transmit to non-SFML responder + [[self nextResponder] otherMouseUp:theEvent]; + } } @@ -471,6 +504,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); //////////////////////////////////////////////////////// -(void)keyDown:(NSEvent *)theEvent { + // Transmit to non-SFML responder + [[self nextResponder] keyDown:theEvent]; + if (myRequester == 0) return; // Handle key down event @@ -526,6 +562,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); //////////////////////////////////////////////////////// -(void)keyUp:(NSEvent *)theEvent { + // Transmit to non-SFML responder + [[self nextResponder] keyUp:theEvent]; + if (myRequester == 0) return; sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent]; @@ -539,6 +578,9 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); //////////////////////////////////////////////////////// -(void)flagsChanged:(NSEvent *)theEvent { + // Transmit to non-SFML responder + [[self nextResponder] flagsChanged:theEvent]; + if (myRequester == 0) return; NSUInteger modifiers = [theEvent modifierFlags]; From 28560905735f5a06ba2a19ac34eb0c49efa7f89b Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 18 Sep 2011 22:46:11 +0200 Subject: [PATCH 28/42] Fixed error when calling Shader::LoadFromFile multiple times on the same instance --- src/SFML/Graphics/Shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index e5c62fd66..82d91ffc6 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -96,6 +96,7 @@ bool Shader::LoadFromFile(const std::string& filename) } // Read the shader code from the file + myFragmentShader.clear(); std::string line; while (std::getline(file, line)) myFragmentShader += line + "\n"; From a547acfeb7f3af1468d66735d66cfebd718288f1 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Tue, 20 Sep 2011 21:02:02 +0200 Subject: [PATCH 29/42] Fixed linker errors with InputStream in SFML dynamic libraries --- include/SFML/System/InputStream.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SFML/System/InputStream.hpp b/include/SFML/System/InputStream.hpp index 1d9765571..623c6337d 100644 --- a/include/SFML/System/InputStream.hpp +++ b/include/SFML/System/InputStream.hpp @@ -37,7 +37,7 @@ namespace sf /// \brief Abstract class for custom file input streams /// //////////////////////////////////////////////////////////// -class SFML_API InputStream +class InputStream { public : From 0fd992d56e23859f25057ea2878c7e19eced294a Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Sat, 24 Sep 2011 13:34:58 +0200 Subject: [PATCH 30/42] fix OS X alert related to key event (close #98) --- src/SFML/Window/OSX/SFOpenGLView.mm | 10 ++++++---- src/SFML/Window/OSX/SFWindow.m | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index 9686ee023..7eb45da06 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -520,11 +520,13 @@ NSUInteger KeepOnlyMaskFromData(NSUInteger data, NSUInteger mask); // Handle text entred event - // We create a new event without command modifiers + // We create a new event without command/ctrl modifiers // to prevent the OS from sending an alert - NSUInteger modifiers = [theEvent modifierFlags] & NSCommandKeyMask - ? [theEvent modifierFlags] & ~NSCommandKeyMask - : [theEvent modifierFlags]; + NSUInteger modifiers = [theEvent modifierFlags]; + + if (modifiers & NSCommandKeyMask) modifiers = modifiers & ~NSCommandKeyMask; + if (modifiers & NSControlKeyMask) modifiers = modifiers & ~NSControlKeyMask; + NSEvent* ev = [NSEvent keyEventWithType:NSKeyDown location:[theEvent locationInWindow] modifierFlags:modifiers diff --git a/src/SFML/Window/OSX/SFWindow.m b/src/SFML/Window/OSX/SFWindow.m index f6ba6e8a7..98296aa4b 100644 --- a/src/SFML/Window/OSX/SFWindow.m +++ b/src/SFML/Window/OSX/SFWindow.m @@ -32,14 +32,28 @@ @implementation SFWindow //////////////////////////////////////////////////////// --(BOOL)acceptsFirstResponder { +-(BOOL)acceptsFirstResponder +{ return YES; } //////////////////////////////////////////////////////// --(BOOL)canBecomeKeyWindow { +-(BOOL)canBecomeKeyWindow +{ return YES; } +//////////////////////////////////////////////////////// +-(void)keyDown:(NSEvent *)theEvent +{ + // Do nothing except preventing a system alert each time a key is pressed + // + // Special Consideration : + // ----------------------- + // Consider overriding NSResponder -keyDown: message in a Cocoa view/window + // that contains a SFML rendering area. Doing so will prevent a system + // alert to be thrown everytime the user presses a key. +} + @end From d58d6e51bc1c7eff6f47753846b5d21bd10fcb01 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 30 Sep 2011 13:43:52 +0200 Subject: [PATCH 31/42] Added explicit include directories for OpenGL and X11 in CMake files --- examples/X11/CMakeLists.txt | 2 ++ examples/opengl/CMakeLists.txt | 1 + examples/window/CMakeLists.txt | 1 + src/SFML/Graphics/CMakeLists.txt | 2 +- src/SFML/Window/CMakeLists.txt | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/X11/CMakeLists.txt b/examples/X11/CMakeLists.txt index 4ffba2811..d63ca9fce 100644 --- a/examples/X11/CMakeLists.txt +++ b/examples/X11/CMakeLists.txt @@ -6,7 +6,9 @@ set(SRC ${SRCROOT}/X11.cpp) # find OpenGL, GLU and X11 find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIR}) find_package(X11 REQUIRED) +include_directories(${X11_INCLUDE_DIR}) # define the X11 target sfml_add_example(X11 GUI_APP diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt index b4402b35c..5a699b6f9 100644 --- a/examples/opengl/CMakeLists.txt +++ b/examples/opengl/CMakeLists.txt @@ -6,6 +6,7 @@ set(SRC ${SRCROOT}/OpenGL.cpp) # find OpenGL and GLU find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIR}) # define the opengl target sfml_add_example(opengl GUI_APP diff --git a/examples/window/CMakeLists.txt b/examples/window/CMakeLists.txt index ed3665c43..a9edafa56 100644 --- a/examples/window/CMakeLists.txt +++ b/examples/window/CMakeLists.txt @@ -6,6 +6,7 @@ set(SRC ${SRCROOT}/Window.cpp) # find OpenGL and GLU find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIR}) # define the window target sfml_add_example(window GUI_APP diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 09daa851d..5597ff222 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -72,7 +72,7 @@ if(MACOSX) endif() # add include paths of external libraries -include_directories(${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR}) +include_directories(${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) # build the list of libraries to link # GL and X11 are only needed for shared build, as they are already linked by sfml-window diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index b332b3510..77b6a8b83 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -98,11 +98,13 @@ endif() # find external libraries find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIR}) if(LINUX) find_package(X11 REQUIRED) if(NOT X11_Xrandr_FOUND) message(FATAL_ERROR "Xrandr library not found") endif() + include_directories(${X11_INCLUDE_DIR}) endif() # build the list of external libraries to link From 9f7573c39578cb123b80fe950c50c277d9ea3e7b Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 3 Oct 2011 22:10:48 +0200 Subject: [PATCH 32/42] Fixed signed/unsigned comparison --- src/SFML/Graphics/Font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 5bc51c83a..59e1e6dc3 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -46,7 +46,7 @@ namespace unsigned long Read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count) { sf::InputStream* stream = static_cast(rec->descriptor.pointer); - if (stream->Seek(offset) == offset) + if (static_cast(stream->Seek(offset)) == offset) { if (count > 0) return static_cast(stream->Read(reinterpret_cast(buffer), count)); From 5b6c824773df2a12deba1c9b49e3c5d5608facfd Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 7 Oct 2011 08:03:24 +0200 Subject: [PATCH 33/42] Fixed error in subrect adjustment in Texture::LoadFromImage --- src/SFML/Graphics/Texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index b7a80d335..202b19683 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -188,8 +188,8 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area) IntRect rectangle = area; if (rectangle.Left < 0) rectangle.Left = 0; if (rectangle.Top < 0) rectangle.Top = 0; - if (rectangle.Width > width) rectangle.Width = width; - if (rectangle.Height > height) rectangle.Height = height; + if (rectangle.Left + rectangle.Width > width) rectangle.Width = width - rectangle.Left; + if (rectangle.Top + rectangle.Height > height) rectangle.Height = height - rectangle.Top; // Create the texture and upload the pixels if (Create(rectangle.Width, rectangle.Height)) From 512a7c63cbc0d2d703c4881339c3a0ceb49da70a Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 9 Oct 2011 11:20:45 +0200 Subject: [PATCH 34/42] FindSFML.cmake now defines the SFML_STATIC macro when requesting static libraries --- cmake/Modules/FindSFML.cmake | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/FindSFML.cmake b/cmake/Modules/FindSFML.cmake index 5e4f727bf..55e958c1d 100644 --- a/cmake/Modules/FindSFML.cmake +++ b/cmake/Modules/FindSFML.cmake @@ -11,16 +11,22 @@ # - SFML_INCLUDE_DIR, the path where SFML headers are located (the directory containing the SFML/Config.hpp file) # # By default, the dynamic libraries of SFML will be found. To find the static ones instead, -# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...). -# -# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless -# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details. -# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which +# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...). +# In case of static linking, the SFML_STATIC macro will also be defined by this script. +# +# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless +# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details. +# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which # are available for both release and debug modes. # # If SFML is not installed in a standard path, you can use the SFMLDIR CMake variable or environment variable # to tell CMake where SFML is. +# define the SFML_STATIC macro if static build was chosen +if(SFML_STATIC_LIBRARIES) + add_definitions(-DSFML_STATIC) +endif() + # deduce the libraries suffix from the options set(FIND_SFML_LIB_SUFFIX "") if(SFML_STATIC_LIBRARIES) From eed112d9eab210ebef69c0ea9c1be074a9eba273 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 16 Oct 2011 19:30:37 +0200 Subject: [PATCH 35/42] SFML shared libraries now use ELF visibility on Unixes with gcc >= 4 --- cmake/Macros.cmake | 46 ++++++++++++++++++++++++----------------- include/SFML/Config.hpp | 46 ++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 348c918e6..6cb03aaa6 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -133,29 +133,37 @@ macro(sfml_add_library target) endif() endif() + # on Unix systems with gcc 4.x, we must hide public symbols by default + # (exported ones are explicitely marked) + if((LINUX OR MACOSX) AND COMPILER_GCC) + if(${GCC_VERSION} MATCHES "4\\..*") + set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() + endif() + # link the target to its SFML dependencies if(THIS_DEPENDS) target_link_libraries(${target} ${THIS_DEPENDS}) endif() - # build frameworks or dylibs - if(MACOSX AND BUILD_SHARED_LIBS) - if(BUILD_FRAMEWORKS) - # adapt target to build frameworks instead of dylibs - set_target_properties(${target} PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} - MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - endif() - - # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle - set_target_properties(${target} PROPERTIES - BUILD_WITH_INSTALL_RPATH 1 - INSTALL_NAME_DIR "@executable_path/../Frameworks") - endif() - + # build frameworks or dylibs + if(MACOSX AND BUILD_SHARED_LIBS) + if(BUILD_FRAMEWORKS) + # adapt target to build frameworks instead of dylibs + set_target_properties(${target} PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + endif() + + # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle + set_target_properties(${target} PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 + INSTALL_NAME_DIR "@executable_path/../Frameworks") + endif() + # link the target to its external dependencies if(THIS_EXTERNAL_LIBS) if(BUILD_SHARED_LIBS) @@ -172,7 +180,7 @@ macro(sfml_add_library target) install(TARGETS ${target} RUNTIME DESTINATION bin COMPONENT bin LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel + ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin) endmacro() diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 92f229cba..677d4096b 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -97,32 +97,50 @@ //////////////////////////////////////////////////////////// // Define portable import / export macros //////////////////////////////////////////////////////////// -#if defined(SFML_SYSTEM_WINDOWS) && !defined(SFML_STATIC) +#if !defined(SFML_STATIC) - #ifdef SFML_EXPORTS + #if defined(SFML_SYSTEM_WINDOWS) - // From DLL side, we must export - #define SFML_API __declspec(dllexport) + #ifdef SFML_EXPORTS - #else + // From DLL side, we must export + #define SFML_API __declspec(dllexport) - // From client application side, we must import - #define SFML_API __declspec(dllimport) + #else - #endif + // From client application side, we must import + #define SFML_API __declspec(dllimport) - // For Visual C++ compilers, we also need to turn off this annoying C4251 warning. - // You can read lots ot different things about it, but the point is the code will - // just work fine, and so the simplest way to get rid of this warning is to disable it - #ifdef _MSC_VER + #endif - #pragma warning(disable : 4251) + // For Visual C++ compilers, we also need to turn off this annoying C4251 warning. + // You can read lots ot different things about it, but the point is the code will + // just work fine, and so the simplest way to get rid of this warning is to disable it + #ifdef _MSC_VER + + #pragma warning(disable : 4251) + + #endif + + #else // Linux, FreeBSD, Mac OS X + + #if __GNUC__ >= 4 + + // gcc 4 has special keywords for showing/hidding symbols + #define SFML_API __attribute__ ((visibility ("default"))) + + #else + + // gcc < 4 has no mechanism to explicitely hide symbols, everything's exported + #define SFML_API + + #endif #endif #else - // Other platforms and static build don't need these export macros + // Static build doesn't need these export macros #define SFML_API #endif From 01254d41228d1fa6a186ca94c387da4984a0576c Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Mon, 17 Oct 2011 00:50:20 +0300 Subject: [PATCH 36/42] Improve Xcode 4 Templates (close #113) --- .../SFML/SFML Application Base.xctemplate/TemplateInfo.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist index d197a5489..a157afd4c 100644 --- a/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist +++ b/xcode/templates/SFML/SFML Application Base.xctemplate/TemplateInfo.plist @@ -727,7 +727,7 @@ fi RunOnlyForDeploymentPostprocessing - YES + NO From 46b2c096c4aac509150fffddca2a252050df7d55 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 4 Nov 2011 08:01:56 +0100 Subject: [PATCH 37/42] Added extra underscores to gcc 4 specific attributes (visibility, constructor) --- include/SFML/Config.hpp | 2 +- src/SFML/System/Unix/Initializer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 677d4096b..d9df3f6cb 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -127,7 +127,7 @@ #if __GNUC__ >= 4 // gcc 4 has special keywords for showing/hidding symbols - #define SFML_API __attribute__ ((visibility ("default"))) + #define SFML_API __attribute__ ((__visibility__ ("default"))) #else diff --git a/src/SFML/System/Unix/Initializer.cpp b/src/SFML/System/Unix/Initializer.cpp index 0d3dbeeae..018d4a362 100644 --- a/src/SFML/System/Unix/Initializer.cpp +++ b/src/SFML/System/Unix/Initializer.cpp @@ -48,7 +48,7 @@ namespace priv /// The "constructor" attribute forces the function to be called /// at library loading time. //////////////////////////////////////////////////////////// -void InitializeWorkingDirectory(void) __attribute__ ((constructor)); +void InitializeWorkingDirectory(void) __attribute__ ((__constructor__)); void InitializeWorkingDirectory(void) { char PathBuffer[4096]; From 017ef652f98d20847b0c87076558ae0c5db50e25 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 5 Nov 2011 15:50:44 +0100 Subject: [PATCH 38/42] Removed the Resource and ResourcePtr classes --- include/SFML/Audio/Sound.hpp | 3 +- include/SFML/Audio/SoundBuffer.hpp | 3 +- include/SFML/Graphics/Font.hpp | 3 +- include/SFML/Graphics/Sprite.hpp | 9 +- include/SFML/Graphics/Text.hpp | 3 +- include/SFML/Graphics/Texture.hpp | 5 +- include/SFML/System/Resource.hpp | 288 ---------------------------- include/SFML/System/Resource.inl | 78 -------- include/SFML/System/ResourcePtr.inl | 125 ------------ src/SFML/Audio/Sound.cpp | 3 +- src/SFML/Audio/SoundBuffer.cpp | 9 +- src/SFML/Graphics/Font.cpp | 1 - src/SFML/Graphics/Sprite.cpp | 2 + src/SFML/Graphics/Texture.cpp | 1 - src/SFML/System/CMakeLists.txt | 3 - 15 files changed, 18 insertions(+), 518 deletions(-) delete mode 100644 include/SFML/System/Resource.hpp delete mode 100644 include/SFML/System/Resource.inl delete mode 100644 include/SFML/System/ResourcePtr.inl diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index c0d7d8b6d..47ce64546 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include @@ -214,7 +213,7 @@ private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - ResourcePtr myBuffer; ///< Sound buffer bound to the source + const SoundBuffer* myBuffer; ///< Sound buffer bound to the source }; } // namespace sf diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index 31c291945..2e8fe699a 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include #include #include #include @@ -49,7 +48,7 @@ class InputStream; /// \brief Storage for audio samples defining a sound /// //////////////////////////////////////////////////////////// -class SFML_API SoundBuffer : public Resource +class SFML_API SoundBuffer { public : diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index d846f5acd..dd33432cb 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -28,7 +28,6 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include #include #include #include @@ -47,7 +46,7 @@ class InputStream; /// \brief Class for loading and manipulating character fonts /// //////////////////////////////////////////////////////////// -class SFML_API Font : public Resource +class SFML_API Font { public : diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp index cb754797d..38af302ac 100644 --- a/include/SFML/Graphics/Sprite.hpp +++ b/include/SFML/Graphics/Sprite.hpp @@ -28,7 +28,6 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include #include #include @@ -204,10 +203,10 @@ private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - ResourcePtr myTexture; ///< Texture used to draw the sprite - IntRect mySubRect; ///< Sub-rectangle of source texture to assign to the sprite - bool myIsFlippedX; ///< Is the sprite flipped on the X axis ? - bool myIsFlippedY; ///< Is the sprite flipped on the Y axis ? + const Texture* myTexture; ///< Texture used to draw the sprite + IntRect mySubRect; ///< Sub-rectangle of source texture to assign to the sprite + bool myIsFlippedX; ///< Is the sprite flipped on the X axis ? + bool myIsFlippedY; ///< Is the sprite flipped on the Y axis ? }; } // namespace sf diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index 1aa45aa75..b3d97c7e6 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -28,7 +28,6 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include #include #include #include @@ -239,7 +238,7 @@ private : // Member data //////////////////////////////////////////////////////////// String myString; ///< String to display - ResourcePtr myFont; ///< Font used to display the string + const Font* myFont; ///< Font used to display the string unsigned int myCharacterSize; ///< Base size of characters, in pixels unsigned long myStyle; ///< Text style (see Style enum) mutable FloatRect myBaseRect; ///< Bounding rectangle of the text in object coordinates diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index f4a2a276d..6f4d20a1a 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -28,9 +28,8 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include -#include #include +#include namespace sf @@ -44,7 +43,7 @@ class InputStream; /// \brief Image living on the graphics card that can be used for drawing /// //////////////////////////////////////////////////////////// -class SFML_API Texture : public Resource, GlResource +class SFML_API Texture : GlResource { public : diff --git a/include/SFML/System/Resource.hpp b/include/SFML/System/Resource.hpp deleted file mode 100644 index b31597948..000000000 --- a/include/SFML/System/Resource.hpp +++ /dev/null @@ -1,288 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007 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. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_RESOURCE_HPP -#define SFML_RESOURCE_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include - - -namespace sf -{ -//////////////////////////////////////////////////////////// -// These two classes are defined in the same header because -// they depend on each other. And as they're template classes, -// they must be entirely defined in header files, which -// prevents from proper separate compiling -//////////////////////////////////////////////////////////// - -template class ResourcePtr; - -//////////////////////////////////////////////////////////// -/// \brief Base class for resources that need to notify -/// dependent classes about their destruction -/// -//////////////////////////////////////////////////////////// -template -class Resource -{ -protected : - - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - //////////////////////////////////////////////////////////// - Resource(); - - //////////////////////////////////////////////////////////// - /// \brief Copy constructor - /// - /// \param copy Instance to copy - /// - //////////////////////////////////////////////////////////// - Resource(const Resource& copy); - - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - //////////////////////////////////////////////////////////// - ~Resource(); - - //////////////////////////////////////////////////////////// - /// \brief Assignment operator - /// - /// \param right Instance to assign - /// - /// \return Reference to self - /// - //////////////////////////////////////////////////////////// - Resource& operator =(const Resource& right); - -private : - - friend class ResourcePtr; - - //////////////////////////////////////////////////////////// - /// \brief Connect a ResourcePtr to this resource - /// - /// A connected ResourcePtr will be notified of the - /// destruction of this instance. - /// - /// \param observer ResourcePtr to connect - /// - //////////////////////////////////////////////////////////// - void Connect(ResourcePtr& observer) const; - - //////////////////////////////////////////////////////////// - /// \brief Disconnect a ResourcePtr from this resource - /// - /// The disconnected ResourcePtr will no longer be notified - /// if this instance is destroyed. - /// - /// \param observer ResourcePtr to disconnect - /// - //////////////////////////////////////////////////////////// - void Disconnect(ResourcePtr& observer) const; - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - mutable std::set*> myObservers; ///< List of pointers to this resource - mutable Mutex myMutex; ///< Mutex for preventing concurrent access to the pointer list -}; - - -//////////////////////////////////////////////////////////// -/// \brief Safe pointer to a sf::Resource -/// -//////////////////////////////////////////////////////////// -template -class ResourcePtr -{ -public : - - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - /// A default constructed ResourcePtr is empty (null). - /// - //////////////////////////////////////////////////////////// - ResourcePtr(); - - //////////////////////////////////////////////////////////// - /// \brief Construct from a raw pointer - /// - /// \param resource Raw pointer to the resource to wrap - /// - //////////////////////////////////////////////////////////// - ResourcePtr(const T* resource); - - //////////////////////////////////////////////////////////// - /// \brief Copy constructor - /// - /// The new ResourcePtr will share the same resource as \a copy. - /// - /// \param copy Instance to copy - /// - //////////////////////////////////////////////////////////// - ResourcePtr(const ResourcePtr& copy); - - //////////////////////////////////////////////////////////// - /// \brief Destructor - /// - //////////////////////////////////////////////////////////// - ~ResourcePtr(); - - //////////////////////////////////////////////////////////// - /// \brief Assignment operator for a ResourcePtr parameter - /// - /// \param right Instance to assign - /// - /// \return Reference to self - /// - //////////////////////////////////////////////////////////// - ResourcePtr& operator =(const ResourcePtr& right); - - //////////////////////////////////////////////////////////// - /// \brief Assignment operator for a raw pointer parameter - /// - /// \param resource Resource to assign - /// - /// \return Reference to self - /// - //////////////////////////////////////////////////////////// - ResourcePtr& operator =(const T* resource); - - //////////////////////////////////////////////////////////// - /// \brief Cast operator to implicitely convert the resource - /// pointer to its raw pointer type (T*) - /// - /// This might be dangerous in the general case, but in this context - /// it is safe enough to define this operator. - /// - /// \return Read-only pointer to the actual resource - /// - //////////////////////////////////////////////////////////// - operator const T*() const; - - //////////////////////////////////////////////////////////// - /// \brief Overload of unary operator * - /// - /// Like raw pointers, applying the * operator returns a - /// reference to the pointed object. - /// - /// \return Reference to the pointed resource - /// - //////////////////////////////////////////////////////////// - const T& operator *() const; - - //////////////////////////////////////////////////////////// - /// \brief Overload of operator -> - /// - /// Like raw pointers, applying the -> operator returns the - /// pointed object. - /// - /// \return Pointed resource - /// - //////////////////////////////////////////////////////////// - const T* operator ->() const; - - //////////////////////////////////////////////////////////// - /// \brief Function called when the observed resource - /// is about to be destroyed - /// - /// This functions is called by the destructor of the pointed - /// resource. It allows this instance to reset its internal pointer - /// when the resource is destroyed, and avoid dangling pointers. - /// - //////////////////////////////////////////////////////////// - void OnResourceDestroyed(); - -private : - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - const T* myResource; /// Pointer to the actual resource -}; - -#include -#include - -} // namespace sf - - -#endif // SFML_RESOURCE_HPP - - -//////////////////////////////////////////////////////////// -/// \class sf::Resource -/// \ingroup system -/// -/// sf::Resource is a base for classes that want to be -/// compatible with the sf::ResourcePtr safe pointer. -/// -/// See sf::ResourcePtr for a complete explanation. -/// -/// \see sf::ResourcePtr -/// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -/// \class sf::ResourcePtr -/// \ingroup system -/// -/// sf::ResourcePtr is a special kind of smart pointer for -/// resources. Its main feature is to automatically -/// reset its internal pointer to 0 when the resource -/// gets destroyed, so that pointers to a resource never -/// become invalid when the resource is destroyed. Instead, -/// it properly returns 0 when the resource no longer exists. -/// -/// Its usage is completely transparent, so that it is similar -/// to manipulating the raw resource directly (like any smart pointer). -/// -/// For sf::ResourcePtr to work, T must inherit from -/// the sf::Resource class. -/// -/// These two classes are heavily used internally in SFML -/// to safely handle resources and the classes that use them: -/// \li sf::Texture / sf::Sprite -/// \li sf::Font / sf::Text -/// \li sf::SoundBuffer / sf::Sound -/// -/// sf::Resource and sf::ResourcePtr are designed for internal use, -/// but if you feel like they would fit well in your implementation -/// there's no problem to use them. -/// -/// \see sf::Resource -/// -//////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Resource.inl b/include/SFML/System/Resource.inl deleted file mode 100644 index 0582e5625..000000000 --- a/include/SFML/System/Resource.inl +++ /dev/null @@ -1,78 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007 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. -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -template -Resource::Resource() -{ - // Nothing to do -} - - -//////////////////////////////////////////////////////////// -template -Resource::Resource(const Resource&) -{ - // Nothing to do, we don't want to copy observers -} - - -//////////////////////////////////////////////////////////// -template -Resource::~Resource() -{ - // Notify all observers - for (typename std::set*>::iterator i = myObservers.begin(); i != myObservers.end(); ++i) - { - (*i)->OnResourceDestroyed(); - } -} - - -//////////////////////////////////////////////////////////// -template -Resource& Resource::operator =(const Resource&) -{ - // Nothing to do, we don't want to copy observers - return *this; -} - - -//////////////////////////////////////////////////////////// -template -void Resource::Connect(ResourcePtr& observer) const -{ - sf::Lock lock(myMutex); - myObservers.insert(&observer); -} - - -//////////////////////////////////////////////////////////// -template -void Resource::Disconnect(ResourcePtr& observer) const -{ - sf::Lock lock(myMutex); - myObservers.erase(&observer); -} diff --git a/include/SFML/System/ResourcePtr.inl b/include/SFML/System/ResourcePtr.inl deleted file mode 100644 index 3aa5f3634..000000000 --- a/include/SFML/System/ResourcePtr.inl +++ /dev/null @@ -1,125 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007 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. -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -template -ResourcePtr::ResourcePtr() : -myResource(NULL) -{ - -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr::ResourcePtr(const T* resource) : -myResource(resource) -{ - if (myResource) - myResource->Connect(*this); -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr::ResourcePtr(const ResourcePtr& copy) : -myResource(copy.myResource) -{ - if (myResource) - myResource->Connect(*this); -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr::~ResourcePtr() -{ - if (myResource) - myResource->Disconnect(*this); -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr& ResourcePtr::operator =(const ResourcePtr& right) -{ - if (myResource) - myResource->Disconnect(*this); - - myResource = right.myResource; - - if (myResource) - myResource->Connect(*this); - - return *this; -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr& ResourcePtr::operator =(const T* resource) -{ - if (myResource) - myResource->Disconnect(*this); - - myResource = resource; - - if (myResource) - myResource->Connect(*this); - - return *this; -} - - -//////////////////////////////////////////////////////////// -template -ResourcePtr::operator const T*() const -{ - return myResource; -} - - -//////////////////////////////////////////////////////////// -template -const T& ResourcePtr::operator *() const -{ - return *myResource; -} - - -//////////////////////////////////////////////////////////// -template -const T* ResourcePtr::operator ->() const -{ - return myResource; -} - - -//////////////////////////////////////////////////////////// -template -void ResourcePtr::OnResourceDestroyed() -{ - myResource = NULL; -} diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index dc1978a9b..961fd2f13 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -33,7 +33,8 @@ namespace sf { //////////////////////////////////////////////////////////// -Sound::Sound() +Sound::Sound() : +myBuffer(NULL) { } diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index d5e09a8d9..5f5295911 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -50,11 +50,10 @@ myDuration(0) //////////////////////////////////////////////////////////// SoundBuffer::SoundBuffer(const SoundBuffer& copy) : -Resource(), -myBuffer (0), -mySamples (copy.mySamples), -myDuration (copy.myDuration), -mySounds () // don't copy the attached sounds +myBuffer (0), +mySamples (copy.mySamples), +myDuration(copy.myDuration), +mySounds () // don't copy the attached sounds { // Create the buffer ALCheck(alGenBuffers(1, &myBuffer)); diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 59e1e6dc3..b16e254e6 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -77,7 +77,6 @@ myRefCount (NULL) //////////////////////////////////////////////////////////// Font::Font(const Font& copy) : -Resource(), myLibrary (copy.myLibrary), myFace (copy.myFace), myStreamRec (copy.myStreamRec), diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp index 19405a7b6..6518dc46b 100644 --- a/src/SFML/Graphics/Sprite.cpp +++ b/src/SFML/Graphics/Sprite.cpp @@ -36,6 +36,7 @@ namespace sf //////////////////////////////////////////////////////////// Sprite::Sprite() : Drawable (), +myTexture (NULL), mySubRect (0, 0, 1, 1), myIsFlippedX(false), myIsFlippedY(false) @@ -47,6 +48,7 @@ myIsFlippedY(false) //////////////////////////////////////////////////////////// Sprite::Sprite(const Texture& texture) : Drawable (), +myTexture (NULL), mySubRect (0, 0, 1, 1), myIsFlippedX(false), myIsFlippedY(false) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 202b19683..0517927fb 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -52,7 +52,6 @@ myPixelsFlipped(false) //////////////////////////////////////////////////////////// Texture::Texture(const Texture& copy) : -Resource(), myWidth (0), myHeight (0), myTextureWidth (0), diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index dc1a8b2c5..8cc3a26f8 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -14,9 +14,6 @@ set(SRC ${INCROOT}/Mutex.hpp ${INCROOT}/NonCopyable.hpp ${SRCROOT}/Platform.hpp - ${INCROOT}/Resource.hpp - ${INCROOT}/Resource.inl - ${INCROOT}/ResourcePtr.inl ${SRCROOT}/Sleep.cpp ${INCROOT}/Sleep.hpp ${SRCROOT}/String.cpp From a9f0ba794360cc60c8ce27ac1fb5d7f1c8d625f3 Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Wed, 9 Nov 2011 20:13:48 +0100 Subject: [PATCH 39/42] Remove unused file --- src/SFML/System/Unix/Initializer.cpp | 86 ---------------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/SFML/System/Unix/Initializer.cpp diff --git a/src/SFML/System/Unix/Initializer.cpp b/src/SFML/System/Unix/Initializer.cpp deleted file mode 100644 index 018d4a362..000000000 --- a/src/SFML/System/Unix/Initializer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Lucas Soltic (ceylow@gmail.com) and 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. -// -//////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - - -#ifdef SFML_SYSTEM_MACOS - -#include -#include -#include - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// Under Mac OS X, when launching an application from the Finder, -/// the default working directory is the user home directory ; -/// when launching from Xcode, the default one is the directory -/// containing the application. In order to produce a uniform behaviour -/// and simplify the use of resources, SFML sets the working directory to -/// the Resources folder of the application bundle. -/// The "constructor" attribute forces the function to be called -/// at library loading time. -//////////////////////////////////////////////////////////// -void InitializeWorkingDirectory(void) __attribute__ ((__constructor__)); -void InitializeWorkingDirectory(void) -{ - char PathBuffer[4096]; - bool Encoded = false; - - // Get the application bundle - CFBundleRef MainBundle = CFBundleGetMainBundle(); - assert(MainBundle != NULL); - - // Get the resource directory URL - CFURLRef ResourceDirectory = CFBundleCopyResourcesDirectoryURL(MainBundle); - assert(ResourceDirectory != NULL); - - // Convert it as absolute URL - CFURLRef AbsoluteURL = CFURLCopyAbsoluteURL(ResourceDirectory); - assert(AbsoluteURL != NULL); - - // Get the path as C string - Encoded = CFURLGetFileSystemRepresentation(AbsoluteURL, true, (UInt8 *)PathBuffer, 4096); - assert(Encoded); - - // Set the working directory - chdir(PathBuffer); - - CFRelease(AbsoluteURL); - CFRelease(ResourceDirectory); -} - -} // namespace priv - -} // namespace sf - - -#endif // SFML_SYSTEM_MACOS - From a5d40de8a2fed29bad6e451fc1ab5a17dfe16a6c Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sun, 20 Nov 2011 13:50:11 +0100 Subject: [PATCH 40/42] Replaced unsigned long with Uint32 in the public API (avoids size problems with bindings) --- include/SFML/Audio/SoundStream.hpp | 2 +- include/SFML/Graphics/RenderWindow.hpp | 2 +- include/SFML/Graphics/Text.hpp | 6 +++--- include/SFML/Window/Window.hpp | 4 ++-- src/SFML/Graphics/RenderWindow.cpp | 2 +- src/SFML/Graphics/Text.cpp | 4 ++-- src/SFML/Network/TcpSocket.cpp | 2 +- src/SFML/Network/Unix/SocketImpl.cpp | 2 +- src/SFML/Network/Win32/SocketImpl.cpp | 4 ++-- src/SFML/Network/Win32/SocketImpl.hpp | 2 +- src/SFML/Window/GlResource.cpp | 2 +- src/SFML/Window/Win32/WindowImplWin32.cpp | 2 +- src/SFML/Window/Win32/WindowImplWin32.hpp | 2 +- src/SFML/Window/Window.cpp | 4 ++-- src/SFML/Window/WindowImpl.cpp | 2 +- src/SFML/Window/WindowImpl.hpp | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 68ff9129b..65200cb85 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -284,7 +284,7 @@ private : unsigned int myBuffers[BuffersCount]; ///< Sound buffers used to store temporary audio data unsigned int myChannelsCount; ///< Number of channels (1 = mono, 2 = stereo, ...) unsigned int mySampleRate; ///< Frequency (samples / second) - unsigned long myFormat; ///< Format of the internal sound buffers + Uint32 myFormat; ///< Format of the internal sound buffers bool myLoop; ///< Loop flag (true to loop, false to play once) Uint64 mySamplesProcessed; ///< Number of buffers processed since beginning of the stream bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index b6263d7f0..46ae29efe 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -72,7 +72,7 @@ public : /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// - RenderWindow(VideoMode mode, const std::string& title, unsigned long style = Style::Default, const ContextSettings& settings = ContextSettings()); + RenderWindow(VideoMode mode, const std::string& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings()); //////////////////////////////////////////////////////////// /// \brief Construct the window from an existing control diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index b3d97c7e6..84eccb238 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -133,7 +133,7 @@ public : /// \see GetStyle /// //////////////////////////////////////////////////////////// - void SetStyle(unsigned long style); + void SetStyle(Uint32 style); //////////////////////////////////////////////////////////// /// \brief Get the text's string @@ -185,7 +185,7 @@ public : /// \see SetStyle /// //////////////////////////////////////////////////////////// - unsigned long GetStyle() const; + Uint32 GetStyle() const; //////////////////////////////////////////////////////////// /// \brief Return the position of the \a index-th character @@ -240,7 +240,7 @@ private : String myString; ///< String to display const Font* myFont; ///< Font used to display the string unsigned int myCharacterSize; ///< Base size of characters, in pixels - unsigned long myStyle; ///< Text style (see Style enum) + Uint32 myStyle; ///< Text style (see Style enum) mutable FloatRect myBaseRect; ///< Bounding rectangle of the text in object coordinates mutable bool myRectUpdated; ///< Is the bounding rectangle up-to-date ? }; diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 14f040ae3..0a0d257a2 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -85,7 +85,7 @@ public : /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// - Window(VideoMode mode, const std::string& title, unsigned long style = Style::Default, const ContextSettings& settings = ContextSettings()); + Window(VideoMode mode, const std::string& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings()); //////////////////////////////////////////////////////////// /// \brief Construct the window from an existing control @@ -124,7 +124,7 @@ public : /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// - void Create(VideoMode mode, const std::string& title, unsigned long style = Style::Default, const ContextSettings& settings = ContextSettings()); + void Create(VideoMode mode, const std::string& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings()); //////////////////////////////////////////////////////////// /// \brief Create (or recreate) the window from an existing control diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 4fec0f264..087eaea47 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -39,7 +39,7 @@ RenderWindow::RenderWindow() //////////////////////////////////////////////////////////// -RenderWindow::RenderWindow(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) +RenderWindow::RenderWindow(VideoMode mode, const std::string& title, Uint32 style, const ContextSettings& settings) { // Don't call the base class constructor because it contains virtual function calls Create(mode, title, style, settings); diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index bed9c5e2b..bb92ec7d3 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -85,7 +85,7 @@ void Text::SetCharacterSize(unsigned int size) //////////////////////////////////////////////////////////// -void Text::SetStyle(unsigned long style) +void Text::SetStyle(Uint32 style) { if (myStyle != style) { @@ -117,7 +117,7 @@ unsigned int Text::GetCharacterSize() const //////////////////////////////////////////////////////////// -unsigned long Text::GetStyle() const +Uint32 Text::GetStyle() const { return myStyle; } diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index c7a1f055b..238fdabc0 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -277,7 +277,7 @@ Socket::Status TcpSocket::Send(Packet& packet) const char* data = packet.OnSend(size); // First send the packet size - Uint32 packetSize = htonl(static_cast(size)); + Uint32 packetSize = htonl(static_cast(size)); Status status = Send(reinterpret_cast(&packetSize), sizeof(packetSize)); // Make sure that the size was properly sent diff --git a/src/SFML/Network/Unix/SocketImpl.cpp b/src/SFML/Network/Unix/SocketImpl.cpp index 1cf503240..9a4cb762e 100644 --- a/src/SFML/Network/Unix/SocketImpl.cpp +++ b/src/SFML/Network/Unix/SocketImpl.cpp @@ -36,7 +36,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -sockaddr_in SocketImpl::CreateAddress(unsigned long address, unsigned short port) +sockaddr_in SocketImpl::CreateAddress(Uint32 address, unsigned short port) { sockaddr_in addr; std::memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); diff --git a/src/SFML/Network/Win32/SocketImpl.cpp b/src/SFML/Network/Win32/SocketImpl.cpp index 95812f4e6..fcafa7f0b 100644 --- a/src/SFML/Network/Win32/SocketImpl.cpp +++ b/src/SFML/Network/Win32/SocketImpl.cpp @@ -34,7 +34,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -sockaddr_in SocketImpl::CreateAddress(unsigned long address, unsigned short port) +sockaddr_in SocketImpl::CreateAddress(Uint32 address, unsigned short port) { sockaddr_in addr; std::memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); @@ -63,7 +63,7 @@ void SocketImpl::Close(SocketHandle sock) //////////////////////////////////////////////////////////// void SocketImpl::SetBlocking(SocketHandle sock, bool block) { - unsigned long blocking = block ? 0 : 1; + u_long blocking = block ? 0 : 1; ioctlsocket(sock, FIONBIO, &blocking); } diff --git a/src/SFML/Network/Win32/SocketImpl.hpp b/src/SFML/Network/Win32/SocketImpl.hpp index f6e5b001f..475ea4ae1 100644 --- a/src/SFML/Network/Win32/SocketImpl.hpp +++ b/src/SFML/Network/Win32/SocketImpl.hpp @@ -59,7 +59,7 @@ public : /// \return sockaddr_in ready to be used by socket functions /// //////////////////////////////////////////////////////////// - static sockaddr_in CreateAddress(unsigned long address, unsigned short port); + static sockaddr_in CreateAddress(Uint32 address, unsigned short port); //////////////////////////////////////////////////////////// /// \brief Return the value of the invalid socket diff --git a/src/SFML/Window/GlResource.cpp b/src/SFML/Window/GlResource.cpp index c3f263845..0dd56c5ec 100644 --- a/src/SFML/Window/GlResource.cpp +++ b/src/SFML/Window/GlResource.cpp @@ -37,7 +37,7 @@ namespace { // OpenGL resources counter and its mutex - unsigned long count = 0; + unsigned int count = 0; sf::Mutex mutex; } diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index dd11178c9..4f7320692 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -87,7 +87,7 @@ myIsCursorIn (false) //////////////////////////////////////////////////////////// -WindowImplWin32::WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style) : +WindowImplWin32::WindowImplWin32(VideoMode mode, const std::string& title, Uint32 style) : myHandle (NULL), myCallback (0), myCursor (NULL), diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp index 047e279f0..9a7d97afb 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.hpp +++ b/src/SFML/Window/Win32/WindowImplWin32.hpp @@ -62,7 +62,7 @@ public : /// \param style Window style /// //////////////////////////////////////////////////////////// - WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style); + WindowImplWin32(VideoMode mode, const std::string& title, Uint32 style); //////////////////////////////////////////////////////////// /// \brief Destructor diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index ac047f9ce..7101649b5 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -55,7 +55,7 @@ myFramerateLimit(0) //////////////////////////////////////////////////////////// -Window::Window(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) : +Window::Window(VideoMode mode, const std::string& title, Uint32 style, const ContextSettings& settings) : myWindow (NULL), myContext (NULL), myLastFrameTime (0), @@ -84,7 +84,7 @@ Window::~Window() //////////////////////////////////////////////////////////// -void Window::Create(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) +void Window::Create(VideoMode mode, const std::string& title, Uint32 style, const ContextSettings& settings) { // Destroy the previous window implementation Close(); diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index 518ea5d8e..228018581 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -55,7 +55,7 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -WindowImpl* WindowImpl::New(VideoMode mode, const std::string& title, unsigned long style) +WindowImpl* WindowImpl::New(VideoMode mode, const std::string& title, Uint32 style) { return new WindowImplType(mode, title, style); } diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index 86a24fcfd..add622cc0 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -64,7 +64,7 @@ public : /// \return Pointer to the created window (don't forget to delete it) /// //////////////////////////////////////////////////////////// - static WindowImpl* New(VideoMode mode, const std::string& title, unsigned long style); + static WindowImpl* New(VideoMode mode, const std::string& title, Uint32 style); //////////////////////////////////////////////////////////// /// \brief Create a new window depending on to the current OS From 09854baccfc370480fe30f10c7a78648034fde3f Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 21 Nov 2011 07:55:52 +0100 Subject: [PATCH 41/42] Fixed compile error on Unix systems (caused by the latest commit) --- src/SFML/Network/Unix/SocketImpl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFML/Network/Unix/SocketImpl.hpp b/src/SFML/Network/Unix/SocketImpl.hpp index ae37e62c6..c9248148e 100644 --- a/src/SFML/Network/Unix/SocketImpl.hpp +++ b/src/SFML/Network/Unix/SocketImpl.hpp @@ -65,7 +65,7 @@ public : /// \return sockaddr_in ready to be used by socket functions /// //////////////////////////////////////////////////////////// - static sockaddr_in CreateAddress(unsigned long address, unsigned short port); + static sockaddr_in CreateAddress(Uint32 address, unsigned short port); //////////////////////////////////////////////////////////// /// \brief Return the value of the invalid socket From 6f44f12fafa5b708a10039f6a4777eb8fae719df Mon Sep 17 00:00:00 2001 From: Thomas Knepper Date: Tue, 29 Nov 2011 21:57:36 +0100 Subject: [PATCH 42/42] Explicit use signed char for included font data to enable cross-compile for an arm-based system From ISO/IEC 9899:1999, 6.2.5.15 (p. 49): The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. Signed-off-by: Thomas Knepper --- src/SFML/Graphics/Font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index b16e254e6..8a7f64ca8 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -338,7 +338,7 @@ const Font& Font::GetDefaultFont() // Load the default font on first call if (!loaded) { - static const char data[] = + static const signed char data[] = { #include };