2009-01-29 00:18:34 +08:00
|
|
|
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>
|
2009-06-01 23:58:13 +08:00
|
|
|
/// Origin of the transformation of the object
|
2009-01-29 00:18:34 +08:00
|
|
|
/// (center of translation, rotation and scale)
|
|
|
|
/// </summary>
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-06-01 23:58:13 +08:00
|
|
|
public abstract Vector2 Origin {get; set;}
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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
|
2009-06-01 23:58:13 +08:00
|
|
|
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </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
|
2009-06-01 23:58:13 +08:00
|
|
|
/// (ie it applies the object's origin, translation, rotation and scale to the point)
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </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>
|
2009-06-11 23:49:36 +08:00
|
|
|
/// <param name="target">Target render window</param>
|
2009-11-03 17:04:40 +08:00
|
|
|
/// <param name="shader">Shader to apply</param>
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-11-03 17:04:40 +08:00
|
|
|
internal abstract void Render(RenderWindow target, Shader shader);
|
2009-06-11 23:49:36 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Render the object into the given render image
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="target">Target render image</param>
|
2009-11-03 17:04:40 +08:00
|
|
|
/// <param name="shader">Shader to apply</param>
|
2009-06-11 23:49:36 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-11-03 17:04:40 +08:00
|
|
|
internal abstract void Render(RenderImage target, Shader shader);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Internal constructor, for derived classes
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="thisPtr">Pointer to the object in C library</param>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
protected Drawable(IntPtr thisPtr) :
|
|
|
|
base(thisPtr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|