/**
         * Causes this SurfaceObject to draw a representation of itself suitable for use during picking.
         *
         * @param dc the current DrawContext.
         */
        protected void drawPickRepresentation(DrawContext dc)
        {
            // The pick representation is stored as a list of surface tiles. If the list is empty, then this surface object
            // was not picked. This method might be called when the list is null or empty because of an upstream
            // exception that prevented creation of the list.
            if (this.pickTileBuilder == null || this.pickTileBuilder.getTileCount(dc) == 0)
            {
                return;
            }

            // Draw the pickable representation of this surface object created during preRendering.
            GL2             gl   = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushAttrib(gl, GL2.GL_POLYGON_BIT); // For cull face enable, cull face, polygon mode.
            try
            {
                gl.glEnable(GL.GL_CULL_FACE);
                gl.glCullFace(GL.GL_BACK);
                gl.glPolygonMode(GL2.GL_FRONT, GL2.GL_FILL);

                dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.pickTileBuilder.getTiles(dc));
            }
            finally
            {
                ogsh.pop(gl);
                // Clear the list of pick tiles to avoid retaining references to them in case we're never picked again.
                this.pickTileBuilder.clearTiles(dc);
            }
        }
Beispiel #2
0
        /**
         * Draw a vertex buffer with texture coordinates in a given gl mode. Vertex buffers coming from the
         * createShapeBuffer() methods support both <code>GL.GL_TRIANGLE_FAN</code> and <code>GL.LINE_STRIP</code>.
         *
         * @param dc     the current DrawContext.
         * @param mode   the desired drawing GL mode.
         * @param count  the number of vertices to draw.
         * @param verts  the vertex buffer to draw.
         * @param coords the buffer containing the shape texture coordinates.
         */
        public static void drawBuffer(DrawContext dc, int mode, int count, DoubleBuffer verts, DoubleBuffer coords)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            if (verts == null || coords == null)
            {
                String message = Logging.getMessage("nullValue.BufferIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            // Set up
            gl.glPushClientAttrib(GL2.GL_CLIENT_VERTEX_ARRAY_BIT);
            gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
            gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
            gl.glVertexPointer(2, GL2.GL_DOUBLE, 0, verts);
            gl.glTexCoordPointer(2, GL2.GL_DOUBLE, 0, coords);
            // Draw
            gl.glDrawArrays(mode, 0, count);
            // Restore
            gl.glPopClientAttrib();
        }
Beispiel #3
0
        /**
         * Causes this <code>Sphere</code> to render itself using the <code>DrawContext</code> provided. <code>dc</code> may
         * not be null.
         *
         * @param dc the <code>DrawContext</code> to be used
         *
         * @throws ArgumentException if <code>dc</code> is null
         */
        public void render(DrawContext dc)
        {
            if (dc == null)
            {
                String msg = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT);

            gl.glMatrixMode(GL2.GL_MODELVIEW);
            gl.glPushMatrix();
            gl.glTranslated(this.center.x, this.center.y, this.center.z);
            GLUquadric quadric = dc.getGLU().gluNewQuadric();

            dc.getGLU().gluQuadricDrawStyle(quadric, GLU.GLU_LINE);
            dc.getGLU().gluSphere(quadric, this.radius, 10, 10);
            gl.glPopMatrix();
            dc.getGLU().gluDeleteQuadric(quadric);

            gl.glPopAttrib();
        }
 public void pushModelviewIdentity(GL2 gl)
 {
     gl.MatrixMode(GL2.GL_MODELVIEW);
     this.modelviewPushed = true;
     gl.PushMatrix();
     gl.LoadIdentity();
 }
        public void applyInternalTransform(DrawContext dc)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new IllegalStateException(message);
            }

            Texture texture = this.getTexture(dc);

            if (texture == null)
            {
                texture = this.requestTexture(dc);
            }

            if (texture == null)
            {
                return;
            }

            if (texture.getMustFlipVertically())
            {
                GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
                gl.glMatrixMode(GL2.GL_TEXTURE);
                gl.glLoadIdentity();
                gl.glScaled(1, -1, 1);
                gl.glTranslated(0, -1, 0);
            }
        }
