daily update on 20240104 by nitload youmu, double threading not work
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -11,19 +12,18 @@ namespace StgSharp.Graphics
|
||||
|
||||
internal unsafe partial class GLonRender : IglFunc
|
||||
{
|
||||
internal GLcontext* api;
|
||||
FrameTimeoutException refreshSIgnal = new FrameTimeoutException();
|
||||
|
||||
internal GLonRender(GLcontext context)
|
||||
|
||||
internal GLonRender(GLcontext* context)
|
||||
{
|
||||
api = context;
|
||||
}
|
||||
|
||||
internal GLcontext api;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.ActiveTexture(uint type)
|
||||
{
|
||||
api.ActiveTexture(type);
|
||||
api->glActiveTexture(type);
|
||||
}
|
||||
|
||||
void IglFunc.AfterAlign(Form form, Action action)
|
||||
@@ -45,41 +45,44 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.AttachShader(uint program, uint shader)
|
||||
{
|
||||
api.AttachShader(program, shader);
|
||||
api->glAttachShader(program, shader);
|
||||
}
|
||||
|
||||
void IglFunc.BindBuffer(BufferType bufferType, uint index)
|
||||
{
|
||||
api.BindBuffer((uint)bufferType, index);
|
||||
api->glBindBuffer((uint)bufferType, index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.BindTexture(uint type, uint texture)
|
||||
{
|
||||
api.BindTexture(type, texture);
|
||||
api->glBindTexture(type, texture);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.BindVertexArray(uint index)
|
||||
{
|
||||
api.BindVertexArray(index);
|
||||
api->glBindVertexArray(index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.Clear(MaskBufferBit mask)
|
||||
{
|
||||
api.Clear((uint)mask);
|
||||
api->glClear((uint)mask);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.ClearColor(float R, float G, float B, float A)
|
||||
{
|
||||
api.ClearColor(R, G, B, A);
|
||||
api->glClearColor(R, G, B, A);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.ClearGraphicError()
|
||||
{
|
||||
while (api.GetError() != 0) { }
|
||||
while (api->glGetError() != 0) { }
|
||||
}
|
||||
|
||||
uint IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
|
||||
{
|
||||
uint shaderID;
|
||||
@@ -123,7 +126,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
uint IglFunc.CreateProgram()
|
||||
{
|
||||
return api.CreateProgram();
|
||||
return api->glCreateProgram();
|
||||
}
|
||||
|
||||
unsafe IntPtr IglFunc.CreateWindowHandle(
|
||||
@@ -152,36 +155,44 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe uint IglFunc.CreatGraphicProgram()
|
||||
{
|
||||
return api.CreateProgram();
|
||||
return api->glCreateProgram();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.DeleteBuffers(int count, uint* ptr)
|
||||
unsafe void IglFunc.DeleteBuffer(uint handle)
|
||||
{
|
||||
api.DeleteBuffers(count, ptr);
|
||||
api->glDeleteBuffers(1, &handle);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.DeleteVertexArrays(int count, uint* ptr)
|
||||
unsafe void IglFunc.DeleteBuffers(uint count, uint[] handle)
|
||||
{
|
||||
api.DeleteVertexArrays(count, ptr);
|
||||
fixed (uint* ptr = handle)
|
||||
api->glDeleteBuffers(count, ptr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.DrawElements(GepmetryType mode, int count, Type type, IntPtr ptr)
|
||||
unsafe void IglFunc.DeleteVertexArrays(uint count, uint[] arrays)
|
||||
{
|
||||
fixed (uint* ptr = arrays)
|
||||
api->glDeleteVertexArrays(count, ptr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.DrawElements(GepmetryType mode, uint count, Type type, IntPtr ptr)
|
||||
{
|
||||
uint a;
|
||||
switch (type.Name)
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case "UInt32":
|
||||
case TypeCode.UInt32:
|
||||
a = GLconst.UNSIGNED_INT;
|
||||
break;
|
||||
case "UInt16":
|
||||
case TypeCode.UInt16:
|
||||
a = GLconst.UNSIGNED_SHORT;
|
||||
break;
|
||||
case "Byte":
|
||||
case TypeCode.Byte:
|
||||
a = GLconst.UNSIGNED_BYTE;
|
||||
break;
|
||||
default:
|
||||
@@ -191,31 +202,31 @@ namespace StgSharp.Graphics
|
||||
LogType.Error);
|
||||
return;
|
||||
}
|
||||
api.DrawElements((uint)mode, count, a, (void*)ptr);
|
||||
api->glDrawElements((uint)mode, count, a, (void*)ptr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.GenBuffers(int count, uint* ptr)
|
||||
unsafe void IglFunc.GenBuffers(uint count, uint* ptr)
|
||||
{
|
||||
api.GenBuffers(count, ptr);
|
||||
api->glGenBuffers(count, ptr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.GenTextures(int count, uint* ptr)
|
||||
unsafe void IglFunc.GenTextures(uint count, uint* ptr)
|
||||
{
|
||||
api.GenTextures(count, ptr);
|
||||
api->glGenTextures(count, ptr);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.GenVertexArrays(int count, uint* ptr)
|
||||
unsafe void IglFunc.GenVertexArrays(uint count, uint* ptr)
|
||||
{
|
||||
api.GenVertexArrays(count, ptr);
|
||||
api->glGenVertexArrays(count, ptr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.GetGraphicError()
|
||||
{
|
||||
string error = null;
|
||||
uint code = api.GetError();
|
||||
uint code = api->glGetError();
|
||||
while (code != 0)
|
||||
{
|
||||
error += $"OpenGL error {code}\n";
|
||||
@@ -242,7 +253,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe int IglFunc.GetUniformLocation(uint program, byte* ptr)
|
||||
{
|
||||
return api.GetUniformLocation(program, ptr);
|
||||
return api->glGetUniformLocation(program, ptr);
|
||||
}
|
||||
|
||||
unsafe bool IglFunc.GetWindowShouldClose(Form form)
|
||||
@@ -263,9 +274,9 @@ namespace StgSharp.Graphics
|
||||
unsafe void IglFunc.SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
|
||||
{
|
||||
int size = sizeof(T);
|
||||
api.BufferData(
|
||||
api->glBufferData(
|
||||
(uint)bufferType,
|
||||
size,
|
||||
(UIntPtr)size,
|
||||
&bufferData,
|
||||
(uint)usage);
|
||||
}
|
||||
@@ -274,14 +285,20 @@ namespace StgSharp.Graphics
|
||||
unsafe void IglFunc.SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
|
||||
fixed (void* bufferPtr = &bufferArray[0])
|
||||
api.BufferData(
|
||||
if (bufferArray == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fixed (void* bufferPtr = bufferArray)
|
||||
api->glBufferData(
|
||||
(uint)bufferType,
|
||||
size,
|
||||
(UIntPtr)size,
|
||||
bufferPtr,
|
||||
(uint)usage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler)
|
||||
{
|
||||
@@ -290,11 +307,17 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, int stride, int pointer)
|
||||
void IglFunc.SetVertexAttribute(uint index, int size, Type t, bool normalized, uint stride, int pointer)
|
||||
{
|
||||
uint type = InternalIO.GLtype[t];
|
||||
api.VertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
|
||||
api.EnableVertexAttribArray(index);
|
||||
api->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
|
||||
api->glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.SetWindowShouldClose(Form form, bool mark)
|
||||
{
|
||||
InternalIO.glfw.SetWindowShouldClose(form.windowID, mark ? 1 : 0);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SwapBuffers(Form form)
|
||||
@@ -306,27 +329,31 @@ namespace StgSharp.Graphics
|
||||
InternalIO.glfw.SwapBuffers(form.windowID);
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.TextureImage2d(uint target, int level, uint internalformat, int width, int height, uint format, uint type, void* pixels)
|
||||
void IglFunc.TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels)
|
||||
{
|
||||
api.TexImage2D(
|
||||
api->glTexImage2D(
|
||||
target, level, internalformat, width, height, 0, format, type, pixels
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.TextureParameter(uint target, uint pname, int param)
|
||||
{
|
||||
api.TexParameteri(target, pname, param);
|
||||
api->glTexParameteri(target, pname, param);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.UseProgram(uint program)
|
||||
{
|
||||
api.UseProgram(program);
|
||||
api->glUseProgram(program);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.Viewport(int x, int y, int width, int height)
|
||||
void IglFunc.Viewport(int x, int y, uint width, uint height)
|
||||
{
|
||||
api.Viewport(x, y, width, height);
|
||||
api->glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user