Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier platform porting #108

Merged
merged 29 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2510f21
wip
dethrace-labs Mar 14, 2022
eb905c5
wip2
dethrace-labs Mar 14, 2022
8536771
wip2
dethrace-labs Mar 14, 2022
8fcad2a
Create PORTING.md
dethrace-labs Mar 14, 2022
cb3c5ca
Update PORTING.md
dethrace-labs Mar 14, 2022
db30529
io_platform
dethrace-labs Mar 14, 2022
37b8c9f
wip
dethrace-labs Mar 17, 2022
d72f121
Merge branch 'main' of https://github.com/dethrace-labs/dethrace into…
dethrace-labs Mar 17, 2022
6c89c3e
removes miniposix
dethrace-labs Mar 17, 2022
100e8b8
removes miniposix 2
dethrace-labs Mar 18, 2022
7ff629f
removes miniposix 3
dethrace-labs Mar 18, 2022
4affe0e
removes miniposix 4
dethrace-labs Mar 18, 2022
10793cf
fix tests
dethrace-labs Mar 19, 2022
be856d0
fix windows build
dethrace-labs Mar 19, 2022
d647632
remove unistd refs
dethrace-labs Mar 20, 2022
4dd0608
fix again
dethrace-labs Mar 20, 2022
aa1c48a
fix again
dethrace-labs Mar 20, 2022
f666d3d
fix again
dethrace-labs Mar 20, 2022
44f22a6
fix again
dethrace-labs Mar 20, 2022
71077b4
fix again
dethrace-labs Mar 20, 2022
0fa0a0e
removes watcom functions
dethrace-labs Mar 20, 2022
90dd294
removes watcom functions
dethrace-labs Mar 20, 2022
df1f999
removes watcom functions
dethrace-labs Mar 20, 2022
78aa3ed
access
dethrace-labs Mar 20, 2022
028605f
access
dethrace-labs Mar 20, 2022
12f647b
windows fixes
dethrace-labs Mar 20, 2022
249c862
fixes shadow rendering memory leak
dethrace-labs Mar 20, 2022
aaa3e7e
cmake tidy
dethrace-labs Mar 20, 2022
49e7b59
remove watcom files
dethrace-labs Mar 20, 2022
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ option(BUILD_TESTS "Build unit tests." OFF)
find_package(SDL2 REQUIRED)

add_subdirectory(lib/libsmacker)
add_subdirectory(lib/miniposix)
add_subdirectory(lib/glad)
add_subdirectory(lib/cglm EXCLUDE_FROM_ALL)

Expand Down
68 changes: 68 additions & 0 deletions docs/PORTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Porting Dethrace to other systems

## Operating Systems

See: xxx

Assuming an operating system called _foo_, follow the steps to add support for it.

1. Add a new file `os/foo.h` and implement the required functions defined in `os.h`:
- `OS_GetTime`
- `OS_Sleep`
- `OS_Basename`
- `OS_GetFirstFileInDirectory`
- `OS_GetNextFileInDirectory`
- `OS_IsDebuggerPresent`
- `OS_InstallSignalHandler`

2. Update `src/harness/CMakeLists.h` and add a new conditional section for "os/foo.h", based on existing conditions for Windows, MacOS etc.

For example:

```
...
elseif( _FOO_ )
target_sources(harness PRIVATE
os/foo.c
)
...
```

## IO Platform (windowing / input / rendering)

An `IOPlatform` in _dethrace_ implements windowing and input handling, and points to a _renderer_.

The default IO platform is `SDL_OpenGL`, which uses SDL for windowing and input, and OpenGL for rendering. See `io_platforms/sdl_gl.c`.

To add a new `IOPlatform`:

1. Create `io_platforms/my_platform.c` file and implement the required functions defined in `io_platform.h`:
- `Window_Create`
- `Window_PollEvents`
- `Window_Swap`
- `Input_GetKeyMap`
- `Input_IsKeyDown`

`Window_Create` returns a `tRenderer*`, which must implement the interface defined in `renderers/renderer.h`. See `renderers/gl` for an example.

2. Add a new conditional section in `src/harness/CMakeLists.txt` for your new platform

For example:
```
if (IO_PLATFORM STREQUAL "My_Platform")
target_sources(harness PRIVATE
io_platforms/my_platform.c
)
endif()
```

3. Run cmake to update your build with the new platform
```sh
cd build
cmake -DIO_PLATFORM=My_Platform ..
```

4. Build
```
cmake --build .
```
50 changes: 0 additions & 50 deletions lib/miniposix/CMakeLists.txt

This file was deleted.

Loading