Beispiel #6
0
        /**
         * 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);
            }
        }
Beispiel #7
0
        public void applyInternalTransform(DrawContext dc)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new IllegalStateException(message);
            }

            // Use the tile's texture if available.
            Texture t = this.getTextureFromCache(dc);

            if (t == null)
            {
                t = this.initializeTexture(dc, this.imageSource);
            }

            if (t != null)
            {
                if (t.getMustFlipVertically())
                {
                    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
                    gl.glMatrixMode(GL2.GL_TEXTURE);
                    gl.glLoadIdentity();
                    gl.glScaled(1, -1, 1);
                    gl.glTranslated(0, -1, 0);
                }
            }
        }
Beispiel #8
0
        public void endLighting(DrawContext dc)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            this.lightingStackHandler.pop(gl);
            this.lightingStackHandler.clear();
        }
Beispiel #9
0
        /**
         * Sets the GL color state to the specified {@link java.awt.Color}, and with the specified color mode. If
         * <code>premultiplyColors</code> is true, this premultipies the Red, Green, and Blue color values by the Alpha
         * value. Otherwise, this does not modify the Red, Green, and Blue color values.
         *
         * @param gl                the GL context.
         * @param color             the Red, Green, Blue, and Alpha values to set.
         * @param premultiplyColors true to premultiply the Red, Green and Blue color values by the Alpha value, false to
         *                          leave the Red, Green, and Blue values unmodified.
         *
         * @throws ArgumentException if the GL is null, if the Color is null, if the opacity is less than 0, or if
         *                                  the opacity is greater than 1.
         */
        public static void applyColor(GL2 gl, java.awt.Color color, bool premultiplyColors)
        {
            if (gl == null)
            {
                String message = Logging.getMessage("nullValue.GLIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (color == null)
            {
                String message = Logging.getMessage("nullValue.ColorIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            float[] compArray = new float[4];
            color.getRGBComponents(compArray);

            if (premultiplyColors)
            {
                compArray[0] *= compArray[3];
                compArray[1] *= compArray[3];
                compArray[2] *= compArray[3];
            }

            gl.glColor4fv(compArray, 0);
        }
Beispiel #10
0
        /**
         * Sets the GL lighting state to a white light originating from the eye position and pointed in the specified
         * direction, in model coordinates. The light direction is always relative to the current eye point and viewer
         * direction. If the direction is null, this the light direction defaults to (0, 0, -1), which points directly along
         * the forward vector form the eye point
         *
         * @param gl        the GL context.
         * @param light     the GL light name to set.
         * @param direction the light direction in model coordinates, may be null.
         *
         * @throws ArgumentException if the GL is null.
         */
        public static void applyLightingDirectionalFromViewer(GL2 gl, int light, Vec4 direction)
        {
            if (gl == null)
            {
                String message = Logging.getMessage("nullValue.GLIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (direction == null)
            {
                direction = DEFAULT_LIGHT_DIRECTION;
            }

            float[] ambient  = { 1f, 1f, 1f, 0f };
            float[] diffuse  = { 1f, 1f, 1f, 0f };
            float[] specular = { 1f, 1f, 1f, 0f };
            float[] position = { (float)direction.x, (float)direction.y, (float)direction.z, 0.0f };

            gl.glLightfv(light, GL2.GL_AMBIENT, ambient, 0);
            gl.glLightfv(light, GL2.GL_DIFFUSE, diffuse, 0);
            gl.glLightfv(light, GL2.GL_SPECULAR, specular, 0);

            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushModelviewIdentity(gl);
            try
            {
                gl.glLightfv(light, GL2.GL_POSITION, position, 0);
            }
            finally
            {
                ogsh.pop(gl);
            }
        }
        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;
            }
        }
 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();
 }
Beispiel #14
0
        /**
         * Flushes any buffered pixel values to the appropriate texure targets, then restores the GL state to its previous
         * configuration before {@link #beginRendering(gov.nasa.worldwind.render.DrawContext, int, int, int, int)} was
         * called. Finally, all texture targets associated with this OGLRenderToTextureSupport are unbound.
         *
         * @param dc the current DrawContext.
         *
         * @throws ArgumentException if the DrawContext is null.
         */
        public void endRendering(DrawContext dc)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            this.flush(dc);

            if (this.useFramebufferObject(dc))
            {
                if (this.colorTarget != null)
                {
                    this.bindFramebufferColorAttachment(dc, null);
                }

                this.endFramebufferObjectRendering(dc);
            }

            this.stackHandler.pop(gl);
            this.drawRegion  = null;
            this.colorTarget = null;
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        public void endPicking(DrawContext dc)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glPopAttrib();

            // Some nvidia Quadro cards have a bug in which the current color is not restored. Restore it to the
            // default here.
            gl.glColor3ub((byte)255, (byte)255, (byte)255);
        }
        /**
         * Creates a new {@link javax.media.opengl.glu.GLUtessellatorCallback} that draws tessellated polygons as OpenGL
         * primitives by calling glBegin, glEnd, and glVertex.
         *
         * @param gl the GL context to draw into.
         *
         * @return a new GLUtessellatorCallback for drawing tessellated polygons as OpenGL primtives.
         *
         * @throws ArgumentException if the GL is null.
         */
        public static GLUtessellatorCallback createOGLDrawPrimitivesCallback(GL2 gl)
        {
            if (gl == null)
            {
                String message = Logging.getMessage("nullValue.GLIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(new OGLDrawPrimitivesCallback(gl));
        }
Beispiel #18
0
        protected void drawOutline(DrawContext dc, Vec4 a, Vec4 b, Vec4 c, Vec4 d)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glBegin(GL2.GL_LINE_LOOP);
            gl.glVertex3d(a.x, a.y, a.z);
            gl.glVertex3d(b.x, b.y, b.z);
            gl.glVertex3d(c.x, c.y, c.z);
            gl.glVertex3d(d.x, d.y, d.z);
            gl.glEnd();
        }
        protected void endDrawAnnotations(DrawContext dc, OGLStackHandler stackHandler)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            if (dc.isPickingMode())
            {
                this.pickSupport.endPicking(dc);
            }

            stackHandler.pop(gl);
        }
            public OGLDrawPrimitivesCallback(GL2 gl)
            {
                if (gl == null)
                {
                    String message = Logging.getMessage("nullValue.GLIsNull");
                    Logging.logger().severe(message);
                    throw new ArgumentException(message);
                }

                this.gl = gl;
            }
Beispiel #21
0
        /**
         * Detects the locations of the sector geometries in this list that intersect a specified screen point.
         * <p/>
         * Note: Prior to calling this method, {@link #beginRendering(gov.nasa.worldwind.render.DrawContext)} must be
         * called.
         *
         * @param dc        the current draw context.
         * @param pickPoint the screen point to test.
         */
        public void pick(DrawContext dc, java.awt.Point pickPoint)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new IllegalStateException(message);
            }

            if (pickPoint == null)
            {
                return;
            }

            this.pickSupport.clearPickList();
            this.pickSupport.beginPicking(dc);

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glShadeModel(GL2.GL_FLAT);

            try
            {
                // render each sector in unique color
                this.beginRendering(dc);
                foreach (SectorGeometry sector in this)
                {
                    Color color = dc.getUniquePickColor();
                    gl.glColor3ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue());
                    sector.render(dc);
                    // lat/lon/elevation not used in this case
                    this.pickSupport.addPickableObject(color.getRGB(), sector, Position.ZERO, true);
                }

                PickedObject pickedSector = this.pickSupport.getTopObject(dc, pickPoint);
                if (pickedSector == null || pickedSector.getObject() == null)
                {
                    return; // no sector picked
                }
                this.beginSectorGeometryPicking(dc);
                SectorGeometry sector = (SectorGeometry)pickedSector.getObject();
                sector.pick(dc, pickPoint);
            }
            finally
            {
                this.endSectorGeometryPicking(dc);
                this.endRendering(dc);
                gl.glShadeModel(GL2.GL_SMOOTH); // restore to default explicitly to avoid more expensive pushAttrib

                this.pickSupport.endPicking(dc);
                this.pickSupport.clearPickList();
            }
        }
