/*    */ package org.shader;
/*    */ 
/*    */ import org.lwjgl.opengl.GL20C;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ShaderProgram
/*    */   implements AutoCloseable
/*    */ {
/*    */   protected int program;
/*    */   private Shader vertexShader;
/*    */   private Shader fragmentShader;
/*    */   
/*    */   public ShaderProgram(String shaderName) throws AssertionError {
/* 28 */     this.program = GL20C.glCreateProgram();
/*    */ 
/*    */     
/* 31 */     this.vertexShader = new Shader(String.valueOf(shaderName) + ".vsh.glsl", 35633);
/* 32 */     this.fragmentShader = new Shader(String.valueOf(shaderName) + ".fsh.glsl", 35632);
/*    */ 
/*    */     
/* 35 */     GL20C.glAttachShader(this.program, this.vertexShader.getHandle());
/* 36 */     GL20C.glAttachShader(this.program, this.fragmentShader.getHandle());
/*    */     
/* 38 */     GL20C.glBindAttribLocation(this.program, 0, "vertexPosition");
/*    */     
/* 40 */     GL20C.glLinkProgram(this.program);
/* 41 */     if (GL20C.glGetProgrami(this.program, 35714) == 0) {
/*    */       
/* 43 */       System.err.println(GL20C.glGetProgramInfoLog(this.program));
/* 44 */       throw new AssertionError("Unable to create shader program");
/*    */     } 
/*    */     
/* 47 */     GL20C.glValidateProgram(this.program);
/* 48 */     if (GL20C.glGetProgrami(this.program, 35715) == 0) {
/*    */       
/* 50 */       System.err.println(GL20C.glGetProgramInfoLog(this.program));
/* 51 */       throw new AssertionError("Unable to create shader program");
/*    */     } 
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void bind() {
/* 59 */     GL20C.glUseProgram(this.program);
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void close() {
/* 67 */     GL20C.glDeleteProgram(this.program);
/*    */     
/* 69 */     this.vertexShader.close();
/* 70 */     this.fragmentShader.close();
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void unbind() {
/* 77 */     GL20C.glUseProgram(0);
/*    */   }
/*    */ }


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