daily update on 20240203 by nitloadd youmu. New glhandle setup.

This commit is contained in:
Nitload
2024-02-03 23:20:50 +08:00
parent 8148c10acd
commit 5d778e0f2f
258 changed files with 10025 additions and 1220 deletions
+36 -22
View File
@@ -3,6 +3,7 @@ using StgSharp.Math;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
@@ -43,9 +44,9 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void IglFunc.AttachShader(uint program, uint shader)
void IglFunc.AttachShader(glHandle program, glHandle shader)
{
api->glAttachShader(program, shader);
api->glAttachShader(program[0], shader[0]);
}
void IglFunc.BindBuffer(BufferType bufferType, uint index)
@@ -83,12 +84,12 @@ namespace StgSharp.Graphics
while (api->glGetError() != 0) { }
}
uint IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
glHandle IglFunc.CompileShader(string shaderCode, ShaderType shaderType)
{
uint shaderID;
shaderCode += '\0';
shaderID = InternalIO.InternalLoadShaderCode(shaderCode, (int)shaderType);
if (shaderID == 0)
if (shaderID == 0) //compile error handler
{
IntPtr logPtr = InternalIO.InternalReadLog();
string log;
@@ -114,19 +115,32 @@ namespace StgSharp.Graphics
}
catch (Exception)
{
log = "Failed to compile shader.\nFailed to get GLSL compiler log";
log = "Failed to compile shader.\n" +
"Failed to get GLSL compiler log";
}
InternalIO.InternalWriteLog(log, LogType.Error);
}
return shaderID;
return new glHandle(shaderID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
uint IglFunc.CreateProgram()
glHandle IglFunc.CreateProgram()
{
return api->glCreateProgram();
return new glHandle(api->glCreateProgram());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe glHandle IglFunc.CreateProgram(int count)
{
glHandle h = new glHandle(count);
uint* p = h.handle;
for (int i = 0; i < count; i++)
{
*(p + i) = api->glCreateProgram();
}
return h;
}
unsafe IntPtr IglFunc.CreateWindowHandle(
@@ -156,9 +170,9 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe uint IglFunc.CreatGraphicProgram()
unsafe glHandle IglFunc.CreatGraphicProgram()
{
return api->glCreateProgram();
return new glHandle(api->glCreateProgram());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -167,17 +181,17 @@ namespace StgSharp.Graphics
api->glDeleteBuffers(1, &handle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.DeleteBuffers(uint count, uint[] handle)
unsafe void IglFunc.DeleteBuffers(glHandle handle)
{
fixed (uint* ptr = handle)
api->glDeleteBuffers(count, ptr);
api->glDeleteBuffers((uint)handle.length, handle.handle);
handle.Free();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.DeleteVertexArrays(uint count, uint[] arrays)
unsafe void IglFunc.DeleteVertexArrays(glHandle arrays)
{
fixed (uint* ptr = arrays)
api->glDeleteVertexArrays(count, ptr);
api->glDeleteVertexArrays((uint)arrays.length, arrays.handle);
arrays.Free();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -206,20 +220,20 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenBuffers(uint count, uint* ptr)
unsafe void IglFunc.GenBuffers(uint count, glHandle handle)
{
api->glGenBuffers(count, ptr);
api->glGenBuffers(count, handle.handle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenTextures(uint count, uint* ptr)
unsafe void IglFunc.GenTextures(uint count, glHandle handle)
{
api->glGenTextures(count, ptr);
api->glGenTextures(count, handle.handle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void IglFunc.GenVertexArrays(uint count, uint* ptr)
unsafe void IglFunc.GenVertexArrays(uint count, glHandle handle)
{
api->glGenVertexArrays(count, ptr);
api->glGenVertexArrays(count, handle.handle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]