From 38276860ff3ef95cd1b02a94f65bdeacd0900dcf Mon Sep 17 00:00:00 2001 From: Ian Burgmyer Date: Thu, 23 Mar 2017 16:40:01 -0400 Subject: [PATCH] Started the project; began importing library functions. --- DotSDL.sln | 28 ++++++ DotSDL.sln.DotSettings | 103 +++++++++++++++++++++ DotSDL/DotSDL.csproj | 7 ++ DotSDL/Sdl/Init.cs | 90 ++++++++++++++++++ DotSDL/Sdl/Meta.cs | 11 +++ DotSDL/Sdl/Video.cs | 102 ++++++++++++++++++++ LICENSE.txt | 13 +++ Samples/Sample.BasicPixels/App.config | 6 ++ .../Sample.BasicPixels/Sample.BasicPixels.csproj | 38 ++++++++ 9 files changed, 398 insertions(+) create mode 100644 DotSDL.sln.DotSettings create mode 100644 DotSDL/DotSDL.csproj create mode 100644 DotSDL/Sdl/Init.cs create mode 100644 DotSDL/Sdl/Meta.cs create mode 100644 DotSDL/Sdl/Video.cs create mode 100644 LICENSE.txt create mode 100644 Samples/Sample.BasicPixels/App.config create mode 100644 Samples/Sample.BasicPixels/Sample.BasicPixels.csproj diff --git a/DotSDL.sln b/DotSDL.sln index 06dbd6c..86245be 100644 --- a/DotSDL.sln +++ b/DotSDL.sln @@ -3,8 +3,36 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{53C506CE-9D99-4306-A304-D4B09924A883}" + ProjectSection(SolutionItems) = preProject + LICENSE.txt = LICENSE.txt + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotSDL", "DotSDL\DotSDL.csproj", "{C645C551-C6A4-4312-BCAF-DF94B0EB878E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{70DA3135-B76E-421D-B9CF-E49CD6440B0A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.BasicPixels", "Samples\Sample.BasicPixels\Sample.BasicPixels.csproj", "{C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6}" +EndProject Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C645C551-C6A4-4312-BCAF-DF94B0EB878E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C645C551-C6A4-4312-BCAF-DF94B0EB878E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C645C551-C6A4-4312-BCAF-DF94B0EB878E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C645C551-C6A4-4312-BCAF-DF94B0EB878E}.Release|Any CPU.Build.0 = Release|Any CPU + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6} = {70DA3135-B76E-421D-B9CF-E49CD6440B0A} + EndGlobalSection EndGlobal diff --git a/DotSDL.sln.DotSettings b/DotSDL.sln.DotSettings new file mode 100644 index 0000000..787bd4d --- /dev/null +++ b/DotSDL.sln.DotSettings @@ -0,0 +1,103 @@ + + True + DO_NOT_SHOW + END_OF_LINE + END_OF_LINE + True + True + True + True + True + True + True + True + True + True + END_OF_LINE + END_OF_LINE + TOGETHER + True + END_OF_LINE + END_OF_LINE + True + END_OF_LINE + False + False + False + False + False + False + False + False + False + False + False + False + False + True + False + END_OF_LINE + False + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="set_" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="_" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> + UI + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + True + True + True + True + True \ No newline at end of file diff --git a/DotSDL/DotSDL.csproj b/DotSDL/DotSDL.csproj new file mode 100644 index 0000000..35b0726 --- /dev/null +++ b/DotSDL/DotSDL.csproj @@ -0,0 +1,7 @@ + + + + netstandard1.3 + + + \ No newline at end of file diff --git a/DotSDL/Sdl/Init.cs b/DotSDL/Sdl/Init.cs new file mode 100644 index 0000000..98e8340 --- /dev/null +++ b/DotSDL/Sdl/Init.cs @@ -0,0 +1,90 @@ +using System; +using System.Runtime.InteropServices; + +namespace DotSDL.Sdl { + /// + /// Contains the necessary constants and function imports from SDL.h. + /// + internal static class Init { + [Flags] + internal enum SubsystemFlags : uint { + /// No subsystem. + None = 0x0000000, + + /// Timer subsystem. + Timer = 0x0000001, + + /// Audio subsystem. + Audio = 0x0000010, + + /// Video subsystem; automatically initializes the events subsystem. + Video = 0x0000020, + + /// Joystick subsystem; automatically initializes the events subsystem. + Joystick = 0x0000200, + + /// Haptic (force feedback) subsystem. + Haptic = 0x0001000, + + /// Controller subsystem; automatically initializes the joystick subsystem. + GameController = 0x0002000, + + /// Events subsystem. + Events = 0x0004000, + + /// Compatibility; this flag is ignored. + NoParachute = 0x0010000, + + /// All of the above subsystems. + Everything = Timer | Audio | Video | Joystick | Haptic | GameController | Events | NoParachute + } + + /// + /// This function initalizes the subsystems specified by . + /// + /// Flags indicating which subsystem or subsystems to initialize. + /// 0 on success or a negative error code on failure. + [DllImport(Meta.DllName, EntryPoint = "SDL_Init", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Initialize(SubsystemFlags flags); + + /// + /// This function initializes specific SDL subsystems + /// + /// Subsystem initialization is ref-counted, you must call + /// SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly + /// shutdown a subsystem manually(or call SDL_Quit() to force shutdown). + /// If a subsystem is already loaded then this call will + /// increase the ref-count and return. + /// + /// Flags indicating which subsystem or subsystems to initialize. + /// 0 on success or a negative error code on failure. + [DllImport(Meta.DllName, EntryPoint = "SDL_InitSubSystem", CallingConvention = CallingConvention.Cdecl)] + internal static extern int InitSubSystem(SubsystemFlags flags); + + /// + /// This function cleans up specific SDL subsystems + /// + /// Flags indicating which subsystem or subsystems to quit. + /// 0 on success or a negative error code on failure. + [DllImport(Meta.DllName, EntryPoint = "SDL_QuitSubSystem", CallingConvention = CallingConvention.Cdecl)] + internal static extern int QuitSubSystem(SubsystemFlags flags); + + /// + /// This function returns a mask of the specified subsystems which have + /// previously been initialized. + /// + /// If is 0, it returns a mask of all initialized subsystems. + /// + /// Flags indicating which subsystem or subsystems to query. + /// A set of all initialized subsystems. + [DllImport(Meta.DllName, EntryPoint = "SDL_WasInit", CallingConvention = CallingConvention.Cdecl)] + internal static extern SubsystemFlags WasInit(SubsystemFlags flags); + + /// + /// This function cleans up all initialized subsystems. You should call it upon all + /// exit conditions. + /// + [DllImport(Meta.DllName, EntryPoint = "SDL_Quit", CallingConvention = CallingConvention.Cdecl)] + internal static extern void Quit(); + } +} diff --git a/DotSDL/Sdl/Meta.cs b/DotSDL/Sdl/Meta.cs new file mode 100644 index 0000000..c4fe6c7 --- /dev/null +++ b/DotSDL/Sdl/Meta.cs @@ -0,0 +1,11 @@ +namespace DotSDL.Sdl { + /// + /// Contains .NET constants to assist with making calls to the SDL library.. + /// + internal static class Meta { + /// + /// Contains the name of the SDL library. + /// + internal const string DllName = "SDL2.dll"; + } +} diff --git a/DotSDL/Sdl/Video.cs b/DotSDL/Sdl/Video.cs new file mode 100644 index 0000000..a85c2f6 --- /dev/null +++ b/DotSDL/Sdl/Video.cs @@ -0,0 +1,102 @@ +using System; +using System.Runtime.InteropServices; + +namespace DotSDL.Sdl { + /// + /// Contains the necessary constants and function imports from SDL_video.h. + /// + internal static class Video { + /// + /// An enumeration of window statesm. + /// + [Flags] + internal enum WindowFlags : uint { + /// Fullscreen window. + Fullscreen = 0x00000001, + + /// Window usable with OpenGL context. + OpenGl = 0x00000002, + + /// Window is visible. + Shown = 0x00000004, + + /// Window is not visible. + Hidden = 0x00000008, + + /// No window decoration. + Borderless = 0x00000010, + + /// Window can be resized. + Resizable = 0x00000020, + + /// Window is minimized. + Minimized = 0x00000040, + + /// Window is maximized. + Maximized = 0x00000080, + + /// Window has grabbed input focus. + InputGrabbed = 0x00000100, + + /// Window has input focus. + InputFocus = 0x00000200, + + /// Window has mouse focus. + MouseFocus = 0x00000400, + + /// Window not created by SDL. + Foreign = 0x00000800, + + /// Fullscreen window at the current desktop resolution. + FullscreenDesktop = Fullscreen | 0x00001000, + + /// Window should be created in high-DPI mode if supported (>= SDL 2.0.1). + AllowHighDpi = 0x00002000, + + /// Window has mouse captured (unrelated to , >= SDL 2.0.4). + MouseCapture = 0x00004000, + + /// Window should always be above others (X11 only, >= SDL 2.0.5). + AlwaysOnTop = 0x00008000, + + /// Window should not be added to the taskbar (X11 only, >= SDL 2.0.5). + SkipTaskbar = 0x00010000, + + /// Window should be treated as a utility window (X11 only, >= SDL 2.0.5). + Utility = 0x00020000, + + /// Window should be treated as a popup (X11 only, >= SDL 2.0.5). + Tooltip = 0x00040000, + + /// Window should be treated as a popup menu (X11 only, >= SDL 2.0.5). + PopupMenu = 0x00080000 + } + + internal const uint WindowPosUndefinedMask = 0x1FFF0000; + /// Indicates that the window manager should place the window.. + internal const uint WindowPosUndefined = WindowPosUndefinedMask; + internal static uint WindowPosUndefinedDisplay(uint x) { + return WindowPosUndefinedMask | x; + } + + internal const uint WindowPosCenteredMask = 0x2FFF0000; + /// Indicates that the window should be in the center of the screen. + internal const uint WindowPosCentered = WindowPosCenteredMask; + internal static uint WindowPosCenteredDisplay(uint x) { + return WindowPosCenteredMask | x; + } + + /// + /// Creates a window with the specified position, dimensions, and flags. + /// + /// The title of the window, in UTF-8 encoding. + /// The x position of the window, , or . + /// The y position of the window, , or . + /// The width of the window, in screen coordinates. + /// The height of the window, in screen coordinates. + /// One or more OR'd together. + /// The window that was created, or NULL on failure. + [DllImport(Meta.DllName, EntryPoint = "SDL_CreateWindow", CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr CreateWindow(string title, int x, int y, int w, int h, WindowFlags flags); + } +} diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..4f650c3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,13 @@ +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/Samples/Sample.BasicPixels/App.config b/Samples/Sample.BasicPixels/App.config new file mode 100644 index 0000000..8324aa6 --- /dev/null +++ b/Samples/Sample.BasicPixels/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Samples/Sample.BasicPixels/Sample.BasicPixels.csproj b/Samples/Sample.BasicPixels/Sample.BasicPixels.csproj new file mode 100644 index 0000000..828e246 --- /dev/null +++ b/Samples/Sample.BasicPixels/Sample.BasicPixels.csproj @@ -0,0 +1,38 @@ + + + + + Debug + AnyCPU + {C1CCAC4E-6914-4BC1-B81F-BDFB68B476F6} + Exe + DotSDL.Sample.BasicPixels + BasicPixels + v4.6 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + \ No newline at end of file