daily update on 20240513 by nitload youmu, instancing render added

This commit is contained in:
YoumuLiu
2024-05-13 03:39:54 +08:00
parent 56459deec5
commit a3506c96a3
78 changed files with 2562 additions and 1098 deletions
@@ -33,9 +33,11 @@ using StgSharp.Data;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml.Linq;
namespace StgSharp.Graphics
{
@@ -85,6 +87,16 @@ namespace StgSharp.Graphics
GL.AttachShader(target.handle, handle[index]);
}
public static string FromCodeFile(string fileRoute)
{
string str = File.ReadAllText(fileRoute);
if (str == "")
{
throw new Exception($"Cannot load and GLSL code from {fileRoute}");
}
return str;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Compile(int index, string code)
{
@@ -94,6 +106,7 @@ namespace StgSharp.Graphics
}
GL.LoadShaderSource(handle[index], $"{code}\0");
GL.CompileShader(handle[index]);
CheckStatus(index,ShaderStatus.CompileStatus);
}
public override string ToString()
@@ -107,6 +120,15 @@ namespace StgSharp.Graphics
throw new NotImplementedException();
}
public void CheckStatus(int index, ShaderStatus status)
{
string log = GL.GetShaderStatus(this,index, (int)status);
if (log != "")
{
throw new Exception($"Shader Error\n{status}\n" + log);
}
}
public override byte[] GetBytes(out int length)
{
throw new NotImplementedException();
@@ -118,6 +140,11 @@ namespace StgSharp.Graphics
}
}
public enum ShaderStatus : int
{
CompileStatus = GLconst.COMPILE_STATUS,
}
public class ShaderProgram
{