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

📄 pipeline.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * $RCSfile: Pipeline.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.10 $ * $Date: 2007/05/29 23:18:14 $ * $State: Exp $ */package javax.media.j3d;import java.awt.GraphicsConfiguration;import java.awt.GraphicsDevice;/** * Abstract pipeline class for rendering pipeline methods. All rendering * pipeline methods are defined here. */abstract class Pipeline {    // Supported rendering pipelines    enum Type {        // Native rendering pipelines using OGL or D3D library        NATIVE_OGL,        NATIVE_D3D,                // Java rendering pipeline using Java Bindings for OpenGL        JOGL,        // No-op rendering pipeline        NOOP,    }    private static final String CLASSNAME_NATIVE = "javax.media.j3d.NativePipeline";    private static final String CLASSNAME_JOGL = "javax.media.j3d.JoglPipeline";    private static final String CLASSNAME_NOOP = "javax.media.j3d.NoopPipeline";    // Singleton pipeline instance    private static Pipeline pipeline;    // Type of rendering pipeline (as defined above)    private Type pipelineType = null;    /**     * An instance of a specific Pipeline subclass should only be constructed     * // from the createPipeline method.     */    protected Pipeline() {    }    /**     * Method to check whether the native OpenGL library can and should be used     * on Windows. We will use D3D if OpenGL is unavailable or undesirable.     */    static boolean useNativeOgl(boolean isWindowsVista, boolean nativeOglRequested) {        // Get the OpenGL vendor string.        String vendorString;        try {            vendorString = NativePipeline.getSupportedOglVendor();        } catch (Exception ex) {            MasterControl.getCoreLogger().severe(ex.toString());            return false;        } catch (Error ex) {            MasterControl.getCoreLogger().severe(ex.toString());            return false;        }        // A null vendor string means OpenGL 1.2+ support unavailable.        if (vendorString == null) {            return false;        }        // If OGL was explicitly requested, we will use it        if (nativeOglRequested) {            return true;        }        // Check OS type and vendor string to see whether OGL is preferred        return preferOgl(isWindowsVista, vendorString);    }    // Returns a flag inticating whether the specified vendor prefers OpenGL.    private static boolean preferOgl(boolean isWindowsVista, String vendorString) {        // We prefer OpenGL on all Windows/XP cards        if (!isWindowsVista) {            return true;        }        // List of vendors for which we will prefer to use D3D on Windows Vista        // This must be all lower case.        final String[] vistaD3dList = {            "microsoft",            "ati",            // TODO: add the following if Intel's OpenGL driver turns out to be buggy on Vista            // "intel",        };        final String lcVendorString = vendorString.toLowerCase();        // If we are running on Windows Vista, we will check the vendor string        // against the list of vendors that prefer D3D on Vista, and return true        // *unless* the vendor is in that list.        for (int i = 0; i < vistaD3dList.length; i++) {            if (lcVendorString.startsWith(vistaD3dList[i])) {                return false;            }        }        return true;    }        /**     * Initialize the Pipeline. Called exactly once by     * MasterControl.loadLibraries() to create the singleton     * Pipeline object.     */    static void createPipeline(Type pipelineType) {        String className = null;        switch (pipelineType) {        case NATIVE_OGL:        case NATIVE_D3D:            className = CLASSNAME_NATIVE;            break;        case JOGL:            className = CLASSNAME_JOGL;            break;        case NOOP:            className = CLASSNAME_NOOP;            break;        default:            // Should not get here            throw new AssertionError("missing case statement");        }        final String pipelineClassName = className;        pipeline = (Pipeline)            java.security.AccessController.doPrivileged(new                java.security.PrivilegedAction() {                    public Object run() {                        try {                            Class pipelineClass = Class.forName(pipelineClassName);                            return pipelineClass.newInstance();                        } catch (Exception e) {                            throw new RuntimeException(e);                        }                    }                });        pipeline.initialize(pipelineType);    }    /**     * Returns the singleton Pipeline object.     */    static Pipeline getPipeline() {        return pipeline;    }    /**     * Initializes the pipeline object. Only called by initPipeline.     * Pipeline subclasses may override this, but must call     * super.initialize(pipelineType);     */    void initialize(Type pipelineType) {        setPipelineType(pipelineType);    }    /**     * Sets the pipeline type. Only called by initialize.     */    private void setPipelineType(Type pipelineType) {        this.pipelineType = pipelineType;    }    /**     * Returns the pipeline type     */    Type getPipelineType() {        return pipelineType;    }    /**     * Returns the pipeline name     */    String getPipelineName() {        switch (pipelineType) {        case NATIVE_OGL:            return "NATIVE_OGL";        case NATIVE_D3D:            return "NATIVE_D3D";        case JOGL:            return "JOGL";        case NOOP:            return "NOOP";        default:            // Should not get here            throw new AssertionError("missing case statement");        }    }    /**     * Returns the renderer name     */    String getRendererName() {        switch (pipelineType) {        case NATIVE_OGL:        case JOGL:            return "OpenGL";        case NATIVE_D3D:            return "DirectX";        case NOOP:            return "None";        default:            // Should not get here            throw new AssertionError("missing case statement");        }    }    // ---------------------------------------------------------------------    //    // Methods to initialize and load required libraries (from MasterControl)    //    /**     * Load all of the required libraries     */    abstract void loadLibraries(int globalShadingLanguage);    /**     * Returns true if the Cg library is loaded and available. Note that this     * does not necessarily mean that Cg is supported by the graphics card.     */    abstract boolean isCgLibraryAvailable();    /**     * Returns true if the GLSL library is loaded and available. Note that this     * does not necessarily mean that GLSL is supported by the graphics card.     */    abstract boolean isGLSLLibraryAvailable();    // ---------------------------------------------------------------------    //    // GeometryArrayRetained methods    //    // Used by D3D to free vertex buffer    abstract void freeD3DArray(GeometryArrayRetained geo, boolean deleteVB);    // used for GeometryArrays by Copy or interleaved    abstract void execute(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean useAlpha,            boolean ignoreVertexColors,            int startVIndex, int vcount, int vformat,            int texCoordSetCount, int[] texCoordSetMap,            int texCoordSetMapLen,            int[] texCoordSetOffset,            int numActiveTexUnitState,            int vertexAttrCount, int[] vertexAttrSizes,            float[] varray, float[] cdata, int cdirty);    // used by GeometryArray by Reference with java arrays    abstract void executeVA(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int coordIndex, float[] vfcoords, double[] vdcoords,            int colorIndex, float[] cfdata, byte[] cbdata,            int normalIndex, float[] ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndex, float[][] vertexAttrData,            int texcoordmaplength,            int[] texcoordoffset,            int numActiveTexUnitState,            int[] texIndex, int texstride, Object[] texCoords,            int cdirty);    // used by GeometryArray by Reference with NIO buffer    abstract void executeVABuffer(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int coordIndex,            Object vcoords,            int colorIndex,            Object cdataBuffer,            float[] cfdata, byte[] cbdata,            int normalIndex, Object ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndex, Object[] vertexAttrData,            int texcoordmaplength,            int[] texcoordoffset,            int numActiveTexUnitState,            int[] texIndex, int texstride, Object[] texCoords,            int cdirty);    // used by GeometryArray by Reference in interleaved format with NIO buffer    abstract void executeInterleavedBuffer(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean useAlpha,            boolean ignoreVertexColors,            int startVIndex, int vcount, int vformat,            int texCoordSetCount, int[] texCoordSetMap,            int texCoordSetMapLen,            int[] texCoordSetOffset,            int numActiveTexUnitState,            Object varray, float[] cdata, int cdirty);    abstract void setVertexFormat(Context ctx, GeometryArrayRetained geo,            int vformat, boolean useAlpha, boolean ignoreVertexColors);    abstract void disableGlobalAlpha(Context ctx, GeometryArrayRetained geo, int vformat,            boolean useAlpha, boolean ignoreVertexColors);    // used for GeometryArrays    abstract void buildGA(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale, boolean updateAlpha,            float alpha,            boolean ignoreVertexColors,            int startVIndex,            int vcount, int vformat,            int texCoordSetCount, int[] texCoordSetMap,            int texCoordSetMapLen, int[] texCoordSetMapOffset,            int vertexAttrCount, int[] vertexAttrSizes,                double[] xform, double[] nxform,            float[] varray);    // used to Build Dlist GeometryArray by Reference with java arrays    abstract void buildGAForByRef(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,  boolean updateAlpha,            float alpha,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int coordIndex, float[] vfcoords, double[] vdcoords,            int colorIndex, float[] cfdata, byte[] cbdata,            int normalIndex, float[] ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndex, float[][] vertexAttrData,            int texcoordmaplength,            int[] texcoordoffset,            int[] texIndex, int texstride, Object[] texCoords,            double[] xform, double[] nxform);    // used to Build Dlist GeometryArray by Reference with NIO buffer    // NOTE: NIO buffers are no longer supported in display lists. We    // have no plans to add this support.    /*    abstract void buildGAForBuffer(Context ctx,

⌨️ 快捷键说明

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