public void dispose(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); if (null != texture) { texture.disable(); texture.destroy(gl); } if (null != textureData) { textureData.destroy(); } }
@Override public void dispose(final GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); if (null != texture) { texture.disable(gl); texture.destroy(gl); } if (null != textureData) { textureData.destroy(); } pmvMatrixUniform = null; pmvMatrix = null; st.destroy(gl); st = null; }
protected void destroy(Texture texture) { texture.destroy(g2d.getGLContext().getGL()); }
public void destroy(GL3 gl) { if (isInitialised) { texture.destroy(gl); isInitialised = false; } }
/** @param context */ public void create(IGLElementContext context, TablePerspective tablePerspective) { final GL gl = GLContext.getCurrentGL(); final int numberOfRecords = tablePerspective.getRecordPerspective().getVirtualArray().size(); final int numberOfDimensions = tablePerspective.getDimensionPerspective().getVirtualArray().size(); dimension = new Dimension(numberOfDimensions, numberOfRecords); if (numberOfDimensions <= 0 || numberOfRecords <= 0) { takeDown(); return; } final int maxSize = resolveMaxSize(gl); boolean needXTiling = numberOfDimensions > maxSize; boolean needYTiling = numberOfRecords > maxSize; // pool of old texture which we might wanna reuse final Deque<Texture> pool = new LinkedList<>(); for (Tile tile : tiles) { pool.add(tile.texture); } tiles.clear(); if (!needXTiling && !needYTiling) { // single tile FloatBuffer buffer = FloatBuffer.allocate(numberOfDimensions * numberOfRecords * 4); // w*h*rgba Rectangle tile = new Rectangle(0, 0, numberOfDimensions, numberOfRecords); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } else if (needXTiling && !needYTiling) { // tile in x direction only FloatBuffer buffer = FloatBuffer.allocate(maxSize * numberOfRecords * 4); // w*h*rgba // fill full int lastTile = numberOfDimensions - maxSize; for (int i = 0; i < lastTile; i += maxSize) { Rectangle tile = new Rectangle(i, 0, maxSize, numberOfRecords); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } { // create rest int remaining = numberOfDimensions % maxSize; Rectangle tile = new Rectangle(numberOfDimensions - remaining, 0, remaining, numberOfRecords); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } } else if (!needXTiling && needYTiling) { // tile in y direction only FloatBuffer buffer = FloatBuffer.allocate(numberOfDimensions * maxSize * 4); // w*h*rgba // fill full int lastTile = numberOfRecords - maxSize; for (int i = 0; i < lastTile; i += maxSize) { Rectangle tile = new Rectangle(0, i, numberOfDimensions, maxSize); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } { // create rest int remaining = numberOfRecords % maxSize; Rectangle tile = new Rectangle(0, numberOfRecords - remaining, numberOfDimensions, remaining); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } } else { // tile in both directions // tile in y direction only FloatBuffer buffer = FloatBuffer.allocate(maxSize * maxSize * 4); // w*h*rgba // fill full int lastTileR = numberOfRecords - maxSize; int lastTileD = numberOfDimensions - maxSize; for (int i = 0; i < lastTileR; i += maxSize) { for (int j = 0; j < lastTileD; j += maxSize) { Rectangle tile = new Rectangle(j, i, maxSize, maxSize); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } { // create rest int remaining = numberOfDimensions % maxSize; Rectangle tile = new Rectangle(numberOfDimensions - remaining, i, remaining, maxSize); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } } { // last line int iremaining = numberOfRecords % maxSize; int i = numberOfRecords - iremaining; for (int j = 0; j < lastTileD; j += maxSize) { Rectangle tile = new Rectangle(j, i, maxSize, iremaining); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } { // create rest int remaining = numberOfDimensions % maxSize; Rectangle tile = new Rectangle(numberOfDimensions - remaining, i, remaining, iremaining); tiles.add(createTile(buffer, tile, gl, pool, tablePerspective)); } } } // free remaining elements in pool for (Texture tex : pool) tex.destroy(gl); pool.clear(); }