{"id":13805340,"url":"https://github.com/BindBC/bindbc-sdl","last_synced_at":"2025-05-13T19:30:48.283Z","repository":{"id":37458270,"uuid":"124232670","full_name":"BindBC/bindbc-sdl","owner":"BindBC","description":"Static \u0026 dynamic D bindings to SDL and the SDL_* libraries, compatible with BetterC, @nogc, and nothrow.","archived":false,"fork":false,"pushed_at":"2024-11-10T01:28:26.000Z","size":999,"stargazers_count":89,"open_issues_count":1,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-10T02:23:49.389Z","etag":null,"topics":["bindbc","dlang","sdl-image","sdl-mixer","sdl-net","sdl-ttf","sdl2","sdl2-bindings"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BindBC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"BindBC"}},"created_at":"2018-03-07T12:26:50.000Z","updated_at":"2024-11-10T01:28:29.000Z","dependencies_parsed_at":"2024-05-02T09:53:33.513Z","dependency_job_id":"8de7f965-4859-418f-a528-a143b606f5f2","html_url":"https://github.com/BindBC/bindbc-sdl","commit_stats":null,"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-sdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-sdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-sdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-sdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BindBC","download_url":"https://codeload.github.com/BindBC/bindbc-sdl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225254306,"owners_count":17445160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindbc","dlang","sdl-image","sdl-mixer","sdl-net","sdl-ttf","sdl2","sdl2-bindings"],"created_at":"2024-08-04T01:01:00.223Z","updated_at":"2025-05-13T19:30:48.259Z","avatar_url":"https://github.com/BindBC.png","language":"D","funding_links":["https://github.com/sponsors/BindBC"],"categories":["Game Bindings"],"sub_categories":["XML"],"readme":"\u003ch1 align=\"center\" width=\"100%\"\u003e\u003ca href=\"https://git.sleeping.town/BindBC/bindbc-sdl\"\u003e\n\t\u003cimg alt=\"BindBC-SDL logo\" width=\"50%\" src=\"https://git.sleeping.town/BindBC/bindbc-branding/media/branch/trunk/logo_wide_sdl.png\"/\u003e\n\u003c/a\u003e\u003c/h1\u003e\n\n[Official git repository](https://git.sleeping.town/BindBC/bindbc-sdl)\n\nThis project provides a set of both static and dynamic bindings to\n[SDL3 (Simple DirectMedia Layer)](https://libsdl.org/) and its official extension libraries. They are compatible with `@nogc` and `nothrow`, and can be compiled with BetterC compatibility.\n\nIf you still need SDL2 bindings, they are available in the [SDL2](https://git.sleeping.town/BindBC/bindbc-sdl/src/branch/SDL2) branch with versions tagged 1.X.X.\n\n| Table of Contents |\n|-------------------|\n|[License](#license)|\n|[SDL documentation](#sdl-documentation)|\n|[Quickstart guide](#quickstart-guide)|\n|[Binding-specific changes](#binding-specific-changes)|\n|[Configurations](#configurations)|\n|[Library versions](#library-versions)|\n|[Special platforms](#special-platforms)|\n|[Gesture API](#gesture-api)|\n|[Entry points](#entry-points)|\n\n## License\nBindBC-SDL\u0026mdash;as well as every other binding in the [BindBC project](https://git.sleeping.town/BindBC)\u0026mdash;is licensed under the [Boost Software License](https://www.boost.org/LICENSE_1_0.txt).\n\nBear in mind that you still need to abide by [SDL's license](https://github.com/libsdl-org/SDL/blob/main/LICENSE.txt), and the licenses of any SDL_* libraries that you use through these bindings.\n\n## SDL documentation\nThis readme describes how to use BindBC-SDL, *not* SDL itself. BindBC-SDL is a direct D binding to the SDL3 API, so any existing SDL 3documentation and tutorials can be adapted with only minor modifications.\n* [The SDL Wiki](https://wiki.libsdl.org/SDL3/APIByCategory) has official documentation of the SDL API. It also has [a list of tutorials](https://wiki.libsdl.org/SDL3/Tutorials).\n* [Layers All The Way Down](https://moonside.games/posts/layers-all-the-way-down/) has a broad explanation of rendering and SDL3's GPU API.\n* [How to migrate from SDL 2.0](https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md).\n* [Lazy Foo' Productions' SDL3 tutorials](https://lazyfoo.net/tutorials/SDL3/index.php) are aimed at C++ programmers, and give a good overview of the SDL3 API.\n\n## Quickstart guide\nTo use BindBC-SDL in your dub project, add it to the list of `dependencies` in your dub configuration file. The easiest way is by running `dub add bindbc-sdl` in your project folder. The result should look like this:\n\nExample __dub.json__\n```json\n\"dependencies\": {\n\t\"bindbc-sdl\": \"~\u003e2.0\",\n},\n```\nExample __dub.sdl__\n```sdl\ndependency \"bindbc-sdl\" version=\"~\u003e2.0\"\n```\n\nBy default, BindBC-SDL is configured to compile as a dynamic binding that is not BetterC-compatible. If you prefer static bindings or need BetterC compatibility, they can be enabled via `subConfigurations` in your dub configuration file. For configuration naming \u0026 more details, see [Configurations](#configurations).\n\nExample __dub.json__\n```json\n\"subConfigurations\": {\n\t\"bindbc-sdl\": \"staticBC\",\n},\n```\nExample __dub.sdl__\n```sdl\nsubConfiguration \"bindbc-sdl\" \"staticBC\"\n```\n\nIf you need to use the SDL_* libraries, or versions of SDL newer than 3.2.0, then you will have to add the appropriate version identifiers to `versions` in your dub configuration. For a list of library version identifiers, see [Library versions](#library-versions).\n\nIf you're using static bindings, then you will also need to add the name of each library you're using to `libs`.\n\nExample __dub.json__\n```json\n\"versions\": [\n\t\"SDL_3_4\", \"SDL_Net_3_0\",\n],\n\"libs\": [\n\t\"SDL3\", \"SDL3_net\",\n],\n```\nExample __dub.sdl__\n```sdl\nversions \"SDL_3_4\" \"SDL_Net_3_0\"\nlibs \"SDL3\" \"SDL3_net\"\n```\n\n**If you're using static bindings**: `import bindbc.sdl` in your code, and then you can use all of SDL just like you would in C. That's it!\n```d\nimport bindbc.sdl;\n\nvoid main(){\n\tSDL_Init(SDL_INIT_VIDEO);\n\t\n\t//etc.\n\t\n\tSDL_Quit();\n}\n```\n\n**If you're using dynamic bindings**: you need to load each library you need with the appropriate load function:\n| Function           | Library        |\n|--------------------|----------------|\n|`loadSDL`           | SDL            |\n|`loadSDLImage`      | SDL_image      |\n|`loadSDLMixer`      | SDL_mixer      |\n|`loadSDLNet`        | SDL_net        |\n|`loadSDLTTF`        | SDL_ttf        |\n|`loadSDLShaderCross`| SDL_shadercross|\n\nFor most use cases, it's best to use BindBC-Loader's [error handling API](https://git.sleeping.town/BindBC/bindbc-loader#error-handling) to see if there were any errors while loading the libraries. This information can be written to a log file before aborting the program.\n\nThe load function will also return a member of the `LoadMsg` enum, which can be used for debugging:\n\n- `noLibrary` means the library couldn't be found.\n- `badLibrary` means there was an error while loading the library.\n- `success` means that the library was loaded without any errors.\n\nYou should also check that the desired minimum version of the library was loaded with the appropriate function:\n| Function              | Library        |\n|-----------------------|----------------|\n|`SDL_GetVersion`       | SDL            |\n|`IMG_Version`          | SDL_image      |\n|`Mix_Version`          | SDL_mixer      |\n|`SDLNet_Version`       | SDL_net        |\n|`TTF_Version`          | SDL_ttf        |\n\nUnfortunately SDL_shadercross does not provide a function for this.\n\nHere's a simple example using only the load function's return value:\n\n```d\nimport bindbc.sdl;\nimport bindbc.loader;\n\n/*\nThis code attempts to load the SDL shared library using\nwell-known variations of the library name for the host system.\n*/\nLoadMsg ret = loadSDL();\nif(ret != LoadMsg.success){\n\t/*\n\tError handling. For most use cases, it's best to use the error handling API in\n\tBindBC-Loader to retrieve error messages for logging and then abort.\n\tIf necessary, it's possible to determine the root cause via the return value:\n\t*/\n\tif(ret == LoadMsg.noLibrary){\n\t\t//The SDL shared library failed to load\n\t}else if(ret == LoadMsg.badLibrary){\n\t\t/*\n\t\tOne or more symbols failed to load. The likely cause is that\n\t\tthe shared library is for a lower version than BindBC-SDL was\n\t\tconfigured to load.\n\t\t*/\n\t}\n}\n\n/*\nThis code attempts to load the SDL library using a user-supplied file name.\nUsually, the name and/or path used will be platform specific, as in this\nexample which attempts to load `sdl3.dll` from the `libs` subdirectory,\nrelative to the executable, only on Windows.\n*/\nversion(Windows) loadSDL(\"libs/sdl3.dll\");\n```\n\n[The error handling API](https://git.sleeping.town/BindBC/bindbc-loader#error-handling) in BindBC-Loader can be used to log error messages:\n```d\nimport bindbc.sdl;\n\n/*\nImport the sharedlib module for error handling. Assigning an alias ensures that the\nfunction names do not conflict with other public APIs. This isn't strictly necessary,\nbut the API names are common enough that they could appear in other packages.\n*/\nimport loader = bindbc.loader.sharedlib;\n\nbool loadLib(){\n\tLoadMsg ret = loadSDL();\n\tif(ret != LoadMsg.success){\n\t\t//Log the error info\n\t\tforeach(info; loader.errors){\n\t\t\t/*\n\t\t\tA hypothetical logging function. Note that `info.error` and\n\t\t\t`info.message` are null-terminated `const(char)*`, not `string`.\n\t\t\t*/\n\t\t\tlogError(info.error, info.message);\n\t\t}\n\t\t\n\t\t//Optionally construct a user-friendly error message for the user\n\t\tstring msg;\n\t\tif(ret == LoadMsg.noLibrary){\n\t\t\tmsg = \"This application requires the SDL library.\";\n\t\t}else{\n\t\t\tSDL_version version_;\n\t\t\tSDL_GetVersion(\u0026version_);\n\t\t\tmsg = \"Your SDL version is too low: \"~\n\t\t\t\titoa(version_.major)~\".\"~\n\t\t\t\titoa(version_.minor)~\".\"~\n\t\t\t\titoa(version_.patch)~\n\t\t\t\t\". Please upgrade to 3.4.0+.\";\n\t\t}\n\t\t//A hypothetical message box function\n\t\tshowMessageBox(msg);\n\t\treturn false;\n\t}\n\treturn true;\n}\n```\n\n## Binding-specific changes\nEnums are available both in their original C-style `UPPER_SNAKE_CASE` form, and as the D-style `PascalCase.camelCase`. Both variants are enabled by default, but can be selectively chosen using the version identifiers `SDL_C_Enums_Only` or `SDL_D_Enums_Only` respectively.\n\n\u003e [!TIP]\\\n\u003e The version identifiers `BindBC_C_Enums_Only` and `BindBC_D_Enums_Only` can be used to configure all of the applicable _official_ BindBC packages used in your program. Package-specific version identifiers override this.\n\n`camelCase`d variants are available for struct fields using `snake_case` or `lowercase`.\n\n## Configurations\nBindBC-SDL has the following configurations:\n\n|      ┌      |  DRuntime  |   BetterC   |\n|-------------|------------|-------------|\n| **Dynamic** | `dynamic`  | `dynamicBC` |\n| **Static**  | `static`   | `staticBC`  |\n\nFor projects that don't use dub, if BindBC-SDL is compiled for static bindings then the version identifier `BindSDL_Static` must be passed to your compiler when building your project.\n\n\u003e [!TIP]\\\n\u003e The version identifier `BindBC_Static` can be used to configure all of the _official_ BindBC packages used in your program. (i.e. those maintained in [the BindBC GitHub organisation](https://git.sleeping.town/BindBC)) Some third-party BindBC packages may support it as well.\n\n### Dynamic bindings\nThe dynamic bindings have no link-time dependency on the SDL libraries, so the SDL shared libraries must be manually loaded at runtime from the shared library search path of the user's system.\nOn Windows, this is typically handled by distributing the SDL DLLs with your program.\nOn other systems, it usually means installing the SDL shared libraries through a package manager.\n\nIt is recommended that you always select the minimum version you require _and no higher_.\nIf a lower version is loaded then it's still possible to call functions available in that lower version, but any calls to functions from versions between that version and the one you configured will result in a null pointer access.\nFor example, if you configured SDL to 3.6.0 (`SDL_3_6`) but loaded SDL 3.2.0 at runtime, then any function pointers from 3.6.0 and 3.4.0 will be `null`. For this reason, it's recommended to always specify your required version of the SDL library at compile time and unconditionally abort when you receive an `LoadMsg.badLibrary` return value from `loadSDL` (or equivalent).\n\nThe function `isSDLLoaded` returns `true` if any version of the shared library has been loaded and `false` if not. `unloadSDL` can be used to unload a successfully loaded shared library. The SDL_* libraries provide similar functions: `isSDLImageLoaded`, `unloadSDLImage`, etc.\n\n### Static bindings\nStatic _bindings_ do not require static _linking_. The static bindings have a link-time dependency on either the shared _or_ static SDL libraries and any satellite SDL libraries the program uses. On Windows, you can link with the static libraries or, to use the DLLs, the import libraries. On other systems, you can link with either the static libraries or directly with the shared libraries.\n\nWhen linking with the shared (or import) libraries, there is a runtime dependency on the shared library just as there is when using the dynamic bindings. The difference is that the shared libraries are no longer loaded manually\u0026mdash;loading is handled automatically by the system when the program is launched. Attempting to call `loadSDL` with the static bindings enabled will result in a compilation error.\n\nStatic linking requires the SDL development packages be installed on your system. The [SDL releases page](https://github.com/libsdl-org/SDL/releases) provides development packages for Windows and macOS. You can also install them via your system's package manager. For example, on Debian-based Linux distributions `sudo apt install libsdl3-dev` will install both the development and runtime packages.\n\nWhen linking with the static libraries, there is no runtime dependency on SDL. The SDL homepage does not distribute pre-compiled static libraries. If you decide to obtain static libraries from another source (usually by compiling them yourself) you will also need to ensure that you link with all of SDL's link-time dependencies (such as the OpenGL library and system API libraries).\n\n## Library versions\nThese are the supported versions of each SDL_* library, along with the corresponding version identifiers to add to your dub recipe's `versions` list, or pass directly to the compiler.\n\nIt is necessary to specify only a single version identifier per library. For example, `SDL_Image_3_2` by itself will activate the SDL_image binding.\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003ch3\u003eSDL versions\u003c/h3\u003e\u003c/summary\u003e\n\n| Version     |Version identifier|\n|-------------|------------------|\n| 3.2.0       | (none; default)  |\n| 3.2.4       | `SDL_3_2_4`      |\n| 3.2.6       | `SDL_3_2_6`      |\n| 3.2.10      | `SDL_3_2_10`     |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch3\u003eSDL_image versions\u003c/h3\u003e\u003c/summary\u003e\n\n| Version |Version identifier| Public API updated |\n|---------|------------------|--------------------|\n| 3.2.0   | `SDL_Image_3_2`  |                    |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch3\u003eSDL_mixer versions\u003c/h3\u003e\u003c/summary\u003e\n\n\n\u003e [!NOTE]\\\n\u003e These bindings are based on [this commit](https://github.com/libsdl-org/SDL_mixer/commit/af6a29df4e14c6ce72608b3ccd49cf35e1014255). SDL_mixer 3.X has not officially released yet. The API of these bindings \u0026 the version identifier used to activate them will change when SDL_mixer 3.X is officially released.\n\n| Version |Version identifier| Public API updated |\n|---------|------------------|--------------------|\n| 3.0.0   | `SDL_Mixer_3_0`  |                    |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch3\u003eSDL_net versions\u003c/h3\u003e\u003c/summary\u003e\n\n\n\u003e [!NOTE]\\\n\u003e These bindings are based on [this commit](https://github.com/libsdl-org/SDL_net/commit/f02213ba76be2f091778b5a9aab5afe218f3ca7f). SDL_net 3.X has not officially released yet. The API of these bindings \u0026 the version identifier used to activate them will change when SDL_net 3.X is officially released.\n\n| Version |Version identifier| Public API updated |\n|---------|------------------|--------------------|\n| 3.0.0   | `SDL_Net_3_0`    |                    |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch3\u003eSDL_ttf versions\u003c/h3\u003e\u003c/summary\u003e\n\n| Version |Version identifier| Public API updated |\n|---------|------------------|--------------------|\n| 3.2.0   | `SDL_TTF_3_2`    |                    |\n| 3.2.2   | `SDL_TTF_3_2_2`  | :heavy_check_mark: |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch3\u003eSDL_shadercross versions\u003c/h3\u003e\u003c/summary\u003e\n\n\n\u003e [!NOTE]\\\n\u003e These bindings are based on [this commit](https://github.com/libsdl-org/SDL_shadercross/commit/a1bc850a6c32d5186d84dfd00701dd35858e309d). SDL_shadercross has no versioned releases yet. The API of these bindings \u0026 the version identifier used to activate them may change if/when SDL_shadercross recieves its first versioned release.\n\n| Version | Version identifier    | Public API updated |\n|---------|-----------------------|--------------------|\n| 3.0.0   | `SDL_ShaderCross_3_0` |                    |\n\n\u003c/details\u003e\n\n## Special platforms\nSome platforms do not have [pre-defined versions in D](https://dlang.org/spec/version.html#predefined-versions), meaning that BindBC-SDL has to use custom version identifiers for them. When you wish to compile for one of these platforms, please supply the corresponding version identifier to the compiler.\n\n| Platform                       | Version identifier |\n|--------------------------------|--------------------|\n| Nintendo 3DS                   | `_3DS`             |\n| Microsoft Game Development Kit | `GDK`              |\n| Sony Vita                      | `Vita`             |\n| Sony PSP                       | `PSP`              |\n\n## Gesture API\nSDL2's gesture API was removed from SDL3 and made available as a header-only library called [SDL_gesture](https://github.com/libsdl-org/SDL_gesture). BindBC-SDL contains a full D translation of SDL_gesture, which you can enable by adding the version identifier `SDL_Gesture` in your dub recipe's `versions` list, or by passing it directly to the compiler.\n\nSDL_gesture does not have versioned releases. The D translation of it BindBC-SDL up-to-date with [this commit](https://github.com/libsdl-org/SDL_gesture/commit/91b42083a7dcb60007f15f5e1600f0c04c8e814e).\n\n## Entry points\nIt is recommended that you read this first: [README-main-functions.md](https://github.com/libsdl-org/SDL/blob/main/docs/README-main-functions.md)\n\nFor convenience, `sdl.main` (equivalent to `SDL_main.h`) is imported by default. However, in BindBC-SDL having your entry point replaced by `sdl.main` is opt-*in* rather than opt-*out*. See more information below.\n\n### Replacing the main entry point\nIf you want SDL to replace your entry point, you will have to wrap your main function's parameter names \u0026 body in a mixin of `makeSDLMain`. Doing so is the equivalent of using `#include \u003cSDL3/SDL_main.h\u003e` in C *without* defining `SDL_MAIN_NOIMPL`.\n```d\nenum dynLoadSDL = q{\n\tLoadMsg ret = loadSDL();\n\tif(ret != LoadMsg.success){\n\t\timport core.stdc.stdio, bindbc.loader;\n\t\tforeach(error; bindbc.loader.errors){\n\t\t\tprintf(\"%s\\n\", error.message);\n\t\t}\n\t}};\nmixin(makeSDLMain(q{argC}, q{argV}, dynLoadSDL, dynLoadSDL~q{\n\timport core.stdc.stdio;\n\tforeach(argument; argV[0..argC]){\n\t\tprintf(\"%s\\n\", argument);\n\t}\n\treturn 0;\n}));\n```\n\u003e [!WARNING]\\\n\u003e When using this feature, your provided main function will always be `extern(C) nothrow`, take `(int, char**)` as its parameters, and must return `int`. If you're not using BetterC, then an `extern(C)` main function means that DRuntime will not be initialised, and so if you want to use any DRuntime features then you will have to research \u0026 re-implement what DRuntime usually does for you before calling your main function. For this reason, using SDL's entry point with DRuntime is not advised for inexperienced programmers.\n\u003e\n\u003e To learn more, see the [`extern(C) main()` spec](https://dlang.org/spec/function.html#betterc-main).\n\n\u003e [!IMPORTANT]\\\n\u003e When using dynamic bindings, `makeSDLMain`'s third argument (`dynLoad`) must be a string with code to load SDL (and handle any loader errors). It can be left blank as long as you ONLY use the static bindings. Unless SDL overrides your main function or you're using static bindings, the code in `dynLoad` will be prepended to your main function.\n\n### Callback entry points\nIf you want to use the callback entry points (or 'main callbacks'), then you also need to use version identifier `SDL_MainUseCallbacks`. When using callback functions, only the `dynLoad` parameter of `makeSDLMain` is used. As a side-effect, this means that you can safely write code in your main body that depends on `SDL_MainUseCallbacks` not being in-use.\n\nHere's an example that initialises \u0026 terminates DRuntime, and has basic exception handling.\n```\nimport core.runtime, core.stdc.stdio;\n\nmixin(makeSDLMain(dynLoad: q{\n\tLoadMsg ret = loadSDL();\n\tif(ret != LoadMsg.success){\n\t\timport core.stdc.stdio, bindbc.loader;\n\t\tforeach(error; bindbc.loader.errors){\n\t\t\tprintf(\"%s\\n\", error.message);\n\t\t}\n\t}})); //makeSDLMain's parameters are optional\n\nversion SDL_MainUseCallbacks{\n\textern(C) SDL_AppResult SDL_AppInit(void** state, int argC, char** argV) nothrow{\n\t\ttry{\n\t\t\tif(!rt_init()) return SDL_AppResult.failure;\n\t\t}catch(Exception ex){\n\t\t\treturn SDL_AppResult.failure;\n\t\t}\n\t\treturn SDL_AppResult.continue_;\n\t}\n\t\n\textern(C) SDL_AppResult SDL_AppIterate(void* state) nothrow{\n\t\ttry{\n\t\t\t/*\n\t\t\tPut your code that can throw exceptions here!\n\t\t\t*/\n\t\t}catch(Throwable t){\n\t\t\tvoid sink(in char[] buf) scope nothrow{\n\t\t\t\tfwrite(buf.ptr, char.sizeof, buf.length, stderr);\n\t\t\t}\n\t\t\tdo{\n\t\t\t\ttry t.toString(\u0026sink);\n\t\t\t\tcatch(Exception) return SDL_AppResult.failure;\n\t\t\t}while((t = t.next) !is null);\n\t\t\tprintf(\"\\n\");\n\t\t\treturn SDL_AppResult.failure;\n\t\t}\n\t\treturn SDL_AppResult.success;\n\t}\n\t\n\textern(C) SDL_AppResult SDL_AppEvent(void* state, SDL_Event* event) nothrow =\u003e SDL_AppResult.continue_;\n\t\n\textern(C) void SDL_AppQuit(void*, SDL_AppResult result) nothrow{\n\t\ttry rt_term();\n\t\tcatch(Exception ex){}\n\t}\n}\n```\n\u003e [!NOTE]\\\n\u003e This example code does **NOT** support unittests, doesn't run any module constructors/destructors, and does not support `--DRT` command-line parameters. Look at how DRuntime implements these features if you need them (or any other DRuntime features) in your project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBindBC%2Fbindbc-sdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBindBC%2Fbindbc-sdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBindBC%2Fbindbc-sdl/lists"}