fna-workbench

fna-workbench Commit Details


Date:2016-01-13 15:00:03 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:049a623e9415ed0cffd5beaf790bea9d29852231
Parents: 5fa4cba009415fbe7972006bad2511a6a238ed7e
Message:Move WIIU_GAMEPAD to GraphicsDevice, trim GamePlatform further

Changes:

File differences

src/Game.cs
644644
645645
646646
647
648647
649648
650649
if (GraphicsDevice != null)
{
GraphicsDevice.Present();
Platform.Present(GraphicsDevice);
}
}
src/GamePlatform.cs
101101
102102
103103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133104
134105
135
136
137106
138107
139108
/// </summary>
public abstract void RunLoop();
/// <summary>
/// Starts a device transition (windowed to full screen or vice versa).
/// </summary>
/// <param name='willBeFullScreen'>
/// Specifies whether the device will be in full-screen mode upon completion of
/// the change.
/// </param>
public abstract void BeginScreenDeviceChange(
bool willBeFullScreen
);
/// <summary>
/// Completes a device transition.
/// </summary>
/// <param name='screenDeviceName'>
/// Screen device name.
/// </param>
/// <param name='clientWidth'>
/// The new width of the game's client window.
/// </param>
/// <param name='clientHeight'>
/// The new height of the game's client window.
/// </param>
public abstract void EndScreenDeviceChange(
string screenDeviceName,
int clientWidth,
int clientHeight
);
public abstract void OnIsMouseVisibleChanged(bool visible);
public abstract void Present(GraphicsDevice device);
public abstract void ShowRuntimeError(
String title,
String message
src/Graphics/GraphicsDevice.cs
77
88
99
10
11
12
13
14
15
16
17
18
1019
1120
1221
......
406415
407416
408417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
409440
410441
411442
......
449480
450481
451482
483
484
485
486
487
488
489
490
491
452492
453493
454494
......
486526
487527
488528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
489544
490545
491546
......
498553
499554
500555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
501571
502572
503573
......
564634
565635
566636
637
638
639
640
641
642
643
644
567645
568646
569647
......
13351413
13361414
13371415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
13381478
13391479
*/
#endregion
#region WIIU_GAMEPAD Option
// #define WIIU_GAMEPAD
/* This is something I added for myself, because I am a complete goof.
* You should NEVER enable this in your shipping build.
* Let your hacker customers self-build FNA, they'll know what to do.
* -flibit
*/
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
// Set the default viewport and scissor rect.
Viewport = new Viewport(PresentationParameters.Bounds);
ScissorRectangle = Viewport.Bounds;
#if WIIU_GAMEPAD
wiiuStream = DRC.drc_new_streamer();
if (wiiuStream == IntPtr.Zero)
{
System.Console.WriteLine("Failed to alloc GamePad stream!");
return;
}
if (DRC.drc_start_streamer(wiiuStream) < 1) // ???
{
System.Console.WriteLine("Failed to start GamePad stream!");
DRC.drc_delete_streamer(wiiuStream);
wiiuStream = IntPtr.Zero;
return;
}
DRC.drc_enable_system_input_feeder(wiiuStream);
wiiuPixelData = new byte[
PresentationParameters.BackBufferWidth *
PresentationParameters.BackBufferHeight *
4
];
#endif
}
~GraphicsDevice()
// Dispose of the GL Device/Context
GLDevice.Dispose();
#if WIIU_GAMEPAD
if (wiiuStream != IntPtr.Zero)
{
DRC.drc_stop_streamer(wiiuStream);
DRC.drc_delete_streamer(wiiuStream);
wiiuStream = IntPtr.Zero;
}
#endif
}
IsDisposed = true;
null,
PresentationParameters.DeviceWindowHandle
);
#if WIIU_GAMEPAD
if (wiiuStream != IntPtr.Zero)
{
GetBackBufferData(wiiuPixelData);
DRC.drc_push_vid_frame(
wiiuStream,
wiiuPixelData,
(uint) wiiuPixelData.Length,
(ushort) GLDevice.Backbuffer.Width,
(ushort) GLDevice.Backbuffer.Height,
DRC.drc_pixel_format.DRC_RGBA,
DRC.drc_flipping_mode.DRC_NO_FLIP
);
}
#endif
}
public void Present(
destinationRectangle,
overrideWindowHandle
);
#if WIIU_GAMEPAD
if (wiiuStream != IntPtr.Zero)
{
GetBackBufferData(wiiuPixelData);
DRC.drc_push_vid_frame(
wiiuStream,
wiiuPixelData,
(uint) wiiuPixelData.Length,
(ushort) GLDevice.Backbuffer.Width,
(ushort) GLDevice.Backbuffer.Height,
DRC.drc_pixel_format.DRC_RGBA,
DRC.drc_flipping_mode.DRC_NO_FLIP
);
}
#endif
}
#endregion
RenderTargetCount > 0
);
#if WIIU_GAMEPAD
wiiuPixelData = new byte[
PresentationParameters.BackBufferWidth *
PresentationParameters.BackBufferHeight *
4
];
#endif
// Now, update the viewport
Viewport = new Viewport(
0,
}
#endregion
#region Wii U GamePad Support, libdrc Interop
#if WIIU_GAMEPAD
private static class DRC
{
// FIXME: Deal with Mac/Windows LibName later.
private const string nativeLibName = "libdrc.so";
public enum drc_pixel_format
{
DRC_RGB,
DRC_RGBA,
DRC_BGR,
DRC_BGRA,
DRC_RGB565
}
public enum drc_flipping_mode
{
DRC_NO_FLIP,
DRC_FLIP_VERTICALLY
}
/* IntPtr refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr drc_new_streamer();
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_delete_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int drc_start_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_stop_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int drc_push_vid_frame(
IntPtr self,
byte[] buffer,
uint size,
ushort width,
ushort height,
drc_pixel_format pixfmt,
drc_flipping_mode flipmode
);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_enable_system_input_feeder(IntPtr self);
}
private IntPtr wiiuStream;
private byte[] wiiuPixelData;
#endif
#endregion
}
}
src/GraphicsDeviceManager.cs
251251
252252
253253
254
254
255255
256256
257
257
258258
259259
260260
......
290290
291291
292292
293
294
293
294
295295
296296
297297
}
// Make the Platform device changes.
game.Platform.BeginScreenDeviceChange(
game.Window.BeginScreenDeviceChange(
GraphicsDevice.PresentationParameters.IsFullScreen
);
game.Platform.EndScreenDeviceChange(
game.Window.EndScreenDeviceChange(
"FNA",
GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight
PreferredBackBufferHeight;
// Apply settings.
game.Platform.BeginScreenDeviceChange(IsFullScreen);
game.Platform.EndScreenDeviceChange(
game.Window.BeginScreenDeviceChange(IsFullScreen);
game.Window.EndScreenDeviceChange(
"FNA",
GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight
src/SDL2/SDL2_GamePlatform.cs
2424
2525
2626
27
28
29
30
31
32
33
34
35
3627
3728
3829
......
4940
5041
5142
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
11443
11544
11645
......
236165
237166
238167
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258168
259169
260170
......
483393
484394
485395
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500396
501397
502398
503399
504400
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524401
525402
526403
......
920797
921798
922799
923
924
925
926
927
928
929
930
931
932800
933801
934802
*/
#endregion
#region WIIU_GAMEPAD Option
// #define WIIU_GAMEPAD
/* This is something I added for myself, because I am a complete goof.
* You should NEVER enable this in your shipping build.
* Let your hacker customers self-build FNA, they'll know what to do.
* -flibit
*/
#endregion
#region Using Statements
using System;
using System.IO;
{
class SDL2_GamePlatform : GamePlatform
{
#region Wii U GamePad Support, libdrc Interop
#if WIIU_GAMEPAD
private static class DRC
{
// FIXME: Deal with Mac/Windows LibName later.
private const string nativeLibName = "libdrc.so";
public enum drc_pixel_format
{
DRC_RGB,
DRC_RGBA,
DRC_BGR,
DRC_BGRA,
DRC_RGB565
}
public enum drc_flipping_mode
{
DRC_NO_FLIP,
DRC_FLIP_VERTICALLY
}
/* IntPtr refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr drc_new_streamer();
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_delete_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int drc_start_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_stop_streamer(IntPtr self);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int drc_push_vid_frame(
IntPtr self,
byte[] buffer,
uint size,
ushort width,
ushort height,
drc_pixel_format pixfmt,
drc_flipping_mode flipmode
);
/* self refers to a drc_streamer* */
[DllImportAttribute(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void drc_enable_system_input_feeder(IntPtr self);
}
private IntPtr wiiuStream;
private byte[] wiiuPixelData;
#endif
#endregion
#region Private OSX-specific Variables
private bool INTERNAL_useFullscreenSpaces;
// Ready to run the loop!
INTERNAL_runApplication = true;
#if WIIU_GAMEPAD
wiiuStream = DRC.drc_new_streamer();
if (wiiuStream == IntPtr.Zero)
{
System.Console.WriteLine("Failed to alloc GamePad stream!");
return;
}
if (DRC.drc_start_streamer(wiiuStream) < 1) // ???
{
System.Console.WriteLine("Failed to start GamePad stream!");
DRC.drc_delete_streamer(wiiuStream);
wiiuStream = IntPtr.Zero;
return;
}
DRC.drc_enable_system_input_feeder(wiiuStream);
Rectangle bounds = game.Window.ClientBounds;
wiiuPixelData = new byte[bounds.Width * bounds.Height * 4];
#endif
}
#endregion
}
}
public override void BeginScreenDeviceChange(bool willBeFullScreen)
{
Game.Window.BeginScreenDeviceChange(willBeFullScreen);
}
public override void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
{
Game.Window.EndScreenDeviceChange(screenDeviceName, clientWidth, clientHeight);
#if WIIU_GAMEPAD
wiiuPixelData = new byte[clientWidth * clientHeight * 4];
#endif
}
public override void Log(string Message)
{
Console.WriteLine(Message);
}
public override void Present(GraphicsDevice device)
{
#if WIIU_GAMEPAD
if (wiiuStream != IntPtr.Zero)
{
device.GetBackBufferData(wiiuPixelData);
DRC.drc_push_vid_frame(
wiiuStream,
wiiuPixelData,
(uint) wiiuPixelData.Length,
(ushort) device.GLDevice.Backbuffer.Width,
(ushort) device.GLDevice.Backbuffer.Height,
DRC.drc_pixel_format.DRC_RGBA,
DRC.drc_flipping_mode.DRC_NO_FLIP
);
}
#endif
}
public override void ShowRuntimeError(string title, string message)
{
SDL.SDL_ShowSimpleMessageBox(
Game.Window = null;
}
#if WIIU_GAMEPAD
if (wiiuStream != IntPtr.Zero)
{
DRC.drc_stop_streamer(wiiuStream);
DRC.drc_delete_streamer(wiiuStream);
wiiuStream = IntPtr.Zero;
}
#endif
// This _should_ be the last SDL call we make...
SDL.SDL_Quit();
}

Archive Download the corresponding diff file

Branches

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