diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-06-21 02:00:10 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-06-21 02:00:10 +0200 |
| commit | 4e3802bba7c4d7fa564cec723ff93d5aa2c1a056 (patch) | |
| tree | b245fd7f1454f520a58083fdefffac114e40d5ca | |
| parent | 5dc86e504cd04a1a3764561219c2a128da922484 (diff) | |
SDL work in progress
| -rw-r--r-- | SDL2Crow/SDL2.cs | 8 | ||||
| -rw-r--r-- | SDL2Crow/SDL2Crow.csproj | 48 | ||||
| -rw-r--r-- | SDL2Crow/main.cs | 70 | ||||
| -rw-r--r-- | SDL2Crow/packages.config | 1 |
4 files changed, 118 insertions, 9 deletions
diff --git a/SDL2Crow/SDL2.cs b/SDL2Crow/SDL2.cs index 62a7c0e2..f9a64fb5 100644 --- a/SDL2Crow/SDL2.cs +++ b/SDL2Crow/SDL2.cs @@ -26,20 +26,14 @@ */ #endregion -#region Using Statements using System; using System.Runtime.InteropServices; -#endregion namespace SDL2 { - /// <summary> - /// Entry point for all SDL-related (non-extension) types and methods - /// </summary> - public static class SDL +public static class SDL { #region SDL2# Variables - /// <summary> /// Used by DllImport to load the native library. /// </summary> diff --git a/SDL2Crow/SDL2Crow.csproj b/SDL2Crow/SDL2Crow.csproj index dc54f567..941e426f 100644 --- a/SDL2Crow/SDL2Crow.csproj +++ b/SDL2Crow/SDL2Crow.csproj @@ -10,6 +10,7 @@ <RootNamespace>SDL2Crow</RootNamespace> <AssemblyName>SDL2Crow</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <ReleaseVersion>0.4</ReleaseVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Linux_x86' "> <DebugSymbols>true</DebugSymbols> @@ -20,6 +21,7 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Linux_x86' "> <Optimize>true</Optimize> @@ -27,6 +29,52 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <ConsolePause>false</ConsolePause> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> + <ItemGroup> + <Reference Include="SDL2-CS"> + <HintPath>..\packages\SDL2-CS.dll.2.0.0.0\lib\net20\SDL2-CS.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Xml" /> + <Reference Include="atk-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\atk-sharp.dll</HintPath> + </Reference> + <Reference Include="cairo-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\cairo-sharp.dll</HintPath> + </Reference> + <Reference Include="gdk-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gdk-sharp.dll</HintPath> + </Reference> + <Reference Include="gio-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gio-sharp.dll</HintPath> + </Reference> + <Reference Include="glib-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\glib-sharp.dll</HintPath> + </Reference> + <Reference Include="gtk-dotnet"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gtk-dotnet.dll</HintPath> + </Reference> + <Reference Include="gtk-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gtk-sharp.dll</HintPath> + </Reference> + <Reference Include="pango-sharp"> + <HintPath>..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\pango-sharp.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="main.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Crow.csproj"> + <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project> + <Name>Crow</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <Import Project="..\packages\gtk-sharp.Linux.3.14.3.14.7\build\net40\gtk-sharp.Linux.3.14.targets" Condition="Exists('..\packages\gtk-sharp.Linux.3.14.3.14.7\build\net40\gtk-sharp.Linux.3.14.targets')" /> </Project>
\ No newline at end of file diff --git a/SDL2Crow/main.cs b/SDL2Crow/main.cs index bc72e8e3..3bc4d2ac 100644 --- a/SDL2Crow/main.cs +++ b/SDL2Crow/main.cs @@ -19,12 +19,78 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using SDL2; +using Cairo; + namespace SDL2Crow { - public class main + public class SDL2Window : IDisposable { - public main () + int width, height; + IntPtr win, rend; + SDL.SDL_Surface sdlSurface; + + public SDL2Window (int _width = 800, int _height = 600) { + width = _width; + height = _height; + + SDL.SDL_Init (SDL.SDL_INIT_VIDEO); + + + SDL.SDL_CreateWindowAndRenderer (width, height, + SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS, out win, out rend); + + IntPtr sdlSurfPtr = SDL.SDL_GetWindowSurface (win); + sdlSurface = (SDL.SDL_Surface)Marshal.PtrToStructure (sdlSurfPtr, typeof (SDL.SDL_Surface)); + sdlSurface. + //uint colorkey = SDL.SDL_MapRGB (sdlSurface.format, 0xFF, 0x00, 0xFF); + //// Set all pixels of colour R(255), G(0), B(255) to be transparent + //SDL.SDL_SetColorKey (sdlSurfPtr, 4, colorkey); + + //using (Cairo.Surface surf = new Cairo.ImageSurface (sdlSurface.pixels, Cairo.Format.ARGB32, sdlSurface.w, sdlSurface.h, sdlSurface.pitch)) { + // using (Context ctx = new Context (surf)) { + // ctx.Rectangle (0, 0, width, height); + // ctx.SetSourceRGBA (1, 0, 0, 0); + // ctx.Fill (); + // } + //} + + //SDL.SDL_UpdateWindowSurface (win); + + } + void Run () { + SDL.SDL_Event e; + + while(true){ + SDL.SDL_PollEvent (out e); + + if (e.type == SDL.SDL_EventType.SDL_QUIT) + break; + + SDL.SDL_SetRenderDrawBlendMode (rend, SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND); + SDL.SDL_SetRenderDrawColor (rend, 0xFF, 0x00, 0x00, 0x20); + SDL.SDL_RenderClear (rend); + + SDL.SDL_RenderPresent (rend); + } + + } + + [STAThread] + static void Main () + { + using (SDL2Window win = new SDL2Window ()) { + win.Run (); + } + } + + public void Dispose () { + SDL.SDL_DestroyRenderer (rend); + SDL.SDL_DestroyWindow (win); + SDL.SDL_Quit (); } } } diff --git a/SDL2Crow/packages.config b/SDL2Crow/packages.config index fb3df3d7..916a571c 100644 --- a/SDL2Crow/packages.config +++ b/SDL2Crow/packages.config @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="gtk-sharp.Linux.3.14" version="3.14.7" targetFramework="net45" /> <package id="SDL2-CS.dll" version="2.0.0.0" targetFramework="net45" /> </packages>
\ No newline at end of file |