Moved all bindings to the "bindings" sub-directory

Renamed the CSFML directory to c
Renamed the DSFML directory to d
--> bindings must now be updated to match the new organization!

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1630 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-11-09 17:13:17 +00:00
parent 0cc5563cac
commit 0e2297af28
417 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,110 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Utility class for manipulating 32-bits RGBA colors
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Color
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the color from its red, green and blue components
/// </summary>
/// <param name="red">Red component</param>
/// <param name="green">Green component</param>
/// <param name="blue">Blue component</param>
////////////////////////////////////////////////////////////
public Color(byte red, byte green, byte blue) :
this(red, green, blue, 255)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the color from its red, green, blue and alpha components
/// </summary>
/// <param name="red">Red component</param>
/// <param name="green">Green component</param>
/// <param name="blue">Blue component</param>
/// <param name="alpha">Alpha (transparency) component</param>
////////////////////////////////////////////////////////////
public Color(byte red, byte green, byte blue, byte alpha)
{
R = red;
G = green;
B = blue;
A = alpha;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the color from another
/// </summary>
/// <param name="color">Color to copy</param>
////////////////////////////////////////////////////////////
public Color(Color color) :
this(color.R, color.G, color.B, color.A)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Color]" +
" R(" + R + ")" +
" G(" + G + ")" +
" B(" + B + ")" +
" A(" + A + ")";
}
/// <summary>Red component of the color</summary>
public byte R;
/// <summary>Green component of the color</summary>
public byte G;
/// <summary>Blue component of the color</summary>
public byte B;
/// <summary>Alpha (transparent) component of the color</summary>
public byte A;
/// <summary>Predefined black color</summary>
public static readonly Color Black = new Color(0, 0, 0);
/// <summary>Predefined white color</summary>
public static readonly Color White = new Color(255, 255, 255);
/// <summary>Predefined red color</summary>
public static readonly Color Red = new Color(255, 0, 0);
/// <summary>Predefined green color</summary>
public static readonly Color Green = new Color(0, 255, 0);
/// <summary>Predefined blue color</summary>
public static readonly Color Blue = new Color(0, 0, 255);
/// <summary>Predefined yellow color</summary>
public static readonly Color Yellow = new Color(255, 255, 0);
/// <summary>Predefined magenta color</summary>
public static readonly Color Magenta = new Color(255, 0, 255);
/// <summary>Predefined cyan color</summary>
public static readonly Color Cyan = new Color(0, 255, 255);
}
}
}

View file

@ -0,0 +1,91 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Runtime.ConstrainedExecution;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// This class defines
/// </summary>
////////////////////////////////////////////////////////////
internal class Context : CriticalFinalizerObject
{
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor
/// </summary>
////////////////////////////////////////////////////////////
public Context()
{
myThis = sfContext_Create();
}
////////////////////////////////////////////////////////////
/// <summary>
/// Finalizer
/// </summary>
////////////////////////////////////////////////////////////
~Context()
{
sfContext_Destroy(myThis);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Activate or deactivate the context
/// </summary>
/// <param name="active">True to activate, false to deactivate</param>
////////////////////////////////////////////////////////////
public void SetActive(bool active)
{
sfContext_SetActive(myThis, active);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Global helper context
/// </summary>
////////////////////////////////////////////////////////////
public static Context Global
{
get
{
if (ourGlobalContext == null)
ourGlobalContext = new Context();
return ourGlobalContext;
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Context]";
}
private static Context ourGlobalContext = null;
private IntPtr myThis = IntPtr.Zero;
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfContext_Create();
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfContext_Destroy(IntPtr View);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfContext_SetActive(IntPtr View, bool Active);
#endregion
}
}
}

View file

