Examples of GL2


Examples of javax.media.opengl.GL2

    }

    @Override
    public void display(GLAutoDrawable glDrawable) {
     
          final GL2 gl = glDrawable.getGL().getGL2();
         
          JOGLTarget.clearGL(gl, Color.BLACK);
         
          helpView.renderTo(gl, null, null);
         
          if (renderOptions.camera != null) {
           
            /* prepare projection matrix stack */
           
            //TODO: reactivate to allow
//            //calculate height for orthographic projection to match
//            //the height of the perspective view volume at lookAt's distance
//            double dist = renderOptions.camera.getLookAt().subtract(
//                renderOptions.camera.getPos())
//                .length();
//            double tanAngle = Math.tan(renderOptions.projection.getVertAngle());
//            double height = tanAngle * dist;
//            renderOptions.projection = renderOptions.projection.withVolumeHeight(height);
                       
            /* draw debug views */
           
            DebugView activeWorldObjectView = null;
           
            for (DebugView debugView : renderOptions.activeDebugViews) {
              if (debugView instanceof WorldObjectView) {
                // needs to be rendered last because of transparency
                activeWorldObjectView = debugView;
                continue;
              }
              debugView.renderTo(gl, renderOptions.camera, renderOptions.projection);
            }
           
            if (activeWorldObjectView != null) {
              activeWorldObjectView.renderTo(gl, renderOptions.camera, renderOptions.projection);
            }
           
            /* write messages */
           
            int messageCount = 0;
            for (Message message : messageManager.getLiveMessages()) {
              JOGLTarget.drawText(message.messageString,
                  10, 10 + messageCount * 20,
                  ViewerGLCanvas.this.getWidth(),
                  ViewerGLCanvas.this.getHeight(),
                  Color.WHITE);
              messageCount++;
            }
           
            gl.glFlush();

          }
     
    }
View Full Code Here

Examples of javax.media.opengl.GL2

     *
     * @param dc the current draw context.
     */
    protected void beginDrawing(DrawContext dc)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        int attrMask =
            GL2.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
                | GL2.GL_TRANSFORM_BIT // for modelview and perspective
                | GL2.GL_VIEWPORT_BIT // for depth range
                | GL2.GL_CURRENT_BIT // for current color
                | GL2.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
                | GL2.GL_DEPTH_BUFFER_BIT // for depth func
                | GL2.GL_ENABLE_BIT // for enable/disable changes
                | GL2.GL_HINT_BIT | GL2.GL_LINE_BIT; // for antialiasing and line attrs

        gl.glPushAttrib(attrMask);

        if (!dc.isPickingMode())
        {
            gl.glEnable(GL.GL_BLEND);
            OGLUtil.applyBlending(gl, false);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

     *
     * @param dc the current draw context.
     */
    protected void endDrawing(DrawContext dc)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
        gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
        gl.glPopAttrib();
    }
View Full Code Here

