protected bool generateTexture(DrawContext dc, int width, int height) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. OGLStackHandler ogsh = new OGLStackHandler(); Matrix geoToCartesian = this.computeGeographicToCartesianTransform(this.sector); try { ogsh.pushAttrib(gl, GL2.GL_COLOR_BUFFER_BIT | GL2.GL_ENABLE_BIT | GL2.GL_TRANSFORM_BIT | GL2.GL_VIEWPORT_BIT); // Fill the frame buffer with transparent black. gl.glClearColor(0f, 0f, 0f, 0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glDisable(GL.GL_BLEND); gl.glDisable(GL.GL_CULL_FACE); gl.glDisable(GL.GL_DEPTH_TEST); // Setup a viewport with the dimensions of the texture, and a projection matrix of dimension 2.0 (along // each axis) centered at the origin. Using a projection matrix with these dimensions ensures that incoming // vertices are rasterized without any rounding error. ogsh.pushProjectionIdentity(gl); gl.glViewport(0, 0, width, height); gl.glOrtho(-1d, 1d, -1d, 1d, -1d, 1d); ogsh.pushModelviewIdentity(gl); ogsh.pushTextureIdentity(gl); if (this.sourceTexture != null) { try { gl.glEnable(GL.GL_TEXTURE_2D); if (!this.sourceTexture.bind(dc)) { return(false); } this.sourceTexture.applyInternalTransform(dc); // Setup the texture to replace the fragment color at each pixel. gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); int tessellationDensity = this.getTessellationDensity(); this.drawQuad(dc, geoToCartesian, tessellationDensity, tessellationDensity); } finally { gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, OGLUtil.DEFAULT_TEX_ENV_MODE); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); } } } finally { ogsh.pop(gl); } return(true); }