daily update on 20240427 by nitload youmu
This commit is contained in:
@@ -34,6 +34,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -41,18 +43,27 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public abstract class RenderStream
|
||||
{
|
||||
protected (int x, int y, int z) _coordStretch;
|
||||
private int refDepth;
|
||||
protected Camera NativeCamera;
|
||||
|
||||
private IntPtr canvasHandle;
|
||||
private IntPtr contextHandle;
|
||||
private IntPtr monitor;
|
||||
private IntPtr sharedCanvas;
|
||||
|
||||
private int height;
|
||||
private IntPtr monitor;
|
||||
private IntPtr sharedCanvas;
|
||||
private int width;
|
||||
protected (int x, int y, int z) _coordStretch;
|
||||
protected string name;
|
||||
private Camera nativeCamera;
|
||||
|
||||
protected RenderStream(RenderStreamConstructArgs args)
|
||||
{
|
||||
height = args.Height;
|
||||
monitor = args.Monitor;
|
||||
width = args.Width;
|
||||
name = args.Name;
|
||||
monitor = args.Monitor;
|
||||
_coordStretch = args.UnitCubeSize;
|
||||
}
|
||||
|
||||
public IntPtr CanvasHandle
|
||||
{
|
||||
@@ -66,26 +77,30 @@ namespace StgSharp.Graphics
|
||||
internal set => contextHandle = value;
|
||||
}
|
||||
|
||||
public int Depth
|
||||
internal protected Camera NativeCamera
|
||||
{
|
||||
get => refDepth;
|
||||
internal set => refDepth = value;
|
||||
get => nativeCamera;
|
||||
internal set => nativeCamera = value;
|
||||
}
|
||||
|
||||
public FrameBufferSizeHandler FrameSizeCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(CanvasHandle, handlerPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public vec2d GlobalCoordSize => ((Width * 1.0f) / _coordStretch.x, (Height * 1.0f) / _coordStretch.y);
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => height;
|
||||
internal set => height = value;
|
||||
}
|
||||
|
||||
public vec3d GlobalCoordSize
|
||||
{
|
||||
get
|
||||
internal set
|
||||
{
|
||||
return (
|
||||
Width * 1.0f / _coordStrech.x,
|
||||
Height * 1.0f / _coordStrech.y,
|
||||
refDepth * 1.0f / _coordStrech.z);
|
||||
height = value;
|
||||
InternalIO.glfwSetWindowSize(this.canvasHandle, Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,24 +122,86 @@ namespace StgSharp.Graphics
|
||||
internal set => sharedCanvas = value;
|
||||
}
|
||||
|
||||
public vec2d Size
|
||||
{
|
||||
get => new vec2d(width, height);
|
||||
internal set
|
||||
{
|
||||
height = (int)value.Y;
|
||||
width = (int)value.X;
|
||||
InternalIO.glfwSetWindowSize(this.canvasHandle, Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => width;
|
||||
internal set => width = value;
|
||||
internal set
|
||||
{
|
||||
width = value;
|
||||
InternalIO.glfwSetWindowSize(this.canvasHandle, Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract void CreateCanvas(
|
||||
(int width,int height,int depth) size, (int x_stretch,int y_stretch, int z_stretch) coordStrech, string name
|
||||
);
|
||||
/// <summary>
|
||||
/// Set the size limit of current form
|
||||
/// </summary>
|
||||
/// <param name="minWidth">Minimum width of current form</param>
|
||||
/// <param name="minHeight">Minimum height of current form</param>
|
||||
/// <param name="maxWidth">Maximum width of current form</param>
|
||||
/// <param name="maxHeight">Maximum height of current form</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public abstract void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight);
|
||||
|
||||
internal abstract void CreateCanvas();
|
||||
|
||||
#region native camera operation
|
||||
protected abstract void NativeCameraViewRange(Radius FieldOfRange,vec2d offset, (float frontDepth, float backDepth ) viewDepth );
|
||||
protected abstract void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up);
|
||||
/// <summary>
|
||||
/// Get <see cref="Uniform{Matrix44}"/> uniform from a shader.
|
||||
/// This uniform will be used as projection matrix of this camera.
|
||||
/// Additionally, for multi-shader rendering, each shader requires a uniform,
|
||||
/// so do not ignore return value of this method.
|
||||
/// </summary>
|
||||
/// <param name="source">Shader using this camera</param>
|
||||
/// <param name="name">Name of projection camera named in shader</param>
|
||||
/// <returns>
|
||||
/// <see cref="Uniform{T}"/>(T is <see cref="Matrix44"/>) representing
|
||||
/// projection matrix in shader program.
|
||||
/// </returns>
|
||||
protected abstract Uniform<Matrix44> NativeCameraUniform(ShaderProgram source, string name);
|
||||
#endregion
|
||||
|
||||
#region internal operation
|
||||
internal abstract void InternalDraw();
|
||||
internal abstract void InternalInit();
|
||||
internal abstract void InternalTerminate();
|
||||
#endregion
|
||||
|
||||
#region public operation
|
||||
protected abstract void Deinit();
|
||||
protected abstract void Init();
|
||||
protected abstract void Main();
|
||||
protected abstract void Deinit();
|
||||
protected abstract void ProcessInput();
|
||||
#endregion
|
||||
|
||||
internal abstract void InternalInit();
|
||||
internal abstract void InternalDraw();
|
||||
internal abstract void InternalTerminate();
|
||||
#region public resource generator
|
||||
|
||||
protected abstract Shader CreateShaderSegment(ShaderType type, int count);
|
||||
protected abstract ShaderProgram CreateShaderProgram();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class RenderStreamConstructArgs
|
||||
{
|
||||
|
||||
public int Height { get; set; }
|
||||
public IntPtr Monitor { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Width { get; set; }
|
||||
public (int x, int y, int z) UnitCubeSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user