public Box() { /* * create the shader program. If OK, create vertex * and fragment shaders */ shader = ARBShaderObjects.glCreateProgramObjectARB(); if (shader != 0) { vertShader = createVertShader("shaders/hello-gl.v.glsl"); fragShader = createFragShader("shaders/hello-gl.f.glsl"); // skyFragShader=createFragShader("shaders/sky-gl.f.glsl"); } else useShader = false; /* * if the vertex and fragment shaders setup sucessfully, * attach them to the shader program, link the sahder program * (into the GL context I suppose), and validate */ if (vertShader != 0 && fragShader != 0) { ARBShaderObjects.glAttachObjectARB(shader, vertShader); ARBShaderObjects.glAttachObjectARB(shader, fragShader); ARBShaderObjects.glLinkProgramARB(shader); ARBShaderObjects.glValidateProgramARB(shader); useShader = printLogInfo(shader, "attach"); } else useShader = false; }
private static int setupProgram(String vShaderPath, String fShaderPath) { int program = glCreateProgramObjectARB(); int vShader = 0; int fShader = 0; if (program != 0) { vShader = createVertShader(vShaderPath); fShader = createFragShader(fShaderPath); } if (vShader != 0 || fShader != 0) { if (vShader != 0) { glAttachObjectARB(program, vShader); } if (fShader != 0) { glAttachObjectARB(program, fShader); } if (entityAttrib >= 0) { glBindAttribLocationARB(program, entityAttrib, "mc_Entity"); } glLinkProgramARB(program); glValidateProgramARB(program); printLogInfo(program); } else if (program != 0) { glDeleteObjectARB(program); program = 0; } return program; }
public boolean initShader() { int vertShader = 0, fragShader = 0; try { vertShader = this.createShader("./shaders/screen.vert", ARBVertexShader.GL_VERTEX_SHADER_ARB); fragShader = this.createShader("./shaders/screen.frag", ARBFragmentShader.GL_FRAGMENT_SHADER_ARB); } catch (final Exception exc) { exc.printStackTrace(); return false; } finally { if ((vertShader == 0) || (fragShader == 0)) { return false; } } this.program = ARBShaderObjects.glCreateProgramObjectARB(); if (this.program == 0) { return false; } ARBShaderObjects.glAttachObjectARB(this.program, vertShader); ARBShaderObjects.glAttachObjectARB(this.program, fragShader); ARBShaderObjects.glLinkProgramARB(this.program); if (ARBShaderObjects.glGetObjectParameteriARB( this.program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { System.err.println(this.getLogInfo(this.program)); return false; } ARBShaderObjects.glValidateProgramARB(this.program); if (ARBShaderObjects.glGetObjectParameteriARB( this.program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { System.err.println(this.getLogInfo(this.program)); return false; } return true; }