Examples of javax.media.opengl.GL2

            if (this.isDrawPoint(dc))
                this.drawPoint(dc, pickCandidates);
            return;
        }

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

        OGLStackHandler osh = new OGLStackHandler();
        try
        {
            if (dc.isPickingMode())
            {
                // Set up to replace the non-transparent texture colors with the single pick color.
                gl.glEnable(GL.GL_TEXTURE_2D);
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_COMBINE);
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, GL2.GL_PREVIOUS);
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, GL2.GL_REPLACE);

                Color pickColor = dc.getUniquePickColor();
                pickCandidates.addPickableObject(this.createPickedObject(dc, pickColor));
                gl.glColor3ub((byte) pickColor.getRed(), (byte) pickColor.getGreen(), (byte) pickColor.getBlue());
            }
            else
            {
                gl.glEnable(GL.GL_TEXTURE_2D);
                Color color = this.getActiveAttributes().getImageColor();
                if (color == null)
                    color = PointPlacemarkAttributes.DEFAULT_IMAGE_COLOR;
                gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(),
                    (byte) color.getAlpha());
            }

            // The image is drawn using a parallel projection.
            osh.pushProjectionIdentity(gl);
            gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d);

            // Apply the depth buffer but don't change it (for screen-space shapes).
            if ((!dc.isDeepPickingEnabled()))
                gl.glEnable(GL.GL_DEPTH_TEST);
            gl.glDepthMask(false);

            // Suppress any fully transparent image pixels.
            gl.glEnable(GL2.GL_ALPHA_TEST);
            gl.glAlphaFunc(GL2.GL_GREATER, 0.001f);

            // Adjust depth of image to bring it slightly forward
            double depth = screenPoint.z - (8d * 0.00048875809d);
            depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
            gl.glDepthFunc(GL.GL_LESS);
            gl.glDepthRange(depth, depth);

            // The image is drawn using a translated and scaled unit quad.
            // Translate to screen point and adjust to align hot spot.
            osh.pushModelviewIdentity(gl);
            gl.glTranslated(screenPoint.x + this.dx, screenPoint.y + this.dy, 0);

            // Compute the scale
            double xscale;
            Double scale = this.getActiveAttributes().getScale();
            if (scale != null)
                xscale = scale * this.activeTexture.getWidth(dc);
            else
                xscale = this.activeTexture.getWidth(dc);

            double yscale;
            if (scale != null)
                yscale = scale * this.activeTexture.getHeight(dc);
            else
                yscale = this.activeTexture.getHeight(dc);

            Double heading = getActiveAttributes().getHeading();
            Double pitch = getActiveAttributes().getPitch();

            // Adjust heading to be relative to globe or screen
            if (heading != null)
            {
                if (AVKey.RELATIVE_TO_GLOBE.equals(this.getActiveAttributes().getHeadingReference()))
                    heading = dc.getView().getHeading().degrees - heading;
                else
                    heading = -heading;
            }

            // Apply the heading and pitch if specified.
            if (heading != null || pitch != null)
            {
                gl.glTranslated(xscale / 2, yscale / 2, 0);
                if (pitch != null)
                    gl.glRotated(pitch, 1, 0, 0);
                if (heading != null)
                    gl.glRotated(heading, 0, 0, 1);
                gl.glTranslated(-xscale / 2, -yscale / 2, 0);
            }

            // Scale the unit quad
            gl.glScaled(xscale, yscale, 1);

            if (this.activeTexture.bind(dc))
                dc.drawUnitQuad(activeTexture.getTexCoords());

            gl.glDepthRange(0, 1); // reset depth range to the OGL default
//
//            gl.glDisable(GL.GL_TEXTURE_2D);
//            dc.drawUnitQuadOutline(); // for debugging label placement

            if (this.mustDrawLabel() && !dc.isPickingMode()) // don't pick via the label
                this.drawLabel(dc);
        }
        finally
        {
            if (dc.isPickingMode())
            {
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, OGLUtil.DEFAULT_TEX_ENV_MODE);
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, OGLUtil.DEFAULT_SRC0_RGB);
                gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, OGLUtil.DEFAULT_COMBINE_RGB);
            }

            gl.glDisable(GL.GL_TEXTURE_2D);
            osh.pop(gl);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

        double h = this.activeTexture != null ? this.activeTexture.getHeight(dc) : 1;
        Point.Double offset = os.computeOffset(w, h, imageScale, imageScale);
        x += offset.x;
        y += offset.y;

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

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

        Double labelScale = this.getActiveAttributes().getLabelScale();
        if (labelScale != null)
        {
            gl.glTranslatef(x, y, 0); // Assumes matrix mode is MODELVIEW
            gl.glScaled(labelScale, labelScale, 1);
            gl.glTranslatef(-x, -y, 0);
        }

        // Do not depth buffer the label. (Placemarks beyond the horizon are culled above.)
        gl.glDisable(GL.GL_DEPTH_TEST);
        gl.glDepthMask(false);

        TextRenderer textRenderer = OGLTextRenderer.getOrCreateTextRenderer(dc.getTextRendererCache(), font);
        try
        {
            textRenderer.begin3DRendering();
View Full Code Here

Examples of javax.media.opengl.GL2

     * @param dc             the current draw context.
     * @param pickCandidates the pick support object to use when adding this as a pick candidate.
     */
    protected void drawLine(DrawContext dc, PickSupport pickCandidates)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        if ((!dc.isDeepPickingEnabled()))
            gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);
        gl.glDepthMask(true);

        try
        {
            dc.getView().pushReferenceCenter(dc, this.placePoint); // draw relative to the place point

            this.setLineWidth(dc);
            this.setLineColor(dc, pickCandidates);

            gl.glBegin(GL2.GL_LINE_STRIP);
            gl.glVertex3d(Vec4.ZERO.x, Vec4.ZERO.y, Vec4.ZERO.z);
            gl.glVertex3d(this.terrainPoint.x - this.placePoint.x, this.terrainPoint.y - this.placePoint.y,
                this.terrainPoint.z - this.placePoint.z);
            gl.glEnd();
        }
        finally
        {
            dc.getView().popReferenceCenter(dc);
        }
