fna-workbench

fna-workbench Git Source Tree


Root/src/FNAPlatform.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
 * Copyright 2009-2016 Ethan Lee and the MonoGame Team
 *
 * Released under the Microsoft Public License.
 * See LICENSE for details.
 */
#endregion
 
#region Using Statements
using System;
using System.IO;
 
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input;
#endregion
 
namespace Microsoft.Xna.Framework
{
    internal static class FNAPlatform
    {
        #region Static Constructor
 
        static FNAPlatform()
        {
            /* I suspect you may have an urge to put an #if in here for new
             * FNAPlatform implementations.
             *
             * DON'T.
             *
             * Determine this at runtime, or load dynamically.
             * No amount of whining will get me to budge on this.
             * -flibit
             */
 
            // Environment.GetEnvironmentVariable("FNA_PLATFORM_BACKEND");
 
            CreateWindow =          SDL2_FNAPlatform.CreateWindow;
            DisposeWindow =         SDL2_FNAPlatform.DisposeWindow;
            BeforeInitialize =      SDL2_FNAPlatform.BeforeInitialize;
            RunLoop =           SDL2_FNAPlatform.RunLoop;
            CreateGLDevice =        SDL2_FNAPlatform.CreateGLDevice;
            CreateALDevice =        SDL2_FNAPlatform.CreateALDevice;
            SetPresentationInterval =   SDL2_FNAPlatform.SetPresentationInterval;
            GetGraphicsAdapters =       SDL2_FNAPlatform.GetGraphicsAdapters;
            GetKeyFromScancode =        SDL2_KeyboardUtil.GetKeyFromScancode;
            StartTextInput =        SDL2.SDL.SDL_StartTextInput;
            StopTextInput =         SDL2.SDL.SDL_StopTextInput;
            GetMouseState =         SDL2_FNAPlatform.GetMouseState;
            SetMousePosition =      SDL2.SDL.SDL_WarpMouseInWindow;
            OnIsMouseVisibleChanged =   SDL2_FNAPlatform.OnIsMouseVisibleChanged;
            GetGamePadCapabilities =    SDL2_FNAPlatform.GetGamePadCapabilities;
            GetGamePadState =       SDL2_FNAPlatform.GetGamePadState;
            SetGamePadVibration =       SDL2_FNAPlatform.SetGamePadVibration;
            GetGamePadGUID =        SDL2_FNAPlatform.GetGamePadGUID;
            SetGamePadLightBar =        SDL2_FNAPlatform.SetGamePadLightBar;
            GetStorageRoot =        SDL2_FNAPlatform.GetStorageRoot;
            IsStoragePathConnected =    SDL2_FNAPlatform.IsStoragePathConnected;
            ShowRuntimeError =      SDL2_FNAPlatform.ShowRuntimeError;
            TextureDataFromStream =     SDL2_FNAPlatform.TextureDataFromStream;
            SavePNG =           SDL2_FNAPlatform.SavePNG;
 
            Log = Console.WriteLine;
 
            AppDomain.CurrentDomain.ProcessExit += SDL2_FNAPlatform.ProgramExit;
            SDL2_FNAPlatform.ProgramInit();
        }
 
        #endregion
 
        #region Public Static Methods
 
        public static void UnhookLogger()
        {
            Log = Console.WriteLine;
        }
 
        public static Action<string> Log;
 
        public delegate GameWindow CreateWindowFunc();
        public static readonly CreateWindowFunc CreateWindow;
 
        public delegate void DisposeWindowFunc(GameWindow window);
        public static readonly DisposeWindowFunc DisposeWindow;
 
        public delegate void BeforeInitializeFunc();
        public static readonly BeforeInitializeFunc BeforeInitialize;
 
        public delegate void RunLoopFunc(Game game);
        public static readonly RunLoopFunc RunLoop;
 
        public delegate IGLDevice CreateGLDeviceFunc(
            PresentationParameters presentationParameters
        );
        public static readonly CreateGLDeviceFunc CreateGLDevice;
 
        public delegate IALDevice CreateALDeviceFunc();
        public static readonly CreateALDeviceFunc CreateALDevice;
 
        public delegate void SetPresentationIntervalFunc(PresentInterval interval);
        public static readonly SetPresentationIntervalFunc SetPresentationInterval;
 
        public delegate GraphicsAdapter[] GetGraphicsAdaptersFunc();
        public static readonly GetGraphicsAdaptersFunc GetGraphicsAdapters;
 
        public delegate Keys GetKeyFromScancodeFunc(Keys scancode);
        public static readonly GetKeyFromScancodeFunc GetKeyFromScancode;
 
        public delegate void StartTextInputFunc();
        public static readonly StartTextInputFunc StartTextInput;
 
        public delegate void StopTextInputFunc();
        public static readonly StopTextInputFunc StopTextInput;
 
        public delegate void GetMouseStateFunc(
            out int x,
            out int y,
            out ButtonState left,
            out ButtonState middle,
            out ButtonState right,
            out ButtonState x1,
            out ButtonState x2
        );
        public static readonly GetMouseStateFunc GetMouseState;
 
        public delegate void SetMousePositionFunc(
            IntPtr window,
            int x,
            int y
        );
        public static readonly SetMousePositionFunc SetMousePosition;
 
        public delegate void OnIsMouseVisibleChangedFunc(bool visible);
        public static readonly OnIsMouseVisibleChangedFunc OnIsMouseVisibleChanged;
 
        public delegate GamePadCapabilities GetGamePadCapabilitiesFunc(int index);
        public static readonly GetGamePadCapabilitiesFunc GetGamePadCapabilities;
 
        public delegate GamePadState GetGamePadStateFunc(
            int index,
            GamePadDeadZone deadZoneMode
        );
        public static readonly GetGamePadStateFunc GetGamePadState;
 
        public delegate bool SetGamePadVibrationFunc(
            int index,
            float leftMotor,
            float rightMotor
        );
        public static readonly SetGamePadVibrationFunc SetGamePadVibration;
 
        public delegate string GetGamePadGUIDFunc(int index);
        public static readonly GetGamePadGUIDFunc GetGamePadGUID;
 
        public delegate void SetGamePadLightBarFunc(int index, Color color);
        public static readonly SetGamePadLightBarFunc SetGamePadLightBar;
 
        public delegate string GetStorageRootFunc();
        public static readonly GetStorageRootFunc GetStorageRoot;
 
        public delegate bool IsStoragePathConnectedFunc(string path);
        public static readonly IsStoragePathConnectedFunc IsStoragePathConnected;
 
        public delegate void ShowRuntimeErrorFunc(string title, string message);
        public static readonly ShowRuntimeErrorFunc ShowRuntimeError;
 
        public delegate void TextureDataFromStreamFunc(
            Stream stream,
            out int width,
            out int height,
            out byte[] pixels,
            int reqWidth = -1,
            int reqHeight = -1,
            bool zoom = false
        );
        public static readonly TextureDataFromStreamFunc TextureDataFromStream;
 
        public delegate void SavePNGFunc(
            Stream stream,
            int width,
            int height,
            int imgWidth,
            int imgHeight,
            byte[] data
        );
        public static readonly SavePNGFunc SavePNG;
 
        #endregion
    }
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.09217s using 11 queries.