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

📄 mastercontrol.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		public Object run() {		    return System.getProperty(prop);		}   	    });    }    private static boolean getBooleanProperty(String prop,					      boolean defaultValue,					      String trueMsg,					      String falseMsg) {	boolean value = defaultValue;	String propValue = getProperty(prop);	if (propValue != null) {	    value = Boolean.valueOf(propValue).booleanValue();	    System.err.println("Java 3D: " + (value ? trueMsg : falseMsg));	}	return value;    }    private static boolean getBooleanProperty(String prop,					      boolean defaultValue,					      String msg) {	return getBooleanProperty(prop,				  defaultValue,				  (msg + " enabled"),				  (msg + " disabled"));    }    /**     * Method to create and initialize the rendering Pipeline object,     * and to load the native libraries needed by Java 3D. This is     * called by the static initializer in VirtualUniverse <i>before</i>     * the MasterControl object is created.     */    static void loadLibraries() {        assert !librariesLoaded;        // Get platform system properties        String osName = getProperty("os.name").toLowerCase();        String sunArchDataModel = getProperty("sun.arch.data.model");        // Set global flags based on platform architecture        isMacOs = osName != null && osName.startsWith("mac");        isWindowsOs = osName != null && osName.startsWith("windows");        boolean isWindowsVista = isWindowsOs && osName.indexOf("vista") != -1;        boolean is64Bit = (sunArchDataModel != null) && sunArchDataModel.equals("64");        // Issue 257: check to see if the sun.jnlp.applet.launcher property is set to true        String sunAppletLauncher = getProperty("sun.jnlp.applet.launcher");        appletLauncher = Boolean.valueOf(sunAppletLauncher);        if (isCoreLoggable(Level.CONFIG)) {            StringBuffer strBuf = new StringBuffer();            strBuf.append("MasterControl.loadLibraries()\n").                    append("    osName [lower-case] = \"").                    append(osName).                    append("\"").                    append(", sunArchDataModel = ").                    append(sunArchDataModel).                    append("\n").                    append("    is64Bit = ").                    append(is64Bit).                    append(", isWindowsOs = ").                    append(isWindowsOs).                    append(", isMacOs = ").                    append(isMacOs).                    append(", isWindowsVista = ").                    append(isWindowsVista);            getCoreLogger().config(strBuf.toString());        }        // Initialize the Pipeline object associated with the        // renderer specified by the "j3d.rend" system property.        //        // XXXX : We should consider adding support for a more flexible,        // dynamic selection scheme via an API call.        // Default rendering pipeline is the JOGL pipeline on MacOS and the        // native OpenGL pipeline on all other platforms.        Pipeline.Type pipelineType =                isMacOs ? Pipeline.Type.JOGL : Pipeline.Type.NATIVE_OGL;        final String rendStr = getProperty("j3d.rend");        boolean nativeOglRequested = false;        if (rendStr == null) {            // Use default pipeline        } else if (rendStr.equals("ogl") && !isMacOs) {            pipelineType = Pipeline.Type.NATIVE_OGL;            nativeOglRequested = true;        } else if (rendStr.equals("d3d") && isWindowsOs) {            pipelineType = Pipeline.Type.NATIVE_D3D;        } else if (rendStr.equals("jogl")) {            pipelineType = Pipeline.Type.JOGL;        } else if (rendStr.equals("noop")) {            pipelineType = Pipeline.Type.NOOP;        } else {            System.err.println("Java 3D: Unrecognized renderer: " + rendStr);            // Use default pipeline        }        // Issue 452 : if we are on 32-bit Windows, then check whether we        // can and should use OpenGL. Note that we can't do this on 64-bit        // Windows until we have a 64-bit D3D pipeline.        if (isWindowsOs && !is64Bit && pipelineType == Pipeline.Type.NATIVE_OGL) {            if (!Pipeline.useNativeOgl(isWindowsVista, nativeOglRequested)) {                pipelineType = Pipeline.Type.NATIVE_D3D;            }        }        // Construct the singleton Pipeline instance        Pipeline.createPipeline(pipelineType);        // Get the global j3d.shadingLanguage system property        final String slStr = getProperty("j3d.shadingLanguage");        if (slStr != null) {            boolean found = false;            if (slStr.equals("GLSL")) {                globalShadingLanguage = Shader.SHADING_LANGUAGE_GLSL;                found = true;            } else if (slStr.equals("Cg")) {                globalShadingLanguage = Shader.SHADING_LANGUAGE_CG;                found = true;            }            if (found) {                System.err.println("Java 3D: Setting global shading language to " + slStr);            } else {                System.err.println("Java 3D: Unrecognized shading language: " + slStr);            }        }        // Load all required libraries        Pipeline.getPipeline().loadLibraries(globalShadingLanguage);        // Check whether the Cg library is available        if (globalShadingLanguage == Shader.SHADING_LANGUAGE_CG) {            cgLibraryAvailable = Pipeline.getPipeline().isCgLibraryAvailable();        }        // Check whether the GLSL library is available        if (globalShadingLanguage == Shader.SHADING_LANGUAGE_GLSL) {            glslLibraryAvailable = Pipeline.getPipeline().isGLSLLibraryAvailable();        }        assert !(glslLibraryAvailable && cgLibraryAvailable) :            "ERROR: cannot support both GLSL and CG at the same time";        librariesLoaded = true;    }    /**     * Invoke from InputDeviceScheduler to create an     * InputDeviceBlockingThread.      */    InputDeviceBlockingThread getInputDeviceBlockingThread(					   final InputDevice device) {	return (InputDeviceBlockingThread)	    java.security.AccessController.doPrivileged(		 new java.security.PrivilegedAction() {                     public Object run() {			 synchronized (rootThreadGroup) {			     Thread thread = new InputDeviceBlockingThread(				 	    rootThreadGroup, device);			     thread.setPriority(threadPriority);			     return thread;			 }		     }		 }        );    }    /**     * Set thread priority to all threads under Java3D thread group.     */    void setThreadPriority(final int pri) {	synchronized (rootThreadGroup) {	    threadPriority = pri;	    java.security.AccessController.doPrivileged(                new java.security.PrivilegedAction() {                    public Object run() {			Thread list[] = new			    Thread[rootThreadGroup.activeCount()];			int count = rootThreadGroup.enumerate(list);			for (int i=count-1; i >=0; i--) {			    list[i].setPriority(pri);			}			return null;		    }	    });	}    }    /**     * Return Java3D thread priority     */    int getThreadPriority() {	return threadPriority;    }    /**     * This returns the a unused renderer bit     */    int getRendererBit() {        return (1 << rendererCount++);    }    /**     * This returns the a unused renderer bit     */    int getRendererId() {        return rendererCount++;    }    /**     * This returns a context creation time stamp     * Note: this has to be called under the contextCreationLock     */    long getContextTimeStamp() {	return (++contextTimeStamp);    }    /**     * This returns the a unused displayListId     */    Integer getDisplayListId() {        return (Integer) FreeListManager.getObject(FreeListManager.DISPLAYLIST);    }    void freeDisplayListId(Integer id) {	FreeListManager.freeObject(FreeListManager.DISPLAYLIST, id);    }    /**     * This returns the a unused textureId     */    int getTexture2DId() {	// MasterControl has to handle the ID itself.  2D and 3D ideas must	// never be the same, so the counter has to be in the MasterControl	MemoryFreeList textureIds =	    FreeListManager.getFreeList(FreeListManager.TEXTURE2D);	int id;	synchronized (textureIdLock) {	    if (textureIds.size() > 0) {		id = ((Integer)FreeListManager.			getObject(FreeListManager.TEXTURE2D)).intValue();	    } else {		id = (++textureIdCount);	    }            return id;	}    }    int getTexture3DId() {	// MasterControl has to handle the ID itself.  2D and 3D ideas must	// never be the same, so the counter has to be in the MasterControl	MemoryFreeList textureIds =	    FreeListManager.getFreeList(FreeListManager.TEXTURE3D);	synchronized (textureIdLock) {	    if (textureIds.size > 0) {		return ((Integer)FreeListManager.			getObject(FreeListManager.TEXTURE3D)).intValue();	    }	    else return (++textureIdCount);	}    }    void freeTexture2DId(int id) {	FreeListManager.freeObject(FreeListManager.TEXTURE2D, new Integer(id));    }    void freeTexture3DId(int id) {	FreeListManager.freeObject(FreeListManager.TEXTURE3D, new Integer(id));    }    int getCanvasId() {        int i;	synchronized(canvasIdLock) {	    // Master control need to keep count itself        	    for(i=canvasFreeIndex; i<canvasIds.length; i++) {		if(canvasIds[i] == false)		    break;	    }	    if (i >= canvasIds.length) {                throw new RuntimeException("Cannot render to more than 32 Canvas3Ds");	    }	    canvasIds[i] = true;	    canvasFreeIndex = i + 1;	}        return i;            }    void freeCanvasId(int canvasId) {        // Valid range is [0, 31]	synchronized(canvasIdLock) {	    canvasIds[canvasId] = false;	    if(canvasFreeIndex > canvasId) {		canvasFreeIndex = canvasId;	    }	}    }    /**     * Create a Renderer if it is not already done so.     * This is used for GraphicsConfigTemplate3D passing      * graphics call to RequestRenderer, and for creating     * an off-screen buffer for an off-screen Canvas3D.     */    private Renderer createRenderer(GraphicsConfiguration gc) {	final GraphicsDevice gd = gc.getDevice();	Renderer rdr = (Renderer) Screen3D.deviceRendererMap.get(gd);	if (rdr != null) {	    return rdr;	}	java.security.AccessController.doPrivileged(	     new java.security.PrivilegedAction() {                    public Object run() {			Renderer r;		        synchronized (rootThreadGroup) {			    r = new Renderer(rootThreadGroup);			    r.initialize();			    r.setPriority(threadPriority);			    Screen3D.deviceRendererMap.put(gd, r);			}			return null;		   }	});	threadListsChanged = true;	return (Renderer) Screen3D.deviceRendererMap.get(gd);    }    /**     * Post the request in queue     */    void postRequest(Integer type, Object obj) {	synchronized (mcThreadLock) {	    synchronized (requestObjList) {		if (mcThread == null) {		    if ((type == ACTIVATE_VIEW) || 			(type == GETBESTCONFIG) ||			(type == SET_VIEW) ||			(type == ISCONFIGSUPPORT) ||			(type == SET_QUERYPROPERTIES) ||			(type == SET_GRAPHICSCONFIG_FEATURES)) {			createMasterControlThread();			requestObjList.add(obj);			requestTypeList.add(type);			pendingRequest = true;		    } else if (type == EMPTY_UNIVERSE) {			destroyUniverseThreads((VirtualUniverse) obj);		    } else if (type == STOP_VIEW) {			View v = (View) obj;			v.stopViewCount = -1;			v.isRunning = false;		    } else if (type == STOP_RENDERER) {			if (obj instanceof Canvas3D) {			    ((Canvas3D) obj).isRunningStatus = false;			} else {			    ((Renderer) obj).userStop = true;			}		    } else if (type == UNREGISTER_VIEW) {			((View) obj).doneUnregister = true;		    } else {			requestObjList.add(obj);			requestTypeList.add(type);			pendingRequest = true;		    }		} else {		    requestObjList.add(obj);		    requestTypeList.add(type);		    pendingRequest = true;		}	    }	}	setWork();    }    /**     * This procedure is invoked when isRunning is false.       * Return true when there is no more pending request so that      * Thread can terminate. Otherwise we have to recreate     * the MC related threads.     */    boolean mcThreadDone() {

⌨️ 快捷键说明

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