fna-workbench

fna-workbench Commit Details


Date:2016-01-28 12:29:52 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:43b6f2e75adc488ed62a932955647f7f056683b3
Parents: c83a9cccb7266399e322fbc505ebb3af2fc43a52
Message:Improve multimonitor support via GraphicsAdapter

Changes:

File differences

src/GraphicsDeviceManager.cs
219219
220220
221221
222
223
222
223
224
225
226
227
228
229
230
224231
225
226
232
233
234
235
236
237
227238
228
239
229240
230
241
231242
232
243
233244
234
245
235246
236247
237248
238
249
239250
240
251
241252
242253
243254
244255
245256
246257
247
258
248259
249260
250261
251262
252263
264
265
266
253267
254268
255
269
256270
257271
258
259
260
272
273
274
261275
262276
263277
264278
265279
266
280
267281
268282
269283
270284
271
285
272286
273287
274288
return;
}
// We're about to reset a device, notify the application.
OnDeviceResetting(this, EventArgs.Empty);
// Recreate device information before resetting
GraphicsDeviceInformation gdi = new GraphicsDeviceInformation();
gdi.Adapter = GraphicsDevice.Adapter;
gdi.GraphicsProfile = GraphicsDevice.GraphicsProfile;
gdi.PresentationParameters = GraphicsDevice.PresentationParameters.Clone();
OnPreparingDeviceSettings(
this,
new PreparingDeviceSettingsEventArgs(gdi)
);
// Apply the GraphicsDevice changes internally.
GraphicsDevice.PresentationParameters.BackBufferFormat =
/* Apply the GraphicsDevice changes to the new Parameters.
* FIXME: Do we care about what OnPreparingDeviceSettings says about
* any of the data we're overwriting here?
* -flibit
*/
gdi.PresentationParameters.BackBufferFormat =
PreferredBackBufferFormat;
GraphicsDevice.PresentationParameters.BackBufferWidth =
gdi.PresentationParameters.BackBufferWidth =
PreferredBackBufferWidth;
GraphicsDevice.PresentationParameters.BackBufferHeight =
gdi.PresentationParameters.BackBufferHeight =
PreferredBackBufferHeight;
GraphicsDevice.PresentationParameters.DepthStencilFormat =
gdi.PresentationParameters.DepthStencilFormat =
PreferredDepthStencilFormat;
GraphicsDevice.PresentationParameters.IsFullScreen =
gdi.PresentationParameters.IsFullScreen =
IsFullScreen;
if (!PreferMultiSampling)
{
GraphicsDevice.PresentationParameters.MultiSampleCount = 0;
gdi.PresentationParameters.MultiSampleCount = 0;
}
else if (GraphicsDevice.PresentationParameters.MultiSampleCount == 0)
else if (gdi.PresentationParameters.MultiSampleCount == 0)
{
/* XNA4 seems to have an upper limit of 8, but I'm willing to
* limit this only in GraphicsDeviceManager's default setting.
* If you want even higher values, Reset() with a custom value.
* -flibit
*/
GraphicsDevice.PresentationParameters.MultiSampleCount = Math.Min(
gdi.PresentationParameters.MultiSampleCount = Math.Min(
GraphicsDevice.GLDevice.MaxMultiSampleCount,
8
);
}
// We're about to reset a device, notify the application.
OnDeviceResetting(this, EventArgs.Empty);
// Make the Platform device changes.
game.Window.BeginScreenDeviceChange(
GraphicsDevice.PresentationParameters.IsFullScreen
gdi.PresentationParameters.IsFullScreen
);
game.Window.EndScreenDeviceChange(
"FNA",
GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight
gdi.Adapter.Description, // FIXME: Should be Name! -flibit
gdi.PresentationParameters.BackBufferWidth,
gdi.PresentationParameters.BackBufferHeight
);
// Apply the PresentInterval.
FNAPlatform.SetPresentationInterval(
SynchronizeWithVerticalRetrace ?
GraphicsDevice.PresentationParameters.PresentationInterval :
gdi.PresentationParameters.PresentationInterval :
PresentInterval.Immediate
);
// Reset!
GraphicsDevice.Reset();
GraphicsDevice.Reset(gdi.PresentationParameters, gdi.Adapter);
// We just reset a device, notify the application.
OnDeviceReset(this, EventArgs.Empty);
src/SDL2/SDL2_GameWindow.cs
137137
138138
139139
140
141
142140
143141
144142
......
221219
222220
223221
222
223
224
224225
225226
226
227227
228228
229229
......
240240
241241
242242
243
244
245
246243
247244
248245
......
256253
257254
258255
259
260
261
262
263
264
265256
266
267
268
269
270
271
257
272258
273259
274
260
261
275262
276263
277
278
279
280
281
264
265
266
282267
283
284
285
286
287
288
268
269
270
271
272
273
289274
290
275
276
277
291278
292
293
294
279
280
281
295282
296
283
284
285
286
287
288
289
290
291
292
293
294
297295
298
299
300
301
302
303
304
305
296
306297
307298
308299
private string INTERNAL_deviceName;
private Point INTERNAL_lastWindowPosition;
#endregion
#region Internal Constructor
);
INTERNAL_SetIcon(title);
INTERNAL_deviceName = SDL.SDL_GetDisplayName(
SDL.SDL_GetWindowDisplayIndex(INTERNAL_sdlWindow)
);
INTERNAL_isFullscreen = false;
INTERNAL_wantsFullscreen = false;
INTERNAL_lastWindowPosition = new Point(SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED);
}
#endregion
int clientWidth,
int clientHeight
) {
// Set screen device name, not that we use it...
INTERNAL_deviceName = screenDeviceName;
// Fullscreen
if (INTERNAL_wantsFullscreen &&
(SDL.SDL_GetWindowFlags(INTERNAL_sdlWindow) & (uint) SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN) == 0)
*/
SDL.SDL_ShowWindow(INTERNAL_sdlWindow);
}
SDL.SDL_SetWindowFullscreen(
INTERNAL_sdlWindow,
INTERNAL_wantsFullscreen ?
(uint) SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP :
0
);
/* Because Mac windows resize from the bottom, we have to get the
* position before changing the size so we can keep the window
* centered when resizing in windowed mode.
* -Nick
*/
Rectangle prevBounds = Rectangle.Empty;
// When windowed, set the size before moving
if (!INTERNAL_wantsFullscreen)
{
prevBounds = ClientBounds;
SDL.SDL_SetWindowFullscreen(INTERNAL_sdlWindow, 0);
SDL.SDL_SetWindowSize(INTERNAL_sdlWindow, clientWidth, clientHeight);
}
// Window bounds
SDL.SDL_SetWindowSize(INTERNAL_sdlWindow, clientWidth, clientHeight);
// Window position
if (INTERNAL_isFullscreen && !INTERNAL_wantsFullscreen)
// Get on the right display!
int displayIndex = 0;
for (int i = 0; i < GraphicsAdapter.Adapters.Count; i += 1)
{
// If exiting fullscreen, just center the window on the desktop.
SDL.SDL_SetWindowPosition(
INTERNAL_sdlWindow,
INTERNAL_lastWindowPosition.X,
INTERNAL_lastWindowPosition.Y
);
// FIXME: Should be checking Name, not Description! -flibit
if (screenDeviceName == GraphicsAdapter.Adapters[i].Description)
{
displayIndex = i;
break;
}
}
else if (!INTERNAL_wantsFullscreen)
// Just to be sure, become a window first before changing displays
if (INTERNAL_deviceName != screenDeviceName)
{
// Store the window position before switching to fullscreen
INTERNAL_lastWindowPosition.X = prevBounds.X + ((prevBounds.Width - clientWidth) / 2);
INTERNAL_lastWindowPosition.Y = prevBounds.Y + ((prevBounds.Height - clientHeight) / 2);
SDL.SDL_SetWindowFullscreen(INTERNAL_sdlWindow, 0);
INTERNAL_deviceName = screenDeviceName;
}
SDL.SDL_SetWindowPosition(
// Window always gets centered, per XNA behavior
int pos = SDL.SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex);
SDL.SDL_SetWindowPosition(
INTERNAL_sdlWindow,
pos,
pos
);
// Set fullscreen after we've done all the ugly stuff.
if (INTERNAL_wantsFullscreen)
{
SDL.SDL_SetWindowFullscreen(
INTERNAL_sdlWindow,
Math.Max(
INTERNAL_lastWindowPosition.X,
0
),
Math.Max(
INTERNAL_lastWindowPosition.Y,
0
)
(uint) SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP
);
}

Archive Download the corresponding diff file

Branches

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