Beispiel #22
0
        protected void apply(DrawContext dc)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glEnable(GL2.GL_LIGHTING);
            applyStandardLightModel(gl);
            applyStandardShadeModel(gl);

            gl.glEnable(GL2.GL_LIGHT0);
            applyStandardLightMaterial(gl, GL2.GL_LIGHT0, this.lightMaterial);
            applyStandardLightDirection(gl, GL2.GL_LIGHT0, this.lightDirection);
        }
Beispiel #23
0
        public void beginLighting(DrawContext dc)
        {
            if (this.lightingStackHandler.isActive())
            {
                return;                   // lighting is already enabled
            }
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            this.lightingStackHandler.pushAttrib(gl, GL2.GL_LIGHTING_BIT);

            this.apply(dc);
        }
        public void endDrawAnnotations(DrawContext dc)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            this.stackHandler.pop(gl);
        }
Beispiel #25
0
        protected void applyStandardLightModel(GL2 gl)
        {
            float[] modelAmbient = new float[4];
            modelAmbient[0] = 1.0f;
            modelAmbient[1] = 1.0f;
            modelAmbient[2] = 1.0f;
            modelAmbient[3] = 0.0f;

            gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, modelAmbient, 0);
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2.GL_TRUE);
//        gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, GL2.GL_FALSE);
            gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, GL2.GL_TRUE);
        }
        //**************************************************************//
        //********************  Diagnostic Support  ********************//
        //**************************************************************//

        /**
         * Causes this SurfaceObject to render its bounding sectors to the specified region in geographic coordinates. The
         * specified viewport denotes the geographic region and its corresponding screen viewport.
         * <p/>
         * The bounding sectors are rendered as a 1 pixel wide green outline.
         *
         * @param dc  the current DrawContext.
         * @param sdc the context containing a geographic region and screen viewport corresponding to a surface tile.
         *
         * @see #getSectors(DrawContext)
         */
        protected void drawBoundingSectors(DrawContext dc, SurfaceTileDrawContext sdc)
        {
            List <Sector> sectors = this.getSectors(dc);

            if (sectors == null)
            {
                return;
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            int attributeMask =
                GL2.GL_COLOR_BUFFER_BIT // For alpha test enable, blend enable, alpha func, blend func.
                | GL2.GL_CURRENT_BIT    // For current color.
                | GL2.GL_LINE_BIT;      // For line smooth, line width.

            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushAttrib(gl, attributeMask);
            ogsh.pushModelview(gl);
            try
            {
                gl.glEnable(GL.GL_BLEND);
                OGLUtil.applyBlending(gl, false);

                gl.glDisable(GL.GL_LINE_SMOOTH);
                gl.glLineWidth(1f);

                gl.glColor4f(1f, 1f, 1f, 0.5f);

                // Set the model-view matrix to transform from geographic coordinates to viewport coordinates.
                Matrix matrix = sdc.getModelviewMatrix();
                gl.glMultMatrixd(matrix.toArray(new double[16], 0, false), 0);

                foreach (Sector s in sectors)
                {
                    LatLon[] corners = s.getCorners();
                    gl.glBegin(GL2.GL_LINE_LOOP);
                    gl.glVertex2f((float)corners[0].getLongitude().degrees, (float)corners[0].getLatitude().degrees);
                    gl.glVertex2f((float)corners[1].getLongitude().degrees, (float)corners[1].getLatitude().degrees);
                    gl.glVertex2f((float)corners[2].getLongitude().degrees, (float)corners[2].getLatitude().degrees);
                    gl.glVertex2f((float)corners[3].getLongitude().degrees, (float)corners[3].getLatitude().degrees);
                    gl.glEnd();
                }
            }
            finally
            {
                ogsh.pop(gl);
            }
        }
Beispiel #27
0
        protected void finalizeFrame(DrawContext dc)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glMatrixMode(GL2.GL_MODELVIEW);
            gl.glPopMatrix();

            gl.glMatrixMode(GL2.GL_PROJECTION);
            gl.glPopMatrix();

            gl.glPopAttrib();

//        checkGLErrors(dc);
        }
        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);
            }
        }
