补充文档

This commit is contained in:
ww-rm
2025-05-27 17:23:32 +08:00
parent 44b5bf8613
commit 10008166ac
4 changed files with 53 additions and 18 deletions

View File

@@ -9,15 +9,19 @@ using System.Threading.Tasks;
namespace SFMLRenderer namespace SFMLRenderer
{ {
/// <summary>
/// 定义了 SFML 渲染器的基本功能和事件, 基本上是对 <see cref="RenderWindow"/> 的抽象
/// <para>实现示例可以见 <see cref="SFMLRenderPanel"/></para>
/// </summary>
public interface ISFMLRenderer public interface ISFMLRenderer
{ {
/// <summary> /// <summary>
/// 发生在资源首次创建完成后 /// 发生在资源首次创建完成后, 该事件发生之后渲染器才是可用的, 操作才会生效
/// </summary> /// </summary>
public event EventHandler? RendererCreated; public event EventHandler? RendererCreated;
/// <summary> /// <summary>
/// 发生在资源即将不可用之前 /// 发生在资源即将不可用之前, 该事件发生之后对渲染器的操作将被忽略
/// </summary> /// </summary>
public event EventHandler? RendererDisposing; public event EventHandler? RendererDisposing;
@@ -62,72 +66,72 @@ namespace SFMLRenderer
public uint MaxFps { get; set; } public uint MaxFps { get; set; }
/// <summary> /// <summary>
/// 垂直同步 /// 垂直同步, <see cref="RenderWindow.SetVerticalSyncEnabled(bool)"/>
/// </summary> /// </summary>
public bool VerticalSync { get; set; } public bool VerticalSync { get; set; }
/// <summary> /// <summary>
/// <see cref="RenderWindow.SetActive(bool)"/> /// <inheritdoc cref="RenderWindow.SetActive(bool)"/>
/// </summary> /// </summary>
public void SetActive(bool active); public bool SetActive(bool active);
/// <summary> /// <summary>
/// <see cref="RenderWindow.GetView"/> /// <inheritdoc cref="RenderWindow.GetView"/>
/// </summary> /// </summary>
public View GetView(); public View GetView();
/// <summary> /// <summary>
/// <see cref="RenderWindow.SetView(View)"/> /// <inheritdoc cref="RenderWindow.SetView(View)"/>
/// </summary> /// </summary>
public void SetView(View view); public void SetView(View view);
/// <summary> /// <summary>
/// <see cref="RenderWindow.MapPixelToCoords(Vector2i)"/> /// <inheritdoc cref="RenderWindow.MapPixelToCoords(Vector2i)"/>
/// </summary> /// </summary>
public Vector2f MapPixelToCoords(Vector2i point); public Vector2f MapPixelToCoords(Vector2i point);
/// <summary> /// <summary>
/// <see cref="RenderWindow.MapCoordsToPixel(Vector2f)"/> /// <inheritdoc cref="RenderWindow.MapCoordsToPixel(Vector2f)"/>
/// </summary> /// </summary>
public Vector2i MapCoordsToPixel(Vector2f point); public Vector2i MapCoordsToPixel(Vector2f point);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Clear()"/> /// <inheritdoc cref="RenderWindow.Clear()"/>
/// </summary> /// </summary>
public void Clear(); public void Clear();
/// <summary> /// <summary>
/// <see cref="RenderWindow.Clear(Color)"/> /// <inheritdoc cref="RenderWindow.Clear(Color)"/>
/// </summary> /// </summary>
public void Clear(Color color); public void Clear(Color color);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Draw(Drawable)"/> /// <inheritdoc cref="RenderWindow.Draw(Drawable)"/>
/// </summary> /// </summary>
public void Draw(Drawable drawable); public void Draw(Drawable drawable);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Draw(Drawable, RenderStates)"/> /// <inheritdoc cref="RenderWindow.Draw(Drawable, RenderStates)"/>
/// </summary> /// </summary>
public void Draw(Drawable drawable, RenderStates states); public void Draw(Drawable drawable, RenderStates states);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Draw(Vertex[], PrimitiveType)"/> /// <inheritdoc cref="RenderWindow.Draw(Vertex[], PrimitiveType)"/>
/// </summary> /// </summary>
public void Draw(Vertex[] vertices, PrimitiveType type); public void Draw(Vertex[] vertices, PrimitiveType type);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Draw(Vertex[], PrimitiveType, RenderStates)"/> /// <inheritdoc cref="RenderWindow.Draw(Vertex[], PrimitiveType, RenderStates)"/>
/// </summary> /// </summary>
public void Draw(Vertex[] vertices, PrimitiveType type, RenderStates states); public void Draw(Vertex[] vertices, PrimitiveType type, RenderStates states);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Draw(Vertex[], uint, uint, PrimitiveType)"/> /// <inheritdoc cref="RenderWindow.Draw(Vertex[], uint, uint, PrimitiveType)"/>
/// </summary> /// </summary>
public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type); public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type);
/// <summary> /// <summary>
/// <see cref="RenderWindow.Display"/> /// <inheritdoc cref="RenderWindow.Display"/>
/// </summary> /// </summary>
public void Display(); public void Display();
} }

View File

@@ -1,3 +1,21 @@
# SFMLRenderer # SFMLRenderer
这个库封装了一个用于 WPF 的 SFML 渲染控件. 这个库封装了一个用于 WPF 的 SFML 渲染控件.
```mermaid
classDiagram
namespace SFMLRenderer {
class ISFMLRenderer {
<<Interface>>
}
class SFMLHwndHost
class SFMLRenderPanel
}
ISFMLRenderer <|.. SFMLRenderPanel
SFMLHwndHost <.. SFMLRenderPanel
```

View File

@@ -12,14 +12,27 @@ using System.Windows.Media;
namespace SFMLRenderer namespace SFMLRenderer
{ {
/// <summary>
/// 原生窗口控件, 不应直接使用该类, 而是使用 <see cref="SFMLRenderPanel"/> 或者二次封装
/// </summary>
public class SFMLHwndHost : HwndHost public class SFMLHwndHost : HwndHost
{ {
private HwndSource? _hwndSource; private HwndSource? _hwndSource;
private SFML.Graphics.RenderWindow? _renderWindow; private SFML.Graphics.RenderWindow? _renderWindow;
/// <summary>
/// 内部的 SFML 窗口对象
/// </summary>
public SFML.Graphics.RenderWindow? RenderWindow => _renderWindow; public SFML.Graphics.RenderWindow? RenderWindow => _renderWindow;
/// <summary>
/// 窗口建立事件
/// </summary>
public event EventHandler? RenderWindowBuilded; public event EventHandler? RenderWindowBuilded;
/// <summary>
/// 窗口销毁事件
/// </summary>
public event EventHandler? RenderWindowDestroying; public event EventHandler? RenderWindowDestroying;
protected override HandleRef BuildWindowCore(HandleRef hwndParent) protected override HandleRef BuildWindowCore(HandleRef hwndParent)

View File

@@ -229,7 +229,7 @@ namespace SFMLRenderer
public Vector2f MapPixelToCoords(Vector2i point) => RenderWindow?.MapPixelToCoords(point) ?? default; public Vector2f MapPixelToCoords(Vector2i point) => RenderWindow?.MapPixelToCoords(point) ?? default;
public void SetActive(bool active) => RenderWindow?.SetActive(active); public bool SetActive(bool active) => RenderWindow?.SetActive(active) ?? false;
public void SetView(View view) => RenderWindow?.SetView(view); public void SetView(View view) => RenderWindow?.SetView(view);