Skip to content

Commit

Permalink
Upgrade to SFML 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Dec 18, 2024
1 parent b2b94be commit 08d969f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
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
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libxi-dev libudev-dev libgl1-mesa-dev libegl1-mesa-dev

- name: Checkout
uses: actions/checkout@v4
Expand Down
16 changes: 3 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
cmake_minimum_required(VERSION 3.28)
project(CMakeSFMLProject LANGUAGES CXX)
project(CMakeSFMLProject)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x
GIT_TAG master
GIT_SHALLOW ON
EXCLUDE_FROM_ALL
SYSTEM)
FetchContent_MakeAvailable(SFML)

add_executable(main src/main.cpp)
target_link_libraries(main PRIVATE sfml-graphics)
target_compile_features(main PRIVATE cxx_std_17)

if(WIN32)
add_custom_command(
TARGET main
COMMENT "Copy OpenAL DLL"
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:main>
VERBATIM)
endif()
target_link_libraries(main PRIVATE SFML::Graphics)
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ The template starts out very basic, but might receive additional features over t
libxcursor-dev \
libudev-dev \
libfreetype-dev \
libopenal-dev \
libflac-dev \
libvorbis-dev \
libgl1-mesa-dev \
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

int main()
{
auto window = sf::RenderWindow({1920u, 1080u}, "CMake SFML Project");
auto window = sf::RenderWindow(sf::VideoMode({1920u, 1080u}), "CMake SFML Project");
window.setFramerateLimit(144);

while (window.isOpen())
{
for (auto event = sf::Event(); window.pollEvent(event);)
while (const std::optional event = window.pollEvent())
{
if (event.type == sf::Event::Closed)
if (event->is<sf::Event::Closed>())
{
window.close();
}
Expand Down

0 comments on commit 08d969f

Please sign in to comment.