Skip to content

Commit

Permalink
Stuff boots!
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Oct 1, 2024
1 parent f0202fe commit 1576658
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/SDL3-CS
Submodule SDL3-CS updated 1 files
+1 −255 SDL3/SDL3.cs
30 changes: 22 additions & 8 deletions src/FNAPlatform/SDL3_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,11 @@ public static GraphicsAdapter RegisterGame(Game game)
activeGames.Add(game);

// Which display did we end up on?
uint displayIndex = SDL.SDL_GetDisplayForWindow(
uint displayId = SDL.SDL_GetDisplayForWindow(
game.Window.Handle
) - 1;
return GraphicsAdapter.Adapters[(int) displayIndex];
);
int displayIndex = FetchDisplayIndex(displayId);
return GraphicsAdapter.Adapters[displayIndex];
}

public static void UnregisterGame(Game game)
Expand Down Expand Up @@ -1014,9 +1015,10 @@ ref bool textInputSuppress
* display, a GraphicsDevice Reset occurs.
* -flibit
*/
int newIndex = (int) SDL.SDL_GetDisplayForWindow(
uint newId = SDL.SDL_GetDisplayForWindow(
game.Window.Handle
) - 1;
);
int newIndex = FetchDisplayIndex(newId);

if (newIndex >= GraphicsAdapter.Adapters.Count)
{
Expand Down Expand Up @@ -1049,10 +1051,11 @@ ref bool textInputSuppress
{
GraphicsAdapter.AdaptersChanged();

uint displayIndex = SDL.SDL_GetDisplayForWindow(
uint displayId = SDL.SDL_GetDisplayForWindow(
game.Window.Handle
) - 1;
currentAdapter = GraphicsAdapter.Adapters[(int) displayIndex];
);
int displayIndex = FetchDisplayIndex(displayId);
currentAdapter = GraphicsAdapter.Adapters[displayIndex];

// Orientation Change
if (evt.type == (uint) SDL.SDL_EventType.SDL_EVENT_DISPLAY_ORIENTATION)
Expand Down Expand Up @@ -1212,6 +1215,17 @@ private static void RunEmscriptenMainLoop()

// FIXME SDL3: This is really sloppy -flibit
private static uint[] displayIds;
private static int FetchDisplayIndex(uint id)
{
for (int i = 0; i < displayIds.Length; i += 1)
{
if (id == displayIds[i])
{
return i;
}
}
throw new InvalidOperationException();
}

public static GraphicsAdapter[] GetGraphicsAdapters()
{
Expand Down

0 comments on commit 1576658

Please sign in to comment.