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

📄 canvas3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    ArrayList displayListResourceFreeList = new ArrayList();    ArrayList textureIdResourceFreeList = new ArrayList();    // an unique bit to identify this canvas    int canvasBit = 0;    // an unique number to identify this canvas : ( canvasBit = 1 << canvasId)    int canvasId = 0;    // Indicates whether the canvasId has been allocated    private boolean canvasIdAlloc = false;        // Avoid using this as lock, it cause deadlock     Object cvLock = new Object();    Object evaluateLock = new Object();    Object dirtyMaskLock = new Object();    // Use by D3D when toggle between window/fullscreen mode.    // Note that in fullscreen mode, the width and height get    // by canvas is smaller than expected.    boolean fullScreenMode = false;    int fullscreenWidth;    int fullscreenHeight;    // For D3D, instead of using the same variable in Renderer,    // each canvas has to build its own displayList.    boolean needToRebuildDisplayList = false;    // Use by D3D when canvas resize/toggle in pure immediate mode    int reEvaluateCanvasCmd = 0;    // Read-only flag that indicates whether the following texture features    // are supported for this canvas.    static final int TEXTURE_3D			= 0x0001;    static final int TEXTURE_COLOR_TABLE	= 0x0002;    static final int TEXTURE_MULTI_TEXTURE	= 0x0004;    static final int TEXTURE_COMBINE		= 0x0008;    static final int TEXTURE_COMBINE_DOT3	= 0x0010;    static final int TEXTURE_COMBINE_SUBTRACT	= 0x0020;    static final int TEXTURE_REGISTER_COMBINERS	= 0x0040;    static final int TEXTURE_CUBE_MAP		= 0x0080;    static final int TEXTURE_SHARPEN		= 0x0100;    static final int TEXTURE_DETAIL		= 0x0200;    static final int TEXTURE_FILTER4		= 0x0400;    static final int TEXTURE_ANISOTROPIC_FILTER	= 0x0800;    static final int TEXTURE_LOD_RANGE		= 0x1000;    static final int TEXTURE_LOD_OFFSET		= 0x2000;    // Use by D3D to indicate using one pass Blend mode     // if Texture interpolation mode is support.    static final int TEXTURE_LERP               = 0x4000;    static final int TEXTURE_NON_POWER_OF_TWO	= 0x8000;    static final int TEXTURE_AUTO_MIPMAP_GENERATION = 0x10000;        int textureExtendedFeatures = 0;    // Extensions supported by the underlying canvas    //    // NOTE: we should remove EXT_BGR and EXT_ABGR when the imaging code is    // rewritten    static final int SUN_GLOBAL_ALPHA            = 0x1;    static final int EXT_ABGR                    = 0x2;    static final int EXT_BGR                     = 0x4;    static final int MULTISAMPLE                 = 0x8;    // The following 10 variables are set by the native    // createNewContext()/createQueryContext() methods    // Supported Extensions    int extensionsSupported = 0;    // Anisotropic Filter degree    float anisotropicDegreeMax = 1.0f;    // Texture Boundary Width Max    int   textureBoundaryWidthMax = 0;    boolean multiTexAccelerated = false;    // Max number of texture coordinate sets    int maxTexCoordSets = 1;    // Max number of fixed-function texture units    int maxTextureUnits = 1;    // Max number of fragment shader texture units    int maxTextureImageUnits = 0;    // Max number of vertex shader texture units    int maxVertexTextureImageUnits = 0;    // Max number of combined shader texture units    int maxCombinedTextureImageUnits = 0;        // Max number of vertex attrs (not counting coord, etc.)    int maxVertexAttrs = 0;    // End of variables set by createNewContext()/createQueryContext()    // The total available number of texture units used by either the    // fixed-function or programmable shader pipeline.    // This is computed as: max(maxTextureUnits, maxTextureImageUnits)    int maxAvailableTextureUnits;    // Texture Width, Height Max    int   textureWidthMax = 0;    int   textureHeightMax = 0;    // Texture3D Width, Heigh, Depth Max    int   texture3DWidthMax = -1;    int   texture3DHeightMax = -1;    int   texture3DDepthMax = -1;    // Cached position & size for CanvasViewCache.    // We don't want to call canvas.getxx method in Renderer    // since it will cause deadlock as removeNotify() need to get    // component lock of Canvas also and need to wait Renderer to    // finish before continue. So we invoke the method now in     // CanvasViewEventCatcher.    Point newPosition = new Point();    Dimension newSize = new Dimension();    // Remember OGL context resources to free    // before context is destroy.    // It is used when sharedCtx = false;    ArrayList textureIDResourceTable = new ArrayList(5);    // The following variables are used by the lazy download of    // states code to keep track of the set of current to be update bins    static final int LIGHTBIN_BIT	= 0x0;    static final int ENVIRONMENTSET_BIT	= 0x1;    static final int ATTRIBUTEBIN_BIT	= 0x2;    static final int TEXTUREBIN_BIT	= 0x3;    static final int RENDERMOLECULE_BIT	= 0x4;    static final int TRANSPARENCY_BIT	= 0x5;    static final int SHADERBIN_BIT	= 0x6;    // bitmask to specify if the corresponding "bin" needs to be updated    int stateUpdateMask = 0;       // the set of current "bins" that is to be updated, the stateUpdateMask    // specifies if each bin in this set is updated or not.    Object curStateToUpdate[] = new Object[7];    /**     * The list of lights that are currently being represented in the native     * graphics context.     */    LightRetained[] currentLights = null;    /**     * Flag to override RenderAttributes.depthBufferWriteEnable     */    boolean depthBufferWriteEnableOverride = false;    /**     * Flag to override RenderAttributes.depthBufferEnable     */    boolean depthBufferEnableOverride = false;    // current state of depthBufferWriteEnable    boolean depthBufferWriteEnable = true;    boolean vfPlanesValid = false;    // The event catcher for this canvas.    EventCatcher eventCatcher;    // The view event catcher for this canvas.    private CanvasViewEventCatcher canvasViewEventCatcher;    // The top-level parent window for this canvas.    private Window windowParent;    // Issue 458 - list of all parent containers for this canvas    // (includes top-level parent window)    private LinkedList<Container> containerParentList = new LinkedList<Container>();    // flag that indicates if light has changed    boolean lightChanged = false;    // resource control object    DrawingSurfaceObject drawingSurfaceObject;    // true if context is valid for rendering    boolean validCtx = false;    // true if canvas is valid for rendering    boolean validCanvas = false;    // true if ctx changed between render and swap. In this case    // cv.canvasDirty flag will not reset in Renderer.    // This case happen when GraphicsContext3D invoked doClear()    // and canvas removeNotify() called while Renderer is running    boolean ctxChanged = false;    // Default graphics configuration    private static GraphicsConfiguration defaultGcfg = null;    // Returns default graphics configuration if user passes null    // into the Canvas3D constructor    private static synchronized GraphicsConfiguration  defaultGraphicsConfiguration() {        if (defaultGcfg == null) {            GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();            defaultGcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().                getDefaultScreenDevice().getBestConfiguration(template);        }        return defaultGcfg;    }    // Returns true if this is a valid graphics configuration, obtained    // via a GraphicsConfigTemplate3D.    private static boolean isValidConfig(GraphicsConfiguration gconfig) {        // If this is a valid GraphicsConfiguration object, then it will        // be in the graphicsConfigTable        return graphicsConfigTable.containsKey(gconfig);    }    // Checks the given graphics configuration, and throws an exception if    // the config is null or invalid.    private static synchronized GraphicsConfiguration            checkForValidGraphicsConfig(GraphicsConfiguration gconfig, boolean offScreen) {        // Issue 266 - for backwards compatibility with legacy applications,        // we will accept a null GraphicsConfiguration for an on-screen Canvas3D        // only if the "allowNullGraphicsConfig" system property is set to true.        if (!offScreen && VirtualUniverse.mc.allowNullGraphicsConfig) {            if (gconfig == null) {                // Print out warning if Canvas3D is called with a                // null GraphicsConfiguration                System.err.println(J3dI18N.getString("Canvas3D7"));                System.err.println("    " + J3dI18N.getString("Canvas3D18"));                // Use a default graphics config                gconfig = defaultGraphicsConfiguration();            }        }        // Validate input graphics config        if (gconfig == null) {            throw new NullPointerException(J3dI18N.getString("Canvas3D19"));        } else if (!isValidConfig(gconfig)) {            throw new IllegalArgumentException(J3dI18N.getString("Canvas3D17"));        }        return gconfig;    }    // Return the actual graphics config that will be used to construct    // the AWT Canvas. This is permitted to be non-unique or null.    private static GraphicsConfiguration getGraphicsConfig(GraphicsConfiguration gconfig) {        return Pipeline.getPipeline().getGraphicsConfig(gconfig);    }    /**     * Constructs and initializes a new Canvas3D object that Java 3D     * can render into. The following Canvas3D attributes are initialized     * to default values as shown:     * <ul>     * left manual eye in image plate : (0.142, 0.135, 0.4572)<br>     * right manual eye in image plate : (0.208, 0.135, 0.4572)<br>     * stereo enable : true<br>     * double buffer enable : true<br>     * monoscopic view policy : View.CYCLOPEAN_EYE_VIEW<br>     * off-screen mode : false<br>     * off-screen buffer : null<br>     * off-screen location : (0,0)<br>     * </ul>     *     * @param graphicsConfiguration a valid GraphicsConfiguration object that     * will be used to create the canvas.  This object should not be null and     * should be created using a GraphicsConfigTemplate3D or the     * getPreferredConfiguration() method of the SimpleUniverse utility.  For     * backward compatibility with earlier versions of Java 3D, a null or     * default GraphicsConfiguration will still work when used to create a     * Canvas3D on the default screen, but an error message will be printed.     * A NullPointerException or IllegalArgumentException will be thrown in a     * subsequent release.     *     * @exception IllegalArgumentException if the specified     * GraphicsConfiguration does not support 3D rendering     */    public Canvas3D(GraphicsConfiguration graphicsConfiguration) {	this(null, checkForValidGraphicsConfig(graphicsConfiguration, false), false);    }    /**     * Constructs and initializes a new Canvas3D object that Java 3D     * can render into.     *     * @param graphicsConfiguration a valid GraphicsConfiguration object     * that will be used to create the canvas.  This must be created either     * with a GraphicsConfigTemplate3D or by using the     * getPreferredConfiguration() method of the SimpleUniverse utility.     *     * @param offScreen a flag that indicates whether this canvas is     * an off-screen 3D rendering canvas.  Note that if offScreen     * is set to true, this Canvas3D object cannot be used for normal     * rendering; it should not be added to any Container object.     *     * @exception NullPointerException if the GraphicsConfiguration     * is null.     *     * @exception IllegalArgumentException if the specified     * GraphicsConfiguration does not support 3D rendering     *     * @since Java 3D 1.2     */    public Canvas3D(GraphicsConfiguration graphicsConfiguration, boolean offScreen) {        this(null, checkForValidGraphicsConfig(graphicsConfiguration, offScreen), offScreen);    }    // Private constructor only called by the two public constructors after    // they have validated the graphics config (and possibly constructed a new    // default config).    // The graphics config must be valid, unique, and non-null.    private Canvas3D(Object dummyObj1,            GraphicsConfiguration graphicsConfiguration,            boolean offScreen) {        this(dummyObj1,                graphicsConfiguration,                getGraphicsConfig(graphicsConfiguration),                offScreen);    }    // Private constructor only called by the previous private constructor.    // The graphicsConfiguration parameter is used by Canvas3D to lookup the    // graphics device and graphics template. The graphicsConfiguration2    // parameter is generated by the Pipeline from graphicsConfiguration and    // is only used to initialize the java.awt.Canvas.    private Canvas3D(Object dummyObj1,            GraphicsConfiguration graphicsConfiguration,            GraphicsConfiguration graphicsConfiguration2,            boolean offScreen) {	super(graphicsConfiguration2);	this.offScreen = offScreen;	this.graphicsConfiguration = graphicsConfiguration;        // Issue 131: Set the autoOffScreen variable based on whether this        // canvas3d implements the AutoOffScreenCanvas3D tagging interface.        // Eventually, we may replace this with an actual API.        boolean autoOffScreenCanvas3D = false;        if (this instanceof com.sun.j3d.exp.swing.impl.AutoOffScreenCanvas3D) {            autoOffScreenCanvas3D = true;        }        // Throw an illegal argument exception if an on-screen canvas is tagged        // as an  auto-off-screen canvas        if (autoOffScreenCanvas3D && !offScreen) {            throw new IllegalArgumentException(J3dI18N.getString("Canvas3D25"));        }        // Issue 163 : Set dirty bits for both Renderer and RenderBin        cvDirtyMask[0] = VIEW_INFO_DIRTY;        cvDirtyMask[1] = VIEW_INFO_DIRTY;    	GraphicsConfigInfo gcInfo = graphicsConfigTable.get(graphicsConfiguration);        requestedStencilSize = gcInfo.getGraphicsConfigTemplate3D().getStencilSize();

⌨️ 快捷键说明

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