add lots more doc comments

pull/51/head
cosmonaut 2023-09-19 13:19:41 -07:00
parent e0f05881b0
commit b026b9e81f
32 changed files with 246 additions and 30 deletions

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary> /// <summary>
/// Contains raw audio data in the format specified by Format. /// Contains raw audio data in a specified Format. <br/>
/// Submit this to a SourceVoice to play audio. /// Submit this to a SourceVoice to play audio.
/// </summary> /// </summary>
public class AudioBuffer : AudioResource public class AudioBuffer : AudioResource
@ -15,6 +15,10 @@ namespace MoonWorks.Audio
public Format Format { get; } public Format Format { get; }
/// <summary>
/// Create a new AudioBuffer.
/// </summary>
/// <param name="ownsBufferData">If true, the buffer data will be destroyed when this AudioBuffer is destroyed.</param>
public AudioBuffer( public AudioBuffer(
AudioDevice device, AudioDevice device,
Format format, Format format,

View File

@ -58,6 +58,9 @@ namespace MoonWorks.Audio
filledLengthInBytes = sampleCount * sizeof(float); filledLengthInBytes = sampleCount * sizeof(float);
} }
/// <summary>
/// Prepares the Ogg data for streaming.
/// </summary>
public override unsafe void Load() public override unsafe void Load()
{ {
if (!Loaded) if (!Loaded)
@ -84,6 +87,9 @@ namespace MoonWorks.Audio
FAudio.stb_vorbis_seek(VorbisHandle, sampleFrame); FAudio.stb_vorbis_seek(VorbisHandle, sampleFrame);
} }
/// <summary>
/// Unloads the Ogg data, freeing resources.
/// </summary>
public override unsafe void Unload() public override unsafe void Unload()
{ {
if (Loaded) if (Loaded)
@ -96,6 +102,9 @@ namespace MoonWorks.Audio
} }
} }
/// <summary>
/// Loads an entire ogg file into an AudioBuffer. Useful for static audio.
/// </summary>
public unsafe static AudioBuffer CreateBuffer(AudioDevice device, string filePath) public unsafe static AudioBuffer CreateBuffer(AudioDevice device, string filePath)
{ {
var filePointer = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero); var filePointer = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero);

View File

