fna-workbench

fna-workbench Commit Details


Date:2016-01-14 08:54:48 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:5a0cd5e43e8f75f5f379a5aea78a7adefe9f53ce
Parents: ad50a2718b39800a5254828fc59489c497ac5d27
Message:GraphicsAdapter now has a real use in FNA

Changes:

File differences

gendarme/sdl2.ignore
8282
8383
8484
85
8586
8687
8788
......
982983
983984
984985
986
985987
986988
987989
M: System.Int32 SDL2.SDL::SDL_GetCurrentDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&)
M: System.String SDL2.SDL::SDL_GetCurrentVideoDriver()
M: System.Int32 SDL2.SDL::SDL_GetDesktopDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&)
M: System.String SDL2.SDL::SDL_GetDisplayName(System.Int32)
M: System.Int32 SDL2.SDL::SDL_GetDisplayBounds(System.Int32,SDL2.SDL/SDL_Rect&)
M: System.Int32 SDL2.SDL::SDL_GetDisplayDPI(System.Int32,System.Single&,System.Single&,System.Single&)
M: System.Int32 SDL2.SDL::SDL_GetDisplayMode(System.Int32,System.Int32,SDL2.SDL/SDL_DisplayMode&)
M: System.Int32 SDL2.SDL::SDL_GetCurrentDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&)
M: System.String SDL2.SDL::SDL_GetCurrentVideoDriver()
M: System.Int32 SDL2.SDL::SDL_GetDesktopDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&)
M: System.String SDL2.SDL::SDL_GetDisplayName(System.Int32)
M: System.Int32 SDL2.SDL::SDL_GetDisplayBounds(System.Int32,SDL2.SDL/SDL_Rect&)
M: System.Int32 SDL2.SDL::SDL_GetDisplayDPI(System.Int32,System.Single&,System.Single&,System.Single&)
M: System.Int32 SDL2.SDL::SDL_GetDisplayMode(System.Int32,System.Int32,SDL2.SDL/SDL_DisplayMode&)
lib/SDL2-CS
1
1
Subproject commit c6fa4d14572783392d4c6bcbcedb5defda5effc7
Subproject commit 9b6f16a23821fadd22da5eb81810410a301c81a3
src/GamePlatform.cs
103103
104104
105105
106
107
108
106
109107
110108
111109
String message
);
public abstract DisplayMode GetCurrentDisplayMode();
public abstract DisplayModeCollection GetDisplayModes();
public abstract GraphicsAdapter[] GetGraphicsAdapters();
public abstract void SetPresentationInterval(PresentInterval interval);
src/Graphics/GraphicsAdapter.cs
2020
2121
2222
23
24
25
26
23
24
2725
2826
2927
3028
31
32
33
34
29
30
3531
3632
3733
3834
39
40
41
42
35
36
4337
4438
4539
......
149143
150144
151145
152
153
154
155
146
156147
157148
158149
......
169160
170161
171162
172
173
163
164
165
166
167
168
169
170
174171
175172
176173
public DisplayMode CurrentDisplayMode
{
get
{
return Game.Instance.Platform.GetCurrentDisplayMode();
}
get;
private set;
}
public DisplayModeCollection SupportedDisplayModes
{
get
{
return Game.Instance.Platform.GetDisplayModes();
}
get;
private set;
}
public string Description
{
get
{
throw new NotImplementedException();
}
get;
private set;
}
public int DeviceId
if (adapters == null)
{
adapters = new ReadOnlyCollection<GraphicsAdapter>(
new GraphicsAdapter[]
{
new GraphicsAdapter()
}
Game.Instance.Platform.GetGraphicsAdapters()
);
}
return adapters;
#region Internal Constructor
internal GraphicsAdapter()
{
internal GraphicsAdapter(
DisplayMode currentMode,
DisplayModeCollection modes,
string description
) {
CurrentDisplayMode = currentMode;
SupportedDisplayModes = modes;
Description = description;
UseNullDevice = false;
UseReferenceDevice = false;
}
src/SDL2/SDL2_GamePlatform.cs
4040
4141
4242
43
44
45
46
47
48
49
5043
5144
5245
......
10497
10598
10699
107
108
109
110
111
112
113100
114101
115102
......
125112
126113
127114
115
116
117
118
119
128120
129121
130122
......
315307
316308
317309
318
319
310
311
312
313
320314
321315
322316
......
429423
430424
431425
432
426
433427
434
435
436
437
438
439
440
441
428
429
430
431
432
433
434
435
436
442437
443
444
445
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
446470
447471
448472
......
822846
823847
824848
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861849
862850
863851
{
class SDL2_GamePlatform : GamePlatform
{
#region Private DisplayMode Variables
private int displayIndex = 0;
private DisplayModeCollection supportedDisplayModes = null;
#endregion
#region Public Constructor
public SDL2_GamePlatform(Game game) : base(game, SDL.SDL_GetPlatform())
forceCoreProfile
);
// Create the DisplayMode list
displayIndex = SDL.SDL_GetWindowDisplayIndex(
game.Window.Handle
);
INTERNAL_GenerateDisplayModes();
// Disable the screensaver.
SDL.SDL_DisableScreenSaver();
{
SDL.SDL_ShowWindow(Game.Window.Handle);
// Which display did we end up on?
int displayIndex = SDL.SDL_GetWindowDisplayIndex(
Game.Window.Handle
);
// OSX has some fancy fullscreen features, let's use them!
bool osxUseSpaces;
if (OSVersion.Equals("Mac OS X"))
if (newIndex != displayIndex)
{
displayIndex = newIndex;
INTERNAL_GenerateDisplayModes();
Game.GraphicsDevice.Reset();
Game.GraphicsDevice.Reset(
Game.GraphicsDevice.PresentationParameters,
GraphicsAdapter.Adapters[displayIndex]
);
}
}
);
}
public override DisplayMode GetCurrentDisplayMode()
public override GraphicsAdapter[] GetGraphicsAdapters()
{
SDL.SDL_DisplayMode mode;
SDL.SDL_GetCurrentDisplayMode(displayIndex, out mode);
return new DisplayMode(
mode.w,
mode.h,
SurfaceFormat.Color
);
}
SDL.SDL_DisplayMode filler = new SDL.SDL_DisplayMode();
GraphicsAdapter[] adapters = new GraphicsAdapter[SDL.SDL_GetNumVideoDisplays()];
for (int i = 0; i < adapters.Length; i += 1)
{
List<DisplayMode> modes = new List<DisplayMode>();
int numModes = SDL.SDL_GetNumDisplayModes(i);
for (int j = 0; j < numModes; j += 1)
{
SDL.SDL_GetDisplayMode(i, j, out filler);
public override DisplayModeCollection GetDisplayModes()
{
return supportedDisplayModes;
// Check for dupes caused by varying refresh rates.
bool dupe = false;
foreach (DisplayMode mode in modes)
{
if (filler.w == mode.Width && filler.h == mode.Height)
{
dupe = true;
}
}
if (!dupe)
{
modes.Add(
new DisplayMode(
filler.w,
filler.h,
SurfaceFormat.Color // FIXME: Assumption!
)
);
}
}
SDL.SDL_GetCurrentDisplayMode(i, out filler);
adapters[i] = new GraphicsAdapter(
new DisplayMode(
filler.w,
filler.h,
SurfaceFormat.Color // FIXME: Assumption!
),
new DisplayModeCollection(modes),
SDL.SDL_GetDisplayName(i)
);
}
return adapters;
}
public override void SetPresentationInterval(PresentInterval interval)
#endregion
#region Private DisplayMode Methods
private void INTERNAL_GenerateDisplayModes()
{
List<DisplayMode> modes = new List<DisplayMode>();
SDL.SDL_DisplayMode filler = new SDL.SDL_DisplayMode();
int numModes = SDL.SDL_GetNumDisplayModes(displayIndex);
for (int i = 0; i < numModes; i += 1)
{
SDL.SDL_GetDisplayMode(displayIndex, i, out filler);
// Check for dupes caused by varying refresh rates.
bool dupe = false;
foreach (DisplayMode mode in modes)
{
if (filler.w == mode.Width && filler.h == mode.Height)
{
dupe = true;
}
}
if (!dupe)
{
modes.Add(
new DisplayMode(
filler.w,
filler.h,
SurfaceFormat.Color // FIXME: Assumption!
)
);
}
}
supportedDisplayModes = new DisplayModeCollection(modes);
}
#endregion
#region Private Static SDL_Surface Interop
[StructLayout(LayoutKind.Sequential)]

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.90155s using 13 queries.