/*    */ package org.shader;
/*    */ 
/*    */ import java.io.BufferedReader;
/*    */ import java.io.InputStreamReader;
/*    */ import org.lwjgl.opengl.GL20C;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class Shader
/*    */   implements AutoCloseable
/*    */ {
/*    */   private int shaderHandle;
/*    */   
/*    */   public Shader(String fileName, int shaderType) throws AssertionError {
/* 28 */     this.shaderHandle = GL20C.glCreateShader(shaderType);
/*    */     
/* 30 */     GL20C.glShaderSource(this.shaderHandle, getSource(fileName));
/* 31 */     GL20C.glCompileShader(this.shaderHandle);
/*    */     
/* 33 */     if (GL20C.glGetShaderi(this.shaderHandle, 35713) == 0) {
/*    */       
/* 35 */       System.err.println(GL20C.glGetShaderInfoLog(this.shaderHandle));
/* 36 */       throw new AssertionError("Could not compile Shader: " + fileName);
/*    */     } 
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   private String getSource(String fileName) {
/*    */     try {
/* 49 */       BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResource(fileName).openStream()));
/*    */       
/* 51 */       String result = reader.lines().reduce("", (A, B) -> String.valueOf(A) + B + System.lineSeparator());
/*    */       
/* 53 */       reader.close();
/*    */       
/* 55 */       return result;
/* 56 */     } catch (Exception e) {
/* 57 */       e.printStackTrace();
/* 58 */       return null;
/*    */     } 
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public final int getHandle() {
/* 68 */     return this.shaderHandle;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void close() {
/* 76 */     GL20C.glDeleteShader(this.shaderHandle);
/*    */   }
/*    */ }


/* Location:              /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/shader/Shader.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */