*/
#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>
<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>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Linux_x86' ">
<Optimize>true</Optimize>
<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
// 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 ();
}
}
}
<?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