Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev

- name: Checkout SFML
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 2.6.0
Expand All @@ -54,7 +54,7 @@ jobs:
run: cmake --build $GITHUB_WORKSPACE/SFML/build --config ${{matrix.type.name}} --target install

- name: Checkout CSFML
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: CSFML

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.7.2)
cmake_minimum_required(VERSION 3.22)

# define a macro that helps defining an option
macro(csfml_set_option var default type docstring)
Expand All @@ -13,7 +13,7 @@ endmacro()
csfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")

# project name
project(CSFML VERSION 2.6.0)
project(CSFML VERSION 3.0.0)

# include the configuration file
include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake)
Expand Down
11 changes: 5 additions & 6 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ function(set_file_warnings)
/w14905 # wide string literal cast to 'LPSTR'
/w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
# /permissive- # standards conformance mode for MSVC compiler. Disabled until all out-of-the-box Windows SDKs can successfully build with it.
/permissive- # standards conformance mode for MSVC compiler

# Disables, remove when appropriate
/wd4996 # disable warnings about deprecated functions
/wd4068 # disable warnings about unknown pragmas (e.g. #pragma GCC)
/wd4505 # disable warnings about unused functions that might be platform-specific
/wd4800 # disable warnings regarding implicit conversions to bool
/wd5105 # disable warning about expansion of 'defined' keyword
)

