2009-01-29 00:18:34 +08:00
|
|
|
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>
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-06-11 23:49:36 +08:00
|
|
|
public class RenderWindow : SFML.Window.Window, RenderTarget
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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) :
|
2009-11-03 23:13:11 +08:00
|
|
|
this(mode, title, Styles.Resize | Styles.Close, new ContextSettings(24, 8))
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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) :
|
2009-11-03 23:13:11 +08:00
|
|
|
this(mode, title, style, new ContextSettings(24, 8))
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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>
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-17 15:57:28 +08:00
|
|
|
public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) :
|
2009-11-03 23:13:11 +08:00
|
|
|
base(sfRenderWindow_Create(mode, title, style, ref settings), 0)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
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) :
|
2009-11-03 23:13:11 +08:00
|
|
|
this(handle, new ContextSettings(24, 8))
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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>
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-17 15:57:28 +08:00
|
|
|
public RenderWindow(IntPtr handle, ContextSettings settings) :
|
2009-11-03 23:13:11 +08:00
|
|
|
base(sfRenderWindow_CreateFromHandle(handle, ref settings), 0)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
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>
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-07-17 15:57:28 +08:00
|
|
|
public override ContextSettings Settings
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
|
|
|
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>
|
|
|
|
/// 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>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// Get the viewport of a view applied to this target
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </summary>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// <param name="view">Target view</param>
|
|
|
|
/// <returns>Viewport rectangle, expressed in pixels in the current target</returns>
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-09-24 15:50:08 +08:00
|
|
|
public IntRect GetViewport(View view)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
2009-09-24 15:50:08 +08:00
|
|
|
return sfRenderWindow_GetViewport(This, view.This);
|
2009-01-29 00:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// Convert a point in target coordinates into view coordinates
|
|
|
|
/// This version uses the current view of the window
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </summary>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// <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>
|
2009-01-29 00:18:34 +08:00
|
|
|
/// <returns>Converted point</returns>
|
2009-09-24 15:50:08 +08:00
|
|
|
///
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-09-24 15:50:08 +08:00
|
|
|
public Vector2 ConvertCoords(uint x, uint y)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
2009-09-24 15:50:08 +08:00
|
|
|
return ConvertCoords(x, y, CurrentView);
|
2009-01-29 00:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// Convert a point in target coordinates into view coordinates
|
|
|
|
/// This version uses the given view
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </summary>
|
2009-09-24 15:50:08 +08:00
|
|
|
/// <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>
|
|
|
|
///
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-09-24 15:50:08 +08:00
|
|
|
public Vector2 ConvertCoords(uint x, uint y, View view)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
2009-09-24 15:50:08 +08:00
|
|
|
Vector2 point;
|
|
|
|
sfRenderWindow_ConvertCoords(This, x, y, out point.X, out point.Y, view.This);
|
|
|
|
|
|
|
|
return point;
|
2009-01-29 00:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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)
|
|
|
|
{
|
2009-11-03 17:04:40 +08:00
|
|
|
objectToDraw.Render(this, null);
|
2009-01-29 00:18:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
2009-11-03 17:04:40 +08:00
|
|
|
/// Draw something into the window with a shader
|
2009-01-29 00:18:34 +08:00
|
|
|
/// </summary>
|
2009-11-03 17:04:40 +08:00
|
|
|
/// <param name="objectToDraw">Object to draw</param>
|
|
|
|
/// <param name="shader">Shader to apply</param>
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
2009-11-03 17:04:40 +08:00
|
|
|
public void Draw(Drawable objectToDraw, Shader shader)
|
2009-01-29 00:18:34 +08:00
|
|
|
{
|
2009-11-03 17:04:40 +08:00
|
|
|
objectToDraw.Render(this, shader);
|
2009-01-29 00:18:34 +08:00
|
|
|
}
|
|
|
|
|
2009-10-12 18:24:49 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Make sure that what has been drawn so far is rendered.
|
|
|
|
///
|
|
|
|
/// Use this function if you use OpenGL rendering commands,
|
|
|
|
/// and you want to make sure that things will appear on top
|
|
|
|
/// of all the SFML objects that have been drawn so far.
|
|
|
|
/// This is needed because SFML doesn't use immediate rendering,
|
|
|
|
/// it first accumulates drawables into a queue and
|
|
|
|
/// trigger the actual rendering afterwards.
|
|
|
|
///
|
|
|
|
/// You don't need to call this function if you're not
|
|
|
|
/// dealing with OpenGL directly.
|
|
|
|
/// </summary>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public void Flush()
|
|
|
|
{
|
|
|
|
sfRenderWindow_Flush(This);
|
|
|
|
}
|
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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);
|
|
|
|
}
|
|
|
|
|
2009-10-27 19:50:11 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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);
|
|
|
|
}
|
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <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"), SuppressUnmanagedCodeSecurity]
|
2009-11-03 23:13:11 +08:00
|
|
|
static extern IntPtr sfRenderWindow_Create(VideoMode Mode, string Title, Styles Style, ref ContextSettings Params);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
2009-11-03 23:13:11 +08:00
|
|
|
static extern IntPtr sfRenderWindow_CreateFromHandle(IntPtr Handle, ref ContextSettings Params);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_Destroy(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern IntPtr sfRenderWindow_GetInput(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfRenderWindow_IsOpened(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_Close(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfRenderWindow_GetEvent(IntPtr This, out Event Evt);
|
2009-10-27 19:50:11 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfRenderWindow_WaitEvent(IntPtr This, out Event Evt);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_Clear(IntPtr This, Color ClearColor);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_Display(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern uint sfRenderWindow_GetWidth(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern uint sfRenderWindow_GetHeight(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
2009-07-17 15:57:28 +08:00
|
|
|
static extern ContextSettings sfRenderWindow_GetSettings(IntPtr This);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_UseVerticalSync(IntPtr This, bool Enable);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_ShowMouseCursor(IntPtr This, bool Show);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetCursorPosition(IntPtr This, uint X, uint Y);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetPosition(IntPtr This, int X, int Y);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetSize(IntPtr This, uint Width, uint Height);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_Show(IntPtr This, bool Show);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_EnableKeyRepeat(IntPtr This, bool Enable);
|
|
|
|
|
2009-03-23 02:36:03 +08:00
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
2009-01-29 00:18:34 +08:00
|
|
|
unsafe static extern void sfRenderWindow_SetIcon(IntPtr This, uint Width, uint Height, byte* Pixels);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfRenderWindow_SetActive(IntPtr This, bool Active);
|
|
|
|
|
2009-10-12 18:24:49 +08:00
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfRenderWindow_Flush(IntPtr This);
|
|
|
|
|
2009-01-29 00:18:34 +08:00
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetFramerateLimit(IntPtr This, uint Limit);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern float sfRenderWindow_GetFrameTime(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetJoystickThreshold(IntPtr This, float Threshold);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern void sfRenderWindow_SetView(IntPtr This, IntPtr View);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern IntPtr sfRenderWindow_GetView(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern IntPtr sfRenderWindow_GetDefaultView(IntPtr This);
|
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
2009-09-24 15:50:08 +08:00
|
|
|
static extern IntRect sfRenderWindow_GetViewport(IntPtr This, IntPtr TargetView);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
2009-09-24 15:50:08 +08:00
|
|
|
static extern void sfRenderWindow_ConvertCoords(IntPtr This, uint WindowX, uint WindowY, out float ViewX, out float ViewY, IntPtr TargetView);
|
2009-01-29 00:18:34 +08:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|