Skip to content

Commit 1f5cd1f

Browse files
authored
feat: Add an SDL example to the C bindings (#250)
1 parent c2db1b0 commit 1f5cd1f

File tree

6 files changed

+478
-3
lines changed

6 files changed

+478
-3
lines changed

bindings/c/examples/sdl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(sdl_example)
4+
5+
find_package(SDL2 REQUIRED)
6+
include_directories(${SDL2_INCLUDE_DIRS})
7+
find_package(ACCESSKIT REQUIRED)
8+
include_directories(windows_example ${ACCESSKIT_INCLUDE_DIR})
9+
10+
add_executable(hello_world hello_world.c)
11+
target_link_libraries(hello_world PUBLIC ${SDL2_LIBRARIES})
12+
target_link_libraries(hello_world PUBLIC accesskit)
13+
target_compile_definitions(hello_world PRIVATE -DUNICODE -D_UNICODE)

bindings/c/examples/sdl/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# AccessKit cross-platform SDL example
2+
3+
This example demonstrates how to make use of the C bindings to create cross-platform applications.
4+
5+
## Building
6+
7+
The process will vary based on your operating system.
8+
9+
### Windows:
10+
11+
First download an SDL2 development package from the project's [GitHub release page](https://github.com/libsdl-org/SDL/releases) (SDL2-devel-2.x.y-VC.zip for MSVC) and extract it.
12+
13+
```bash
14+
cmake -S . -B build -DACCESSKIT_DIR="../.." -DSDL2_DIR="<PATH_TO_SDL2_PACKAGE>/cmake"
15+
cmake --build build --config Release
16+
```
17+
18+
You will then need to copy `SDL2.dll` into the `build/Release` folder.
19+
20+
### Linux
21+
22+
Make sure to install SDL2 and its development package.
23+
24+
```bash
25+
cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release
26+
cmake --build build
27+
```
28+
29+
### macOS
30+
31+
First download an SDL2 package from the project's [GitHub release page](https://github.com/libsdl-org/SDL/releases) (SDL2-2.x.y.dmg) and copy `SDL2.framework` to `/Library/Frameworks`.
32+
33+
```bash
34+
cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release
35+
cmake --build build
36+
```

0 commit comments

Comments
 (0)