set(CLANG_AND_GCC_WARNINGS
Expand Down Expand Up @@ -61,14 +62,13 @@ function(set_file_warnings)
endif()

if(WARNINGS_AS_ERRORS)
set(CLANG_AND_GCC_WARNINGS ${CLANG_AND_GCC_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
list(APPEND CLANG_AND_GCC_WARNINGS -Werror)
list(APPEND MSVC_WARNINGS /WX)
endif()

set(CLANG_WARNINGS
${CLANG_AND_GCC_WARNINGS}
-Wno-unknown-warning-option # do not warn on GCC-specific warning diagnostic pragmas
-Wno-c++11-long-long # do not warn on uses of long long
)

set(GCC_WARNINGS
Expand All @@ -82,8 +82,7 @@ function(set_file_warnings)
# Don't enable -Wduplicated-branches for GCC < 8.1 since it will lead to false positives
# https://github.com/gcc-mirror/gcc/commit/6bebae75035889a4844eb4d32a695bebf412bcd7
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(GCC_WARNINGS
${GCC_WARNINGS}
list(APPEND GCC_WARNINGS
-Wduplicated-branches # warn if if / else branches have duplicated code
)
endif()
Expand Down
21 changes: 1 addition & 20 deletions cmake/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(SFML_OS_FREEBSD 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SFML_OS_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(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
return()
endif()
else()
message(FATAL_ERROR "Unsupported operating system")
return()
Expand All @@ -52,24 +44,13 @@ if(MSVC)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SFML_COMPILER_CLANG 1)

execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(SFML_COMPILER_GCC 1)

execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)

if(GCC_MACHINE MATCHES ".*w64.*")
set(SFML_COMPILER_GCC_W64 1)
endif()
else()
message(FATAL_ERROR "Unsupported compiler")
message(WARNING "Unsupported compiler")
return()
endif()

Expand Down
14 changes: 7 additions & 7 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ macro(csfml_add_library target)
# add warnings
set_file_warnings(${THIS_SOURCES})

# require C11 and C++17
target_compile_features(${target} PUBLIC c_std_11 cxx_std_17)

# define the export symbol of the module
string(REPLACE "-" "_" NAME_UPPER "${target}")
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
Expand All @@ -45,20 +48,17 @@ macro(csfml_add_library target)
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
set_target_properties(${target} PROPERTIES FOLDER "CSFML")

# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
# apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
endif()
endif()

# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
# (exported ones are explicitely marked)
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
endif()
# ensure public symbols are hidden by default (exported ones are explicitly marked)
set_target_properties(${target} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)

# link the target to its external dependencies (C++ SFML libraries)
target_link_libraries(${target} PRIVATE ${THIS_DEPENDS})
Expand Down
2 changes: 1 addition & 1 deletion doc/mainpage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/// if (!texture)
/// return EXIT_FAILURE;
/// sprite = sfSprite_create();
/// sfSprite_setTexture(sprite, texture, sfTrue);
/// sfSprite_setTexture(sprite, texture, true);
///
/// /* Create a graphical text to display */
/// font = sfFont_createFromFile("arial.ttf");
Expand Down
2 changes: 1 addition & 1 deletion examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(void)
return EXIT_FAILURE;
}
sfSprite* sprite = sfSprite_create();
sfSprite_setTexture(sprite, texture, sfTrue);
sfSprite_setTexture(sprite, texture, true);
const sfVector2f spritePosition = {200, 200};
sfSprite_setPosition(sprite, spritePosition);

Expand Down
18 changes: 9 additions & 9 deletions include/SFML/Audio/Music.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ CSFML_AUDIO_API void sfMusic_destroy(sfMusic* music);
///
/// If set, the music will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// sfMusic_setLoop(music, sfFalse) is called.
/// sfMusic_setLoop(music, false) is called.
/// The default looping state for musics is false.
///
/// \param music Music object
/// \param loop sfTrue to play in loop, sfFalse to play once
/// \param loop true to play in loop, false to play once
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setLoop(sfMusic* music, sfBool loop);
CSFML_AUDIO_API void sfMusic_setLoop(sfMusic* music, bool loop);

////////////////////////////////////////////////////////////
/// \brief Tell whether or not a music is in loop mode
///
/// \param music Music object
///
/// \return sfTrue if the music is looping, sfFalse otherwise
/// \return true if the music is looping, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfMusic_getLoop(const sfMusic* music);
CSFML_AUDIO_API bool sfMusic_getLoop(const sfMusic* music);

////////////////////////////////////////////////////////////
/// \brief Get the total duration of a music
Expand Down Expand Up @@ -310,10 +310,10 @@ CSFML_AUDIO_API void sfMusic_setPosition(sfMusic* music, sfVector3f position);
/// The default value is false (position is absolute).
///
/// \param music Music object
/// \param relative sfTrue to set the position relative, sfFalse to set it absolute
/// \param relative true to set the position relative, false to set it absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, sfBool relative);
CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, bool relative);

////////////////////////////////////////////////////////////
/// \brief Set the minimum distance of a music
Expand Down Expand Up @@ -397,10 +397,10 @@ CSFML_AUDIO_API sfVector3f sfMusic_getPosition(const sfMusic* music);
///
/// \param music Music object
///
/// \return sfTrue if the position is relative, sfFalse if it's absolute
/// \return true if the position is relative, false if it's absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfMusic_isRelativeToListener(const sfMusic* music);
CSFML_AUDIO_API bool sfMusic_isRelativeToListener(const sfMusic* music);

////////////////////////////////////////////////////////////
/// \brief Get the minimum distance of a music
Expand Down
18 changes: 9 additions & 9 deletions include/SFML/Audio/Sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,24 @@ CSFML_AUDIO_API const sfSoundBuffer* sfSound_getBuffer(const sfSound* sound);
///
/// If set, the sound will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// sfSound_setLoop(sound, sfFalse) is called.
/// sfSound_setLoop(sound, false) is called.
/// The default looping state for sounds is false.
///
/// \param sound Sound object
/// \param loop sfTrue to play in loop, sfFalse to play once
/// \param loop true to play in loop, false to play once
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setLoop(sfSound* sound, sfBool loop);
CSFML_AUDIO_API void sfSound_setLoop(sfSound* sound, bool loop);

////////////////////////////////////////////////////////////
/// \brief Tell whether or not a sound is in loop mode
///
/// \param sound Sound object
///
/// \return sfTrue if the sound is looping, sfFalse otherwise
/// \return true if the sound is looping, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSound_getLoop(const sfSound* sound);
CSFML_AUDIO_API bool sfSound_getLoop(const sfSound* sound);

////////////////////////////////////////////////////////////
/// \brief Get the current status of a sound (stopped, paused, playing)
Expand Down Expand Up @@ -205,10 +205,10 @@ CSFML_AUDIO_API void sfSound_setPosition(sfSound* sound, sfVector3f position);
/// The default value is false (position is absolute).
///
/// \param sound Sound object
/// \param relative sfTrue to set the position relative, sfFalse to set it absolute
/// \param relative true to set the position relative, false to set it absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, sfBool relative);
CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, bool relative);

////////////////////////////////////////////////////////////
/// \brief Set the minimum distance of a sound
Expand Down Expand Up @@ -292,10 +292,10 @@ CSFML_AUDIO_API sfVector3f sfSound_getPosition(const sfSound* sound);
///
/// \param sound Sound object
///
/// \return sfTrue if the position is relative, sfFalse if it's absolute
/// \return true if the position is relative, false if it's absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSound_isRelativeToListener(const sfSound* sound);
CSFML_AUDIO_API bool sfSound_isRelativeToListener(const sfSound* sound);

////////////////////////////////////////////////////////////
/// \brief Get the minimum distance of a sound
Expand Down
14 changes: 7 additions & 7 deletions include/SFML/Audio/SoundBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* str
/// \brief Create a new sound buffer and load it from an array of samples in memory
///
/// The assumed format of the audio samples is 16 bits signed integer
/// (sfInt16).
/// (int16_t).
///
/// \param samples Pointer to the array of samples in memory
/// \param sampleCount Number of samples in the array
Expand All @@ -92,7 +92,7 @@ CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* str
/// \return A new sfSoundBuffer object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, sfUint64 sampleCount, unsigned int channelCount, unsigned int sampleRate);
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const int16_t* samples, uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate);

////////////////////////////////////////////////////////////
/// \brief Create a new sound buffer by copying an existing one
Expand Down Expand Up @@ -122,24 +122,24 @@ CSFML_AUDIO_API void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer);
/// \param soundBuffer Sound buffer object
/// \param filename Path of the sound file to write
///
/// \return sfTrue if saving succeeded, sfFalse if it failed
/// \return true if saving succeeded, false if it failed
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename);
CSFML_AUDIO_API bool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename);

