public void pop(GL2 gl) { if (this.attribsPushed) { gl.PopAttrib(); this.attribsPushed = false; } if (this.clientAttribsPushed) { gl.PopClientAttrib(); this.clientAttribsPushed = false; } if (this.modelviewPushed) { gl.MatrixMode(GL2.GL_MODELVIEW); gl.PopMatrix(); this.modelviewPushed = false; } if (this.projectionPushed) { gl.MatrixMode(GL2.GL_PROJECTION); gl.PopAttrib(); this.projectionPushed = false; } if (this.texturePushed) { gl.MatrixMode(GL2.GL_TEXTURE); gl.PopMatrix(); this.texturePushed = false; } }
/** * Removes the model-view matrix on top of the matrix stack, and restores the original matrix. * * @param dc the current World Wind drawing context on which the original matrix will be restored. * * @throws ArgumentException if <code>dc</code> is null, or if the <code>Globe</code> or <code>GL</code> * instances in <code>dc</code> are null. */ public void popReferenceCenter(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (dc.getGL() == null) { String message = Logging.getMessage("nullValue.DrawingContextGLIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. // Store the current matrix-mode state. OGLStackHandler ogsh = new OGLStackHandler(); try { ogsh.pushAttrib(gl, GL2.GL_TRANSFORM_BIT); gl.MatrixMode(GL2.GL_MODELVIEW); // Pop the top model-view matrix. gl.PopMatrix(); } finally { ogsh.pop(gl); } }
public void pushTextureIdentity(GL2 gl) { gl.MatrixMode(GL2.GL_TEXTURE); this.texturePushed = true; gl.PushMatrix(); gl.LoadIdentity(); }
public void pushProjectionIdentity(GL2 gl) { gl.MatrixMode(GL2.GL_PROJECTION); this.projectionPushed = true; gl.PushMatrix(); gl.LoadIdentity(); }
public void pushModelviewIdentity(GL2 gl) { gl.MatrixMode(GL2.GL_MODELVIEW); this.modelviewPushed = true; gl.PushMatrix(); gl.LoadIdentity(); }
public Matrix pushReferenceCenter(DrawContext dc, Vec4 referenceCenter) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (dc.getGL() == null) { String message = Logging.getMessage("nullValue.DrawingContextGLIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (referenceCenter == null) { String message = Logging.getMessage("nullValue.PointIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } Matrix modelview = getModelviewMatrix(); // Compute a new model-view matrix with origin at referenceCenter. Matrix matrix = null; if (modelview != null) { matrix = modelview.multiply(Matrix.fromTranslation(referenceCenter)); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. // Store the current matrix-mode state. OGLStackHandler ogsh = new OGLStackHandler(); try { ogsh.pushAttrib(gl, GL2.GL_TRANSFORM_BIT); gl.MatrixMode(GL2.GL_MODELVIEW); // Push and load a new model-view matrix to the current OpenGL context held by 'dc'. gl.PushMatrix(); if (matrix != null) { double[] matrixArray = new double[16]; matrix.toArray(matrixArray, 0, false); gl.LoadMatrix(matrixArray); } } finally { ogsh.pop(gl); } return(matrix); }
public Matrix setReferenceCenter(DrawContext dc, Vec4 referenceCenter) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (dc.getGL() == null) { String message = Logging.getMessage("nullValue.DrawingContextGLIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (referenceCenter == null) { String message = Logging.getMessage("nullValue.PointIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } Matrix modelview = getModelviewMatrix(); // Compute a new model-view matrix with origin at referenceCenter. Matrix matrix = null; if (modelview != null) { matrix = modelview.multiply(Matrix.fromTranslation(referenceCenter)); } if (matrix == null) { return(null); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.MatrixMode(GL2.GL_MODELVIEW); double[] matrixArray = new double[16]; matrix.toArray(matrixArray, 0, false); gl.LoadMatrix(matrixArray); return(matrix); }
/** * Sets the the opengl modelview and projection matrices to the given matrices. * * @param dc the drawing context * @param modelview the modelview matrix * @param projection the projection matrix */ public static void loadGLViewState(DrawContext dc, Matrix modelview, Matrix projection) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (dc.getGL() == null) { String message = Logging.getMessage("nullValue.DrawingContextGLIsNull"); Logging.logger().severe(message); throw new IllegalStateException(message); } if (modelview == null) { Logging.logger().fine("nullValue.ModelViewIsNull"); } if (projection == null) { Logging.logger().fine("nullValue.ProjectionIsNull"); } double[] matrixArray = new double[16]; GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. // Store the current matrix-mode state. OGLStackHandler ogsh = new OGLStackHandler(); try { ogsh.pushAttrib(gl, GL2.GL_TRANSFORM_BIT); // Apply the model-view matrix to the current OpenGL context. gl.MatrixMode(GL2.GL_MODELVIEW); if (modelview != null) { modelview.toArray(matrixArray, 0, false); gl.LoadMatrix(matrixArray); } else { gl.LoadIdentity(); } // Apply the projection matrix to the current OpenGL context. gl.MatrixMode(GL2.GL_PROJECTION); if (projection != null) { projection.toArray(matrixArray, 0, false); gl.LoadMatrix(matrixArray); } else { gl.LoadIdentity(); } } finally { ogsh.pop(gl); } }
public void pushTexture(GL2 gl) { gl.MatrixMode(GL2.GL_TEXTURE); gl.PushMatrix(); this.texturePushed = true; }
public void pushProjection(GL2 gl) { gl.MatrixMode(GL2.GL_PROJECTION); gl.PushMatrix(); this.projectionPushed = true; }
public void pushModelview(GL2 gl) { gl.MatrixMode(GL2.GL_MODELVIEW); gl.PushMatrix(); this.modelviewPushed = true; }