protected void beginDrawAnnotations(DrawContext dc, OGLStackHandler stackHandler) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. int attributeMask = GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, blend func | GL2.GL_CURRENT_BIT // for current color | GL2.GL_DEPTH_BUFFER_BIT // for depth test, depth mask, depth func | GL2.GL_ENABLE_BIT // for enable/disable changes | GL2.GL_HINT_BIT // for line smoothing hint | GL2.GL_LINE_BIT // for line width, line stipple | GL2.GL_TRANSFORM_BIT // for matrix mode | GL2.GL_VIEWPORT_BIT; // for viewport, depth range stackHandler.pushAttrib(gl, attributeMask); // Load a parallel projection with dimensions (viewportWidth, viewportHeight) stackHandler.pushProjectionIdentity(gl); gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d); // Push identity matrices on the texture and modelview matrix stacks. Leave the matrix mode as modelview. stackHandler.pushTextureIdentity(gl); stackHandler.pushModelviewIdentity(gl); // Enable the alpha test. gl.glEnable(GL2.GL_ALPHA_TEST); gl.glAlphaFunc(GL2.GL_GREATER, 0.0f); // Apply the depth buffer but don't change it. if ((!dc.isDeepPickingEnabled())) { gl.glEnable(GL.GL_DEPTH_TEST); } gl.glDepthMask(false); // Disable lighting and backface culling. gl.glDisable(GL2.GL_LIGHTING); gl.glDisable(GL.GL_CULL_FACE); if (!dc.isPickingMode()) { // Enable blending in premultiplied color mode. gl.glEnable(GL.GL_BLEND); OGLUtil.applyBlending(gl, true); } else { this.pickSupport.beginPicking(dc); } }
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); }