Files
stgsharp/源代码/StgSharp/Graphics/Form.cs
T

107 lines
2.6 KiB
C#

using StgSharp.Graphics.GL;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace StgSharp.Graphics
{
[StructLayout(LayoutKind.Sequential)]
internal struct formInfo
{
public int width;
public int height;
public vec4d color;
public string name;
}
public unsafe class Form:INode<Form>
{
internal IntPtr windowPtr;
internal formInfo info;
internal shaderObject shader;
internal LinkedList<Pool> allControl;
public vec2d Size
{
get { return new vec2d(info.width,info.height); }
set
{
info.width = (int)value.X;
info.height = (int)value.Y;
}
}
public int Width
{
get => info.width;
set => info.width = value;
}
public int Height
{
get => info.height;
set => info.height = value;
}
public vec4d Color
{
get => info.color;
set => info.color = value;
}
/// <summary>
/// Constructor of a Form, creats an instance of a form and
/// initilize all the customizing operations.
/// </summary>
public Form()
{
info = new formInfo();
allControl = new LinkedList<Pool>();
Init();
StgSharp.Graphic.LoadForm(this);
}
//used for internal control purpose
internal Form(int instruction)
{
}
internal unsafe void defualtInit()
{
fixed (shaderObject* shaderObj = &this.shader)
{
IntPtr windowPtr = Graphic.InitWindow(this);
internalIO.InternalCompileShader(shaderObj);
internalIO.InternalRenderWindow(windowPtr, this.info, shaderObj);
internalIO.TerminateWindow(shaderObj);
}
}
public virtual void Init()
{
info.color = new vec4d(0.95, 0.93, 0.92, 0);
info.width = 800;
info.height = 600;
this.windowPtr = Graphic.InitWindow(this);
}
public void Show()
{
fixed (shaderObject* shaderObj = &this.shader)
{
internalIO.InternalCompileShader(shaderObj);
internalIO.InternalRenderWindow(this.windowPtr, this.info, shaderObj);
internalIO.TerminateWindow(shaderObj);
}
}
}
}