Beispiel #1
0
  // Creates program object, attaches shaders, and links into pipeline
  protected int createProgram(String vertexSource, String fragmentSource) {
    // Load the vertex and fragment shaders
    int vertexShader = loadShader(GL_VERTEX_SHADER, vertexSource);
    int fragmentShader = loadShader(GL_FRAGMENT_SHADER, fragmentSource);
    // Create the program object
    int program = glCreateProgram();
    if (vertexShader == 0 || fragmentShader == 0 || program == 0) return 0;

    if (program != 0) {
      glAttachShader(program, vertexShader);
      ctx.checkGLError("createProgram Attaching vertex shader");
      glAttachShader(program, fragmentShader);
      ctx.checkGLError("createProgram Attaching fragment shader");
      glLinkProgram(program);

      int linkStatus = glGetProgram(program, GL_LINK_STATUS);
      if (linkStatus != GL_TRUE) {
        log().error("Could not link program: ");
        log().error(glGetProgramInfoLog(program, SHADER_INFO_LOG_LEN));
        glDeleteProgram(program);
        program = 0;
      }
    }
    return program;
  }
Beispiel #2
0
  private void cleanup() {
    CLCleaner memObjCleaner =
        new CLCleaner() {
          @Override
          public int release(long object) {
            return clReleaseMemObject(object);
          }
        };

    release(clTexture, memObjCleaner);
    release(clColorMap, memObjCleaner);

    release(
        clKernel,
        new CLCleaner() {
          @Override
          public int release(long object) {
            return clReleaseKernel(object);
          }
        });

    release(
        clProgram,
        new CLCleaner() {
          @Override
          public int release(long object) {
            return clReleaseProgram(object);
          }
        });

    release(
        clQueue,
        new CLCleaner() {
          @Override
          public int release(long object) {
            return clReleaseCommandQueue(object);
          }
        });

    release(
        clContext,
        new CLCleaner() {
          @Override
          public int release(long object) {
            return clReleaseContext(object);
          }
        });
    clContextCB.free();

    glDeleteProgram(glProgram);
    glDeleteShader(fsh);
    glDeleteShader(vsh);
    glDeleteBuffers(vbo);
    glDeleteVertexArrays(vao);

    if (debugProc != null) debugProc.free();
  }
 private static void cleanUp() {
   glDeleteProgram(shaderProgram);
   glDeleteBuffers(vboVertexHandle);
   glDeleteBuffers(vboNormalHandle);
   Display.destroy();
 }