Skip to content

Commit

Permalink
feat: Add an SDL example to the C bindings (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny authored Aug 8, 2023
1 parent c2db1b0 commit 1f5cd1f
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 3 deletions.
1 change: 1 addition & 0 deletions bindings/c/examples/sdl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
13 changes: 13 additions & 0 deletions bindings/c/examples/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.20)

project(sdl_example)

find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
find_package(ACCESSKIT REQUIRED)
include_directories(windows_example ${ACCESSKIT_INCLUDE_DIR})

add_executable(hello_world hello_world.c)
target_link_libraries(hello_world PUBLIC ${SDL2_LIBRARIES})
target_link_libraries(hello_world PUBLIC accesskit)
target_compile_definitions(hello_world PRIVATE -DUNICODE -D_UNICODE)
36 changes: 36 additions & 0 deletions bindings/c/examples/sdl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# AccessKit cross-platform SDL example

This example demonstrates how to make use of the C bindings to create cross-platform applications.

## Building

The process will vary based on your operating system.

### Windows:

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.

```bash
cmake -S . -B build -DACCESSKIT_DIR="../.." -DSDL2_DIR="<PATH_TO_SDL2_PACKAGE>/cmake"
cmake --build build --config Release
```

You will then need to copy `SDL2.dll` into the `build/Release` folder.

### Linux

Make sure to install SDL2 and its development package.

```bash
cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release
cmake --build build
```

### macOS

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`.

```bash
cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release
cmake --build build
```
Loading

0 comments on commit 1f5cd1f

Please sign in to comment.