补充文档

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

View File

@@ -1,3 +1,21 @@
# SFMLRenderer
这个库封装了一个用于 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
{
/// <summary>
/// 原生窗口控件, 不应直接使用该类, 而是使用 <see cref="SFMLRenderPanel"/> 或者二次封装
/// </summary>
public class SFMLHwndHost : HwndHost
{
private HwndSource? _hwndSource;
private SFML.Graphics.RenderWindow? _renderWindow;
/// <summary>
/// 内部的 SFML 窗口对象
/// </summary>
public SFML.Graphics.RenderWindow? RenderWindow => _renderWindow;
/// <summary>
/// 窗口建立事件
/// </summary>
public event EventHandler? RenderWindowBuilded;
/// <summary>
/// 窗口销毁事件
/// </summary>
public event EventHandler? RenderWindowDestroying;
protected override HandleRef BuildWindowCore(HandleRef hwndParent)

View File

@@ -229,7 +229,7 @@ namespace SFMLRenderer
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);