mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-22 21:51:08 +00:00
Clean up shader error detection
This commit is contained in:
parent
3ee6d1dbbd
commit
809799aa90
|
@ -80,8 +80,8 @@ namespace Examples.Tutorial
|
||||||
ShaderFilenames[0] = "Data/Shaders/JuliaSet_SM3_FS.glsl";
|
ShaderFilenames[0] = "Data/Shaders/JuliaSet_SM3_FS.glsl";
|
||||||
ShaderFilenames[1] = "Data/Shaders/JuliaSet_SM2_FS.glsl";
|
ShaderFilenames[1] = "Data/Shaders/JuliaSet_SM2_FS.glsl";
|
||||||
|
|
||||||
byte CurrentOption = 0;
|
|
||||||
string LogInfo;
|
string LogInfo;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
#region Shaders
|
#region Shaders
|
||||||
// Load&Compile Vertex Shader
|
// Load&Compile Vertex Shader
|
||||||
|
@ -99,34 +99,31 @@ namespace Examples.Tutorial
|
||||||
Trace.WriteLine("Vertex Shader compiled without complaint.");
|
Trace.WriteLine("Vertex Shader compiled without complaint.");
|
||||||
|
|
||||||
// Load&Compile Fragment Shader
|
// Load&Compile Fragment Shader
|
||||||
|
|
||||||
|
|
||||||
FragmentShaderObject = GL.CreateShader(ShaderType.FragmentShader);
|
FragmentShaderObject = GL.CreateShader(ShaderType.FragmentShader);
|
||||||
do
|
foreach (var shader in ShaderFilenames)
|
||||||
{
|
{
|
||||||
using (StreamReader sr = new StreamReader(ShaderFilenames[CurrentOption]))
|
using (StreamReader sr = new StreamReader(shader))
|
||||||
{
|
{
|
||||||
|
|
||||||
GL.ShaderSource(FragmentShaderObject, sr.ReadToEnd());
|
GL.ShaderSource(FragmentShaderObject, sr.ReadToEnd());
|
||||||
GL.CompileShader(FragmentShaderObject);
|
GL.CompileShader(FragmentShaderObject);
|
||||||
}
|
}
|
||||||
|
GL.GetShader(FragmentShaderObject, ShaderParameter.CompileStatus, out status);
|
||||||
|
if (status != 1)
|
||||||
|
{
|
||||||
GL.GetShaderInfoLog(FragmentShaderObject, out LogInfo);
|
GL.GetShaderInfoLog(FragmentShaderObject, out LogInfo);
|
||||||
|
Trace.WriteLine("Compiling " + shader + " failed!\nLog:\n" + LogInfo);
|
||||||
if (LogInfo.Length > 0 && !LogInfo.Contains("hardware"))
|
}
|
||||||
Trace.WriteLine("Compiling " + ShaderFilenames[CurrentOption] + " failed!\nLog:\n" + LogInfo);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Trace.WriteLine("Fragment Shader compiled without complaint.");
|
Trace.WriteLine("Fragment Shader compiled without complaint.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++CurrentOption > 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Neither SM2 nor SM3 Fragment Shader compiled successfully. Aborting.",
|
|
||||||
"Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
this.Exit();
|
|
||||||
}
|
}
|
||||||
} while (true);
|
if (status != 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Shader compilation failed");
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
|
|
||||||
// Link the Shaders to a usable Program
|
// Link the Shaders to a usable Program
|
||||||
ProgramObject = GL.CreateProgram();
|
ProgramObject = GL.CreateProgram();
|
||||||
|
|
Loading…
Reference in a new issue