Skip to content

Commit

Permalink
Updated to SDL 2.30.8
Browse files Browse the repository at this point in the history
  • Loading branch information
JunaMeinhold committed Oct 20, 2024
1 parent e5d5a5b commit d7a8624
Show file tree
Hide file tree
Showing 50 changed files with 33,504 additions and 31,928 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-sdl2-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Upload Artifacts
uses: actions/upload-artifact@v4.3.4
with:
name: sdl2-${{ matrix.os }}-${{ matrix.arch }}-artifacts
name: sdl2-android-latest-all-artifacts
path: |
SDL/build/arm64-v8a/*.so
SDL/build/x86_64/*.so
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/cmake-sdl2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,30 @@ jobs:
- name: Configure cimgui with CMake on Linux (x86_64)
if: matrix.os == 'linux' || matrix.os == 'ubuntu-latest'
run: cmake -S SDL -B SDL/build
run: cmake -S SDL -B SDL/build -DSDL_STATIC=OFF -DSDL_SHARED=ON

- name: Configure SDL2 with CMake for macOS ARM64
if: matrix.os == 'macos-latest'
run: cmake -S SDL -B SDL/build -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake-arch }} -DSDL_STATIC=OFF -DSDL_SHARED=ON

- name: Configure cimgui with CMake for Windows
if: matrix.os == 'windows-latest'
run: cmake -S SDL -B SDL/build -A ${{ matrix.cmake-arch }}
run: cmake -S SDL -B SDL/build -A ${{ matrix.cmake-arch }} -DSDL_STATIC=OFF -DSDL_SHARED=ON

- name: Build SDL2
run: cmake --build SDL/build --config Release

- name: Move Windows binaries
if: matrix.os == 'windows-latest'
run: |
mv SDL/build/Release/*.dll SDL/build/
- name: Upload Artifacts
uses: actions/upload-artifact@v4.3.4
with:
name: sdl2-${{ matrix.os }}-${{ matrix.arch }}-artifacts
path: |
SDL/build/Release/*.dll
SDL/build/*.dll
SDL/build/*.so
SDL/build/*.dylib
if-no-files-found: ignore # 'warn' or 'ignore' or 'error'
4 changes: 4 additions & 0 deletions ExampleAndroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yourcompany.yourapp">
<application android:icon="@mipmap/icon" />
</manifest>
26 changes: 26 additions & 0 deletions ExampleAndroid/ExampleAndroid.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<None Remove="libc++_shared.so" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.13.1.3" />
<PackageReference Include="Hexa.NET.SDL2" Version="1.2.4" />
<PackageReference Include="Hexa.NET.Utilities" Version="2.1.5" />
</ItemGroup>





</Project>
97 changes: 97 additions & 0 deletions ExampleAndroid/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
namespace ExampleAndroid
{
using Android.Content.PM;
using Android.Runtime;
using Hexa.NET.SDL2;
using Hexa.NET.Utilities;
using System.Runtime.InteropServices;

[Activity(Label = "ExampleAndroid", MainLauncher = true, Icon = "@mipmap/icon", Theme = "@style/AppTheme")]
public unsafe class MainActivity : Activity
{
private Thread thread;

protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
RunOnUiThread(() =>
{
SDL.SetHint(SDL.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
SDL.SetHint(SDL.SDL_HINT_AUTO_UPDATE_JOYSTICKS, "1");
SDL.SetHint(SDL.SDL_HINT_JOYSTICK_HIDAPI_PS4, "1");//HintJoystickHidapiPS4
SDL.SetHint(SDL.SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); //HintJoystickHidapiPS4Rumble
SDL.SetHint(SDL.SDL_HINT_JOYSTICK_RAWINPUT, "0");
SDL.SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1"); //HintWindowsDisableThreadNaming
SDL.SetHint(SDL.SDL_HINT_MOUSE_NORMAL_SPEED_SCALE, "1");
SDL.SetHint(SDL.SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
SDL.SetHint(SDL.SDL_HINT_IME_SHOW_UI, "1");
SDL.Init(SDL.SDL_INIT_EVENTS + SDL.SDL_INIT_GAMECONTROLLER + SDL.SDL_INIT_HAPTIC + SDL.SDL_INIT_JOYSTICK + SDL.SDL_INIT_SENSOR);
thread = new Thread(NewMethod);
thread.Start();
});
}

private static void NewMethod()
{
var window = SDL.CreateWindow("Test Window", (int)SDL.SDL_WINDOWPOS_UNDEFINED_MASK, (int)SDL.SDL_WINDOWPOS_UNDEFINED_MASK, 1280, 720, (uint)SDLWindowFlags.Resizable);
var windowId = SDL.GetWindowID(window);

SDLRenderer* renderer = SDL.CreateRenderer(window, -1, (uint)SDLRendererFlags.Accelerated);

UnsafeList<SDLVertex> verts =
[
new(new SDLFPoint( 400, 150 ), new SDLColor( 255, 0, 0, 255 ), new SDLFPoint( 0 ) ),
new(new SDLFPoint( 200, 450 ), new SDLColor( 0, 0, 255, 255 ), new SDLFPoint( 0 ) ),
new(new SDLFPoint( 600, 450 ), new SDLColor( 0, 255, 0, 255 ), new SDLFPoint( 0 ) ),
];

SDLEvent sdlEvent = default;
bool exiting = false;
while (!exiting)
{
SDL.PumpEvents();

while ((SDLBool)SDL.PollEvent(ref sdlEvent) == SDLBool.True)
{
switch ((SDLEventType)sdlEvent.Type)
{
case SDLEventType.Quit:
exiting = true;
break;

case SDLEventType.AppTerminating:
exiting = true;
break;

case SDLEventType.Windowevent:
var windowEvent = sdlEvent.Window;
if (windowEvent.WindowID == windowId)
{
if ((SDLWindowEventID)windowEvent.Event == SDLWindowEventID.Close)
{
exiting = true;
}
}
break;
}
}

SDL.RenderClear(renderer);

SDL.SetRenderTarget(renderer, null);
SDL.RenderGeometry(renderer, null, verts.Data, verts.Size, null, 0);

SDL.RenderPresent(renderer);
}
}

protected override void OnDestroy()
{
base.OnDestroy();
SDL.Quit();
thread.Join();
}
}
}
Binary file added ExampleAndroid/Resources/mipmap/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ExampleAndroid/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Customize your theme here -->
</style>
</resources>
2 changes: 1 addition & 1 deletion Generator/Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HexaGen" Version="1.1.4" />
<PackageReference Include="HexaGen" Version="1.1.9-rc11" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CsCodeGenerator generator = new(config);
generator.PatchEngine.RegisterPrePatch(new NamingPatch(["SDL"], NamingPatchOptions.None));
generator.PatchEngine.RegisterPrePatch(new EnumNamePatch());
generator.LogEvent += (s, m) => Console.WriteLine($"{s}: {m}");
generator.LogToConsole();
generator.Generate(["include/main.h"], "../../../../Hexa.NET.SDL2/Generated");

public class EnumNamePatch : PrePatch
Expand Down
2 changes: 1 addition & 1 deletion Generator/generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"GenerateSizeOfStructs": false,
"GeneratePlaceholderComments": false,
"GenerateMetadata": true,
"ImportType": "VTable",
"ImportType": "FunctionTable",
"IncludeFolders": [
"C:\\VulkanSDK\\1.3.250.0\\Include\\"
],
Expand Down
1 change: 1 addition & 0 deletions Generator/include/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ extern "C" {
* Since it's driver-specific, it's only supported where possible and
* implemented. Currently supported the following drivers:
*
* - Wayland (wayland)
* - KMSDRM (kmsdrm)
* - Raspberry Pi (raspberrypi)
*/
Expand Down
2 changes: 1 addition & 1 deletion Generator/include/SDL_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 30
#define SDL_PATCHLEVEL 6
#define SDL_PATCHLEVEL 8

