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

📄 joglpipeline.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * $RCSfile: JoglPipeline.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.22 $ * $Date: 2007/04/13 17:59:45 $ * $State: Exp $ */package javax.media.j3d;import com.sun.j3d.internal.ByteBufferWrapper;import java.awt.*;import java.io.*;import java.lang.reflect.*;import java.nio.*;import java.security.*;import java.util.*;import java.util.regex.*;import javax.media.opengl.*;import javax.media.opengl.glu.*;import com.sun.opengl.cg.*;import com.sun.opengl.util.*;/** * Concrete implementation of Pipeline class for the JOGL rendering * pipeline. */class JoglPipeline extends Pipeline {        // Flags indicating whether the Cg or GLSL libraries are available.    private boolean cgLibraryAvailable = false;        // Currently prints for entry points not yet implemented    private static final boolean DEBUG = true;    // Currently prints for entry points already implemented    private static final boolean VERBOSE = false;    // Debugging output for graphics configuration selection    private static final boolean DEBUG_CONFIG = false;    // Prints extra debugging information    private static final boolean EXTRA_DEBUGGING = false;    // Number of milliseconds to wait for windows to pop up on screen    private static final int WAIT_TIME = 1000;    // Configurable constant just in case we want to change this later    private static final int MIN_FRAME_SIZE = 1;        /**     * Constructor for singleton JoglPipeline instance     */    protected JoglPipeline() {    }        /**     * Initialize the pipeline     */    void initialize(Pipeline.Type pipelineType) {        super.initialize(pipelineType);                assert pipelineType == Pipeline.Type.JOGL;                // Java3D maintains strict control over which threads perform OpenGL work        Threading.disableSingleThreading();                // TODO: finish this with any other needed initialization    }        /**     * Load all of the required libraries     */    void loadLibraries(int globalShadingLanguage) {        if (globalShadingLanguage == Shader.SHADING_LANGUAGE_CG) {            // Try to load the jogl_cg library and set the            // cgLibraryAvailable flag to true if loads successfully; note            // that successfully performing initialization of this class            // will cause the Cg native library to be loaded on our behalf            try {                Class.forName("com.sun.opengl.cg.CgGL");                cgLibraryAvailable = true;            } catch (Exception ex) {                System.err.println(ex);            } catch (Error ex) {                System.err.println(ex);            }        }    }        /**     * 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.     */    boolean isCgLibraryAvailable() {        return cgLibraryAvailable;    }        /**     * 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.     */    boolean isGLSLLibraryAvailable() {        return true;    }            // ---------------------------------------------------------------------        //    // GeometryArrayRetained methods    //        // Used by D3D to free vertex buffer    void freeD3DArray(GeometryArrayRetained geo, boolean deleteVB) {        // Nothing to do    }        // used for GeometryArrays by Copy or interleaved    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[] texUnitOffset,            int numActiveTexUnitState,            int vertexAttrCount, int[] vertexAttrSizes,            float[] varray, float[] carray, int cDirty) {        if (VERBOSE) System.err.println("JoglPipeline.execute()");                executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha,                ignoreVertexColors, startVIndex, vcount, vformat,                texCoordSetCount, texCoordSetMap, texCoordSetMapLen,                texUnitOffset, numActiveTexUnitState,                vertexAttrCount, vertexAttrSizes,                varray, null, carray, cDirty);    }        // used by GeometryArray by Reference with java arrays    void executeVA(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int initialCoordIndex, float[] vfcoords, double[] vdcoords,            int initialColorIndex, float[] cfdata, byte[] cbdata,            int initialNormalIndex, float[] ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndices, float[][] vertexAttrData,            int texCoordMapLength,            int[] texcoordoffset,            int numActiveTexUnitState,            int[] texIndex, int texstride, Object[] texCoords,            int cdirty) {        if (VERBOSE) System.err.println("JoglPipeline.executeVA()");                boolean floatCoordDefined  = ((vdefined & GeometryArrayRetained.COORD_FLOAT)    != 0);        boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE)   != 0);        boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT)    != 0);        boolean byteColorsDefined  = ((vdefined & GeometryArrayRetained.COLOR_BYTE)     != 0);        boolean normalsDefined     = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT)   != 0);        boolean vattrDefined       = ((vdefined & GeometryArrayRetained.VATTR_FLOAT)    != 0);        boolean textureDefined     = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);                FloatBuffer fverts = null;        DoubleBuffer dverts = null;        FloatBuffer fclrs = null;        ByteBuffer bclrs = null;        FloatBuffer[] texCoordBufs = null;        FloatBuffer norms = null;        FloatBuffer[] vertexAttrBufs = null;                // Get vertex attribute arrays        if (vattrDefined) {            vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);        }                // get texture arrays        if (textureDefined) {            texCoordBufs = getTexCoordSetBuffer(texCoords);        }                // get coordinate array        if (floatCoordDefined) {            fverts = getVertexArrayBuffer(vfcoords);        } else if (doubleCoordDefined) {            dverts = getVertexArrayBuffer(vdcoords);        }                // get color array        if (floatColorsDefined) {            fclrs = getColorArrayBuffer(cfdata);        } else if (byteColorsDefined) {            bclrs = getColorArrayBuffer(cbdata);        }                // get normal array        if (normalsDefined) {            norms = getNormalArrayBuffer(ndata);        }                int[] sarray = null;        int[] start_array = null;        int strip_len = 0;        if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET ||                geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET   ||                geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {            sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;            strip_len = sarray.length;            start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;        }                executeGeometryArrayVA(ctx, geo, geo_type,                isNonUniformScale, ignoreVertexColors,                vcount, vformat, vdefined,                initialCoordIndex, fverts, dverts,                initialColorIndex, fclrs, bclrs,                initialNormalIndex, norms,                vertexAttrCount, vertexAttrSizes,                vertexAttrIndices, vertexAttrBufs,                texCoordMapLength,                texcoordoffset, numActiveTexUnitState,                texIndex, texstride, texCoordBufs, cdirty,                sarray, strip_len, start_array);    }        // used by GeometryArray by Reference with NIO buffer    void executeVABuffer(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int initialCoordIndex,            Object vcoords,            int initialColorIndex,            Object cdataBuffer,            float[] cfdata, byte[] cbdata,            int initialNormalIndex, Object ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndices, Object[] vertexAttrData,            int texCoordMapLength,            int[] texcoordoffset,            int numActiveTexUnitState,            int[] texIndex, int texstride, Object[] texCoords,            int cdirty) {        if (VERBOSE) System.err.println("JoglPipeline.executeVABuffer()");                boolean floatCoordDefined  = ((vdefined & GeometryArrayRetained.COORD_FLOAT)    != 0);        boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE)   != 0);        boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT)    != 0);        boolean byteColorsDefined  = ((vdefined & GeometryArrayRetained.COLOR_BYTE)     != 0);        boolean normalsDefined     = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT)   != 0);        boolean vattrDefined       = ((vdefined & GeometryArrayRetained.VATTR_FLOAT)    != 0);        boolean textureDefined     = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);                FloatBuffer fverts = null;        DoubleBuffer dverts = null;        FloatBuffer fclrs = null;        ByteBuffer bclrs = null;        FloatBuffer[] texCoordBufs = null;        FloatBuffer norms = null;        FloatBuffer[] vertexAttrBufs = null;                // Get vertex attribute arrays        if (vattrDefined) {            vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);        }                // get texture arrays        if (textureDefined) {            texCoordBufs = new FloatBuffer[texCoords.length];            for (int i = 0; i < texCoords.length; i++) {                texCoordBufs[i] = (FloatBuffer) texCoords[i];            }        }                // get coordinate array        if (floatCoordDefined) {            fverts = (FloatBuffer) vcoords;        } else if (doubleCoordDefined) {            dverts = (DoubleBuffer) vcoords;        }                if (fverts == null && dverts == null) {            return;        }                // get color array        if (floatColorsDefined) {            if (cfdata != null)                fclrs = getColorArrayBuffer(cfdata);

⌨️ 快捷键说明

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