daily update on 2024.03.18 by itload youmu
This commit is contained in:
@@ -1,4 +1,34 @@
|
||||
using StgSharp.Logic;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GLonUpdate.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.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -15,10 +45,10 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
internal unsafe partial class GLonUpdate : IglFunc
|
||||
{
|
||||
|
||||
private GLcontext* api;
|
||||
private IntPtr SwapBufferPtr = (IntPtr)(delegate*<IntPtr, void>)&InternalIO.glfwSwapBuffers;
|
||||
private glSHandle unupdatedFrame = glSHandle.Alloc(0);
|
||||
private FrameOperationBuffer frameOpBuffer;
|
||||
private glSHandle unupdatedFrame = glSHandle.Alloc(0);
|
||||
|
||||
internal GLonUpdate(GLcontext* context)
|
||||
{
|
||||
@@ -29,15 +59,19 @@ namespace StgSharp.Graphics
|
||||
api = context;
|
||||
}
|
||||
|
||||
GLcontext* IglFunc.Context
|
||||
{
|
||||
get => api;
|
||||
}
|
||||
|
||||
public FrameOperationBuffer ActivatedOperationBuffer
|
||||
{
|
||||
get { return frameOpBuffer; }
|
||||
set { frameOpBuffer = value; }
|
||||
get => frameOpBuffer;
|
||||
set => frameOpBuffer = value;
|
||||
}
|
||||
|
||||
public void GLswapBuffers(Form form)
|
||||
{
|
||||
if (form.WindowID == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InternalIO.glfwSwapBuffers(form.id);
|
||||
}
|
||||
|
||||
void IglFunc.ActiveTexture(uint type)
|
||||
@@ -77,7 +111,7 @@ namespace StgSharp.Graphics
|
||||
void IglFunc.BindTexture(uint type, glHandle texture)
|
||||
{
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, (uint)type);
|
||||
m.Write<uint>(0, type);
|
||||
m.Write<ulong>(1, (ulong)texture.valuePtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(BindTexturePtr);
|
||||
@@ -156,15 +190,15 @@ namespace StgSharp.Graphics
|
||||
if (share == null)
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(
|
||||
width, height, tittleBytes, monitor, IntPtr.Zero);
|
||||
width, height, tittleBytes, monitor, (GLFWwindow*)IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(
|
||||
width, height, tittleBytes, monitor, share.windowID);
|
||||
width, height, tittleBytes, monitor, share.id);
|
||||
}
|
||||
|
||||
if ((long)windowPtr == -1 || (long)windowPtr == -2)
|
||||
if (((long)windowPtr == -1) || ((long)windowPtr == -2))
|
||||
{
|
||||
throw new Exception("Cannot create window instance!");
|
||||
}
|
||||
@@ -229,8 +263,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
default:
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Parameter error in parameter {type} method DrawElements. " +
|
||||
$"Only {TypeCode.Byte}, {TypeCode.UInt16}, {TypeCode.UInt32} types are suporrted.",
|
||||
$"{($"Parameter error in parameter {type} method DrawElements. ")}{($"Only {TypeCode.Byte}, {TypeCode.UInt16}, {TypeCode.UInt32} types are suporrted.")}",
|
||||
LogType.Error);
|
||||
return;
|
||||
}
|
||||
@@ -239,6 +272,16 @@ namespace StgSharp.Graphics
|
||||
frameOpBuffer.MethodEnqueue(DrawElementsPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.frameworkHandleEnqueue(IntPtr methodHandle, params M128[] param)
|
||||
{
|
||||
foreach (M128 item in param)
|
||||
{
|
||||
frameOpBuffer.ParamEnqueue(item);
|
||||
}
|
||||
frameOpBuffer.ParamEnqueue(methodHandle);
|
||||
}
|
||||
|
||||
unsafe glHandleSet IglFunc.GenBuffers(int count)
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
@@ -282,16 +325,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
bool IglFunc.GetWindowShouldClose(Form form)
|
||||
{
|
||||
return InternalIO.glfwWindowShouldClose(form.windowID) == 0;
|
||||
}
|
||||
|
||||
public void GLswapBuffers(Form form)
|
||||
{
|
||||
if (form.windowID == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InternalIO.glfwSwapBuffers(form.windowID);
|
||||
return InternalIO.glfwWindowShouldClose(form.id) == 0;
|
||||
}
|
||||
|
||||
void IglFunc.LoadShaderSource(glHandle shaderHandle, string codeStream)
|
||||
@@ -304,11 +338,11 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.MakeContexCurrent(Form form)
|
||||
{
|
||||
if (form.windowID == IntPtr.Zero)
|
||||
if (form.WindowID == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InternalIO.glfwMakeContextCurrent(form.windowID);
|
||||
InternalIO.glfwMakeContextCurrent(form.id);
|
||||
}
|
||||
|
||||
void IglFunc.SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
|
||||
@@ -370,14 +404,8 @@ namespace StgSharp.Graphics
|
||||
frameOpBuffer.MethodEnqueue(ViewPortPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.frameworkHandleEnqueue(IntPtr methodHandle, params M128[] param)
|
||||
{
|
||||
foreach (M128 item in param)
|
||||
{
|
||||
frameOpBuffer.ParamEnqueue(item);
|
||||
}
|
||||
frameOpBuffer.ParamEnqueue(methodHandle);
|
||||
}
|
||||
GLcontext* IglFunc.Context
|
||||
=> api;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user