// Path: src/main/java/org/scorpion/jmugen/exception/InitializationError.java
// public class InitializationError extends Error implements Fatal {
// 
//     public InitializationError(String message) {
//         super(message);
//     }
// 
//     public InitializationError(String message, String reason) {
//         super(message + ":\n" + reason);
//     }
// 
//     public InitializationError(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/scorpion/jmugen/util/Resource.java
// public interface Resource {
// 
//     InputStream load();
// 
//     String getName();
// 
// }


import org.apache.commons.io.IOUtils;
import org.scorpion.jmugen.exception.InitializationError;
import org.scorpion.jmugen.util.Resource;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import java.io.IOException;
package org.scorpion.jmugen.render.util;




public class ShaderUtils {

    public static int loadShaders(Resource vertex, Resource fragment) {
        int p = glCreateProgram();
        int vertexShaderId = loadAndAttachShader(p, GL_VERTEX_SHADER, vertex);
        int fragmentShaderId = loadAndAttachShader(p, GL_FRAGMENT_SHADER, fragment);
        glLinkProgram(p);
        if (glGetProgrami(p, GL_LINK_STATUS) == GL_FALSE) {
            String log = glGetProgramInfoLog(p, glGetProgrami(p, GL_INFO_LOG_LENGTH));
            throw new InitializationError("Failed to link program " + vertex + " " + fragment, log);
        }
        glValidateProgram(p);

        glDeleteShader(vertexShaderId);
        glDeleteShader(fragmentShaderId);

        return p;
    }

// Path: src/main/java/org/scorpion/jmugen/exception/InitializationError.java
// public class InitializationError extends Error implements Fatal {
// 
//     public InitializationError(String message) {
//         super(message);
//     }
// 
//     public InitializationError(String message, String reason) {
//         super(message + ":\n" + reason);
//     }
// 
//     public InitializationError(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/scorpion/jmugen/util/Resource.java
// public interface Resource {
// 
//     InputStream load();
// 
//     String getName();
// 
// }


// Path: src/main/java/org/scorpion/jmugen/render/util/ShaderUtils.java
import org.apache.commons.io.IOUtils;
import org.scorpion.jmugen.exception.InitializationError;
import org.scorpion.jmugen.util.Resource;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import java.io.IOException;

package org.scorpion.jmugen.render.util;




public class ShaderUtils {

    public static int loadShaders(Resource vertex, Resource fragment) {
        int p = glCreateProgram();
        int vertexShaderId = loadAndAttachShader(p, GL_VERTEX_SHADER, vertex);
        int fragmentShaderId = loadAndAttachShader(p, GL_FRAGMENT_SHADER, fragment);
        glLinkProgram(p);
        if (glGetProgrami(p, GL_LINK_STATUS) == GL_FALSE) {
            String log = glGetProgramInfoLog(p, glGetProgrami(p, GL_INFO_LOG_LENGTH));
            throw new InitializationError("Failed to link program " + vertex + " " + fragment, log);
        }
        glValidateProgram(p);

        glDeleteShader(vertexShaderId);
        glDeleteShader(fragmentShaderId);

        return p;
    }

    private static int loadAndAttachShader(int program, int type, Resource shaderRes) throws InitializationError {