From 2f1383a89f70817c246551447cdda3f5d70dea2b Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Wed, 7 Dec 2016 11:59:35 -0800 Subject: [PATCH] Improve error handling when shader does not compile --- lime/utils/GLUtils.hx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lime/utils/GLUtils.hx b/lime/utils/GLUtils.hx index 5585398d4..224beebde 100644 --- a/lime/utils/GLUtils.hx +++ b/lime/utils/GLUtils.hx @@ -4,6 +4,7 @@ package lime.utils; import lime.graphics.opengl.GLProgram; import lime.graphics.opengl.GLShader; import lime.graphics.opengl.GL; +import lime.utils.Log; class GLUtils { @@ -17,14 +18,17 @@ class GLUtils { if (GL.getShaderParameter (shader, GL.COMPILE_STATUS) == 0) { - switch (type) { + var message = switch (type) { - case GL.VERTEX_SHADER: throw "Error compiling vertex shader"; - case GL.FRAGMENT_SHADER: throw "Error compiling fragment shader"; - default: throw "Error compiling unknown shader type"; + case GL.VERTEX_SHADER: "Error compiling vertex shader"; + case GL.FRAGMENT_SHADER: "Error compiling fragment shader"; + default: "Error compiling unknown shader type"; } + message += "\n" + GL.getShaderInfoLog (shader); + Log.error (message); + } return shader; @@ -44,7 +48,7 @@ class GLUtils { if (GL.getProgramParameter (program, GL.LINK_STATUS) == 0) { - throw "Unable to initialize the shader program."; + Log.error ("Unable to initialize the shader program"); }