style: apply code-style cleanup (explicit types, this-qualification, switch expressions)

This commit is contained in:
2026-05-28 13:29:13 +02:00
parent 8e3195ca37
commit 70c986529b
9 changed files with 110 additions and 102 deletions

View File

@@ -10,38 +10,38 @@ public sealed class Shader : IDisposable
public Shader(string vertexPath, string fragmentPath)
{
int vertex = CompileFromFile(ShaderType.VertexShader, vertexPath);
int fragment = CompileFromFile(ShaderType.FragmentShader, fragmentPath);
int vertex = Shader.CompileFromFile(ShaderType.VertexShader, vertexPath);
int fragment = Shader.CompileFromFile(ShaderType.FragmentShader, fragmentPath);
_handle = GL.CreateProgram();
GL.AttachShader(_handle, vertex);
GL.AttachShader(_handle, fragment);
GL.LinkProgram(_handle);
this._handle = GL.CreateProgram();
GL.AttachShader(this._handle, vertex);
GL.AttachShader(this._handle, fragment);
GL.LinkProgram(this._handle);
GL.GetProgram(_handle, GetProgramParameterName.LinkStatus, out int linked);
GL.GetProgram(this._handle, GetProgramParameterName.LinkStatus, out int linked);
if (linked == 0)
throw new InvalidOperationException($"Program link failed: {GL.GetProgramInfoLog(_handle)}");
throw new InvalidOperationException($"Program link failed: {GL.GetProgramInfoLog(this._handle)}");
GL.DetachShader(_handle, vertex);
GL.DetachShader(_handle, fragment);
GL.DetachShader(this._handle, vertex);
GL.DetachShader(this._handle, fragment);
GL.DeleteShader(vertex);
GL.DeleteShader(fragment);
}
public void Use() => GL.UseProgram(_handle);
public void Use() => GL.UseProgram(this._handle);
public void SetMatrix4(string name, Matrix4 value) =>
GL.UniformMatrix4(Location(name), true, ref value);
GL.UniformMatrix4(this.Location(name), true, ref value);
public void SetInt(string name, int value) =>
GL.Uniform1(Location(name), value);
GL.Uniform1(this.Location(name), value);
private int Location(string name)
{
if (!_uniforms.TryGetValue(name, out int location))
if (!this._uniforms.TryGetValue(name, out int location))
{
location = GL.GetUniformLocation(_handle, name);
_uniforms[name] = location;
location = GL.GetUniformLocation(this._handle, name);
this._uniforms[name] = location;
}
return location;
}
@@ -60,5 +60,5 @@ public sealed class Shader : IDisposable
return shader;
}
public void Dispose() => GL.DeleteProgram(_handle);
public void Dispose() => GL.DeleteProgram(this._handle);
}