daily update on 20240305 by nitload youmu
This commit is contained in:
@@ -54,13 +54,13 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.AttachShader(glHandle program, glHandle shader)
|
||||
{
|
||||
api->glAttachShader(*program.valuePtr, *shader.valuePtr);
|
||||
api->glAttachShader(*program.valuePtr, shader.DirectValue);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.BindBuffer(BufferType bufferType, glHandle handle)
|
||||
{
|
||||
api->glBindBuffer((uint)bufferType, *handle.valuePtr);
|
||||
api->glBindBuffer((uint)bufferType, handle.DirectValue);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -93,57 +93,39 @@ namespace StgSharp.Graphics
|
||||
while (api->glGetError() != 0) { }
|
||||
}
|
||||
|
||||
glHandleSet IglFunc.CompileShader(ShaderType shaderType, params string[] shaderCodeArray)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.LoadShaderSource(glHandle shaderHandle, string codeStream)
|
||||
{
|
||||
int l = shaderCodeArray.Length;
|
||||
if (l == 0)
|
||||
byte[] stream = Encoding.UTF8.GetBytes(codeStream);
|
||||
fixed (byte* streamPtr = stream)
|
||||
{
|
||||
throw new ArgumentException("At least one pice of code is required.");
|
||||
api->glShaderSource(shaderHandle.DirectValue, 1, &streamPtr, (void*)0);
|
||||
}
|
||||
glHandleSet handleSet = new glHandleSet(l);
|
||||
for (int i = 0; i < l; i++)
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
glHandleSet IglFunc.CreateShaderSet(int count, ShaderType type)
|
||||
{
|
||||
glHandleSet ret = new glHandleSet(count);
|
||||
uint t = (uint)type;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint shaderID;
|
||||
byte[] data = Encoding.UTF8.GetBytes(shaderCodeArray[i] + '\0');
|
||||
fixed (byte* codePtr = data)
|
||||
uint id = api->glCreateShader(t);
|
||||
if (id == 0)
|
||||
{
|
||||
shaderID = InternalIO.InternalLoadShaderCode(api, codePtr, (int)shaderType);
|
||||
uint error = api->glGetError();
|
||||
InternalIO.InternalWriteLog($"Failed in creating shader: {error}", LogType.Error);
|
||||
throw new Exception();
|
||||
}
|
||||
if (shaderID == 0) //compile error handler
|
||||
{
|
||||
IntPtr logPtr = InternalIO.InternalReadSSCLog();
|
||||
string log;
|
||||
try
|
||||
{
|
||||
byte[] logByte = new byte[512];
|
||||
Marshal.Copy(logPtr, logByte, 0, 512);
|
||||
log = Encoding.UTF8.GetString(logByte);
|
||||
log = log.Replace("\0", "");
|
||||
|
||||
bool isUseful = false;
|
||||
foreach (char item in log)
|
||||
{
|
||||
if (!char.IsControl(item))
|
||||
{
|
||||
isUseful = true; break;
|
||||
}
|
||||
}
|
||||
if (!isUseful)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
log = "Failed to compile shader.\n" +
|
||||
"Failed to get GLSL compiler log";
|
||||
}
|
||||
|
||||
InternalIO.InternalWriteLog(log, LogType.Error);
|
||||
}
|
||||
handleSet.SetValue(i, shaderID);
|
||||
ret.SetValue(i, id);
|
||||
}
|
||||
return handleSet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.CompileShader(glHandle shaderhandle)
|
||||
{
|
||||
api->glCompileShader(shaderhandle.DirectValue);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -301,7 +283,7 @@ namespace StgSharp.Graphics
|
||||
api->glBufferData(
|
||||
(uint)bufferType,
|
||||
(IntPtr)size,
|
||||
&bufferData,
|
||||
(IntPtr)(&bufferData),
|
||||
(uint)usage);
|
||||
}
|
||||
|
||||
@@ -317,7 +299,7 @@ namespace StgSharp.Graphics
|
||||
api->glBufferData(
|
||||
(uint)bufferType,
|
||||
(IntPtr)size,
|
||||
bufferPtr,
|
||||
(IntPtr)bufferPtr,
|
||||
(uint)usage);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user