// Path: src/integeruser/jglsdk/glutil/Shader.java
// public class Shader {
//     private static class CompileLinkShaderException extends RuntimeException {
//         private static final long serialVersionUID = 5490603440382398244L;
// 
//         CompileLinkShaderException(int shader) {
//             super(glGetShaderInfoLog(
//                     shader,
//                     glGetShaderi(shader, GL_INFO_LOG_LENGTH)));
//         }
//     }
// 
//     private static class CompileLinkProgramException extends RuntimeException {
//         private static final long serialVersionUID = 7321217286524434327L;
// 
//         CompileLinkProgramException(int program) {
//             super(glGetShaderInfoLog(
//                     program,
//                     glGetShaderi(program, GL_INFO_LOG_LENGTH)));
//         }
//     }
// 
// 
//     public static int compileShader(int shaderType, String shaderCode) {
//         int shader = glCreateShader(shaderType);
// 
//         glShaderSource(shader, shaderCode);
//         glCompileShader(shader);
// 
//         int status = glGetShaderi(shader, GL_COMPILE_STATUS);
//         if (status == GL_FALSE) {
//             glDeleteShader(shader);
//             throw new CompileLinkShaderException(shader);
//         }
// 
//         return shader;
//     }
// 
// 
//     public static int linkProgram(ArrayList<Integer> shaders) {
//         int program = glCreateProgram();
//         return linkProgram(program, shaders);
//     }
// 
//     private static int linkProgram(int program, ArrayList<Integer> shaders) {
//         for (Integer shader : shaders) {
//             glAttachShader(program, shader);
//         }
// 
//         glLinkProgram(program);
// 
//         int status = glGetProgrami(program, GL_LINK_STATUS);
//         if (status == GL_FALSE) {
//             glDeleteProgram(program);
//             throw new CompileLinkProgramException(program);
//         }
// 
//         for (Integer shader : shaders) {
//             glDetachShader(program, shader);
//         }
// 
//         return program;
//     }
// }


import integeruser.jglsdk.glutil.Shader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import static org.lwjgl.opengl.GL20.glDeleteShader;
package integeruser.jgltut.framework;





/**
 * Visit https://github.com/integeruser/jgltut for info and updates.
 * Original: https://bitbucket.org/alfonse/gltut/src/default/framework/framework.cpp
 */
public class Framework {
    public static String COMMON_DATAPATH = "/integeruser/jgltut/data/";
    public static String CURRENT_TUTORIAL_DATAPATH = null;


    public static String findFileOrThrow(String fileName) {
        // search the file in '/jgltut/tut##/data/'
        InputStream fileStream = Framework.class.getResourceAsStream(CURRENT_TUTORIAL_DATAPATH + fileName);
        if (fileStream != null) return CURRENT_TUTORIAL_DATAPATH + fileName;

        // search the file in '/jgltut/data/'
        fileStream = Framework.class.getResourceAsStream(COMMON_DATAPATH + fileName);
        if (fileStream != null) return COMMON_DATAPATH + fileName;

// Path: src/integeruser/jglsdk/glutil/Shader.java
// public class Shader {
//     private static class CompileLinkShaderException extends RuntimeException {
//         private static final long serialVersionUID = 5490603440382398244L;
// 
//         CompileLinkShaderException(int shader) {
//             super(glGetShaderInfoLog(
//                     shader,
//                     glGetShaderi(shader, GL_INFO_LOG_LENGTH)));
//         }
//     }
// 
//     private static class CompileLinkProgramException extends RuntimeException {
//         private static final long serialVersionUID = 7321217286524434327L;
// 
//         CompileLinkProgramException(int program) {
//             super(glGetShaderInfoLog(
//                     program,
//                     glGetShaderi(program, GL_INFO_LOG_LENGTH)));
//         }
//     }
// 
// 
//     public static int compileShader(int shaderType, String shaderCode) {
//         int shader = glCreateShader(shaderType);
// 
//         glShaderSource(shader, shaderCode);
//         glCompileShader(shader);
// 
//         int status = glGetShaderi(shader, GL_COMPILE_STATUS);
//         if (status == GL_FALSE) {
//             glDeleteShader(shader);
//             throw new CompileLinkShaderException(shader);
//         }
// 
//         return shader;
//     }
// 
// 
//     public static int linkProgram(ArrayList<Integer> shaders) {
//         int program = glCreateProgram();
//         return linkProgram(program, shaders);
//     }
// 
//     private static int linkProgram(int program, ArrayList<Integer> shaders) {
//         for (Integer shader : shaders) {
//             glAttachShader(program, shader);
//         }
// 
//         glLinkProgram(program);
// 
//         int status = glGetProgrami(program, GL_LINK_STATUS);
//         if (status == GL_FALSE) {
//             glDeleteProgram(program);
//             throw new CompileLinkProgramException(program);
//         }
// 
//         for (Integer shader : shaders) {
//             glDetachShader(program, shader);
//         }
// 
//         return program;
//     }
// }


// Path: src/integeruser/jgltut/framework/Framework.java
import integeruser.jglsdk.glutil.Shader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import static org.lwjgl.opengl.GL20.glDeleteShader;

package integeruser.jgltut.framework;





/**
 * Visit https://github.com/integeruser/jgltut for info and updates.
 * Original: https://bitbucket.org/alfonse/gltut/src/default/framework/framework.cpp
 */
public class Framework {
    public static String COMMON_DATAPATH = "/integeruser/jgltut/data/";
    public static String CURRENT_TUTORIAL_DATAPATH = null;


    public static String findFileOrThrow(String fileName) {
        // search the file in '/jgltut/tut##/data/'
        InputStream fileStream = Framework.class.getResourceAsStream(CURRENT_TUTORIAL_DATAPATH + fileName);
        if (fileStream != null) return CURRENT_TUTORIAL_DATAPATH + fileName;

        // search the file in '/jgltut/data/'
        fileStream = Framework.class.getResourceAsStream(COMMON_DATAPATH + fileName);
        if (fileStream != null) return COMMON_DATAPATH + fileName;

        throw new RuntimeException("Could not find the file " + fileName);