예제 #1
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();
  }
예제 #2
0
  private int loadShader(int type, final String shaderSource) {
    // Create the shader object
    int shader = glCreateShader(type);
    if (shader == 0) return 0;

    // Load the shader source
    glShaderSource(shader, shaderSource);

    // Compile the shader
    glCompileShader(shader);

    int compiled = glGetShader(shader, GL_COMPILE_STATUS);
    if (compiled == 0) { // Same as gfx.GL_FALSE
      log().error("Could not compile shader " + type + ":");
      log().error(glGetShaderInfoLog(shader, SHADER_INFO_LOG_LEN));
      glDeleteShader(shader);
      shader = 0;
    }

    return shader;
  }