From ce5cb5da0e5d828203d7463a766d375dc8cc2075 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 20 Jun 2025 01:49:35 +0900 Subject: [PATCH] Load SDL3 when using `SDL_image` or `SDL_ttf` members --- SDL3_image-CS/SDL3_image/SDL_image.cs | 9 +++++++++ SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/SDL3_image-CS/SDL3_image/SDL_image.cs b/SDL3_image-CS/SDL3_image/SDL_image.cs index 275bf23..8910191 100644 --- a/SDL3_image-CS/SDL3_image/SDL_image.cs +++ b/SDL3_image-CS/SDL3_image/SDL_image.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Runtime.CompilerServices; namespace SDL { @@ -21,5 +22,13 @@ namespace SDL { [Constant] public static readonly int SDL_IMAGE_VERSION = SDL3.SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_MICRO_VERSION); + +#pragma warning disable CA2255 + [ModuleInitializer] + internal static void ModuleInitializer() + { + SDL3.SDL_Init(0); + } +#pragma warning restore CA2255 } } diff --git a/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs b/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs index c1a9b08..3642887 100644 --- a/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs +++ b/SDL3_ttf-CS/SDL3_ttf/SDL_ttf.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Runtime.CompilerServices; namespace SDL { @@ -19,5 +20,13 @@ namespace SDL { [Constant] public static readonly int SDL_TTF_VERSION = SDL3.SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION); + +#pragma warning disable CA2255 + [ModuleInitializer] + internal static void ModuleInitializer() + { + SDL3.SDL_Init(0); + } +#pragma warning restore CA2255 } }