Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
 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;
 }