From: jpbruyere Date: Tue, 21 Jun 2016 00:00:10 +0000 (+0200) Subject: SDL work in progress X-Git-Tag: v0.4~61^2 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=4e3802bba7c4d7fa564cec723ff93d5aa2c1a056;p=jp%2Fcrow.git SDL work in progress --- 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 { - /// - /// Entry point for all SDL-related (non-extension) types and methods - /// - public static class SDL +public static class SDL { #region SDL2# Variables - /// /// Used by DllImport to load the native library. /// 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 @@ SDL2Crow SDL2Crow v4.5 + 0.4 true @@ -20,6 +21,7 @@ prompt 4 false + true true @@ -27,6 +29,52 @@ prompt 4 false + true + + + ..\packages\SDL2-CS.dll.2.0.0.0\lib\net20\SDL2-CS.dll + + + + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\atk-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\cairo-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gdk-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gio-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\glib-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gtk-dotnet.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gtk-sharp.dll + + + ..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\pango-sharp.dll + + + + + + + + + + + {C2980F9B-4798-4C05-99E2-E174810F7C7B} + Crow + + + \ 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 . 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 @@  + \ No newline at end of file