@ -68,6 +68,9 @@ namespace MoonWorks.Audio
filledLengthInBytes = (int) (sampleCount * sizeof(short)); filledLengthInBytes = (int) (sampleCount * sizeof(short));
} }
/// <summary>
/// Prepares qoa data for streaming.
/// </summary>
public override unsafe void Load() public override unsafe void Load()
{ {
if (!Loaded) if (!Loaded)
@ -93,6 +96,9 @@ namespace MoonWorks.Audio
FAudio.qoa_seek_frame(QoaHandle, (int) sampleFrame); FAudio.qoa_seek_frame(QoaHandle, (int) sampleFrame);
} }
/// <summary>
/// Unloads the qoa data, freeing resources.
/// </summary>
public override unsafe void Unload() public override unsafe void Unload()
{ {
if (Loaded) if (Loaded)
@ -105,6 +111,9 @@ namespace MoonWorks.Audio
} }
} }
/// <summary>
/// Loads the entire qoa file into an AudioBuffer. Useful for static audio.
/// </summary>
public unsafe static AudioBuffer CreateBuffer(AudioDevice device, string filePath) public unsafe static AudioBuffer CreateBuffer(AudioDevice device, string filePath)
{ {
using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

View File

@ -4,6 +4,9 @@ using System.Threading;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary>
/// AudioDevice manages all audio-related concerns.
/// </summary>
public class AudioDevice : IDisposable public class AudioDevice : IDisposable
{ {
public IntPtr Handle { get; } public IntPtr Handle { get; }

View File

@ -4,6 +4,9 @@ using MoonWorks.Math.Float;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary>
/// An emitter for 3D spatial audio.
/// </summary>
public class AudioEmitter : AudioResource public class AudioEmitter : AudioResource
{ {
internal FAudio.F3DAUDIO_EMITTER emitterData; internal FAudio.F3DAUDIO_EMITTER emitterData;

View File

@ -3,6 +3,9 @@ using MoonWorks.Math.Float;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary>
/// A listener for 3D spatial audio. Usually attached to a camera.
/// </summary>
public class AudioListener : AudioResource public class AudioListener : AudioResource
{ {
internal FAudio.F3DAUDIO_LISTENER listenerData; internal FAudio.F3DAUDIO_LISTENER listenerData;

View File

@ -8,6 +8,9 @@ namespace MoonWorks.Audio
IEEE_FLOAT = 3 IEEE_FLOAT = 3
} }
/// <summary>
/// Describes the format of audio data. Usually specified in an audio file's header information.
/// </summary>
public record struct Format public record struct Format
{ {
public FormatTag Tag; public FormatTag Tag;

View File

@ -1,8 +1,8 @@
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary> /// <summary>
/// TransientVoice is intended for playing one-off sound effects that don't have a long term reference. /// TransientVoice is intended for playing one-off sound effects that don't have a long term reference. <br/>
/// It will be automatically returned to the source voice pool once it is done playing back. /// It will be automatically returned to the AudioDevice SourceVoice pool once it is done playing back.
/// </summary> /// </summary>
public class TransientVoice : SourceVoice, IPoolable<TransientVoice> public class TransientVoice : SourceVoice, IPoolable<TransientVoice>
{ {

View File

@ -4,6 +4,9 @@ using EasingFunction = System.Func<float, float>;
namespace MoonWorks.Audio namespace MoonWorks.Audio
{ {
/// <summary>
/// Handles audio playback from audio buffer data. Can be configured with a variety of parameters.
/// </summary>
public abstract unsafe class Voice : AudioResource public abstract unsafe class Voice : AudioResource
{ {
protected IntPtr handle; protected IntPtr handle;

View File

@ -1,14 +1,27 @@
namespace MoonWorks namespace MoonWorks
{ {
/// <summary>
/// The Game's frame limiter mode. Specifies a maximum rendering frames per second value.
/// </summary>
public enum FrameLimiterMode public enum FrameLimiterMode
{ {
/// <summary>
/// The game will render at the maximum possible framerate that the computing resources allow. <br/>
/// Note that this may lead to overheating, resource starvation, etc.
/// </summary>
Uncapped, Uncapped,
/// <summary>
/// The game will render no more than the specified frames per second.
/// </summary>
Capped Capped
} }
public struct FrameLimiterSettings public struct FrameLimiterSettings
{ {
public FrameLimiterMode Mode; public FrameLimiterMode Mode;
/// <summary>
/// If Mode is set to Uncapped, this is the maximum frames per second that will be rendered.
/// </summary>
public int Cap; public int Cap;
public FrameLimiterSettings( public FrameLimiterSettings(

View File

@ -1,5 +1,8 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// A buffer-offset pair to be used when binding vertex buffers.
/// </summary>
public struct BufferBinding public struct BufferBinding
{ {
public Buffer Buffer; public Buffer Buffer;

View File

@ -1,7 +1,8 @@
using System; namespace MoonWorks.Graphics
namespace MoonWorks.Graphics
{ {
/// <summary>
/// A texture-sampler pair to be used when binding samplers.
/// </summary>
public struct TextureSamplerBinding public struct TextureSamplerBinding
{ {
public Texture Texture; public Texture Texture;

View File

@ -5,6 +5,9 @@ using RefreshCS;
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// GraphicsDevice manages all graphics-related concerns.
/// </summary>
public class GraphicsDevice : IDisposable public class GraphicsDevice : IDisposable
{ {
public IntPtr Handle { get; } public IntPtr Handle { get; }
@ -21,7 +24,7 @@ namespace MoonWorks.Graphics
private readonly HashSet<WeakReference<GraphicsResource>> resources = new HashSet<WeakReference<GraphicsResource>>(); private readonly HashSet<WeakReference<GraphicsResource>> resources = new HashSet<WeakReference<GraphicsResource>>();
private FencePool FencePool; private FencePool FencePool;
public GraphicsDevice( internal GraphicsDevice(
Backend preferredBackend, Backend preferredBackend,
bool debugMode bool debugMode
) { ) {
@ -77,6 +80,11 @@ namespace MoonWorks.Graphics
FencePool = new FencePool(this); FencePool = new FencePool(this);
} }
/// <summary>
/// Prepares a window so that frames can be presented to it.
/// </summary>
/// <param name="presentMode">The desired presentation mode for the window. Roughly equivalent to V-Sync.</param>
/// <returns>True if successfully claimed.</returns>
public bool ClaimWindow(Window window, PresentMode presentMode) public bool ClaimWindow(Window window, PresentMode presentMode)
{ {
var success = Conversions.ByteToBool( var success = Conversions.ByteToBool(
@ -100,6 +108,9 @@ namespace MoonWorks.Graphics
return success; return success;
} }
/// <summary>
/// Unclaims a window, making it unavailable for presenting and freeing associated resources.
/// </summary>
public void UnclaimWindow(Window window) public void UnclaimWindow(Window window)
{ {
Refresh.Refresh_UnclaimWindow( Refresh.Refresh_UnclaimWindow(
@ -109,8 +120,18 @@ namespace MoonWorks.Graphics
window.Claimed = false; window.Claimed = false;
} }
/// <summary>
/// Changes the present mode of a claimed window. Does nothing if the window is not claimed.
/// </summary>
/// <param name="window"></param>
/// <param name="presentMode"></param>
public void SetPresentMode(Window window, PresentMode presentMode) public void SetPresentMode(Window window, PresentMode presentMode)
{ {
if (!window.Claimed)
{
return;
}
Refresh.Refresh_SetSwapchainPresentMode( Refresh.Refresh_SetSwapchainPresentMode(
Handle, Handle,
window.Handle, window.Handle,
@ -118,6 +139,11 @@ namespace MoonWorks.Graphics
); );
} }
/// <summary>
/// Acquires a command buffer.
/// This is the start of your rendering process.
/// </summary>
/// <returns></returns>
public CommandBuffer AcquireCommandBuffer() public CommandBuffer AcquireCommandBuffer()
{ {
return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle)); return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle));

View File

@ -1,7 +1,13 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// Can be defined on your struct type to enable simplified vertex input state definition.
/// </summary>
public interface IVertexType public interface IVertexType
{ {
/// <summary>
/// An ordered list of the types in your vertex struct.
/// </summary>
static abstract VertexElementFormat[] Formats { get; } static abstract VertexElementFormat[] Formats { get; }
} }
} }

View File

@ -2,11 +2,31 @@
namespace MoonWorks namespace MoonWorks
{ {
/// <summary>
/// Presentation mode for a window.
/// </summary>
public enum PresentMode public enum PresentMode
{ {
/// <summary>
/// Does not wait for v-blank to update the window. Can cause visible tearing.
/// </summary>
Immediate, Immediate,
/// <summary>
/// Waits for v-blank and uses a queue to hold present requests.
/// Allows for low latency while preventing tearing.
/// May not be supported on non-Vulkan non-Linux systems or older hardware.
/// </summary>
Mailbox, Mailbox,
/// <summary>
/// Waits for v-blank and adds present requests to a queue.
/// Will probably cause latency.
/// Required to be supported by all compliant hardware.
/// </summary>
FIFO, FIFO,
/// <summary>
/// Usually waits for v-blank, but if v-blank has passed since last update will update immediately.
/// May cause visible tearing.
/// </summary>
FIFORelaxed FIFORelaxed
} }
} }

View File

@ -59,7 +59,7 @@ namespace MoonWorks.Graphics
/// <summary> /// <summary>
/// Reads data out of a buffer and into a span. /// Reads data out of a buffer and into a span.
/// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait is called first. /// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait or GraphicsDevice.WaitForFences is called first.
/// </summary> /// </summary>
/// <param name="data">The span that data will be copied to.</param> /// <param name="data">The span that data will be copied to.</param>
/// <param name="dataLengthInBytes">The length of the data to read.</param> /// <param name="dataLengthInBytes">The length of the data to read.</param>
@ -73,6 +73,11 @@ namespace MoonWorks.Graphics
{ {
Logger.LogWarn("Requested too many bytes from buffer!"); Logger.LogWarn("Requested too many bytes from buffer!");
} }
if (dataLengthInBytes > data.Length)
{
Logger.LogWarn("Data length is larger than the provided Span!");
}
#endif #endif
fixed (T* ptr = data) fixed (T* ptr = data)
@ -88,7 +93,7 @@ namespace MoonWorks.Graphics
/// <summary> /// <summary>
/// Reads data out of a buffer and into an array. /// Reads data out of a buffer and into an array.
/// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait is called first. /// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait or GraphicsDevice.WaitForFences is called first.
/// </summary> /// </summary>
/// <param name="data">The span that data will be copied to.</param> /// <param name="data">The span that data will be copied to.</param>
/// <param name="dataLengthInBytes">The length of the data to read.</param> /// <param name="dataLengthInBytes">The length of the data to read.</param>
@ -102,7 +107,7 @@ namespace MoonWorks.Graphics
/// <summary> /// <summary>
/// Reads data out of a buffer and into a span. /// Reads data out of a buffer and into a span.
/// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait is called first. /// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait or GraphicsDevice.WaitForFences is called first.
/// Fills the span with as much data from the buffer as it can. /// Fills the span with as much data from the buffer as it can.
/// </summary> /// </summary>
/// <param name="data">The span that data will be copied to.</param> /// <param name="data">The span that data will be copied to.</param>
@ -116,7 +121,7 @@ namespace MoonWorks.Graphics
/// <summary> /// <summary>
/// Reads data out of a buffer and into an array. /// Reads data out of a buffer and into an array.
/// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait is called first. /// This operation is only guaranteed to read up-to-date data if GraphicsDevice.Wait or GraphicsDevice.WaitForFences is called first.
/// Fills the array with as much data from the buffer as it can. /// Fills the array with as much data from the buffer as it can.
/// </summary> /// </summary>
/// <param name="data">The span that data will be copied to.</param> /// <param name="data">The span that data will be copied to.</param>

View File

@ -1,9 +1,11 @@
using RefreshCS; using RefreshCS;
using System; using System;
using System.Runtime.InteropServices;
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// Compute pipelines perform arbitrary parallel processing on input data.
/// </summary>
public class ComputePipeline : GraphicsResource public class ComputePipeline : GraphicsResource
{ {
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline; protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline;

View File

@ -4,11 +4,10 @@ using RefreshCS;
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary> /// <summary>
/// Fences allow you to track the status of a submitted command buffer. /// Fences allow you to track the status of a submitted command buffer. <br/>
/// You should only acquire a Fence if you will need to track the command buffer. /// You should only acquire a Fence if you will need to track the command buffer. <br/>
/// You should make sure to call GraphicsDevice.ReleaseFence when done with a Fence to avoid memory growth. /// You should make sure to call GraphicsDevice.ReleaseFence when done with a Fence to avoid memory growth. <br/>
/// /// The Fence object itself is basically just a wrapper for the Refresh_Fence. <br/>
/// The Fence object itself is basically just a wrapper for the Refresh_Fence.
/// The internal handle is replaced so that we can pool Fence objects to manage garbage. /// The internal handle is replaced so that we can pool Fence objects to manage garbage.
/// </summary> /// </summary>
public class Fence : GraphicsResource public class Fence : GraphicsResource

View File

@ -5,7 +5,7 @@ using RefreshCS;
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary> /// <summary>
/// Graphics pipelines encapsulate all of the render state in a single object. /// Graphics pipelines encapsulate all of the render state in a single object. <br/>
/// These pipelines are bound before draw calls are issued. /// These pipelines are bound before draw calls are issued.
/// </summary> /// </summary>
public class GraphicsPipeline : GraphicsResource public class GraphicsPipeline : GraphicsResource

View File

@ -591,8 +591,9 @@ namespace MoonWorks.Graphics
} }
/// <summary> /// <summary>
/// Asynchronously saves RGBA or BGRA pixel data to a file in PNG format. /// Asynchronously saves RGBA or BGRA pixel data to a file in PNG format. <br/>
/// Warning: this is expensive and will block to wait for data download from GPU! /// Warning: this is expensive and will block to wait for data download from GPU! <br/>
/// You can avoid blocking by calling this method from a thread.
/// </summary> /// </summary>
public unsafe void SavePNG(string path) public unsafe void SavePNG(string path)
{ {

View File

@ -2,6 +2,9 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// Defines how color blending will be performed in a GraphicsPipeline.
/// </summary>
public struct ColorAttachmentBlendState public struct ColorAttachmentBlendState
{ {
/// <summary> /// <summary>

View File

@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary> /// <summary>
/// Information that the pipeline needs about a shader. /// Information that the compute pipeline needs about a compute shader.
/// </summary> /// </summary>
public struct ComputeShaderInfo public struct ComputeShaderInfo
{ {

View File

@ -1,5 +1,8 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// All of the information that is used to create a GraphicsPipeline.
/// </summary>
public struct GraphicsPipelineCreateInfo public struct GraphicsPipelineCreateInfo
{ {
public DepthStencilState DepthStencilState; public DepthStencilState DepthStencilState;

View File

@ -3,7 +3,7 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary> /// <summary>
/// Information that the pipeline needs about a shader. /// Information that the pipeline needs about a graphics shader.
/// </summary> /// </summary>
public struct GraphicsShaderInfo public struct GraphicsShaderInfo
{ {

View File

@ -2,21 +2,60 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// All of the information that is used to create a sampler.
/// </summary>
public struct SamplerCreateInfo public struct SamplerCreateInfo
{ {
/// <summary>
/// Minification filter mode. Used when the image is downscaled.
/// </summary>
public Filter MinFilter; public Filter MinFilter;
/// <summary>
/// Magnification filter mode. Used when the image is upscaled.
/// </summary>
public Filter MagFilter; public Filter MagFilter;
/// <summary>
/// Filter mode applied to mipmap lookups.
/// </summary>
public SamplerMipmapMode MipmapMode; public SamplerMipmapMode MipmapMode;
/// <summary>
/// Horizontal addressing mode.
/// </summary>
public SamplerAddressMode AddressModeU; public SamplerAddressMode AddressModeU;
/// <summary>
/// Vertical addressing mode.
/// </summary>
public SamplerAddressMode AddressModeV; public SamplerAddressMode AddressModeV;
/// <summary>
/// Depth addressing mode.
/// </summary>
public SamplerAddressMode AddressModeW; public SamplerAddressMode AddressModeW;
/// <summary>
/// Bias value added to mipmap level of detail calculation.
/// </summary>
public float MipLodBias; public float MipLodBias;
/// <summary>
/// Enables anisotropic filtering.
/// </summary>
public bool AnisotropyEnable; public bool AnisotropyEnable;
/// <summary>
/// Maximum anisotropy value.
/// </summary>
public float MaxAnisotropy; public float MaxAnisotropy;
public bool CompareEnable; public bool CompareEnable;
public CompareOp CompareOp; public CompareOp CompareOp;
/// <summary>
/// Clamps the LOD value to a specified minimum.
/// </summary>
public float MinLod; public float MinLod;
/// <summary>
/// Clamps the LOD value to a specified maximum.
/// </summary>
public float MaxLod; public float MaxLod;
/// <summary>
/// If an address mode is set to ClampToBorder, will replace color with this color when samples are outside the [0, 1) range.
/// </summary>
public BorderColor BorderColor; public BorderColor BorderColor;
public static readonly SamplerCreateInfo AnisotropicClamp = new SamplerCreateInfo public static readonly SamplerCreateInfo AnisotropicClamp = new SamplerCreateInfo

View File

@ -2,6 +2,9 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary>
/// All of the information that is used to create a texture.
/// </summary>
public struct TextureCreateInfo public struct TextureCreateInfo
{ {
public uint Width; public uint Width;

View File

@ -1,7 +1,7 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
/// <summary> /// <summary>
/// Specifies how to interpet vertex data in a buffer to be passed to the vertex shader. /// Specifies how the vertex shader will interpet vertex data in a buffer.
/// </summary> /// </summary>
public struct VertexInputState public struct VertexInputState
{ {

View File

@ -1,6 +1,8 @@
namespace MoonWorks.Graphics namespace MoonWorks.Graphics
{ {
// This is a convenience structure for pairing a vertex binding with its associated attributes. /// <summary>
/// A convenience structure for pairing a vertex binding with its associated attributes.
/// </summary>
public struct VertexBindingAndAttributes public struct VertexBindingAndAttributes
{ {
public VertexBinding VertexBinding { get; } public VertexBinding VertexBinding { get; }

View File

@ -25,6 +25,9 @@ namespace MoonWorks.Video
private int height; private int height;
private Dav1dfile.PixelLayout pixelLayout; private Dav1dfile.PixelLayout pixelLayout;
/// <summary>
/// Opens an AV1 file so it can be loaded by VideoPlayer. You must also provide a playback framerate.
/// </summary>
public VideoAV1(string filename, double framesPerSecond) public VideoAV1(string filename, double framesPerSecond)
{ {
if (!File.Exists(filename)) if (!File.Exists(filename))

View File

@ -1,12 +1,13 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Runtime.InteropServices;
using MoonWorks.Audio;
using MoonWorks.Graphics; using MoonWorks.Graphics;
namespace MoonWorks.Video namespace MoonWorks.Video
{ {
/// <summary>
/// A structure for continuous decoding of AV1 videos and rendering them into a texture.
/// </summary>
public unsafe class VideoPlayer : IDisposable public unsafe class VideoPlayer : IDisposable
{ {
public Texture RenderTexture { get; private set; } = null; public Texture RenderTexture { get; private set; } = null;
@ -44,6 +45,10 @@ namespace MoonWorks.Video
timer = new Stopwatch(); timer = new Stopwatch();
} }
/// <summary>
/// Prepares a VideoAV1 for decoding and rendering.
/// </summary>
/// <param name="video"></param>
public void Load(VideoAV1 video) public void Load(VideoAV1 video)
{ {
if (Video != video) if (Video != video)
@ -100,6 +105,9 @@ namespace MoonWorks.Video
} }
} }
/// <summary>
/// Starts playing back and decoding the loaded video.
/// </summary>
public void Play() public void Play()
{ {
if (Video == null) { return; } if (Video == null) { return; }
@ -114,6 +122,9 @@ namespace MoonWorks.Video
State = VideoState.Playing; State = VideoState.Playing;
} }
/// <summary>
/// Pauses playback and decoding of the currently playing video.
/// </summary>
public void Pause() public void Pause()
{ {
if (Video == null) { return; } if (Video == null) { return; }
@ -128,6 +139,9 @@ namespace MoonWorks.Video
State = VideoState.Paused; State = VideoState.Paused;
} }
/// <summary>
/// Stops and resets decoding of the currently playing video.
/// </summary>
public void Stop() public void Stop()
{ {
if (Video == null) { return; } if (Video == null) { return; }
@ -148,12 +162,18 @@ namespace MoonWorks.Video
State = VideoState.Stopped; State = VideoState.Stopped;
} }
/// <summary>
/// Unloads the currently playing video.
/// </summary>
public void Unload() public void Unload()
{ {
Stop(); Stop();
Video = null; Video = null;
} }
/// <summary>
/// Renders the video data into RenderTexture.
/// </summary>
public void Render() public void Render()
{ {
if (Video == null || State == VideoState.Stopped) if (Video == null || State == VideoState.Stopped)

View File

@ -6,9 +6,9 @@ using SDL2;
namespace MoonWorks namespace MoonWorks
{ {
/// <summary> /// <summary>
/// Represents a window in the client operating system. /// Represents a window in the client operating system. <br/>
/// Every Game has a MainWindow automatically. /// Every Game has a MainWindow automatically. <br/>
/// You can create dditional Windows if you desire. They must be Claimed by the GraphicsDevice to be rendered to. /// You can create additional Windows if you desire. They must be Claimed by the GraphicsDevice to be rendered to.
/// </summary> /// </summary>
public class Window : IDisposable public class Window : IDisposable
{ {
@ -69,6 +69,9 @@ namespace MoonWorks
idLookup.Add(SDL.SDL_GetWindowID(Handle), this); idLookup.Add(SDL.SDL_GetWindowID(Handle), this);
} }
/// <summary>
/// Changes the ScreenMode of this window.
/// </summary>
public void SetScreenMode(ScreenMode screenMode) public void SetScreenMode(ScreenMode screenMode)
{ {
SDL.SDL_WindowFlags windowFlag = 0; SDL.SDL_WindowFlags windowFlag = 0;
@ -93,7 +96,7 @@ namespace MoonWorks
} }
/// <summary> /// <summary>
/// Resizes the window. /// Resizes the window. <br/>
/// Note that you are responsible for recreating any graphics resources that need to change as a result of the size change. /// Note that you are responsible for recreating any graphics resources that need to change as a result of the size change.
/// </summary> /// </summary>
/// <param name="width"></param> /// <param name="width"></param>
@ -131,6 +134,9 @@ namespace MoonWorks
} }
} }
/// <summary>
/// You can specify a method to run when the window size changes.
/// </summary>
public void RegisterSizeChangeCallback(System.Action<uint, uint> sizeChangeCallback) public void RegisterSizeChangeCallback(System.Action<uint, uint> sizeChangeCallback)
{ {
SizeChangeCallback = sizeChangeCallback; SizeChangeCallback = sizeChangeCallback;

View File

@ -1,13 +1,37 @@
namespace MoonWorks namespace MoonWorks
{ {
/// <summary>
/// All the information required for window creation.
/// </summary>
public struct WindowCreateInfo public struct WindowCreateInfo
{ {
/// <summary>
/// The name of the window that will be displayed in the operating system.
/// </summary>
public string WindowTitle; public string WindowTitle;
/// <summary>
/// The width of the window.
/// </summary>
public uint WindowWidth; public uint WindowWidth;
/// <summary>
/// The height of the window.
/// </summary>
public uint WindowHeight; public uint WindowHeight;
/// <summary>
/// Specifies if the window will be created in windowed mode or a fullscreen mode.
/// </summary>
public ScreenMode ScreenMode; public ScreenMode ScreenMode;
/// <summary>
/// Specifies the presentation mode for the window. Roughly equivalent to V-Sync.
/// </summary>
public PresentMode PresentMode; public PresentMode PresentMode;
/// <summary>
/// Whether the window can be resized using the operating system's window dragging feature.
/// </summary>
public bool SystemResizable; public bool SystemResizable;
/// <summary>
/// Specifies if the window will open at the maximum desktop resolution.
/// </summary>
public bool StartMaximized; public bool StartMaximized;
public WindowCreateInfo( public WindowCreateInfo(