/**
* Macro to determine SDL version program was compiled against.
Expand Down
10 changes: 9 additions & 1 deletion Hexa.NET.SDL2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Generator", "Generator\Gene
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "Example\Example.csproj", "{FD826B07-B533-4229-AF02-6D1734E64044}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleImGui", "ExampleImGui\ExampleImGui.csproj", "{38502E55-8C18-4B2B-851D-D3533AE25003}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleImGui", "ExampleImGui\ExampleImGui.csproj", "{38502E55-8C18-4B2B-851D-D3533AE25003}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleAndroid", "ExampleAndroid\ExampleAndroid.csproj", "{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -33,6 +35,12 @@ Global
{38502E55-8C18-4B2B-851D-D3533AE25003}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38502E55-8C18-4B2B-851D-D3533AE25003}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38502E55-8C18-4B2B-851D-D3533AE25003}.Release|Any CPU.Build.0 = Release|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Release|Any CPU.Build.0 = Release|Any CPU
{0F0F9B1E-C6AE-43F1-9936-A3ADEDDCBCD9}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 1 addition & 6 deletions Hexa.NET.SDL2/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@

#if NET7_0_OR_GREATER
[assembly: System.Runtime.CompilerServices.DisableRuntimeMarshalling]
#endif

[assembly: NativeLibrary("SDL2", TargetPlatform.Windows)]
[assembly: NativeLibrary("libSDL2-2.0", TargetPlatform.Linux)]
[assembly: NativeLibrary("libSDL2-2.0", TargetPlatform.Android)]
[assembly: NativeLibrary("libSDL2-2.0", TargetPlatform.OSX)]
#endif
4 changes: 2 additions & 2 deletions Hexa.NET.SDL2/Generated/Constants/Constants.000.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,8 @@ public unsafe partial class SDL
public const int SDL_MINOR_VERSION = 30;

[NativeName(NativeNameType.Const, "SDL_PATCHLEVEL")]
[NativeName(NativeNameType.Value, "6")]
public const int SDL_PATCHLEVEL = 6;
[NativeName(NativeNameType.Value, "8")]
public const int SDL_PATCHLEVEL = 8;

[NativeName(NativeNameType.Const, "SDL_INIT_TIMER")]
[NativeName(NativeNameType.Value, "0x00000001u")]
Expand Down
Loading

0 comments on commit d7a8624

Please sign in to comment.