View Full Code Here

Examples of javax.media.opengl.GL2

     * @param dc             the current draw context.
     * @param pickCandidates the pick support object to use when adding this as a pick candidate.
     */
    protected void drawPoint(DrawContext dc, PickSupport pickCandidates)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        OGLStackHandler osh = new OGLStackHandler();
        try
        {
            osh.pushAttrib(gl, GL2.GL_POINT_BIT);

            this.setLineColor(dc, pickCandidates);
            this.setPointSize(dc);

            // The point is drawn using a parallel projection.
            osh.pushProjectionIdentity(gl);
            gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d);

            osh.pushModelviewIdentity(gl);

            // Apply the depth buffer but don't change it (for screen-space shapes).
            if ((!dc.isDeepPickingEnabled()))
                gl.glEnable(GL.GL_DEPTH_TEST);
            gl.glDepthMask(false);

            // Suppress any fully transparent pixels.
            gl.glEnable(GL2.GL_ALPHA_TEST);
            gl.glAlphaFunc(GL2.GL_GREATER, 0.001f);

            // Adjust depth of point to bring it slightly forward
            double depth = this.screenPoint.z - (8d * 0.00048875809d);
            depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
            gl.glDepthFunc(GL.GL_LESS);
            gl.glDepthRange(depth, depth);

            gl.glBegin(GL2.GL_POINTS);
            gl.glVertex3d(this.screenPoint.x, this.screenPoint.y, 0);
            gl.glEnd();

            gl.glDepthRange(0, 1); // reset depth range to the OGL default

            if (!dc.isPickingMode()) // don't pick via the label
                this.drawLabel(dc);
        }
        finally
View Full Code Here

Examples of javax.media.opengl.GL2

     *
     * @param dc the current draw context.
     */
    protected void setPointSize(DrawContext dc)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        Double scale = this.getActiveAttributes().getScale();
        if (scale == null)
            scale = DEFAULT_POINT_SIZE;

        if (dc.isPickingMode())
            gl.glPointSize(scale.floatValue() + this.getLinePickWidth());
        else
            gl.glPointSize(scale.floatValue());

        if (!dc.isPickingMode())
        {
            gl.glEnable(GL2.GL_POINT_SMOOTH);
            gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

     * @param dc             the current draw context.
     * @param pickCandidates the pick support object to use when adding this as a pick candidate.
     */
    protected void setLineColor(DrawContext dc, PickSupport pickCandidates)
    {
        GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

        if (!dc.isPickingMode())
        {
            Color color = this.getActiveAttributes().getLineColor();
            if (color == null)
                color = PointPlacemarkAttributes.DEFAULT_LINE_COLOR;
            gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(),
                (byte) color.getAlpha());
        }
        else
        {
            Color pickColor = dc.getUniquePickColor();
            pickCandidates.addPickableObject(pickColor.getRGB(), this, this.getPosition());
            gl.glColor3ub((byte) pickColor.getRed(), (byte) pickColor.getGreen(), (byte) pickColor.getBlue());
        }
    }
View Full Code Here

Examples of javax.media.opengl.GL2

        // Setup the mask to modulate with the existing fragment color. This will have the effect of multiplying
        // the button depressed mask colors with the button colors.
        if (this.getPressedMaskTexture() == texture)
        {
            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
            gl.glEnable(GL.GL_BLEND);
            gl.glBlendFunc(GL.GL_ZERO, GL.GL_SRC_COLOR);
            gl.glColor4f(1f, 1f, 1f, 1f);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.