Skip to content

Commit 3e10ce1

Browse files
committed
Upgrade to SFML 3
1 parent 2163ac3 commit 3e10ce1

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- name: Install Linux Dependencies
2929
if: runner.os == 'Linux'
30-
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 libfreetype-dev
30+
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libxi-dev libudev-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libfreetype-dev
3131

3232
- name: Checkout
3333
uses: actions/checkout@v4

Diff for: CMakeLists.txt

+2-12
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@ cmake_minimum_required(VERSION 3.28)
22
project(CMakeSFMLProject LANGUAGES CXX)
33

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

76
include(FetchContent)
87
FetchContent_Declare(SFML
98
GIT_REPOSITORY https://github.com/SFML/SFML.git
10-
GIT_TAG 2.6.x
9+
GIT_TAG 3.0.0
1110
GIT_SHALLOW ON
1211
EXCLUDE_FROM_ALL
1312
SYSTEM)
1413
FetchContent_MakeAvailable(SFML)
1514

1615
add_executable(main src/main.cpp)
17-
target_link_libraries(main PRIVATE sfml-graphics)
18-
target_compile_features(main PRIVATE cxx_std_17)
19-
20-
if(WIN32)
21-
add_custom_command(
22-
TARGET main
23-
COMMENT "Copy OpenAL DLL"
24-
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>
25-
VERBATIM)
26-
endif()
16+
target_link_libraries(main PRIVATE SFML::Graphics)

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ The template starts out very basic, but might receive additional features over t
2424
libxcursor-dev \
2525
libudev-dev \
2626
libfreetype-dev \
27-
libopenal-dev \
2827
libflac-dev \
2928
libvorbis-dev \
3029
libgl1-mesa-dev \
31-
libegl1-mesa-dev
30+
libegl1-mesa-dev \
31+
libfreetype-dev
3232
```
3333
8. Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part.
3434

Diff for: src/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
int main()
44
{
5-
auto window = sf::RenderWindow({1920u, 1080u}, "CMake SFML Project");
5+
auto window = sf::RenderWindow(sf::VideoMode({1920u, 1080u}), "CMake SFML Project");
66
window.setFramerateLimit(144);
77

88
while (window.isOpen())
99
{
10-
for (auto event = sf::Event(); window.pollEvent(event);)
10+
while (const std::optional event = window.pollEvent())
1111
{
12-
if (event.type == sf::Event::Closed)
12+
if (event->is<sf::Event::Closed>())
1313
{
1414
window.close();
1515
}

0 commit comments

Comments
 (0)