Beispiel #29
0
        public void apply(GL2 gl, int face)
        {
            if (gl == null)
            {
                String msg = Logging.getMessage("nullValue.GLIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            glMaterial(gl, face, GL2.GL_AMBIENT, this.ambient);
            glMaterial(gl, face, GL2.GL_DIFFUSE, this.diffuse);
            glMaterial(gl, face, GL2.GL_SPECULAR, this.specular);
            glMaterial(gl, face, GL2.GL_EMISSION, this.emission);
            gl.glMaterialf(face, GL2.GL_SHININESS, (float)this.shininess);
        }
Beispiel #30
0
        /**
         * Implement no stereo ("Mono") while using a stereo device.
         * <p/>
         * Note that this method draws the image twice, once to each of the left and right eye buffers, even when stereo is
         * not in effect. This is to prevent the stereo device from drawing blurred scenes.
         *
         * @param dc the current draw context.
         */
        protected void doDrawStereoNone(DrawContext dc)
        {
            // If running on a stereo device but want to draw a normal image, both buffers must be filled or the
            // display will be blurry.

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            gl.glDrawBuffer(GL2.GL_BACK_LEFT);
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            super.draw(dc);

            gl.glDrawBuffer(GL2.GL_BACK_RIGHT);
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            super.draw(dc);
        }