Skip to content

Commit

Permalink
Store displayIds
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Oct 1, 2024
1 parent 7b27b2b commit bea8051
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/FNAPlatform/SDL3_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ out h
if (center)
{
// FIXME CSHARP: SDL_WINDOWPOS_CENTERED_DISPLAY
// FIXME SDL3: I dunno if I like this +1...
int pos = 0x2FFF0000 | (displayIndex + 1);
int pos = (int) (0x2FFF0000 | displayIds[displayIndex]);
SDL.SDL_SetWindowPosition(
window,
pos,
Expand Down Expand Up @@ -1218,11 +1217,15 @@ private static void RunEmscriptenMainLoop()

#region Graphics Methods

// FIXME SDL3: This is really sloppy -flibit
private static uint[] displayIds;

public static GraphicsAdapter[] GetGraphicsAdapters()
{
int numDisplays;
uint* displays = (uint*) SDL.SDL_GetDisplays(out numDisplays);
GraphicsAdapter[] adapters = new GraphicsAdapter[numDisplays];
displayIds = new uint[numDisplays];
for (int i = 0; i < adapters.Length; i += 1)
{
List<DisplayMode> modes = new List<DisplayMode>();
Expand Down Expand Up @@ -1256,15 +1259,15 @@ public static GraphicsAdapter[] GetGraphicsAdapters()
@"\\.\DISPLAY" + (i + 1).ToString(),
SDL.SDL_GetDisplayName(displays[i])
);
displayIds[i] = displays[i];
}
SDL.SDL_free((IntPtr) displays);
return adapters;
}

public static DisplayMode GetCurrentDisplayMode(int adapterIndex)
{
// FIXME SDL3: I dunno if I like this +1...
SDL.SDL_DisplayMode *mode = (SDL.SDL_DisplayMode*) SDL.SDL_GetCurrentDisplayMode((uint) adapterIndex + 1);
SDL.SDL_DisplayMode *mode = (SDL.SDL_DisplayMode*) SDL.SDL_GetCurrentDisplayMode(displayIds[adapterIndex]);

// FIXME: iOS needs to factor in the DPI!

Expand Down

0 comments on commit bea8051

Please sign in to comment.