////////////////////////////////////////////////////////////
/// \brief Get the array of audio samples stored in a sound buffer
///
/// The format of the returned samples is 16 bits signed integer
/// (sfInt16). The total number of samples in this array
/// (int16_t). The total number of samples in this array
/// is given by the sfSoundBuffer_getSampleCount function.
///
/// \param soundBuffer Sound buffer object
///
/// \return Read-only pointer to the array of sound samples
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer);
CSFML_AUDIO_API const int16_t* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer);

////////////////////////////////////////////////////////////
/// \brief Get the number of samples stored in a sound buffer
Expand All @@ -152,7 +152,7 @@ CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples(const sfSoundBuffer* sou
/// \return Number of samples
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfUint64 sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);
CSFML_AUDIO_API uint64_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);

////////////////////////////////////////////////////////////
/// \brief Get the sample rate of a sound buffer
Expand Down
8 changes: 4 additions & 4 deletions include/SFML/Audio/SoundBufferRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundB
/// \param soundBufferRecorder Sound buffer recorder object
/// \param sampleRate Desired capture rate, in number of samples per second
///
/// \return sfTrue, if it was able to start recording
/// \return true, if it was able to start recording
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);
CSFML_AUDIO_API bool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);

////////////////////////////////////////////////////////////
/// \brief Stop the capture of a sound recorder
Expand Down Expand Up @@ -114,10 +114,10 @@ CSFML_AUDIO_API const sfSoundBuffer* sfSoundBufferRecorder_getBuffer(const sfSou
/// \param soundBufferRecorder Sound buffer recorder object
/// \param name The name of the audio capture device
///
/// \return sfTrue, if it was able to set the requested device
/// \return true, if it was able to set the requested device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name);
CSFML_AUDIO_API bool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name);

////////////////////////////////////////////////////////////
/// \brief Get the name of the current audio capture device
Expand Down
Loading