Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | # Porting Dethrace to other systems |
| 2 | |||
| 3 | ## Operating Systems |
||
| 4 | |||
| 5 | Assuming an operating system called _foo_, follow the steps to add support for it. |
||
| 6 | |||
| 7 | 1. Add a new file `os/foo.h` and implement the required functions defined in [os.h](https://github.com/dethrace-labs/dethrace/blob/main/src/harness/include/harness/os.h): |
||
| 8 | - `OS_InstallSignalHandler` |
||
| 9 | - `OS_fopen` |
||
| 10 | - `OS_ConsoleReadPassword` |
||
| 11 | |||
| 12 | 2. Update `src/harness/CMakeLists.h` and add a new conditional section for "os/foo.h", based on existing conditions for Windows, MacOS etc. |
||
| 13 | |||
| 14 | For example: |
||
| 15 | |||
| 16 | ``` |
||
| 17 | ... |
||
| 18 | elseif( _FOO_ ) |
||
| 19 | target_sources(harness PRIVATE |
||
| 20 | os/foo.c |
||
| 21 | ) |
||
| 22 | ... |
||
| 23 | ``` |
||
| 24 | |||
| 25 | ## IO Platform (windowing / input / rendering) |
||
| 26 | |||
| 27 | A `Platform` in _dethrace_ implements windowing, rendering and input handling. |
||
| 28 | |||
| 29 | The default platform is `SDL_OpenGL`, which uses SDL for windowing and input, and OpenGL for rendering. See [platforms/sdl_opengl.c](https://github.com/dethrace-labs/dethrace/blob/main/src/harness/platforms/sdl_opengl.c). |
||
| 30 | |||
| 31 | To add a new `Platform`: |
||
| 32 | |||
| 33 | 1. Create `platforms/my_platform.c` file and add a `Harness_Platform_Init` function. Hook up all the function pointers using the `sdl_opengl` [implementation](https://github.com/dethrace-labs/dethrace/blob/main/src/harness/platforms/sdl_opengl.h) as a guide. |
||
| 34 | |||
| 35 | 2. Add a new conditional section in `src/harness/CMakeLists.txt` for your new platform |
||
| 36 | |||
| 37 | For example: |
||
| 38 | ``` |
||
| 39 | if (IO_PLATFORM STREQUAL "My_Platform") |
||
| 40 | target_sources(harness PRIVATE |
||
| 41 | io_platforms/my_platform.c |
||
| 42 | ) |
||
| 43 | endif() |
||
| 44 | ``` |
||
| 45 | |||
| 46 | 3. Run cmake to update your build with the new platform |
||
| 47 | ```sh |
||
| 48 | cd build |
||
| 49 | cmake -DIO_PLATFORM=My_Platform .. |
||
| 50 | ``` |
||
| 51 | |||
| 52 | 4. Build |
||
| 53 | ``` |
||
| 54 | cmake --build . |
||
| 55 | ``` |