public void delete() {
   if (!deleted) {
     glDeleteBuffers(vboID);
     if (indices != null) glDeleteBuffers(indID);
     deleted = true;
   }
 }
  public void destroyOpenGL() {
    // Delete the shaders
    GL20.glUseProgram(0);
    GL20.glDetachShader(pId, vsId);
    GL20.glDetachShader(pId, fsId);

    GL20.glDeleteShader(vsId);
    GL20.glDeleteShader(fsId);
    GL20.glDeleteProgram(pId);

    // Select the VAO
    GL30.glBindVertexArray(vaoId);

    // Disable the VBO index from the VAO attributes list
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);

    // Delete the vertex VBO
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboId);

    // Delete the index VBO
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboiId);

    // Delete the VAO
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vaoId);

    Display.destroy();
  }
 private static void cleanUp() {
   glDeleteProgram(perPixelShaderProgram);
   glDeleteProgram(perVertexShaderProgram);
   glDeleteBuffers(vboVertexHandle);
   glDeleteBuffers(vboNormalHandle);
   Display.destroy();
 }
Exemplo n.º 4
0
  public void render() {
    if (((ViewerContainer3D) v.getContainer()).getPbuffer() != currentPbuffer) {
      for (int i = 0; i < vbo.length; i++) {
        vbo[i] = -1;
        selectedVbo[i] = -1;
      }
      currentPbuffer = ((ViewerContainer3D) v.getContainer()).getPbuffer();
    }

    for (int i = 0; i < tubes.length; i++) {
      if (hidden[i]) continue;

      int vbo;
      if (!selected[i]) {
        if (this.vbo[i] == -1) {
          Color c = colors[i];
          GL15.glDeleteBuffers(this.vbo[i]);
          this.vbo[i] = createTubeVbo(i, colors[i]);
        }
        vbo = this.vbo[i];
      } else {
        if (this.selectedVbo[i] == -1) {
          Color c = selectedColors[i];
          GL15.glDeleteBuffers(this.selectedVbo[i]);
          this.selectedVbo[i] = createTubeVbo(i, selectedColors[i]);
        }
        vbo = this.selectedVbo[i];
      }

      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);

      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
      GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);

      GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
      GL11.glEnable(GL11.GL_COLOR_MATERIAL);

      GL11.glColorPointer(3, GL11.GL_FLOAT, vertexStride, colorPointer);
      GL11.glVertexPointer(3, GL11.GL_FLOAT, vertexStride, vertexPointer);
      GL11.glNormalPointer(GL11.GL_FLOAT, vertexStride, normalPointer);

      GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, totalNumVerts[i]);

      GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
      GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
      GL11.glDisable(GL11.GL_COLOR_MATERIAL);

      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    }
  }
Exemplo n.º 5
0
 @Override
 public void delete() {
   for (int i = 0; i < bufferHandles.length; i++) {
     glDeleteBuffers(bufferHandles[i]);
     bufferHandles[i] = -1;
   }
 }
Exemplo n.º 6
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();
  }
Exemplo n.º 7
0
 public void cleanUP() {
   for (int vao : vaos) {
     GL30.glDeleteVertexArrays(vao);
   }
   for (int vbo : vbos) {
     GL15.glDeleteBuffers(vbo);
   }
   for (int texture : textures) {
     GL11.glDeleteTextures(texture);
   }
 }
Exemplo n.º 8
0
 @Override
 public void destroy() {
   checkCreated();
   // Unbind any bound buffer
   GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
   // Unbind and delete the indices buffer
   GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
   GL15.glDeleteBuffers(indicesBufferID);
   // Bind the vao for deletion
   GL30.glBindVertexArray(id);
   // Disable each attribute and delete its buffer
   for (int i = 0; i < attributeBufferIDs.length; i++) {
     GL20.glDisableVertexAttribArray(i);
     GL15.glDeleteBuffers(attributeBufferIDs[i]);
   }
   // Unbind the vao and delete it
   GL30.glBindVertexArray(0);
   GL30.glDeleteVertexArrays(id);
   super.destroy();
   // Check for errors
   LWJGLUtil.checkForGLError();
 }
Exemplo n.º 9
0
 public void glDeleteBuffers(int n, IntBuffer buffers) {
   GL15.glDeleteBuffers(buffers);
 }
Exemplo n.º 10
0
  public void delete() {

    glDeleteBuffers(vbo);
    glDeleteBuffers(ibo);
  }
Exemplo n.º 11
0
 /** @Info detruit le vbo */
 public void destroyVBO() {
   glDeleteBuffers(vboID);
 }
Exemplo n.º 12
0
 @Override
 protected void finalize() {
   glDeleteBuffers(m_id);
 }