⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drawcontextimpl.java

📁 world wind java sdk 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*Copyright (C) 2001, 2006 United States Governmentas represented by the Administrator of theNational Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.render;import com.sun.opengl.util.texture.TextureCoords;import gov.nasa.worldwind.*;import gov.nasa.worldwind.cache.TextureCache;import gov.nasa.worldwind.geom.*;import gov.nasa.worldwind.globes.*;import gov.nasa.worldwind.layers.LayerList;import gov.nasa.worldwind.layers.Layer;import gov.nasa.worldwind.pick.*;import gov.nasa.worldwind.util.*;import gov.nasa.worldwind.View;import gov.nasa.worldwind.terrain.*;import javax.media.opengl.*;import javax.media.opengl.glu.GLU;import java.awt.*;import java.util.*;import java.util.List;/** * @author Tom Gaskins * @version $Id: DrawContextImpl.java 9365 2009-03-13 22:41:43Z dcollins $ */public class DrawContextImpl extends WWObjectImpl implements DrawContext{    private long frameTimestamp;    private GLContext glContext;    private GLU glu = new GLU();    private View view;    private Model model;    private Globe globe;    private double verticalExaggeration = 1d;    private Sector visibleSector;    private SectorGeometryList surfaceGeometry;    private PickedObjectList pickedObjects = new PickedObjectList();    private int uniquePickNumber = 0;    private Color clearColor = new Color(0, 0, 0, 0);    private boolean isPickingMode = false;    private Point pickPoint = null;    private Point viewportCenterScreenPoint = null;    private Position viewportCenterPosition = null;    private Vec4 viewportCenterSurfacePoint = null;    private Vec4 viewportCenterGlobePoint = null;    private int numTextureUnits = -1;    private double maxTextureAnisotropy = -1.0;    private SurfaceTileRenderer geographicSurfaceTileRenderer = new GeographicSurfaceTileRenderer();    private AnnotationRenderer annotationRenderer = new BasicAnnotationRenderer();    private TextureCache textureCache;    private TextRendererCache textRendererCache;    private Set<String> perFrameStatisticsKeys;    private Collection<PerformanceStatistic> perFrameStatistics;    private SectorVisibilityTree visibleSectors;    private Layer currentLayer;    private static final String GL_EXT_TEXTURE_FILTER_ANISOTROPIC_STRING = "GL_EXT_texture_filter_anisotropic";    PriorityQueue<OrderedRenderable> orderedRenderables =        new PriorityQueue<OrderedRenderable>(100, new Comparator<OrderedRenderable>()        {            public int compare(OrderedRenderable orA, OrderedRenderable orB)            {                double eA = orA.getDistanceFromEye();                double eB = orB.getDistanceFromEye();                return eA > eB ? -1 : eA == eB ? 0 : 1;            }        });    /**     * Free internal resources held by this draw context. A GL context must be current when this method is called.     *     * @throws javax.media.opengl.GLException - If an OpenGL context is not current when this method is called.     */    public void dispose()    {        this.geographicSurfaceTileRenderer.dispose();    }    public final GL getGL()    {        return this.getGLContext().getGL();    }    public final GLU getGLU()    {        return this.glu;    }    public final GLContext getGLContext()    {        return this.glContext;    }    public final int getDrawableHeight()    {        return this.getGLDrawable().getHeight();    }    public final int getDrawableWidth()    {        return this.getGLDrawable().getWidth();    }    public final GLDrawable getGLDrawable()    {        return this.getGLContext().getGLDrawable();    }    public final void initialize(GLContext glContext)    {        if (glContext == null)        {            String message = Logging.getMessage("nullValue.GLContextIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.glContext = glContext;        this.visibleSector = null;        if (this.surfaceGeometry != null)            this.surfaceGeometry.clear();        this.surfaceGeometry = null;        this.pickedObjects.clear();        this.orderedRenderables.clear();        this.uniquePickNumber = 0;        if (this.numTextureUnits < 1)            this.numTextureUnits = queryMaxTextureUnits(glContext);        // Texture max anisotropy defaults to -1. A value less than 2.0 indicates that this graphics context does not        // support texture anisotropy.        if (this.maxTextureAnisotropy < 0)            this.maxTextureAnisotropy = queryMaxTextureAnisotropy(glContext);        this.currentLayer = null;    }    private static int queryMaxTextureUnits(GLContext glContext)    {        int[] mtu = new int[1];        glContext.getGL().glGetIntegerv(GL.GL_MAX_TEXTURE_UNITS, mtu, 0);        return mtu[0];    }    private static double queryMaxTextureAnisotropy(GLContext glContext)    {        // Documentation on the anisotropic texture filter is available at        // http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt                if (!glContext.getGL().isExtensionAvailable(GL_EXT_TEXTURE_FILTER_ANISOTROPIC_STRING))            return 0;        double[] mta = new double[1];        glContext.getGL().glGetDoublev(GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, mta, 0);        return mta[0];    }    public final void setModel(Model model)    {        this.model = model;        if (this.model == null)            return;        Globe g = this.model.getGlobe();        if (g != null)            this.globe = g;    }    public final Model getModel()    {        return this.model;    }    public final LayerList getLayers()    {        return this.model.getLayers();    }    public final Sector getVisibleSector()    {        return this.visibleSector;    }    public final void setVisibleSector(Sector s)    {        // don't check for null - it is possible that no globe is active, no view is active, no sectors visible, etc.        this.visibleSector = s;    }    public void setSurfaceGeometry(SectorGeometryList surfaceGeometry)    {        this.surfaceGeometry = surfaceGeometry;    }    public SectorGeometryList getSurfaceGeometry()    {        return surfaceGeometry;    }    public final Globe getGlobe()    {        return this.globe != null ? this.globe : this.model.getGlobe();    }    public final void setView(View view)    {        this.view = view;    }    public final View getView()    {        return this.view;    }    public final void setGLContext(GLContext glContext)    {        if (glContext == null)        {            String message = Logging.getMessage("nullValue.GLContextIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.glContext = glContext;    }    public final double getVerticalExaggeration()    {        return verticalExaggeration;    }    public final void setVerticalExaggeration(double verticalExaggeration)    {        this.verticalExaggeration = verticalExaggeration;    }    public TextureCache getTextureCache()    {        return textureCache;    }    public void setTextureCache(TextureCache textureCache)    {        if (textureCache == null)        {            String msg = Logging.getMessage("nullValue.TextureCacheIsNull");            Logging.logger().severe(msg);            throw new IllegalArgumentException(msg);        }        this.textureCache = textureCache;    }    public TextRendererCache getTextRendererCache()    {        return textRendererCache;    }    public void setTextRendererCache(TextRendererCache textRendererCache)    {        if (textRendererCache == null)        {            String msg = Logging.getMessage("nullValue.TextRendererCacheIsNull");            Logging.logger().severe(msg);            throw new IllegalArgumentException(msg);        }        this.textRendererCache = textRendererCache;    }    public AnnotationRenderer getAnnotationRenderer()    {        return annotationRenderer;    }    public void setAnnotationRenderer(AnnotationRenderer ar)    {        if (ar == null)        {            String msg = Logging.getMessage("nullValue.AnnotationRendererIsNull");            Logging.logger().severe(msg);            throw new IllegalArgumentException(msg);        }        annotationRenderer = ar;    }    public Point getPickPoint()    {        return pickPoint;    }    public void setPickPoint(Point pickPoint)    {        this.pickPoint = pickPoint;    }    public Point getViewportCenterScreenPoint()    {        return viewportCenterScreenPoint;    }    public void setViewportCenterScreenPoint(Point viewportCenterScreenPoint)    {        this.viewportCenterScreenPoint = viewportCenterScreenPoint;    }    public Position getViewportCenterPosition()    {        return viewportCenterPosition;    }    public void setViewportCenterPosition(Position viewportCenterPosition)    {        this.viewportCenterPosition = viewportCenterPosition;        this.viewportCenterGlobePoint = null;        this.viewportCenterSurfacePoint = null;        if (viewportCenterPosition != null)        {            if (this.getGlobe() != null)                this.viewportCenterGlobePoint = this.getGlobe().computePointFromPosition(                    this.viewportCenterPosition.getLatitude(), this.viewportCenterPosition.getLongitude(), 0d);            if (this.getSurfaceGeometry() != null)                this.viewportCenterSurfacePoint =                    this.getSurfaceGeometry().getSurfacePoint(this.viewportCenterPosition);        }    }    public Vec4 getViewportCenterSurfacePoint()    {        return viewportCenterSurfacePoint;    }    public Vec4 getViewportCenterGlobePoint()    {        return viewportCenterGlobePoint;    }    /**     * Add picked objects to the current list of picked objects.     *     * @param pickedObjects the list of picked objects to add     *     * @throws IllegalArgumentException if <code>pickedObjects is null</code>     */    public void addPickedObjects(PickedObjectList pickedObjects)    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -