* @return the resulting ID
* @throws SlimException if compilation was unsuccessful */
protected int compileShader(int type, String source) throws LWJGLException {
int shader = glCreateShader(type);
if (shader == 0)
throw new LWJGLException(
"could not create shader object; check ShaderProgram.isSupported()");
glShaderSource(shader, source);
glCompileShader(shader);
int comp = glGetShaderi(shader, GL_COMPILE_STATUS);
int len = glGetShaderi(shader, GL_INFO_LOG_LENGTH);
String t = shaderTypeString(type);
String err = glGetShaderInfoLog(shader, len);
if (err != null && err.length() != 0)
log += t + " compile log:\n" + err + "\n";
if (comp == GL11.GL_FALSE)
throw new LWJGLException(log.length()!=0 ? log : "Could not compile "+shaderTypeString(type));
return shader;
}