daily update on 20240613 by nitload youmu[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[C[4
This commit is contained in:
@@ -49,22 +49,15 @@ namespace StgSharp.Graphics
|
||||
public unsafe partial class View
|
||||
{
|
||||
|
||||
private (int w, int h) sizeCache;
|
||||
private (int x, int y, int z) unitCubeSize;
|
||||
|
||||
private ViewPort context;
|
||||
|
||||
private ViewPortDesigner design;
|
||||
|
||||
public ViewPort Port
|
||||
{
|
||||
get => context;
|
||||
}
|
||||
|
||||
public View(ViewPort vp, ViewPortDesigner design)
|
||||
{
|
||||
context = vp;
|
||||
sizeCache = (0, 0);
|
||||
unitCubeSize = (1, 1, 1);
|
||||
localLogic = new Logic.Blueprint();
|
||||
this.design = design;
|
||||
@@ -74,30 +67,27 @@ namespace StgSharp.Graphics
|
||||
public View(ViewPort vp, ViewPortDesigner design, (int, int, int) cubeSize)
|
||||
{
|
||||
context = vp;
|
||||
sizeCache = (0, 0);
|
||||
unitCubeSize = cubeSize;
|
||||
localLogic = new Logic.Blueprint();
|
||||
}
|
||||
|
||||
public (int x, int y, int z) UnitCubeSize
|
||||
{
|
||||
get => unitCubeSize;
|
||||
}
|
||||
|
||||
public bool Activated { get; internal set; }
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
if (context.Height != sizeCache.h)
|
||||
{
|
||||
sizeCache.h = context.Height;
|
||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
||||
}
|
||||
return sizeCache.h;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
sizeCache.h = value;
|
||||
context.Height = value;
|
||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
||||
}
|
||||
get => context.Height;
|
||||
internal set { context.Height = value; }
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => context.Width;
|
||||
internal set { context.Width = value; }
|
||||
}
|
||||
|
||||
public IntPtr Monitor => context.Monitor;
|
||||
@@ -108,28 +98,9 @@ namespace StgSharp.Graphics
|
||||
|
||||
public string SelfName { get; set; }
|
||||
|
||||
public (int x, int y, int z) UnitCubeSize
|
||||
public ViewPort Port
|
||||
{
|
||||
get => unitCubeSize;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
if (context.Width != sizeCache.w)
|
||||
{
|
||||
sizeCache.w = context.Width;
|
||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
||||
}
|
||||
return sizeCache.h;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
sizeCache.w = value;
|
||||
context.Width = value;
|
||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
||||
}
|
||||
get => context;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,38 @@
|
||||
using StgSharp.Math;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="ViewPort.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -10,37 +41,82 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public class ViewPort
|
||||
{
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
private int _width, _height;
|
||||
|
||||
public string Name { get; set; }
|
||||
internal ViewPort()
|
||||
{
|
||||
_height = 800;
|
||||
_width = 600;
|
||||
Name = new StackFrame(1, false).
|
||||
GetMethod()!.DeclaringType!.Name;
|
||||
Monitor = IntPtr.Zero;
|
||||
ViewPortID = InternalIO.glfwCreateWindow(_width, _height,
|
||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||
);
|
||||
if (ViewPortID == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||
}
|
||||
}
|
||||
|
||||
public ViewPort(vec2d size, string name, IntPtr monitor)
|
||||
{
|
||||
_width = (int)size.X;
|
||||
_height = (int)size.Y;
|
||||
Name = name;
|
||||
Monitor = monitor;
|
||||
ViewPortID = InternalIO.glfwCreateWindow(_width, _height,
|
||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||
);
|
||||
if (ViewPortID == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(this.ViewPortID, _width, value);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalIO.glfwSetWindowSize(this.ViewPortID, value, _height);
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr GraphicHandle { get; internal set; }
|
||||
|
||||
public IntPtr Monitor { get; internal set; }
|
||||
|
||||
public IntPtr ViewPortID { get; private set; }
|
||||
public IntPtr GraphicHandle { get; internal set; }
|
||||
|
||||
internal ViewPort()
|
||||
public string Name { get; set; }
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Height = 800;
|
||||
Width = 600;
|
||||
Name = new StackFrame(1, false).
|
||||
GetMethod()!.DeclaringType!.Name;
|
||||
Monitor = IntPtr.Zero;
|
||||
ViewPortID = InternalIO.glfwCreateWindow(Width,Height,
|
||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||
);
|
||||
InternalIO.glfwSetWindowShouldClose(this.ViewPortID,1);
|
||||
}
|
||||
|
||||
public ViewPort(vec2d size,string name, IntPtr monitor)
|
||||
internal unsafe void FlushSize()
|
||||
{
|
||||
Height = (int) size.Y;
|
||||
Width = (int) size.X;
|
||||
Name = name;
|
||||
Monitor = monitor;
|
||||
ViewPortID = InternalIO.glfwCreateWindow(Width, Height,
|
||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||
);
|
||||
fixed (int* wptr = &_width, hptr = &_height)
|
||||
{
|
||||
InternalIO.glfwGetWindowSize(ViewPortID, wptr, hptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user