@ -0,0 +1,129 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Enumerate the blending modes available for drawable objects
/// </summary>
////////////////////////////////////////////////////////////
public enum BlendMode
{
/// <summary>Pixel = Src * a + Dest * (1 - a)</summary>
Alpha,
/// <summary>Pixel = Src + Dest</summary>
Add,
/// <summary>Pixel = Src * Dest</summary>
Multiply,
/// <summary>No blending</summary>
None
}
////////////////////////////////////////////////////////////
/// <summary>
/// Abstract base class for every object that can be drawn
/// into a render window
/// </summary>
////////////////////////////////////////////////////////////
public abstract class Drawable : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Position {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotation of the object, defined in degrees
/// </summary>
////////////////////////////////////////////////////////////
public abstract float Rotation {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Scale {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Origin of the transformation of the object
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Origin {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Global color of the object
/// </summary>
////////////////////////////////////////////////////////////
public abstract Color Color {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Blending mode of the object
/// </summary>
////////////////////////////////////////////////////////////
public abstract BlendMode BlendMode {get; set;}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public abstract Vector2 TransformToLocal(Vector2 point);
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public abstract Vector2 TransformToGlobal(Vector2 point);
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render window
/// </summary>
/// <param name="target">Target render window</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal abstract void Render(RenderWindow target, Shader shader);
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render image
/// </summary>
/// <param name="target">Target render image</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal abstract void Render(RenderImage target, Shader shader);
////////////////////////////////////////////////////////////
/// <summary>
/// Internal constructor, for derived classes
/// </summary>
/// <param name="thisPtr">Pointer to the object in C library</param>
////////////////////////////////////////////////////////////
protected Drawable(IntPtr thisPtr) :
base(thisPtr)
{
}
}
}
}

View file

@ -0,0 +1,238 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using System.IO;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Structure describing a glyph (a visual character)
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Glyph
{
/// <summary>Offset to move horizontically to the next character</summary>
public int Advance;
/// <summary>Bounding rectangle of the glyph, in coordinates relative to the baseline</summary>
public IntRect Rectangle;
/// <summary>Texture coordinates of the glyph inside the font's image</summary>
public FloatRect TexCoords;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Font is the low-level class for loading and
/// manipulating character fonts. This class is meant to
/// be used by String2D
/// </summary>
////////////////////////////////////////////////////////////
public class Font : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the font from a file
/// </summary>
/// <param name="filename">Font file to load</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Font(string filename) :
base(sfFont_CreateFromFile(filename))
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("font", filename);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the font from a file in a stream
/// </summary>
/// <param name="stream">Stream containing the file contents</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Font(Stream stream) :
base(IntPtr.Zero)
{
unsafe
{
stream.Position = 0;
byte[] StreamData = new byte[stream.Length];
uint Read = (uint)stream.Read(StreamData, 0, StreamData.Length);
fixed (byte* dataPtr = StreamData)
{
SetThis(sfFont_CreateFromMemory((char*)dataPtr, Read));
}
}
if (This == IntPtr.Zero)
throw new LoadingFailedException("font");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the font from another font
/// </summary>
/// <param name="copy">Font to copy</param>
////////////////////////////////////////////////////////////
public Font(Font copy) :
base(sfFont_Copy(copy.This))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get a glyph in the font
/// </summary>
/// <param name="codePoint">Unicode code point of the character to get</param>
/// <param name="characterSize">Character size</param>
/// <param name="bold">Retrieve the bold version or the regular one?</param>
/// <returns>The glyph corresponding to the character</returns>
////////////////////////////////////////////////////////////
public Glyph GetGlyph(uint codePoint, uint characterSize, bool bold)
{
return sfFont_GetGlyph(This, codePoint, characterSize, bold);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the kerning offset between two glyphs
/// </summary>
/// <param name="first">Unicode code point of the first character</param>
/// <param name="second">Unicode code point of the second character</param>
/// <param name="characterSize">Character size</param>
/// <returns>Kerning offset, in pixels</returns>
////////////////////////////////////////////////////////////
public int GetKerning(uint first, uint second, uint characterSize)
{
return sfFont_GetKerning(This, first, second, characterSize);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get spacing between two consecutive lines
/// </summary>
/// <param name="characterSize">Character size</param>
/// <returns>Line spacing, in pixels</returns>
////////////////////////////////////////////////////////////
public int GetLineSpacing(uint characterSize)
{
return sfFont_GetLineSpacing(This, characterSize);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the image containing the glyphs of a given size
/// </summary>
/// <param name="characterSize">Character size</param>
/// <returns>Image storing the glyphs for the given size</returns>
////////////////////////////////////////////////////////////
public Image GetImage(uint characterSize)
{
myImages[characterSize] = new Image(sfFont_GetImage(This, characterSize));
return myImages[characterSize];
}
////////////////////////////////////////////////////////////
/// <summary>
/// Default built-in font
/// </summary>
////////////////////////////////////////////////////////////
public static Font DefaultFont
{
get
{
if (ourDefaultFont == null)
ourDefaultFont = new Font(sfFont_GetDefaultFont());
return ourDefaultFont;
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Font]";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
if (this != ourDefaultFont)
{
if (!disposing)
Context.Global.SetActive(true);
sfFont_Destroy(This);
if (disposing)
{
foreach (Image image in myImages.Values)
image.Dispose();
}
if (!disposing)
Context.Global.SetActive(false);
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal constructor
/// </summary>
/// <param name="thisPtr">Pointer to the object in C library</param>
////////////////////////////////////////////////////////////
private Font(IntPtr thisPtr) :
base(thisPtr)
{
}
private Dictionary<uint, Image> myImages = new Dictionary<uint, Image>();
private static Font ourDefaultFont = null;
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfFont_CreateFromFile(string Filename);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
unsafe static extern IntPtr sfFont_CreateFromMemory(char* Data, uint SizeInBytes);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfFont_Copy(IntPtr Font);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfFont_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Glyph sfFont_GetGlyph(IntPtr This, uint codePoint, uint characterSize, bool bold);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern int sfFont_GetKerning(IntPtr This, uint first, uint second, uint characterSize);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern int sfFont_GetLineSpacing(IntPtr This, uint characterSize);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfFont_GetImage(IntPtr This, uint characterSize);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfFont_GetDefaultFont();
#endregion
}
}
}

View file

@ -0,0 +1,472 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.IO;
using System.Runtime.ConstrainedExecution;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Image is the low-level class for loading and
/// manipulating images
/// </summary>
////////////////////////////////////////////////////////////
public class Image : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor (invalid image)
/// </summary>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image() :
base(sfImage_Create())
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image with black color
/// </summary>
/// <param name="width">Image width</param>
/// <param name="height">Image height</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(uint width, uint height) :
this(width, height, Color.Black)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image from a single color
/// </summary>
/// <param name="width">Image width</param>
/// <param name="height">Image height</param>
/// <param name="color">Color to fill the image with</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(uint width, uint height, Color color) :
base(sfImage_CreateFromColor(width, height, color))
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image from a file
/// </summary>
/// <param name="filename">Path of the image file to load</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(string filename) :
base(sfImage_CreateFromFile(filename))
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("image", filename);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image from a file in a stream
/// </summary>
/// <param name="stream">Stream containing the file contents</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(Stream stream) :
base(IntPtr.Zero)
{
stream.Position = 0;
byte[] StreamData = new byte[stream.Length];
uint Read = (uint)stream.Read(StreamData, 0, StreamData.Length);
unsafe
{
fixed (byte* dataPtr = StreamData)
{
SetThis(sfImage_CreateFromMemory((char*)dataPtr, Read));
}
}
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image directly from an array of pixels
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(Color[,] pixels) :
base(IntPtr.Zero)
{
unsafe
{
fixed (Color* PixelsPtr = pixels)
{
uint Width = (uint)pixels.GetLength(0);
uint Height = (uint)pixels.GetLength(1);
SetThis(sfImage_CreateFromPixels(Width, Height, (byte*)PixelsPtr));
}
}
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image directly from an array of pixels
/// </summary>
/// <param name="width">Image width</param>
/// <param name="height">Image height</param>
/// <param name="pixels">array containing the pixels</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(uint width, uint height, byte[] pixels) :
base(IntPtr.Zero)
{
unsafe
{
fixed (byte* PixelsPtr = pixels)
{
SetThis(sfImage_CreateFromPixels(width, height, PixelsPtr));
}
}
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image from another image
/// </summary>
/// <param name="copy">Image to copy</param>
////////////////////////////////////////////////////////////
public Image(Image copy) :
base(sfImage_Copy(copy.This))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Save the contents of the image to a file
/// </summary>
/// <param name="filename">Path of the file to save (overwritten if already exist)</param>
/// <returns>True if saving was successful</returns>
////////////////////////////////////////////////////////////
public bool SaveToFile(string filename)
{
return sfImage_SaveToFile(This, filename);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a transparency mask from a specified colorkey
/// </summary>
/// <param name="color">Color to become transparent</param>
////////////////////////////////////////////////////////////
public void CreateMaskFromColor(Color color)
{
CreateMaskFromColor(color, 0);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a transparency mask from a specified colorkey
/// </summary>
/// <param name="color">Color to become transparent</param>
/// <param name="alpha">Alpha value to use for transparent pixels</param>
////////////////////////////////////////////////////////////
public void CreateMaskFromColor(Color color, byte alpha)
{
sfImage_CreateMaskFromColor(This, color, alpha);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Copy pixels from another image onto this one.
/// This function does a slow pixel copy and should only
/// be used at initialization time
/// </summary>
/// <param name="source">Source image to copy</param>
/// <param name="destX">X coordinate of the destination position</param>
/// <param name="destY">Y coordinate of the destination position</param>
////////////////////////////////////////////////////////////
public void Copy(Image source, uint destX, uint destY)
{
Copy(source, destX, destY, new IntRect(0, 0, 0, 0));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Copy pixels from another image onto this one.
/// This function does a slow pixel copy and should only
/// be used at initialization time
/// </summary>
/// <param name="source">Source image to copy</param>
/// <param name="destX">X coordinate of the destination position</param>
/// <param name="destY">Y coordinate of the destination position</param>
/// <param name="sourceRect">Sub-rectangle of the source image to copy</param>
////////////////////////////////////////////////////////////
public void Copy(Image source, uint destX, uint destY, IntRect sourceRect)
{
sfImage_CopyImage(This, source.This, destX, destY, sourceRect);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the image from the current contents of the
/// given window
/// </summary>
/// <param name="window">Window to capture</param>
/// <returns>True if copy has been successful</returns>
////////////////////////////////////////////////////////////
public bool CopyScreen(RenderWindow window)
{
return CopyScreen(window, new IntRect(0, 0, 0, 0));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the image from the current contents of the
/// given window
/// </summary>
/// <param name="window">Window to capture</param>
/// <param name="sourceRect">Sub-rectangle of the screen to copy</param>
/// <returns>True if copy has been successful</returns>
////////////////////////////////////////////////////////////
public bool CopyScreen(RenderWindow window, IntRect sourceRect)
{
return sfImage_CopyScreen(This, window.This, sourceRect);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get a pixel from the image
/// </summary>
/// <param name="x">X coordinate of pixel in the image</param>
/// <param name="y">Y coordinate of pixel in the image</param>
/// <returns>Color of pixel (x, y)</returns>
////////////////////////////////////////////////////////////
public Color GetPixel(uint x, uint y)
{
return sfImage_GetPixel(This, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the color of a pixel
/// </summary>
/// <param name="x">X coordinate of pixel in the image</param>
/// <param name="y">Y coordinate of pixel in the image</param>
/// <param name="color">New color for pixel (x, y)</param>
////////////////////////////////////////////////////////////
public void SetPixel(uint x, uint y, Color color)
{
sfImage_SetPixel(This, x, y, color);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get a copy of the array of pixels (RGBA 8 bits integers components)
/// Array size is Width x Height x 4
/// </summary>
/// <returns>Array of pixels</returns>
////////////////////////////////////////////////////////////
public byte[] Pixels
{
get
{
byte[] PixelsPtr = new byte[Width * Height * 4];
Marshal.Copy(sfImage_GetPixelsPtr(This), PixelsPtr, 0, PixelsPtr.Length);
return PixelsPtr;
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Update the pixels of the image
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
////////////////////////////////////////////////////////////
public void UpdatePixels(Color[,] pixels)
{
UpdatePixels(pixels, 0, 0);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Update the pixels of the image
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
/// <param name="x">X position of the rectangle to update</param>
/// <param name="y">Y position of the rectangle to update</param>
////////////////////////////////////////////////////////////
public void UpdatePixels(Color[,] pixels, uint x, uint y)
{
unsafe
{
fixed (Color* PixelsPtr = pixels)
{
int Width = pixels.GetLength(0);
int Height = pixels.GetLength(1);
sfImage_UpdatePixels(This, PixelsPtr, new IntRect((int)x, (int)y, Width, Height));
}
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Bind the image for rendering
/// </summary>
////////////////////////////////////////////////////////////
public void Bind()
{
sfImage_Bind(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Control the smooth filter
/// </summary>
////////////////////////////////////////////////////////////
public bool Smooth
{
get {return sfImage_IsSmooth(This);}
set {sfImage_SetSmooth(This, value);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the image, in pixels
/// </summary>
////////////////////////////////////////////////////////////
public uint Width
{
get {return sfImage_GetWidth(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Height of the image, in pixels
/// </summary>
////////////////////////////////////////////////////////////
public uint Height
{
get {return sfImage_GetHeight(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Image]" +
" Width(" + Width + ")" +
" Height(" + Height + ")" +
" Smooth(" + Smooth + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal constructor
/// </summary>
/// <param name="thisPtr">Pointer to the object in C library</param>
////////////////////////////////////////////////////////////
internal Image(IntPtr thisPtr) :
base(thisPtr)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
if (!disposing)
Context.Global.SetActive(true);
sfImage_Destroy(This);
if (!disposing)
Context.Global.SetActive(false);
}
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfImage_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfImage_CreateFromColor(uint Width, uint Height, Color Col);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
unsafe static extern IntPtr sfImage_CreateFromPixels(uint Width, uint Height, byte* Pixels);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfImage_CreateFromFile(string Filename);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfImage_Copy(IntPtr Image);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
unsafe static extern IntPtr sfImage_CreateFromMemory(char* Data, uint Size);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfImage_SaveToFile(IntPtr This, string Filename);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_CreateMaskFromColor(IntPtr This, Color Col, byte Alpha);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfImage_CopyScreen(IntPtr This, IntPtr Window, IntRect SourceRect);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_CopyImage(IntPtr This, IntPtr Source, uint DestX, uint DestY, IntRect SourceRect);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_SetPixel(IntPtr This, uint X, uint Y, Color Col);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfImage_GetPixel(IntPtr This, uint X, uint Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfImage_GetPixelsPtr(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
unsafe static extern void sfImage_UpdatePixels(IntPtr This, Color* Pixels, IntRect Rectangle);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_Bind(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfImage_SetSmooth(IntPtr This, bool Smooth);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfImage_GetWidth(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfImage_GetHeight(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfImage_IsSmooth(IntPtr This);
#endregion
}
}
}

View file

@ -0,0 +1,247 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// IntRect is an utility class for manipulating 2D rectangles
/// with integer coordinates
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct IntRect
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the rectangle from its coordinates
/// </summary>
/// <param name="left">Left coordinate of the rectangle</param>
/// <param name="top">Top coordinate of the rectangle</param>
/// <param name="width">Width of the rectangle</param>
/// <param name="height">Height of the rectangle</param>
////////////////////////////////////////////////////////////
public IntRect(int left, int top, int width, int height)
{
Left = left;
Top = top;
Width = width;
Height = height;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a point is inside the rectangle's area
/// </summary>
/// <param name="x">X coordinate of the point to test</param>
/// <param name="y">Y coordinate of the point to test</param>
/// <returns>True if the point is inside</returns>
////////////////////////////////////////////////////////////
public bool Contains(int x, int y)
{
return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check intersection between two rectangles
/// </summary>
/// <param name="rect"> Rectangle to test</param>
/// <returns>True if rectangles overlap</returns>
////////////////////////////////////////////////////////////
public bool Intersects(IntRect rect)
{
// Compute the intersection boundaries
int left = Math.Max(Left, rect.Left);
int top = Math.Max(Top, rect.Top);
int right = Math.Min(Left + Width, rect.Left + rect.Width);
int bottom = Math.Min(Top + Height, rect.Top + rect.Height);
return (left < right) && (top < bottom);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check intersection between two rectangles
/// </summary>
/// <param name="rect"> Rectangle to test</param>
/// <param name="overlap">Rectangle to be filled with overlapping rect</param>
/// <returns>True if rectangles overlap</returns>
////////////////////////////////////////////////////////////
public bool Intersects(IntRect rect, out IntRect overlap)
{
// Compute the intersection boundaries
int left = Math.Max(Left, rect.Left);
int top = Math.Max(Top, rect.Top);
int right = Math.Min(Left + Width, rect.Left + rect.Width);
int bottom = Math.Min(Top + Height, rect.Top + rect.Height);
// If the intersection is valid (positive non zero area), then there is an intersection
if ((left < right) && (top < bottom))
{
overlap.Left = left;
overlap.Top = top;
overlap.Width = right - left;
overlap.Height = bottom - top;
return true;
}
else
{
overlap.Left = 0;
overlap.Top = 0;
overlap.Width = 0;
overlap.Height = 0;
return false;
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[IntRect]" +
" Left(" + Left + ")" +
" Top(" + Top + ")" +
" Width(" + Width + ")" +
" Height(" + Height + ")";
}
/// <summary>Left coordinate of the rectangle</summary>
public int Left;
/// <summary>Top coordinate of the rectangle</summary>
public int Top;
/// <summary>Width of the rectangle</summary>
public int Width;
/// <summary>Height of the rectangle</summary>
public int Height;
}
////////////////////////////////////////////////////////////
/// <summary>
/// IntRect is an utility class for manipulating 2D rectangles
/// with float coordinates
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct FloatRect
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the rectangle from its coordinates
/// </summary>
/// <param name="left">Left coordinate of the rectangle</param>
/// <param name="top">Top coordinate of the rectangle</param>
/// <param name="width">Width of the rectangle</param>
/// <param name="height">Height of the rectangle</param>
////////////////////////////////////////////////////////////
public FloatRect(float left, float top, float width, float height)
{
Left = left;
Top = top;
Width = width;
Height = height;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a point is inside the rectangle's area
/// </summary>
/// <param name="x">X coordinate of the point to test</param>
/// <param name="y">Y coordinate of the point to test</param>
/// <returns>True if the point is inside</returns>
////////////////////////////////////////////////////////////
public bool Contains(float x, float y)
{
return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check intersection between two rectangles
/// </summary>
/// <param name="rect"> Rectangle to test</param>
/// <returns>True if rectangles overlap</returns>
////////////////////////////////////////////////////////////
public bool Intersects(FloatRect rect)
{
// Compute the intersection boundaries
float left = Math.Max(Left, rect.Left);
float top = Math.Max(Top, rect.Top);
float right = Math.Min(Left + Width, rect.Left + rect.Width);
float bottom = Math.Min(Top + Height, rect.Top + rect.Height);
return (left < right) && (top < bottom);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check intersection between two rectangles
/// </summary>
/// <param name="rect"> Rectangle to test</param>
/// <param name="overlap">Rectangle to be filled with overlapping rect</param>
/// <returns>True if rectangles overlap</returns>
////////////////////////////////////////////////////////////
public bool Intersects(FloatRect rect, out FloatRect overlap)
{
// Compute the intersection boundaries
float left = Math.Max(Left, rect.Left);
float top = Math.Max(Top, rect.Top);
float right = Math.Min(Left + Width, rect.Left + rect.Width);
float bottom = Math.Min(Top + Height, rect.Top + rect.Height);
// If the intersection is valid (positive non zero area), then there is an intersection
if ((left < right) && (top < bottom))
{
overlap.Left = left;
overlap.Top = top;
overlap.Width = right - left;
overlap.Height = bottom - top;
return true;
}
else
{
overlap.Left = 0;
overlap.Top = 0;
overlap.Width = 0;
overlap.Height = 0;
return false;
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[FloatRect]" +
" Left(" + Left + ")" +
" Top(" + Top + ")" +
" Width(" + Width + ")" +
" Height(" + Height + ")";
}
/// <summary>Left coordinate of the rectangle</summary>
public float Left;
/// <summary>Top coordinate of the rectangle</summary>
public float Top;
/// <summary>Width of the rectangle</summary>
public float Width;
/// <summary>Height of the rectangle</summary>
public float Height;
}
}
}

View file

@ -0,0 +1,340 @@
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
using System.Security;
using SFML.Window;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Simple wrapper for Window that allows easy
/// 2D rendering
/// </summary>
////////////////////////////////////////////////////////////
public class RenderImage : ObjectBase, RenderTarget
{
////////////////////////////////////////////////////////////
/// <summary>
/// Create the render image with the given dimensions
/// </summary>
/// <param name="width">Width of the render image</param>
/// <param name="height">Height of the render image</param>
////////////////////////////////////////////////////////////
public RenderImage(uint width, uint height) :
this(width, height, false)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the render image with the given dimensions and
/// an optional depth-buffer attached
/// </summary>
/// <param name="width">Width of the render image</param>
/// <param name="height">Height of the render image</param>
/// <param name="depthBuffer">Do you want a depth-buffer attached?</param>
////////////////////////////////////////////////////////////
public RenderImage(uint width, uint height, bool depthBuffer) :
base(sfRenderImage_Create(width, height, depthBuffer))
{
myDefaultView = new View(sfRenderImage_GetDefaultView(This));
myImage = new Image(sfRenderImage_GetImage(This));
myCurrentView = myDefaultView;
GC.SuppressFinalize(myDefaultView);
GC.SuppressFinalize(myImage);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the rendering region of the image
/// </summary>
////////////////////////////////////////////////////////////
public uint Width
{
get {return sfRenderImage_GetWidth(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Height of the rendering region of the image
/// </summary>
////////////////////////////////////////////////////////////
public uint Height
{
get {return sfRenderImage_GetHeight(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Activate of deactivate the render image as the current target
/// for rendering
/// </summary>
/// <param name="active">True to activate, false to deactivate (true by default)</param>
/// <returns>True if operation was successful, false otherwise</returns>
////////////////////////////////////////////////////////////
public bool SetActive(bool active)
{
return sfRenderImage_SetActive(This, active);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Default view of the render image
/// </summary>
////////////////////////////////////////////////////////////
public View DefaultView
{
get {return myDefaultView;}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Current view active in the render image
/// </summary>
////////////////////////////////////////////////////////////
public View CurrentView
{
get {return myCurrentView;}
set {myCurrentView = value; sfRenderImage_SetView(This, value.This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the viewport of a view applied to this target
/// </summary>
/// <param name="view">Target view</param>
/// <returns>Viewport rectangle, expressed in pixels in the current target</returns>
////////////////////////////////////////////////////////////
public IntRect GetViewport(View view)
{
return sfRenderImage_GetViewport(This, view.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the current view of the window
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y)
{
return ConvertCoords(x, y, CurrentView);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the given view
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <param name="view">Target view to convert the point to</param>
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y, View view)
{
Vector2 point;
sfRenderImage_ConvertCoords(This, x, y, out point.X, out point.Y, view.This);
return point;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire render image with black color
/// </summary>
////////////////////////////////////////////////////////////
public void Clear()
{
sfRenderImage_Clear(This, Color.Black);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire render image with a single color
/// </summary>
/// <param name="color">Color to use to clear the image</param>
////////////////////////////////////////////////////////////
public void Clear(Color color)
{
sfRenderImage_Clear(This, color);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the render image
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
////////////////////////////////////////////////////////////
public void Draw(Drawable objectToDraw)
{
objectToDraw.Render(this, null);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the render image with a shader
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
public void Draw(Drawable objectToDraw, Shader shader)
{
objectToDraw.Render(this, shader);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Save the current OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
public void SaveGLStates()
{
sfRenderImage_SaveGLStates(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Restore the previously saved OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
public void RestoreGLStates()
{
sfRenderImage_RestoreGLStates(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Update the contents of the target image
/// </summary>
////////////////////////////////////////////////////////////
public void Display()
{
sfRenderImage_Display(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Target image of the render image
/// </summary>
////////////////////////////////////////////////////////////
public Image Image
{
get {return myImage;}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Tell whether or not the system supports render images
/// </summary>
////////////////////////////////////////////////////////////
public static bool IsAvailable
{
get {return sfRenderImage_IsAvailable();}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[RenderImage]" +
" Width(" + Width + ")" +
" Height(" + Height + ")" +
" Image(" + Image + ")" +
" DefaultView(" + DefaultView + ")" +
" CurrentView(" + CurrentView + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
if (!disposing)
Context.Global.SetActive(true);
sfRenderImage_Destroy(This);
if (disposing)
{
myDefaultView.Dispose();
myImage.Dispose();
}
if (!disposing)
Context.Global.SetActive(false);
}
private View myCurrentView = null;
private View myDefaultView = null;
private Image myImage = null;
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderImage_Create(uint Width, uint Height, bool DepthBuffer);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_Clear(IntPtr This, Color ClearColor);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfRenderImage_GetWidth(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfRenderImage_GetHeight(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderImage_SetActive(IntPtr This, bool Active);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderImage_SaveGLStates(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderImage_RestoreGLStates(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderImage_Display(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_SetView(IntPtr This, IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderImage_GetView(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderImage_GetDefaultView(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntRect sfRenderImage_GetViewport(IntPtr This, IntPtr TargetView);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_ConvertCoords(IntPtr This, uint WindowX, uint WindowY, out float ViewX, out float ViewY, IntPtr TargetView);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderImage_GetImage(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderImage_IsAvailable();
#endregion
}
}
}

View file

@ -0,0 +1,124 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using SFML.Window;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Abstract base class for render targets (renderwindow, renderimage)
/// </summary>
////////////////////////////////////////////////////////////
public interface RenderTarget
{
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the rendering region of the window
/// </summary>
////////////////////////////////////////////////////////////
uint Width {get;}
////////////////////////////////////////////////////////////
/// <summary>
/// Height of the rendering region of the window
/// </summary>
////////////////////////////////////////////////////////////
uint Height {get;}
////////////////////////////////////////////////////////////
/// <summary>
/// Default view of the window
/// </summary>
////////////////////////////////////////////////////////////
View DefaultView {get;}
////////////////////////////////////////////////////////////
/// <summary>
/// Current view active in the window
/// </summary>
////////////////////////////////////////////////////////////
View CurrentView {get;}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the viewport of a view applied to this target
/// </summary>
/// <param name="view">Target view</param>
/// <returns>Viewport rectangle, expressed in pixels in the current target</returns>
////////////////////////////////////////////////////////////
IntRect GetViewport(View view);
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the current view of the window
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <returns>Converted point</returns>
////////////////////////////////////////////////////////////
Vector2 ConvertCoords(uint x, uint y);
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the given view
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <param name="view">Target view to convert the point to</param>
/// <returns>Converted point</returns>
////////////////////////////////////////////////////////////
Vector2 ConvertCoords(uint x, uint y, View view);
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire window with black color
/// </summary>
////////////////////////////////////////////////////////////
void Clear();
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire window with a single color
/// </summary>
/// <param name="color">Color to use to clear the window</param>
////////////////////////////////////////////////////////////
void Clear(Color color);
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the window
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
////////////////////////////////////////////////////////////
void Draw(Drawable objectToDraw);
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the render image with a shader
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
void Draw(Drawable objectToDraw, Shader shader);
////////////////////////////////////////////////////////////
/// <summary>
/// Save the current OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
void SaveGLStates();
////////////////////////////////////////////////////////////
/// <summary>
/// Restore the previously saved OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
void RestoreGLStates();
}
}
}

View file

@ -0,0 +1,611 @@
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
using System.Security;
using SFML.Window;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Simple wrapper for Window that allows easy
/// 2D rendering
/// </summary>
////////////////////////////////////////////////////////////
public class RenderWindow : SFML.Window.Window, RenderTarget
{
////////////////////////////////////////////////////////////
/// <summary>
/// Create the window with default style and creation settings
/// </summary>
/// <param name="mode">Video mode to use</param>
/// <param name="title">Title of the window</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title) :
this(mode, title, Styles.Default, new ContextSettings(24, 8))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the window with default creation settings
/// </summary>
/// <param name="mode">Video mode to use</param>
/// <param name="title">Title of the window</param>
/// <param name="style">Window style (Resize | Close by default)</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title, Styles style) :
this(mode, title, style, new ContextSettings(24, 8))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the window
/// </summary>
/// <param name="mode">Video mode to use</param>
/// <param name="title">Title of the window</param>
/// <param name="style">Window style (Resize | Close by default)</param>
/// <param name="settings">Creation parameters</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) :
base(sfRenderWindow_Create(mode, title, style, ref settings), 0)
{
Initialize();
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the window from an existing control with default creation settings
/// </summary>
/// <param name="handle">Platform-specific handle of the control</param>
////////////////////////////////////////////////////////////
public RenderWindow(IntPtr handle) :
this(handle, new ContextSettings(24, 8))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create the window from an existing control
/// </summary>
/// <param name="handle">Platform-specific handle of the control</param>
/// <param name="settings">Creation parameters</param>
////////////////////////////////////////////////////////////
public RenderWindow(IntPtr handle, ContextSettings settings) :
base(sfRenderWindow_CreateFromHandle(handle, ref settings), 0)
{
Initialize();
}
////////////////////////////////////////////////////////////
/// <summary>
/// Tell whether or not the window is opened (ie. has been created).
/// Note that a hidden window (Show(false))
/// will still return true
/// </summary>
/// <returns>True if the window is opened</returns>
////////////////////////////////////////////////////////////
public override bool IsOpened()
{
return sfRenderWindow_IsOpened(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Close (destroy) the window.
/// The Window instance remains valid and you can call
/// Create to recreate the window
/// </summary>
////////////////////////////////////////////////////////////
public override void Close()
{
sfRenderWindow_Close(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Display the window on screen
/// </summary>
////////////////////////////////////////////////////////////
public override void Display()
{
sfRenderWindow_Display(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the rendering region of the window
/// </summary>
////////////////////////////////////////////////////////////
public override uint Width
{
get {return sfRenderWindow_GetWidth(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Height of the rendering region of the window
/// </summary>
////////////////////////////////////////////////////////////
public override uint Height
{
get {return sfRenderWindow_GetHeight(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Creation settings of the window
/// </summary>
////////////////////////////////////////////////////////////
public override ContextSettings Settings
{
get {return sfRenderWindow_GetSettings(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Enable / disable vertical synchronization
/// </summary>
/// <param name="enable">True to enable v-sync, false to deactivate</param>
////////////////////////////////////////////////////////////
public override void UseVerticalSync(bool enable)
{
sfRenderWindow_UseVerticalSync(This, enable);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Show or hide the mouse cursor
/// </summary>
/// <param name="show">True to show, false to hide</param>
////////////////////////////////////////////////////////////
public override void ShowMouseCursor(bool show)
{
sfRenderWindow_ShowMouseCursor(This, show);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the position of the mouse cursor
/// </summary>
/// <param name="x">Left coordinate of the cursor, relative to the window</param>
/// <param name="y">Top coordinate of the cursor, relative to the window</param>
////////////////////////////////////////////////////////////
public override void SetCursorPosition(uint x, uint y)
{
sfRenderWindow_SetCursorPosition(This, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the position of the window on screen.
/// Only works for top-level windows
/// </summary>
/// <param name="x">Left position</param>
/// <param name="y">Top position</param>
////////////////////////////////////////////////////////////
public override void SetPosition(int x, int y)
{
sfRenderWindow_SetPosition(This, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the size of the rendering region of the window
/// </summary>
/// <param name="width">New width</param>
/// <param name="height">New height</param>
////////////////////////////////////////////////////////////
public override void SetSize(uint width, uint height)
{
sfRenderWindow_SetSize(This, width, height);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Show or hide the window
/// </summary>
/// <param name="show">True to show, false to hide</param>
////////////////////////////////////////////////////////////
public override void Show(bool show)
{
sfRenderWindow_Show(This, show);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Enable or disable automatic key-repeat.
/// Automatic key-repeat is enabled by default
/// </summary>
/// <param name="enable">True to enable, false to disable</param>
////////////////////////////////////////////////////////////
public override void EnableKeyRepeat(bool enable)
{
sfRenderWindow_EnableKeyRepeat(This, enable);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the window's icon
/// </summary>
/// <param name="width">Icon's width, in pixels</param>
/// <param name="height">Icon's height, in pixels</param>
/// <param name="pixels">Array of pixels, format must be RGBA 32 bits</param>
////////////////////////////////////////////////////////////
public override void SetIcon(uint width, uint height, byte[] pixels)
{
unsafe
{
fixed (byte* PixelsPtr = pixels)
{
sfRenderWindow_SetIcon(This, width, height, PixelsPtr);
}
}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Activate of deactivate the window as the current target
/// for rendering
/// </summary>
/// <param name="active">True to activate, false to deactivate (true by default)</param>
/// <returns>True if operation was successful, false otherwise</returns>
////////////////////////////////////////////////////////////
public override bool SetActive(bool active)
{
return sfRenderWindow_SetActive(This, active);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Limit the framerate to a maximum fixed frequency
/// </summary>
/// <param name="limit">Framerate limit, in frames per seconds (use 0 to disable limit)</param>
////////////////////////////////////////////////////////////
public override void SetFramerateLimit(uint limit)
{
sfRenderWindow_SetFramerateLimit(This, limit);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get time elapsed since last frame
/// </summary>
/// <returns>Time elapsed, in seconds</returns>
////////////////////////////////////////////////////////////
public override float GetFrameTime()
{
return sfRenderWindow_GetFrameTime(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
/// </summary>
/// <param name="threshold">New threshold, in range [0, 100]</param>
////////////////////////////////////////////////////////////
public override void SetJoystickThreshold(float threshold)
{
sfRenderWindow_SetJoystickThreshold(This, threshold);
}
////////////////////////////////////////////////////////////
/// <summary>
/// OS-specific handle of the window
/// </summary>
////////////////////////////////////////////////////////////
public override IntPtr SystemHandle
{
get {return sfRenderWindow_GetSystemHandle(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Default view of the window
/// </summary>
////////////////////////////////////////////////////////////
public View DefaultView
{
get {return myDefaultView;}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Current view active in the window
/// </summary>
////////////////////////////////////////////////////////////
public View CurrentView
{
get {return myCurrentView;}
set {myCurrentView = value; sfRenderWindow_SetView(This, value.This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the viewport of a view applied to this target
/// </summary>
/// <param name="view">Target view</param>
/// <returns>Viewport rectangle, expressed in pixels in the current target</returns>
////////////////////////////////////////////////////////////
public IntRect GetViewport(View view)
{
return sfRenderWindow_GetViewport(This, view.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the current view of the window
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y)
{
return ConvertCoords(x, y, CurrentView);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Convert a point in target coordinates into view coordinates
/// This version uses the given view
/// </summary>
/// <param name="x">X coordinate of the point to convert, relative to the target</param>
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <param name="view">Target view to convert the point to</param>
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y, View view)
{
Vector2 point;
sfRenderWindow_ConvertCoords(This, x, y, out point.X, out point.Y, view.This);
return point;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire window with black color
/// </summary>
////////////////////////////////////////////////////////////
public void Clear()
{
sfRenderWindow_Clear(This, Color.Black);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Clear the entire window with a single color
/// </summary>
/// <param name="color">Color to use to clear the window</param>
////////////////////////////////////////////////////////////
public void Clear(Color color)
{
sfRenderWindow_Clear(This, color);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the window
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
////////////////////////////////////////////////////////////
public void Draw(Drawable objectToDraw)
{
objectToDraw.Render(this, null);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Draw something into the window with a shader
/// </summary>
/// <param name="objectToDraw">Object to draw</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
public void Draw(Drawable objectToDraw, Shader shader)
{
objectToDraw.Render(this, shader);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Save the current OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
public void SaveGLStates()
{
sfRenderWindow_SaveGLStates(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Restore the previously saved OpenGL render states and matrices
/// </summary>
////////////////////////////////////////////////////////////
public void RestoreGLStates()
{
sfRenderWindow_RestoreGLStates(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[RenderWindow]" +
" Width(" + Width + ")" +
" Height(" + Height + ")" +
" Settings(" + Settings + ")" +
" DefaultView(" + DefaultView + ")" +
" CurrentView(" + CurrentView + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal function to get the next event
/// </summary>
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
/// <returns>True if there was an event, false otherwise</returns>
////////////////////////////////////////////////////////////
protected override bool GetEvent(out Event eventToFill)
{
return sfRenderWindow_GetEvent(This, out eventToFill);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal function to get the next event (blocking)
/// </summary>
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
/// <returns>False if any error occured</returns>
////////////////////////////////////////////////////////////
protected override bool WaitEvent(out Event eventToFill)
{
return sfRenderWindow_WaitEvent(This, out eventToFill);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfRenderWindow_Destroy(This);
if (disposing)
myDefaultView.Dispose();
}
////////////////////////////////////////////////////////////
/// <summary>
/// Do common initializations
/// </summary>
////////////////////////////////////////////////////////////
private void Initialize()
{
myInput = new Input(sfRenderWindow_GetInput(This));
myDefaultView = new View(sfRenderWindow_GetDefaultView(This));
myCurrentView = myDefaultView;
GC.SuppressFinalize(myDefaultView);
}
private View myCurrentView = null;
private View myDefaultView = null;
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, ref ContextSettings Params);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetInput(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_IsOpened(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Close(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_GetEvent(IntPtr This, out Event Evt);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_WaitEvent(IntPtr This, out Event Evt);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Clear(IntPtr This, Color ClearColor);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Display(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfRenderWindow_GetWidth(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfRenderWindow_GetHeight(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern ContextSettings sfRenderWindow_GetSettings(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_UseVerticalSync(IntPtr This, bool Enable);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_ShowMouseCursor(IntPtr This, bool Show);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetCursorPosition(IntPtr This, uint X, uint Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetPosition(IntPtr This, int X, int Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetSize(IntPtr This, uint Width, uint Height);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Show(IntPtr This, bool Show);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_EnableKeyRepeat(IntPtr This, bool Enable);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
unsafe static extern void sfRenderWindow_SetIcon(IntPtr This, uint Width, uint Height, byte* Pixels);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_SetActive(IntPtr This, bool Active);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_SaveGLStates(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_RestoreGLStates(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetFramerateLimit(IntPtr This, uint Limit);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfRenderWindow_GetFrameTime(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetJoystickThreshold(IntPtr This, float Threshold);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_SetView(IntPtr This, IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetView(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetDefaultView(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntRect sfRenderWindow_GetViewport(IntPtr This, IntPtr TargetView);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_ConvertCoords(IntPtr This, uint WindowX, uint WindowY, out float ViewX, out float ViewY, IntPtr TargetView);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetSystemHandle(IntPtr This);
#endregion
}
}
}

View file

@ -0,0 +1,265 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Collections.Generic;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Wrapper for pixel shaders
/// </summary>
////////////////////////////////////////////////////////////
public class Shader : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor (invalid shader)
/// </summary>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Shader() :
base(sfShader_Create())
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("shader");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Load the shader from a file
/// </summary>
/// <param name="filename">Path of the shader file to load</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Shader(string filename) :
base(sfShader_CreateFromFile(filename))
{
if (This == IntPtr.Zero)
throw new LoadingFailedException("shader", filename);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the shader from another shader
/// </summary>
/// <param name="copy">Shader to copy</param>
////////////////////////////////////////////////////////////
public Shader(Shader copy) :
base(sfShader_Copy(copy.This))
{
foreach (KeyValuePair<string, Image> pair in copy.myTextures)
myTextures[pair.Key] = copy.myTextures[pair.Key];
}
////////////////////////////////////////////////////////////
/// <summary>
/// Load the shader from a text in memory
/// </summary>
/// <param name="shader">String containing the shader code</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
void LoadFromString(string shader)
{
SetThis(sfShader_CreateFromMemory(shader));
if (This == IntPtr.Zero)
throw new LoadingFailedException("shader");
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change a vector2 parameter of the shader
/// </summary>
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="v">Value of the parameter</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, Vector2 v)
{
SetParameter(name, v.X, v.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change a 1-component parameter of the shader
/// </summary>
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="x">Value of the parameter</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, float x)
{
sfShader_SetParameter1(This, name, x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change a 2-component parameter of the shader
/// </summary>
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="x">X component of the value</param>
/// <param name="y">Y component of the value</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, float x, float y)
{
sfShader_SetParameter2(This, name, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change a 3-component parameter of the shader
/// </summary>
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="x">X component of the value</param>
/// <param name="y">Y component of the value</param>
/// <param name="z">Z component of the value</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, float x, float y, float z)
{
sfShader_SetParameter3(This, name, x, y, z);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change a 4-component parameter of the shader
/// </summary>
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="x">X component of the value</param>
/// <param name="y">Y component of the value</param>
/// <param name="z">Z component of the value</param>
/// <param name="w">W component of the value</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, float x, float y, float z, float w)
{
sfShader_SetParameter4(This, name, x, y, z, w);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Set a texture parameter
/// </summary>
/// <param name="name">Name of the texture in the shader</param>
/// <param name="texture">Image to set (pass null to use the texture of the object being drawn)</param>
////////////////////////////////////////////////////////////
public void SetTexture(string name, Image texture)
{
myTextures[name] = texture;
sfShader_SetTexture(This, name, texture != null ? texture.This : IntPtr.Zero);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Bind the shader for rendering
/// </summary>
////////////////////////////////////////////////////////////
public void Bind()
{
sfShader_Bind(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Unbind the shader
/// </summary>
////////////////////////////////////////////////////////////
public void Unbind()
{
sfShader_Unbind(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Tell whether or not the system supports shaders
/// </summary>
////////////////////////////////////////////////////////////
public static bool IsAvailable
{
get {return sfShader_IsAvailable();}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Special image representing the texture used by the object being drawn
/// </summary>
////////////////////////////////////////////////////////////
public static Image CurrentTexture
{
get {return null;}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Shader]";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
if (!disposing)
Context.Global.SetActive(true);
myTextures.Clear();
sfShader_Destroy(This);
if (!disposing)
Context.Global.SetActive(false);
}
Dictionary<string, Image> myTextures = new Dictionary<string, Image>();
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShader_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShader_CreateFromFile(string Filename);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShader_CreateFromMemory(string Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShader_Copy(IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_Destroy(IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_SetParameter1(IntPtr Shader, string Name, float X);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_SetParameter2(IntPtr Shader, string Name, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_SetParameter3(IntPtr Shader, string Name, float X, float Y, float Z);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_SetParameter4(IntPtr Shader, string Name, float X, float Y, float Z, float W);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_SetTexture(IntPtr Shader, string Name, IntPtr Texture);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_Bind(IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShader_Unbind(IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfShader_IsAvailable();
#endregion
}
}
}

View file

@ -0,0 +1,564 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Shape defines a drawable convex shape ; it also defines
/// helper functions to draw simple shapes like
/// lines, rectangles, circles, etc.
/// </summary>
////////////////////////////////////////////////////////////
public class Shape : Drawable
{
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor
/// </summary>
////////////////////////////////////////////////////////////
public Shape() :
base(sfShape_Create())
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the shape from another shape
/// </summary>
/// <param name="copy">Shape to copy</param>
////////////////////////////////////////////////////////////
public Shape(Shape copy) :
base(sfShape_Copy(copy.This))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
{
get { return new Vector2(sfShape_GetX(This), sfShape_GetY(This)); }
set { sfShape_SetPosition(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotation of the object, defined in degrees
/// </summary>
////////////////////////////////////////////////////////////
public override float Rotation
{
get { return sfShape_GetRotation(This); }
set { sfShape_SetRotation(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
{
get { return new Vector2(sfShape_GetScaleX(This), sfShape_GetScaleY(This)); }
set { sfShape_SetScale(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Origin of the transformation of the object
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
{
get { return new Vector2(sfShape_GetOriginX(This), sfShape_GetOriginY(This)); }
set { sfShape_SetOrigin(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Global color of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Color Color
{
get { return sfShape_GetColor(This); }
set { sfShape_SetColor(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Blending mode of the object
/// </summary>
////////////////////////////////////////////////////////////
public override BlendMode BlendMode
{
get { return sfShape_GetBlendMode(This); }
set { sfShape_SetBlendMode(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
{
Vector2 Transformed;
sfShape_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
{
Vector2 Transformed;
sfShape_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Add a point to the shape
/// </summary>
/// <param name="position">Position of the point</param>
/// <param name="color">Color of the point</param>
////////////////////////////////////////////////////////////
public void AddPoint(Vector2 position, Color color)
{
AddPoint(position, color, Color.Black);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Add a point to the shape
/// </summary>
/// <param name="position">Position of the point</param>
/// <param name="color">Color of the point</param>
/// <param name="outlineColor">Outline color of the point</param>
////////////////////////////////////////////////////////////
public void AddPoint(Vector2 position, Color color, Color outlineColor)
{
sfShape_AddPoint(This, position.X, position.Y, color, outlineColor);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Enable or disable filling the shape.
/// Fill is enabled by default
/// </summary>
/// <param name="enable">True to enable, false to disable</param>
////////////////////////////////////////////////////////////
public void EnableFill(bool enable)
{
sfShape_EnableFill(This, enable);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Enable or disable drawing the shape outline.
/// Outline is enabled by default
/// </summary>
/// <param name="enable">True to enable, false to disable</param>
////////////////////////////////////////////////////////////
public void EnableOutline(bool enable)
{
sfShape_EnableOutline(This, enable);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the shape outline
/// </summary>
////////////////////////////////////////////////////////////
public float OutlineWidth
{
get {return sfShape_GetOutlineWidth(This);}
set {sfShape_SetOutlineWidth(This, value);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Total number of points of the shape
/// </summary>
////////////////////////////////////////////////////////////
public uint PointsCount
{
get {return sfShape_GetPointsCount(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Set the position of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <param name="position">New position of the index-th point</param>
////////////////////////////////////////////////////////////
public void SetPointPosition(uint index, Vector2 position)
{
sfShape_SetPointPosition(This, index, position.X, position.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the position of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <returns>Position of the index-th point</returns>
////////////////////////////////////////////////////////////
public Vector2 GetPointPosition(uint index)
{
Vector2 Pos;
sfShape_GetPointPosition(This, index, out Pos.X, out Pos.Y);
return Pos;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Set the color of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <param name="color">New color of the index-th point</param>
////////////////////////////////////////////////////////////
public void SetPointColor(uint index, Color color)
{
sfShape_SetPointColor(This, index, color);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the color of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <returns>Color of the index-th point</returns>
////////////////////////////////////////////////////////////
public Color GetPointColor(uint index)
{
return sfShape_GetPointColor(This, index);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Set the outline color of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <param name="color">New outline color of the index-th point</param>
////////////////////////////////////////////////////////////
public void SetPointOutlineColor(uint index, Color color)
{
sfShape_SetPointOutlineColor(This, index, color);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the outline color of a point
/// </summary>
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <returns>Outline color of the index-th point</returns>
////////////////////////////////////////////////////////////
public Color GetPointOutlineColor(uint index)
{
return sfShape_GetPointOutlineColor(This, index);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single line
/// </summary>
/// <param name="p1">Position of the first point</param>
/// <param name="p2">Position of the second point</param>
/// <param name="thickness">Line thickness</param>
/// <param name="color">Color used to draw the line</param>
/// <returns>New line shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Line(Vector2 p1, Vector2 p2, float thickness, Color color)
{
return Line(p1, p2, thickness, color, 0, Color.White);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single line
/// </summary>
/// <param name="p1">Position of the first point</param>
/// <param name="p2">Position of the second point</param>
/// <param name="thickness">Line thickness</param>
/// <param name="color">Color used to draw the line</param>
/// <param name="outline">Outline width</param>
/// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New line shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Line(Vector2 p1, Vector2 p2, float thickness, Color color, float outline, Color outlineColor)
{
return new Shape(sfShape_CreateLine(p1.X, p1.Y, p2.X, p2.Y, thickness, color, outline, outlineColor));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single rectangle
/// </summary>
/// <param name="rectangle">Rectangle to create</param>
/// <param name="color">Color used to fill the rectangle</param>
/// <returns>New rectangle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Rectangle(FloatRect rectangle, Color color)
{
return Rectangle(rectangle, color, 0, Color.White);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single rectangle
/// </summary>
/// <param name="rectangle">Rectangle to create</param>
/// <param name="color">Color used to fill the rectangle</param>
/// <param name="outline">Outline width</param>
/// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New rectangle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Rectangle(FloatRect rectangle, Color color, float outline, Color outlineColor)
{
return new Shape(sfShape_CreateRectangle(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, color, outline, outlineColor));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single circle
/// </summary>
/// <param name="center">Position of the center</param>
/// <param name="radius">Radius of the circle</param>
/// <param name="color">Color used to fill the circle</param>
/// <returns>New circle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Circle(Vector2 center, float radius, Color color)
{
return Circle(center, radius, color, 0, Color.White);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Create a shape made of a single circle
/// </summary>
/// <param name="center">Position of the center</param>
/// <param name="radius">Radius of the circle</param>
/// <param name="color">Color used to fill the circle</param>
/// <param name="outline">Outline width</param>
/// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New circle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Circle(Vector2 center, float radius, Color color, float outline, Color outlineColor)
{
return new Shape(sfShape_CreateCircle(center.X, center.Y, radius, color, outline, outlineColor));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Shape]" +
" Position(" + Position + ")" +
" Rotation(" + Rotation + ")" +
" Scale(" + Scale + ")" +
" Origin(" + Origin + ")" +
" Color(" + Color + ")" +
" BlendMode(" + BlendMode + ")" +
" OutlineWidth(" + OutlineWidth + ")" +
" PointsCount(" + PointsCount + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render window
/// </summary>
/// <param name="target">Target render window</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderWindow target, Shader shader)
{
if (shader == null)
sfRenderWindow_DrawShape(target.This, This);
else
sfRenderWindow_DrawShapeWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render image
/// </summary>
/// <param name="target">Target render image</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderImage target, Shader shader)
{
if (shader == null)
sfRenderImage_DrawShape(target.This, This);
else
sfRenderImage_DrawShapeWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfShape_Destroy(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal constructor
/// </summary>
/// <param name="thisPtr">Pointer to the internal object in C library</param>
////////////////////////////////////////////////////////////
private Shape(IntPtr thisPtr) :
base(thisPtr)
{
}
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShape_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShape_Copy(IntPtr Shape);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetPosition(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetRotation(IntPtr This, float Rotation);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetRotation(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetScale(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetScaleX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetScaleY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetOrigin(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetOriginX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetOriginY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetColor(IntPtr This, Color Color);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfShape_GetColor(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetBlendMode(IntPtr This, BlendMode Mode);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern BlendMode sfShape_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfShape_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfShape_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawShape(IntPtr This, IntPtr Shape);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawShapeWithShader(IntPtr This, IntPtr Shape, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawShape(IntPtr This, IntPtr Shape);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawShapeWithShader(IntPtr This, IntPtr Shape, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShape_CreateLine(float P1X, float P1Y, float P2X, float P2Y, float Thickness, Color Col, float Outline, Color OutlineCol);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShape_CreateRectangle(float P1X, float P1Y, float P2X, float P2Y, Color Col, float Outline, Color OutlineCol);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfShape_CreateCircle(float X, float Y, float Radius, Color Col, float Outline, Color OutlineCol);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_AddPoint(IntPtr This, float X, float Y, Color Col, Color OutlineCol);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_EnableFill(IntPtr This, bool Enable);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_EnableOutline(IntPtr This, bool Enable);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetOutlineWidth(IntPtr This, float Width);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfShape_GetOutlineWidth(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfShape_GetPointsCount(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetPointPosition(IntPtr This, uint Index, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_GetPointPosition(IntPtr This, uint Index, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetPointColor(IntPtr This, uint Index, Color Col);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfShape_GetPointColor(IntPtr This, uint Index);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfShape_SetPointOutlineColor(IntPtr This, uint Index, Color Col);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfShape_GetPointOutlineColor(IntPtr This, uint Index);
#endregion
}
}
}

View file

@ -0,0 +1,396 @@
using System;
using System.Security;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// This class defines a sprite : texture, transformations,
/// color, and draw on screen
/// </summary>
////////////////////////////////////////////////////////////
public class Sprite : Drawable
{
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor
/// </summary>
////////////////////////////////////////////////////////////
public Sprite() :
base(sfSprite_Create())
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the sprite from a source image
/// </summary>
/// <param name="image">Source image to assign to the sprite</param>
////////////////////////////////////////////////////////////
public Sprite(Image image) :
base(sfSprite_Create())
{
Image = image;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the sprite from another sprite
/// </summary>
/// <param name="copy">Sprite to copy</param>
////////////////////////////////////////////////////////////
public Sprite(Sprite copy) :
base(sfSprite_Copy(copy.This))
{
Image = copy.Image;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
{
get { return new Vector2(sfSprite_GetX(This), sfSprite_GetY(This)); }
set { sfSprite_SetPosition(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotation of the object, defined in degrees
/// </summary>
////////////////////////////////////////////////////////////
public override float Rotation
{
get { return sfSprite_GetRotation(This); }
set { sfSprite_SetRotation(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
{
get { return new Vector2(sfSprite_GetScaleX(This), sfSprite_GetScaleY(This)); }
set { sfSprite_SetScale(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Origin of the transformation of the object
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
{
get { return new Vector2(sfSprite_GetOriginX(This), sfSprite_GetOriginY(This)); }
set { sfSprite_SetOrigin(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Global color of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Color Color
{
get { return sfSprite_GetColor(This); }
set { sfSprite_SetColor(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Blending mode of the object
/// </summary>
////////////////////////////////////////////////////////////
public override BlendMode BlendMode
{
get { return sfSprite_GetBlendMode(This); }
set { sfSprite_SetBlendMode(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
{
Vector2 Transformed;
sfSprite_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
{
Vector2 Transformed;
sfSprite_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Width of the sprite
/// </summary>
////////////////////////////////////////////////////////////
public float Width
{
get { return sfSprite_GetWidth(This); }
set { sfSprite_Resize(This, value, this.Height); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Height of the sprite
/// </summary>
////////////////////////////////////////////////////////////
public float Height
{
get { return sfSprite_GetHeight(This); }
set { sfSprite_Resize(This, this.Width, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Source images displayed by the sprite
/// </summary>
////////////////////////////////////////////////////////////
public Image Image
{
get { return myImage; }
set { myImage = value; sfSprite_SetImage(This, value != null ? value.This : IntPtr.Zero, false); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Sub-rectangle of the source image displayed by the sprite
/// </summary>
////////////////////////////////////////////////////////////
public IntRect SubRect
{
get { return sfSprite_GetSubRect(This); }
set { sfSprite_SetSubRect(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Flip the sprite horizontically
/// </summary>
/// <param name="flipped">True to flip, false to canel flip</param>
////////////////////////////////////////////////////////////
public void FlipX(bool flipped)
{
sfSprite_FlipX(This, flipped);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Flip the sprite vertically
/// </summary>
/// <param name="flipped">True to flip, false to canel flip</param>
////////////////////////////////////////////////////////////
public void FlipY(bool flipped)
{
sfSprite_FlipY(This, flipped);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the color of a given pixel in the sprite
/// (point is in local coordinates)
/// </summary>
/// <param name="x">X coordinate of the pixel to get</param>
/// <param name="y">Y coordinate of the pixel to get</param>
/// <returns>Color of pixel (x, y)</returns>
////////////////////////////////////////////////////////////
public Color GetPixel(uint x, uint y)
{
return sfSprite_GetPixel(This, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Sprite]" +
" Position(" + Position + ")" +
" Rotation(" + Rotation + ")" +
" Scale(" + Scale + ")" +
" Origin(" + Origin + ")" +
" Color(" + Color + ")" +
" BlendMode(" + BlendMode + ")" +
" Width(" + Width + ")" +
" Height(" + Height + ")" +
" SubRect(" + SubRect + ")" +
" Image(" + Image + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render window
/// </summary>
/// <param name="target">Target render window</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderWindow target, Shader shader)
{
if (shader == null)
sfRenderWindow_DrawSprite(target.This, This);
else
sfRenderWindow_DrawSpriteWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render image
/// </summary>
/// <param name="target">Target render image</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderImage target, Shader shader)
{
if (shader == null)
sfRenderImage_DrawSprite(target.This, This);
else
sfRenderImage_DrawSpriteWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfSprite_Destroy(This);
}
private Image myImage = null;
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfSprite_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfSprite_Copy(IntPtr Sprite);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetPosition(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetRotation(IntPtr This, float Rotation);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetRotation(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetScale(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetScaleX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetScaleY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetOrigin(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetOriginX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetOriginY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetColor(IntPtr This, Color Color);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfSprite_GetColor(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetBlendMode(IntPtr This, BlendMode Mode);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern BlendMode sfSprite_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfSprite_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfSprite_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawSprite(IntPtr This, IntPtr Sprite);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawSpriteWithShader(IntPtr This, IntPtr Sprite, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawSprite(IntPtr This, IntPtr Sprite);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawSpriteWithShader(IntPtr This, IntPtr Sprite, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_Resize(IntPtr This, float Width, float Height);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetWidth(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfSprite_GetHeight(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetImage(IntPtr This, IntPtr Image, bool AdjustToNewSize);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_SetSubRect(IntPtr This, IntRect Rect);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntRect sfSprite_GetSubRect(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_FlipX(IntPtr This, bool Flipped);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfSprite_FlipY(IntPtr This, bool Flipped);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfSprite_GetPixel(IntPtr This, uint X, uint Y);
#endregion
}
}
}

View file

@ -0,0 +1,439 @@
using System;
using System.Security;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// This class defines a graphical 2D text, that can be drawn on screen
/// </summary>
////////////////////////////////////////////////////////////
public class Text : Drawable
{
////////////////////////////////////////////////////////////
/// <summary>
/// Enumerate the string drawing styles
/// </summary>
////////////////////////////////////////////////////////////
[Flags]
public enum Styles
{
/// <summary>Regular characters, no style</summary>
Regular = 0,
/// <summary> Characters are bold</summary>
Bold = 1 << 0,
/// <summary>Characters are in italic</summary>
Italic = 1 << 1,
/// <summary>Characters are underlined</summary>
Underlined = 1 << 2
}
////////////////////////////////////////////////////////////
/// <summary>
/// Default constructor
/// </summary>
////////////////////////////////////////////////////////////
public Text() :
this("")
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the text from a string
/// </summary>
/// <param name="str">String to display</param>
////////////////////////////////////////////////////////////
public Text(string str) :
this(str, Font.DefaultFont)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the text from a string and a font
/// </summary>
/// <param name="str">String to display</param>
/// <param name="font">Font to use</param>
////////////////////////////////////////////////////////////
public Text(string str, Font font) :
this(str, font, 30)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the text from a string, font and size
/// </summary>
/// <param name="str">String to display</param>
/// <param name="font">Font to use</param>
/// <param name="size">Base characters size</param>
////////////////////////////////////////////////////////////
public Text(string str, Font font, uint size) :
base(sfText_Create())
{
DisplayedString = str;
Font = font;
Size = size;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the text from another text
/// </summary>
/// <param name="copy">Text to copy</param>
////////////////////////////////////////////////////////////
public Text(Text copy) :
base(sfText_Copy(copy.This))
{
Font = copy.Font;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
{
get { return new Vector2(sfText_GetX(This), sfText_GetY(This)); }
set { sfText_SetPosition(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotation of the object, defined in degrees
/// </summary>
////////////////////////////////////////////////////////////
public override float Rotation
{
get { return sfText_GetRotation(This); }
set { sfText_SetRotation(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
{
get { return new Vector2(sfText_GetScaleX(This), sfText_GetScaleY(This)); }
set { sfText_SetScale(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Origin of the transformation of the object
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
{
get { return new Vector2(sfText_GetOriginX(This), sfText_GetOriginY(This)); }
set { sfText_SetOrigin(This, value.X, value.Y); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Global color of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Color Color
{
get { return sfText_GetColor(This); }
set { sfText_SetColor(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Blending mode of the object
/// </summary>
////////////////////////////////////////////////////////////
public override BlendMode BlendMode
{
get { return sfText_GetBlendMode(This); }
set { sfText_SetBlendMode(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
{
Vector2 Transformed;
sfText_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// </summary>
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
{
Vector2 Transformed;
sfText_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
}
////////////////////////////////////////////////////////////
/// <summary>
/// String which is displayed
/// </summary>
////////////////////////////////////////////////////////////
public string DisplayedString
{
// TODO : use unicode functions
// (convert from UTF-16 to UTF-32, and find how to marshal System.String as sfUint32*...)
get {return sfText_GetString(This);}
set {sfText_SetString(This, value);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Font used to display the text
/// </summary>
////////////////////////////////////////////////////////////
public Font Font
{
get {return myFont;}
set {myFont = value; sfText_SetFont(This, value != null ? value.This : IntPtr.Zero);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Base size of characters
/// </summary>
////////////////////////////////////////////////////////////
public uint Size
{
get {return sfText_GetCharacterSize(This);}
set {sfText_SetCharacterSize(This, value);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Style of the text (see Styles enum)
/// </summary>
////////////////////////////////////////////////////////////
public Styles Style
{
get {return sfText_GetStyle(This);}
set {sfText_SetStyle(This, value);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the text rectangle on screen
/// </summary>
/// <returns>Text rectangle in global coordinates (doesn't include rotation)</returns>
////////////////////////////////////////////////////////////
public FloatRect GetRect()
{
return sfText_GetRect(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Return the visual position of the Index-th character of the text,
/// in coordinates relative to the text
/// (note : translation, origin, rotation and scale are not applied)
/// </summary>
/// <param name="index">Index of the character</param>
/// <returns>Position of the Index-th character (end of text if Index is out of range)</returns>
////////////////////////////////////////////////////////////
public Vector2 GetCharacterPos(uint index)
{
Vector2 Pos;
sfText_GetCharacterPos(This, index, out Pos.X, out Pos.Y);
return Pos;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Text]" +
" Position(" + Position + ")" +
" Rotation(" + Rotation + ")" +
" Scale(" + Scale + ")" +
" Origin(" + Origin + ")" +
" Color(" + Color + ")" +
" BlendMode(" + BlendMode + ")" +
" String(" + DisplayedString + ")" +
" Font(" + Font + ")" +
" Size(" + Size + ")" +
" Style(" + Style + ")" +
" Rectangle(" + GetRect() + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render window
/// </summary>
/// <param name="target">Target render window</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderWindow target, Shader shader)
{
if (shader == null)
sfRenderWindow_DrawText(target.This, This);
else
sfRenderWindow_DrawTextWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Render the object into the given render image
/// </summary>
/// <param name="target">Target render image</param>
/// <param name="shader">Shader to apply</param>
////////////////////////////////////////////////////////////
internal override void Render(RenderImage target, Shader shader)
{
if (shader == null)
sfRenderImage_DrawText(target.This, This);
else
sfRenderImage_DrawTextWithShader(target.This, This, shader.This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfText_Destroy(This);
}
private Font myFont = Font.DefaultFont;
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfText_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfText_Copy(IntPtr Text);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetPosition(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetRotation(IntPtr This, float Rotation);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetRotation(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetScale(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetScaleX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetScaleY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetOrigin(IntPtr This, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetOriginX(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfText_GetOriginY(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetColor(IntPtr This, Color Color);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Color sfText_GetColor(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetBlendMode(IntPtr This, BlendMode Mode);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern BlendMode sfText_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfText_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfText_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawText(IntPtr This, IntPtr String);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawTextWithShader(IntPtr This, IntPtr String, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawText(IntPtr This, IntPtr String);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderImage_DrawTextWithShader(IntPtr This, IntPtr String, IntPtr Shader);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetString(IntPtr This, string Text);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetFont(IntPtr This, IntPtr Font);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetCharacterSize(IntPtr This, uint Size);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_SetStyle(IntPtr This, Styles Style);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity]
static extern string sfText_GetString(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfText_GetCharacterSize(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Styles sfText_GetStyle(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern FloatRect sfText_GetRect(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfText_GetCharacterPos(IntPtr This, uint Index, out float X, out float Y);
#endregion
}
}
}

View file

@ -0,0 +1,127 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Vector2 is an utility class for manipulating 2 dimensional
/// vectors with float components
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Vector2
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the vector from its coordinates
/// </summary>
/// <param name="x">X coordinate</param>
/// <param name="y">Y coordinate</param>
////////////////////////////////////////////////////////////
public Vector2(float x, float y)
{
X = x;
Y = y;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; returns the opposite of a vector
/// </summary>
/// <param name="v">Vector to negate</param>
/// <returns>-v</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator -(Vector2 v)
{
return new Vector2(-v.X, -v.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; subtracts two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 - v2</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator -(Vector2 v1, Vector2 v2)
{
return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator + overload ; add two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 + v2</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator +(Vector2 v1, Vector2 v2)
{
return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v * x</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator *(Vector2 v, float x)
{
return new Vector2(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a scalar value by a vector
/// </summary>
/// <param name="x">Scalar value</param>
/// <param name="v">Vector</param>
/// <returns>x * v</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator *(float x, Vector2 v)
{
return new Vector2(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator / overload ; divide a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v / x</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator /(Vector2 v, float x)
{
return new Vector2(v.X / x, v.Y / x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Vector2]" +
" X(" + X + ")" +
" Y(" + Y + ")";
}
/// <summary>X (horizontal) component of the vector</summary>
public float X;
/// <summary>Y (vertical) component of the vector</summary>
public float Y;
}
}
}

View file

@ -0,0 +1,247 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// This class defines a view (position, size, etc.) ;
/// you can consider it as a 2D camera
/// </summary>
////////////////////////////////////////////////////////////
public class View : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Create a default view (1000x1000)
/// </summary>
////////////////////////////////////////////////////////////
public View() :
base(sfView_Create())
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the view from a rectangle
/// </summary>
/// <param name="viewRect">Rectangle defining the position and size of the view</param>
////////////////////////////////////////////////////////////
public View(FloatRect viewRect) :
base(sfView_CreateFromRect(viewRect))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the view from its center and size
/// </summary>
/// <param name="center">Center of the view</param>
/// <param name="size">Size of the view</param>
////////////////////////////////////////////////////////////
public View(Vector2 center, Vector2 size) :
base(sfView_Create())
{
this.Center = center;
this.Size = size;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the view from another view
/// </summary>
/// <param name="copy">View to copy</param>
////////////////////////////////////////////////////////////
public View(View copy) :
base(sfView_Copy(copy.This))
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Center of the view
/// </summary>
////////////////////////////////////////////////////////////
public Vector2 Center
{
get {return new Vector2(sfView_GetCenterX(This), sfView_GetCenterY(This));}
set {sfView_SetCenter(This, value.X, value.Y);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Half-size of the view
/// </summary>
////////////////////////////////////////////////////////////
public Vector2 Size
{
get {return new Vector2(sfView_GetWidth(This), sfView_GetHeight(This));}
set {sfView_SetSize(This, value.X, value.Y);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotation of the view, in degrees
/// </summary>
////////////////////////////////////////////////////////////
public float Rotation
{
get { return sfView_GetRotation(This); }
set { sfView_SetRotation(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Target viewport of the view, defined as a factor of the
/// size of the target to which the view is applied
/// </summary>
////////////////////////////////////////////////////////////
public FloatRect Viewport
{
get { return sfView_GetViewport(This); }
set { sfView_SetViewport(This, value); }
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rebuild the view from a rectangle
/// </summary>
/// <param name="rectangle">Rectangle defining the position and size of the view</param>
////////////////////////////////////////////////////////////
public void Reset(FloatRect rectangle)
{
sfView_Reset(This, rectangle);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Move the view
/// </summary>
/// <param name="offset">Offset to move the view</param>
////////////////////////////////////////////////////////////
public void Move(Vector2 offset)
{
sfView_Move(This, offset.X, offset.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Rotate the view
/// </summary>
/// <param name="angle">Angle of rotation, in degrees</param>
////////////////////////////////////////////////////////////
public void Rotate(float angle)
{
sfView_Rotate(This, angle);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Resize the view rectangle to simulate a zoom / unzoom effect
/// </summary>
/// <param name="factor">Zoom factor to apply, relative to the current zoom</param>
////////////////////////////////////////////////////////////
public void Zoom(float factor)
{
sfView_Zoom(This, factor);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[View]" +
" Center(" + Center + ")" +
" Size(" + Size + ")" +
" Rotation(" + Rotation + ")" +
" Viewport(" + Viewport + ")";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Internal constructor for other classes which need to manipulate raw views
/// </summary>
/// <param name="thisPtr">Direct pointer to the view object in the C library</param>
////////////////////////////////////////////////////////////
internal View(IntPtr thisPtr) :
base(thisPtr)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
sfView_Destroy(This);
}
#region Imports
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfView_Create();
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfView_CreateFromRect(FloatRect Rect);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfView_Copy(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_Destroy(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_SetCenter(IntPtr View, float X, float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_SetSize(IntPtr View, float Width, float Height);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_SetRotation(IntPtr View, float Angle);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_SetViewport(IntPtr View, FloatRect Viewport);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_Reset(IntPtr View, FloatRect Rectangle);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfView_GetCenterX(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfView_GetCenterY(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfView_GetWidth(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfView_GetHeight(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfView_GetRotation(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern FloatRect sfView_GetViewport(IntPtr View);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_Move(IntPtr View, float OffsetX, float OffsetY);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_Rotate(IntPtr View, float Angle);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfView_Zoom(IntPtr View, float Factor);
#endregion
}
}
}

View file

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{46786269-57B9-48E7-AA4F-8F4D84609FE6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SFML.Graphics</RootNamespace>
<AssemblyName>sfmlnet-graphics-2</AssemblyName>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\lib\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\..\doc\build\graphics-doc.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\lib\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\..\doc\build\graphics-doc.xml</DocumentationFile>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="Color.cs" />
<Compile Include="Context.cs" />
<Compile Include="Drawable.cs" />
<Compile Include="Font.cs" />
<Compile Include="Image.cs" />
<Compile Include="Rect.cs" />
<Compile Include="RenderImage.cs" />
<Compile Include="RenderTarget.cs" />
<Compile Include="RenderWindow.cs" />
<Compile Include="Shader.cs" />
<Compile Include="Shape.cs" />
<Compile Include="Sprite.cs" />
<Compile Include="Text.cs" />
<Compile Include="Vector2.cs" />
<Compile Include="View.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Window\sfml-window.csproj">
<Project>{D17DE83D-A592-461F-8AF2-53F9E22E1D0F}</Project>
<Name>sfml-window</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>