diff options
280 files changed, 35205 insertions, 9595 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 930cc77..8f40b99 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -2,8 +2,12 @@ This software is licensed by Sun: i) for research use under terms of the Java Research License (JRL) as specified in the LICENSE-JRL.txt file and on the web at -"http://java3d.dev.java.net/jrl.html"; or +"http://java3d.dev.java.net/jrl.html" -ii) for commercial use under the terms of the Java Distribution License -(JDL) as specified in the LICENSE-JDL.txt file and on the web at -"http://java3d.dev.java.net/jdl-java3d.pdf". +NOTE: The main trunk of the Java 3D core source code (j3d-core +project) contains proposed API changes for an eventual 1.4 version of +the Java 3D API. THESE API CHANGES ARE NOT YET APPROVED AS PART OF +A JAVA SPECIFICATION REQUEST (JSR) UNDER THE JAVA COMMUNITY PROCESS +(JCP). UNTIL SUCH TIME AS THEY ARE ADOPTED AND APPROVED BY A JSR, +THE 1.4-EXPERIMENTAL VERSION OF THE JAVA 3D API MAY ONLY BE USED FOR +RESEARCH UNDER THE TERMS OF THE JAVA RESEARCH LICENSE (JRL). diff --git a/README-FIRST.txt b/README-FIRST.txt index b6dd53b..8126ba6 100644 --- a/README-FIRST.txt +++ b/README-FIRST.txt @@ -1,3 +1,11 @@ +NOTE: The main trunk of the Java 3D core source code (j3d-core +project) contains proposed API changes for an eventual 1.4 version of +the Java 3D API. THESE API CHANGES ARE NOT YET APPROVED AS PART OF +A JAVA SPECIFICATION REQUEST (JSR) UNDER THE JAVA COMMUNITY PROCESS +(JCP). UNTIL SUCH TIME AS THEY ARE ADOPTED AND APPROVED BY A JSR, +THE 1.4-EXPERIMENTAL VERSION OF THE JAVA 3D API MAY ONLY BE USED FOR +RESEARCH UNDER THE TERMS OF THE JAVA RESEARCH LICENSE (JRL). + The source code for the j3d-core project is copyrighted code that is licensed to individuals or companies who download or otherwise access the code. diff --git a/build-tools/VersionInfo.java b/build-tools/VersionInfo.java index 282de87..55dee73 100644 --- a/build-tools/VersionInfo.java +++ b/build-tools/VersionInfo.java @@ -157,7 +157,7 @@ class VersionInfo extends Object { * Specification version (major and minor version only). This * string must not be modified by developers. */ - private static final String SPECIFICATION_VERSION = "1.3"; + private static final String SPECIFICATION_VERSION = "1.4"; /** * Specification vendor. This should never change and must not @@ -14,7 +14,7 @@ */ --> -<project name="Java 3D" default="jar-opt" basedir="."> +<project name="java3d-1.4.0" default="jar-opt" basedir="."> <!-- ********************************************************************* @@ -51,7 +51,7 @@ * build number that is greater than the previous build's build * number. --> - <property name="version_buildnum" value="1"/> + <property name="version_buildnum" value="8"/> <!-- * The following property specifies the beta revision of the current @@ -72,8 +72,8 @@ * separated by "periods ("."). The version_base_file property must * be the same version number as version_base with "_" replacing ".". --> - <property name="version_base" value="1.3.3"/> - <property name="version_base_file" value="1_3_3"/> + <property name="version_base" value="1.4.0"/> + <property name="version_base_file" value="1_4_0"/> <!-- ************************************* --> @@ -152,31 +152,48 @@ <target name="setupSolaris" if="isSolarisOnSparc"> <property name="ostype" value="solaris"/> <property name="platform" value="solaris-sparc-${build.comp}"/> + <property name="install.bin" value="lib/sparc"/> + </target> + + <target name="setupSolarisX86" if="isSolarisOnX86"> + <property name="ostype" value="solaris"/> + <property name="platform" value="solaris-x86-${build.comp}"/> + <property name="install.bin" value="lib/i386"/> </target> <target name="setupLinux" if="isLinuxOnX86"> <property name="ostype" value="linux"/> <property name="platform" value="linux-i586"/> + <property name="install.bin" value="lib/i386"/> </target> <target name="setupLinuxAmd64" if="isLinuxOnAmd64"> <property name="ostype" value="linux"/> <property name="platform" value="linux-amd64"/> + <property name="install.bin" value="lib/amd64"/> </target> <target name="setupLinuxIA64" if="isLinuxOnIA64"> <property name="ostype" value="linux"/> <property name="platform" value="linux-ia64"/> + <property name="install.bin" value="lib/ia64"/> + </target> + + <target name="setupLinuxPPC" if="isLinuxOnPPC"> + <property name="ostype" value="linux"/> + <property name="platform" value="linux-ppc"/> + <property name="install.bin" value="lib/ppc"/> </target> - <!-- win32 should be rename as windows --> + <!-- win32 should be rename as windows --> <target name="setupWindows" if="isWindowsOnX86"> <property name="ostype" value="win32"/> <property name="platform" value="windows-i586-${build.comp}"/> + <property name="install.bin" value="bin"/> </target> <target name="setupPlatform" - depends="init, setupBuildType, setupSolaris, setupLinux, setupLinuxAmd64, setupLinuxIA64, setupWindows"> + depends="init, setupBuildType, setupSolaris, setupSolarisX86, setupLinux, setupLinuxAmd64, setupLinuxIA64, setupLinuxPPC, setupWindows"> <property name="build-debug-gen" location="${build}/${platform}/debug/gen"/> <property name="build-opt-gen" location="${build}/${platform}/opt/gen"/> <property name="docname" value="java3d-${version_file}-doc"/> @@ -313,13 +330,38 @@ <condition property="isLinuxOnIA64"> <os name="linux" arch="ia64"/> </condition> + + <condition property="isLinuxOnPPC"> + <os name="linux" arch="ppc"/> + </condition> <condition property="isSolarisOnSparc"> <os name="SunOS" arch="sparc"/> </condition> + + <condition property="isSolarisOnX86"> + <os name="SunOS" arch="x86"/> + </condition> + + <condition property="isa_amd64"> + <contains string="${sun.cpu.isalist}" substring="amd64"/> + </condition> + + <available file="${java.home}/lib/amd64/libjawt.so" property="jre_amd64_present"/> + + <!-- flag indicating that a 64-bit JVM is available for Solaris/x86 --> + <condition property="isSolarisOnX86_64"> + <and> + <isset property="isSolarisOnX86"/> + <isset property="isa_amd64"/> + <isset property="jre_amd64_present"/> + </and> + </condition> + </target> <target name="compile-debug" depends="setupPlatform"> +<!-- <ant dir="${vecmath_home}" target="jar-debug"/>--> <ant dir="src/classes" target="compile-debug"/> <antcall target="compile-debug-native"/> </target> @@ -329,6 +371,7 @@ </target> <target name="compile-opt" depends="setupPlatform"> +<!-- <ant dir="${vecmath_home}" target="jar-opt"/>--> <ant dir="src/classes" target="compile-opt"/> <antcall target="compile-opt-native"/> </target> @@ -472,6 +515,14 @@ <delete dir="${build}/${platform}/opt/lib/ext"/> </target> + <target name="install-debug" depends="jar-debug"> + <ant dir="src/classes" target="install-debug"/> + </target> + + <target name="uninstall" depends="setupPlatform"> + <ant dir="src/classes" target="uninstall"/> + </target> + <description> The following ant targets are available ("jar-opt" is the default): @@ -535,5 +586,9 @@ The following ant targets are available ("jar-opt" is the default): rpm - creates a i586 rpm for installation in /usr/java/jdk1.5.0 the rpm is placed in dist/rpm + + install-debug - installs the debug build into the JDK pointed to by JAVA_HOME + + uninstall - uninstalls Java 3D from the JDK pointed to by JAVA_HOME </description> </project> diff --git a/docs/api-changes-1_4.txt b/docs/api-changes-1_4.txt new file mode 100644 index 0000000..39f29a0 --- /dev/null +++ b/docs/api-changes-1_4.txt @@ -0,0 +1,533 @@ +------------------------------------------------------------------------ +$RCSfile$ +$Revision$ +$Date$ +------------------------------------------------------------------------ +This document conatains proposed API changes to the Java 3D 1.4 API +that deviate from the 1.3 API. + +This file must be updated to record the addition or deprecation of any +public or protected class, interface, field, constructor, or method to +the Java 3D API. + +The one exception to this rule is that you don't need to update this +file when adding a non-final (i.e., virtual) method to a class if that +method--with exactly the same signature--already exists in a +superclass. For example, adding a "toString" method to a j3d object +doesn't require an entry in this file. Likewise, adding duplicateNode +or cloneNode methods to Node subclasses doesn't require an entry in +this file. + +No incompatible changes to the Java 3D 1.3 API are allowed. + + +I. New/deprecated fields, constructors, methods + + Canvas3D + -------- + New methods: + public boolean isShadingLanguageSupported(int shadingLanguage) + + + SceneGraphObject + ---------------- + New methods: + public void setName(String name) + public String getName() + + + GeometryArray + ------------- + New fields: + public static final int ALLOW_VERTEX_ATTR_READ + public static final int ALLOW_VERTEX_ATTR_WRITE + public static final int VERTEX_ATTRIBUTES + + New constructors: + public GeometryArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) + + New methods: + public int getVertexAttrCount() + public void getVertexAttrSizes(int[] vertexAttrSizes) + public void setVertexAttr(int vertexAttrNum, int index, + float[] vertexAttr) + public void setVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) + public void setVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) + public void setVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) + public void setVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs) + public void setVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs) + public void setVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs) + public void setVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs) + public void setVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs, + int start, int length) + public void setVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs, + int start, int length) + public void setVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs, + int start, int length) + public void setVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs, + int start, int length) + public void getVertexAttr(int vertexAttrNum, int index, + float[] vertexAttr) + public void getVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) + public void getVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) + public void getVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) + public void getVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs) + public void getVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs) + public void getVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs) + public void getVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs) + public void setInitialVertexAttrIndex(int vertexAttrNum, + int initialVertexAttrIndex) + public int getInitialVertexAttrIndex(int vertexAttrNum) + public void setVertexAttrRefBuffer(int vertexAttrNum, J3DBuffer vertexAttrs) + public J3DBuffer getVertexAttrRefBuffer(int vertexAttrNum) + public void setVertexAttrRefFloat(int vertexAttrNum, float[] vertexAttrs) + public float[] getVertexAttrRefFloat(int vertexAttrNum) + + + PointArray + ---------- + New constructors: + public PointArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) + + + LineArray + --------- + New constructors: + public LineArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) + + + TriangleArray + ------------- + New constructors: + public TriangleArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) + + + QuadArray + --------- + New constructors: + public QuadArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) + + + GeometryStripArray + ------------------ + New constructors: + public GeometryStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) + + + LineStripArray + -------------- + New constructors: + public LineStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) + + + TriangleStripArray + ------------------ + New constructors: + public TriangleStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) + + + TriangleFanArray + ---------------- + New constructors: + public TriangleFanArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) + + + IndexedGeometryArray + -------------------- + New constructors: + public IndexedGeometryArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) + + New fields: + public static final int ALLOW_VERTEX_ATTR_INDEX_READ + public static final int ALLOW_VERTEX_ATTR_INDEX_WRITE + + New methods: + public void setInitialVertexAttrIndex(int vertexAttrNum, + int initialVertexAttrIndex) + public void setVertexAttrIndex(int vertexAttrNum, + int index, + int vertexAttrIndex) + public void setVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) + public int getVertexAttrIndex(int vertexAttrNum, int index) + public void getVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) + + + IndexedPointArray + ---------------- + New constructors: + public IndexedPointArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) + + + IndexedLineArray + ---------------- + New constructors: + public IndexedLineArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) + + + IndexedTriangleArray + ---------------- + New constructors: + public IndexedTriangleArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) + + + IndexedQuadArray + ---------------- + New constructors: + public IndexedQuadArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) + + + IndexedGeometryStripArray + ------------------------- + New constructors: + public IndexedGeometryStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount + int[] stripIndexCounts) + + + IndexedLineStripArray + ------------------------- + New constructors: + public IndexedLineStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount + int[] stripIndexCounts) + + + IndexedTriangleStripArray + ------------------------- + New constructors: + public IndexedTriangleStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount + int[] stripIndexCounts) + + + IndexedTriangleFanArray + ------------------------- + New constructors: + public IndexedTriangleFanArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount + int[] stripIndexCounts) + + + Node + ---- + New fields: + public static final int ALLOW_PARENT_READ + public static final int ALLOW_LOCALE_READ + + New methods: + public Locale getLocale() + + + VirtualUniverse + --------------- + New methods: + public void addGraphStructureChangeListener(GraphStructureChangeListener listener) + public void removeGraphStructureChangeListener(GraphStructureChangeListener listener) + public void addShaderErrorListener(ShaderErrorListener listener) + public void removeShaderErrorListener(ShaderErrorListener listener) + + + Locale + ------ + New methods: + public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) + public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) + public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) + public PickInfo pickAny( int mode, int flags, PickShape pickShape ) + + + BranchGroup + ----------- + New methods: + public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) + public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) + public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) + public PickInfo pickAny( int mode, int flags, PickShape pickShape ) + + + Sensor + ------ + Deprecated fields: + public static final int PREDICT_NONE + public static final int PREDICT_NEXT_FRAME_TIME + public static final int NO_PREDICTOR + public static final int HEAD_PREDICTOR + public static final int HAND_PREDICTOR + + Deprecated methods: + public void setPredictor(int predictor) + public int getPredictor() + public void setPredictionPolicy(int policy) + public int getPredictionPolicy() + public void getRead(Transform3D read, long deltaT) + + + RenderingAttributes + ------------------- + New fields: + public static final int ALLOW_DEPTH_TEST_FUNCTION_READ + public static final int ALLOW_DEPTH_TEST_FUNCTION_WRITE + public static final int ALLOW_STENCIL_ATTRIBUTES_READ + public static final int ALLOW_STENCIL_ATTRIBUTES_WRITE + public static final int ROP_CLEAR + public static final int ROP_AND + public static final int ROP_AND_REVERSE + public static final int ROP_AND_INVERTED + public static final int ROP_NOOP + public static final int ROP_OR + public static final int ROP_NOR + public static final int ROP_EQUIV + public static final int ROP_INVERT + public static final int ROP_OR_REVERSE + public static final int ROP_COPY_INVERTED + public static final int ROP_OR_INVERTED + public static final int ROP_NAND + public static final int ROP_SET + public static final int STENCIL_KEEP + public static final int STENCIL_ZERO + public static final int STENCIL_REPLACE + public static final int STENCIL_INCR + public static final int STENCIL_DECR + public static final int STENCIL_INVERT + + + New methods: + public void setDepthTestFunction(int function) + public int getDepthTestFunction() + public void setStencilEnable(boolean enable) + public boolean getStencilEnable() + public void setStencilOp(int failOp, int zFailOp, int zPassOp) + public void setStencilOp(int[] stencilOps) + public void getStencilOp(int[] stencilOps) + public void setStencilFunction(int function, int refValue, int compareMask) + public void setStencilFunction(int[] params) + public void getStencilFunction(int[] params) + public void setStencilWriteMask(int mask) + public int getStencilWriteMask() + + + Font3D + ------ + New methods: + public GeometryArray getGlyphGeometry(char c) + + + GraphicsConfigTemplate3D + ------------------------ + New methods: + public void setStencilSize(int value) + public int getStencilSize() + + + TransparencyAttributes + ---------------------- + New fields: + public static final int BLEND_DST_COLOR + public static final int BLEND_ONE_MINUS_DST_COLOR + public static final int BLEND_SRC_COLOR + public static final int BLEND_ONE_MINUS_SRC_COLOR + + +II. Reparented classes + + NONE + + +III. New classes and interfaces (in javax.media.j3d) + + ShaderAppearance + ---------------- + public class ShaderAppearance extends Appearance + + ShaderAttributeSet + ------------------ + public class ShaderAttributeSet extends NodeComponent + + ShaderAttribute + --------------- + public abstract class ShaderAttribute extends NodeComponent + + ShaderAttributeBinding + ---------------------- + public class ShaderAttributeBinding extends ShaderAttribute + + ShaderAttributeObject + --------------------- + public abstract class ShaderAttributeObject extends ShaderAttribute + + ShaderAttributeValue + -------------------- + public class ShaderAttributeValue extends ShaderAttributeObject + + ShaderAttributeArray + -------------------- + public class ShaderAttributeArray extends ShaderAttributeObject + + Shader + ------ + public abstract class Shader extends NodeComponent + + SourceCodeShader + ---------------- + public class SourceCodeShader extends Shader + + ShaderProgram + ------------- + public abstract class ShaderProgram extends NodeComponent + + CgShaderProgram + --------------- + public class CgShaderProgram extends ShaderProgram + + GLSLShaderProgram + ----------------- + public class GLSLShaderProgram extends ShaderProgram + + ShaderError + ----------- + public class ShaderError extends Object + + ShaderErrorListener + ------------------- + public interface ShaderErrorListener + + GraphStructureChangeListener + ---------------------------- + public interface GraphStructureChangeListener + + PickInfo + -------- + public class PickInfo extends Object + + PickInfo.IntersectionInfo + ------------------------- + public class PickInfo.IntersectionInfo extends Object + + +IV. Deprecated classes and interfaces (in javax.media.j3d) + + CompressedGeometry + CompressedGeometryHeader + PickPoint + Morph diff --git a/release-info/pre-release/HOW-TO-INSTALL.txt b/release-info/pre-release/HOW-TO-INSTALL.txt index aa91ff0..1c85efb 100644 --- a/release-info/pre-release/HOW-TO-INSTALL.txt +++ b/release-info/pre-release/HOW-TO-INSTALL.txt @@ -4,6 +4,6 @@ and unzip (or unjar) the zip file. For example, if your JDK is installed in /usr/java/j2sdk1.5.0, you would install this as follows: cd /usr/java/j2sdk1.5.0/jre - unzip /path-to-extracted-files/j3d-jre-*.zip + unzip /path-to-extracted-files/j3d-140-*.zip You may need to be "root" to do this on Solaris or Linux. diff --git a/release-info/pre-release/README.txt b/release-info/pre-release/README.txt index 40edd3a..8420795 100644 --- a/release-info/pre-release/README.txt +++ b/release-info/pre-release/README.txt @@ -1,4 +1,4 @@ -This binary release of Java 3D 1.3.3-experimental is an intermediate +This binary release of Java 3D 1.4.0-experimental is an intermediate build made available for testing purposes only. The code is untested and presumed incompatible with the Java 3D(TM) API specification. You must only use this code in accordance with the terms under which the diff --git a/src/classes/J3dVersion b/src/classes/J3dVersion index 61276d5..cc882bb 100644 --- a/src/classes/J3dVersion +++ b/src/classes/J3dVersion @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Specification-Title: Java 3D API Specification -Specification-Version: 1.3 +Specification-Version: 1.4 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: Java 3D Core Runtime Environment Implementation-Version: @VERSION_BASE@ diff --git a/src/classes/build.xml b/src/classes/build.xml index 5a7df2a..1cd3cc1 100644 --- a/src/classes/build.xml +++ b/src/classes/build.xml @@ -139,14 +139,14 @@ <!-- Put everything in ${build}/${platform}/debug/classes/javax into the j3dcore.jar file --> <jar jarfile="${build}/${platform}/debug/lib/ext/j3dcore.jar" - manifest="${build-debug-gen}/J3dVersion" update="yes" + manifest="${build-debug-gen}/J3dVersion" update="no" compress="false"> <fileset dir="${build}/${platform}/debug/classes" includes="javax/**/*"/> </jar> <!-- Put everything in ${build}/${platform}/debug/classes/com into the j3dutils.jar file --> <jar jarfile="${build}/${platform}/debug/lib/ext/j3dutils.jar" - manifest="${build-debug-gen}/ToolsVersion" update="yes" + manifest="${build-debug-gen}/ToolsVersion" update="no" compress="false"> <fileset dir="${build}/${platform}/debug/classes" includes="com/**/*"/> </jar> @@ -179,14 +179,14 @@ <!-- Put everything in ${build}/${platform}/opt/classes/javax into the j3dcore.jar file --> <jar jarfile="${build}/${platform}/opt/lib/ext/j3dcore.jar" - manifest="${build-opt-gen}/J3dVersion" update="yes" + manifest="${build-opt-gen}/J3dVersion" update="no" compress="false"> <fileset dir="${build}/${platform}/opt/classes" includes="javax/**/*"/> </jar> <!-- Put everything in ${build}/${platform}/opt/classes/com into the j3dutils.jar file --> <jar jarfile="${build}/${platform}/opt/lib/ext/j3dutils.jar" - manifest="${build-opt-gen}/ToolsVersion" update="yes" + manifest="${build-opt-gen}/ToolsVersion" update="no" compress="false"> <fileset dir="${build}/${platform}/opt/classes" includes="com/**/*"/> </jar> @@ -306,4 +306,24 @@ basedir="${build}/${platform}/javadocs/docs-public"/> </target> + <target name="install-debug"> + <copy todir="${java.home}/lib/ext"> + <fileset dir="${build}/${platform}/debug/lib/ext" includes="*.jar"/> + <fileset dir="${vecmath_home}/build/opt/lib/ext" includes="vecmath.jar"/> + </copy> + <copy todir="${java.home}/${install.bin}"> + <fileset dir="${build}/${platform}/debug/${install.bin}" includes="*"/> + </copy> + </target> + + <target name="uninstall"> + <delete> + <fileset dir="${java.home}/lib/ext" includes="j3dcore.jar, j3dutils.jar, vecmath.jar"/> + </delete> + <delete> + <fileset dir="${java.home}/${install.bin}" includes="libj3dcore*.so, libj3dutils.so"/> + <fileset dir="${java.home}/${install.bin}" includes="j3dcore*.dll, j3dutils.dll"/> + </delete> + </target> + </project> diff --git a/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java b/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java index 35249b6..0006ef5 100644 --- a/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java +++ b/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java @@ -39,7 +39,6 @@ class J3dGraphicsConfig { // Check to see if a valid FBConfig pointer has been cached. Object fbConfigObject = Canvas3D.fbConfigTable.get(gc); return ((fbConfigObject != null) && - (fbConfigObject instanceof Long)); - + (fbConfigObject instanceof GraphicsConfigInfo)); } } diff --git a/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java index 42f7518..4580b00 100644 --- a/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java @@ -43,7 +43,8 @@ class NativeConfigTemplate3D { final static int DOUBLEBUFFER = 6; final static int STEREO = 7; final static int ANTIALIASING = 8; - final static int NUM_ITEMS = 9; + final static int STENCIL_SIZE = 9; + final static int NUM_ITEMS = 10; // Native method to get an OpenGL visual id and a pointer to the // GLXFBConfig structure list itself. @@ -60,6 +61,7 @@ class NativeConfigTemplate3D { native boolean isDoubleBufferAvailable(long display, int screen, int vid); native boolean isSceneAntialiasingAccumAvailable(long display, int screen, int vid); native boolean isSceneAntialiasingMultisampleAvailable(long display, int screen, int vid); + native int getStencilSize(long display, int screen, int vid); /* @@ -118,6 +120,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; int visID = chooseOglVisual(display, screen, attrList, fbConfig); @@ -146,10 +151,14 @@ class NativeConfigTemplate3D { // returns, since this is not cached with X11GraphicsConfig and there // are no public constructors to allow us to extend it. synchronized (Canvas3D.fbConfigTable) { - if (Canvas3D.fbConfigTable.get(gc1) == null) - Canvas3D.fbConfigTable.put(gc1, new Long(fbConfig[0])); - else + if (Canvas3D.fbConfigTable.get(gc1) == null) { + GraphicsConfigInfo gcInfo = new GraphicsConfigInfo(); + gcInfo.setFBConfig(fbConfig[0]); + gcInfo.setRequestedStencilSize(attrList[STENCIL_SIZE]); + Canvas3D.fbConfigTable.put(gc1, gcInfo); + } else { freeFBConfig(fbConfig[0]); + } } return gc1; @@ -188,6 +197,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; int visID = chooseOglVisual(display, screen, attrList, fbConfig); @@ -214,6 +226,22 @@ class NativeConfigTemplate3D { return isStereoAvailable(display, screen, vid); } + + // Return the stencil of this canvas. + int getStencilSize(Canvas3D c3d) { + GraphicsConfiguration gc = c3d.graphicsConfiguration; + + X11GraphicsDevice gd = + (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); + NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); + + long display = nativeScreenInfo.getDisplay(); + int screen = nativeScreenInfo.getScreen(); + int vid = ((X11GraphicsConfig)gc).getVisual(); + + return getStencilSize(display, screen, vid); + } + // Return whether a double buffer is available. boolean hasDoubleBuffer(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; diff --git a/src/classes/share/javax/media/j3d/AlternateAppearance.java b/src/classes/share/javax/media/j3d/AlternateAppearance.java index e6d160c..fccc203 100644 --- a/src/classes/share/javax/media/j3d/AlternateAppearance.java +++ b/src/classes/share/javax/media/j3d/AlternateAppearance.java @@ -92,7 +92,13 @@ public class AlternateAppearance extends Leaf { public static final int ALLOW_SCOPE_WRITE = CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_SCOPE_WRITE; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_INFLUENCING_BOUNDS_READ, + ALLOW_APPEARANCE_READ, + ALLOW_SCOPE_READ + }; + /** * Constructs an AlternateAppearance node with default * parameters. The default values are as follows: @@ -106,28 +112,30 @@ public class AlternateAppearance extends Leaf { */ public AlternateAppearance() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } - - /** - * Creates the retained mode AlternateAppearanceRetained object that this - * Alternate Appearance component object will point to. - */ - void createRetained() { - this.retained = new AlternateAppearanceRetained(); - this.retained.setSource(this); - } - - /** * Constructs an AlternateAppearance node with the specified appearance. * @param appearance the appearance that is used for those nodes affected * by this AlternateAppearance node. */ public AlternateAppearance(Appearance appearance) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); ((AlternateAppearanceRetained)retained).initAppearance(appearance); } + /** + * Creates the retained mode AlternateAppearanceRetained object that this + * Alternate Appearance component object will point to. + */ + void createRetained() { + this.retained = new AlternateAppearanceRetained(); + this.retained.setSource(this); + } /** * Sets the appearance of this AlternateAppearance node. diff --git a/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java b/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java index 0b88951..b7d17bf 100644 --- a/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java +++ b/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java @@ -803,7 +803,7 @@ class AlternateAppearanceRetained extends LeafRetained { // AlternateAppearance alternate appearance = (AlternateAppearance) originalNode; -// // TODO: clone appearance +// // XXXX: clone appearance // setInfluencingBounds(alternate appearance.getInfluencingBounds()); diff --git a/src/classes/share/javax/media/j3d/Appearance.java b/src/classes/share/javax/media/j3d/Appearance.java index cb24eba..88aea7b 100644 --- a/src/classes/share/javax/media/j3d/Appearance.java +++ b/src/classes/share/javax/media/j3d/Appearance.java @@ -285,7 +285,21 @@ public class Appearance extends NodeComponent { public static final int ALLOW_TEXTURE_UNIT_STATE_WRITE = CapabilityBits.APPEARANCE_ALLOW_TEXTURE_UNIT_STATE_WRITE; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COLORING_ATTRIBUTES_READ, + ALLOW_LINE_ATTRIBUTES_READ, + ALLOW_MATERIAL_READ, + ALLOW_POINT_ATTRIBUTES_READ, + ALLOW_POLYGON_ATTRIBUTES_READ, + ALLOW_RENDERING_ATTRIBUTES_READ, + ALLOW_TEXGEN_READ, + ALLOW_TEXTURE_ATTRIBUTES_READ, + ALLOW_TEXTURE_READ, + ALLOW_TEXTURE_UNIT_STATE_READ, + ALLOW_TRANSPARENCY_ATTRIBUTES_READ + }; + /** * Constructs an Appearance component object using defaults for all * state variables. All component object references are initialized @@ -293,6 +307,8 @@ public class Appearance extends NodeComponent { */ public Appearance() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -919,7 +935,7 @@ public class Appearance extends NodeComponent { if ((nc != null) && nc.getDuplicateOnCloneTree()) return true; - // TODO: TextureUnitState + // XXXX: TextureUnitState return false; } diff --git a/src/classes/share/javax/media/j3d/AppearanceRetained.java b/src/classes/share/javax/media/j3d/AppearanceRetained.java index cc0489e..215c8eb 100644 --- a/src/classes/share/javax/media/j3d/AppearanceRetained.java +++ b/src/classes/share/javax/media/j3d/AppearanceRetained.java @@ -83,9 +83,6 @@ class AppearanceRetained extends NodeComponentRetained { static final int POINT = 0x0200; static final int TEXTURE_UNIT_STATE = 0x0400; - static final int ALL_COMPONENTS = (MATERIAL|TEXTURE|TEXCOORD_GEN|TEXTURE_ATTR|COLOR|TRANSPARENCY| - RENDERING|POLYGON|LINE|POINT|TEXTURE_UNIT_STATE); - static final int ALL_SOLE_USERS = 0; // A pointer to the scene graph appearance object @@ -876,11 +873,18 @@ class AppearanceRetained extends NodeComponentRetained { } + void setLive(boolean backgroundGroup, int refCount) { + // System.out.println("AppearceRetained.setLive()"); + doSetLive(backgroundGroup, refCount); + markAsLive(); + } + /** - * This setLive routine first calls the superclass's method, then - * it adds itself to the list of lights + * This method calls the setLive method of all appearance bundle + * objects. */ - void setLive(boolean backgroundGroup, int refCount) { + void doSetLive(boolean backgroundGroup, int refCount) { + // System.out.println("AppearceRetained.doSetLive()"); if (material != null) { @@ -938,12 +942,11 @@ class AppearanceRetained extends NodeComponentRetained { // Increment the reference count and initialize the appearance // mirror object super.doSetLive(backgroundGroup, refCount); - super.markAsLive(); } /** - * This clearLive routine first calls the superclass's method, then - * it removes itself to the list of lights + * This method calls the clearLive method of all appearance bundle + * objects. */ void clearLive(int refCount) { super.clearLive(refCount); diff --git a/src/classes/share/javax/media/j3d/AttributeBin.java b/src/classes/share/javax/media/j3d/AttributeBin.java index 8e98708..cc1afd4 100644 --- a/src/classes/share/javax/media/j3d/AttributeBin.java +++ b/src/classes/share/javax/media/j3d/AttributeBin.java @@ -28,6 +28,11 @@ class AttributeBin extends Object implements ObjectUpdate { RenderingAttributesRetained definingRenderingAttributes = null; /** + * The RenderBin for this object + */ + RenderBin renderBin = null; + + /** * The EnvirionmentSet that this AttributeBin resides */ EnvironmentSet environmentSet = null; @@ -40,21 +45,14 @@ class AttributeBin extends Object implements ObjectUpdate { AttributeBin prev = null; /** - * The list of TextureBins in this AttributeBin + * The list of ShaderBins in this AttributeBin */ - TextureBin textureBinList = null; - + ShaderBin shaderBinList = null; /** - * The list of TextureBins to be added for the next frame + * List of shaderBins to be added next frame */ - ArrayList addTextureBins = new ArrayList(); - - /** - * List of TextureBins to be added next frame - */ - ArrayList addTBs = new ArrayList(); - + ArrayList addShaderBins = new ArrayList(); /** * If the RenderingAttribute component of the appearance will be changed @@ -63,11 +61,6 @@ class AttributeBin extends Object implements ObjectUpdate { boolean soleUser = false; AppearanceRetained app = null; - /** - * List of TextureBins to be removeded next frame - */ - ArrayList removeTBs = new ArrayList(); - int onUpdateList = 0; static int ON_OBJ_UPDATE_LIST = 0x1; static int ON_CHANGED_FREQUENT_UPDATE_LIST = 0x2; @@ -76,44 +69,45 @@ class AttributeBin extends Object implements ObjectUpdate { // for whether the definingRendering attrs is non-null; boolean ignoreVertexColors = false; - // TODO: use definingMaterial etc. instead of these + // XXXX: use definingMaterial etc. instead of these // when sole user is completely implement RenderingAttributesRetained renderingAttrs; - int numEditingTextureBins = 0; - - + int numEditingShaderBins = 0; AttributeBin(AppearanceRetained app, RenderingAttributesRetained renderingAttributes, RenderBin rBin) { + reset(app, renderingAttributes, rBin); } void reset(AppearanceRetained app, RenderingAttributesRetained renderingAttributes, RenderBin rBin) { prev = null; next = null; - textureBinList = null; + shaderBinList = null; onUpdateList = 0; - numEditingTextureBins = 0; + numEditingShaderBins = 0; renderingAttrs = renderingAttributes; + renderBin = rBin; + if (app != null) { soleUser = ((app.changedFrequent & AppearanceRetained.RENDERING) != 0); } else { soleUser = false; } - // System.out.println("soleUser = "+soleUser+" renderingAttributes ="+renderingAttributes); + //System.out.println("soleUser = "+soleUser+" renderingAttributes ="+renderingAttributes); // Set the appearance only for soleUser case if (soleUser) this.app = app; else app = null; - + if (renderingAttributes != null) { if (renderingAttributes.changedFrequent != 0) { definingRenderingAttributes = renderingAttributes; if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0 ) { - rBin.aBinUpdateList.add(this); + renderBin.aBinUpdateList.add(this); onUpdateList |= AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST; } } @@ -140,10 +134,9 @@ class AttributeBin extends Object implements ObjectUpdate { // If the any reference to the appearance components that is cached renderMolecule // can change frequently, make a separate bin - // If the any reference to the appearance components that is cached renderMolecule - // can change frequently, make a separate bin if (soleUser || (ra.geometryAtom.source.appearance != null && - ((ra.geometryAtom.source.appearance.changedFrequent & AppearanceRetained.RENDERING) != 0))) { + ((ra.geometryAtom.source.appearance.changedFrequent & + AppearanceRetained.RENDERING) != 0))) { if (app == (Object)ra.geometryAtom.source.appearance) { // if this AttributeBin is currently on a zombie state, @@ -156,9 +149,9 @@ class AttributeBin extends Object implements ObjectUpdate { // attributes reference change would not have reflected to // the AttributeBin - if (numEditingTextureBins == 0) { + if (numEditingShaderBins == 0) { if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0) { - environmentSet.renderBin.aBinUpdateList.add(this); + renderBin.aBinUpdateList.add(this); onUpdateList |= AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST; } @@ -180,7 +173,7 @@ class AttributeBin extends Object implements ObjectUpdate { if (definingRenderingAttributes == renderingAttributes) { if (definingRenderingAttributes.compChanged != 0) { if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0 ) { - environmentSet.renderBin.aBinUpdateList.add(this); + renderBin.aBinUpdateList.add(this); onUpdateList |= AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST; } } @@ -196,127 +189,56 @@ class AttributeBin extends Object implements ObjectUpdate { return false; } - - return (true); } - public void updateObject() { + ShaderBin sb; TextureBin t; - int i; + int i, size; - if (addTBs.size() > 0) { - t = (TextureBin)addTBs.get(0); - if (textureBinList == null) { - textureBinList = t; - + size = addShaderBins.size(); + if (size > 0) { + sb = (ShaderBin)addShaderBins.get(0); + if (shaderBinList == null) { + shaderBinList = sb; } else { - // Look for a TextureBin that has the same texture - insertTextureBin(t); - } - for (i = 1; i < addTBs.size() ; i++) { - t = (TextureBin)addTBs.get(i); - // Look for a TextureBin that has the same texture - insertTextureBin(t); - + sb.next = shaderBinList; + shaderBinList.prev = sb; + shaderBinList = sb; } - } - addTBs.clear(); - onUpdateList &= ~ON_OBJ_UPDATE_LIST; - } - - void insertTextureBin(TextureBin t) { - TextureBin tb; - int i; - TextureRetained texture = null; - - if (t.texUnitState != null && t.texUnitState.length > 0) { - if (t.texUnitState[0] != null) { - texture = t.texUnitState[0].texture; + + for (i = 1; i < size ; i++) { + sb = (ShaderBin)addShaderBins.get(i); + sb.next = shaderBinList; + shaderBinList.prev = sb; + shaderBinList = sb; } } - - // use the texture in the first texture unit as the sorting criteria - if (texture != null) { - tb = textureBinList; - while (tb != null) { - if (tb.texUnitState == null || tb.texUnitState[0] == null || - tb.texUnitState[0].texture != texture) { - tb = tb.next; - } else { - // put it here - t.next = tb; - t.prev = tb.prev; - if (tb.prev == null) { - textureBinList = t; - } - else { - tb.prev.next = t; - } - tb.prev = t; - return; - } - } - } - // Just put it up front - t.prev = null; - t.next = textureBinList; - textureBinList.prev = t; - textureBinList = t; - - t.tbFlag &= ~TextureBin.RESORT; + addShaderBins.clear(); + onUpdateList &= ~ON_OBJ_UPDATE_LIST; } /** - * reInsert textureBin if the first texture is different from - * the previous bin and different from the next bin + * Adds the given shaderBin to this AttributeBin. */ - void reInsertTextureBin(TextureBin tb) { - - TextureRetained texture = null, - prevTexture = null, - nextTexture = null; - - if (tb.texUnitState != null && tb.texUnitState[0] != null) { - texture = tb.texUnitState[0].texture; - } - - if (tb.prev != null && tb.prev.texUnitState != null) { - prevTexture = tb.prev.texUnitState[0].texture; - } - - if (texture != prevTexture) { - if (tb.next != null && tb.next.texUnitState != null) { - nextTexture = tb.next.texUnitState[0].texture; - } - if (texture != nextTexture) { - if (tb.prev != null && tb.next != null) { - tb.prev.next = tb.next; - tb.next.prev = tb.prev; - insertTextureBin(tb); - } - } - } - } + void addShaderBin(ShaderBin sb, RenderBin rb, ShaderAppearanceRetained sApp) { + sb.attributeBin = this; - /** - * Adds the given TextureBin to this AttributeBin. - */ - void addTextureBin(TextureBin t, RenderBin rb, RenderAtom ra) { - int i; - t.attributeBin = this; - AppearanceRetained raApp = ra.geometryAtom.source.appearance; - RenderingAttributesRetained rAttrs = - (raApp == null)? null : raApp.renderingAttributes; - if (!soleUser && renderingAttrs != rAttrs) { - // no longer sole user - renderingAttrs = definingRenderingAttributes; + if(sApp != null) { + // ShaderBin should reference to the mirror components. -- JADA. + // System.out.println("AttributeBin : sApp.isMirror = " + sApp.isMirror); + assert(sApp.isMirror); + sb.shaderProgram = sApp.shaderProgram; + sb.shaderAttributeSet = sApp.shaderAttributeSet; } - addTBs.add(t); + sb.shaderAppearance = sApp; + + // TODO : JADA - sort by ShaderProgram to avoid state trashing. + addShaderBins.add(sb); if ((onUpdateList & ON_OBJ_UPDATE_LIST) == 0) { onUpdateList |= ON_OBJ_UPDATE_LIST; rb.objUpdateList.add(this); @@ -324,41 +246,35 @@ class AttributeBin extends Object implements ObjectUpdate { } + /** - * Removes the given TextureBin from this AttributeBin. + * Removes the given shaderBin from this AttributeBin. */ - void removeTextureBin(TextureBin t) { - - int i; - TextureRetained tex; + void removeShaderBin(ShaderBin sb) { - t.attributeBin = null; - // If the TextureBin being remove is contained in addTBs, then - // remove the TextureBin from the addList - if (addTBs.contains(t)) { - addTBs.remove(addTBs.indexOf(t)); + // If the shaderBin being remove is contained in addShaderBins, + // then remove the shadereBin from the addList + if (addShaderBins.contains(sb)) { + addShaderBins.remove(addShaderBins.indexOf(sb)); } else { - if (t.prev == null) { // At the head of the list - textureBinList = t.next; - if (t.next != null) { - t.next.prev = null; + if (sb.prev == null) { // At the head of the list + shaderBinList = sb.next; + if (sb.next != null) { + sb.next.prev = null; } } else { // In the middle or at the end. - t.prev.next = t.next; - if (t.next != null) { - t.next.prev = t.prev; + sb.prev.next = sb.next; + if (sb.next != null) { + sb.next.prev = sb.prev; } } } - t.prev = null; - t.next = null; - t.clear(); + sb.clear(); + renderBin.shaderBinFreelist.add(sb); - environmentSet.renderBin.textureBinFreelist.add(t); - - if (textureBinList == null && addTBs.size() == 0 ) { + if (shaderBinList == null && addShaderBins.size() == 0 ) { // Note: Removal of this attributebin as a user of the rendering // atttrs is done during removeRenderAtom() in RenderMolecule.java environmentSet.removeAttributeBin(this); @@ -370,14 +286,14 @@ class AttributeBin extends Object implements ObjectUpdate { */ void render(Canvas3D cv) { - TextureBin t; + ShaderBin sb; boolean visible = (definingRenderingAttributes == null || definingRenderingAttributes.visible); - if ( (environmentSet.renderBin.view.viewCache.visibilityPolicy + if ( (renderBin.view.viewCache.visibilityPolicy == View.VISIBILITY_DRAW_VISIBLE && !visible) || - (environmentSet.renderBin.view.viewCache.visibilityPolicy + (renderBin.view.viewCache.visibilityPolicy == View.VISIBILITY_DRAW_INVISIBLE && visible)) { return; } @@ -386,15 +302,16 @@ class AttributeBin extends Object implements ObjectUpdate { // include this AttributeBin to the to-be-updated list in Canvas cv.setStateToUpdate(Canvas3D.ATTRIBUTEBIN_BIT, this); - t = textureBinList; - while (t != null) { - t.render(cv); - t = t.next; + sb = shaderBinList; + while (sb != null) { + sb.render(cv); + sb = sb.next; } } void updateAttributes(Canvas3D cv) { + if ((cv.canvasDirty & Canvas3D.ATTRIBUTEBIN_DIRTY) != 0) { // Update Attribute Bundles if (definingRenderingAttributes == null) { @@ -403,7 +320,7 @@ class AttributeBin extends Object implements ObjectUpdate { cv.depthBufferEnableOverride); } else { definingRenderingAttributes.updateNative( - cv.ctx, + cv, cv.depthBufferWriteEnableOverride, cv.depthBufferEnableOverride); } @@ -420,7 +337,7 @@ class AttributeBin extends Object implements ObjectUpdate { cv.depthBufferEnableOverride); } else { definingRenderingAttributes.updateNative( - cv.ctx, + cv, cv.depthBufferWriteEnableOverride, cv.depthBufferEnableOverride); } @@ -465,11 +382,23 @@ class AttributeBin extends Object implements ObjectUpdate { onUpdateList &= ~ON_CHANGED_FREQUENT_UPDATE_LIST; } - void incrActiveTextureBin() { - numEditingTextureBins++; + void incrActiveShaderBin() { + numEditingShaderBins++; } - void decrActiveTextureBin() { - numEditingTextureBins--; + void decrActiveShaderBin() { + numEditingShaderBins--; + } + + void updateFromShaderBin(RenderAtom ra) { + + AppearanceRetained raApp = ra.geometryAtom.source.appearance; + RenderingAttributesRetained rAttrs = + (raApp == null)? null : raApp.renderingAttributes; + + if (!soleUser && renderingAttrs != rAttrs) { + // no longer sole user + renderingAttrs = definingRenderingAttributes; + } } } diff --git a/src/classes/share/javax/media/j3d/AuralAttributes.java b/src/classes/share/javax/media/j3d/AuralAttributes.java index 89384e6..289383f 100644 --- a/src/classes/share/javax/media/j3d/AuralAttributes.java +++ b/src/classes/share/javax/media/j3d/AuralAttributes.java @@ -473,6 +473,24 @@ public class AuralAttributes extends NodeComponent { public static final int ALLOW_VELOCITY_SCALE_FACTOR_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_VELOCITY_SCALE_FACTOR_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ATTRIBUTE_GAIN_READ, + ALLOW_DECAY_FILTER_READ, + ALLOW_DECAY_TIME_READ, + ALLOW_DENSITY_READ, + ALLOW_DIFFUSION_READ, + ALLOW_DISTANCE_FILTER_READ, + ALLOW_FREQUENCY_SCALE_FACTOR_READ, + ALLOW_REFLECTION_COEFFICIENT_READ, + ALLOW_REFLECTION_DELAY_READ, + ALLOW_REVERB_COEFFICIENT_READ, + ALLOW_REVERB_DELAY_READ, + ALLOW_REVERB_ORDER_READ, + ALLOW_ROLLOFF_READ, + ALLOW_VELOCITY_SCALE_FACTOR_READ + }; + /** ***************** * * Constructors @@ -501,6 +519,8 @@ public class AuralAttributes extends NodeComponent { */ public AuralAttributes() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -523,6 +543,9 @@ public class AuralAttributes extends NodeComponent { Point2f[] distanceFilter, float frequencyScaleFactor, float velocityScaleFactor) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((AuralAttributesRetained)this.retained).setAttributeGain(gain); ((AuralAttributesRetained)this.retained).setRolloff(rolloff); ((AuralAttributesRetained)this.retained).setReflectionCoefficient( @@ -558,6 +581,9 @@ public class AuralAttributes extends NodeComponent { float[] frequencyCutoff, float frequencyScaleFactor, float velocityScaleFactor) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((AuralAttributesRetained)this.retained).setAttributeGain(gain); ((AuralAttributesRetained)this.retained).setRolloff(rolloff); ((AuralAttributesRetained)this.retained).setReflectionCoefficient( @@ -606,6 +632,9 @@ public class AuralAttributes extends NodeComponent { float[] frequencyCutoff, float frequencyScaleFactor, float velocityScaleFactor) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((AuralAttributesRetained)this.retained).setAttributeGain(gain); ((AuralAttributesRetained)this.retained).setRolloff(rolloff); ((AuralAttributesRetained)this.retained).setReflectionCoefficient( diff --git a/src/classes/share/javax/media/j3d/AuralAttributesRetained.java b/src/classes/share/javax/media/j3d/AuralAttributesRetained.java index 3b23c51..eb88987 100644 --- a/src/classes/share/javax/media/j3d/AuralAttributesRetained.java +++ b/src/classes/share/javax/media/j3d/AuralAttributesRetained.java @@ -642,7 +642,7 @@ class AuralAttributesRetained extends NodeComponentRetained { else if (debugFlag) debugPrint("reset aa; aa.frequencyCutoff = null"); - // TODO: (Enhancement) Why are these dirtyFlag cleared rather than aa->this + // XXXX: (Enhancement) Why are these dirtyFlag cleared rather than aa->this this.aaDirty = false; aa.aaDirty = false; } diff --git a/src/classes/share/javax/media/j3d/Background.java b/src/classes/share/javax/media/j3d/Background.java index f50a9b3..c9a2bdd 100644 --- a/src/classes/share/javax/media/j3d/Background.java +++ b/src/classes/share/javax/media/j3d/Background.java @@ -228,6 +228,16 @@ public class Background extends Leaf { */ public static final int SCALE_NONE_CENTER = 5; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_APPLICATION_BOUNDS_READ, + ALLOW_COLOR_READ, + ALLOW_GEOMETRY_READ, + ALLOW_IMAGE_READ, + ALLOW_IMAGE_SCALE_MODE_READ + }; + + /** * Constructs a Background node with default parameters. The default * values are as follows: @@ -242,6 +252,8 @@ public class Background extends Leaf { */ public Background () { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -250,7 +262,10 @@ public class Background extends Leaf { * objects in the scene. */ public Background(Color3f color) { - ((BackgroundRetained)this.retained).setColor(color); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((BackgroundRetained)this.retained).setColor(color); } /** @@ -259,7 +274,10 @@ public class Background extends Leaf { * objects in the scene. */ public Background(float r, float g, float b) { - ((BackgroundRetained)this.retained).setColor(r, g, b); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((BackgroundRetained)this.retained).setColor(r, g, b); } /** @@ -273,7 +291,10 @@ public class Background extends Leaf { * @param image pixel array object used as the background image */ public Background(ImageComponent2D image) { - ((BackgroundRetained)this.retained).setImage(image); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((BackgroundRetained)this.retained).setImage(image); } /** @@ -290,7 +311,10 @@ public class Background extends Leaf { * contains an illegal node. */ public Background(BranchGroup branch) { - ((BackgroundRetained)this.retained).setGeometry(branch); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((BackgroundRetained)this.retained).setGeometry(branch); } /** diff --git a/src/classes/share/javax/media/j3d/BehaviorStructure.java b/src/classes/share/javax/media/j3d/BehaviorStructure.java index a8e9389..24a56c2 100644 --- a/src/classes/share/javax/media/j3d/BehaviorStructure.java +++ b/src/classes/share/javax/media/j3d/BehaviorStructure.java @@ -667,7 +667,7 @@ class BehaviorStructure extends J3dStructure { if (awtCond.AwtId != 0) { if (awtCond.AwtId == id) { - // TODO: how do we clone this event (do we need to?) + // XXXX: how do we clone this event (do we need to?) // Bug: 4181321 awtCond.addAWTEvent(evt); } diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java index 7e4e88a..3bd5e15 100644 --- a/src/classes/share/javax/media/j3d/BoundingBox.java +++ b/src/classes/share/javax/media/j3d/BoundingBox.java @@ -215,7 +215,7 @@ public class BoundingBox extends Bounds { else if(bounds[i].boundId == BOUNDING_POLYTOPE) { BoundingPolytope polytope = (BoundingPolytope)bounds[i]; - for(i=0;i<polytope.nVerts;i++) { // TODO handle polytope with no verts + for(i=0;i<polytope.nVerts;i++) { // XXXX: handle polytope with no verts if( polytope.verts[i].x < lower.x ) lower.x = polytope.verts[i].x; if( polytope.verts[i].y < lower.y ) diff --git a/src/classes/share/javax/media/j3d/BoundingLeaf.java b/src/classes/share/javax/media/j3d/BoundingLeaf.java index 9015202..80c35a1 100644 --- a/src/classes/share/javax/media/j3d/BoundingLeaf.java +++ b/src/classes/share/javax/media/j3d/BoundingLeaf.java @@ -50,10 +50,18 @@ public class BoundingLeaf extends Leaf { public static final int ALLOW_REGION_WRITE = CapabilityBits.BOUNDING_LEAF_ALLOW_REGION_WRITE; - /** + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_REGION_READ + }; + + /** * Constructs a BoundingLeaf node with a null (empty) bounding region. */ public BoundingLeaf() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((BoundingLeafRetained)this.retained).createBoundingLeaf(); } @@ -62,6 +70,9 @@ public class BoundingLeaf extends Leaf { * @param region the bounding region of this leaf node */ public BoundingLeaf(Bounds region) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((BoundingLeafRetained)this.retained).createBoundingLeaf(); ((BoundingLeafRetained)this.retained).initRegion(region); } diff --git a/src/classes/share/javax/media/j3d/BoundingPolytope.java b/src/classes/share/javax/media/j3d/BoundingPolytope.java index 491f85a..fbed7f3 100644 --- a/src/classes/share/javax/media/j3d/BoundingPolytope.java +++ b/src/classes/share/javax/media/j3d/BoundingPolytope.java @@ -76,7 +76,7 @@ public class BoundingPolytope extends Bounds { planes[i].z*invMag, planes[i].w*invMag ); } - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } /** @@ -111,7 +111,7 @@ public class BoundingPolytope extends Bounds { mag[4] = 1.0; mag[5] = 1.0; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } @@ -131,7 +131,7 @@ public class BoundingPolytope extends Bounds { boundsIsEmpty = true; boundsIsInfinite = false; initEmptyPolytope(); - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate return; } @@ -156,7 +156,7 @@ public class BoundingPolytope extends Bounds { mag[3] = 1.0; mag[4] = 1.0; mag[5] = 1.0; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if( boundsObject.boundId == BOUNDING_BOX ){ BoundingBox box = (BoundingBox)boundsObject; @@ -176,7 +176,7 @@ public class BoundingPolytope extends Bounds { mag[3] = 1.0; mag[4] = 1.0; mag[5] = 1.0; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if( boundsObject.boundId == BOUNDING_POLYTOPE ) { BoundingPolytope polytope = (BoundingPolytope)boundsObject; @@ -215,7 +215,7 @@ public class BoundingPolytope extends Bounds { boundsIsEmpty = true; boundsIsInfinite = false; initEmptyPolytope(); - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate return; } // find first non empty bounds object @@ -227,7 +227,7 @@ public class BoundingPolytope extends Bounds { boundsIsEmpty = true; boundsIsInfinite = false; initEmptyPolytope(); - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate return; } @@ -253,7 +253,7 @@ public class BoundingPolytope extends Bounds { mag[4] = 1.0; mag[5] = 1.0; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if( boundsObjects[i].boundId == BOUNDING_BOX ){ BoundingBox box = (BoundingBox)boundsObjects[i]; planes = new Vector4d[6]; @@ -273,7 +273,7 @@ public class BoundingPolytope extends Bounds { mag[4] = 1.0; mag[5] = 1.0; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if( boundsObjects[i].boundId == BOUNDING_POLYTOPE ) { BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i]; planes = new Vector4d[polytope.planes.length]; @@ -320,7 +320,7 @@ public class BoundingPolytope extends Bounds { if( planes.length <= 0 ) { boundsIsEmpty = true; boundsIsInfinite = false; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate return; } @@ -332,7 +332,7 @@ public class BoundingPolytope extends Bounds { this.planes[i] = new Vector4d( planes[i].x*invMag, planes[i].y*invMag, planes[i].z*invMag, planes[i].w*invMag ); } - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } @@ -373,7 +373,7 @@ public class BoundingPolytope extends Bounds { if( boundsObject == null ) { boundsIsEmpty = true; boundsIsInfinite = false; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate }else if( boundsObject.boundId == BOUNDING_SPHERE ) { BoundingSphere sphere = (BoundingSphere)boundsObject; @@ -391,7 +391,7 @@ public class BoundingPolytope extends Bounds { boundsIsEmpty = boundsObject.boundsIsEmpty; boundsIsInfinite = boundsObject.boundsIsInfinite; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if( boundsObject.boundId == BOUNDING_BOX){ BoundingBox box = (BoundingBox)boundsObject; @@ -422,7 +422,7 @@ public class BoundingPolytope extends Bounds { boundsIsEmpty = boundsObject.boundsIsEmpty; boundsIsInfinite = boundsObject.boundsIsInfinite; - computeAllVerts(); // TODO lazy evaluate + computeAllVerts(); // XXXX: lazy evaluate } else if(boundsObject.boundId == BOUNDING_POLYTOPE) { BoundingPolytope polytope = (BoundingPolytope)boundsObject; @@ -1627,7 +1627,7 @@ public class BoundingPolytope extends Bounds { } } } - // TODO correctly compute centroid + // XXXX: correctly compute centroid x=y=z=0.0; Point3d newVerts[] = new Point3d[nVerts]; diff --git a/src/classes/share/javax/media/j3d/BoundingSphere.java b/src/classes/share/javax/media/j3d/BoundingSphere.java index 79dd8fb..67b9d5c 100644 --- a/src/classes/share/javax/media/j3d/BoundingSphere.java +++ b/src/classes/share/javax/media/j3d/BoundingSphere.java @@ -1073,7 +1073,7 @@ public class BoundingSphere extends Bounds { Point3d dir = new Point3d(); // normalized direction of ray Point3d oc = new Point3d(); // vector from sphere center to ray origin - oc.x = center.x - origin.x; // TODO check if this method is still needed + oc.x = center.x - origin.x; // XXXX: check if this method is still needed oc.y = center.y - origin.y; oc.z = center.z - origin.z; diff --git a/src/classes/share/javax/media/j3d/BranchGroup.java b/src/classes/share/javax/media/j3d/BranchGroup.java index 92004fd..1c58feb 100644 --- a/src/classes/share/javax/media/j3d/BranchGroup.java +++ b/src/classes/share/javax/media/j3d/BranchGroup.java @@ -86,22 +86,63 @@ public class BranchGroup extends Group { * Detaches this BranchGroup from its parent. */ public void detach() { - Group parent; - - if (isLiveOrCompiled()) { - if(!this.getCapability(ALLOW_DETACH)) - throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup1")); - - if (((BranchGroupRetained)this.retained).parent != null) { - parent = (Group)((BranchGroupRetained)this.retained).parent.source; - if(!parent.getCapability(Group.ALLOW_CHILDREN_WRITE)) - throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup2")); - } - } + Group parent; + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_DETACH)) + throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup1")); + + if (((BranchGroupRetained)this.retained).parent != null) { + parent = (Group)((BranchGroupRetained)this.retained).parent.source; + if(!parent.getCapability(Group.ALLOW_CHILDREN_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup2")); + } + } + + ((BranchGroupRetained)this.retained).detach(); + } + + + void validateModeFlagAndPickShape(int mode, int flags, PickShape pickShape) { - ((BranchGroupRetained)this.retained).detach(); - } + if(isLive()==false) { + throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); + } + + if((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) { + + throw new IllegalArgumentException(J3dI18N.getString("BranchGroup4")); + } + + if((pickShape instanceof PickPoint) && (mode == PickInfo.PICK_GEOMETRY)) { + throw new IllegalArgumentException(J3dI18N.getString("BranchGroup5")); + } + + if(((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) && + ((flags & PickInfo.ALL_GEOM_INFO) != 0)) { + throw new IllegalArgumentException(J3dI18N.getString("BranchGroup6")); + } + + if((mode == PickInfo.PICK_BOUNDS) && + (((flags & (PickInfo.CLOSEST_GEOM_INFO | + PickInfo.ALL_GEOM_INFO | + PickInfo.CLOSEST_DISTANCE | + PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { + + throw new IllegalArgumentException(J3dI18N.getString("BranchGroup7")); + } + + if((pickShape instanceof PickBounds) && + (((flags & (PickInfo.CLOSEST_GEOM_INFO | + PickInfo.ALL_GEOM_INFO | + PickInfo.CLOSEST_DISTANCE | + PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { + + throw new IllegalArgumentException(J3dI18N.getString("BranchGroup8")); + } + } + /** * Returns an array referencing all the items that are pickable below this * <code>BranchGroup</code> that intersect with PickShape. @@ -116,12 +157,91 @@ public class BranchGroup extends Group { * */ public SceneGraphPath[] pickAll( PickShape pickShape ) { + if(isLive()==false) throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); + + return ((BranchGroupRetained)this.retained).pickAll(pickShape); + + } - return Picking.pickAll( this, pickShape ); + /** + * Returns an array unsorted references to all the PickInfo objects that are + * pickable below this <code>BranchGroup</code> that intersect with PickShape. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if BranchGroup is not live. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see Locale#pickAll(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + + public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + return ((BranchGroupRetained)this.retained).pickAll(mode, flags, pickShape); + } + /** * Returns a sorted array of references to all the Pickable items that * intersect with the pickShape. Element [0] references the item closest @@ -139,10 +259,90 @@ public class BranchGroup extends Group { * */ public SceneGraphPath[] pickAllSorted( PickShape pickShape ) { + if(isLive()==false) - throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); - - return Picking.pickAllSorted( this, pickShape ); + throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); + + return ((BranchGroupRetained)this.retained).pickAllSorted(pickShape); + + } + + + /** + * Returns a sorted array of PickInfo references to all the pickable + * items that intersect with the pickShape. Element [0] references + * the item closest to <i>origin</i> of PickShape successive array + * elements are further from the <i>origin</i> + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if BranchGroup is not live. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see Locale#pickAllSorted(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + return ((BranchGroupRetained)this.retained).pickAllSorted(mode, flags, pickShape); + } /** @@ -160,17 +360,95 @@ public class BranchGroup extends Group { * */ public SceneGraphPath pickClosest( PickShape pickShape ) { + if(isLive()==false) throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); - return Picking.pickClosest( this, pickShape ); + return ((BranchGroupRetained)this.retained).pickClosest(pickShape); + } + /** + * Returns a PickInfo which references the pickable item + * which is closest to the origin of <code>pickShape</code>. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if BranchGroup is not live. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see Locale#pickClosest(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + return ((BranchGroupRetained)this.retained).pickClosest(mode, flags, pickShape); + + } + + /** * Returns a reference to any item that is Pickable below this BranchGroup that * intersects with <code>pickShape</code>. - * * @param pickShape the PickShape object + * * @see SceneGraphPath * @see Locale#pickAny * @see PickShape @@ -178,12 +456,88 @@ public class BranchGroup extends Group { * */ public SceneGraphPath pickAny( PickShape pickShape ) { + if(isLive()==false) throw new IllegalStateException(J3dI18N.getString("BranchGroup3")); + + return ((BranchGroupRetained)this.retained).pickAny(pickShape); - return Picking.pickAny( this, pickShape ); } + /** + * Returns a PickInfo which references the pickable item below this + * BranchGroup that intersects with <code>pickShape</code>. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if BranchGroup is not live. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see Locale#pickAny(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo pickAny( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + return ((BranchGroupRetained)this.retained).pickAny(mode, flags, pickShape); + + } /** * Creates a new instance of the node. This routine is called @@ -200,8 +554,11 @@ public class BranchGroup extends Group { * @see NodeComponent#setDuplicateOnCloneTree */ public Node cloneNode(boolean forceDuplicate) { + BranchGroup bg = new BranchGroup(); bg.duplicateNode(this, forceDuplicate); return bg; + } + } diff --git a/src/classes/share/javax/media/j3d/BranchGroupRetained.java b/src/classes/share/javax/media/j3d/BranchGroupRetained.java index 5d1aa84..696ba49 100644 --- a/src/classes/share/javax/media/j3d/BranchGroupRetained.java +++ b/src/classes/share/javax/media/j3d/BranchGroupRetained.java @@ -58,11 +58,18 @@ class BranchGroupRetained extends GroupRetained { if (universe != null) { universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { - if (source.isLive()) { + boolean isLive = source.isLive(); + if (isLive) { notifySceneGraphChanged(true); } + GroupRetained oldParent = (GroupRetained)parent; do_detach(); universe.setLiveState.clear(); + if (isLive) + if (oldParent==null) + universe.notifyStructureChangeListeners(false,locale,(BranchGroup)this.source); + else + universe.notifyStructureChangeListeners(false,oldParent.source, (BranchGroup)this.source); } universe.waitForMC(); } else { // Not live yet, just do it. @@ -106,7 +113,7 @@ class BranchGroupRetained extends GroupRetained { setAuxData(s, j, hkIndex); } else { - // TODO: change this to an assertion exception + // XXXX: change this to an assertion exception System.out.println("Can't Find matching hashKey in setNodeData."); System.out.println("We're in TROUBLE!!!"); } @@ -206,4 +213,145 @@ class BranchGroupRetained extends GroupRetained { // without any capabilities set mergeFlag = SceneGraphObjectRetained.DONT_MERGE; } + + SceneGraphPath[] pickAll(PickShape pickShape) { + + PickInfo[] pickInfoArr = pickAll(PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfoArr == null) { + return null; + } + + SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length]; + for( int i=0; i<sgpArr.length; i++) { + sgpArr[i] = pickInfoArr[i].getSceneGraphPath(); + } + + return sgpArr; + } + + PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) { + + if (inSharedGroup) { + throw new RestrictedAccessException(J3dI18N.getString("BranchGroup9")); + } + + GeometryAtom geomAtoms[] = + locale.universe.geometryStructure.pickAll(locale, pickShape); + + return PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL); + + } + + SceneGraphPath[] pickAllSorted(PickShape pickShape) { + + PickInfo[] pickInfoArr = pickAllSorted(PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfoArr == null) { + return null; + } + + SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length]; + for( int i=0; i<sgpArr.length; i++) { + sgpArr[i] = pickInfoArr[i].getSceneGraphPath(); + } + + return sgpArr; + + } + + PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) { + + if (inSharedGroup) { + throw new RestrictedAccessException(J3dI18N.getString("BranchGroup9")); + } + + GeometryAtom geomAtoms[] = + locale.universe.geometryStructure.pickAll(locale, pickShape); + + PickInfo[] pickInfoArr = null; + + + if ((geomAtoms == null) || (geomAtoms.length == 0)) { + return null; + } + + if (mode == PickInfo.PICK_GEOMETRY) { + // Need to have closestDistance set + flags |= PickInfo.CLOSEST_DISTANCE; + pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, + pickShape, PickInfo.PICK_ALL); + if (pickInfoArr != null) { + PickInfo.sortPickInfoArray(pickInfoArr); + } + } + else { + PickInfo.sortGeomAtoms(geomAtoms, pickShape); + pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, + pickShape, PickInfo.PICK_ALL); + } + + return pickInfoArr; + + } + + SceneGraphPath pickClosest( PickShape pickShape ) { + + PickInfo pickInfo = pickClosest( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfo == null) { + return null; + } + + return pickInfo.getSceneGraphPath(); + + } + + PickInfo pickClosest( int mode, int flags, PickShape pickShape ) { + + PickInfo[] pickInfoArr = null; + + pickInfoArr = pickAllSorted( mode, flags, pickShape ); + + if(pickInfoArr == null) { + return null; + } + + return pickInfoArr[0]; + + } + + SceneGraphPath pickAny( PickShape pickShape ) { + + PickInfo pickInfo = pickAny( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfo == null) { + return null; + } + return pickInfo.getSceneGraphPath(); + } + + PickInfo pickAny( int mode, int flags, PickShape pickShape ) { + + if (inSharedGroup) { + throw new RestrictedAccessException(J3dI18N.getString("BranchGroup9")); + } + + GeometryAtom geomAtoms[] = + locale.universe.geometryStructure.pickAll(locale, pickShape); + + PickInfo[] pickInfoArr = PickInfo.pick(this, geomAtoms, mode, + flags, pickShape, PickInfo.PICK_ANY); + + if(pickInfoArr == null) { + return null; + } + + return pickInfoArr[0]; + + } } diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index 597fbd3..6d887b9 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -300,6 +300,7 @@ public class Canvas3D extends Canvas { static final int FOG_DIRTY = 0x2000; static final int MODELCLIP_DIRTY = 0x4000; static final int VIEW_MATRIX_DIRTY = 0x8000; + // static final int SHADER_DIRTY = 0x10000; Not ready for this yet -- JADA // Use to notify D3D Canvas when window change static final int RESIZE = 1; @@ -373,6 +374,18 @@ public class Canvas3D extends Canvas { // int monoscopicViewPolicy = View.CYCLOPEAN_EYE_VIEW; + // User requested stencil size + int requestedStencilSize; + + // Actual stencil size return for this canvas + int actualStencilSize; + + // True if stencil buffer is available for user + boolean userStencilAvailable; + + // True if stencil buffer is available for system ( decal ) + boolean systemStencilAvailable; + // // Read-only flag that indicates whether double buffering is supported // for this canvas. This is always false for off-screen canvases. @@ -409,17 +422,11 @@ public class Canvas3D extends Canvas { // int textureColorTableSize; - - boolean multiTexAccelerated = false; - - // number of simultaneous Texture unit support for this canvas. - int numTexUnitSupported = 1; - - // number of texture coords unit support for multi-texture. - int numTexCoordSupported = 1; - // a mapping between underlying graphics library texture unit and // texture unit state in j3d + // + // TODO: This mapping is now required to be 1-to-1, and it should be + // removed entirely in Java 3D 1.5 int[] texUnitStateMap = null; // number of active/enabled texture unit @@ -428,6 +435,10 @@ public class Canvas3D extends Canvas { // index iof last enabled texture unit int lastActiveTexUnit = -1; + // True if shadingLanguage is supported, otherwise false. + boolean shadingLanguageGLSL = false; + boolean shadingLanguageCg = false; + // Query properties J3dQueryProps queryProps; @@ -454,7 +465,10 @@ public class Canvas3D extends Canvas { // View cache for this canvas and its associated view. // CanvasViewCache canvasViewCache = null; - + + // Issue 109: View cache for this canvas, for computing view frustum planes + CanvasViewCache canvasViewCacheFrustum = null; + // Since multiple renderAtomListInfo, share the same vecBounds // we want to do the intersection test only once per renderAtom // this flag is set to true after the first intersect and set to @@ -488,7 +502,14 @@ public class Canvas3D extends Canvas { BACKGROUND_DIRTY | BACKGROUND_IMAGE_DIRTY); - int cvDirtyMask = VIEW_INFO_DIRTY; + // Issue 163: Array of dirty bits is used because the Renderer and + // RenderBin run asynchronously. Now that they each have a separate + // instance of CanvasViewCache (due to the fix for Issue 109), they + // need separate dirty bits. Array element 0 is used for the Renderer and + // element 1 is used for the RenderBin. + static final int RENDERER_DIRTY_IDX = 0; + static final int RENDER_BIN_DIRTY_IDX = 1; + int[] cvDirtyMask = new int[2]; // This boolean informs the J3DGraphics2DImpl that the window is resized boolean resizeGraphics2D = true; @@ -574,7 +595,8 @@ public class Canvas3D extends Canvas { // PixelFormat structure ( see also gldef.h ) to allow value such // as offScreen's pixelformat, and ARB function pointers to be stored. long fbConfig = 0; - + GraphicsConfigInfo gcInfo = null; + // offScreenBufferInfo is a pointer to additional information about the // offScreenBuffer in this Canvas. // @@ -587,6 +609,7 @@ public class Canvas3D extends Canvas { // doesn't exist at the time getBestConfiguration() is called, and // X11GraphicsConfig neither maintains this pointer nor provides a public // constructor to allow Java 3D to extend it. + // static Hashtable fbConfigInfoTable = new Hashtable(); -- Chien static Hashtable fbConfigTable = new Hashtable(); // The native graphics version, vendor, and renderer information @@ -631,6 +654,7 @@ public class Canvas3D extends Canvas { LightBin lightBin = null; EnvironmentSet environmentSet = null; AttributeBin attributeBin = null; + ShaderBin shaderBin = null; RenderMolecule renderMolecule = null; PolygonAttributesRetained polygonAttributes = null; LineAttributesRetained lineAttributes = null; @@ -641,7 +665,7 @@ public class Canvas3D extends Canvas { ColoringAttributesRetained coloringAttributes = null; Transform3D modelMatrix = null; TextureBin textureBin = null; - + /** * cached RenderBin states for lazy native states update @@ -652,7 +676,7 @@ public class Canvas3D extends Canvas { FogRetained fog = null; ModelClipRetained modelClip = null; Color3f sceneAmbient = new Color3f(); - TextureUnitStateRetained texUnitState[] = null; + TextureUnitStateRetained[] texUnitState = null; /** * cached View states for lazy native states update @@ -669,6 +693,8 @@ public class Canvas3D extends Canvas { TexCoordGenerationRetained texCoordGeneration = null; RenderingAttributesRetained renderingAttrs = null; AppearanceRetained appearance = null; + + ShaderProgramRetained shaderProgram = null; // only used in Mixed Mode rendering Object appHandle = null; @@ -678,6 +704,8 @@ public class Canvas3D extends Canvas { * Texture Generation linear mode. This is used for D3D * temporary turn displayList off and do its own coordinate * generation since D3D don't support it. + * + * TODO aces : is this still true in DX9? */ boolean texLinearMode = false; @@ -701,7 +729,9 @@ public class Canvas3D extends Canvas { // an unique bit to identify this canvas int canvasBit = 0; - + // an unique number to identify this canvas : ( canvasBit = 1 << canvasId) + int canvasId = 0; + // Avoid using this as lock, it cause deadlock Object cvLock = new Object(); Object evaluateLock = new Object(); @@ -757,10 +787,10 @@ public class Canvas3D extends Canvas { static final int ARB_MULTISAMPLE = 0x200; static final int EXT_COMPILED_VERTEX_ARRAYS = 0x400; static final int SUN_VIDEO_RESIZE = 0x800; - static final int STENCIL_BUFFER = 0x1000; - // The following three variables are set by - // createNewContext()/createQueryContext() callback + // The following 10 variables are set by the native + // createNewContext()/createQueryContext() methods + // Supported Extensions int extensionsSupported = 0; @@ -770,6 +800,33 @@ public class Canvas3D extends Canvas { // 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; @@ -802,29 +859,31 @@ public class Canvas3D extends Canvas { 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[6]; - + Object curStateToUpdate[] = new Object[7]; - // Native method for determining the number of texture unit supported - native int getTextureUnitCount(long ctx); // Native method for determining the texture color table size // in the underlying API for this Canvas3D. /* native int getTextureColorTableSize(long ctx); */ // This is the native method for creating the underlying graphics context. - native long createNewContext(long display, int window, int vid, long fbConfig, - long shareCtx, boolean isSharedCtx, - boolean offScreen); + private native long createNewContext(long display, int window, int vid, + long fbConfig, long shareCtx, boolean isSharedCtx, + boolean offScreen, + boolean glslLibraryAvailable, + boolean cgLibraryAvailable); - native void createQueryContext(long display, int window, int vid, long fbConfig, - boolean offScreen, int width, int height); + private native void createQueryContext(long display, int window, int vid, + long fbConfig, boolean offScreen, int width, int height, + boolean glslLibraryAvailable, + boolean cgLibraryAvailable); native static void destroyContext(long display, int window, long context); @@ -863,9 +922,6 @@ public class Canvas3D extends Canvas { // The following three methods are used in multi-pass case - // Native method for setting the depth func - native void setDepthFunc(long ctx, int func); - // native method for setting blend color native void setBlendColor(long ctx, float red, float green, float blue, float alpha); @@ -1001,7 +1057,7 @@ public class Canvas3D extends Canvas { // native method for updating the texture unit state map - native void updateTexUnitStateMap(long ctx, int numActiveTexUnit, + private native void updateTexUnitStateMap(long ctx, int numActiveTexUnit, int[] texUnitStateMap); /** @@ -1082,7 +1138,7 @@ public class Canvas3D extends Canvas { public Canvas3D(GraphicsConfiguration graphicsConfiguration) { this(checkForValidGraphicsConfig(graphicsConfiguration), false); - // TODO 1.4: remove call to checkForValidGraphicsConfig. + // XXXX: ENHANCEMENT -- remove call to checkForValidGraphicsConfig. // Call should then be: // this(graphicsConfiguration, false); } @@ -1135,14 +1191,22 @@ public class Canvas3D extends Canvas { // Needed for Win32-D3D only. vid = nativeWSobj.getCanvasVid(graphicsConfiguration); + // Issue 163 : Set dirty bits for both Renderer and RenderBin + cvDirtyMask[0] = VIEW_INFO_DIRTY; + cvDirtyMask[1] = VIEW_INFO_DIRTY; + // Fix for issue 20. // Needed for Linux and Solaris. - Object fbConfigObject; - fbConfigObject = fbConfigTable.get(graphicsConfiguration); - if ((fbConfigObject != null) && - (fbConfigObject instanceof Long)) { - fbConfig = ((Long)fbConfigObject).longValue(); - /* System.out.println("Canvas3D creation FBConfig = " + fbConfig + + GraphicsConfigInfo gcInfo; + gcInfo = (GraphicsConfigInfo) fbConfigTable.get(graphicsConfiguration); + if (gcInfo != null) { + fbConfig = gcInfo.getFBConfig(); + requestedStencilSize = gcInfo.getRequestedStencilSize(); + + /* + System.out.println("Canvas3D : requestedStencilSize is " + + requestedStencilSize); + System.out.println("Canvas3D creation FBConfig = " + fbConfig + " offScreen is " + offScreen ); */ // This check is needed for Unix and Win-ogl only. fbConfig should @@ -1151,8 +1215,8 @@ public class Canvas3D extends Canvas { throw new IllegalArgumentException (J3dI18N.getString("Canvas3D23")); } - } - + } + if (offScreen) { screen = new Screen3D(graphicsConfiguration, offScreen); @@ -1164,7 +1228,8 @@ public class Canvas3D extends Canvas { // callback from AWT, set the added flag here added = true; synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[0] |= MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[1] |= MOVED_OR_RESIZED_DIRTY; } // this canvas will not receive the paint callback either, @@ -1343,11 +1408,14 @@ public class Canvas3D extends Canvas { } synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[0] |= MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[1] |= MOVED_OR_RESIZED_DIRTY; } - canvasBit = VirtualUniverse.mc.getCanvasBit(); - validCanvas = true; + canvasId = VirtualUniverse.mc.getCanvasId(); + canvasBit = 1 << canvasId; + + validCanvas = true; added = true; // In case the same canvas is removed and add back, @@ -1436,8 +1504,9 @@ public class Canvas3D extends Canvas { screen.removeUser(this); evaluateActive(); - VirtualUniverse.mc.freeCanvasBit(canvasBit); + VirtualUniverse.mc.freeCanvasId(canvasId); canvasBit = 0; + canvasId = 0; ra = null; graphicsContext3D = null; @@ -1812,7 +1881,7 @@ public class Canvas3D extends Canvas { width = height = 0; } - // TODO: illegalSharing + // XXXX: illegalSharing if ((offScreenCanvasSize.width != width) || (offScreenCanvasSize.height != height)) { @@ -1842,7 +1911,8 @@ public class Canvas3D extends Canvas { offScreenBuffer = buffer; synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[0] |= MOVED_OR_RESIZED_DIRTY; + cvDirtyMask[1] |= MOVED_OR_RESIZED_DIRTY; } } @@ -2033,7 +2103,7 @@ public class Canvas3D extends Canvas { screen.renderer.doWork(0); } else { - // TODO: + // XXXX: // Now we are in trouble, this will cause deadlock if // waitForOffScreenRendering() is invoked J3dMessage createMessage = VirtualUniverse.mc.getMessage(); @@ -2347,6 +2417,23 @@ public class Canvas3D extends Canvas { } /** + * Wrapper for native createNewContext method. + */ + long createNewContext(long shareCtx, boolean isSharedCtx) { + long retVal = createNewContext(this.screen.display, + this.window, + this.vid, + this.fbConfig, + shareCtx, isSharedCtx, + this.offScreen, + VirtualUniverse.mc.glslLibraryAvailable, + VirtualUniverse.mc.cgLibraryAvailable); + // compute the max available texture units + maxAvailableTextureUnits = Math.max(maxTextureUnits, maxTextureImageUnits); + return retVal; + } + + /** * Make the context associated with the specified canvas current. */ final void makeCtxCurrent() { @@ -2447,7 +2534,8 @@ public class Canvas3D extends Canvas { this.leftManualEyeInImagePlate.set(position); synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.EYE_IN_IMAGE_PLATE_DIRTY; + cvDirtyMask[0] |= EYE_IN_IMAGE_PLATE_DIRTY; + cvDirtyMask[1] |= EYE_IN_IMAGE_PLATE_DIRTY; } redraw(); } @@ -2468,7 +2556,8 @@ public class Canvas3D extends Canvas { this.rightManualEyeInImagePlate.set(position); synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.EYE_IN_IMAGE_PLATE_DIRTY; + cvDirtyMask[0] |= EYE_IN_IMAGE_PLATE_DIRTY; + cvDirtyMask[1] |= EYE_IN_IMAGE_PLATE_DIRTY; } redraw(); } @@ -2542,7 +2631,7 @@ public class Canvas3D extends Canvas { * @param position the object that will receive the position * @see #setMonoscopicViewPolicy */ - // TODO: This might not make sense for field-sequential HMD. + // XXXX: This might not make sense for field-sequential HMD. public void getCenterEyeInImagePlate(Point3d position) { if (canvasViewCache != null) { synchronized(canvasViewCache) { @@ -2851,17 +2940,22 @@ public class Canvas3D extends Canvas { synchronized(cvLock) { if (view == null) { canvasViewCache = null; + canvasViewCacheFrustum = null; } else { canvasViewCache = new CanvasViewCache(this, screen.screenViewCache, - view.viewCache); + view.viewCache); + // Issue 109 : construct a separate canvasViewCache for + // computing view frustum + canvasViewCacheFrustum = new CanvasViewCache(this, + screen.screenViewCache, + view.viewCache); synchronized (dirtyMaskLock) { - cvDirtyMask = (STEREO_DIRTY | MONOSCOPIC_VIEW_POLICY_DIRTY - | EYE_IN_IMAGE_PLATE_DIRTY | - MOVED_OR_RESIZED_DIRTY); + cvDirtyMask[0] = VIEW_INFO_DIRTY; + cvDirtyMask[1] = VIEW_INFO_DIRTY; } - } + } } } @@ -2904,7 +2998,8 @@ public class Canvas3D extends Canvas { stereoEnable = flag; useStereo = stereoEnable && stereoAvailable; synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.STEREO_DIRTY; + cvDirtyMask[0] |= STEREO_DIRTY; + cvDirtyMask[1] |= STEREO_DIRTY; } redraw(); } @@ -2956,7 +3051,8 @@ public class Canvas3D extends Canvas { monoscopicViewPolicy = policy; synchronized(dirtyMaskLock) { - cvDirtyMask |= Canvas3D.MONOSCOPIC_VIEW_POLICY_DIRTY; + cvDirtyMask[0] |= MONOSCOPIC_VIEW_POLICY_DIRTY; + cvDirtyMask[1] |= MONOSCOPIC_VIEW_POLICY_DIRTY; } redraw(); } @@ -3044,6 +3140,36 @@ public class Canvas3D extends Canvas { /** + * Returns a flag indicating whether or not the specified shading + * language is supported. A ShaderError will be generated if an + * unsupported shading language is used. + * + * @param shadingLanguage the shading language being queried, one of: + * <code>Shader.SHADING_LANGUAGE_GLSL</code> or + * <code>Shader.SHADING_LANGUAGE_CG</code>. + * + * @return true if the specified shading language is supported, + * false otherwise. + * + * @since Java 3D 1.4 + */ + public boolean isShadingLanguageSupported(int shadingLanguage) { + // Call queryProperties to ensure that the shading language flags are valid + queryProperties(); + + // Return flag for specified shading language + switch (shadingLanguage) { + case Shader.SHADING_LANGUAGE_GLSL: + return shadingLanguageGLSL; + case Shader.SHADING_LANGUAGE_CG: + return shadingLanguageCg; + } + + return false; + } + + + /** * Returns a read-only Map object containing key-value pairs that define * various properties for this Canvas3D. All of the keys are * String objects. The values are key-specific, but most will be @@ -3060,6 +3186,14 @@ public class Canvas3D extends Canvas { * <td><b>Value Type</b></td> * </tr> * <tr> + * <td><code>shadingLanguageCg</code></td> + * <td>Boolean</td> + * </tr> + * <tr> + * <td><code>shadingLanguageGLSL</code></td> + * <td>Boolean</td> + * </tr> + * <tr> * <td><code>doubleBufferAvailable</code></td> * <td>Boolean</td> * </tr> @@ -3076,6 +3210,10 @@ public class Canvas3D extends Canvas { * <td>Integer</td> * </tr> * <tr> + * <td><code>stencilSize</code></td> + * <td>Integer</td> + * </tr> + * <tr> * <td><code>texture3DAvailable</code></td> * <td>Boolean</td> * </tr> @@ -3116,10 +3254,26 @@ public class Canvas3D extends Canvas { * <td>Boolean</td> * </tr> * <tr> + * <td><code>textureCoordSetsMax</code></td> + * <td>Integer</td> + * </tr> + * <tr> * <td><code>textureUnitStateMax</code></td> * <td>Integer</td> * </tr> * <tr> + * <td><code>textureImageUnitsMax</code></td> + * <td>Integer</td> + * </tr> + * <tr> + * <td><code>textureImageUnitsVertexMax</code></td> + * <td>Integer</td> + * </tr> + * <tr> + * <td><code>textureImageUnitsCombinedMax</code></td> + * <td>Integer</td> + * </tr> + * <tr> * <td><code>textureCubeMapAvailable</code></td> * <td>Boolean</td> * </tr> @@ -3140,6 +3294,10 @@ public class Canvas3D extends Canvas { * <td>Float</td> * </tr> * <tr> + * <td><code>vertexAttrsMax</code></td> + * <td>Integer</td> + * </tr> + * <tr> * <td><code>compressedGeometry.majorVersionNumber</code></td> * <td>Integer</td> * </tr> @@ -3164,6 +3322,22 @@ public class Canvas3D extends Canvas { * <p> * <ul> * <li> + * <code>shadingLanguageCg</code> + * <ul> + * A Boolean indicating whether or not Cg shading Language + * is available for this Canvas3D. + * </ul> + * </li> + * + * <li> + * <code>shadingLanguageGLSL</code> + * <ul> + * A Boolean indicating whether or not GLSL shading Language + * is available for this Canvas3D. + * </ul> + * </li> + * + * <li> * <code>doubleBufferAvailable</code> * <ul> * A Boolean indicating whether or not double buffering @@ -3195,7 +3369,6 @@ public class Canvas3D extends Canvas { * </ul> * </li> * - * * <li> * <code>sceneAntialiasingNumPasses</code> * <ul> @@ -3209,6 +3382,14 @@ public class Canvas3D extends Canvas { * </li> * * <li> + * <code>stencilSize</code> + * <ul> + * An Integer indicating the number of stencil bits that are available + * for this Canvas3D. + * </ul> + * </li> + * + * <li> * <code>texture3DAvailable</code> * <ul> * A Boolean indicating whether or not 3D Texture mapping @@ -3329,14 +3510,48 @@ public class Canvas3D extends Canvas { * </li> * * <li> + * <code>textureCoordSetsMax</code> + * <ul> + * An Integer indicating the maximum number of texture coordinate sets + * supported by the underlying rendering layer. + * </ul> + * </li> + * + * <li> * <code>textureUnitStateMax</code> * <ul> - * An Integer indicating the maximum number of texture unit states - * supported by the underlying rendering layer. Java3D allows an - * application to specify number of texture unit states more than - * what the underlying rendering layer supports; in this case, Java3D - * will use multi-pass to support the specified number of texture - * unit states. + * An Integer indicating the maximum number of fixed-function texture units + * supported by the underlying rendering layer. If the number of + * application-sepcified texture unit states exceeds the maximum number + * for a Canvas3D, and the fixed-function rendering pipeline is used, then + * the texture will be effectively disabled for that Canvas3D. + * </ul> + * </li> + * + * <li> + * <code>textureImageUnitsMax</code> + * <ul> + * An Integer indicating the maximum number of texture image units + * that can be accessed by the fragment shader when programmable shaders + * are used. + * </ul> + * </li> + * + * <li> + * <code>textureImageUnitsVertexMax</code> + * <ul> + * An Integer indicating the maximum number of texture image units + * that can be accessed by the vertex shader when programmable shaders + * are used. + * </ul> + * </li> + * + * <li> + * <code>textureImageUnitsCombinedMax</code> + * <ul> + * An Integer indicating the combined maximum number of texture image units + * that can be accessed by the vertex shader and the fragment shader when + * programmable shaders are used. * </ul> * </li> * @@ -3401,6 +3616,15 @@ public class Canvas3D extends Canvas { * </li> * * <li> + * <code>vertexAttrsMax</code> + * <ul> + * An Integer indicating the maximum number of vertex attributes + * supported by the underlying rendering layer. This is in addition to + * the vertex coordinate (position), color, normal, and so forth. + * </ul> + * </li> + * + * <li> * <code>compressedGeometry.majorVersionNumber</code><br> * <code>compressedGeometry.minorVersionNumber</code><br> * <code>compressedGeometry.minorMinorVersionNumber</code> @@ -3451,7 +3675,11 @@ public class Canvas3D extends Canvas { // inside the native code after setting the various // fields in this object createQueryContext(screen.display, window, vid, - fbConfig, offScreen, 1, 1); + fbConfig, offScreen, 1, 1, + VirtualUniverse.mc.glslLibraryAvailable, + VirtualUniverse.mc.cgLibraryAvailable); + // compute the max available texture units + maxAvailableTextureUnits = Math.max(maxTextureUnits, maxTextureImageUnits); } /** @@ -3480,8 +3708,12 @@ public class Canvas3D extends Canvas { 1: Renderer.NUM_ACCUMULATION_SAMPLES); } values.add(new Integer(pass)); - - keys.add("compressedGeometry.majorVersionNumber"); + + keys.add("stencilSize"); + // Return the actual stencil size. + values.add(new Integer(actualStencilSize)); + + keys.add("compressedGeometry.majorVersionNumber"); values.add(new Integer(GeometryDecompressor.majorVersionNumber)); keys.add("compressedGeometry.minorVersionNumber"); values.add(new Integer(GeometryDecompressor.minorVersionNumber)); @@ -3552,8 +3784,29 @@ public class Canvas3D extends Canvas { values.add(new Boolean( (textureExtendedFeatures & TEXTURE_LOD_OFFSET) != 0)); + keys.add("textureCoordSetsMax"); + values.add(new Integer(maxTexCoordSets)); + keys.add("textureUnitStateMax"); - values.add(new Integer(numTexUnitSupported)); + values.add(new Integer(maxTextureUnits)); + + keys.add("textureImageUnitsMax"); + values.add(new Integer(maxTextureImageUnits)); + + keys.add("textureImageUnitsVertexMax"); + values.add(new Integer(maxVertexTextureImageUnits)); + + keys.add("textureImageUnitsCombinedMax"); + values.add(new Integer(maxCombinedTextureImageUnits)); + + keys.add("vertexAttrsMax"); + values.add(new Integer(maxVertexAttrs)); + + keys.add("shadingLanguageGLSL"); + values.add(new Boolean(shadingLanguageGLSL)); + + keys.add("shadingLanguageCg"); + values.add(new Boolean(shadingLanguageCg)); keys.add("native.version"); values.add(nativeGraphicsVersion); @@ -3587,12 +3840,21 @@ public class Canvas3D extends Canvas { void updateViewCache(boolean flag, CanvasViewCache cvc, BoundingBox frustumBBox, boolean doInfinite) { + assert cvc == null; synchronized(cvLock) { - if (firstPaintCalled && (canvasViewCache != null)) { - canvasViewCache.snapshot(); - canvasViewCache.computeDerivedData(flag, cvc, frustumBBox, - doInfinite); - } + if (firstPaintCalled && (canvasViewCache != null)) { + assert canvasViewCacheFrustum != null; + // Issue 109 : choose the appropriate cvCache + if (frustumBBox != null) { + canvasViewCacheFrustum.snapshot(true); + canvasViewCacheFrustum.computeDerivedData(flag, null, + frustumBBox, doInfinite); + } else { + canvasViewCache.snapshot(false); + canvasViewCache.computeDerivedData(flag, null, + null, doInfinite); + } + } } } @@ -3736,7 +3998,10 @@ public class Canvas3D extends Canvas { reset(); - cvDirtyMask |= VIEW_INFO_DIRTY; + synchronized (dirtyMaskLock) { + cvDirtyMask[0] |= VIEW_INFO_DIRTY; + cvDirtyMask[1] |= VIEW_INFO_DIRTY; + } needToRebuildDisplayList = true; ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp(); @@ -3754,6 +4019,7 @@ public class Canvas3D extends Canvas { lightBin = null; environmentSet = null; attributeBin = null; + shaderBin = null; textureBin = null; renderMolecule = null; polygonAttributes = null; @@ -3763,6 +4029,7 @@ public class Canvas3D extends Canvas { enableLighting = false; transparency = null; coloringAttributes = null; + shaderProgram = null; texture = null; texAttrs = null; if (texUnitState != null) { @@ -3849,7 +4116,10 @@ public class Canvas3D extends Canvas { updateMaterial(ctx, 1.0f, 1.0f, 1.0f, 1.0f); resetRendering(NOCHANGE); makeCtxCurrent(); - cvDirtyMask |= VIEW_INFO_DIRTY; + synchronized (dirtyMaskLock) { + cvDirtyMask[0] |= VIEW_INFO_DIRTY; + cvDirtyMask[1] |= VIEW_INFO_DIRTY; + } needToRebuildDisplayList = true; ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp(); @@ -3978,7 +4248,7 @@ public class Canvas3D extends Canvas { } else { if (rightStereoPass) { // Only set cache in right stereo pass, otherwise - // if the left stero pass set the cache value, + // if the left stereo pass set the cache value, // setModelViewMatrix() in right stereo pass will not // perform in RenderMolecules. this.modelMatrix = mTrans; @@ -3991,10 +4261,6 @@ public class Canvas3D extends Canvas { setDepthBufferWriteEnable(ctx, mode); } - void setTexUnitStateMap(int texUnitStateIndex, int texUnitIndex) { - texUnitStateMap[texUnitIndex] = texUnitStateIndex; - } - void setNumActiveTexUnit(int n) { numActiveTexUnit = n; } @@ -4011,6 +4277,29 @@ public class Canvas3D extends Canvas { return lastActiveTexUnit; } + // Create the texture state array + void createTexUnitState() { + texUnitState = new TextureUnitStateRetained[maxAvailableTextureUnits]; + for (int t = 0; t < maxAvailableTextureUnits; t++) { + texUnitState[t] = new TextureUnitStateRetained(); + texUnitState[t].texture = null; + texUnitState[t].mirror = null; + } + } + + // Create the texture unit state map + void createTexUnitStateMap() { + // Create the texture unit state map array, which is a mapping from + // texture unit state to the actual underlying texture unit + // NOTE: since this is now required to be a 1-to-1 mapping, we will + // initialize it as such + + texUnitStateMap = new int[maxAvailableTextureUnits]; + for (int t = 0; t < maxAvailableTextureUnits; t++) { + texUnitStateMap[t] = t; + } + } + // update the underlying layer of the current texture unit state map void updateTexUnitStateMap() { updateTexUnitStateMap(ctx, numActiveTexUnit, texUnitStateMap); @@ -4164,12 +4453,13 @@ public class Canvas3D extends Canvas { curStateToUpdate[bit] = bin; } - // update LightBin, EnvironmentSet, & AttributeBin if neccessary + // update LightBin, EnvironmentSet, AttributeBin & ShaderBin if neccessary // according to the stateUpdateMask static int ENV_STATE_MASK = (1 << LIGHTBIN_BIT) | - (1 << ENVIRONMENTSET_BIT) | - (1 << ATTRIBUTEBIN_BIT); + (1 << ENVIRONMENTSET_BIT) | + (1 << ATTRIBUTEBIN_BIT) | + (1 << SHADERBIN_BIT); void updateEnvState() { @@ -4190,6 +4480,12 @@ public class Canvas3D extends Canvas { curStateToUpdate[ATTRIBUTEBIN_BIT]).updateAttributes(this); } + if ((stateUpdateMask & (1 << SHADERBIN_BIT)) != 0) { + ((ShaderBin) + curStateToUpdate[SHADERBIN_BIT]).updateAttributes(this); + } + + // reset the state update mask for those environment state bits stateUpdateMask &= ~ENV_STATE_MASK; } @@ -4317,7 +4613,7 @@ public class Canvas3D extends Canvas { // it so there is no need to do so in // Renderer.freeContextResources() if (rdr.objectId > 0) { - Canvas3D.freeTexture(ctx, rdr.objectId); + freeTexture(ctx, rdr.objectId); VirtualUniverse.mc.freeTexture2DId(rdr.objectId); rdr.objectId = -1; @@ -4325,7 +4621,7 @@ public class Canvas3D extends Canvas { // Free Graphics2D Texture if ((graphics2D != null) && (graphics2D.objectId != -1)) { - Canvas3D.freeTexture(ctx, graphics2D.objectId); + freeTexture(ctx, graphics2D.objectId); VirtualUniverse.mc.freeTexture2DId(graphics2D.objectId); graphics2D.objectId = -1; } diff --git a/src/classes/share/javax/media/j3d/CanvasViewCache.java b/src/classes/share/javax/media/j3d/CanvasViewCache.java index 7e0ba88..db55ebc 100644 --- a/src/classes/share/javax/media/j3d/CanvasViewCache.java +++ b/src/classes/share/javax/media/j3d/CanvasViewCache.java @@ -342,10 +342,19 @@ class CanvasViewCache extends Object { * NOTE: This is probably not needed, but we'll do it for symmetry * with the ScreenViewCache and ViewCache objects. */ - synchronized void snapshot() { - cvcDirtyMask = canvas.cvDirtyMask; - canvas.cvDirtyMask = 0; - useStereo = canvas.useStereo; + synchronized void snapshot(boolean computeFrustum) { + // Issue 109 : determine the the correct index to use -- either the + // Renderer or RenderBin + int dirtyIndex = computeFrustum ? + Canvas3D.RENDER_BIN_DIRTY_IDX : Canvas3D.RENDERER_DIRTY_IDX; + + synchronized (canvas.dirtyMaskLock) { + // Issue 109 : read/clear the dirty bits for the correct index + cvcDirtyMask = canvas.cvDirtyMask[dirtyIndex]; + canvas.cvDirtyMask[dirtyIndex] = 0; + } + + useStereo = canvas.useStereo; monoscopicViewPolicy = canvas.monoscopicViewPolicy; leftManualEyeInImagePlate.set(canvas.leftManualEyeInImagePlate); rightManualEyeInImagePlate.set(canvas.rightManualEyeInImagePlate); @@ -384,13 +393,29 @@ class CanvasViewCache extends Object { private void doComputeDerivedData(boolean currentFlag, CanvasViewCache cvc, BoundingBox frustumBBox, boolean doInfinite) { - if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) { + // Issue 109 : determine the the correct index to use -- either the + // Renderer or RenderBin + int dirtyIndex = (frustumBBox != null) ? + Canvas3D.RENDER_BIN_DIRTY_IDX : Canvas3D.RENDERER_DIRTY_IDX; + int scrvcDirtyMask; + + // Issue 109 : read/clear the dirty bits for the correct index + synchronized (screenViewCache) { + scrvcDirtyMask = screenViewCache.scrvcDirtyMask[dirtyIndex]; + // reset screen view dirty mask if canvas is offScreen. Note: + // there is only one canvas per offscreen, so it is ok to + // do the reset here. + if (canvas.offScreen) { + screenViewCache.scrvcDirtyMask[dirtyIndex] = 0; + } + } + + if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_2)) { if(cvcDirtyMask != 0) System.out.println("cvcDirtyMask : " + cvcDirtyMask); - if(screenViewCache.scrvcDirtyMask != 0) - System.out.println("scrvcDirtyMask : "+ - screenViewCache.scrvcDirtyMask); + if(scrvcDirtyMask != 0) + System.out.println("scrvcDirtyMask : "+ scrvcDirtyMask); if(viewCache.vcDirtyMask != 0) System.out.println("vcDirtyMask : " + viewCache.vcDirtyMask); @@ -406,13 +431,13 @@ class CanvasViewCache extends Object { // This flag is use to force a computation when a ViewPlatformTransform // is detected. No sync. needed. We're doing a read of t/f. - // TODO: Peeking at the dirty flag is a hack. Need to revisit this. + // XXXX: Peeking at the dirty flag is a hack. Need to revisit this. boolean vprNotDirty = (viewCache.vpRetained.vprDirtyMask == 0); if(!canvas.offScreen && (vprNotDirty) && (cvcDirtyMask == 0) && - (screenViewCache.scrvcDirtyMask == 0) && + (scrvcDirtyMask == 0) && (viewCache.vcDirtyMask == 0) && !(updateLastTime && (doInfinite != lastDoInfinite))) { if(frustumBBox != null) @@ -439,7 +464,7 @@ class CanvasViewCache extends Object { // System.out.println("vpcToVworld is \n" + vpcToVworld); - try { + try { vworldToVpc.invert(vpcToVworld); } catch (SingularMatrixException e) { @@ -484,19 +509,13 @@ class CanvasViewCache extends Object { if (frustumBBox != null) computefrustumBBox(frustumBBox); - // Copy the computed data into cvc. + // Issue 109: cvc should *always* be null + assert cvc == null; if(cvc != null) copyComputedCanvasViewCache(cvc, doInfinite); canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY; - // reset screen view dirty mask if canvas is offScreen. Note: - // there is only one canvas per offscreen, so it is ok to - // do the reset here. - if (canvas.offScreen) { - screenViewCache.scrvcDirtyMask = 0; - } - if((J3dDebug.devPhase) && (J3dDebug.canvasViewCache >= J3dDebug.LEVEL_1)) { // Print some data : System.out.println("useStereo = " + useStereo); @@ -908,7 +927,7 @@ class CanvasViewCache extends Object { */ private void cacheEyePosition() { if (viewCache.compatibilityModeEnable) { - // TODO: Compute compatibility mode eye position in ImagePlate??? + // XXXX: Compute compatibility mode eye position in ImagePlate??? cacheEyePosScreenRelative(leftManualEyeInImagePlate, rightManualEyeInImagePlate); } @@ -965,7 +984,7 @@ class CanvasViewCache extends Object { private void computePlateToVworld() { if (viewCache.compatibilityModeEnable) { - // TODO: implement this correctly for compat mode + // XXXX: implement this correctly for compat mode leftPlateToVworld.setIdentity(); vworldToLeftPlate.setIdentity(); } @@ -1027,7 +1046,7 @@ class CanvasViewCache extends Object { // Concatenate headToLeftImagePlate with leftPlateToVworld if (viewCache.compatibilityModeEnable) { - // TODO: implement this correctly for compat mode + // XXXX: implement this correctly for compat mode headToVworld.setIdentity(); } else { @@ -1054,7 +1073,7 @@ class CanvasViewCache extends Object { // Create a transform with the view platform to coexistence scale tMat1.set(viewPlatformScale); - // TODO: Is this really correct to ignore HMD? + // XXXX: Is this really correct to ignore HMD? if (viewCache.viewPolicy != View.HMD_VIEW) { switch (viewCache.coexistenceCenterInPworldPolicy) { @@ -1161,7 +1180,7 @@ class CanvasViewCache extends Object { private void computeCoexistenceToPlate() { if (viewCache.compatibilityModeEnable) { - // TODO: implement this correctly + // XXXX: implement this correctly coexistenceToLeftPlate.setIdentity(); return; } @@ -1334,7 +1353,7 @@ class CanvasViewCache extends Object { B = scale * -backClipDistance; } - // TODO: Can optimize for HMD case. + // XXXX: Can optimize for HMD case. if (true /*viewCache.viewPolicy != View.HMD_VIEW*/) { // Call buildProjView to build the projection and view matrices. @@ -1392,7 +1411,7 @@ class CanvasViewCache extends Object { } } } - // TODO: The following code has never been ported + // XXXX: The following code has never been ported // else { // Point3d cen_eye; // @@ -1467,14 +1486,14 @@ class CanvasViewCache extends Object { ecToCc.setIdentity(); - // TODO: we have no concept of glass correction in the Java 3D API + // XXXX: we have no concept of glass correction in the Java 3D API // // Correction in apparent 3D position of window due to glass/CRT // and spherical/cylinderical curvarure of CRT. // This boils down to producing modified values of Lx Ly Hx Hy // and is different for hot spot vs. window center corrections. // - /* TODO: + /* XXXX: double cx, cy; if(viewPolicy != HMD_VIEW && enable_crt_glass_correction) { if (correction_point == CORRECTION_POINT_WINDOW_CENTER) { @@ -1812,20 +1831,20 @@ class CanvasViewCache extends Object { } Transform3D getImagePlateToVworld() { - // TODO: Document -- This will return the transform of left plate. + // XXXX: Document -- This will return the transform of left plate. return leftPlateToVworld; } Transform3D getLastVworldToImagePlate() { - // TODO: Document -- This will return the transform of left plate. + // XXXX: Document -- This will return the transform of left plate. return lastVworldToLeftPlate; } Transform3D getVworldToImagePlate() { - // TODO: Document -- This will return the transform of left plate. + // XXXX: Document -- This will return the transform of left plate. return vworldToLeftPlate; } diff --git a/src/classes/share/javax/media/j3d/CanvasViewEventCatcher.java b/src/classes/share/javax/media/j3d/CanvasViewEventCatcher.java index 74dc617..2b723e0 100644 --- a/src/classes/share/javax/media/j3d/CanvasViewEventCatcher.java +++ b/src/classes/share/javax/media/j3d/CanvasViewEventCatcher.java @@ -42,7 +42,10 @@ class CanvasViewEventCatcher extends ComponentAdapter { System.out.println("It is canvas!"); } synchronized(canvas) { - canvas.cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + synchronized (canvas.dirtyMaskLock) { + canvas.cvDirtyMask[0] |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + canvas.cvDirtyMask[1] |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + } canvas.resizeGraphics2D = true; } @@ -60,9 +63,12 @@ class CanvasViewEventCatcher extends ComponentAdapter { System.out.println("Component moved " + e); } - synchronized(canvas) { - canvas.cvDirtyMask |= Canvas3D.MOVED_OR_RESIZED_DIRTY; - } + synchronized(canvas) { + synchronized (canvas.dirtyMaskLock) { + canvas.cvDirtyMask[0] |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + canvas.cvDirtyMask[1] |= Canvas3D.MOVED_OR_RESIZED_DIRTY; + } + } // Can't sync. with canvas lock since canvas.getLocationOnScreen() // required Component lock. The order is reverse of // removeNotify() lock sequence which required Component lock diff --git a/src/classes/share/javax/media/j3d/CapabilityBits.java b/src/classes/share/javax/media/j3d/CapabilityBits.java index c7844ae..0b7b41b 100644 --- a/src/classes/share/javax/media/j3d/CapabilityBits.java +++ b/src/classes/share/javax/media/j3d/CapabilityBits.java @@ -23,7 +23,7 @@ class CapabilityBits extends Object { // Node extends SceneGraphObject static final int NODE_ENABLE_COLLISION_REPORTING = 0; static final int NODE_ENABLE_PICK_REPORTING = 1; - static final int NODE_ALLOW_PICK = 2; + private static final int NODE_UNUSED_BIT = 2; static final int NODE_ALLOW_BOUNDS_READ = 3; static final int NODE_ALLOW_BOUNDS_WRITE = 4; static final int NODE_ALLOW_PICKABLE_READ = 5; @@ -241,6 +241,11 @@ class CapabilityBits extends Object { static final int ALTERNATE_APPEARANCE_ALLOW_SCOPE_READ = 16; static final int ALTERNATE_APPEARANCE_ALLOW_SCOPE_WRITE = 17; + // Additional Node bits (must go after all existing Node subclass bits) + static final int NODE_ALLOW_PARENT_READ = 46; + static final int NODE_ALLOW_LOCALE_READ = 47; + + // NodeComponent extends SceneGraphObject // Appearance extends NodeComponent @@ -267,6 +272,12 @@ class CapabilityBits extends Object { static final int APPEARANCE_ALLOW_TEXTURE_UNIT_STATE_READ = 20; static final int APPEARANCE_ALLOW_TEXTURE_UNIT_STATE_WRITE = 21; + // ShaderAppearance extends Appearance + static final int SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_READ = 22; + static final int SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_WRITE = 23; + static final int SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_READ = 24; + static final int SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_WRITE = 25; + // AuralAttributes extends NodeComponent static final int AURAL_ATTRIBUTES_ALLOW_ATTRIBUTE_GAIN_READ = 0; static final int AURAL_ATTRIBUTES_ALLOW_ATTRIBUTE_GAIN_WRITE = 1; @@ -362,6 +373,10 @@ class CapabilityBits extends Object { static final int RENDERING_ATTRIBUTES_ALLOW_IGNORE_VERTEX_COLORS_WRITE = 10; static final int RENDERING_ATTRIBUTES_ALLOW_DEPTH_ENABLE_WRITE = 11; + static final int RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_READ = 12; + static final int RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_WRITE = 13; + static final int RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_READ = 14; + static final int RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_WRITE = 15; // TexCoordGeneration extends NodeComponent static final int TEX_COORD_GENERATION_ALLOW_ENABLE_READ = 0; @@ -415,6 +430,20 @@ class CapabilityBits extends Object { static final int TEXTURE_UNIT_STATE_ALLOW_STATE_READ = 0; static final int TEXTURE_UNIT_STATE_ALLOW_STATE_WRITE = 1; + // ShaderProgram extends NodeComponent + static final int SHADER_PROGRAM_ALLOW_SHADERS_READ = 0; + static final int SHADER_PROGRAM_ALLOW_NAMES_READ = 1; + + // ShaderAttributeSet extends NodeComponent + static final int SHADER_ATTRIBUTE_SET_ALLOW_ATTRIBUTES_READ = 0; + static final int SHADER_ATTRIBUTE_SET_ALLOW_ATTRIBUTES_WRITE = 1; + + // ShaderAttribute extends NodeComponent + + // ShaderAttributeObject extends ShaderAttribute + static final int SHADER_ATTRIBUTE_OBJECT_ALLOW_VALUE_READ = 0; + static final int SHADER_ATTRIBUTE_OBJECT_ALLOW_VALUE_WRITE = 1; + // Geometry extends NodeComponent // NOTE: additional bits are below the subclasses @@ -445,6 +474,12 @@ class CapabilityBits extends Object { static final int GEOMETRY_ARRAY_ALLOW_REF_DATA_WRITE = 19; static final int GEOMETRY_ARRAY_ALLOW_COUNT_WRITE = 20; static final int GEOMETRY_ARRAY_ALLOW_REF_DATA_READ = 21; + static final int GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_READ = 22; + static final int GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_WRITE = 23; + + // Additional GeometryArray bits (must go after IndexedGeometryArray bits) + static final int INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_READ = 24; + static final int INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_WRITE = 25; // CompressedGeometry extends Geometry static final int COMPRESSED_GEOMETRY_ALLOW_COUNT_READ = 0; diff --git a/src/classes/share/javax/media/j3d/CgShaderProgram.java b/src/classes/share/javax/media/j3d/CgShaderProgram.java new file mode 100644 index 0000000..c531073 --- /dev/null +++ b/src/classes/share/javax/media/j3d/CgShaderProgram.java @@ -0,0 +1,173 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The CgShaderProgram object is a concrete implementation of a + * ShaderProgram node component for NVIDIA's Cg shader language. + * + * @see SourceCodeShader + * + * @since Java 3D 1.4 + */ + +public class CgShaderProgram extends ShaderProgram { + + /** + * Constructs a Cg shader program node component. + * + * <br> + * TODO: ADD MORE DOCUMENTATION HERE. + */ + public CgShaderProgram() { + } + + // Implement abstract setVertexAttrNames method (inherit javadoc from parent class) + public void setVertexAttrNames(String[] vertexAttrNames) { + checkForLiveOrCompiled(); + + if (vertexAttrNames != null) { + for (int i = 0; i < vertexAttrNames.length; i++) { + if (vertexAttrNames[i] == null) { + throw new NullPointerException(); + } + } + } + + ((CgShaderProgramRetained)this.retained).setVertexAttrNames(vertexAttrNames); + } + + // Implement abstract getVertexAttrNames method (inherit javadoc from parent class) + public String[] getVertexAttrNames() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_NAMES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("CgShaderProgram0")); + } + } + + return ((CgShaderProgramRetained)this.retained).getVertexAttrNames(); + } + + // Implement abstract setShaderAttrNames method (inherit javadoc from parent class) + public void setShaderAttrNames(String[] shaderAttrNames) { + checkForLiveOrCompiled(); + + if (shaderAttrNames != null) { + for (int i = 0; i < shaderAttrNames.length; i++) { + if (shaderAttrNames[i] == null) { + throw new NullPointerException(); + } + } + } + + ((CgShaderProgramRetained)this.retained).setShaderAttrNames(shaderAttrNames); + } + + // Implement abstract getShaderAttrNames method (inherit javadoc from parent class) + public String[] getShaderAttrNames() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_NAMES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("CgShaderProgram0")); + } + } + + return ((CgShaderProgramRetained)this.retained).getShaderAttrNames(); + } + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading language of + * each shader in the array must be + * <code>SHADING_LANGUAGE_CG</code>. Each shader in the array must + * be a SourceCodeShader. There must be no more than one vertex shader + * and one fragment shader in the array. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array is <em>not</em> + * <code>SHADING_LANGUAGE_CG</code>. + * + * @exception IllegalArgumentException if there are more than one + * vertex shader or more than one fragment shader in the shaders + * array. + * + * @exception ClassCastException if any shader in the shaders + * array is <em>not</em> a SourceCodeShader. + */ + public void setShaders(Shader[] shaders) { + checkForLiveOrCompiled(); + + if (shaders != null) { + // Check shaders for valid shading language, class type, etc. + for (int i = 0; i < shaders.length; i++) { + boolean hasVertexShader = false; + boolean hasFragmentShader = false; + + // Check shading language + if (shaders[i].getShadingLanguage() != Shader.SHADING_LANGUAGE_CG) { + throw new IllegalArgumentException(J3dI18N.getString("CgShaderProgram2")); + } + + // Check for more than one vertex shader or fragment shader + if (shaders[i].getShaderType() == Shader.SHADER_TYPE_VERTEX) { + if (hasVertexShader) { + throw new IllegalArgumentException(J3dI18N.getString("CgShaderProgram3")); + } + hasVertexShader = true; + } + else { // Shader.SHADER_TYPE_FRAGMENT + if (hasFragmentShader) { + throw new IllegalArgumentException(J3dI18N.getString("CgShaderProgram4")); + } + hasFragmentShader = true; + } + + // Try to cast shader to SourceCodeShader; it will throw + // ClassCastException if it isn't. + SourceCodeShader shad = (SourceCodeShader)shaders[i]; + } + } + + ((CgShaderProgramRetained)this.retained).setShaders(shaders); + } + + // Implement abstract getShaders method (inherit javadoc from parent class) + public Shader[] getShaders() { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADERS_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("CgShaderProgram1")); + } + } + + return ((CgShaderProgramRetained)this.retained).getShaders(); + } + + /** + * Creates a retained mode CgShaderProgramRetained object that this + * CgShaderProgram component object will point to. + */ + void createRetained() { + this.retained = new CgShaderProgramRetained(); + this.retained.setSource(this); + } + +} diff --git a/src/classes/share/javax/media/j3d/CgShaderProgramRetained.java b/src/classes/share/javax/media/j3d/CgShaderProgramRetained.java new file mode 100644 index 0000000..eed2484 --- /dev/null +++ b/src/classes/share/javax/media/j3d/CgShaderProgramRetained.java @@ -0,0 +1,283 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The CgShaderProgram object is a concrete implementation of a + * ShaderProgram node component for NVIDIA's Cg shader language. + * + * @see SourceCodeShader + * + * @since Java 3D 1.4 + */ + +class CgShaderProgramRetained extends ShaderProgramRetained { + + /** + * Constructs a Cg shader program node component. + * + * <br> + * TODO: ADD MORE DOCUMENTATION HERE. + */ + CgShaderProgramRetained() { + } + + synchronized void createMirrorObject() { + // System.out.println("CgShaderProgramRetained : createMirrorObject"); + // This method should only call by setLive(). + if (mirror == null) { + CgShaderProgramRetained mirrorCgSP = new CgShaderProgramRetained(); + mirror = mirrorCgSP; + } + initMirrorObject(); + } + + // ShaderAttributeValue methods + + native ShaderError setUniform1i(long ctx, + long shaderProgramId, + long uniformLocation, + int value); + + native ShaderError setUniform1f(long ctx, + long shaderProgramId, + long uniformLocation, + float value); + + native ShaderError setUniform2i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform2f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniform3i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniform4i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniformMatrix3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniformMatrix4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + // ShaderAttributeArray methods + + native ShaderError setUniform1iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform1fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform2iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform2fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform3iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform4iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniformMatrix3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniformMatrix4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + + + /* New native interfaces */ + private native ShaderError createNativeShader(long ctx, int shaderType, long[] shaderId); + private native ShaderError destroyNativeShader(long ctx, long shaderId); + private native ShaderError compileNativeShader(long ctx, long shaderId, String program); + + private native ShaderError createNativeShaderProgram(long ctx, long[] shaderProgramId); + private native ShaderError destroyNativeShaderProgram(long ctx, long shaderProgramId); + private native ShaderError linkNativeShaderProgram(long ctx, long shaderProgramId, + long[] shaderId); + private native void lookupNativeVertexAttrNames(long ctx, long shaderProgramId, + int numAttrNames, String[] attrNames, boolean[] errArr); + private native void lookupNativeShaderAttrNames(long ctx, long shaderProgramId, + int numAttrNames, String[] attrNames, long[] locArr, + int[] typeArr, int[] sizeArr, boolean[] isArrayArr); + + private native ShaderError useShaderProgram(long ctx, long shaderProgramId); + + /** + * Method to return a flag indicating whether this + * ShaderProgram is supported on the specified Canvas. + */ + boolean isSupported(Canvas3D cv) { + return cv.shadingLanguageCg; + } + + /** + * Method to create the native shader. + */ + ShaderError createShader(long ctx, ShaderRetained shader, long[] shaderIdArr) { + return createNativeShader(ctx, shader.shaderType, shaderIdArr); + } + + /** + * Method to destroy the native shader. + */ + ShaderError destroyShader(long ctx, long shaderId) { + return destroyNativeShader(ctx, shaderId); + } + + /** + * Method to compile the native shader. + */ + ShaderError compileShader(long ctx, long shaderId, String source) { + return compileNativeShader(ctx, shaderId, source ); + } + + /** + * Method to create the native shader program. + */ + ShaderError createShaderProgram(long ctx, long[] shaderProgramIdArr) { + return createNativeShaderProgram(ctx, shaderProgramIdArr); + } + + /** + * Method to destroy the native shader program. + */ + ShaderError destroyShaderProgram(long ctx, long shaderProgramId) { + return destroyNativeShaderProgram(ctx, shaderProgramId); + } + + /** + * Method to link the native shader program. + */ + ShaderError linkShaderProgram(long ctx, long shaderProgramId, long[] shaderIds) { + return linkNativeShaderProgram(ctx, shaderProgramId, shaderIds); + } + + ShaderError bindVertexAttrName(long ctx, long shaderProgramId, String attrName, int attrIndex) { + // This is a no-op for Cg + return null; + } + + void lookupVertexAttrNames(long ctx, long shaderProgramId, String[] attrNames, boolean[] errArr) { + lookupNativeVertexAttrNames(ctx, shaderProgramId, attrNames.length, attrNames, errArr); + } + + void lookupShaderAttrNames(long ctx, long shaderProgramId, + String[] attrNames, AttrNameInfo[] attrNameInfoArr) { + + int numAttrNames = attrNames.length; + + long[] locArr = new long[numAttrNames]; + int[] typeArr = new int[numAttrNames]; + int[] sizeArr = new int[numAttrNames]; // currently unused + boolean[] isArrayArr = new boolean[numAttrNames]; + + // Initialize loc array to -1 (indicating no location) + for (int i = 0; i < numAttrNames; i++) { + locArr[i] = -1; + } + + lookupNativeShaderAttrNames(ctx, shaderProgramId, + numAttrNames, attrNames, locArr, typeArr, sizeArr, isArrayArr); + + for (int i = 0; i < numAttrNames; i++) { + attrNameInfoArr[i] = new AttrNameInfo(); + attrNameInfoArr[i].setLocation(locArr[i]); + attrNameInfoArr[i].setArray(isArrayArr[i]); + attrNameInfoArr[i].setType(typeArr[i]); + System.err.println(attrNames[i] + + " : loc = " + locArr[i] + + ", type = " + typeArr[i] + + ", isArray = " + isArrayArr[i] + + ", size = " + sizeArr[i]); + } + } + + /** + * Method to enable the native shader program. + */ + ShaderError enableShaderProgram(long ctx, long shaderProgramId) { + return useShaderProgram(ctx, shaderProgramId); + } + + /** + * Method to disable the native shader program. + */ + ShaderError disableShaderProgram(long ctx) { + return useShaderProgram(ctx, 0); + } + + +} diff --git a/src/classes/share/javax/media/j3d/Clip.java b/src/classes/share/javax/media/j3d/Clip.java index b32342b..e374ec3 100644 --- a/src/classes/share/javax/media/j3d/Clip.java +++ b/src/classes/share/javax/media/j3d/Clip.java @@ -61,6 +61,12 @@ public class Clip extends Leaf { public static final int ALLOW_BACK_DISTANCE_WRITE = CapabilityBits.CLIP_ALLOW_BACK_DISTANCE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_APPLICATION_BOUNDS_READ, + ALLOW_BACK_DISTANCE_READ + }; + /** * Constructs a Clip node with default parameters. The default * values are as follows: @@ -72,12 +78,17 @@ public class Clip extends Leaf { */ public Clip () { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** * Constructs a Clip node with the specified back clip distance. */ public Clip(double backDistance) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ClipRetained)this.retained).initBackDistance(backDistance); } diff --git a/src/classes/share/javax/media/j3d/ColoringAttributes.java b/src/classes/share/javax/media/j3d/ColoringAttributes.java index 996edf1..6858829 100644 --- a/src/classes/share/javax/media/j3d/ColoringAttributes.java +++ b/src/classes/share/javax/media/j3d/ColoringAttributes.java @@ -115,6 +115,12 @@ public class ColoringAttributes extends NodeComponent { */ public static final int SHADE_GOURAUD = 3; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COLOR_READ, + ALLOW_SHADE_MODEL_READ + }; + /** * Constructs a ColoringAttributes node with default parameters. * The default values are as follows: @@ -125,6 +131,8 @@ public class ColoringAttributes extends NodeComponent { */ public ColoringAttributes() { // Just use default attributes + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -134,7 +142,10 @@ public class ColoringAttributes extends NodeComponent { * SHADE_FLAT, or SHADE_GOURAUD */ public ColoringAttributes(Color3f color, int shadeModel) { - ((ColoringAttributesRetained)this.retained).initColor(color); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((ColoringAttributesRetained)this.retained).initColor(color); ((ColoringAttributesRetained)this.retained).initShadeModel(shadeModel); } @@ -149,7 +160,10 @@ public class ColoringAttributes extends NodeComponent { */ public ColoringAttributes(float red, float green, float blue, int shadeModel) { - ((ColoringAttributesRetained)this.retained).initColor(red, green,blue); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((ColoringAttributesRetained)this.retained).initColor(red, green,blue); ((ColoringAttributesRetained)this.retained).initShadeModel(shadeModel); } @@ -315,7 +329,8 @@ public class ColoringAttributes extends NodeComponent { * Capability read bit set will be displayed. */ public String toString() { - StringBuffer str=new StringBuffer("ColoringAttributes:"); + StringBuffer str = new StringBuffer(getNamePrefix()); + str.append("javax.media.j3d.ColoringAttributes: "); String shadingModes[] = { "FASTEST", "NICEST", "SHADE_FLAT", "SHADE_GOURAUD" }; diff --git a/src/classes/share/javax/media/j3d/CompressedGeometry.java b/src/classes/share/javax/media/j3d/CompressedGeometry.java index 60541f9..8609349 100644 --- a/src/classes/share/javax/media/j3d/CompressedGeometry.java +++ b/src/classes/share/javax/media/j3d/CompressedGeometry.java @@ -14,11 +14,10 @@ package javax.media.j3d; /** * The compressed geometry object is used to store geometry in a - * compressed format. Using compressed geometry reduces the amount - * of memory needed by a Java 3D application and increases the speed - * objects can be sent over the network. Once geometry decompression - * hardware support becomes available, increased rendering performance - * will also result from the use of compressed geometry. + * compressed format. Using compressed geometry may increase the speed + * objects can be sent over the network. Note that the geometry will + * be decompressed in memory, so the application will not see any + * memory savings. * <p> * Compressed geometry may be passed to this CompressedGeometry object * in one of two ways: by copying the data into this object using the @@ -49,6 +48,8 @@ package javax.media.j3d; * the results are undefined. * </li> * </ul> + * + * @deprecated As of Java 3D version 1.4. */ public class CompressedGeometry extends Geometry { @@ -87,10 +88,21 @@ public class CompressedGeometry extends Geometry { ALLOW_REF_DATA_READ = CapabilityBits.COMPRESSED_GEOMETRY_ALLOW_REF_DATA_READ; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COUNT_READ, + ALLOW_HEADER_READ, + ALLOW_GEOMETRY_READ, + ALLOW_REF_DATA_READ + }; + /** * Package scoped default constructor for use by cloneNodeComponent. */ CompressedGeometry() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -156,6 +168,9 @@ public class CompressedGeometry extends Geometry { throw new IllegalArgumentException (J3dI18N.getString("CompressedGeometry0")) ; + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + // Create a separate copy of the given header. cgHeader = new CompressedGeometryHeader() ; hdr.copy(cgHeader) ; @@ -174,33 +189,10 @@ public class CompressedGeometry extends Geometry { } /** - * Creates a new CompressedGeometry NodeComponent. The - * specified compressed geometry data is accessed by reference - * from the specified buffer. - * If the version number of compressed geometry, as specified by - * the CompressedGeometryHeader, is incompatible with the - * supported version of compressed geometry in the current version - * of Java 3D, the compressed geometry object will not be - * rendered. - * - * @param hdr the compressed geometry header. This is copied - * into the CompressedGeometry NodeComponent. - * - * @param compressedGeometry a buffer containing an NIO byte buffer - * of compressed geometry data. The - * geometry must conform to the format described in Appendix B of - * the <i>Java 3D API Specification</i>. + * This constructor is not implemented. * - * @exception UnsupportedOperationException this method is not - * yet implemented - * - * @exception IllegalArgumentException if a problem is detected with the - * header, - * or if the java.nio.Buffer contained in the specified J3DBuffer - * is not a java.nio.ByteBuffer object. - * - * @see CompressedGeometryHeader - * @see Canvas3D#queryProperties + * @exception UnsupportedOperationException this constructor is not + * implemented * * @since Java 3D 1.3 */ @@ -323,7 +315,6 @@ public class CompressedGeometry extends Geometry { // the same number of Shape3D objects as TriangleArray using 1/2 // to 2/3 of the vertices, with only a marginal performance penalty. // - // TODO revisit this return decompressor.toTriangleStripArrays(cgr) ; } @@ -345,9 +336,7 @@ public class CompressedGeometry extends Geometry { /** * Gets the compressed geometry data reference. * - * @return the current compressed geometry data reference; - * null is returned if this compressed geometry object was created - * with a J3DBuffer reference rather than a byte array. + * @return the current compressed geometry data reference. * * @exception IllegalStateException if the data access mode for this * object is not by-reference. @@ -372,14 +361,11 @@ public class CompressedGeometry extends Geometry { /** - * Gets the compressed geometry data buffer reference. + * Gets the compressed geometry data buffer reference, which is + * always null since NIO buffers are not supported for + * CompressedGeometry objects. * - * @return the current compressed geometry data buffer reference; - * null is returned if this compressed geometry object was created - * with a byte array reference rather than a J3DBuffer. - * - * @exception IllegalStateException if the data access mode for this - * object is not by-reference. + * @return null * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph @@ -392,11 +378,6 @@ public class CompressedGeometry extends Geometry { throw new CapabilityNotSetException (J3dI18N.getString("CompressedGeometry6")) ; - if (!isByReference()) - throw new IllegalStateException - (J3dI18N.getString("CompressedGeometry8")) ; - - // TODO: implement this when NIO buffer support is added return null; } diff --git a/src/classes/share/javax/media/j3d/CompressedGeometryHeader.java b/src/classes/share/javax/media/j3d/CompressedGeometryHeader.java index 39f409a..38876a9 100644 --- a/src/classes/share/javax/media/j3d/CompressedGeometryHeader.java +++ b/src/classes/share/javax/media/j3d/CompressedGeometryHeader.java @@ -25,6 +25,8 @@ import javax.vecmath.*; * provided. * * @see CompressedGeometry + * + * @deprecated As of Java 3D version 1.4. */ public class CompressedGeometryHeader extends Object { diff --git a/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java b/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java index 6bd7164..737fa4d 100644 --- a/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java +++ b/src/classes/share/javax/media/j3d/CompressedGeometryRetained.java @@ -81,23 +81,31 @@ class CompressedGeometryRetained extends GeometryRetained { private GeometryRetained pickGeometry = null ; /** - * Native method that returns availability of a native by-reference + * Formerly native method that returns availability of a native by-reference * rendering API for compressed geometry. */ - native boolean decompressByRef(long ctx) ; + private boolean decompressByRef(long ctx) { + return false; + } /** - * Native method that returns availability of hardware acceleration for - * compressed geometry of the given version. + * Formerly native method that returns availability of hardware + * rendering (and acceleration) for compressed geometry of the + * given version. */ - native boolean decompressHW(long ctx, int majorVersion, int minorVersion) ; + private boolean decompressHW(long ctx, int majorVersion, int minorVersion) { + return false; + } /** - * Native method that does the rendering + * Formerly native method that does HW compressed geometry rendering */ - native void execute(long ctx, int version, int bufferType, - int bufferContents, int renderFlags, - int offset, int size, byte[] geometry) ; + private void execute(long ctx, int version, int bufferType, + int bufferContents, int renderFlags, + int offset, int size, byte[] geometry) { + + assert false : "This method should never be called!"; + } /** * Method for calling native execute() method on behalf of the J3D renderer. @@ -107,7 +115,7 @@ class CompressedGeometryRetained extends GeometryRetained { boolean multiScreen, int screen, boolean ignoreVertexColors, int pass) { - // TODO: alpha udpate + // XXXX: alpha udpate execute(cv.ctx, packedVersion, bufferType, bufferContents, renderFlags, offset, size, compressedGeometry) ; } @@ -313,12 +321,12 @@ class CompressedGeometryRetained extends GeometryRetained { // The following intersect() methods are used to implement geometry-based // picking and collision. // - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { GeometryRetained geom = getPickGeometry() ; return (geom != null ? - geom.intersect(pickShape, dist, iPnt) : false); + geom.intersect(pickShape, iInfo, flags, iPnt) : false); } - + boolean intersect(Bounds targetBound) { GeometryRetained geom = getPickGeometry() ; return (geom != null ? geom.intersect(targetBound) : false); diff --git a/src/classes/share/javax/media/j3d/ConeSound.java b/src/classes/share/javax/media/j3d/ConeSound.java index 8b57d27..424195b 100644 --- a/src/classes/share/javax/media/j3d/ConeSound.java +++ b/src/classes/share/javax/media/j3d/ConeSound.java @@ -147,6 +147,12 @@ public class ConeSound extends PointSound { public static final int ALLOW_ANGULAR_ATTENUATION_WRITE = CapabilityBits.CONE_SOUND_ALLOW_ANGULAR_ATTENUATION_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_DIRECTION_READ, + ALLOW_ANGULAR_ATTENUATION_READ + }; + /** * Constructs and initializes a new ConeSound node using default * parameters. The following default values are used: @@ -159,6 +165,8 @@ public class ConeSound extends PointSound { public ConeSound() { // Uses default values defined in ConeSoundRetained.java super(); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -177,6 +185,10 @@ public class ConeSound extends PointSound { Vector3f direction) { super(soundData, initialGain, position ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setDirection(direction); } @@ -201,6 +213,10 @@ public class ConeSound extends PointSound { float dirX, float dirY, float dirZ) { super(soundData, initialGain, posX, posY, posZ ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setDirection(dirX, dirY, dirZ); } @@ -248,6 +264,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, position, frontDistanceAttenuation ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setBackDistanceGain( backDistanceAttenuation); ((ConeSoundRetained)this.retained).setDirection(direction); @@ -301,6 +321,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, posX, posY, posZ, frontDistance, frontDistanceGain ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setDirection(dirX, dirY, dirZ); ((ConeSoundRetained)this.retained).setBackDistanceGain( backDistance, backDistanceGain ); @@ -346,6 +370,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, position, distanceAttenuation ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setDirection(direction); ((ConeSoundRetained)this.retained).setAngularAttenuation( angularAttenuation); @@ -402,6 +430,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, posX, posY, posZ, distance, distanceGain ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setDirection(dirX, dirY, dirZ); ((ConeSoundRetained)this.retained).setAngularAttenuation(angle, angularGain, frequencyCutoff); @@ -444,6 +476,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, position, frontDistanceAttenuation ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setBackDistanceGain( backDistanceAttenuation); ((ConeSoundRetained)this.retained).setDirection(direction); @@ -497,6 +533,10 @@ public class ConeSound extends PointSound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority, posX, posY, posZ, frontDistance, frontDistanceGain ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ConeSoundRetained)this.retained).setBackDistanceGain( backDistance, backDistanceGain ); ((ConeSoundRetained)this.retained).setDirection(dirX, dirY, dirZ); diff --git a/src/classes/share/javax/media/j3d/DepthComponent.java b/src/classes/share/javax/media/j3d/DepthComponent.java index 97f6af1..ad3212d 100644 --- a/src/classes/share/javax/media/j3d/DepthComponent.java +++ b/src/classes/share/javax/media/j3d/DepthComponent.java @@ -31,10 +31,18 @@ public abstract class DepthComponent extends NodeComponent { public static final int ALLOW_DATA_READ = CapabilityBits.DEPTH_COMPONENT_ALLOW_DATA_READ; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SIZE_READ, + ALLOW_DATA_READ + }; + /** * default constructor */ DepthComponent() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** diff --git a/src/classes/share/javax/media/j3d/DirectionalLight.java b/src/classes/share/javax/media/j3d/DirectionalLight.java index 987e014..a858cd1 100644 --- a/src/classes/share/javax/media/j3d/DirectionalLight.java +++ b/src/classes/share/javax/media/j3d/DirectionalLight.java @@ -41,6 +41,11 @@ public class DirectionalLight extends Light { public static final int ALLOW_DIRECTION_WRITE = CapabilityBits.DIRECTIONAL_LIGHT_ALLOW_DIRECTION_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_DIRECTION_READ + }; + /** * Constructs a DirectionalLight node with default parameters. * The default values are as follows: @@ -49,6 +54,8 @@ public class DirectionalLight extends Light { * </ul> */ public DirectionalLight() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -59,6 +66,10 @@ public class DirectionalLight extends Light { */ public DirectionalLight(Color3f color, Vector3f direction) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((DirectionalLightRetained)this.retained).initDirection(direction); } @@ -71,6 +82,10 @@ public class DirectionalLight extends Light { */ public DirectionalLight(boolean lightOn, Color3f color, Vector3f direction) { super(lightOn, color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((DirectionalLightRetained)this.retained).initDirection(direction); } diff --git a/src/classes/share/javax/media/j3d/DisplayListRenderMethod.java b/src/classes/share/javax/media/j3d/DisplayListRenderMethod.java index 012f30a..b3f8625 100644 --- a/src/classes/share/javax/media/j3d/DisplayListRenderMethod.java +++ b/src/classes/share/javax/media/j3d/DisplayListRenderMethod.java @@ -155,7 +155,7 @@ class DisplayListRenderMethod implements RenderMethod { Transform3D staticNormalTransform; if ((rm.primaryRenderAtomList != null) && - (rm.texCoordSetMapLen <= cv.numTexCoordSupported)) { + (rm.texCoordSetMapLen <= cv.maxTexCoordSets)) { cv.newDisplayList(cv.ctx, rm.displayListId); @@ -195,7 +195,7 @@ class DisplayListRenderMethod implements RenderMethod { geo = (GeometryArrayRetained)ra.geometry(); if ((geo.texCoordSetMap != null) && - (geo.texCoordSetMap.length > cv.numTexCoordSupported)) { + (geo.texCoordSetMap.length > cv.maxTexCoordSets)) { return; } @@ -224,7 +224,7 @@ class DisplayListRenderMethod implements RenderMethod { geo = (GeometryArrayRetained)ra.geometry(); if ((rm.primaryRenderAtomList != null) && - (rm.texCoordSetMapLen <= cv.numTexCoordSupported)) { + (rm.texCoordSetMapLen <= cv.maxTexCoordSets)) { id = ra.renderAtom.dlistIds[ra.index]; cv.newDisplayList(cv.ctx, id); diff --git a/src/classes/share/javax/media/j3d/ExceptionStrings.properties b/src/classes/share/javax/media/j3d/ExceptionStrings.properties index c3e8674..b1541ba 100644 --- a/src/classes/share/javax/media/j3d/ExceptionStrings.properties +++ b/src/classes/share/javax/media/j3d/ExceptionStrings.properties @@ -153,6 +153,12 @@ BranchGroup0=Cannot compile a live BranchGroup BranchGroup1=BranchGroup: no capability to detach BranchGroup2=Group: no capability to write children BranchGroup3=Picking can only work if BranchGroup is alive +BranchGroup4=BranchGroup: Mode has to be either PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY +BranchGroup5=BranchGroup: Mode can't be PickInfo.PICK_GEOMETRY if PickShape is PickPoint +BranchGroup6=BranchGroup: CLOSEST_GEOM_INFO and ALL_GEOM_INFO can't be set together. +BranchGroup7=BranchGroup: Mode can't be PICK_BOUNDS if geometry information is needed +BranchGroup8=BranchGroup: PickShape can't be PickBounds if geometry information is needed +BranchGroup9=BranchGroup: Cannot call picking under a SharedGroup node CachedFrustum0=Frustum must have aleast 6 planes CachedFrustum1=Frustum must have 6 planes Clip0=Clip: no capability to set back distance @@ -172,7 +178,7 @@ CompressedGeometry5=CompressedGeometry: no capability to get geometry CompressedGeometry6=CompressedGeometry: no capability to get data reference CompressedGeometry7=CompressedGeometry: cannot directly access data in byReference mode CompressedGeometry8=CompressedGeometry: must be in byReference mode to use this method -CompressedGeometry9=CompressedGeometry: NIO buffer support is not currently implemented +CompressedGeometry9=CompressedGeometry: NIO buffer support is not implemented ClipRetained0=Clip: Immediate mode clip may not be in scene graph ClipRetained1=Clip: illegal node under Background geometry Branch ClipRetained2=Clip: illegal node under SharedGroup Branch @@ -268,7 +274,7 @@ GeometryArray103=GeometryArray: initial tex coord index + valid vertex count > v GeometryArray104=GeometryArray: initial coord index + valid vertex count > vertex count GeometryArray105=GeometryArray: must not be in BY_REFERENCE mode to use this method GeometryArray106=GeometryArray: texCoord set mapping is not specified -GeometryArray107=GeometryArray: must specify at least one set of tex coord +GeometryArray107=GeometryArray: must specify at least one set of texture coordinates GeometryArray108=GeometryArray: invalid texCoord set mapping GeometryArray109=GeometryArray: must be in TEXTURE_COORDINATE_4 mode to use this method GeometryArray110=GeometryArray: validVertexCount should be greater than or equal to zero @@ -285,6 +291,18 @@ GeometryArray120=GeometryArray: must be direct nio buffer GeometryArray121=GeometryArray: None of the TEXTURE_COORDINATE bits are set in vertexFormat GeometryArray122=GeometryArray: NORMALS bit is not set in vertexFormat GeometryArray123=GeometryArray: None of the COLOR bits are set in vertexFormat +GeometryArray124=GeometryArray: texCoordSetCount < 0 +GeometryArray125=GeometryArray: vertexAttrCount < 0 +GeometryArray126=GeometryArray: no capability to set vertex attributes +GeometryArray127=GeometryArray: no capability to read vertex attributes +GeometryArray128=GeometryArray: VERTEX_ATTRIBUTES flag must not be set in INTERLEAVED mode +GeometryArray129=GeometryArray: vertex attr array length is incorrect +GeometryArray130=GeometryArray: initial vertex attr index + valid vertex count > vertex count +GeometryArray131=GeometryArray: vertexAttrCount > 0, but VERTEX_ATTRIBUTES flag is not set +GeometryArray132=GeometryArray: vertexAttrCount != vertexAttrSizes.length +GeometryArray133=GeometryArray: vertexAttrSize value out of range +GeometryArray134=GeometryArray: vertexAttrSize invalid for this method +GeometryArray135=GeometryArray: USE_COORD_INDEX_ONLY bit cannot be set for non-indexed geometry GeometryDecompressor0=GeometryDecompressor: start+length > data array size GeometryDecompressor1=GeometryDecompressor: bad delta normal in compressed buffer GeometryDecompressorRetained0=GeometryDecompressorRetained: bad buffer data type @@ -318,6 +336,7 @@ GeometryStripArray4=GeometryStripArray: initial color index + valid vertex count GeometryStripArray5=GeometryStripArray: initial normal index + valid vertex count > vertex count GeometryStripArray6=GeometryStripArray: initial tex coord index + valid vertex count > vertex count GeometryStripArray7=GeometryStripArray: initial coord index + valid vertex count > vertex count +GeometryStripArray8=GeometryStripArray: initial vertex attr index + valid vertex count > vertex count GraphicsContext3D11=Background: Scene Graph background may not be in immediate mode GraphicsContext3D12=Fog: Scene Graph fog may not be in immediate mode GraphicsContext3D13=GraphicsContext3D: Light object is null @@ -358,6 +377,11 @@ Locale0=Locale.addBranchGraph: Branch Group already has a parent Locale1=Locale: no capability to detach BranchGroup Locale3=Locale.replaceBranchGraph: Branch Group already has a parent Locale4=Locale has been removed from its VirtualUniverse +Locale5=Locale: Mode has to be either PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY +Locale6=Locale: Mode can't be PickInfo.PICK_GEOMETRY if PickShape is PickPoint +Locale7=Locale: CLOSEST_GEOM_INFO and ALL_GEOM_INFO can't be set together. +Locale8=Locale: Mode can't be PICK_BOUNDS if geometry information is needed +Locale9=Locale: PickShape can't be PickBounds if geometry information is needed IndexedLineStripArray0=IndexedLineStripArray: illegal vertexCount IndexedLineStripArray1=IndexedLineStripArray: illegal indexCount IndexedGeometryArray0=IndexedGeometryArray: no capability to get index count @@ -381,12 +405,11 @@ IndexedGeometryArray24=IndexedGeometryArray: index color value greater than the IndexedGeometryArray25=IndexedGeometryArray: index texcoord value greater than the array length IndexedGeometryArray26=IndexedGeometryArray: index normal value greater than the array length IndexedGeometryArray27=IndexedGeometryArray: index value less than zero +IndexedGeometryArray28=IndexedGeometryArray: no capability to set vertex attribute index +IndexedGeometryArray29=IndexedGeometryArray: no capability to get vertex attribute index +IndexedGeometryArray30=IndexedGeometryArray: index vertexAttr value greater than the array length IndexedLineArray0=IndexedLineArray: illegal vertexCount IndexedLineArray1=IndexedLineArray: illegal indexCount -IndexedGeometryArrayRetained0=execute() called on indexed geometry -IndexedGeometryArrayRetained1=WARNING: Memory redundantly allocated for Color Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version -IndexedGeometryArrayRetained2=WARNING: Memory redundantly allocated for Normal Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version -IndexedGeometryArrayRetained3=WARNING: Memory redundantly allocated for TextureCoordinate Indices array since the USE_COORD_INDEX_ONLY flag has been specified. This will throw a NPE in a subsequent version IndexedGeometryStripArray0=IndexedGeometryStripArray: no capability to get number of strips IndexedGeometryStripArray1=IndexedGeometryStripArray: no capability to get strip index counts IndexedGeometryStripArray2=IndexedGeometryStripArray: no capability to set strip index counts @@ -466,14 +489,15 @@ MorphRetained2=Morph: All GeometryArrays must be of same type MorphRetained5=Invalid SceneGraphPath encountered : localToVworld is null. MorphRetained7=Morph: number of weights not same as number of GeometryArrays MorphRetained8=Morph: sum of all weights is NOT 1.0 -Node0=Cannot get the parent of a live or compiled node +MorphRetained9=Morph: vertex attributes are not supported +Node0=Node: no capability to read parent Node1=Node: no capability to set bounds Node2=Node: no capability to read user bounds Node3=Node: no capability to read Pickable Node4=Node: no capability to set Collidable Node5=Node: no capability to set user auto compute bounds Node6=Node: no capability to read user auto compute bounds -Node7=Node: local to vworld transform is undefined for a node that is not part of a live scene graph +Node7=Node: local to vworld transform is undefined for a node that is compiled but not live Node8=Node: no capability to read local to vworld transform Node9=Node: Invalid geometric bounds Node11=cloneTree: should be overridden in child @@ -482,6 +506,14 @@ Node13=Node: Cannot clone a live or compiled scenegraph Node14=Node: no capability to set Pickable Node15=Node: Cannot compile, clone or getBounds on a scene graph that contains a cycle. Node16=Node: no capability to read Collidable +Node17=Node: no capability to read locale +PickInfo0=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_GEOMETRY_READ +PickInfo1=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_INTERSECT +PickInfo2=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_COORDINATE_READ +PickInfo3=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_COUNT_READ +PickInfo4=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_FORMAT_READ +PickInfo5=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_COORDINATE_INDEX_READ +PickInfo6=PickInfo: PICK_GEOMETRY mode - no capability to ALLOW_GEOMETRY_ARRAY_READ Picking0=Cannot call picking under a SharedGroup node Picking2=Picking: Node has no parent and locale. This is illegal! NodeComponent0=NodeComponent:cloneNodeComponent must be defined in subclass @@ -572,6 +604,10 @@ RenderingAttributes10=RenderingAttributes: no capability to set raster op RenderingAttributes11=RenderingAttributes: no capability to get raster op RenderingAttributes12=RenderingAttributes: no capability to set ignore vertex colors flag RenderingAttributes13=RenderingAttributes: no capability to get ignore vertex colors flag +RenderingAttributes14=RenderingAttributes: no capability to set depth test function +RenderingAttributes15=RenderingAttributes: no capability to get depth test function +RenderingAttributes16=RenderingAttributes: no capability to set stencil attributes +RenderingAttributes17=RenderingAttributes: no capability to get stencil attributes TriangleStripArrayRetained0=PickPoint doesn't make sense for geometry-based picking. Java 3D doesn't have spatial information of the surface. Should use PickBounds with BoundingSphere and set radius to a epsilon tolerance. TriangleStripArrayRetained1=stripVertexCounts element less than 3 RotationPathInterpolator0=RotationPathInterpolator: length of knots and quats must be of the same length @@ -891,6 +927,26 @@ ModelClip14=ModelClip: no capability to read influencing bounding leaf ModelClipRetained1=ModelClip: illegal node under SharedGroup Branch MasterControl0=OpenGL is not MT safe MasterControl1=Green threads are not supported +MasterControl2=NOTE: simulated multi-texture will not work for programmable shaders +MasterControl3=and will be removed entirely in the next release of Java 3D J3DBuffer0=Native access to NIO buffer not supported J3DBuffer1=NIO buffer must be a direct buffer J3DBuffer2=NIO buffer must match native byte order of underlying platform +GLSLShaderProgram0=GLSLShaderProgram: no capability to read names +GLSLShaderProgram1=GLSLShaderProgram: no capability to read shaders +GLSLShaderProgram2=GLSLShaderProgram: Shader has incompatible shading language +CgShaderProgram0=CgShaderProgram: no capability to read names +CgShaderProgram1=CgShaderProgram: no capability to read shaders +CgShaderProgram2=CgShaderProgram: Shader has incompatible shading language +CgShaderProgram3=CgShaderProgram: must not specify more than one vertex shader +CgShaderProgram4=CgShaderProgram: must not specify more than one fragment shader +ShaderAppearance0=ShaderAppearance: no capability to set shader program +ShaderAppearance1=ShaderAppearance: no capability to get shader program +ShaderAppearance2=ShaderAppearance: no capability to set shader attribute set +ShaderAppearance3=ShaderAppearance: no capability to get shader attribute set +ShaderAttributeBinding0=ShaderAttributeBinding is not supported +ShaderProgramRetained0=Shading language not supported +ShaderAttributeObject0=ShaderAttributeObject: no capability to get value +ShaderAttributeObject1=ShaderAttributeObject: no capability to set value +ShaderAttributeSet0=ShaderAttributeSet: no capability to get attribute +ShaderAttributeSet1=ShaderAttributeSet: no capability to set attribute diff --git a/src/classes/share/javax/media/j3d/ExponentialFog.java b/src/classes/share/javax/media/j3d/ExponentialFog.java index 75b17e1..9d95a32 100644 --- a/src/classes/share/javax/media/j3d/ExponentialFog.java +++ b/src/classes/share/javax/media/j3d/ExponentialFog.java @@ -46,6 +46,11 @@ public class ExponentialFog extends Fog { public static final int ALLOW_DENSITY_WRITE = CapabilityBits.EXPONENTIAL_FOG_ALLOW_DENSITY_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_DENSITY_READ + }; + /** * Constructs an ExponentialFog node with default parameters. * The default values are as follows: @@ -55,6 +60,8 @@ public class ExponentialFog extends Fog { */ public ExponentialFog() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -63,6 +70,9 @@ public class ExponentialFog extends Fog { */ public ExponentialFog(Color3f color) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -73,6 +83,10 @@ public class ExponentialFog extends Fog { */ public ExponentialFog(Color3f color, float density) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ExponentialFogRetained)this.retained).initDensity(density); } @@ -84,6 +98,9 @@ public class ExponentialFog extends Fog { */ public ExponentialFog(float r, float g, float b) { super(r, g, b); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -96,6 +113,10 @@ public class ExponentialFog extends Fog { */ public ExponentialFog(float r, float g, float b, float density) { super(r, g, b); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ExponentialFogRetained)this.retained).initDensity(density); } diff --git a/src/classes/share/javax/media/j3d/ExponentialFogRetained.java b/src/classes/share/javax/media/j3d/ExponentialFogRetained.java index 512e521..b82efd9 100644 --- a/src/classes/share/javax/media/j3d/ExponentialFogRetained.java +++ b/src/classes/share/javax/media/j3d/ExponentialFogRetained.java @@ -21,7 +21,10 @@ import java.util.ArrayList; */ class ExponentialFogRetained extends FogRetained { // Fog density - float density = 1.0f; + private float density = 1.0f; + + // Issue 144: density in Eye Coordinates (EC) + private float densityInEc; // dirty bits for ExponentialFog static final int DENSITY_CHANGED = FogRetained.LAST_DEFINED_BIT << 1; @@ -108,7 +111,9 @@ class ExponentialFogRetained extends FogRetained { native void update(long ctx, float red, float green, float blue, float density); void update(long ctx, double scale) { - update(ctx, color.x, color.y, color.z, density); + // Issue 144: recompute the density in EC, and send it to native code + validateDistancesInEc(scale); + update(ctx, color.x, color.y, color.z, densityInEc); } @@ -128,6 +133,8 @@ class ExponentialFogRetained extends FogRetained { ((ExponentialFogRetained)mirrorFog).density = ((Float)((Object[])objs[4])[4]).floatValue(); } + // Issue 144: store the local to vworld scale used to transform the density + ((ExponentialFogRetained)mirrorFog).setLocalToVworldScale(getLastLocalToVworld().getDistanceScale()); super.updateMirrorObject(objs); } @@ -142,6 +149,18 @@ class ExponentialFogRetained extends FogRetained { return efr; } - + + // Issue 144: method to recompute the density in EC by multiplying the specified + // density by the inverse of the local to EC scale + /** + * Scale distances from local to eye coordinate. + */ + protected void validateDistancesInEc(double vworldToCoexistenceScale) { + // vworldToCoexistenceScale can be used here since + // CoexistenceToEc has a unit scale + double localToEcScale = getLocalToVworldScale() * vworldToCoexistenceScale; + + densityInEc = (float)(density / localToEcScale); + } } diff --git a/src/classes/share/javax/media/j3d/Fog.java b/src/classes/share/javax/media/j3d/Fog.java index cb5e517..ffd2292 100644 --- a/src/classes/share/javax/media/j3d/Fog.java +++ b/src/classes/share/javax/media/j3d/Fog.java @@ -77,6 +77,13 @@ public abstract class Fog extends Leaf { public static final int ALLOW_SCOPE_WRITE = CapabilityBits.FOG_ALLOW_SCOPE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_INFLUENCING_BOUNDS_READ, + ALLOW_COLOR_READ, + ALLOW_SCOPE_READ + }; + /** * Constructs a Fog node with default parameters. The default * values are as follows: @@ -89,6 +96,8 @@ public abstract class Fog extends Leaf { */ public Fog() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -96,7 +105,10 @@ public abstract class Fog extends Leaf { * @param color the fog color */ public Fog(Color3f color) { - ((FogRetained)this.retained).initColor(color); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((FogRetained)this.retained).initColor(color); } /** @@ -106,7 +118,10 @@ public abstract class Fog extends Leaf { * @param b the blue component of the fog color */ public Fog(float r, float g, float b) { - ((FogRetained)this.retained).initColor(r, g, b); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((FogRetained)this.retained).initColor(r, g, b); } /** diff --git a/src/classes/share/javax/media/j3d/FogRetained.java b/src/classes/share/javax/media/j3d/FogRetained.java index 9c84fd5..9ab5ec6 100644 --- a/src/classes/share/javax/media/j3d/FogRetained.java +++ b/src/classes/share/javax/media/j3d/FogRetained.java @@ -90,6 +90,9 @@ abstract class FogRetained extends LeafRetained{ // Is true, if the mirror fog is viewScoped boolean isViewScoped = false; + // Scale value extracted from localToVworld transform + private double localToVworldScale = 1.0; + FogRetained() { localBounds = new BoundingBox(); ((BoundingBox)localBounds).setLower( 1.0, 1.0, 1.0); @@ -750,6 +753,8 @@ abstract class FogRetained extends LeafRetained{ } void updateTransformChange() { + super.updateTransformChange(); + setLocalToVworldScale(sgFog.getLastLocalToVworld().getDistanceScale()); } // Called on mirror object @@ -785,5 +790,19 @@ abstract class FogRetained extends LeafRetained{ void getMirrorObjects(ArrayList leafList, HashKey key) { leafList.add(mirrorFog); } - + + /** + * Scale distances from local to eye coordinate + */ + protected void validateDistancesInEc(double vworldToCoexistenceScale) { + assert false : "subclasses should override this method"; + } + + double getLocalToVworldScale() { + return localToVworldScale; + } + + void setLocalToVworldScale(double localToVworldScale) { + this.localToVworldScale = localToVworldScale; + } } diff --git a/src/classes/share/javax/media/j3d/Font3D.java b/src/classes/share/javax/media/j3d/Font3D.java index 5e440f8..d706abe 100644 --- a/src/classes/share/javax/media/j3d/Font3D.java +++ b/src/classes/share/javax/media/j3d/Font3D.java @@ -178,6 +178,49 @@ public class Font3D extends NodeComponent { bounds.setUpper(upper); } + // BY MIK OF CLASSX + /** + * Returns a GeometryArray of a glyph in this Font3D. + * + * @param c character from which to generate a tessellated glyph. + * + * @return a GeometryArray + * + * @since Java 3D 1.4 + */ + public GeometryArray getGlyphGeometry(char c) { + char code[] = { c }; + GlyphVector gv = font.createGlyphVector(frc, code); + + // triangulate the glyph + GeometryArrayRetained glyph_gar = triangulateGlyphs(gv, code[0]); + + // Assume that triangulateGlyphs returns a triangle array with only coords & normals + // (and without by-ref, interleaved, etc.) + assert glyph_gar instanceof TriangleArrayRetained : + "Font3D: GeometryArray is not an instance of TrangleArray"; + assert glyph_gar.getVertexFormat() == (GeometryArray.COORDINATES | GeometryArray.NORMALS) : + "Font3D: Illegal GeometryArray format -- only coordinates and normals expected"; + + // create a correctly sized TriangleArray + TriangleArray ga = new TriangleArray(glyph_gar.getVertexCount(),glyph_gar.getVertexFormat()); + + // temp storage for coords, normals + float tmp[] = new float[3]; + + int vertexCount = ga.getVertexCount(); + for(int i=0; i<vertexCount; i++) { + // copy the glyph geometry to the TriangleArray + glyph_gar.getCoordinate(i,tmp); + ga.setCoordinate(i,tmp); + + glyph_gar.getNormal(i,tmp); + ga.setNormal(i,tmp); + } + + return ga; + } + // Triangulate glyph with 'unicode' if not already done. GeometryArrayRetained triangulateGlyphs(GlyphVector gv, char c) { @@ -415,7 +458,7 @@ public class Font3D extends NodeComponent { } } - // TODO: Should use IndexedTriangleArray to avoid + // XXXX: Should use IndexedTriangleArray to avoid // duplication of vertices. To create triangles for // side faces, every vertex is duplicated currently. TriangleArray triAry = new TriangleArray(vertCnt, diff --git a/src/classes/share/javax/media/j3d/FreeListManager.java b/src/classes/share/javax/media/j3d/FreeListManager.java index f5c10c5..0233669 100644 --- a/src/classes/share/javax/media/j3d/FreeListManager.java +++ b/src/classes/share/javax/media/j3d/FreeListManager.java @@ -25,10 +25,9 @@ class FreeListManager { static final int DISPLAYLIST = 4; static final int TEXTURE2D = 5; static final int TEXTURE3D = 6; - static final int CANVASBIT = 7; - static final int VECTOR3D = 8; - static final int POINT3D = 9; - static int MAXINT = 9; + static final int VECTOR3D = 7; + static final int POINT3D = 8; + static int MAXINT = 8; // what list we are going to shrink next private static int currlist = 0; @@ -44,7 +43,6 @@ class FreeListManager { freelist[DISPLAYLIST] = new IntegerFreeList(); freelist[TEXTURE2D] = new IntegerFreeList(); freelist[TEXTURE3D] = new IntegerFreeList(); - freelist[CANVASBIT] = new IntegerFreeList(); freelist[POINT3D] = new MemoryFreeList("javax.vecmath.Point3d"); freelist[VECTOR3D] = new MemoryFreeList("javax.vecmath.Vector3d"); } diff --git a/src/classes/share/javax/media/j3d/GLSLShaderProgram.java b/src/classes/share/javax/media/j3d/GLSLShaderProgram.java new file mode 100644 index 0000000..5608cb8 --- /dev/null +++ b/src/classes/share/javax/media/j3d/GLSLShaderProgram.java @@ -0,0 +1,158 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The GLSLShaderProgram object is a concrete implementation of a + * ShaderProgram node component for the OpenGL GLSL shading language. + * + * @see SourceCodeShader + * + * @since Java 3D 1.4 + */ + +public class GLSLShaderProgram extends ShaderProgram { + + /** + * Constructs a GLSL shader program node component. + * + * <br> + * TODO: ADD MORE DOCUMENTATION HERE. + */ + public GLSLShaderProgram() { + } + + // Implement abstract setVertexAttrNames method (inherit javadoc from parent class) + public void setVertexAttrNames(String[] vertexAttrNames) { + checkForLiveOrCompiled(); + + if (vertexAttrNames != null) { + for (int i = 0; i < vertexAttrNames.length; i++) { + if (vertexAttrNames[i] == null) { + throw new NullPointerException(); + } + } + } + + ((GLSLShaderProgramRetained)this.retained).setVertexAttrNames(vertexAttrNames); + } + + // Implement abstract getVertexAttrNames method (inherit javadoc from parent class) + public String[] getVertexAttrNames() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_NAMES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); + } + } + + return ((GLSLShaderProgramRetained)this.retained).getVertexAttrNames(); + + } + + // Implement abstract setShaderAttrNames method (inherit javadoc from parent class) + public void setShaderAttrNames(String[] shaderAttrNames) { + checkForLiveOrCompiled(); + + if (shaderAttrNames != null) { + for (int i = 0; i < shaderAttrNames.length; i++) { + if (shaderAttrNames[i] == null) { + throw new NullPointerException(); + } + } + } + + ((GLSLShaderProgramRetained)this.retained).setShaderAttrNames(shaderAttrNames); + } + + // Implement abstract getShaderAttrNames method (inherit javadoc from parent class) + public String[] getShaderAttrNames() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_NAMES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram0")); + } + } + + return ((GLSLShaderProgramRetained)this.retained).getShaderAttrNames(); + + } + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading language of + * each shader in the array must be + * <code>SHADING_LANGUAGE_GLSL</code>. Each shader in the array must + * be a SourceCodeShader. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array is <em>not</em> + * <code>SHADING_LANGUAGE_GLSL</code>. + * + * @exception ClassCastException if any shader in the shaders + * array is <em>not</em> a SourceCodeShader. + * + * @exception NullPointerException if any element in the + * shaders array is null. + */ + public void setShaders(Shader[] shaders) { + checkForLiveOrCompiled(); + + if(shaders != null) { + // Check shaders for valid shading language and class type + for (int i = 0; i < shaders.length; i++) { + if (shaders[i].getShadingLanguage() != Shader.SHADING_LANGUAGE_GLSL) { + throw new IllegalArgumentException(J3dI18N.getString("GLSLShaderProgram2")); + } + + // Try to cast shader to SourceCodeShader; it will throw + // ClassCastException if it isn't. + SourceCodeShader shad = (SourceCodeShader)shaders[i]; + } + + } + + ((GLSLShaderProgramRetained)this.retained).setShaders(shaders); + } + + // Implement abstract getShaders method (inherit javadoc from parent class) + public Shader[] getShaders() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADERS_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GLSLShaderProgram1")); + } + } + + return ((GLSLShaderProgramRetained)this.retained).getShaders(); + } + + /** + * Creates a retained mode GLSLShaderProgramRetained object that this + * GLSLShaderProgram component object will point to. + */ + void createRetained() { + this.retained = new GLSLShaderProgramRetained(); + this.retained.setSource(this); + } + + +} diff --git a/src/classes/share/javax/media/j3d/GLSLShaderProgramRetained.java b/src/classes/share/javax/media/j3d/GLSLShaderProgramRetained.java new file mode 100644 index 0000000..7d4e10b --- /dev/null +++ b/src/classes/share/javax/media/j3d/GLSLShaderProgramRetained.java @@ -0,0 +1,281 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The GLSLShaderProgram object is a concrete implementation of a + * ShaderProgram node component for the OpenGL GLSL shading language. + * + * @see SourceCodeShader + * + * @since Java 3D 1.4 + */ + +class GLSLShaderProgramRetained extends ShaderProgramRetained { + + /** + * Constructs a GLSL shader program node component. + * + * <br> + * TODO: ADD MORE DOCUMENTATION HERE. + */ + GLSLShaderProgramRetained() { + } + + synchronized void createMirrorObject() { + // System.out.println("GLSLShaderProgramRetained : createMirrorObject"); + // This method should only call by setLive(). + if (mirror == null) { + GLSLShaderProgramRetained mirrorGLSLSP = new GLSLShaderProgramRetained(); + mirror = mirrorGLSLSP; + mirror.source = source; + } + initMirrorObject(); + } + + // ShaderAttributeValue methods + + native ShaderError setUniform1i(long ctx, + long shaderProgramId, + long uniformLocation, + int value); + + native ShaderError setUniform1f(long ctx, + long shaderProgramId, + long uniformLocation, + float value); + + native ShaderError setUniform2i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform2f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniform3i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniform4i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + native ShaderError setUniform4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniformMatrix3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + native ShaderError setUniformMatrix4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + // ShaderAttributeArray methods + + native ShaderError setUniform1iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform1fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform2iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform2fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform3iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniform4iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + native ShaderError setUniform4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniformMatrix3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + native ShaderError setUniformMatrix4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + /* New native interfaces */ + private native ShaderError createNativeShader(long ctx, int shaderType, long[] shaderId); + private native ShaderError destroyNativeShader(long ctx, long shaderId); + private native ShaderError compileNativeShader(long ctx, long shaderId, String program); + + private native ShaderError createNativeShaderProgram(long ctx, long[] shaderProgramId); + private native ShaderError destroyNativeShaderProgram(long ctx, long shaderProgramId); + private native ShaderError linkNativeShaderProgram(long ctx, long shaderProgramId, + long[] shaderId); + private native ShaderError bindNativeVertexAttrName(long ctx, long shaderProgramId, + String attrName, int attrIndex); + private native void lookupNativeShaderAttrNames(long ctx, long shaderProgramId, + int numAttrNames, String[] attrNames, long[] locArr, + int[] typeArr, int[] sizeArr, boolean[] isArrayArr); + + private native ShaderError useShaderProgram(long ctx, long shaderProgramId); + + /** + * Method to return a flag indicating whether this + * ShaderProgram is supported on the specified Canvas. + */ + boolean isSupported(Canvas3D cv) { + return cv.shadingLanguageGLSL; + } + + /** + * Method to create the native shader. + */ + ShaderError createShader(long ctx, ShaderRetained shader, long[] shaderIdArr) { + return createNativeShader(ctx, shader.shaderType, shaderIdArr); + } + + /** + * Method to destroy the native shader. + */ + ShaderError destroyShader(long ctx, long shaderId) { + return destroyNativeShader(ctx, shaderId); + } + + /** + * Method to compile the native shader. + */ + ShaderError compileShader(long ctx, long shaderId, String source) { + return compileNativeShader(ctx, shaderId, source ); + } + + /** + * Method to create the native shader program. + */ + ShaderError createShaderProgram(long ctx, long[] shaderProgramIdArr) { + return createNativeShaderProgram(ctx, shaderProgramIdArr); + } + + /** + * Method to destroy the native shader program. + */ + ShaderError destroyShaderProgram(long ctx, long shaderProgramId) { + return destroyNativeShaderProgram(ctx, shaderProgramId); + } + + /** + * Method to link the native shader program. + */ + ShaderError linkShaderProgram(long ctx, long shaderProgramId, long[] shaderIds) { + return linkNativeShaderProgram(ctx, shaderProgramId, shaderIds); + } + + ShaderError bindVertexAttrName(long ctx, long shaderProgramId, String attrName, int attrIndex) { + return bindNativeVertexAttrName(ctx, shaderProgramId, attrName, attrIndex); + } + + void lookupVertexAttrNames(long ctx, long shaderProgramId, String[] attrNames, boolean[] errArr) { + // This method is a no-op for GLSL + } + + void lookupShaderAttrNames(long ctx, long shaderProgramId, + String[] attrNames, AttrNameInfo[] attrNameInfoArr) { + + int numAttrNames = attrNames.length; + + long[] locArr = new long[numAttrNames]; + int[] typeArr = new int[numAttrNames]; + int[] sizeArr = new int[numAttrNames]; // currently unused + boolean[] isArrayArr = new boolean[numAttrNames]; + + // Initialize loc array to -1 (indicating no location) + for (int i = 0; i < numAttrNames; i++) { + locArr[i] = -1; + } + + lookupNativeShaderAttrNames(ctx, shaderProgramId, + numAttrNames, attrNames, locArr, typeArr, sizeArr, isArrayArr); + + for (int i = 0; i < numAttrNames; i++) { + attrNameInfoArr[i] = new AttrNameInfo(); + attrNameInfoArr[i].setLocation(locArr[i]); + attrNameInfoArr[i].setArray(isArrayArr[i]); + attrNameInfoArr[i].setType(typeArr[i]); +// System.err.println(attrNames[i] + +// " : loc = " + locArr[i] + +// ", type = " + typeArr[i] + +// ", isArray = " + isArrayArr[i] + +// ", size = " + sizeArr[i]); + } + } + + /** + * Method to enable the native shader program. + */ + ShaderError enableShaderProgram(long ctx, long shaderProgramId) { + return useShaderProgram(ctx, shaderProgramId); + } + + /** + * Method to disable the native shader program. + */ + ShaderError disableShaderProgram(long ctx) { + return useShaderProgram(ctx, 0); + } + + +} diff --git a/src/classes/share/javax/media/j3d/Geometry.java b/src/classes/share/javax/media/j3d/Geometry.java index 042b366..89391b1 100644 --- a/src/classes/share/javax/media/j3d/Geometry.java +++ b/src/classes/share/javax/media/j3d/Geometry.java @@ -32,14 +32,22 @@ package javax.media.j3d; public abstract class Geometry extends NodeComponent { /** - * Specifies that this Geometry allows intersect operation. + * Specifies that this Geometry allows intersect operation. This + * capability bit is set (true) by default for all Geometry objects. */ public static final int ALLOW_INTERSECT = CapabilityBits.GEOMETRY_ALLOW_INTERSECT; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_INTERSECT + }; + /** * Constructs a new Geometry object. */ public Geometry() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } } diff --git a/src/classes/share/javax/media/j3d/GeometryArray.java b/src/classes/share/javax/media/j3d/GeometryArray.java index 8851569..b784a11 100644 --- a/src/classes/share/javax/media/j3d/GeometryArray.java +++ b/src/classes/share/javax/media/j3d/GeometryArray.java @@ -17,7 +17,8 @@ import javax.vecmath.*; /** * The GeometryArray object contains separate arrays of positional - * coordinates, colors, normals, and texture coordinates that + * coordinates, colors, normals, texture coordinates, and vertex + * attributes that * describe point, line, or polygon geometry. This class is extended * to create the various primitive types (such as lines, * triangle strips, etc.). @@ -29,7 +30,8 @@ import javax.vecmath.*; * <li> * <b>By Copying:</b> * The existing methods for setting positional coordinates, colors, - * normals, and texture coordinates (such as <code>setCoordinate</code>, + * normals, texture coordinates, and vertex attributes + * (such as <code>setCoordinate</code>, * <code>setColors</code>, etc.) copy the data into this * GeometryArray. This is appropriate for many applications and * offers an application much flexibility in organizing its data. @@ -41,9 +43,11 @@ import javax.vecmath.*; * this feature, set the <code>BY_REFERENCE</code> bit in the * <code>vertexFormat</code> field of the constructor for this * GeometryArray. In this mode, the various set methods for - * coordinates, normals, colors, and texture coordinates are not used. + * coordinates, normals, colors, texture coordinates, and vertex attributes + * are not used. * Instead, new methods are used to set a reference to user-supplied - * coordinate, color, normal, and texture coordinate arrays (such as + * coordinate, color, normal, texture coordinate, and vertex attribute + * arrays (such as * <code>setCoordRefFloat</code>, <code>setColorRefFloat</code>, * etc.). Data in any array that is referenced by a live or compiled * GeometryArray object may only be modified via the @@ -133,6 +137,24 @@ public abstract class GeometryArray extends Geometry { ALLOW_TEXCOORD_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_TEXCOORD_WRITE; /** + * Specifies that this GeometryArray allows reading the array of + * vertex attributes. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_VERTEX_ATTR_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_READ; + + /** + * Specifies that this GeometryArray allows writing the array of + * vertex attributes. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_VERTEX_ATTR_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_WRITE; + + /** * Specifies that this GeometryArray allows reading the count or * initial index information for this object. */ @@ -268,15 +290,12 @@ public abstract class GeometryArray extends Geometry { * is only valid in conjunction with the <code>BY_REFERENCE</code> * flag. * - * <p> - * NOTE: Use of this class requires version 1.4 of the - * Java<sup><font size="-2">TM</font></sup> 2 Platform. - * * @see J3DBuffer * @see #setCoordRefBuffer(J3DBuffer) * @see #setColorRefBuffer(J3DBuffer) * @see #setNormalRefBuffer(J3DBuffer) * @see #setTexCoordRefBuffer(int,J3DBuffer) + * @see #setVertexAttrRefBuffer(int,J3DBuffer) * @see #setInterleavedVertexBuffer(J3DBuffer) * * @since Java 3D 1.3 @@ -287,17 +306,30 @@ public abstract class GeometryArray extends Geometry { * Specifies that only the coordinate indices are used for indexed * geometry arrays. In this mode, the values from the coordinate * index array are used as a single set of index values to access - * the vertex data for all four vertex components (coord, color, - * normal, and texCoord). The color, normal, and texCoord index arrays - * are ignored. This flag is only valid for indexed geometry arrays + * the vertex data for all five vertex components (coord, color, + * normal, texCoord, and vertexAttr). The color, normal, texCoord, + * and vertexAttr index arrays are neither allocated nor used. Any + * attempt to access the color, normal, texCoord, + * or vertexAttr index arrays will result in a NullPointerException. + * This flag is only valid for indexed geometry arrays * (subclasses of IndexedGeometryArray). * * @since Java 3D 1.3 */ public static final int USE_COORD_INDEX_ONLY = 0x200; + /** + * Specifies that this GeometryArray contains one or more arrays of + * vertex attributes. These attributes are used in programmable + * shading. + * + * @since Java 3D 1.4 + */ + public static final int VERTEX_ATTRIBUTES = 0x1000; + + // Used to keep track of the last bit (for adding new bits only) - private static final int LAST_FORMAT_BIT = 0x800; + private static final int LAST_FORMAT_BIT = 0x1000; // Scratch arrays for converting Point[234]f to TexCoord[234]f @@ -306,11 +338,26 @@ public abstract class GeometryArray extends Geometry { private TexCoord4f [] texCoord4fArray = null; private TexCoord2f texCoord2fScratch = null; private TexCoord3f texCoord3fScratch = null; - - + + private static final int[] defTexCoordMap = { 0 }; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COLOR_READ, + ALLOW_COORDINATE_READ, + ALLOW_COUNT_READ, + ALLOW_FORMAT_READ, + ALLOW_NORMAL_READ, + ALLOW_REF_DATA_READ, + ALLOW_TEXCOORD_READ, + ALLOW_VERTEX_ATTR_READ + }; + // non-public, no parameter constructor GeometryArray() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } @@ -321,12 +368,15 @@ public abstract class GeometryArray extends Geometry { * <ul> * texCoordSetCount : 1<br> * texCoordSetMap : { 0 }<br> + * vertexAttrCount : 0<br> + * vertexAttrSizes : null<br> * validVertexCount : vertexCount<br> * initialVertexIndex : 0<br> * initialCoordIndex : 0<br> * initialColorIndex : 0<br> * initialNormalIndex : 0<br> * initialTexCoordIndex : 0<br> + * initialVertexAttrIndex : 0<br> * all data array values : 0.0<br> * all data array references : null<br> * </ul> @@ -355,46 +405,29 @@ public abstract class GeometryArray extends Geometry { * <code>USE_COORD_INDEX_ONLY</code>, * to indicate that only the coordinate indices are used for indexed * geometry arrays. - * @exception IllegalArgumentException if vertexCount < 0, if - * vertexFormat does NOT include <code>COORDINATES</code>, - * if the <code>USE_COORD_INDEX_ONLY</code> bit is set for non-indexed - * geometry arrays (that is, GeometryArray objects that are not a - * subclass of IndexedGeometryArray), - * if the <code>INTERLEAVED</code> bit is set without the - * <code>BY_REFERENCE</code> bit being set, - * or if the <code>USE_NIO_BUFFER</code> bit is set without the - * <code>BY_REFERENCE</code> bit being set. + * + * @exception IllegalArgumentException if vertexCount < 0 + * + * @exception IllegalArgumentException if vertexFormat does <b>not</b> + * include <code>COORDINATES</code> + * + * @exception IllegalArgumentException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set for non-indexed geometry arrays (that is, GeometryArray objects + * that are not a subclass of IndexedGeometryArray) + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>USE_NIO_BUFFER</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit and the <code>VERTEX_ATTRIBUTES</code> bit are both set */ public GeometryArray(int vertexCount, int vertexFormat) { - - if (vertexCount < 0) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray96")); - - if ((vertexFormat & COORDINATES) == 0) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray0")); - - if ((vertexFormat & INTERLEAVED) != 0 && - (vertexFormat & BY_REFERENCE) == 0) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray80")); - - if ((vertexFormat & USE_NIO_BUFFER) != 0 && - (vertexFormat & BY_REFERENCE) == 0) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray117")); - - if ((vertexFormat & TEXTURE_COORDINATE) != 0) { - if ((vertexFormat & TEXTURE_COORDINATE_2) != 0) { - texCoord2fArray = new TexCoord2f[1]; - texCoord2fScratch = new TexCoord2f(); - } - else if ((vertexFormat & TEXTURE_COORDINATE_3) != 0) { - texCoord3fArray = new TexCoord3f[1]; - texCoord3fScratch = new TexCoord3f(); - } else if ((vertexFormat & TEXTURE_COORDINATE_4) != 0) { - texCoord4fArray = new TexCoord4f[1]; - } - } - - ((GeometryArrayRetained)this.retained).createGeometryArrayData(vertexCount, vertexFormat); + this(vertexCount, vertexFormat, + ((vertexFormat & TEXTURE_COORDINATE) != 0 ? 1 : 0), + ((vertexFormat & TEXTURE_COORDINATE) != 0 ? defTexCoordMap : null)); } @@ -467,48 +500,59 @@ public abstract class GeometryArray extends Geometry { * * <p> * <ul> - * <table BORDER=1 CELLSPACING=1 CELLPADDING=1> + * <table BORDER=1 CELLSPACING=2 CELLPADDING=2> * <tr> * <td><center><b>Index</b></center></td> * <td><center><b>Element</b></center></td> - * <td><center><b>Description</b></center></td> + * <td><b>Description</b></td> * </tr> * <tr> * <td><center>0</center></td> * <td><center>1</center></td> - * <td><center>Use tex coord set 1 for tex unit 0</center></td> + * <td>Use tex coord set 1 for tex unit 0</td> * </tr> * <tr> * <td><center>1</center></td> * <td><center>-1</center></td> - * <td><center>Use no tex coord set for tex unit 1</center></td> + * <td>Use no tex coord set for tex unit 1</td> * </tr> * <tr> * <td><center>2</center></td> * <td><center>0</center></td> - * <td><center>Use tex coord set 0 for tex unit 2</center></td> + * <td>Use tex coord set 0 for tex unit 2</td> * </tr> * <tr> * <td><center>3</center></td> * <td><center>1</center></td> - * <td><center>Reuse tex coord set 1 for tex unit 3</center></td> + * <td>Reuse tex coord set 1 for tex unit 3</td> * </tr> * </table> * </ul> * <p> * + * @exception IllegalArgumentException if vertexCount < 0 + * + * @exception IllegalArgumentException if vertexFormat does <b>not</b> + * include <code>COORDINATES</code> + * + * @exception IllegalArgumentException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set for non-indexed geometry arrays (that is, GeometryArray objects + * that are not a subclass of IndexedGeometryArray) + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>USE_NIO_BUFFER</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit and the <code>VERTEX_ATTRIBUTES</code> bit are both set + * * @exception IllegalArgumentException if - * <code>vertexCount < 0</code>, if vertexFormat does - * NOT include <code>COORDINATES</code>, if the - * <code>INTERLEAVED</code> bit is set without the - * <code>BY_REFERENCE</code> bit being set, if the - * <code>USE_NIO_BUFFER</code> bit is set without the - * <code>BY_REFERENCE</code> bit being set, if - * the <code>USE_COORD_INDEX_ONLY</code> bit is set for non-indexed - * geometry arrays (that is, GeometryArray objects that are not a - * subclass of IndexedGeometryArray), if - * <code>texCoordSetCount < 0</code>, or if any element - * in <code>texCoordSetMap[] >= texCoordSetCount</code>. + * <code>texCoordSetCount < 0</code> + * + * @exception IllegalArgumentException if any element in + * <code>texCoordSetMap[] >= texCoordSetCount</code>. * * @since Java 3D 1.2 */ @@ -516,20 +560,196 @@ public abstract class GeometryArray extends Geometry { int vertexFormat, int texCoordSetCount, int[] texCoordSetMap) { + this(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, 0, null); + } + + + /** + * Constructs an empty GeometryArray object with the specified + * number of vertices, vertex format, number of texture coordinate + * sets, texture coordinate mapping array, vertex attribute count, + * and vertex attribute sizes array. + * + * @param vertexCount the number of vertex elements in this + * GeometryArray<p> + * + * @param vertexFormat a mask indicating which components are + * present in each vertex. This is specified as one or more + * individual flags that are bitwise "OR"ed together to describe + * the per-vertex data. + * The flags include: <code>COORDINATES</code>, to signal the inclusion of + * vertex positions--always present; <code>NORMALS</code>, to signal + * the inclusion of per vertex normals; one of <code>COLOR_3</code> or + * <code>COLOR_4</code>, to signal the inclusion of per vertex + * colors (without or with alpha information); one of + * <code>TEXTURE_COORDINATE_2</code> or <code>TEXTURE_COORDINATE_3</code> + * or <code>TEXTURE_COORDINATE_4</code>, + * to signal the + * inclusion of per-vertex texture coordinates (2D , 3D or 4D); + * <code>VERTEX_ATTRIBUTES</code>, to signal + * the inclusion of one or more arrays of vertex attributes; + * <code>BY_REFERENCE</code>, to indicate that the data is passed + * by reference + * rather than by copying; <code>INTERLEAVED</code>, to indicate + * that the referenced + * data is interleaved in a single array; + * <code>USE_NIO_BUFFER</code>, to indicate that the referenced data + * is accessed via a J3DBuffer object that wraps an NIO buffer; + * <code>USE_COORD_INDEX_ONLY</code>, + * to indicate that only the coordinate indices are used for indexed + * geometry arrays.<p> + * + * @param texCoordSetCount the number of texture coordinate sets + * in this GeometryArray object. If <code>vertexFormat</code> + * does not include one of <code>TEXTURE_COORDINATE_2</code> or + * <code>TEXTURE_COORDINATE_3</code>, the + * <code>texCoordSetCount</code> parameter is not used.<p> + * + * <a name="texCoordSetMap"> + * @param texCoordSetMap an array that maps texture coordinate + * sets to texture units. The array is indexed by texture unit + * number for each texture unit in the associated Appearance + * object. The values in the array specify the texture coordinate + * set within this GeometryArray object that maps to the + * corresponding texture + * unit. All elements within the array must be less than + * <code>texCoordSetCount</code>. A negative value specifies that + * no texture coordinate set maps to the texture unit + * corresponding to the index. If there are more texture units in + * any associated Appearance object than elements in the mapping + * array, the extra elements are assumed to be -1. The same + * texture coordinate set may be used for more than one texture + * unit. Each texture unit in every associated Appearance must + * have a valid source of texture coordinates: either a + * non-negative texture coordinate set must be specified in the + * mapping array or texture coordinate generation must be enabled. + * Texture coordinate generation will take precedence for those + * texture units for which a texture coordinate set is specified + * and texture coordinate generation is enabled. If + * <code>vertexFormat</code> does not include one of + * <code>TEXTURE_COORDINATE_2</code> or + * <code>TEXTURE_COORDINATE_3</code> or + * <code>TEXTURE_COORDINATE_4</code>, the + * <code>texCoordSetMap</code> array is not used. The following example + * illustrates the use of the <code>texCoordSetMap</code> array. + * + * <p> + * <ul> + * <table BORDER=1 CELLSPACING=2 CELLPADDING=2> + * <tr> + * <td><center><b>Index</b></center></td> + * <td><center><b>Element</b></center></td> + * <td><b>Description</b></td> + * </tr> + * <tr> + * <td><center>0</center></td> + * <td><center>1</center></td> + * <td>Use tex coord set 1 for tex unit 0</td> + * </tr> + * <tr> + * <td><center>1</center></td> + * <td><center>-1</center></td> + * <td>Use no tex coord set for tex unit 1</td> + * </tr> + * <tr> + * <td><center>2</center></td> + * <td><center>0</center></td> + * <td>Use tex coord set 0 for tex unit 2</td> + * </tr> + * <tr> + * <td><center>3</center></td> + * <td><center>1</center></td> + * <td>Reuse tex coord set 1 for tex unit 3</td> + * </tr> + * </table> + * </ul> + * <p> + * + * @param vertexAttrCount the number of vertex attributes + * in this GeometryArray object. If <code>vertexFormat</code> + * does not include <code>VERTEX_ATTRIBUTES</code>, the + * <code>vertexAttrCount</code> parameter must be 0.<p> + * + * @param vertexAttrSizes is an array that specifes the size of + * each vertex attribute. Each element in the array specifies the + * number of components in the attribute, from 1 to 4. The length + * of the array must be equal to <code>vertexAttrCount</code>.<p> + * + * @exception IllegalArgumentException if vertexCount < 0 + * + * @exception IllegalArgumentException if vertexFormat does <b>not</b> + * include <code>COORDINATES</code> + * + * @exception IllegalArgumentException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set for non-indexed geometry arrays (that is, GeometryArray objects + * that are not a subclass of IndexedGeometryArray) + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>USE_NIO_BUFFER</code> + * bit is set without the <code>BY_REFERENCE</code> bit being set + * + * @exception IllegalArgumentException if the <code>INTERLEAVED</code> + * bit and the <code>VERTEX_ATTRIBUTES</code> bit are both set + * + * @exception IllegalArgumentException if + * <code>texCoordSetCount < 0</code> + * + * @exception IllegalArgumentException if any element in + * <code>texCoordSetMap[] >= texCoordSetCount</code>. + * + * @exception IllegalArgumentException if + * <code>vertexAttrCount > 0</code> and the + * <code>VERTEX_ATTRIBUTES</code> bit is not set + * + * @exception IllegalArgumentException if + * <code>vertexAttrCount < 0</code> + * + * @exception IllegalArgumentException if + * <code>vertexAttrSizes.length != vertexAttrCount</code> + * + * @exception IllegalArgumentException if any element in + * <code>vertexAttrSizes[]</code> is <code>< 1</code> or + * <code>> 4</code>. + * + * @since Java 3D 1.4 + */ + public GeometryArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) { if (vertexCount < 0) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray96")); + if (texCoordSetCount < 0) + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray124")); + + if (vertexAttrCount < 0) + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray125")); + if ((vertexFormat & COORDINATES) == 0) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray0" -)); + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray0")); if ((vertexFormat & INTERLEAVED) != 0 && (vertexFormat & BY_REFERENCE) == 0) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray80")); + if ((vertexFormat & INTERLEAVED) != 0 && + (vertexFormat & VERTEX_ATTRIBUTES) != 0) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray128")); + } + + if ((vertexFormat & USE_COORD_INDEX_ONLY) != 0 && + !(this instanceof IndexedGeometryArray)) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray135")); + } + if ((vertexFormat & USE_NIO_BUFFER) != 0 && - (vertexFormat & BY_REFERENCE) == 0) + (vertexFormat & BY_REFERENCE) == 0) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray117")); if ((vertexFormat & TEXTURE_COORDINATE) != 0) { @@ -556,8 +776,36 @@ public abstract class GeometryArray extends Geometry { texCoord4fArray = new TexCoord4f[1]; } } - - ((GeometryArrayRetained)this.retained).createGeometryArrayData(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap); + + if ((vertexFormat & VERTEX_ATTRIBUTES) != 0) { + if (vertexAttrCount > 0) { + if (vertexAttrCount != vertexAttrSizes.length) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray132")); + } + + for (int i = 0; i < vertexAttrSizes.length; i++) { + if (vertexAttrSizes[i] < 1 || vertexAttrSizes[i] > 4) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray133")); + } + } + } else { + if (vertexAttrSizes != null && vertexAttrSizes.length != 0) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray132")); + } + } + } else { + if (vertexAttrCount > 0) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray131")); + } + } + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((GeometryArrayRetained)this.retained).createGeometryArrayData( + vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); } @@ -636,7 +884,35 @@ public abstract class GeometryArray extends Geometry { */ public void getTexCoordSetMap(int[] texCoordSetMap) { ((GeometryArrayRetained)this.retained).getTexCoordSetMap(texCoordSetMap); - return; + } + + + /** + * Retrieves the number of vertex attributes in this GeometryArray + * object. + * + * @return the number of vertex attributes in this GeometryArray + * object + * + * @since Java 3D 1.4 + */ + public int getVertexAttrCount() { + return ((GeometryArrayRetained)this.retained).getVertexAttrCount(); + } + + + /** + * Retrieves the vertex attribute sizes array from this + * GeometryArray object. + * + * @param vertexAttrSizes an array that will receive a copy of + * the vertex attribute sizes array. The array must hold at least + * <code>vertexAttrCount</code> elements. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrSizes(int[] vertexAttrSizes) { + ((GeometryArrayRetained)this.retained).getVertexAttrSizes(vertexAttrSizes); } @@ -688,27 +964,30 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if any of the following are * true: * <ul> - * <code>validVertexCount < 0</code>,<br> - * <code>initialVertexIndex + validVertexCount > vertexCount</code>,<br> - * <code>initialCoordIndex + validVertexCount > vertexCount</code>,<br> - * <code>initialColorIndex + validVertexCount > vertexCount</code>,<br> - * <code>initialNormalIndex + validVertexCount > vertexCount</code>,<br> - * <code>initialTexCoordIndex + validVertexCount > vertexCount</code> + * <code>validVertexCount < 0</code>,<br> + * <code>initialVertexIndex + validVertexCount > vertexCount</code>,<br> + * <code>initialCoordIndex + validVertexCount > vertexCount</code>,<br> + * <code>initialColorIndex + validVertexCount > vertexCount</code>,<br> + * <code>initialNormalIndex + validVertexCount > vertexCount</code>,<br> + * <code>initialTexCoordIndex + validVertexCount > vertexCount</code>,<br> + * <code>initialVertexAttrIndex + validVertexCount > vertexCount</code> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if the geometry data format * is <code>BY_REFERENCE</code> and any the following * are true for non-null array references: * <ul> - * <code>CoordRef.length</code> < <i>num_words</i> * + * <code>CoordRef.length</code> < <i>num_words</i> * * (<code>initialCoordIndex + validVertexCount</code>),<br> - * <code>ColorRef.length</code> < <i>num_words</i> * + * <code>ColorRef.length</code> < <i>num_words</i> * * (<code>initialColorIndex + validVertexCount</code>),<br> - * <code>NormalRef.length</code> < <i>num_words</i> * + * <code>NormalRef.length</code> < <i>num_words</i> * * (<code>initialNormalIndex + validVertexCount</code>),<br> - * <code>TexCoordRef.length</code> < <i>num_words</i> * + * <code>TexCoordRef.length</code> < <i>num_words</i> * * (<code>initialTexCoordIndex + validVertexCount</code>),<br> - * <code>InterleavedVertices.length</code> < <i>words_per_vertex</i> * + * <code>VertexAttrRef.length</code> < <i>num_words</i> * + * (<code>initialVertexAttrIndex + validVertexCount</code>),<br> + * <code>InterleavedVertices.length</code> < <i>words_per_vertex</i> * * (<code>initialVertexIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of @@ -727,7 +1006,7 @@ public abstract class GeometryArray extends Geometry { throw new IllegalArgumentException(J3dI18N.getString("GeometryArray96")); ((GeometryArrayRetained)this.retained).setValidVertexCount(validVertexCount); - // NOTE: the checks for initial*Index + validVertexCount > + // NOTE: the checks for initial*Index + validVertexCount > // vertexCount need to be done in the retained method } @@ -770,61 +1049,99 @@ public abstract class GeometryArray extends Geometry { * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(NodeComponent originalNodeComponent, - boolean forceDuplicate) { - - super.duplicateAttributes(originalNodeComponent, forceDuplicate); - // vertexFormat and vertexCount are copied in subclass when constructor - // public GeometryArray(int vertexCount, int vertexFormat) is used - // in cloneNodeComponent() - GeometryArrayRetained src = (GeometryArrayRetained) originalNodeComponent.retained; - GeometryArrayRetained dst = (GeometryArrayRetained) retained; - int format = src.getVertexFormat(); - if ((format & BY_REFERENCE) == 0) { - System.arraycopy(src.vertexData, 0, dst.vertexData, 0, - src.vertexData.length); - dst.setInitialVertexIndex(src.getInitialVertexIndex()); - - } else { - dst.setInitialCoordIndex(src.getInitialCoordIndex()); - dst.setInitialColorIndex(src.getInitialColorIndex()); - dst.setInitialNormalIndex(src.getInitialNormalIndex()); - int setCount = src.getTexCoordSetCount(); - for (int i=0; i < setCount; i++) { - dst.setInitialTexCoordIndex(i, src.getInitialTexCoordIndex(i)); - } - if ((format & INTERLEAVED) == 0) { - dst.setCoordRefFloat(src.getCoordRefFloat()); - dst.setCoordRefDouble(src.getCoordRefDouble()); - dst.setCoordRef3f(src.getCoordRef3f()); - dst.setCoordRef3d(src.getCoordRef3d()); - dst.setColorRefFloat(src.getColorRefFloat()); - dst.setColorRefByte(src.getColorRefByte()); - if ((format & WITH_ALPHA) == 0) { - dst.setColorRef3f(src.getColorRef3f()); - dst.setColorRef3b(src.getColorRef3b()); - } else { - dst.setColorRef4f(src.getColorRef4f()); - dst.setColorRef4b(src.getColorRef4b()); - } - dst.setNormalRefFloat(src.getNormalRefFloat()); - dst.setNormalRef3f(src.getNormalRef3f()); - for (int i=0; i < setCount; i++) { - dst.setTexCoordRefFloat(i, src.getTexCoordRefFloat(i)); - } - if ((format & TEXTURE_COORDINATE_2) != 0) { - for (int i=0; i < setCount; i++) { - dst.setTexCoordRef2f(i, src.getTexCoordRef2f(i)); - } - } - if ((format & TEXTURE_COORDINATE_3) != 0) { - for (int i=0; i < setCount; i++) { - dst.setTexCoordRef3f(i, src.getTexCoordRef3f(i)); - } - } - } else { - dst.setInterleavedVertices(src.getInterleavedVertices()); - } - } + boolean forceDuplicate) { + + super.duplicateAttributes(originalNodeComponent, forceDuplicate); + // vertexFormat and vertexCount are copied in subclass when constructor + // public GeometryArray(int vertexCount, int vertexFormat) is used + // in cloneNodeComponent() + GeometryArrayRetained src = (GeometryArrayRetained) originalNodeComponent.retained; + GeometryArrayRetained dst = (GeometryArrayRetained) retained; + int format = src.getVertexFormat(); + if ((format & BY_REFERENCE) == 0) { + System.arraycopy(src.vertexData, 0, dst.vertexData, 0, + src.vertexData.length); + dst.setInitialVertexIndex(src.getInitialVertexIndex()); + + } else { + dst.setInitialCoordIndex(src.getInitialCoordIndex()); + dst.setInitialColorIndex(src.getInitialColorIndex()); + dst.setInitialNormalIndex(src.getInitialNormalIndex()); + int setCount = src.getTexCoordSetCount(); + int vAttrCount = src.getVertexAttrCount(); + for (int i=0; i < setCount; i++) { + dst.setInitialTexCoordIndex(i, src.getInitialTexCoordIndex(i)); + } + if ((format & INTERLEAVED) == 0) { + if ((format & USE_NIO_BUFFER) == 0) { + // Java arrays + dst.setCoordRefFloat(src.getCoordRefFloat()); + dst.setCoordRefDouble(src.getCoordRefDouble()); + dst.setCoordRef3f(src.getCoordRef3f()); + dst.setCoordRef3d(src.getCoordRef3d()); + dst.setColorRefFloat(src.getColorRefFloat()); + dst.setColorRefByte(src.getColorRefByte()); + if ((format & WITH_ALPHA) == 0) { + dst.setColorRef3f(src.getColorRef3f()); + dst.setColorRef3b(src.getColorRef3b()); + } else { + dst.setColorRef4f(src.getColorRef4f()); + dst.setColorRef4b(src.getColorRef4b()); + } + dst.setNormalRefFloat(src.getNormalRefFloat()); + dst.setNormalRef3f(src.getNormalRef3f()); + + switch (src.getVertexAttrType()) { + case GeometryArrayRetained.AF: + for (int i=0; i < vAttrCount; i++) { + dst.setVertexAttrRefFloat(i, src.getVertexAttrRefFloat(i)); + } + break; + } + + switch (src.getTexCoordType()) { + case GeometryArrayRetained.TF: + for (int i=0; i < setCount; i++) { + dst.setTexCoordRefFloat(i, src.getTexCoordRefFloat(i)); + } + break; + case GeometryArrayRetained.T2F: + for (int i=0; i < setCount; i++) { + dst.setTexCoordRef2f(i, src.getTexCoordRef2f(i)); + } + break; + case GeometryArrayRetained.T3F: + for (int i=0; i < setCount; i++) { + dst.setTexCoordRef3f(i, src.getTexCoordRef3f(i)); + } + break; + } + } else { + // NIO buffer + dst.setCoordRefBuffer(src.getCoordRefBuffer()); + dst.setColorRefBuffer(src.getColorRefBuffer()); + dst.setNormalRefBuffer(src.getNormalRefBuffer()); + + switch (src.getVertexAttrType()) { + case GeometryArrayRetained.AF: + for (int i=0; i < vAttrCount; i++) { + dst.setVertexAttrRefBuffer(i, src.getVertexAttrRefBuffer(i)); + } + break; + } + + switch (src.getTexCoordType()) { + case GeometryArrayRetained.TF: + for (int i=0; i < setCount; i++) { + dst.setTexCoordRefBuffer(i, src.getTexCoordRefBuffer(i)); + } + break; + } + } + } else { + dst.setInterleavedVertices(src.getInterleavedVertices()); + } + } } @@ -848,15 +1165,15 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if either of the following are * true: * <ul> - * <code>initialVertexIndex < 0</code> or<br> - * <code>initialVertexIndex + validVertexCount > vertexCount</code><br> + * <code>initialVertexIndex < 0</code> or<br> + * <code>initialVertexIndex + validVertexCount > vertexCount</code><br> * </ul> * * @exception ArrayIndexOutOfBoundsException if the geometry data format * is <code>INTERLEAVED</code>, the InterleavedVertices array is * non-null, and: * <ul> - * <code>InterleavedVertices.length</code> < <i>num_words</i> * + * <code>InterleavedVertices.length</code> < <i>num_words</i> * * (<code>initialVertexIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which vertex formats are enabled. @@ -2271,7 +2588,7 @@ public abstract class GeometryArray extends Geometry { if (((((GeometryArrayRetained)this.retained).vertexFormat) & - (TEXTURE_COORDINATE_2 | TEXTURE_COORDINATE_3)) != 0) + (TEXTURE_COORDINATE_2 | TEXTURE_COORDINATE_4)) != 0) throw new IllegalStateException(J3dI18N.getString("GeometryArray95")); ((GeometryArrayRetained)this.retained).setTextureCoordinates( @@ -2338,7 +2655,7 @@ public abstract class GeometryArray extends Geometry { * * @param index starting destination vertex index in this geometry array * @param texCoords source array of 2*n , 3*n or 4*n values containing - * n new * texture coordinates + * n new texture coordinates * @param start starting source vertex index in <code>texCoords</code> * array. * @param length number of texture Coordinates to be copied. @@ -2531,6 +2848,581 @@ public abstract class GeometryArray extends Geometry { texCoordSet, index, texCoords, start, length); } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr source array of 1, 2, 3 or 4 values containing + * the new vertex attribute + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttr(int vertexAttrNum, int index, + float[] vertexAttr) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttr, 0, 1); + } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point2f containing the new vertex attribute + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 2. + * + * @since Java 3D 1.4 + */ + public void setVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 2) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point3f containing the new vertex attribute + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 3. + * + * @since Java 3D 1.4 + */ + public void setVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 3) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point4f containing the new vertex attribute + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 4. + * + * @since Java 3D 1.4 + */ + public void setVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 4) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Sets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The entire source array is copied to this + * geometry array. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of 1*n, 2*n, 3*n, or 4*n values + * containing n new vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too large. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, 0, vertexAttrs.length / size); + } + + /** + * Sets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The entire source array is copied to this + * geometry array. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point2f objects containing new + * vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too large. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 2. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 2) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, 0, vertexAttrs.length); + } + + /** + * Sets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The entire source array is copied to this + * geometry array. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point3f objects containing new + * vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too large. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 3. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 3) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, 0, vertexAttrs.length); + } + + /** + * Sets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The entire source array is copied to this + * geometry array. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point4f objects containing new + * vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too large. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 4. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 4) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, 0, vertexAttrs.length); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of 1*n, 2*n, 3*n, or 4*n values + * containing n new vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if any of index, + * (index+length), or vertexAttrNum are out of range, or if + * vertexAttrs is too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs, + int start, int length) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, start, length); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point2f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if any of index, + * (index+length), or vertexAttrNum are out of range, or if + * vertexAttrs is too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 2. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs, + int start, int length) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 2) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, start, length); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point3f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if any of index, + * (index+length), or vertexAttrNum are out of range, or if + * vertexAttrs is too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 3. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs, + int start, int length) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 3) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, start, length); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point4f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if any of index, + * (index+length), or vertexAttrNum are out of range, or if + * vertexAttrs is too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 4. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs, + int start, int length) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray126")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 4) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrs( + vertexAttrNum, index, vertexAttrs, start, length); + } + + /** * Gets the coordinate associated with the vertex at * the specified index for this object using data in <code>texCoords</code> @@ -3714,6 +4606,384 @@ public abstract class GeometryArray extends Geometry { texCoordSet, index, texCoords); } + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index source vertex index in this geometry array + * @param vertexAttr array of 1, 2, 3 or 4 values that will receive the + * vertex attribute + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range, or if the vertexAttr array is + * too small. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @since Java 3D 1.4 + */ + public void getVertexAttr(int vertexAttrNum, int index, + float[] vertexAttr) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index source vertex index in this geometry array + * @param vertexAttr the vector that will receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 2. + * + * @since Java 3D 1.4 + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 2) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index source vertex index in this geometry array + * @param vertexAttr the vector that will receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 3. + * + * @since Java 3D 1.4 + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 3) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index source vertex index in this geometry array + * @param vertexAttr the vector that will receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 4. + * + * @since Java 3D 1.4 + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 4) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttr( + vertexAttrNum, index, vertexAttr); + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The length of the destination + * array determines the number of vertex attributes copied. + * A maximum of <code>vertexCount-index</code> vertex attributes + * are copied. If the destination array is larger than is needed + * to hold the vertex attributes, the excess locations in the + * array are not modified. If the destination array is smaller + * than is needed to hold the vertex attributes, only as + * many vertex attributes as the array will hold are copied. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting source vertex index in this geometry array + * @param vertexAttrs destination array of 1*n, 2*n, 3*n, or 4*n values + * that will receive n new vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttrs( + vertexAttrNum, index, vertexAttrs); + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The length of the destination + * array determines the number of vertex attributes copied. + * A maximum of <code>vertexCount-index</code> vertex attributes + * are copied. If the destination array is larger than is needed + * to hold the vertex attributes, the excess locations in the + * array are not modified. If the destination array is smaller + * than is needed to hold the vertex attributes, only as + * many vertex attributes as the array will hold are copied. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting source vertex index in this geometry array + * @param vertexAttrs destination array of Point2f objects that will + * receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 2. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 2) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttrs( + vertexAttrNum, index, vertexAttrs); + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The length of the destination + * array determines the number of vertex attributes copied. + * A maximum of <code>vertexCount-index</code> vertex attributes + * are copied. If the destination array is larger than is needed + * to hold the vertex attributes, the excess locations in the + * array are not modified. If the destination array is smaller + * than is needed to hold the vertex attributes, only as + * many vertex attributes as the array will hold are copied. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting source vertex index in this geometry array + * @param vertexAttrs destination array of Point3f objects that will + * receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 3. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 3) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttrs( + vertexAttrNum, index, vertexAttrs); + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. The length of the destination + * array determines the number of vertex attributes copied. + * A maximum of <code>vertexCount-index</code> vertex attributes + * are copied. If the destination array is larger than is needed + * to hold the vertex attributes, the excess locations in the + * array are not modified. If the destination array is smaller + * than is needed to hold the vertex attributes, only as + * many vertex attributes as the array will hold are copied. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting source vertex index in this geometry array + * @param vertexAttrs destination array of Point4f objects that will + * receive the vertex attributes + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception IllegalStateException if the data mode for this geometry + * array object is <code>BY_REFERENCE</code>. + * + * @exception IllegalStateException if the size of the specified + * vertex attribute number is not 4. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_VERTEX_ATTR_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray127")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray82")); + } + + int size = ((GeometryArrayRetained)this.retained).vertexAttrSizes[vertexAttrNum]; + if (size != 4) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray134")); + } + + ((GeometryArrayRetained)this.retained).getVertexAttrs( + vertexAttrNum, index, vertexAttrs); + } + //------------------------------------------------------------------ // By-reference methods @@ -3742,14 +5012,14 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if either of the following are * true: * <ul> - * <code>initialCoordIndex < 0</code> or<br> - * <code>initialCoordIndex + validVertexCount > vertexCount</code><br> + * <code>initialCoordIndex < 0</code> or<br> + * <code>initialCoordIndex + validVertexCount > vertexCount</code><br> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if * the CoordRef array is non-null and: * <ul> - * <code>CoordRef.length</code> < <i>num_words</i> * + * <code>CoordRef.length</code> < <i>num_words</i> * * (<code>initialCoordIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of @@ -3820,14 +5090,14 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if either of the following are * true: * <ul> - * <code>initialColorIndex < 0</code> or<br> - * <code>initialColorIndex + validVertexCount > vertexCount</code><br> + * <code>initialColorIndex < 0</code> or<br> + * <code>initialColorIndex + validVertexCount > vertexCount</code><br> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if * the ColorRef array is non-null and: * <ul> - * <code>ColorRef.length</code> < <i>num_words</i> * + * <code>ColorRef.length</code> < <i>num_words</i> * * (<code>initialColorIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of @@ -3898,14 +5168,14 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if either of the following are * true: * <ul> - * <code>initialNormalIndex < 0</code> or<br> - * <code>initialNormalIndex + validVertexCount > vertexCount</code><br> + * <code>initialNormalIndex < 0</code> or<br> + * <code>initialNormalIndex + validVertexCount > vertexCount</code><br> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if normals * the NormalRef array is non-null and: * <ul> - * <code>NormalRef.length</code> < <i>num_words</i> * + * <code>NormalRef.length</code> < <i>num_words</i> * * (<code>initialNormalIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of @@ -3979,14 +5249,14 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if either of the following are * true: * <ul> - * <code>initialTexCoordIndex < 0</code> or<br> - * <code>initialTexCoordIndex + validVertexCount > vertexCount</code><br> + * <code>initialTexCoordIndex < 0</code> or<br> + * <code>initialTexCoordIndex + validVertexCount > vertexCount</code><br> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if * the TexCoordRef array is non-null and: * <ul> - * <code>TexCoordRef.length</code> < <i>num_words</i> * + * <code>TexCoordRef.length</code> < <i>num_words</i> * * (<code>initialTexCoordIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of @@ -4054,6 +5324,109 @@ public abstract class GeometryArray extends Geometry { /** + * Sets the initial vertex attribute index for the specified + * vertex attribute number for this GeometryArray object. This + * index specifies the first vertex attribute within the array + * of vertex attributes referenced by this geometry array that + * is actually used in rendering or other operations such as + * picking and collision. This attribute is initialized to 0. + * This attribute is only used when the data mode for this + * geometry array object is <code>BY_REFERENCE</code> + * and is <i>not</i> </code>INTERLEAVED</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param initialVertexAttrIndex the new initial vertex attribute index. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * <p> + * @exception IllegalStateException if the data mode for this geometry + * array object is not <code>BY_REFERENCE</code> or if the data mode + * is <code>INTERLEAVED</code>. + * <p> + * @exception IllegalArgumentException if either of the following are + * true: + * <ul> + * <code>initialVertexAttrIndex < 0</code> or<br> + * <code>initialVertexAttrIndex + validVertexCount > vertexCount</code><br> + * </ul> + * <p> + * @exception ArrayIndexOutOfBoundsException if + * the VertexAttrRef array is non-null and: + * <ul> + * <code>VertexAttrRef.length</code> < <i>num_words</i> * + * (<code>initialVertexAttrIndex + validVertexCount</code>)<br> + * </ul> + * where <i>num_words</i> is the size of the specified + * vertexAttrNum (1, 2, 3, or 4). + * <p> + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is + * out of range. + * + * @since Java 3D 1.4 + */ + public void setInitialVertexAttrIndex(int vertexAttrNum, + int initialVertexAttrIndex) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_COUNT_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90")); + } + } + + if (initialVertexAttrIndex < 0) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97")); + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) == 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray83")); + } + + if ((format & INTERLEAVED) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray84")); + } + + ((GeometryArrayRetained)this.retained).setInitialVertexAttrIndex( + vertexAttrNum, initialVertexAttrIndex); + + // NOTE: the check for initialVertexAttrIndex + validVertexCount > + // vertexCount needs to be done in the retained method + } + + + /** + * Gets the initial vertex attribute index for the specified + * vertex attribute number for this GeometryArray object. + * This attribute is only used when the data mode for this + * geometry array object is <code>BY_REFERENCE</code> + * and is <i>not</i> </code>INTERLEAVED</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * + * @return the current initial vertex attribute index for the specified + * vertex attribute number + * + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is + * out of range. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public int getInitialVertexAttrIndex(int vertexAttrNum) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_COUNT_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91")); + } + } + + return ((GeometryArrayRetained)this.retained).getInitialVertexAttrIndex( + vertexAttrNum); + } + + + /** * Sets the coordinate buffer reference to the specified * buffer object. The buffer contains either a java.nio.FloatBuffer * or java.nio.DoubleBuffer object containing single or double @@ -4081,7 +5454,7 @@ public abstract class GeometryArray extends Geometry { * java.nio.FloatBuffer or a java.nio.DoubleBuffer object. * * @exception ArrayIndexOutOfBoundsException if - * <code>coords.getBuffer().limit() < + * <code>coords.getBuffer().limit() < * 3 * (initialCoordIndex + validVertexCount)</code>. * * @exception ArrayIndexOutOfBoundsException if this GeometryArray @@ -4164,7 +5537,7 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if the specified array is * non-null and any other coordinate reference is also non-null. * @exception ArrayIndexOutOfBoundsException if - * <code>coords.length < 3 * (initialCoordIndex + validVertexCount)</code>. + * <code>coords.length < 3 * (initialCoordIndex + validVertexCount)</code>. * * @exception ArrayIndexOutOfBoundsException if this GeometryArray * object is a subclass of IndexedGeometryArray, and any element @@ -4253,7 +5626,7 @@ public abstract class GeometryArray extends Geometry { * @exception IllegalArgumentException if the specified array is * non-null and any other coordinate reference is also non-null. * @exception ArrayIndexOutOfBoundsException if - * <code>coords.length < 3 * (initialCoordIndex + validVertexCount)</code>. + * <code>coords.length < 3 * (initialCoordIndex + validVertexCount)</code>. * * @exception ArrayIndexOutOfBoundsException if this GeometryArray * object is a subclass of IndexedGeometryArray, and any element @@ -4456,7 +5829,7 @@ public abstract class GeometryArray extends Geometry { * @exception ArrayIndexOutOfBoundsException if none of the * <code>COLOR</code> bits are set in the * <code>vertexFormat</code>, or if - * <code>colors.getBuffer().limit() < </code> <i>num_words</i> <code> * + * <code>colors.getBuffer().limit() < </code> <i>num_words</i> <code> * * (initialColorIndex + validVertexCount)</code>, * where <i>num_words</i> is 3 or 4 depending on the vertex color format. * @@ -4549,7 +5922,7 @@ public abstract class GeometryArray extends Geometry { * @exception ArrayIndexOutOfBoundsException if none of the * <code>COLOR</code> bits are set in the * <code>vertexFormat</code>, or if - * <code>colors.length < </code> <i>num_words</i> <code> * + * <code>colors.length < </code> <i>num_words</i> <code> * * (initialColorIndex + validVertexCount)</code>, * where <i>num_words</i> is 3 or 4 depending on the vertex color format. * @@ -4646,7 +6019,7 @@ public abstract class GeometryArray extends Geometry { * @exception ArrayIndexOutOfBoundsException if none of the * <code>COLOR</code> bits are set in the * <code>vertexFormat</code>, or if - * <code>colors.length < </code> <i>num_words</i> <code> * + * <code>colors.length < </code> <i>num_words</i> <code> * * (initialColorIndex + validVertexCount)</code>, * where <i>num_words</i> is 3 or 4 depending on the vertex color format. * @@ -4978,7 +6351,7 @@ public abstract class GeometryArray extends Geometry { * @exception ArrayIndexOutOfBoundsException if * <code>NORMALS</code> bit is not set in the * <code>vertexFormat</code>, or if - * <code>normals.getBuffer().limit() < + * <code>normals.getBuffer().limit() < * 3 * (initialNormalIndex + validVertexCount)</code>. * * @exception ArrayIndexOutOfBoundsException if this GeometryArray @@ -5064,7 +6437,7 @@ public abstract class GeometryArray extends Geometry { * @exception ArrayIndexOutOfBoundsException if * <code>NORMALS</code> bit is not set in the * <code>vertexFormat</code>, or if - * <code>normals.length < 3 * (initialNormalIndex + validVertexCount)</code>. + * <code>normals.length < 3 * (initialNormalIndex + validVertexCount)</code>. * * @exception ArrayIndexOutOfBoundsException if this GeometryArray * object is a subclass of IndexedGeometryArray, and any element @@ -5186,7 +6559,7 @@ public abstract class GeometryArray extends Geometry { /** - * Sets the texture coordinate array reference for the specified + * Sets the texture coordinate buffer reference for the specified * texture coordinate set to the * specified buffer object. The buffer contains a java.nio.FloatBuffer * object containing <i>s</i>, @@ -5223,7 +6596,7 @@ public abstract class GeometryArray extends Geometry { * <code>TEXTURE_COORDINATE</code> bits are set in the * <code>vertexFormat</code>, or if texCoordSet is out of range, * or if - * <code>texCoords.getBuffer().limit() < </code> <i>num_words</i> + * <code>texCoords.getBuffer().limit() < </code> <i>num_words</i> * <code> * (initialTexCoordIndex + validVertexCount)</code>, * where <i>num_words</i> is 2, 3, or 4 depending on the vertex * texture coordinate format. @@ -5336,7 +6709,7 @@ public abstract class GeometryArray extends Geometry { * <code>TEXTURE_COORDINATE</code> bits are set in the * <code>vertexFormat</code>, or if texCoordSet is out of range, * or if - * <code>texCoords.length < </code> <i>num_words</i> <code> * + * <code>texCoords.length < </code> <i>num_words</i> <code> * * (initialTexCoordIndex + validVertexCount)</code>, * where <i>num_words</i> is 2, 3, or 4 depending on the vertex * texture coordinate format. @@ -5543,11 +6916,265 @@ public abstract class GeometryArray extends Geometry { texCoordSet); } + + /** + * Sets the vertex attribute buffer reference for the specified + * vertex attribute number to the specified buffer object. The + * buffer contains a java.nio.FloatBuffer object containing 1, 2, + * 3, or 4 values for each vertex (for a total of 1*<i>n</i>, + * 2*<i>n</i>, 3*<i>n</i>, or 4*<i>n</i> values, where <i>n</i> is + * the number of vertices). + * If the vertexAttr buffer reference is null and vertex + * attributes are enabled (that is, the vertexFormat includes + * <code>VERTEX_ATTRIBUTES</code>), the entire geometry array + * object is treated as if it were null--any Shape3D node that + * uses this geometry array will not be drawn. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * + * @param vertexAttrs a J3DBuffer object to which a reference will + * be set. The buffer contains an NIO buffer of 1*<i>n</i>, + * 2*<i>n</i>, 3*<i>n</i>, or 4*<i>n</i> float values. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception IllegalStateException if the data mode for this geometry + * array object is not <code>BY_REFERENCE</code>, + * is not <code>USE_NIO_BUFFER</code>, or is <code>INTERLEAVED</code>. + * + * @exception IllegalArgumentException if the java.nio.Buffer + * contained in the specified J3DBuffer is not a + * java.nio.FloatBuffer object. + * + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is out of + * range, or if + * <code>vertexAttrs.getBuffer().limit() < </code> <i>num_words</i> + * <code> * (initialVertexAttrIndex + validVertexCount)</code>, + * where <i>num_words</i> is the size of the specified + * vertexAttrNum (1, 2, 3, or 4). + * + * @exception ArrayIndexOutOfBoundsException if this GeometryArray + * object is a subclass of IndexedGeometryArray, and any element + * in the range + * <code>[initialIndexIndex, initialIndexIndex+validIndexCount-1]</code> + * in the vertex attribute index array is greater than or equal to the + * number of vertices defined by the vertexAttrs object, + * <code>vertexAttrs.getBuffer().limit() / </code> <i>num_words</i>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrRefBuffer(int vertexAttrNum, J3DBuffer vertexAttrs) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_REF_DATA_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + + if ((format & USE_NIO_BUFFER) == 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray118")); + } + + if ((format & INTERLEAVED) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray84")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrRefBuffer( + vertexAttrNum, vertexAttrs); + } + + + /** + * Gets the vertex attribute array buffer reference for the specified + * vertex attribute number. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * + * @return the current vertex attribute array buffer reference + * for the specified vertex attribute number + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception IllegalStateException if the data mode for this geometry + * array object is not <code>BY_REFERENCE</code>, + * is not <code>USE_NIO_BUFFER</code>, or is <code>INTERLEAVED</code>. + * + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is out + * of range. + * + * @since Java 3D 1.4 + */ + public J3DBuffer getVertexAttrRefBuffer(int vertexAttrNum) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_REF_DATA_READ) && + !this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) { + + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + + if ((format & USE_NIO_BUFFER) == 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray118")); + } + + if ((format & INTERLEAVED) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray84")); + } + + return ((GeometryArrayRetained)this.retained).getVertexAttrRefBuffer(vertexAttrNum); + } + + + /* + * XXXX: add the following to the javadoc if we ever add double-precision + * methods for vertex attribtues. + * + *----------------------------------------------------------------- + * Only one of <code>vertexAttrRefFloat</code>, or + * <code>vertexAttrRefDouble</code> may be non-null (or they may + * all be null). An attempt to set more than one of these + * attributes to a non-null reference will result in an exception + * being thrown. + * + * If all vertexAttr array references are null and vertex + * ... + * @exception IllegalArgumentException if the specified array is + * non-null and any other vertexAttr reference is also non-null. + * ... + *----------------------------------------------------------------- + */ + + /** + * Sets the float vertex attribute array reference for the + * specified vertex attribute number to the specified array. The + * array contains 1, 2, 3, or 4 floating-point values for each + * vertex (for a total of 1*<i>n</i>, 2*<i>n</i>, 3*<i>n</i>, or + * 4*<i>n</i> values, where <i>n</i> is the number of vertices). + * + * If the vertexAttr array reference is null and vertex + * attributes are enabled (that is, the vertexFormat includes + * <code>VERTEX_ATTRIBUTES</code>), the entire geometry array + * object is treated as if it were null--any Shape3D node that + * uses this geometry array will not be drawn. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * + * @param vertexAttrs an array of 1*<i>n</i>, 2*<i>n</i>, + * 3*<i>n</i>, or 4*<i>n</i> values to which a reference will be + * set. + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * @exception IllegalStateException if the data mode for this geometry + * array object is not <code>BY_REFERENCE</code>, + * is <code>USE_NIO_BUFFER</code>, or is <code>INTERLEAVED</code>. + * + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is + * out of range, or if + * <code>vertexAttrs.length < </code> <i>num_words</i> <code> * + * (initialVertexAttrIndex + validVertexCount)</code>, + * where <i>num_words</i> is the size of the specified + * vertexAttrNum (1, 2, 3, or 4). + * + * @exception ArrayIndexOutOfBoundsException if this GeometryArray + * object is a subclass of IndexedGeometryArray, and any element + * in the range + * <code>[initialIndexIndex, initialIndexIndex+validIndexCount-1]</code> + * in the vertex attribute index array is greater than or equal to the + * number of vertices defined by the vertexAttrs array, + * <code>vertexAttrs.length / </code> <i>num_words</i>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrRefFloat(int vertexAttrNum, float[] vertexAttrs) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_REF_DATA_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) == 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray83")); + } + + if ((format & USE_NIO_BUFFER) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray119")); + } + + if ((format & INTERLEAVED) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray84")); + } + + ((GeometryArrayRetained)this.retained).setVertexAttrRefFloat( + vertexAttrNum, vertexAttrs); + + // NOTE: the checks for multiple non-null references, and the + // array length check need to be done in the retained method + } + + + /** + * Gets the float vertex attribute array reference for the specified + * vertex attribute number. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * + * @return the current float vertex attribute array reference + * for the specified vertex attribute number + * + * @exception CapabilityNotSetException if the appropriate capability is + * not set and this object is part of a live or compiled scene graph + * + * @exception IllegalStateException if the data mode for this geometry + * array object is not <code>BY_REFERENCE</code>, + * is <code>USE_NIO_BUFFER</code>, or is <code>INTERLEAVED</code>. + * + * @exception ArrayIndexOutOfBoundsException if vertexAttrNum is + * out of range. + * + * @since Java 3D 1.4 + */ + public float[] getVertexAttrRefFloat(int vertexAttrNum) { + + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_REF_DATA_READ) && + !this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87")); + } + } + + int format = ((GeometryArrayRetained)this.retained).vertexFormat; + if ((format & BY_REFERENCE) == 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray83")); + } + + if ((format & USE_NIO_BUFFER) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray119")); + } + + if ((format & INTERLEAVED) != 0) { + throw new IllegalStateException(J3dI18N.getString("GeometryArray84")); + } + + return ((GeometryArrayRetained)this.retained).getVertexAttrRefFloat( + vertexAttrNum); + } + + /** * Sets the interleaved vertex array reference to the specified * array. The vertex components must be stored in a predetermined * order in the array. The order is: texture coordinates, colors, - * normals, and positional coordinates. In the case of texture + * normals, and positional coordinates. + * Vertex attributes are not supported in interleaved mode. + * In the case of texture * coordinates, the values for each texture coordinate set * are stored in order from 0 through texCoordSetCount-1. Only those * components that are enabled appear in the vertex. The number @@ -5584,7 +7211,7 @@ public abstract class GeometryArray extends Geometry { * or is <code>USE_NIO_BUFFER</code>. * * @exception ArrayIndexOutOfBoundsException if - * <code>vertexData.length</code> < <i>words_per_vertex</i> * + * <code>vertexData.length</code> < <i>words_per_vertex</i> * * (<code>initialVertexIndex + validVertexCount</code>), * where <i>words_per_vertex</i> depends on which formats are enabled. * @@ -5652,7 +7279,9 @@ public abstract class GeometryArray extends Geometry { * buffer object. The buffer must contain a java.nio.FloatBuffer object. * The vertex components must be stored in a predetermined * order in the buffer. The order is: texture coordinates, colors, - * normals, and positional coordinates. In the case of texture + * normals, and positional coordinates. + * Vertex attributes are not supported in interleaved mode. + * In the case of texture * coordinates, the values for each texture coordinate set * are stored in order from 0 through texCoordSetCount-1. Only those * components that are enabled appear in the vertex. The number @@ -5696,7 +7325,7 @@ public abstract class GeometryArray extends Geometry { * java.nio.FloatBuffer object. * * @exception ArrayIndexOutOfBoundsException if - * <code>vertexData.getBuffer().limit()</code> < <i>words_per_vertex</i> * + * <code>vertexData.getBuffer().limit()</code> < <i>words_per_vertex</i> * * (<code>initialVertexIndex + validVertexCount</code>), * where <i>words_per_vertex</i> depends on which formats are enabled. * diff --git a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java index fce41cd..dcc380c 100644 --- a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java @@ -36,9 +36,7 @@ import com.sun.j3d.internal.DoubleBufferWrapper; abstract class GeometryArrayRetained extends GeometryRetained{ - - - // TODO: Memory footprint reduction. Should have separate object to + // XXXX: Memory footprint reduction. Should have separate object to // to contain specific data such as a ByRef object for // all ByRef related data. So that incases where no // ByRef is needed, the ByRef object reference is @@ -89,6 +87,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // Offset (in words) within each vertex of the texture coordinate int textureOffset; + // Offset (in words) within each vertex of each vertex attribute + int[] vertexAttrOffsets; + + // Stride (size) of all vertex attributes + int vertexAttrStride; + // alpha value for transparency and texture blending float[] lastAlpha = new float[1]; float lastScreenAlpha = -1; @@ -132,7 +136,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ int initialCoordIndex = 0; int initialColorIndex = 0; int initialNormalIndex = 0; - int initialTexCoordIndex[] = null; + int[] initialTexCoordIndex = null; + int[] initialVertexAttrIndex = null; int initialVertexIndex = 0; @@ -174,6 +179,19 @@ abstract class GeometryArrayRetained extends GeometryRetained{ static final int T2F = 0x2000; static final int T3F = 0x4000; static final int TEXCOORD_DEFINED = TF | T2F | T3F; + + static final int AF = 0x8000; + static final int VATTR_DEFINED = AF; + + // Flag word indicating the type of by-ref texCoord. We will copy this to + // the vertexType field only when the references for all texture coordinate + // sets are set to non-null values. + private int texCoordType = 0; + + // Flag word indicating the type of by-ref vertex attr. We will copy this to + // the vertexType field only when the references for all vertex attrs + // are set to non-null values. + private int vertexAttrType = 0; // flag for execute geometry array when by reference static final int COORD_FLOAT = 0x01; @@ -181,9 +199,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ static final int COLOR_FLOAT = 0x04; static final int COLOR_BYTE = 0x08; static final int NORMAL_FLOAT = 0x10; - static final int TEXCOORD_FLOAT = 0x20; - - + static final int TEXCOORD_FLOAT = 0x20; + static final int VATTR_FLOAT = 0x40; + + // used by "by reference" normals float[] floatRefNormals = null; Vector3f[] v3fRefNormals = null; @@ -192,6 +211,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ J3DBuffer normalRefBuffer = null; FloatBufferWrapper floatBufferRefNormals = null; + // used for "by reference" vertex attrs + float[][] floatRefVertexAttrs = null; + + // Used for NIO buffer vertex attrs + J3DBuffer[] vertexAttrsRefBuffer = null; + FloatBufferWrapper[] floatBufferRefVertexAttrs = null; + Object[] nioFloatBufferRefVertexAttrs = null; // used by "by reference" tex coords Object[] refTexCoords = null; @@ -212,10 +238,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // pointers used, when transparency is turned on // or when its an object such as C3F, P3F etc .. - // TODO: Update this for J3DBuffer float[] mirrorFloatRefCoords = null; double[] mirrorDoubleRefCoords = null; float[] mirrorFloatRefNormals = null; + float[][] mirrorFloatRefVertexAttrs = null; float[] mirrorFloatRefTexCoords = null; Object[] mirrorRefTexCoords = null; @@ -223,14 +249,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ byte[][] mirrorUnsignedByteRefColors= new byte[1][]; float[][] mirrorInterleavedColorPointer = null; - // This native method builds a native representation of this object, then - // returns the nativeId. - native int build(int geoType); - // boolean to determine if a mirror was allocated int mirrorVertexAllocated = 0; int mirrorColorAllocated = 0; - boolean mirrorTexCoordAllocated = false; boolean mirrorNormalAllocated = false; // Some dirty bits for GeometryArrays @@ -240,12 +261,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ static final int TEXTURE_CHANGED = 0x08; static final int BOUNDS_CHANGED = 0x10; static final int INDEX_CHANGED = 0x20; - static final int STRIPCOUNT_CHANGED = 0x40; + static final int STRIPCOUNT_CHANGED = 0x40; + static final int VATTR_CHANGED = 0x80; static final int VERTEX_CHANGED = COORDINATE_CHANGED | NORMAL_CHANGED | COLOR_CHANGED | - TEXTURE_CHANGED; - + TEXTURE_CHANGED | + VATTR_CHANGED; static final int defaultTexCoordSetMap[] = {0}; int texCoordSetCount = 0; @@ -255,6 +277,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // texture unit. -1 means no corresponding texCoord data offset int [] texCoordSetMapOffset = null; + // Vertex attribute information + int vertexAttrCount = 0; + int[] vertexAttrSizes = null; + + // This point to a list of VertexBuffers in a Vector structure // Each element correspond to a D3D context that create this VB. // Note that this GeometryArray can be used by multiple ctx. @@ -936,26 +963,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } - // TODO: may not need this function in NIO buffer version - // setup mirror vertex pointers for J3DBuffer version - void setupMirrorVertexPointerNIOBuffer(int vType) { - int i, index = 0; - switch(vType) { - case PF: - - break; - case PD: - - break; - - // do not need to handle P3F and P3D case in NIO buffer version - default: - break; - - } - - } - // If turned transparent the first time, then force it to allocate void setupMirrorInterleavedColorPointer(boolean force) { int index, length, offset; @@ -1266,7 +1273,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ vertexType |= CF; vertexType &= ~CUB; if (c4fAllocated == 0 && !force) { - // TODO: make suren mirrorFloatRefColors[0] is set right + // NOTE: make suren mirrorFloatRefColors[0] is set right mirrorFloatRefColors[0] = null; mirrorColorAllocated &= ~CF; } @@ -1302,7 +1309,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ vertexType |= CUB; vertexType &= ~CF; if (c4fAllocated == 0 && !force) { - // TODO: make suren mirrorUnsignedByteRefColors[0] is set right + // NOTE: make sure mirrorUnsignedByteRefColors[0] is set right mirrorUnsignedByteRefColors[0] = null; mirrorColorAllocated &= ~CUB;; } @@ -1387,42 +1394,58 @@ abstract class GeometryArrayRetained extends GeometryRetained{ void setupMirrorTexCoordPointer(int type) { for (int i = 0; i < texCoordSetCount; i++) { - setupMirrorTexCoordPointer(i, type); + doSetupMirrorTexCoordPointer(i, type); } - } + validateTexCoordPointerType(); + } + void setupMirrorTexCoordPointer(int texCoordSet, int type) { - int i, index; + doSetupMirrorTexCoordPointer(texCoordSet, type); + validateTexCoordPointerType(); + } + + // If all texCoord pointers are set to a non-null value, then set the + // texcoord type in the vertexType flag word, else clear the texcoord type + private void validateTexCoordPointerType() { + boolean allNonNull = true; + boolean allNull = true; + for (int i = 0; i < texCoordSetCount; i++) { + if (refTexCoords[i] == null) { + allNonNull = false; + } else { + allNull = false; + } + } - if (mirrorRefTexCoords == null) - mirrorRefTexCoords = new Object[texCoordSetCount]; + // Reset texCoordType if all references are null + if (allNull) { + texCoordType = 0; + } - switch (type) { - case TF: - if (refTexCoords[texCoordSet] == null) { - if ((vertexType & TEXCOORD_DEFINED) == TF) { - vertexType &= ~TF; - mirrorRefTexCoords[texCoordSet] = null; - mirrorTexCoordAllocated = false; - } - } - else { - vertexType |= TF; - mirrorRefTexCoords[texCoordSet] = refTexCoords[texCoordSet]; - mirrorTexCoordAllocated = false; - } + // Copy texCoordType to vertexType if all references are non-null + vertexType &= ~TEXCOORD_DEFINED; + if (allNonNull) { + vertexType |= texCoordType; + } + } + + private void doSetupMirrorTexCoordPointer(int texCoordSet, int type) { + int i, index; + + switch (type) { + case TF: + texCoordType = TF; + mirrorRefTexCoords[texCoordSet] = refTexCoords[texCoordSet]; break; - case T2F: + + case T2F: + texCoordType = T2F; t2fRefTexCoords = (TexCoord2f[])refTexCoords[texCoordSet]; if (t2fRefTexCoords == null) { - if ((vertexType & TEXCOORD_DEFINED) == T2F) { - vertexType &= ~T2F; - } - return; - } - else { - vertexType |= T2F; + mirrorRefTexCoords[texCoordSet] = null; + break; } mirrorFloatRefTexCoords = (float[])mirrorRefTexCoords[texCoordSet]; @@ -1441,19 +1464,15 @@ abstract class GeometryArrayRetained extends GeometryRetained{ mirrorFloatRefTexCoords[index++] = t2fRefTexCoords[i].x; mirrorFloatRefTexCoords[index++] = t2fRefTexCoords[i].y; } - mirrorTexCoordAllocated = true; break; - case T3F: + case T3F: + texCoordType = T3F; t3fRefTexCoords = (TexCoord3f[])refTexCoords[texCoordSet]; - if (t3fRefTexCoords == null) { - if ((vertexType & TEXCOORD_DEFINED) == T3F) { - vertexType &= ~T3F; - } - return; - } - else { - vertexType |= T3F; + + if (t3fRefTexCoords == null) { + mirrorRefTexCoords[texCoordSet] = null; + break; } mirrorFloatRefTexCoords = (float[])mirrorRefTexCoords[texCoordSet]; @@ -1473,142 +1492,240 @@ abstract class GeometryArrayRetained extends GeometryRetained{ mirrorFloatRefTexCoords[index++] = t3fRefTexCoords[i].y; mirrorFloatRefTexCoords[index++] = t3fRefTexCoords[i].z; } - mirrorTexCoordAllocated = true; break; default: break; } } - - void createGeometryArrayData(int vertexCount, int vertexFormat) - { + void setupMirrorVertexAttrPointer(int type) { + for (int i = 0; i < vertexAttrCount; i++) { + doSetupMirrorVertexAttrPointer(i, type); + } + + validateVertexAttrPointerType(); + } + + void setupMirrorVertexAttrPointer(int vertexAttrNum, int type) { + doSetupMirrorVertexAttrPointer(vertexAttrNum, type); + validateVertexAttrPointerType(); + } + + // If all vertex attr pointers are set to a non-null value, then set the + // vertex attr type in the vertexType flag word, else clear the + // vertex attr type + private void validateVertexAttrPointerType() { + boolean allNonNull = true; + boolean allNull = true; + + if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) == 0) { + for (int i = 0; i < vertexAttrCount; i++) { + if (floatRefVertexAttrs[i] == null) { + allNonNull = false; + } else { + allNull = false; + } + } + } else { + for (int i = 0; i < vertexAttrCount; i++) { + if (nioFloatBufferRefVertexAttrs[i] == null) { + allNonNull = false; + } else { + allNull = false; + } + } + } + + // Reset vertexAttrType if all references are null + if (allNull) { + vertexAttrType = 0; + } + + // Copy vertexAttrType to vertexType if all references are non-null + vertexType &= ~VATTR_DEFINED; + if (allNonNull) { + vertexType |= vertexAttrType; + } + } + + private void doSetupMirrorVertexAttrPointer(int vertexAttrNum, int type) { + switch (type) { + case AF: + vertexAttrType = AF; + mirrorFloatRefVertexAttrs[vertexAttrNum] = + floatRefVertexAttrs[vertexAttrNum]; + break; + default: + break; + } + } + + + void createGeometryArrayData(int vertexCount, int vertexFormat) { if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { createGeometryArrayData(vertexCount, vertexFormat, 1, - defaultTexCoordSetMap); + defaultTexCoordSetMap); } else { createGeometryArrayData(vertexCount, vertexFormat, 0, null); } } void createGeometryArrayData(int vertexCount, int vertexFormat, - int texCoordSetCount, int[] texCoordSetMap) - { + int texCoordSetCount, int[] texCoordSetMap) { + + createGeometryArrayData(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + 0, null); + } + + void createGeometryArrayData(int vertexCount, int vertexFormat, + int texCoordSetCount, int[] texCoordSetMap, + int vertexAttrCount, int[] vertexAttrSizes) { this.vertexFormat = vertexFormat; this.vertexCount = vertexCount; this.validVertexCount = vertexCount; + this.texCoordSetCount = texCoordSetCount; - this.texCoordSetMap = texCoordSetMap; + if (texCoordSetMap == null) { + this.texCoordSetMap = null; + } + else { + this.texCoordSetMap = (int[])texCoordSetMap.clone(); + } + + this.vertexAttrCount = vertexAttrCount; + if (vertexAttrSizes == null) { + this.vertexAttrSizes = null; + } + else { + this.vertexAttrSizes = (int[])vertexAttrSizes.clone(); + } + + this.vertexAttrStride = this.vertexAttrStride(); this.stride = this.stride(); + + this.vertexAttrOffsets = this.vertexAttrOffsets(); this.texCoordSetMapOffset = this.texCoordSetMapOffset(); - this.textureOffset = 0; + this.textureOffset = this.textureOffset(); this.colorOffset = this.colorOffset(); this.normalOffset = this.normalOffset(); this.coordinateOffset = this.coordinateOffset(); + if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { this.vertexData = new float[this.vertexCount * this.stride]; } else { // By reference geometry this.vertexData = null; if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + this.mirrorRefTexCoords = new Object[texCoordSetCount]; this.refTexCoords = new Object[texCoordSetCount]; // keep J3DBufferImp object in nio buffer case if((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0 ) this.refTexCoordsBuffer = new Object[texCoordSetCount]; // keep J3DBuffer object } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + this.floatRefVertexAttrs = new float[vertexAttrCount][]; + this.mirrorFloatRefVertexAttrs = new float[vertexAttrCount][]; + if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { + this.vertexAttrsRefBuffer = new J3DBuffer[vertexAttrCount]; + this.floatBufferRefVertexAttrs = new FloatBufferWrapper[vertexAttrCount]; + this.nioFloatBufferRefVertexAttrs = new Object[vertexAttrCount]; + } + } } if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { this.initialTexCoordIndex = new int[texCoordSetCount]; } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + this.initialVertexAttrIndex = new int[vertexAttrCount]; + } noAlpha = ((vertexFormat & GeometryArray.WITH_ALPHA) == 0); lastAlpha[0] = 1.0f; } // used for GeometryArrays by Copy or interleaved - native void execute(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean useAlpha, - boolean multiScreen, - boolean ignoreVertexColors, - int startVIndex, int vcount, int vformat, - int texCoordSetCount, int texCoordSetMap[], - int texCoordSetMapLen, - int[] texCoordSetOffset, - int numActiveTexUnitState, - int[] texUnitStateMap, - float[] varray, float[] cdata, int texUnitIndex, int cdirty); - - - + private native void execute(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean useAlpha, + boolean multiScreen, + boolean ignoreVertexColors, + int startVIndex, int vcount, int vformat, + int texCoordSetCount, int texCoordSetMap[], + int texCoordSetMapLen, + int[] texCoordSetOffset, + int numActiveTexUnitState, + int[] texUnitStateMap, + int vertexAttrCount, int[] vertexAttrSizes, + float[] varray, float[] cdata, int texUnitIndex, int cdirty); // used by GeometryArray by Reference with java arrays - native void executeVA(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean multiScreen, - 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 pass, int texcoordmaplength, - int[] texcoordoffset, - int numActiveTexUnitState, int[] texunitstatemap, - int[] texIndex, int texstride, Object[] texCoords, - int cdirty); - - + private native void executeVA(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean multiScreen, + 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 pass, int texcoordmaplength, + int[] texcoordoffset, + int numActiveTexUnitState, int[] texunitstatemap, + int[] texIndex, int texstride, Object[] texCoords, + int cdirty); // used by GeometryArray by Reference with NIO buffer - native void executeVABuffer(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean multiScreen, - 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 pass, int texcoordmaplength, - int[] texcoordoffset, - int numActiveTexUnitState, int[] texunitstatemap, - int[] texIndex, int texstride, Object[] texCoords, - int cdirty); + private native void executeVABuffer(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean multiScreen, + 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 pass, int texcoordmaplength, + int[] texcoordoffset, + int numActiveTexUnitState, int[] texunitstatemap, + int[] texIndex, int texstride, Object[] texCoords, + int cdirty); // used by GeometryArray by Reference in interleaved format with NIO buffer - native void executeInterleavedBuffer(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean useAlpha, - boolean multiScreen, - boolean ignoreVertexColors, - int startVIndex, int vcount, int vformat, - int texCoordSetCount, int texCoordSetMap[], - int texCoordSetMapLen, - int[] texCoordSetOffset, - int numActiveTexUnitState, - int[] texUnitStateMap, - Object varray, float[] cdata, int texUnitIndex, int cdirty); - - - - native void setVertexFormat(int vformat, boolean useAlpha, - boolean ignoreVertexColors, long ctx); - native void disableGlobalAlpha(long ctx, int vformat, - boolean useAlpha, - boolean ignoreVertexColors); + private native void executeInterleavedBuffer(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean useAlpha, + boolean multiScreen, + boolean ignoreVertexColors, + int startVIndex, int vcount, int vformat, + int texCoordSetCount, int texCoordSetMap[], + int texCoordSetMapLen, + int[] texCoordSetOffset, + int numActiveTexUnitState, + int[] texUnitStateMap, + Object varray, float[] cdata, int texUnitIndex, int cdirty); + + private native void setVertexFormat(long ctx, + int vformat, boolean useAlpha, boolean ignoreVertexColors); + + private native void disableGlobalAlpha(long ctx, int vformat, + boolean useAlpha, boolean ignoreVertexColors); void setVertexFormat(boolean useAlpha, boolean ignoreVC, long ctx) { - setVertexFormat(vertexFormat, useAlpha, ignoreVC, ctx); + setVertexFormat(ctx, vertexFormat, useAlpha, ignoreVC); } void disableGlobalAlpha(long ctx, boolean useAlpha, boolean ignoreVC) { @@ -1628,6 +1745,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return mirrorFloatRefColors[0]; } + // Issue 113 + // TODO: Fix this for screen > 0, for now just ignore transparency + if (screen > 0) { + return mirrorFloatRefColors[0]; + } + // update alpha only if vertex format includes alpha if (((vertexFormat | c4fAllocated) & GeometryArray.WITH_ALPHA) == 0) return mirrorFloatRefColors[0]; @@ -1796,6 +1919,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return mirrorUnsignedByteRefColors[0]; } + // Issue 113 + // TODO: Fix this for screen > 0, for now just ignore transparency + if (screen > 0) { + return mirrorUnsignedByteRefColors[0]; + } + // update alpha only if vertex format includes alpha if (((vertexFormat | c4fAllocated) & GeometryArray.WITH_ALPHA) == 0) return mirrorUnsignedByteRefColors[0]; @@ -1951,6 +2080,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return retVal; } + // Issue 113 + // TODO: Fix this for screen > 0, for now just ignore transparency + if (screen > 0) { + retVal[1] = vertexData; + return retVal; + } + // update alpha only if vertex format includes alpha if ((vertexFormat & GeometryArray.COLOR) == 0) { retVal[1] = vertexData; @@ -1980,7 +2116,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // allocate a copy of the vertex data for the screen if needed. // this piece of code is mainly for multi-screens case - // TODO: this might not too much data for just to update alpha + // NOTE: this might not too much data for just to update alpha if (mvertexData == null || mvertexData.length <= screen) { float[][] cfData = new float[screen + 1][]; @@ -2101,6 +2237,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return retVal; } + // Issue 113 + // TODO: Fix this for screen > 0, for now just ignore transparency + if (screen > 0) { + retVal[1] = null; + return retVal; + } + // update alpha only if vertex format includes alpha if (((vertexFormat | c4fAllocated) & GeometryArray.COLOR) == 0) { retVal[1] = mirrorInterleavedColorPointer[0]; @@ -2131,7 +2274,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // allocate a copy of the vertex data for the screen if needed. // this piece of code is mainly for multi-screens case - // TODO: this might not too much data for just to update alpha + // NOTE: this might not too much data for just to update alpha if (mirrorInterleavedColorPointer.length <= screen) { float[][] cfData = new float[screen + 1][]; @@ -2252,8 +2395,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ boolean useAlpha = false; Object[] retVal; + // Check for by-copy case if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { - float[] vdata; + float[] vdata; synchronized (this) { cdirty = dirtyFlag; @@ -2294,8 +2438,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ (texCoordSetMap == null) ? 0 : texCoordSetMap.length, texCoordSetMapOffset, cv.numActiveTexUnit, cv.texUnitStateMap, - vdata, null, - pass, cdirty); + vertexAttrCount, vertexAttrSizes, + vdata, null, + pass, cdirty); } //By reference with java array @@ -2338,8 +2483,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ texCoordSetCount, texCoordSetMap, (texCoordSetMap == null) ? 0 : texCoordSetMap.length, texCoordSetMapOffset, - cv.numActiveTexUnit, cv.texUnitStateMap, - interLeavedVertexData, cdata, + cv.numActiveTexUnit, cv.texUnitStateMap, + vertexAttrCount, vertexAttrSizes, + interLeavedVertexData, cdata, pass, cdirty); } // end of interleaved case @@ -2354,7 +2500,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ (((vertexFormat & GeometryArray.COLOR) != 0) && (vertexType & COLOR_DEFINED) == 0) || (((vertexFormat & GeometryArray.NORMALS) != 0) && - (vertexType & NORMAL_DEFINED) == 0) || + (vertexType & NORMAL_DEFINED) == 0) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + (vertexType & VATTR_DEFINED) == 0) || (((vertexFormat& GeometryArray.TEXTURE_COORDINATE) != 0) && (vertexType & TEXCOORD_DEFINED) == 0)) { return; @@ -2419,6 +2567,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ vdefined |= COLOR_BYTE; if((vertexType & NORMAL_DEFINED) != 0) vdefined |= NORMAL_FLOAT; + if((vertexType & VATTR_DEFINED) != 0) + vdefined |= VATTR_FLOAT; if((vertexType & TEXCOORD_DEFINED) != 0) vdefined |= TEXCOORD_FLOAT; @@ -2432,6 +2582,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ mirrorFloatRefCoords, mirrorDoubleRefCoords, initialColorIndex, cfdata, cbdata, initialNormalIndex, mirrorFloatRefNormals, + vertexAttrCount, vertexAttrSizes, + initialVertexAttrIndex, mirrorFloatRefVertexAttrs, pass, ((texCoordSetMap == null) ? 0:texCoordSetMap.length), texCoordSetMap, @@ -2456,7 +2608,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ cdirty = dirtyFlag; if (updateAlpha && !ignoreVertexColors) { // update the alpha values - // TODO: to handle alpha case + // XXXX: to handle alpha case retVal = updateAlphaInInterLeavedData(cv, screen, alpha); useAlpha = (retVal[0] == Boolean.TRUE); cdata = (float[])retVal[1]; @@ -2466,7 +2618,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ cdirty |= COLOR_CHANGED; } } else { - // TODO: to handle alpha case + // XXXX: to handle alpha case cdata = null; // if transparency switch between on/off if (lastScreenAlpha != -1) { @@ -2477,7 +2629,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ dirtyFlag = 0; } - executeInterleavedBuffer(cv.ctx, this, geoType, isNonUniformScale, useAlpha, multiScreen, @@ -2493,9 +2644,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ pass, cdirty); } // end of interleaved case - + // non interleaved data else { + // Check if a vertexformat is set, but the array is null // if yes, don't draw anything if ((vertexType == 0) || @@ -2503,15 +2655,16 @@ abstract class GeometryArrayRetained extends GeometryRetained{ (((vertexFormat & GeometryArray.COLOR) != 0) && (vertexType & COLOR_DEFINED) == 0) || (((vertexFormat & GeometryArray.NORMALS) != 0) && - (vertexType & NORMAL_DEFINED) == 0) || + (vertexType & NORMAL_DEFINED) == 0) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + (vertexType & VATTR_DEFINED) == 0) || (((vertexFormat& GeometryArray.TEXTURE_COORDINATE) != 0) && (vertexType & TEXCOORD_DEFINED) == 0)) { return; } else { byte[] cbdata = null; float[] cfdata = null; - - + if ((vertexType & CF ) != 0) { synchronized (this) { cdirty = dirtyFlag; @@ -2523,7 +2676,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ cdirty |= COLOR_CHANGED; } } else { - // TODO: handle transparency case + // XXXX: handle transparency case //cfdata = null; cfdata = mirrorFloatRefColors[0]; // if transparency switch between on/off @@ -2547,7 +2700,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ cdirty |= COLOR_CHANGED; } } else { - // TODO: handle transparency case + // XXXX: handle transparency case //cbdata = null; cbdata = mirrorUnsignedByteRefColors[0]; // if transparency switch between on/off @@ -2585,9 +2738,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if((vertexType & NORMAL_DEFINED) != 0) { vdefined |= NORMAL_FLOAT; normal = floatBufferRefNormals.getBufferAsObject(); - } + } - if((vertexType & TEXCOORD_DEFINED) != 0) + if ((vertexType & VATTR_DEFINED) != 0) { + vdefined |= VATTR_FLOAT; + } + + if((vertexType & TEXCOORD_DEFINED) != 0) vdefined |= TEXCOORD_FLOAT; executeVABuffer(cv.ctx, this, geoType, isNonUniformScale, @@ -2603,6 +2760,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ cfdata, cbdata, initialNormalIndex, normal, + vertexAttrCount, vertexAttrSizes, + initialVertexAttrIndex, + nioFloatBufferRefVertexAttrs, pass, ((texCoordSetMap == null) ? 0:texCoordSetMap.length), texCoordSetMap, @@ -2616,60 +2776,68 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } // used for GeometryArrays - native void buildGA(long 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, - double[] xform, double[] nxform, - float[] varray); - - // used to Build Dlist GeometryArray by Reference with java arrays - native void buildGAForByRef(long 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 texcoordmaplength, - int[] texcoordoffset, - int[] texIndex, int texstride, Object[] texCoords, - double[] xform, double[] nxform); - - - // used to Build Dlist GeometryArray by Reference with java arrays - native void buildGAForBuffer(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, boolean updateAlpha, - float alpha, - boolean ignoreVertexColors, - int vcount, - int vformat, - int vdefined, - int coordIndex, Object vcoords, - int colorIndex, Object cdata, - int normalIndex, Object ndata, - int texcoordmaplength, - int[] texcoordoffset, - int[] texIndex, int texstride, Object[] texCoords, - double[] xform, double[] nxform); - - + private native void buildGA(long 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 + private native void buildGAForByRef(long 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. + /* + private native void buildGAForBuffer(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, boolean updateAlpha, + float alpha, + boolean ignoreVertexColors, + int vcount, + int vformat, + int vdefined, + int coordIndex, Object vcoords, + int colorIndex, Object cdata, + int normalIndex, Object ndata, + int texcoordmaplength, + int[] texcoordoffset, + int[] texIndex, int texstride, Object[] texCoords, + double[] xform, double[] nxform); + */ void buildGA(Canvas3D cv, RenderAtom ra, boolean isNonUniformScale, boolean updateAlpha, float alpha, boolean ignoreVertexColors, Transform3D xform, Transform3D nxform) { - float[] vdata = null; + + float[] vdata = null; + + // NIO buffers are no longer supported in display lists + assert (vertexFormat & GeometryArray.USE_NIO_BUFFER) == 0; if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { vdata = vertexData; @@ -2690,13 +2858,31 @@ abstract class GeometryArrayRetained extends GeometryRetained{ texCoordSetCount, texCoordSetMap, (texCoordSetMap == null) ? 0 : texCoordSetMap.length, texCoordSetMapOffset, - (xform == null) ? null : xform.mat, + vertexAttrCount, vertexAttrSizes, + (xform == null) ? null : xform.mat, (nxform == null) ? null : nxform.mat, vdata); } else { - // Either non-interleaved, by-ref or nio buffer + // Check if a vertexformat is set, but the array is null + // if yes, don't draw anything + if ((vertexType == 0) || + ((vertexType & VERTEX_DEFINED) == 0) || + (((vertexFormat & GeometryArray.COLOR) != 0) && + (vertexType & COLOR_DEFINED) == 0) || + (((vertexFormat & GeometryArray.NORMALS) != 0) && + (vertexType & NORMAL_DEFINED) == 0) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + (vertexType & VATTR_DEFINED) == 0) || + (((vertexFormat& GeometryArray.TEXTURE_COORDINATE) != 0) && + (vertexType & TEXCOORD_DEFINED) == 0)) { + + return; + } + + // Either non-interleaved, by-ref or nio buffer if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) == 0) { + // Java array case // setup vdefined to passed to native code int vdefined = 0; if((vertexType & (PF | P3F)) != 0) @@ -2709,8 +2895,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ vdefined |= COLOR_BYTE; if((vertexType & NORMAL_DEFINED) != 0) vdefined |= NORMAL_FLOAT; + if((vertexType & VATTR_DEFINED) != 0) + vdefined |= VATTR_FLOAT; if((vertexType & TEXCOORD_DEFINED) != 0) vdefined |= TEXCOORD_FLOAT; + buildGAForByRef(cv.ctx, this, geoType, isNonUniformScale, updateAlpha, alpha, ignoreVertexColors, @@ -2721,6 +2910,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ mirrorFloatRefCoords, mirrorDoubleRefCoords, initialColorIndex, mirrorFloatRefColors[0], mirrorUnsignedByteRefColors[0], initialNormalIndex, mirrorFloatRefNormals, + vertexAttrCount, vertexAttrSizes, + initialVertexAttrIndex, mirrorFloatRefVertexAttrs, ((texCoordSetMap == null) ? 0:texCoordSetMap.length), texCoordSetMap, initialTexCoordIndex,texCoordStride, @@ -2728,50 +2919,60 @@ abstract class GeometryArrayRetained extends GeometryRetained{ (xform == null) ? null : xform.mat, (nxform == null) ? null : nxform.mat); } + /* + // NOTE: NIO buffers are no longer supported in display lists. + // This was never enabled by default anyway (only when the + // optimizeForSpace property was set to false), so it wasn't + // well-tested. If future support is desired, we will need to + // add vertex attributes to buildGAForBuffer. There are no plans + // to ever do this. else { - Object vcoord = null, cdataBuffer=null, normal=null; - - int vdefined = 0; - if((vertexType & PF) != 0) { - vdefined |= COORD_FLOAT; - vcoord = floatBufferRefCoords.getBufferAsObject(); - } else if((vertexType & PD ) != 0) { - vdefined |= COORD_DOUBLE; - vcoord = doubleBufferRefCoords.getBufferAsObject(); - } - - if((vertexType & CF ) != 0) { - vdefined |= COLOR_FLOAT; - cdataBuffer = floatBufferRefColors.getBufferAsObject(); - } else if((vertexType & CUB) != 0) { - vdefined |= COLOR_BYTE; - cdataBuffer = byteBufferRefColors.getBufferAsObject(); - } - - if((vertexType & NORMAL_DEFINED) != 0) { - vdefined |= NORMAL_FLOAT; - normal = floatBufferRefNormals.getBufferAsObject(); - } + // NIO Buffer case + Object vcoord = null, cdataBuffer=null, normal=null; + + int vdefined = 0; + if((vertexType & PF) != 0) { + vdefined |= COORD_FLOAT; + vcoord = floatBufferRefCoords.getBufferAsObject(); + } else if((vertexType & PD ) != 0) { + vdefined |= COORD_DOUBLE; + vcoord = doubleBufferRefCoords.getBufferAsObject(); + } - if((vertexType & TEXCOORD_DEFINED) != 0) - vdefined |= TEXCOORD_FLOAT; - buildGAForBuffer(cv.ctx, this, geoType, isNonUniformScale, - updateAlpha, alpha, - ignoreVertexColors, - validVertexCount, - vertexFormat, - vdefined, - initialCoordIndex, - vcoord, - initialColorIndex,cdataBuffer, - initialNormalIndex, normal, - ((texCoordSetMap == null) ? 0:texCoordSetMap.length), - texCoordSetMap, - initialTexCoordIndex,texCoordStride, - refTexCoords, - (xform == null) ? null : xform.mat, - (nxform == null) ? null : nxform.mat); - } + if((vertexType & CF ) != 0) { + vdefined |= COLOR_FLOAT; + cdataBuffer = floatBufferRefColors.getBufferAsObject(); + } else if((vertexType & CUB) != 0) { + vdefined |= COLOR_BYTE; + cdataBuffer = byteBufferRefColors.getBufferAsObject(); + } + + if((vertexType & NORMAL_DEFINED) != 0) { + vdefined |= NORMAL_FLOAT; + normal = floatBufferRefNormals.getBufferAsObject(); + } + + if((vertexType & TEXCOORD_DEFINED) != 0) + vdefined |= TEXCOORD_FLOAT; + // NOTE : need to add vertex attrs + buildGAForBuffer(cv.ctx, this, geoType, isNonUniformScale, + updateAlpha, alpha, + ignoreVertexColors, + validVertexCount, + vertexFormat, + vdefined, + initialCoordIndex, + vcoord, + initialColorIndex,cdataBuffer, + initialNormalIndex, normal, + ((texCoordSetMap == null) ? 0:texCoordSetMap.length), + texCoordSetMap, + initialTexCoordIndex,texCoordStride, + refTexCoords, + (xform == null) ? null : xform.mat, + (nxform == null) ? null : nxform.mat); + } + */ } @@ -2786,8 +2987,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } - void unIndexifyJavaArray(IndexedGeometryArrayRetained src) { - int vOffset = 0, srcOffset, tOffset = 0; + private void unIndexifyJavaArray(IndexedGeometryArrayRetained src) { +// System.err.println("unIndexifyJavaArray"); + + int vOffset = 0, srcOffset, tOffset = 0; int index, colorStride = 0; float[] vdata = null; int i; @@ -2843,10 +3046,24 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } System.arraycopy(vdata, - (((int[])src.indexTexCoord[i])[index])*src.stride + src.textureOffset + interleavedOffset, + (src.indexTexCoord[i][index])*src.stride + src.textureOffset + interleavedOffset, vertexData, tcOffset, texCoordStride); } } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + // vertex attributes can't be interleaved + assert (src.vertexFormat & GeometryArray.INTERLEAVED) == 0; + + for (i = 0; i < vertexAttrCount; i++) { + int vaOffset = vOffset + vertexAttrOffsets[i]; + + System.arraycopy(vdata, + (src.indexVertexAttr[i][index])*src.stride + src.vertexAttrOffsets[i], + vertexData, vaOffset, vertexAttrSizes[i]); + } + } + if ((vertexFormat & GeometryArray.COORDINATES) != 0){ // System.out.println("===> copying coords"); System.arraycopy(vdata, @@ -2859,7 +3076,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } else { - if ((vertexFormat & GeometryArray.NORMALS) != 0){ + if ((vertexFormat & GeometryArray.NORMALS) != 0) { vOffset = normalOffset; switch ((src.vertexType & NORMAL_DEFINED)) { case NF: @@ -2884,7 +3101,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ break; } } - if ((vertexFormat & GeometryArray.COLOR) != 0){ + + if ((vertexFormat & GeometryArray.COLOR) != 0) { vOffset = colorOffset; int multiplier = 3; if ((src.vertexFormat & GeometryArray.WITH_ALPHA) != 0) @@ -2968,6 +3186,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ break; } } + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { vOffset = textureOffset; switch ((src.vertexType & TEXCOORD_DEFINED)) { @@ -2976,7 +3195,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for (i = 0, tOffset = vOffset; i < texCoordSetCount; i++) { System.arraycopy(src.refTexCoords[i], - ((int[])src.indexTexCoord[i])[index]*texCoordStride, + src.indexTexCoord[i][index]*texCoordStride, vertexData, tOffset, texCoordStride); tOffset += texCoordStride; } @@ -2987,7 +3206,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for (index=start; index < end; index++) { for (i = 0, tOffset = vOffset; i < texCoordSetCount; i++) { - srcOffset = ((int[])src.indexTexCoord[i])[index]; + srcOffset = src.indexTexCoord[i][index]; vertexData[tOffset] = ((TexCoord2f[])src.refTexCoords[i])[srcOffset].x; vertexData[tOffset+1] = @@ -3001,7 +3220,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for (index=start; index < end; index++) { for (i = 0, tOffset = vOffset; i < texCoordSetCount; i++) { - srcOffset = ((int[])src.indexTexCoord[i])[index]; + srcOffset = src.indexTexCoord[i][index]; vertexData[tOffset] = ((TexCoord3f[])src.refTexCoords[i])[srcOffset].x; vertexData[tOffset+1] = @@ -3016,8 +3235,26 @@ abstract class GeometryArrayRetained extends GeometryRetained{ default: break; } - } - if ((vertexFormat & GeometryArray.COORDINATES) != 0){ + } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + vOffset = 0; + switch (src.vertexType & VATTR_DEFINED) { + case AF: + for (index=start; index < end; index++) { + for (i = 0; i < vertexAttrCount; i++) { + int vaOffset = vOffset + vertexAttrOffsets[i]; + System.arraycopy(src.floatRefVertexAttrs[i], + src.indexVertexAttr[i][index]*vertexAttrSizes[i], + vertexData, vaOffset, vertexAttrSizes[i]); + } + vOffset += stride; + } + break; + } + } + + if ((vertexFormat & GeometryArray.COORDINATES) != 0) { vOffset = coordinateOffset; switch ((src.vertexType & VERTEX_DEFINED)) { case PF: @@ -3062,11 +3299,13 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } - } + } + + private void unIndexifyNIOBuffer(IndexedGeometryArrayRetained src) { +// System.err.println("unIndexifyNIOBuffer"); - void unIndexifyNIOBuffer(IndexedGeometryArrayRetained src) { - int vOffset = 0, srcOffset, tOffset = 0; + int vOffset = 0, srcOffset, tOffset = 0; int index, colorStride = 0; float[] vdata = null; int i; @@ -3101,7 +3340,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for (i = 0; i < texCoordSetCount; i++, tcOffset += texCoordStride) { - src.interleavedFloatBufferImpl.position((((int[])src.indexTexCoord[i])[index])*src.stride + + src.interleavedFloatBufferImpl.position((src.indexTexCoord[i][index])*src.stride + src.textureOffset); src.interleavedFloatBufferImpl.get(vertexData, tcOffset, texCoordStride); } @@ -3124,7 +3363,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } } - if ((vertexFormat & GeometryArray.COLOR) != 0){ + + if ((vertexFormat & GeometryArray.COLOR) != 0){ vOffset = colorOffset; int multiplier = 3; if ((src.vertexFormat & GeometryArray.WITH_ALPHA) != 0) @@ -3165,7 +3405,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ break; } } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { vOffset = textureOffset; FloatBufferWrapper texBuffer; if ((src.vertexType & TEXCOORD_DEFINED) != 0) { @@ -3173,15 +3414,31 @@ abstract class GeometryArrayRetained extends GeometryRetained{ for (i = 0, tOffset = vOffset; i < texCoordSetCount; i++) { texBuffer = (FloatBufferWrapper)(((J3DBuffer) (src.refTexCoordsBuffer[i])).getBufferImpl()); - texBuffer.position(((int[])src.indexTexCoord[i])[index]*texCoordStride); + texBuffer.position(src.indexTexCoord[i][index]*texCoordStride); texBuffer.get(vertexData, tOffset, texCoordStride); tOffset += texCoordStride; } vOffset += stride; } } - } - if ((vertexFormat & GeometryArray.COORDINATES) != 0){ + } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + vOffset = 0; + if ((src.vertexType & VATTR_DEFINED) == AF) { + for (index=start; index < end; index++) { + for (i = 0; i < vertexAttrCount; i++) { + int vaOffset = vOffset + vertexAttrOffsets[i]; + FloatBufferWrapper vaBuffer = src.floatBufferRefVertexAttrs[i]; + vaBuffer.position(src.indexVertexAttr[i][index]*vertexAttrSizes[i]); + vaBuffer.get(vertexData, vaOffset, vertexAttrSizes[i]); + } + vOffset += stride; + } + } + } + + if ((vertexFormat & GeometryArray.COORDINATES) != 0){ vOffset = coordinateOffset; switch ((src.vertexType & VERTEX_DEFINED)) { case PF: @@ -3206,7 +3463,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } - } + } + /** * Returns the vertex stride in numbers of floats as a function @@ -3250,6 +3508,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ stride += texCoordStride * texCoordSetCount; } + if ((this.vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + stride += vertexAttrStride; + } + + //System.err.println("stride() = " + stride); return stride; } @@ -3270,6 +3533,61 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } /** + * Returns the stride of the set of vertex attributes. This is the + * sum of the sizes of each vertex attribute. + * @return the stride of the vertex attribute data + */ + int vertexAttrStride() { + int sum = 0; + for (int i = 0; i < vertexAttrCount; i++) { + sum += vertexAttrSizes[i]; + } + return sum; + } + + /** + * Returns the offset in number of floats from the start of a vertex to + * each per-vertex vertex attribute. + * @return array of offsets in floats vertex start to the vertex attribute data + */ + int[] vertexAttrOffsets() { + int[] offsets; + + // Create array of offsets to the start of each vertex attribute. + // The offset of the first attribute is always 0. If no vertex attributes exist, + // then we will allocate an array of length 1 to avoid some checking elsewhere. + if (vertexAttrCount > 0) { + offsets = new int[vertexAttrCount]; + } + else { + offsets = new int[1]; + } + offsets[0] = 0; + for (int i = 1; i < vertexAttrCount; i++) { + offsets[i] = offsets[i-1] + vertexAttrSizes[i-1]; + } + + return offsets; + } + + /** + * Returns the offset in number of floats from the start of a vertex to + * the per-vertex texture coordinate data. + * texture coordinate data always follows vertex attribute data + * @return the offset in floats vertex start to the tetxure data + */ + int textureOffset() + { + int offset = vertexAttrOffsets[0]; + + if ((this.vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + offset += vertexAttrStride; + } + + return offset; + } + + /** * Returns the offset in number of floats from the start of a vertex to * the per-vertex color data. * color data always follows texture data @@ -3344,6 +3662,32 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return vertexFormat; } + /** + * Retrieves the number of vertex attributes in this GeometryArray + * object. + * + * @return the number of vertex attributes in this GeometryArray + * object + */ + int getVertexAttrCount() { + return vertexAttrCount; + } + + + /** + * Retrieves the vertex attribute sizes array from this + * GeometryArray object. + * + * @param vertexAttrSizes an array that will receive a copy of + * the vertex attribute sizes array. The array must hold at least + * <code>vertexAttrCount</code> elements. + */ + void getVertexAttrSizes(int[] vertexAttrSizes) { + for (int i = 0; i < vertexAttrCount; i++) { + vertexAttrSizes[i] = this.vertexAttrSizes[i]; + } + } + void sendDataChangedMessage(boolean coordinatesChanged) { @@ -3360,7 +3704,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // Send a message to renderBin to rebuild the display list or // process the vertex array accordingly - // TODO: Should I send one per universe, isn't display list + // XXXX: Should I send one per universe, isn't display list // shared by all context/universes? int threads = J3dThread.UPDATE_RENDER; // If the geometry type is Indexed then we need to clone the geometry @@ -4890,7 +5234,259 @@ abstract class GeometryArrayRetained extends GeometryRetained{ geomLock.unLock(); sendDataChangedMessage(false); - } + } + + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point2f containing the new vertex attribute + */ + void setVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + this.vertexData[offset] = vertexAttr.x; + this.vertexData[offset+1] = vertexAttr.y; + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point3f containing the new vertex attribute + */ + void setVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + this.vertexData[offset] = vertexAttr.x; + this.vertexData[offset+1] = vertexAttr.y; + this.vertexData[offset+2] = vertexAttr.z; + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attribute associated with the vertex at the + * specified index in the specified vertex attribute number for + * this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index destination vertex index in this geometry array + * @param vertexAttr the Point4f containing the new vertex attribute + */ + void setVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + this.vertexData[offset] = vertexAttr.x; + this.vertexData[offset+1] = vertexAttr.y; + this.vertexData[offset+2] = vertexAttr.z; + this.vertexData[offset+3] = vertexAttr.w; + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of 1*n, 2*n, 3*n, or 4*n values + * containing n new vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + */ + void setVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs, + int start, int length) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int size = vertexAttrSizes[vertexAttrNum]; + int i, j, k; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + for (i = start * size, j = offset, k = 0; k < length; i += size, j += this.stride, k++) { + for (int ii = 0; ii < size; ii++) { + this.vertexData[j+ii] = vertexAttrs[i+ii]; + } + } + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point2f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + */ + void setVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs, + int start, int length) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j, k; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + for (i = start, j = offset, k = 0; k < length; i++, j += this.stride, k++) { + this.vertexData[j] = vertexAttrs[i].x; + this.vertexData[j+1] = vertexAttrs[i].y; + } + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point3f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + */ + void setVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs, + int start, int length) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j, k; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + for (i = start, j = offset, k = 0; k < length; i++, j += this.stride, k++) { + this.vertexData[j] = vertexAttrs[i].x; + this.vertexData[j+1] = vertexAttrs[i].y; + this.vertexData[j+2] = vertexAttrs[i].z; + } + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + + /** + * Sets the vertex attributes associated with the vertices + * starting at the specified index in the specified vertex + * attribute number for this object using data in + * <code>vertexAttrs</code> starting at index <code>start</code> and + * ending at index <code>start+length</code>. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index starting destination vertex index in this geometry array + * @param vertexAttrs source array of Point4f objects containing new + * vertex attributes + * @param start starting source vertex index in <code>vertexAttrs</code> + * array. + * @param length number of vertex attributes to be copied. + */ + void setVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs, + int start, int length) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j, k; + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + + for (i = start, j = offset, k = 0; k < length; i++, j += this.stride, k++) { + this.vertexData[j] = vertexAttrs[i].x; + this.vertexData[j+1] = vertexAttrs[i].y; + this.vertexData[j+2] = vertexAttrs[i].z; + this.vertexData[j+3] = vertexAttrs[i].w; + } + + if (source == null || !source.isLive()) { + geomLock.unLock(); + return; + } + + geomLock.unLock(); + sendDataChangedMessage(false); + } + /** * Gets the coordinate associated with the vertex at @@ -5505,6 +6101,158 @@ abstract class GeometryArrayRetained extends GeometryRetained{ /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttr(int vertexAttrNum, int index, + float[] vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int size = vertexAttrSizes[vertexAttrNum]; + + for (int i = 0; i < size; i++) { + vertexAttr[i] = this.vertexData[offset+i]; + + } + + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point2f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + vertexAttr.x = this.vertexData[offset]; + vertexAttr.y = this.vertexData[offset+1]; + + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point3f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + vertexAttr.x = this.vertexData[offset]; + vertexAttr.y = this.vertexData[offset+1]; + vertexAttr.z = this.vertexData[offset+2]; + + } + + /** + * Gets the vertex attribute associated with the vertex at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttr(int vertexAttrNum, int index, + Point4f vertexAttr) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + + vertexAttr.x = this.vertexData[offset]; + vertexAttr.y = this.vertexData[offset+1]; + vertexAttr.z = this.vertexData[offset+2]; + vertexAttr.w = this.vertexData[offset+3]; + + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttrs(int vertexAttrNum, int index, + float[] vertexAttrs) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int size = vertexAttrSizes[vertexAttrNum]; + int i, j, k; + + for (i = 0, j = offset; + ((i < vertexAttrs.length) && (j < this.vertexData.length)) ; + i += size, j += this.stride) { + for (k = 0; k < size; k++) { + vertexAttrs[i+k] = this.vertexData[j+k]; + } + } + + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point2f[] vertexAttrs) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j; + + for (i = 0, j = offset; + ((i < vertexAttrs.length) && (j < this.vertexData.length)) ; + i++, j += this.stride) { + vertexAttrs[i].x = this.vertexData[j]; + vertexAttrs[i].y = this.vertexData[j+1]; + } + + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point3f[] vertexAttrs) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j; + + for (i = 0, j = offset; + ((i < vertexAttrs.length) && (j < this.vertexData.length)) ; + i++, j += this.stride) { + vertexAttrs[i].x = this.vertexData[j]; + vertexAttrs[i].y = this.vertexData[j+1]; + vertexAttrs[i].z = this.vertexData[j+2]; + } + + } + + /** + * Gets the vertex attributes associated with the vertices starting at + * the specified index in the specified vertex attribute number + * for this object. + */ + public void getVertexAttrs(int vertexAttrNum, int index, + Point4f[] vertexAttrs) { + + int offset = this.stride*index + vertexAttrOffsets[vertexAttrNum]; + int i, j; + + for (i = 0, j = offset; + ((i < vertexAttrs.length) && (j < this.vertexData.length)) ; + i++, j += this.stride) { + vertexAttrs[i].x = this.vertexData[j]; + vertexAttrs[i].y = this.vertexData[j+1]; + vertexAttrs[i].z = this.vertexData[j+2]; + vertexAttrs[i].w = this.vertexData[j+3]; + } + + } + + + /** * Updates geometry array data. */ void updateData(GeometryUpdater updater) { @@ -5519,7 +6267,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ inUpdater = false; if ((vertexFormat & GeometryArray.BY_REFERENCE) != 0) { if((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { - // TODO: handle the nio buffer + // XXXX: handle the nio buffer if (!(this instanceof IndexedGeometryArrayRetained) || (vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) { if (((vertexFormat & GeometryArray.INTERLEAVED) != 0)) { @@ -5540,10 +6288,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ nullGeo = (interLeavedVertexData == null); } else { - setupMirrorVertexPointer((vertexType & VERTEX_DEFINED)); + setupMirrorVertexPointer(vertexType & VERTEX_DEFINED); setupMirrorColorPointer((vertexType & COLOR_DEFINED), false); - setupMirrorNormalPointer((vertexType & NORMAL_DEFINED)); - setupMirrorTexCoordPointer((vertexType & TEXCOORD_DEFINED)); + setupMirrorNormalPointer(vertexType & NORMAL_DEFINED); + setupMirrorTexCoordPointer(texCoordType); + setupMirrorVertexAttrPointer(vertexAttrType); nullGeo = ((vertexType & GeometryArrayRetained.VERTEX_DEFINED) == 0); } } @@ -7254,7 +8003,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ direction.z = end.z - start.z; result = intersectRayOrSegment(coordinates, direction, start, dist, iPnt, true); freeVector3d(direction); - return result; + if((result == true) && (dist[0] <= 1.0)) { + return true; + } + + return false; + } @@ -7435,7 +8189,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // Note that by next round sign*lastSign = 0 so it will // not pass the interest test. This should only happen once in the // loop because we already check for degenerate geometry before. - lastSign = 0; } } } @@ -7467,7 +8220,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ isIntersect = ((t > -EPS) && (t < 1+EPS)); break; } else { - lastSign = 0; //degenerate line=>point + //degenerate line=>point } } } @@ -7499,7 +8252,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ isIntersect = ((t > -EPS) && (t < 1+EPS)); break; } else { - lastSign = 0; //degenerate line=>point + //degenerate line=>point } } } @@ -7529,7 +8282,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ isIntersect = ((t > -EPS) && (t < 1+EPS)); break; } else { - lastSign = 0; //degenerate line=>point + //degenerate line=>point } } } @@ -8036,18 +8789,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if (coords != null) { switch (coords.getBufferType()) { case J3DBuffer.TYPE_FLOAT: - if ( !((FloatBufferWrapper)coords.getBufferImpl()).isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); - - // TODO: may need to check whether it is direct and if so, - // whether it is consistent with native byte order + assert ((FloatBufferWrapper)coords.getBufferImpl()).isDirect(); break; case J3DBuffer.TYPE_DOUBLE: - if ( !((DoubleBufferWrapper)coords.getBufferImpl()).isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); - - // TODO: may need to check whether it is direct and if so, - // whether it is consistent with native byte order + assert ((DoubleBufferWrapper)coords.getBufferImpl()).isDirect(); break; case J3DBuffer.TYPE_NULL: throw new IllegalArgumentException(J3dI18N.getString("GeometryArray115")); @@ -8066,7 +8811,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } - //throw new RuntimeException("method not implemeted"); // lock the geometry and start to do real work geomLock.getLock(); dirtyFlag |= COORDINATE_CHANGED; @@ -8074,7 +8818,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if(coords == null) { floatBufferRefCoords = null; doubleBufferRefCoords = null; - // TODO: if not mix java array with nio buffer + // XXXX: if not mix java array with nio buffer // vertexType can be used as vertexTypeBuffer vertexType &= ~PD; vertexType &= ~PF; @@ -8101,7 +8845,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // need not call setupMirrorVertexPointer() since // we are not going to set mirror in NIO buffer case - // TODO: if we need to mix java array with buffer, + // XXXX: if we need to mix java array with buffer, // we may need to consider setupMirrorVertexPointer() geomLock.unLock(); @@ -8375,12 +9119,10 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if (colors != null) { switch(colors.getBufferType()) { case J3DBuffer.TYPE_FLOAT: - if ( !((FloatBufferWrapper)colors.getBufferImpl()).isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); + assert ((FloatBufferWrapper)colors.getBufferImpl()).isDirect(); break; case J3DBuffer.TYPE_BYTE: - if ( !((ByteBufferWrapper)colors.getBufferImpl()).isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); + assert ((ByteBufferWrapper)colors.getBufferImpl()).isDirect(); break; case J3DBuffer.TYPE_NULL: throw new IllegalArgumentException(J3dI18N.getString("GeometryArray115")); @@ -8759,8 +9501,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ bufferImpl = (FloatBufferWrapper)normals.getBufferImpl(); - if ( ! bufferImpl.isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); + assert bufferImpl.isDirect(); if ((vertexFormat & GeometryArray.NORMALS) == 0) { throw new IllegalStateException(J3dI18N.getString("GeometryArray122")); @@ -8863,15 +9604,17 @@ abstract class GeometryArrayRetained extends GeometryRetained{ void setTexCoordRefFloat(int texCoordSet, float[] texCoords) { - if (texCoords != null) { + if (texCoordType != 0 && texCoordType != TF) { + if (texCoords != null) { + throw new IllegalArgumentException( + J3dI18N.getString("GeometryArray98")); + } + return; + } - if ((vertexType & TEXCOORD_DEFINED) != 0 && - (vertexType & TEXCOORD_DEFINED) != TF) { - throw new IllegalArgumentException( - J3dI18N.getString("GeometryArray98")); - } + if (texCoords != null) { - int ts = getTexStride(); + int ts = getTexStride(); if (this instanceof IndexedGeometryArrayRetained) { IndexedGeometryArrayRetained idx = (IndexedGeometryArrayRetained)this; @@ -8889,10 +9632,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ refTexCoords[texCoordSet] = texCoords; if (inUpdater || (this instanceof IndexedGeometryArrayRetained && ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0))) { - if (texCoords == null) - vertexType &= ~TF; - else - vertexType |= TF; + texCoordType = TF; + validateTexCoordPointerType(); } else { setupMirrorTexCoordPointer(texCoordSet, TF); @@ -8903,8 +9644,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } - - + float[] getTexCoordRefFloat(int texCoordSet) { return ((float[])refTexCoords[texCoordSet]); } @@ -8921,8 +9661,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ bufferImpl = (FloatBufferWrapper)texCoords.getBufferImpl(); int bufferSize = bufferImpl.limit(); - if ( ! bufferImpl.isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); + assert bufferImpl.isDirect(); int ts = getTexStride(); @@ -8941,14 +9680,14 @@ abstract class GeometryArrayRetained extends GeometryRetained{ // refTexCoordsBuffer contains J3DBuffer object for tex coord refTexCoordsBuffer[texCoordSet] = texCoords; if (texCoords == null) { - vertexType &= ~TF; refTexCoords[texCoordSet] = null; } else { - vertexType |= TF; // refTexCoords contains NIOBuffer object for tex coord refTexCoords[texCoordSet] = bufferImpl.getBufferAsObject(); } + texCoordType = TF; + validateTexCoordPointerType(); geomLock.unLock(); if (!inUpdater && source != null && source.isLive()) { sendDataChangedMessage(false); @@ -8961,13 +9700,15 @@ abstract class GeometryArrayRetained extends GeometryRetained{ void setTexCoordRef2f(int texCoordSet, TexCoord2f[] texCoords) { - if (texCoords != null) { - if ((vertexType & TEXCOORD_DEFINED) != 0 && - (vertexType & TEXCOORD_DEFINED) != T2F) { - throw new IllegalArgumentException( - J3dI18N.getString("GeometryArray98")); - } - + if (texCoordType != 0 && texCoordType != T2F) { + if (texCoords != null) { + throw new IllegalArgumentException( + J3dI18N.getString("GeometryArray98")); + } + return; + } + + if (texCoords != null) { if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_2) == 0) { throw new IllegalStateException( J3dI18N.getString("GeometryArray94")); @@ -8990,13 +9731,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ refTexCoords[texCoordSet] = texCoords; if (inUpdater || (this instanceof IndexedGeometryArrayRetained && ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0))) { - if (texCoords == null) - vertexType &= ~T2F; - else - vertexType |= T2F; + texCoordType = T2F; + validateTexCoordPointerType(); } else { - setupMirrorTexCoordPointer(T2F); + setupMirrorTexCoordPointer(texCoordSet, T2F); } geomLock.unLock(); if (!inUpdater && source != null && source.isLive()) { @@ -9017,14 +9756,16 @@ abstract class GeometryArrayRetained extends GeometryRetained{ void setTexCoordRef3f(int texCoordSet, TexCoord3f[] texCoords) { + if (texCoordType != 0 && texCoordType != T3F) { + if (texCoords != null) { + throw new IllegalArgumentException( + J3dI18N.getString("GeometryArray98")); + } + return; + } + if (texCoords != null) { - if ((vertexType & TEXCOORD_DEFINED) != 0 && - (vertexType & TEXCOORD_DEFINED) != T3F) { - throw new IllegalArgumentException( - J3dI18N.getString("GeometryArray98")); - } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_3) == 0) { throw new IllegalStateException( J3dI18N.getString("GeometryArray95")); @@ -9048,13 +9789,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ refTexCoords[texCoordSet] = texCoords; if (inUpdater || (this instanceof IndexedGeometryArrayRetained && ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0))) { - if (texCoords == null) - vertexType &= ~T3F; - else - vertexType |= T3F; + texCoordType = T3F; + validateTexCoordPointerType(); } else { - setupMirrorTexCoordPointer(T3F); + setupMirrorTexCoordPointer(texCoordSet, T3F); } geomLock.unLock(); if (!inUpdater && source != null && source.isLive()) { @@ -9073,6 +9812,125 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } + /** + * Sets the float vertex attribute array reference for the + * specified vertex attribute number to the specified array. + */ + void setVertexAttrRefFloat(int vertexAttrNum, float[] vertexAttrs) { + + // XXXX: Add the following test if we ever add double-precision types + /* + if (vertexAttrType != 0 && vertexAttrType != AF) { + if (vertexAttrs != null) { + // XXXX: new exception string + throw new IllegalArgumentException( + J3dI18N.getString("GeometryArray98-XXX")); + } + return; + } + */ + + if (vertexAttrs != null) { + int sz = vertexAttrSizes[vertexAttrNum]; + + if (this instanceof IndexedGeometryArrayRetained) { + IndexedGeometryArrayRetained idx = (IndexedGeometryArrayRetained)this; + + if (sz*idx.maxVertexAttrIndices[vertexAttrNum] >= vertexAttrs.length) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30")); + } + + } else if (vertexAttrs.length < sz*(initialVertexAttrIndex[vertexAttrNum] + validVertexCount) ) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("GeometryArray129")); + } + } + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + floatRefVertexAttrs[vertexAttrNum] = vertexAttrs; + if (inUpdater || (this instanceof IndexedGeometryArrayRetained && + ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0))) { + vertexAttrType = AF; + validateVertexAttrPointerType(); + } + else { + setupMirrorVertexAttrPointer(vertexAttrNum, AF); + } + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } + } + + /** + * Gets the float vertex attribute array reference for the specified + * vertex attribute number. + */ + float[] getVertexAttrRefFloat(int vertexAttrNum) { + return floatRefVertexAttrs[vertexAttrNum]; + } + + + /** + * Sets the vertex attribute buffer reference for the specified + * vertex attribute number to the specified buffer object. + */ + void setVertexAttrRefBuffer(int vertexAttrNum, J3DBuffer vertexAttrs) { + + FloatBufferWrapper bufferImpl = null; + + if (vertexAttrs != null) { + if(vertexAttrs.getBufferType() != J3DBuffer.TYPE_FLOAT) + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116")); + + bufferImpl = (FloatBufferWrapper)vertexAttrs.getBufferImpl(); + int bufferSize = bufferImpl.limit(); + + assert bufferImpl.isDirect(); + + int sz = vertexAttrSizes[vertexAttrNum]; + + if (this instanceof IndexedGeometryArrayRetained) { + IndexedGeometryArrayRetained idx = (IndexedGeometryArrayRetained)this; + + if (idx.maxVertexAttrIndices[vertexAttrNum] * sz >= bufferSize) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30")); + } + } else if (bufferSize < sz*(initialVertexAttrIndex[vertexAttrNum] + validVertexCount)) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("GeometryArray129")); + } + } + + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + vertexAttrsRefBuffer[vertexAttrNum] = vertexAttrs; + if (vertexAttrs == null) { + floatBufferRefVertexAttrs[vertexAttrNum] = null; + nioFloatBufferRefVertexAttrs[vertexAttrNum] = null; + } + else { + floatBufferRefVertexAttrs[vertexAttrNum] = bufferImpl; + nioFloatBufferRefVertexAttrs[vertexAttrNum] = + bufferImpl.getBufferAsObject(); + } + vertexAttrType = AF; + validateVertexAttrPointerType(); + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } + + } + + /** + * Gets the vertex attribute array buffer reference for the specified + * vertex attribute number. + */ + J3DBuffer getVertexAttrRefBuffer(int vertexAttrNum) { + return vertexAttrsRefBuffer[vertexAttrNum]; + } + + void setInterleavedVertices(float[] vertexData) { if (vertexData != null) { @@ -9135,10 +9993,9 @@ abstract class GeometryArrayRetained extends GeometryRetained{ throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116")); bufferImpl = (FloatBufferWrapper)vertexData.getBufferImpl(); - - if (!bufferImpl.isDirect()) - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray120")); - + + assert bufferImpl.isDirect(); + int bufferSize = bufferImpl.limit(); if (this instanceof IndexedGeometryArrayRetained) { @@ -9203,37 +10060,20 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } void setValidVertexCount(int validVertexCount) { + boolean nullGeo = false; if (validVertexCount < 0) { throw new IllegalArgumentException(J3dI18N.getString("GeometryArray110")); } - if ((initialVertexIndex + validVertexCount) > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray100")); - } - else if ((initialCoordIndex + validVertexCount) > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray104")); - } - else if ((initialColorIndex + validVertexCount) > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray101")); - } - else if ((initialNormalIndex + validVertexCount) > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString("GeometryArray102")); - } - else { - if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - for (int i = 0; i < texCoordSetCount; i++) { - if ((initialTexCoordIndex[i] + validVertexCount) - > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString( - "GeometryArray103")); - } - } - } - } - } - if ((vertexFormat & GeometryArray.INTERLEAVED) != 0) { - // use nio buffer for interleaved data + + if ((initialVertexIndex + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray100")); + } + + if ((vertexFormat & GeometryArray.INTERLEAVED) != 0) { + // Interleaved, by-ref + + // use nio buffer for interleaved data if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0 && interleavedFloatBufferImpl != null){ if(interleavedFloatBufferImpl.limit() < stride * (initialVertexIndex + validVertexCount)) { throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("GeometryArray114")); @@ -9249,10 +10089,41 @@ abstract class GeometryArrayRetained extends GeometryRetained{ nullGeo = true; } } else if ((vertexFormat & GeometryArray.BY_REFERENCE) != 0) { - if ((vertexType & GeometryArrayRetained.VERTEX_DEFINED) == 0) + // Non-interleaved, by-ref + + if ((initialCoordIndex + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray104")); + } + if ((initialColorIndex + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray101")); + } + if ((initialNormalIndex + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray102")); + } + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + for (int i = 0; i < texCoordSetCount; i++) { + if ((initialTexCoordIndex[i] + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString( + "GeometryArray103")); + } + } + } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + if ((initialVertexAttrIndex[i] + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString( + "GeometryArray130")); + } + } + } + + if ((vertexType & GeometryArrayRetained.VERTEX_DEFINED) == 0) { nullGeo = true; - - if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { + } + + if (( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { // by reference with nio buffer switch ((vertexType & GeometryArrayRetained.VERTEX_DEFINED)) { case PF: @@ -9324,6 +10195,18 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } break; } + switch ((vertexType & GeometryArrayRetained.VATTR_DEFINED)) { + case AF: + for (int i = 0; i < vertexAttrCount; i++) { + int sz = vertexAttrSizes[i]; + if (floatBufferRefVertexAttrs[i].limit() < + (sz * (initialVertexAttrIndex[i] + validVertexCount)) ) { + throw new ArrayIndexOutOfBoundsException( + J3dI18N.getString("GeometryArray129")); + } + } + break; + } } // By reference with java array else { @@ -9444,6 +10327,18 @@ abstract class GeometryArrayRetained extends GeometryRetained{ throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("GeometryArray111")); } } + switch ((vertexType & GeometryArrayRetained.VATTR_DEFINED)) { + case AF: + for (int i = 0; i < vertexAttrCount; i++) { + int sz = vertexAttrSizes[i]; + if (floatRefVertexAttrs[i].length < + (sz * (initialVertexAttrIndex[i] + validVertexCount)) ) { + throw new ArrayIndexOutOfBoundsException( + J3dI18N.getString("GeometryArray129")); + } + } + break; + } } } @@ -9455,7 +10350,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ processCoordsChanged(nullGeo); sendDataChangedMessage(true); } - } @@ -9689,6 +10583,49 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return initialNormalIndex; } + /** + * Sets the initial vertex attribute index for the specified + * vertex attribute number for this GeometryArray object. + */ + void setInitialVertexAttrIndex(int vertexAttrNum, + int initialVertexAttrIndex) { + + if ((initialVertexAttrIndex + validVertexCount) > vertexCount) { + throw new IllegalArgumentException(J3dI18N.getString("GeometryArray130")); + } + + int sz = vertexAttrSizes[vertexAttrNum]; + int minLength = sz * (initialVertexAttrIndex + validVertexCount); + if ((vertexType & VATTR_DEFINED) == AF) { + if ((vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { + if (floatBufferRefVertexAttrs[vertexAttrNum].limit() < minLength) { + throw new ArrayIndexOutOfBoundsException( + J3dI18N.getString("GeometryArray129")); + } + } else { + if (floatRefVertexAttrs[vertexAttrNum].length < minLength ) { + throw new ArrayIndexOutOfBoundsException( + J3dI18N.getString("GeometryArray129")); + } + } + } + geomLock.getLock(); + dirtyFlag |= VATTR_CHANGED; + this.initialVertexAttrIndex[vertexAttrNum] = initialVertexAttrIndex; + geomLock.unLock(); + // There is no need to send message for by reference, since we + // use VA + } + + + /** + * Gets the initial vertex attribute index for the specified + * vertex attribute number for this GeometryArray object. + */ + int getInitialVertexAttrIndex(int vertexAttrNum) { + return initialVertexAttrIndex[vertexAttrNum]; + } + void setInitialTexCoordIndex(int texCoordSet, int initialTexCoordIndex) { if ((initialTexCoordIndex + validVertexCount) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryArray103")); @@ -9900,6 +10837,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ source.getCapability(GeometryArray.ALLOW_COLOR_WRITE) || source.getCapability(GeometryArray.ALLOW_NORMAL_WRITE) || source.getCapability(GeometryArray.ALLOW_TEXCOORD_WRITE) || + source.getCapability(GeometryArray.ALLOW_VERTEX_ATTR_WRITE) || source.getCapability(GeometryArray.ALLOW_COUNT_WRITE) || source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)) return false; @@ -9963,7 +10901,8 @@ abstract class GeometryArrayRetained extends GeometryRetained{ float[] curVertexData; int length, srcOffset; int curOffset = 0; - // We only merge if the texCoordSetCount is 1; + // We only merge if the texCoordSetCount is 1 and there are no + // vertex attrs if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { texCoordSetCount = 1; texCoordSetMap = new int[1]; @@ -10002,7 +10941,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ texCoordSetMap != null && texCoordSetMap.length > 1)) { return false; } - + + // We will avoid merging geometry if there are any vertex attributes. + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + return false; + } // If intersect is allowed turn off merging if (source.getCapability(Geometry.ALLOW_INTERSECT)) @@ -10011,32 +10954,6 @@ abstract class GeometryArrayRetained extends GeometryRetained{ return true; } - boolean isTextureGeometryMergeable(GeometryArrayRetained srcGeo) { - - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - if (texCoordSetCount != srcGeo.texCoordSetCount ) - return false; - - // If they are both non-null, then check if they are equivalent - if (texCoordSetMap != null && srcGeo.texCoordSetMap != null) { - if (texCoordSetMap.length != srcGeo.texCoordSetMap.length) - return false; - - // Check the texCoordSetMap is same - for (int j = 0; j < texCoordSetMap.length; j++) { - if (texCoordSetMap[j] != srcGeo.texCoordSetMap[j]) - return false; - } - } - // Check if they are both null; - // if one is null and other is non-null return false - else if (texCoordSetMap != srcGeo.texCoordSetMap) - return false; - } - - return true; - } - void compile(CompileState compState) { super.compile(compState); @@ -10097,7 +11014,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ geomLock.getLock(); if (this instanceof IndexedGeometryArrayRetained) { if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - mirrorGeometry = (GeometryRetained) + mirrorGeometry = ((IndexedGeometryArrayRetained)this).cloneNonIndexedGeometry(); } else { @@ -10113,7 +11030,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ geomLock.getLock(); if (this instanceof IndexedGeometryArrayRetained) { if (mirrorGeometry != null) { - mirrorGeometry = (GeometryRetained) + mirrorGeometry = ((IndexedGeometryArrayRetained)this).cloneNonIndexedGeometry(); } } @@ -10261,7 +11178,7 @@ abstract class GeometryArrayRetained extends GeometryRetained{ if ((vertexFormat & GeometryArray.INTERLEAVED) == 0){ switch ((vertexType & GeometryArrayRetained.VERTEX_DEFINED)) { case PF: - count = floatBufferRefCoords.limit()/3; // TODO: limit or capacity + count = floatBufferRefCoords.limit()/3; // XXXX: limit or capacity? break; case PD: count = doubleBufferRefCoords.limit()/3; @@ -10437,8 +11354,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } return count; - } - + } + + // NOTE: we don't need a getNumVertexAttrCount method, since getNum*Count + // is only called by Morph, which doesn't support vertex attrs + + // Found the min distance from center to the point/line/tri/quad // form by dist[] void computeMinDistance(Point3d coordinates[], Point3d center, @@ -10633,9 +11554,11 @@ abstract class GeometryArrayRetained extends GeometryRetained{ (((vertexFormat & GeometryArray.COLOR) != 0) && bit == GeometryArray.ALLOW_COLOR_WRITE)|| (((vertexFormat & GeometryArray.NORMALS) != 0) && - bit ==GeometryArray.ALLOW_NORMAL_WRITE) || - (((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)&& + bit == GeometryArray.ALLOW_NORMAL_WRITE) || + (((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) && bit == GeometryArray.ALLOW_TEXCOORD_WRITE) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + bit == GeometryArray.ALLOW_VERTEX_ATTR_WRITE) || (bit == GeometryArray.ALLOW_COUNT_WRITE)) { mask = 1; } @@ -10649,5 +11572,12 @@ abstract class GeometryArrayRetained extends GeometryRetained{ } } + int getTexCoordType() { + return texCoordType; + } + + int getVertexAttrType() { + return vertexAttrType; + } } diff --git a/src/classes/share/javax/media/j3d/GeometryDecompressorRetained.java b/src/classes/share/javax/media/j3d/GeometryDecompressorRetained.java index 6511553..e9cbdc8 100644 --- a/src/classes/share/javax/media/j3d/GeometryDecompressorRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryDecompressorRetained.java @@ -57,7 +57,7 @@ class GeometryDecompressorRetained extends GeometryDecompressor { // normal-per-vertex data collected from the HelloUniverse.cg file // (seagull, '57 Chevy, dinosaur). // - // TODO: get fudge values for other vertex combinations + // XXXX: get fudge values for other vertex combinations private static final float bytesPerVertexFudge = 5.3f ; // Used for benchmarking if so configured. diff --git a/src/classes/share/javax/media/j3d/GeometryRetained.java b/src/classes/share/javax/media/j3d/GeometryRetained.java index 2b0a39d..3def9c3 100644 --- a/src/classes/share/javax/media/j3d/GeometryRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryRetained.java @@ -229,12 +229,11 @@ abstract class GeometryRetained extends NodeComponentRetained { return 0 ; } - abstract boolean intersect(PickShape pickShape, double dist[], Point3d iPnt); + abstract boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt); abstract boolean intersect(Bounds targetBound); abstract boolean intersect(Point3d[] pnts); abstract boolean intersect(Transform3D thisToOtherVworld, GeometryRetained geom); - boolean intersect(Transform3D thisLocalToVworld, Transform3D otherLocalToVworld, GeometryRetained geom) { Transform3D tg = VirtualUniverse.mc.getTransform3D(null); @@ -256,15 +255,69 @@ abstract class GeometryRetained extends NodeComponentRetained { } + // Return a flag indicating whether or not this Geometry object can be in + // a display list. + // + // XXXX: Note that for IndexedGeometryArray objects, the original + // vertex format is used in making this determination, even when it has + // been unindexified. This should be fixed by using the vertex format of + // the mirror geometry if there is one. boolean canBeInDisplayList(boolean alphaEditable) { - - return (VirtualUniverse.mc.isDisplayList) && - !(this.isEditable || - (!(this instanceof GeometryArrayRetained) && alphaEditable)|| - (alphaEditable && ((((GeometryArrayRetained)this).vertexFormat& - GeometryArray.COLOR) != 0)) || - (((((GeometryArrayRetained)this).vertexFormat & - GeometryArray.BY_REFERENCE) != 0) && !VirtualUniverse.mc.buildDisplayListIfPossible)); + // Check global flag to see whether we can build display lists + if (!VirtualUniverse.mc.isDisplayList) { + return false; + } + + // Can't build display lists if geometry is editable + // XXXX: should look at isFrequent bit and allow DL if + // infrequently writable + if (this.isEditable) { + return false; + } + + if (this instanceof GeometryArrayRetained) { + int vFormat = ((GeometryArrayRetained)this).vertexFormat; + + // If geometry has vertex attributes, check whether + // vertex attributes are allowed in display lists + if (((vFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + !VirtualUniverse.mc.vertexAttrsInDisplayList) { + return false; + } + + // Can't build display lists if alpha is editable and + // geometry array has colors + if (alphaEditable && ((vFormat & GeometryArray.COLOR) != 0)) { + return false; + } + + // Only build DL for by-ref geometry when system property is set. + // Exclude NIO buffers and use-coord-index-only + if ((vFormat & GeometryArray.BY_REFERENCE) != 0) { + if (!VirtualUniverse.mc.buildDisplayListIfPossible) { + return false; + } + + // XXXX: we could change this to allow display lists for + // non-interleaved NIO buffers, but we would first need to + // update the now-obsolete buildGAForBuffer method to handle + // vertex attrs + if ((vFormat & GeometryArray.USE_NIO_BUFFER) != 0) { + return false; + } + + if ((vFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) { + return false; + } + } + + return true; + } else { + // Can't build display lists for other kind of geometry + // NOTE: This method is not called for any type of Geometry + // other than GeometryArray, so we shouldn't even get here. + return false; + } } void computeCentroid() { diff --git a/src/classes/share/javax/media/j3d/GeometryStripArray.java b/src/classes/share/javax/media/j3d/GeometryStripArray.java index 39c4dde..88d927f 100644 --- a/src/classes/share/javax/media/j3d/GeometryStripArray.java +++ b/src/classes/share/javax/media/j3d/GeometryStripArray.java @@ -31,18 +31,15 @@ public abstract class GeometryStripArray extends GeometryArray { * Constructs an empty GeometryStripArray object with the specified * number of vertices, vertex format, and * array of per-strip vertex counts. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2 or TEXTURE_COORDINATE_3, to signal the - * inclusion of per-vertex texture coordinates 2D or 3D. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @param stripVertexCounts array that specifies * the count of the number of vertices for each separate strip. * The length of this array is the number of separate strips. @@ -50,7 +47,10 @@ public abstract class GeometryStripArray extends GeometryArray { * of valid vertices that are rendered (validVertexCount). * * @exception IllegalArgumentException if - * <code>validVertexCount > vertexCount</code> + * <code>validVertexCount > vertexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public GeometryStripArray(int vertexCount, int vertexFormat, @@ -66,50 +66,21 @@ public abstract class GeometryStripArray extends GeometryArray { * sets, texture coordinate mapping array, and * array of per-strip vertex counts. * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2 or TEXTURE_COORDINATE_3, to signal the - * inclusion of per-vertex texture coordinates 2D or 3D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code> or - * <code>TEXTURE_COORDINATE_3</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code> or - * <code>TEXTURE_COORDINATE_3</code>, the - * <code>texCoordSetMap</code> array is not used.<p> + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @param stripVertexCounts array that specifies * the count of the number of vertices for each separate strip. @@ -118,7 +89,10 @@ public abstract class GeometryStripArray extends GeometryArray { * of valid vertices that are rendered (validVertexCount). * * @exception IllegalArgumentException if - * <code>validVertexCount > vertexCount</code> + * <code>validVertexCount > vertexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -134,6 +108,62 @@ public abstract class GeometryStripArray extends GeometryArray { } /** + * Constructs an empty GeometryStripArray object with the + * specified number of vertices, vertex format, number of texture + * coordinate sets, texture coordinate mapping array, vertex + * attribute count, vertex attribute sizes array, and array of + * per-strip vertex counts. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts array that specifies + * the count of the number of vertices for each separate strip. + * The length of this array is the number of separate strips. + * The sum of the elements in this array defines the total number + * of valid vertices that are rendered (validVertexCount). + * + * @exception IllegalArgumentException if + * <code>validVertexCount > vertexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public GeometryStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + ((GeometryStripArrayRetained)this.retained).setStripVertexCounts(stripVertexCounts); + } + + /** * Get number of strips in the GeometryStripArray. * @return numStrips number of strips */ diff --git a/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java index 1340be7..e6f83c0 100644 --- a/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/GeometryStripArrayRetained.java @@ -46,9 +46,9 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { /** * Set stripVertexCount data into local array */ - void setStripVertexCounts(int stripVertexCounts[]){ - boolean nullGeo = false; - + void setStripVertexCounts(int stripVertexCounts[]) { + boolean nullGeo = false; + int i, num = stripVertexCounts.length, total = 0; for (i=0; i < num; i++) { total += stripVertexCounts[i]; @@ -72,28 +72,37 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { if ((initialVertexIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray3")); } - else if ((initialCoordIndex + total) > vertexCount) { + if ((initialCoordIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray7")); } - else if ((initialColorIndex + total) > vertexCount) { + if ((initialColorIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray4")); } - else if ((initialNormalIndex + total) > vertexCount) { + if ((initialNormalIndex + total) > vertexCount) { throw new IllegalArgumentException(J3dI18N.getString("GeometryStripArray5")); } - else { - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { - for (i = 0; i < texCoordSetCount; i++) { - if ((initialTexCoordIndex[i] + total) > vertexCount) { - throw new IllegalArgumentException(J3dI18N.getString( - "GeometryStripArray6")); - } - } - } - } - } - geomLock.getLock(); + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { + for (i = 0; i < texCoordSetCount; i++) { + if ((initialTexCoordIndex[i] + total) > vertexCount) { + throw new IllegalArgumentException( + J3dI18N.getString("GeometryStripArray6")); + } + } + } + } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + if ((vertexFormat & (GeometryArray.BY_REFERENCE|vertexFormat &GeometryArray.INTERLEAVED)) == GeometryArray.BY_REFERENCE) { + for (i = 0; i < vertexAttrCount; i++) { + if ((initialVertexAttrIndex[i] + total) > vertexCount) { + throw new IllegalArgumentException( + J3dI18N.getString("GeometryStripArray8")); + } + } + } + } + + geomLock.getLock(); dirtyFlag |= STRIPCOUNT_CHANGED; validVertexCount = total; this.stripVertexCounts = new int[num]; @@ -139,7 +148,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { unIndexifyNIOBuffer(src); } } - void unIndexifyJavaArray(IndexedGeometryStripArrayRetained src) { + + private void unIndexifyJavaArray(IndexedGeometryStripArrayRetained src) { int vOffset = 0, srcOffset, tOffset = 0; int base = src.initialIndexIndex; int i,j, k, index, colorStride = 0; @@ -169,7 +179,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { src.indexNormal[index]*src.stride + src.normalOffset, vertexData, vOffset + normalOffset, 3); } - if (colorStride == 4) { + + if (colorStride == 4) { /* System.out.println("vdata.length = "+vdata.length); System.out.println("vertexData.length = "+vertexData.length); @@ -188,11 +199,12 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { vertexData, vOffset + colorOffset, colorStride); vertexData[vOffset + colorOffset + 3] = 1.0f; } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { for (k = 0; k < texCoordSetCount; k++) { System.arraycopy(vdata, - (((int[])src.indexTexCoord[k])[index]) - *src.stride + src.textureOffset + + (src.indexTexCoord[k][index]) + * src.stride + src.textureOffset + src.texCoordSetMapOffset[k], vertexData, vOffset + textureOffset + @@ -201,7 +213,17 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { } } - if ((vertexFormat & GeometryArray.COORDINATES) != 0){ + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (k = 0; k < vertexAttrCount; k++) { + System.arraycopy(vdata, + src.indexVertexAttr[k][index] * src.stride + src.vertexAttrOffsets[k], + vertexData, + vOffset + vertexAttrOffsets[k], + vertexAttrSizes[k]); + } + } + + if ((vertexFormat & GeometryArray.COORDINATES) != 0) { System.arraycopy(vdata, src.indexCoord[index]*src.stride + src.coordinateOffset, vertexData, vOffset + coordinateOffset, 3); @@ -245,7 +267,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { break; } } - if ((vertexFormat & GeometryArray.COLOR) != 0){ + + if ((vertexFormat & GeometryArray.COLOR) != 0){ base = src.initialIndexIndex; vOffset = colorOffset; int multiplier = 3; @@ -351,7 +374,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { break; } } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { base = src.initialIndexIndex; vOffset = textureOffset; switch ((src.vertexType & TEXCOORD_DEFINED)) { @@ -363,7 +387,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { for (k = 0, tOffset = vOffset; k < texCoordSetCount; k++) { System.arraycopy(src.refTexCoords[k], - ((int[])src.indexTexCoord[k])[index] + src.indexTexCoord[k][index] *texCoordStride, vertexData, tOffset, texCoordStride); tOffset += texCoordStride; @@ -380,7 +404,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { for (k = 0, tOffset = vOffset; k < texCoordSetCount; k++) { srcOffset = - ((int[])src.indexTexCoord[k])[index]; + src.indexTexCoord[k][index]; vertexData[tOffset] = ((TexCoord2f[]) src.refTexCoords[k])[srcOffset].x; vertexData[tOffset+1] = ((TexCoord2f[]) @@ -399,7 +423,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { for (k = 0, tOffset = vOffset; k < texCoordSetCount; k++) { srcOffset = - ((int[])src.indexTexCoord[k])[index]; + src.indexTexCoord[k][index]; vertexData[tOffset] = ((TexCoord3f[]) src.refTexCoords[k])[srcOffset].x; vertexData[tOffset+1] = ((TexCoord3f[]) @@ -417,7 +441,32 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { default: break; } - } + } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + base = src.initialIndexIndex; + vOffset = 0; + switch (src.vertexType & VATTR_DEFINED) { + case AF: + for (i=0; i < src.stripIndexCounts.length; i++) { + for (j=0; j < src.stripIndexCounts[i]; j++) { + index = j+base; + + for (k = 0; k < vertexAttrCount; k++) { + System.arraycopy(src.floatRefVertexAttrs[k], + src.indexVertexAttr[k][index]*vertexAttrSizes[k], + vertexData, + vOffset + vertexAttrOffsets[k], + vertexAttrSizes[k]); + } + vOffset += stride; + } + base += src.stripIndexCounts[i]; + } + break; + } + } + if ((vertexFormat & GeometryArray.COORDINATES) != 0){ vOffset = coordinateOffset; base = src.initialIndexIndex; @@ -477,9 +526,9 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { } } } - - void unIndexifyNIOBuffer(IndexedGeometryStripArrayRetained src) { - int vOffset = 0, srcOffset, tOffset = 0; + + private void unIndexifyNIOBuffer(IndexedGeometryStripArrayRetained src) { + int vOffset = 0, srcOffset, tOffset = 0; int base = src.initialIndexIndex; int i,j, k, index, colorStride = 0; @@ -506,9 +555,10 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { src.interleavedFloatBufferImpl.get(vertexData, vOffset + colorOffset, colorStride); vertexData[vOffset + colorOffset + 3] = 1.0f; } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { for (k = 0; k < texCoordSetCount; k++) { - src.interleavedFloatBufferImpl.position((((int[])src.indexTexCoord[k])[index]) + src.interleavedFloatBufferImpl.position((src.indexTexCoord[k][index]) *src.stride + src.textureOffset + src.texCoordSetMapOffset[k]); @@ -527,7 +577,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { } } else { - if ((vertexFormat & GeometryArray.NORMALS) != 0){ + if ((vertexFormat & GeometryArray.NORMALS) != 0) { base = src.initialIndexIndex; vOffset = normalOffset; if((src.vertexType & NORMAL_DEFINED) != 0) { @@ -542,7 +592,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { } } } - if ((vertexFormat & GeometryArray.COLOR) != 0){ + + if ((vertexFormat & GeometryArray.COLOR) != 0) { base = src.initialIndexIndex; vOffset = colorOffset; int multiplier = 3; @@ -593,7 +644,8 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { break; } } - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { base = src.initialIndexIndex; vOffset = textureOffset; FloatBufferWrapper texBuffer; @@ -605,7 +657,7 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { for (k = 0, tOffset = vOffset; k < texCoordSetCount; k++) { texBuffer = (FloatBufferWrapper)(((J3DBuffer) (src.refTexCoordsBuffer[k])).getBufferImpl()); - texBuffer.position(((int[])src.indexTexCoord[k])[index]*texCoordStride); + texBuffer.position(src.indexTexCoord[k][index]*texCoordStride); texBuffer.get(vertexData, tOffset, texCoordStride); tOffset += texCoordStride; } @@ -614,8 +666,30 @@ abstract class GeometryStripArrayRetained extends GeometryArrayRetained { base += src.stripIndexCounts[i]; } } - } - if ((vertexFormat & GeometryArray.COORDINATES) != 0){ + } + + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + base = src.initialIndexIndex; + vOffset = 0; + if((src.vertexType & VATTR_DEFINED) == AF) { + for (i=0; i < src.stripIndexCounts.length; i++) { + for (j=0; j < src.stripIndexCounts[i]; j++) { + index = j+base; + + for (k = 0; k < vertexAttrCount; k++) { + int vaOffset = vOffset + vertexAttrOffsets[k]; + FloatBufferWrapper vaBuffer = src.floatBufferRefVertexAttrs[k]; + vaBuffer.position(src.indexVertexAttr[k][index]*vertexAttrSizes[k]); + vaBuffer.get(vertexData, vaOffset, vertexAttrSizes[k]); + } + vOffset += stride; + } + base += src.stripIndexCounts[i]; + } + } + } + + if ((vertexFormat & GeometryArray.COORDINATES) != 0) { vOffset = coordinateOffset; base = src.initialIndexIndex; switch ((src.vertexType & VERTEX_DEFINED)) { diff --git a/src/classes/share/javax/media/j3d/GeometryStructure.java b/src/classes/share/javax/media/j3d/GeometryStructure.java index 7bb9552..b8d7e0d 100644 --- a/src/classes/share/javax/media/j3d/GeometryStructure.java +++ b/src/classes/share/javax/media/j3d/GeometryStructure.java @@ -168,7 +168,6 @@ class GeometryStructure extends J3dStructure { case J3dMessage.MORPH_CHANGED: { int comp = ((Integer)m.args[1]).intValue(); if (comp == MorphRetained.GEOMETRY_CHANGED) { - // TODO: Optimize this case. processBoundsChanged((Object []) m.args[3], false); } else if (comp == MorphRetained.APPEARANCE_CHANGED) { diff --git a/src/classes/share/javax/media/j3d/GraphStructureChangeListener.java b/src/classes/share/javax/media/j3d/GraphStructureChangeListener.java new file mode 100755 index 0000000..c0a50a0 --- /dev/null +++ b/src/classes/share/javax/media/j3d/GraphStructureChangeListener.java @@ -0,0 +1,54 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * Listener interface for monitoring structural changes to live scene + * graphs. BranchGroup additions, removals and moves are reported. + * + * @see VirtualUniverse#addGraphStructureChangeListener + * + * @since Java 3D 1.4 + */ +public interface GraphStructureChangeListener { + /** + * Invoked when a branch group is added. + * Called just before the child is added to the parent. + * Parent can be either a BranchGroup or a Locale. + * + * @param parent the parent of the child being added + * @param child the child being added + */ + public void branchGroupAdded(Object parent, BranchGroup child); + + /** + * Invoked when a branch group is removed. + * Called just after the child has been removed from the parent. + * Parent can be either a BranchGroup or a Locale. + * + * @param parent the parent of the child being added + * @param child the child being added + */ + public void branchGroupRemoved(Object parent, BranchGroup child); + + /** + * Invoked when a branch group is moved. + * Called after a child has been moved to it's new parent. This call differs + * from the other methods in that the child is live when this method is called. + * + * @param oldParent the original parent of the child being moved + * @param newParent the new parent of the child being moved + * @param child the child being moved + */ + public void branchGroupMoved(Object oldParent, Object newParent, BranchGroup child); +} diff --git a/src/classes/share/javax/media/j3d/GraphicsConfigInfo.java b/src/classes/share/javax/media/j3d/GraphicsConfigInfo.java new file mode 100644 index 0000000..7d9e04f --- /dev/null +++ b/src/classes/share/javax/media/j3d/GraphicsConfigInfo.java @@ -0,0 +1,35 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +class GraphicsConfigInfo { + private int reqStencilSize = 0; + private long fbConfig = 0L; + + int getRequestedStencilSize() { + return reqStencilSize; + } + + void setRequestedStencilSize(int reqSS) { + reqStencilSize = reqSS; + } + + long getFBConfig() { + return fbConfig; + } + + void setFBConfig(long fbC) { + fbConfig = fbC; + } + +} diff --git a/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java b/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java index 8b59219..38e8156 100644 --- a/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java +++ b/src/classes/share/javax/media/j3d/GraphicsConfigTemplate3D.java @@ -39,6 +39,7 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { int redSize; int sceneAntialiasing; int stereo; + int stencilSize; // Temporary variables use for passing argument to/from Request Renderer Object testCfg; @@ -66,12 +67,14 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { * redSize : 2<br> * greenSize : 2<br> * blueSize : 2<br> + * stencilSize : 0<br> * </ul> */ public GraphicsConfigTemplate3D() { doubleBuffer = REQUIRED; stereo = UNNECESSARY; depthSize = 16; + stencilSize = 0; redSize = greenSize = blueSize = 2; sceneAntialiasing = UNNECESSARY; } @@ -172,6 +175,35 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { } /** + * Sets the stencil buffer size requirement. + * This is the minimum requirement. + * If no GraphicsConfiguration is found that meets or + * exceeds this minimum requirement, null will be returned in + * getBestConfiguration(). + * + * @param value the value to set this field to + * + * @since Java 3D 1.4 + */ + public void setStencilSize(int value) { + if (value < 0) + return; + + stencilSize = value; + } + + /** + * Retrieves the size of the stencil buffer. + * + * @return the current value of the stencilSize attribute + * + * @since Java 3D 1.4 + */ + public int getStencilSize() { + return stencilSize; + } + + /** * Sets the number of red bits required. This is the minimum requirement. * If no GraphicsConfiguration is found that meets or * exceeds this minimum requirement, null will be returned in @@ -298,7 +330,8 @@ public class GraphicsConfigTemplate3D extends GraphicsConfigTemplate { if (gc == null) { return false; } - synchronized (globalLock) { + + synchronized (globalLock) { testCfg = gc; threadWaiting = true; if (Thread.currentThread() instanceof BehaviorScheduler) { diff --git a/src/classes/share/javax/media/j3d/GraphicsContext3D.java b/src/classes/share/javax/media/j3d/GraphicsContext3D.java index b5c7516..003134f 100644 --- a/src/classes/share/javax/media/j3d/GraphicsContext3D.java +++ b/src/classes/share/javax/media/j3d/GraphicsContext3D.java @@ -183,7 +183,7 @@ public class GraphicsContext3D extends Object { boolean lightsChanged = false; // A boolean that indicates the sounds have changed - // TODO: the soundsChanged flag are set like lights methods set + // XXXX: the soundsChanged flag are set like lights methods set // lightsChanged? but where is this supposed to be check??? // lightsChanged tested in 'draw'; but Sound are not processed // in draw. @@ -285,27 +285,29 @@ public class GraphicsContext3D extends Object { // when a new command is to be // added to the list - static Integer commands[] = new Integer[NCOMMANDS]; - static Integer stereoModes[] = {new Integer(STEREO_LEFT), - new Integer(STEREO_RIGHT), - new Integer(STEREO_BOTH)}; + private static Integer[] commands = new Integer[NCOMMANDS]; + private static Integer[] stereoModes = { + new Integer(STEREO_LEFT), + new Integer(STEREO_RIGHT), + new Integer(STEREO_BOTH) + }; // dirty bits - static final int BUFFER_MODE = 0x1; + private static final int BUFFER_MODE = 0x1; private int dirtyMask = 0; // multi-texture - int numActiveTexUnit = 0; - int lastActiveTexUnitIndex = 0; - boolean toSimulateMultiTex = true; + private int numActiveTexUnit = 0; + private int lastActiveTexUnitIndex = 0; + private boolean toSimulateMultiTex = false; // for read raster - volatile boolean readRasterReady = false; + private volatile boolean readRasterReady = false; // for runMonitor - boolean gcReady = false; - int waiting = 0; + private boolean gcReady = false; + private int waiting = 0; /** @@ -381,7 +383,12 @@ public class GraphicsContext3D extends Object { enableLighting = false; } - if (((AppearanceRetained)appearance.retained).texUnitState != null) { + if (appearance instanceof ShaderAppearance) { + // TODO : handle ShaderProgram and ShaderAttributeSet + System.err.println("ShaderProgram not implemented for immediate mode rendering"); + } + + if (((AppearanceRetained)appearance.retained).texUnitState != null) { TextureUnitStateRetained[] texUnitState = ((AppearanceRetained)appearance.retained).texUnitState; @@ -626,9 +633,8 @@ public class GraphicsContext3D extends Object { if (fog != null) { ((FogRetained)fog.retained).setInImmCtx(true); - - if (fog.retained instanceof LinearFogRetained) - updateFogState((LinearFogRetained)fog.retained); + // Issue 144: updateFogState now called unconditionally + updateFogState((FogRetained)fog.retained); } } @@ -912,8 +918,9 @@ public class GraphicsContext3D extends Object { } - void updateFogState(LinearFogRetained lfog) { - lfog.localToVworldScale = modelTransform.getDistanceScale(); + void updateFogState(FogRetained fogRet) { + // Issue 144: update localToVWorldScale for all types of Fog + fogRet.setLocalToVworldScale(modelTransform.getDistanceScale()); } @@ -1280,7 +1287,7 @@ public class GraphicsContext3D extends Object { if (view != null) { SoundScheduler soundScheduler = getSoundScheduler(); if (soundScheduler == null) { - // TODO: Re-implement + // XXXX: Re-implement // start up SoundScheduler since it hasn't already been started } } @@ -1291,13 +1298,13 @@ public class GraphicsContext3D extends Object { this.modelTransform.transform(cs.direction, cs.xformDirection); cs.xformDirection.normalize(); this.modelTransform.transform(cs.position, cs.xformPosition); - // TODO (Question) Is drawTranform equivalent to Vworld-to-Local? + // XXXX (Question) Is drawTranform equivalent to Vworld-to-Local? cs.trans.setWithLock(drawTransform); } else if (sound instanceof PointSoundRetained) { PointSoundRetained ps = (PointSoundRetained) sound; this.modelTransform.transform(ps.position, ps.xformPosition); - // TODO (Question) Is drawTranform equivalent to Vworld-to-Local? + // XXXX (Question) Is drawTranform equivalent to Vworld-to-Local? ps.trans.setWithLock(drawTransform); } } @@ -1559,7 +1566,7 @@ public class GraphicsContext3D extends Object { else back = this.black; - // TODO: This should ideally be done by the renderer (or by the + // XXXX: This should ideally be done by the renderer (or by the // canvas itself) when the canvas is first added to a view. /* if ((canvas3d.screen.renderer != null) && @@ -1575,7 +1582,7 @@ public class GraphicsContext3D extends Object { try { if (canvas3d.drawingSurfaceObject.renderLock()) { - // TODO : Fix texture + // XXXX : Fix texture /* if (canvas3d.useSharedCtx) { if (canvas3d.screen.renderer.sharedCtx == 0) { @@ -1594,13 +1601,7 @@ public class GraphicsContext3D extends Object { if (canvas3d.ctx == 0) { synchronized (VirtualUniverse.mc.contextCreationLock) { - canvas3d.ctx = - canvas3d.createNewContext(canvas3d.screen.display, - canvas3d.window, - canvas3d.vid, - canvas3d.fbConfig, - 0, false, - canvas3d.offScreen); + canvas3d.ctx = canvas3d.createNewContext(0, false); if (canvas3d.ctx == 0) { canvas3d.drawingSurfaceObject.unLock(); return; @@ -1608,8 +1609,8 @@ public class GraphicsContext3D extends Object { canvas3d.ctxTimeStamp = VirtualUniverse.mc.getContextTimeStamp(); - canvas3d.screen.renderer.listOfCtxs.add( - new Long(canvas3d.ctx)); + canvas3d.screen.renderer.listOfCtxs.add( + new Long(canvas3d.ctx)); canvas3d.screen.renderer.listOfCanvases.add(canvas3d); canvas3d.beginScene(); @@ -1618,43 +1619,21 @@ public class GraphicsContext3D extends Object { canvas3d.graphics2D.init(); } - // query for the number of texture units - // supported - if (canvas3d.multiTexAccelerated) { - canvas3d.numTexUnitSupported = - canvas3d.getTextureUnitCount(canvas3d.ctx); - } - - // enable separate specular color + // enable separate specular color canvas3d.enableSeparateSpecularColor(); } // create the cache texture state in canvas // for state download checking purpose - if (canvas3d.texUnitState == null) { - canvas3d.texUnitState = - new TextureUnitStateRetained[ - canvas3d.numTexUnitSupported]; - for (int t = 0; t < canvas3d.numTexUnitSupported; t++) { - canvas3d.texUnitState[t] = - new TextureUnitStateRetained(); - canvas3d.texUnitState[t].texture = null; - canvas3d.texUnitState[t].mirror = null; - } + canvas3d.createTexUnitState(); } - - // also create the texture unit state map - // which is a mapping from texture unit state to - // the actual underlying texture unit - + // Create the texture unit state map if (canvas3d.texUnitStateMap == null) { - canvas3d.texUnitStateMap = - new int[canvas3d.numTexUnitSupported]; + canvas3d.createTexUnitStateMap(); } - canvas3d.drawingSurfaceObject.contextValidated(); canvas3d.screen.renderer.currentCtx = canvas3d.ctx; initializeState(); @@ -1830,7 +1809,7 @@ public class GraphicsContext3D extends Object { // rb.setVworldToVpc(vp.getVworldToVpc()); // rb.setVpcToVworld(vp.getVpcToVworld()); - // TODO: Fix this + // XXXX: Fix this rb.vpcToVworld = vpR.getVpcToVworld(); rb.vworldToVpc = vpR.getVworldToVpc(); @@ -1890,7 +1869,7 @@ public class GraphicsContext3D extends Object { switch(stereoMode) { case STEREO_RIGHT: vpcToEc = cvCache.getRightVpcToEc(); - // TODO: move this under check for + // XXXX: move this under check for // (dirtyMask & BUFFER_MODE) above after testing // PureImmediate mode canvas3d.setProjectionMatrix(canvas3d.ctx, @@ -1901,7 +1880,7 @@ public class GraphicsContext3D extends Object { case STEREO_BOTH: default: vpcToEc = cvCache.getLeftVpcToEc(); - // TODO: move this under check for + // XXXX: move this under check for // (dirtyMask & BUFFER_MODE) above after testing // PureImmediate mode canvas3d.setProjectionMatrix(canvas3d.ctx, @@ -2000,7 +1979,7 @@ public class GraphicsContext3D extends Object { if ((geometry.retained instanceof IndexedGeometryArrayRetained) && ((((GeometryArrayRetained)geometry.retained).vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0)) { if (geoRetained.dirtyFlag != 0) { - geoRetained.mirrorGeometry = (GeometryRetained) + geoRetained.mirrorGeometry = ((IndexedGeometryArrayRetained)geoRetained).cloneNonIndexedGeometry(); // Change the source geometry dirtyFlag // drawGeo.execute() will change the @@ -2030,7 +2009,7 @@ public class GraphicsContext3D extends Object { drawGeo = (GeometryRetained)geometry.retained; } - if (!toSimulateMultiTex) { + if (!toSimulateMultiTex) { drawGeo.execute(canvas3d, null, isNonUniformScale, false, alpha, ((canvas3d.view.getScreens()).length > 1), @@ -2038,30 +2017,19 @@ public class GraphicsContext3D extends Object { ignoreVertexColors, -1); } else { - // TODO: need to leverage the code in textureBin + // NOTE: we really should leverage the code in textureBin boolean startToSimulate = false; - if (numActiveTexUnit < 1) { - // no active texture unit - drawGeo.execute(canvas3d, null, isNonUniformScale, - false, alpha, - ((canvas3d.view.getScreens()).length > 1), - canvas3d.screen.screen, - ignoreVertexColors, - 0); - } else if (numActiveTexUnit == 1) { - // one active texture unit - drawGeo.execute(canvas3d, null, isNonUniformScale, - false, alpha, - ((canvas3d.view.getScreens()).length > 1), - canvas3d.screen.screen, - ignoreVertexColors, - lastActiveTexUnitIndex); - } else { + // simulate multiple texture units - AppearanceRetained app = - (AppearanceRetained)appearance.retained; + AppearanceRetained app = + (AppearanceRetained)appearance.retained; + + assert VirtualUniverse.mc.allowSimulatedMultiTexture; + assert numActiveTexUnit > 1; + assert app.texUnitState != null; + assert app.texUnitState.length > 1; - // first turn off fog + // first turn off fog if (fog != null) canvas3d.setFogEnableFlag(canvas3d.ctx, false); @@ -2088,16 +2056,20 @@ public class GraphicsContext3D extends Object { // adjust the depth test back to what it was // and adjust the blend func to what it it was - if (startToSimulate) { - app.transparencyAttributes.updateNative( - canvas3d.ctx, alpha, geometryType, - polygonMode, lineAA, pointAA); - } + if (startToSimulate) { + if (app.transparencyAttributes != null) { + app.transparencyAttributes.updateNative( + canvas3d.ctx, alpha, geometryType, + polygonMode, lineAA, pointAA); + } else { + canvas3d.resetTransparency(canvas3d.ctx, geometryType, + polygonMode, lineAA, pointAA); + } + } if (fog != null) { canvas3d.setFogEnableFlag(canvas3d.ctx, true); } - } } if (geoRetained != null) geoRetained.geomLock.unLock(); @@ -2229,7 +2201,7 @@ public class GraphicsContext3D extends Object { throw new IllegalSharingException(J3dI18N.getString("GraphicsContext3D21")); } - // TODO: implement illegal argument exception + // XXXX: implement illegal argument exception /* if (ras.image.byReference && !(ras.image.imageReference instanceof BufferedImage)) { @@ -2419,7 +2391,7 @@ public class GraphicsContext3D extends Object { if (canvas3d.enableMask != enableMask) { canvas3d.canvasDirty |= Canvas3D.LIGHTENABLES_DIRTY; - // TODO: 32 => renderBin.maxLights + // XXXX: 32 => renderBin.maxLights canvas3d.setLightEnables(canvas3d.ctx, enableMask, 32); canvas3d.enableMask = enableMask; } @@ -2481,16 +2453,16 @@ public class GraphicsContext3D extends Object { boolean updateState(RenderBin rb, int geometryType) { - boolean useAlpha = false;; - toSimulateMultiTex = true; - numActiveTexUnit = 0; + boolean useAlpha = false; + toSimulateMultiTex = false; + numActiveTexUnit = 0; lastActiveTexUnitIndex = 0; // Update Appearance if (appearance != null) { AppearanceRetained app = (AppearanceRetained) appearance.retained; - // If the material is not null then check if the one in the canvas + // If the material is not null then check if the one in the canvas // is equivalent to the one being sent down. If Yes, do nothing // Otherwise, cache the sent down material and mark the canvas // dirty flag so that the compiled/compiled-retained rendering @@ -2514,75 +2486,95 @@ public class GraphicsContext3D extends Object { } } + // Set flag indicating whether we are using shaders + boolean useShaders = false; + if (app instanceof ShaderAppearanceRetained) { + if (((ShaderAppearanceRetained)app).shaderProgram != null) { + useShaders = true; + } + } + + // Set the number of available texture units; this depends on + // whether or not shaders are being used. + int availableTextureUnits = + useShaders ? canvas3d.maxTextureImageUnits : canvas3d.maxTextureUnits; + int prevNumActiveTexUnit = canvas3d.getNumActiveTexUnit(); + // Get the number of active texture units. + // Note that this total number now includes disabled units. if (app.texUnitState != null) { - boolean d3dBlendMode = false; - TextureUnitStateRetained tus; for (int i = 0; i < app.texUnitState.length; i++) { tus = app.texUnitState[i]; if (tus != null && tus.isTextureEnabled()) { - numActiveTexUnit++; lastActiveTexUnitIndex = i; - useAlpha = useAlpha || - (tus.texAttrs.textureMode == - TextureAttributes.BLEND); - if (tus.needBlend2Pass(canvas3d)) { - // use multi-pass if one of the stage use blend mode - d3dBlendMode = true; - } + numActiveTexUnit = i + 1; + if (tus.texAttrs != null) { + useAlpha = useAlpha || + (tus.texAttrs.textureMode == + TextureAttributes.BLEND); + } } } - if (canvas3d.numTexUnitSupported >= numActiveTexUnit && - canvas3d.multiTexAccelerated && !d3dBlendMode) { - - int j = 0; + if (numActiveTexUnit <= availableTextureUnits) { + // Normal, single-pass rendering case // update all active texture unit states - for (int i = 0; i < app.texUnitState.length; i++) { - if ((app.texUnitState[i] != null) && + if (i >= availableTextureUnits) { + // This can happen if there are disabled units at + // the end of the array + break; + } + + if ((app.texUnitState[i] != null) && app.texUnitState[i].isTextureEnabled()) { - app.texUnitState[i].updateNative(j, canvas3d, + app.texUnitState[i].updateNative(i, canvas3d, false, false); - canvas3d.setTexUnitStateMap(i, j++); - } + } else { + canvas3d.resetTexture(canvas3d.ctx, i); + } } // reset the remaining texture units - - for (int i = j; i < prevNumActiveTexUnit; i++) { - if (canvas3d.texUnitState[i].texture != null) { - canvas3d.resetTexture(canvas3d.ctx, i); - canvas3d.texUnitState[i].texture = null; - } + for (int i = app.texUnitState.length; i < prevNumActiveTexUnit; i++) { + canvas3d.resetTexture(canvas3d.ctx, i); } // set the number active texture unit in Canvas3D canvas3d.setNumActiveTexUnit(numActiveTexUnit); - // set the active texture unit back to 0 - canvas3d.activeTextureUnit(canvas3d.ctx, 0); - - toSimulateMultiTex = false; - - } else { + } else if (!useShaders && VirtualUniverse.mc.allowSimulatedMultiTexture) { + // Simulated (multi-pass) multi-texture rendering + + toSimulateMultiTex = true; // will fall back to the multi-pass case; // reset all the texture units first + for (int i = 0; i < prevNumActiveTexUnit; i++) { + canvas3d.resetTexture(canvas3d.ctx, i); + } + // set the number active texture unit in Canvas3D + canvas3d.setNumActiveTexUnit(1); + } + else { + // Exceeded limit, and not using simulated multi-texture + + // disable all the texture units for (int i = 0; i < prevNumActiveTexUnit; i++) { - if (canvas3d.texUnitState[i].texture != null) { - canvas3d.resetTexture(canvas3d.ctx, i); - canvas3d.texUnitState[i].texture = null; - } + canvas3d.resetTexture(canvas3d.ctx, i); } + canvas3d.setNumActiveTexUnit(0); } + + // set the active texture unit back to 0 + canvas3d.activeTextureUnit(canvas3d.ctx, 0); } else { - // if texUnitState is null, let's disable + // if texUnitState is null, let's disable // all texture units first if (canvas3d.multiTexAccelerated) { if (canvas3d.texUnitState != null) { @@ -2599,9 +2591,9 @@ public class GraphicsContext3D extends Object { canvas3d.activeTextureUnit(canvas3d.ctx, 0); } - if ((canvas3d.texUnitState != null) && - (canvas3d.texUnitState[0] != null) && - (canvas3d.texUnitState[0].texture != app.texture)) { + if ((canvas3d.texUnitState != null) && + (canvas3d.texUnitState[0] != null) && + (canvas3d.texUnitState[0].texture != app.texture)) { // If the image is by reference, check if the image // should be processed @@ -2616,7 +2608,6 @@ public class GraphicsContext3D extends Object { } } app.texture.updateNative(canvas3d); - canvas3d.setTexUnitStateMap(0, 0); canvas3d.canvasDirty |= Canvas3D.TEXTUREBIN_DIRTY|Canvas3D.TEXTUREATTRIBUTES_DIRTY; numActiveTexUnit = 1; lastActiveTexUnitIndex = 0; @@ -2728,7 +2719,7 @@ public class GraphicsContext3D extends Object { if (app.renderingAttributes != null) { ignoreVertexColors =app.renderingAttributes.ignoreVertexColors; - app.renderingAttributes.updateNative(canvas3d.ctx, + app.renderingAttributes.updateNative(canvas3d, canvas3d.depthBufferWriteEnableOverride, canvas3d.depthBufferEnableOverride); canvas3d.canvasDirty |= Canvas3D.ATTRIBUTEBIN_DIRTY|Canvas3D.TEXTUREATTRIBUTES_DIRTY; diff --git a/src/classes/share/javax/media/j3d/Group.java b/src/classes/share/javax/media/j3d/Group.java index c7a71f2..b5c763b 100644 --- a/src/classes/share/javax/media/j3d/Group.java +++ b/src/classes/share/javax/media/j3d/Group.java @@ -60,6 +60,13 @@ public class Group extends Node { ALLOW_COLLISION_BOUNDS_WRITE = CapabilityBits.GROUP_ALLOW_COLLISION_BOUNDS_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_CHILDREN_READ, + ALLOW_COLLISION_BOUNDS_READ + }; + + /** * Creates the retained mode GroupRetained object that this * Group component object will point to. @@ -528,5 +535,7 @@ public class Group extends Node { * </ul> */ public Group() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } } diff --git a/src/classes/share/javax/media/j3d/GroupRetained.java b/src/classes/share/javax/media/j3d/GroupRetained.java index b300758..da9155a 100644 --- a/src/classes/share/javax/media/j3d/GroupRetained.java +++ b/src/classes/share/javax/media/j3d/GroupRetained.java @@ -238,6 +238,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { if(oldchildr != null) { oldchildr.setParent(null); checkClearLive(oldchildr, messages, 0, index, null); + universe.notifyStructureChangeListeners(false, this.source, (BranchGroup)oldchildr.source); } removeChildrenData(index); @@ -249,6 +250,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { return; } + universe.notifyStructureChangeListeners(true, this.source, (BranchGroup)child); NodeRetained childr = (NodeRetained) child.retained; childr.setParent(this); children.set(index, childr); @@ -276,6 +278,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { if (this.source.isLive()) { universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { + universe.notifyStructureChangeListeners(true, this.source, (BranchGroup)child); doInsertChild(child, index); universe.setLiveState.clear(); } @@ -324,8 +327,10 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { if (this.source.isLive()) { universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { + NodeRetained childr = (NodeRetained)children.get(index); doRemoveChild(index, null, 0); universe.setLiveState.clear(); + universe.notifyStructureChangeListeners(false, this.source, (BranchGroup)childr.source); } universe.waitForMC(); } else { @@ -454,6 +459,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { if (this.source.isLive()) { universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { + universe.notifyStructureChangeListeners(true, this.source, (BranchGroup)child); doAddChild(child, null, 0); universe.setLiveState.clear(); } @@ -492,8 +498,13 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { if (this.source.isLive()) { universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { + GroupRetained oldParent = (GroupRetained)((BranchGroupRetained)bg.retained).parent; doMoveTo(bg); universe.setLiveState.clear(); + if (oldParent==null) + universe.notifyStructureChangeListeners(((BranchGroupRetained)bg.retained).locale, this.source, bg); + else + universe.notifyStructureChangeListeners(oldParent.source, this.source, bg); } universe.waitForMC(); } else { @@ -632,7 +643,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { } /* - // TODO: lights may remove twice or more during clearLive(), + // XXXX: lights may remove twice or more during clearLive(), // one from itself and one call from every LightRetained // reference this. So there is case that this procedure get // called when light already removed. @@ -1828,7 +1839,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { } s.transformTargets = newTargets; - // TODO - optimization for targetThreads computation, require + // XXXX: optimization for targetThreads computation, require // cleanup in GroupRetained.doSetLive() //s.transformTargetThreads = 0; } @@ -2441,14 +2452,23 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { return super.getEffectiveBounds(); } - // returns true if children cannot be read/written + // returns true if children cannot be read/written and none of the + // children can read their parent (i.e., "this") group node boolean isStaticChildren() { if (source.getCapability(Group.ALLOW_CHILDREN_READ) || source.getCapability(Group.ALLOW_CHILDREN_WRITE)) { return false; } + + for (int i = children.size() - 1; i >= 0; i--) { + SceneGraphObjectRetained nodeR = + (SceneGraphObjectRetained) children.get(i); + if (nodeR != null && nodeR.source.getCapability(Node.ALLOW_PARENT_READ)) { + return false; + } + } + return true; - } @@ -2644,7 +2664,7 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { } } // Has its own copy - // TODO: Handle the case of + // XXXX: Handle the case of // was non-zero, gone to zero? if (savedParentLights != null) { if (allocatedLights) { diff --git a/src/classes/share/javax/media/j3d/ImageComponent.java b/src/classes/share/javax/media/j3d/ImageComponent.java index 37f4530..4f927cf 100644 --- a/src/classes/share/javax/media/j3d/ImageComponent.java +++ b/src/classes/share/javax/media/j3d/ImageComponent.java @@ -195,10 +195,19 @@ public abstract class ImageComponent extends NodeComponent { public static final int ALLOW_IMAGE_WRITE = CapabilityBits.IMAGE_COMPONENT_ALLOW_IMAGE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SIZE_READ, + ALLOW_SIZE_READ, + ALLOW_FORMAT_READ + }; + /** * Not a public constructor, for internal use */ ImageComponent() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -220,6 +229,9 @@ public abstract class ImageComponent extends NodeComponent { * width or height are not positive. */ public ImageComponent(int format, int width, int height) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ImageComponentRetained)this.retained).processParams(format, width, height, 1); } @@ -249,6 +261,8 @@ public abstract class ImageComponent extends NodeComponent { int height, boolean byReference, boolean yUp) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); ((ImageComponentRetained)this.retained).setYUp(yUp); ((ImageComponentRetained)this.retained).setByReference(byReference); diff --git a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java index 809884d..6037355 100644 --- a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java +++ b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java @@ -171,7 +171,7 @@ class ImageComponent2DRetained extends ImageComponentRetained { ((biType == BufferedImage.TYPE_BYTE_GRAY) && (format == ImageComponent.FORMAT_CHANNEL8)) || (is4ByteRGBAOr3ByteRGB(ri))) { - /* ||TODO: Don't do short for now! + /* ||XXXX: Don't do short for now! ((biType == BufferedImage.TYPE_USHORT_GRAY) && (format == ImageComponent.FORMAT_CHANNEL8) */ @@ -1293,7 +1293,7 @@ class ImageComponent2DRetained extends ImageComponentRetained { if (source.isLive()) { - //TODO: check whether this is needed + //XXXX: check whether this is needed freeSurface(); // send a SUBIMAGE_CHANGED message in order to @@ -1336,7 +1336,7 @@ class ImageComponent2DRetained extends ImageComponentRetained { if (source.isLive()) { - // TODO: check whether this is needed + // XXXX: check whether this is needed freeSurface(); // send a SUBIMAGE_CHANGED message in order to diff --git a/src/classes/share/javax/media/j3d/ImageComponent3D.java b/src/classes/share/javax/media/j3d/ImageComponent3D.java index 1cb4d9b..224d1f5 100644 --- a/src/classes/share/javax/media/j3d/ImageComponent3D.java +++ b/src/classes/share/javax/media/j3d/ImageComponent3D.java @@ -622,7 +622,7 @@ public class ImageComponent3D extends ImageComponent { rt.height, rt.depth); - // TODO : replace by this to duplicate other attributes + // XXXX : replace by this to duplicate other attributes /* ImageComponent3D img = new ImageComponent3D(rt.format, rt.width, diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryArray.java b/src/classes/share/javax/media/j3d/IndexedGeometryArray.java index c1c4254..00a9aa8 100644 --- a/src/classes/share/javax/media/j3d/IndexedGeometryArray.java +++ b/src/classes/share/javax/media/j3d/IndexedGeometryArray.java @@ -17,7 +17,8 @@ import javax.vecmath.*; /** * The IndexedGeometryArray object contains separate integer arrays * that index into the arrays of positional coordinates, colors, - * normals, and texture coordinates. These index arrays specify how + * normals, texture coordinates, and vertex attributes. + * These index arrays specify how * vertices are connected to form geometry primitives. This class is * extended to create the various indexed primitive types (e.g., * lines, triangle strips, etc.). @@ -26,7 +27,10 @@ import javax.vecmath.*; public abstract class IndexedGeometryArray extends GeometryArray { // non-public, no parameter constructor - IndexedGeometryArray() {} + IndexedGeometryArray() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } /** * Specifies that this IndexedGeometryArray allows reading the array of @@ -85,6 +89,33 @@ public abstract class IndexedGeometryArray extends GeometryArray { ALLOW_TEXCOORD_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_TEXCOORD_INDEX_WRITE; /** + * Specifies that this IndexedGeometryArray allows reading the array of + * vertex attribute indices. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_VERTEX_ATTR_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_READ; + + /** + * Specifies that this IndexedGeometryArray allows writing the array of + * vertex attribute indices. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_VERTEX_ATTR_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_WRITE; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COLOR_INDEX_READ, + ALLOW_COORDINATE_INDEX_READ, + ALLOW_NORMAL_INDEX_READ, + ALLOW_TEXCOORD_INDEX_READ, + ALLOW_VERTEX_ATTR_INDEX_READ + }; + + /** * Constructs an empty IndexedGeometryArray object with the specified * number of vertices, vertex format, and number of indices. * Defaults are used for all other parameters. The default values @@ -96,28 +127,31 @@ public abstract class IndexedGeometryArray extends GeometryArray { * all index array values : 0<br> * </ul> * - * @param vertexCount the number of vertex elements in this - * IndexedGeometryArray - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or - * TEXTURE_COORDINATE_4, to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @param indexCount the number of indices in this object. This * count is the maximum number of vertices that will be rendered. + * + * @exception IllegalArgumentException if <code>indexCount < 0</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public IndexedGeometryArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount, vertexFormat); - ((IndexedGeometryArrayRetained)this.retained).createIndexedGeometryArrayData(indexCount); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((IndexedGeometryArrayRetained)this.retained).createIndexedGeometryArrayData(indexCount); } /** @@ -126,58 +160,30 @@ public abstract class IndexedGeometryArray extends GeometryArray { * sets, texture coordinate mapping array, and number of indices. * Defaults are used for all other parameters. * - * @param vertexCount the number of vertex elements in this - * IndexedGeometryArray<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D , 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @param indexCount the number of indices in this object. This * count is the maximum number of vertices that will be rendered. * + * @exception IllegalArgumentException if <code>indexCount < 0</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown + * * @since Java 3D 1.2 */ public IndexedGeometryArray(int vertexCount, @@ -185,7 +191,61 @@ public abstract class IndexedGeometryArray extends GeometryArray { int texCoordSetCount, int[] texCoordSetMap, int indexCount) { - super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap); + this(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, 0, null, indexCount); + } + + /** + * Constructs an empty IndexedGeometryArray object with the + * specified number of vertices, vertex format, number of texture + * coordinate sets, texture coordinate mapping array, vertex + * attribute count, vertex attribute sizes array, and number of + * indices. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount the number of indices in this object. This + * count is the maximum number of vertices that will be rendered. + * + * @exception IllegalArgumentException if <code>indexCount < 0</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedGeometryArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((IndexedGeometryArrayRetained)this.retained).createIndexedGeometryArrayData(indexCount); } @@ -384,6 +444,20 @@ public abstract class IndexedGeometryArray extends GeometryArray { * This method is not supported for indexed geometry arrays. * Indexed primitives use an array of indices to determine how * to access the vertex array. + * + * @exception UnsupportedOperationException this method is not supported + * + * @since Java 3D 1.4 + */ + public void setInitialVertexAttrIndex(int vertexAttrNum, + int initialVertexAttrIndex) { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported for indexed geometry arrays. + * Indexed primitives use an array of indices to determine how + * to access the vertex array. * The validIndexCount attribute can be used to set the number of * valid indexed vertices rendered. * @@ -468,6 +542,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * colorIndex is out of range if it is less than 0 or is * greater than or equal to the number of vertices actually * defined for the color array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void setColorIndex(int index, int colorIndex) { if (isLiveOrCompiled()) @@ -495,6 +572,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * is out of range. An element is out of range if it is less than 0 * or is greater than or equal to the number of vertices actually * defined for the color array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void setColorIndices(int index, int colorIndices[]) { if (isLiveOrCompiled()) @@ -522,6 +602,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * normalIndex is out of range if it is less than 0 or is * greater than or equal to the number of vertices actually * defined for the normal array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void setNormalIndex(int index, int normalIndex) { if (isLiveOrCompiled()) @@ -549,6 +632,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * is out of range. An element is out of range if it is less than 0 * or is greater than or equal to the number of vertices actually * defined for the normal array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void setNormalIndices(int index, int normalIndices[]) { if (isLiveOrCompiled()) @@ -590,13 +676,16 @@ public abstract class IndexedGeometryArray extends GeometryArray { * greater than or equal to the number of vertices actually * defined for the texture coordinate array. * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * * @since Java 3D 1.2 */ public void setTextureCoordinateIndex(int texCoordSet, int index, int texCoordIndex) { if (isLiveOrCompiled()) - if(!this.getCapability(ALLOW_COORDINATE_INDEX_WRITE)) + if(!this.getCapability(ALLOW_TEXCOORD_INDEX_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray7")); ((IndexedGeometryArrayRetained)this.retained).setTextureCoordinateIndex(texCoordSet, index, texCoordIndex); @@ -634,18 +723,99 @@ public abstract class IndexedGeometryArray extends GeometryArray { * or is greater than or equal to the number of vertices actually * defined for the texture coordinate array. * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * * @since Java 3D 1.2 */ public void setTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) { if (isLiveOrCompiled()) - if(!this.getCapability(ALLOW_COORDINATE_INDEX_WRITE)) + if(!this.getCapability(ALLOW_TEXCOORD_INDEX_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray7")); ((IndexedGeometryArrayRetained)this.retained).setTextureCoordinateIndices(texCoordSet, index, texCoordIndices); } + /** + * Sets the vertex attribute index associated with the vertex at + * the specified index for the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index the vertex index + * @param vertexAttrIndex the new vertex attribute index + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception ArrayIndexOutOfBoundsException if index is in the range + * <code>[initialIndexIndex, initialIndexIndex+validIndexCount-1]</code> + * and the specified vertexAttrIndex is out of range. The + * vertexAttrIndex is out of range if it is less than 0 or is + * greater than or equal to the number of vertices actually + * defined for the vertex attribute array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrIndex(int vertexAttrNum, + int index, + int vertexAttrIndex) { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_VERTEX_ATTR_INDEX_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray28")); + } + } + + ((IndexedGeometryArrayRetained)this.retained).setVertexAttrIndex(vertexAttrNum, index, vertexAttrIndex); + } + + /** + * Sets the vertex attribute indices associated with the vertices + * starting at the specified index for the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index the vertex index + * @param vertexAttrIndices an array of vertex attribute indices + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception ArrayIndexOutOfBoundsException if any element of the + * vertexAttrIndices array whose destination position is in the range + * <code>[initialIndexIndex, initialIndexIndex+validIndexCount-1]</code> + * is out of range. An element is out of range if it is less than 0 + * or is greater than or equal to the number of vertices actually + * defined for the vertex attribute array. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * + * @since Java 3D 1.4 + */ + public void setVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_VERTEX_ATTR_INDEX_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray28")); + } + } + + ((IndexedGeometryArrayRetained)this.retained).setVertexAttrIndices(vertexAttrNum, index, vertexAttrIndices); + } + /** * Retrieves the coordinate index associated with the vertex at * the specified index for this object. @@ -685,6 +855,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * @return the color index * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public int getColorIndex(int index) { if (isLiveOrCompiled()) @@ -703,6 +876,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * @param colorIndices array that will receive the color indices * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void getColorIndices(int index, int colorIndices[]) { if (isLiveOrCompiled()) @@ -719,6 +895,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * @return the normal index * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public int getNormalIndex(int index) { if (isLiveOrCompiled()) @@ -738,6 +917,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * @param normalIndices array that will receive the normal indices * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. */ public void getNormalIndices(int index, int normalIndices[]) { if (isLiveOrCompiled()) @@ -773,6 +955,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * <code>vertexFormat</code> or if the index or * texCoordSet is out of range. * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * * @since Java 3D 1.2 */ public int getTextureCoordinateIndex(int texCoordSet, int index) { @@ -812,6 +997,9 @@ public abstract class IndexedGeometryArray extends GeometryArray { * <code>vertexFormat</code> or if the index or * texCoordSet is out of range. * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * * @since Java 3D 1.2 */ public void getTextureCoordinateIndices(int texCoordSet, @@ -824,6 +1012,72 @@ public abstract class IndexedGeometryArray extends GeometryArray { ((IndexedGeometryArrayRetained)this.retained).getTextureCoordinateIndices(texCoordSet, index, texCoordIndices); } + /** + * Retrieves the vertex attribute index associated with the vertex at + * the specified index for the specified vertex attribute number + * for this object. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index the vertex index + * + * @return the vertex attribute index + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * + * @since Java 3D 1.4 + */ + public int getVertexAttrIndex(int vertexAttrNum, + int index) { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_VERTEX_ATTR_INDEX_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray29")); + } + } + + return ((IndexedGeometryArrayRetained)this.retained).getVertexAttrIndex(vertexAttrNum, index); + } + + /** + * Retrieves the vertex attribute indices associated with the vertices + * starting at the specified index for the specified vertex attribute number + * for this object. The vertex attribute indices + * are copied into the specified array. The array + * must be large enough to hold all of the indices. + * + * @param vertexAttrNum vertex attribute number in this geometry array + * @param index the vertex index + * @param vertexAttrIndices array that will receive the vertex attribute indices + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception ArrayIndexOutOfBoundsException if the index or + * vertexAttrNum is out of range. + * + * @exception NullPointerException if the <code>USE_COORD_INDEX_ONLY</code> + * bit is set in <code>vertexFormat</code>. + * + * @since Java 3D 1.4 + */ + public void getVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_VERTEX_ATTR_INDEX_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray29")); + } + } + + ((IndexedGeometryArrayRetained)this.retained).getVertexAttrIndices(vertexAttrNum, index, vertexAttrIndices); + } + /** * Copies all node information from <code>originalNodeComponent</code> into * the current node. This method is called from the @@ -854,30 +1108,39 @@ public abstract class IndexedGeometryArray extends GeometryArray { IndexedGeometryArrayRetained rt = (IndexedGeometryArrayRetained) retained; - int vformat = ga.getVertexFormat(); - int buffer[] = new int[ga.getIndexCount()]; - - if ((vformat & GeometryArray.COORDINATES) != 0) { - ga.getCoordinateIndices(0, buffer); - rt.setCoordinateIndices(0, buffer); - } - - if ((vformat & GeometryArray.NORMALS) != 0) { - ga.getNormalIndices(0, buffer); - rt.setNormalIndices(0, buffer); - } - - if ((vformat & GeometryArray.COLOR) != 0) { - ga.getColorIndices(0, buffer); - rt.setColorIndices(0, buffer); - } - - if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) { - for (int i = 0; i < ga.texCoordSetCount; i++) { - ga.getTextureCoordinateIndices(i, 0, buffer); - rt.setTextureCoordinateIndices(i, 0, buffer); - } - } + int vformat = ga.getVertexFormat(); + int buffer[] = new int[ga.getIndexCount()]; + + if ((vformat & COORDINATES) != 0) { + ga.getCoordinateIndices(0, buffer); + rt.setCoordinateIndices(0, buffer); + } + + if ((vformat & USE_COORD_INDEX_ONLY) == 0) { + if ((vformat & NORMALS) != 0) { + ga.getNormalIndices(0, buffer); + rt.setNormalIndices(0, buffer); + } + + if ((vformat & COLOR) != 0) { + ga.getColorIndices(0, buffer); + rt.setColorIndices(0, buffer); + } + + if ((vformat & VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < ga.vertexAttrCount; i++) { + ga.getVertexAttrIndices(i, 0, buffer); + rt.setVertexAttrIndices(i, 0, buffer); + } + } + + if ((vformat & TEXTURE_COORDINATE) != 0) { + for (int i = 0; i < ga.texCoordSetCount; i++) { + ga.getTextureCoordinateIndices(i, 0, buffer); + rt.setTextureCoordinateIndices(i, 0, buffer); + } + } + } } } diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java index 090de29..f6d443b 100644 --- a/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedGeometryArrayRetained.java @@ -30,11 +30,14 @@ import com.sun.j3d.internal.DoubleBufferWrapper; abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { - // arrays to save indices for coord, color, normal, texcoord - int indexCoord[], indexColor[], indexNormal[]; - Object indexTexCoord[]; + // arrays to save indices for coord, color, normal, texcoord, vertexAttr + int[] indexCoord; + int[] indexColor; + int[] indexNormal; + int[][] indexTexCoord; + int[][] indexVertexAttr; - int indexCount; + int indexCount = 0; int initialIndexIndex = 0; int validIndexCount = 0; @@ -47,65 +50,77 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { int maxColorIndex = 0; int maxNormalIndex = 0; int[] maxTexCoordIndices = null; - - void createIndexedGeometryArrayData(int indexCount) { - this.indexCount = indexCount; - this.validIndexCount = indexCount; + int[] maxVertexAttrIndices = null; + void createIndexedGeometryArrayData(int indexCount) { + this.indexCount = indexCount; + this.validIndexCount = indexCount; - boolean notUCIO = (this.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0; - - if((this.vertexFormat & GeometryArray.COORDINATES) != 0) - this.indexCoord = new int[indexCount]; - - if(((this.vertexFormat & GeometryArray.NORMALS) != 0) && notUCIO) - this.indexNormal = new int[indexCount]; - - if(((this.vertexFormat & GeometryArray.COLOR) != 0) && notUCIO) - this.indexColor = new int[indexCount]; - - if((this.vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - this.indexTexCoord = new Object[this.texCoordSetCount]; - if(notUCIO) { - for (int i = 0; i < this.texCoordSetCount; i++) { - this.indexTexCoord[i] = new int[indexCount]; + // Only allocate color, normal, texCoord, and vertexAttr + // index arrays if USE_COORD_INDEX_ONLY is not set + boolean notUCIO = (this.vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0; + + if((this.vertexFormat & GeometryArray.COORDINATES) != 0) + this.indexCoord = new int[indexCount]; + + if(((this.vertexFormat & GeometryArray.NORMALS) != 0) && notUCIO) + this.indexNormal = new int[indexCount]; + + if(((this.vertexFormat & GeometryArray.COLOR) != 0) && notUCIO) + this.indexColor = new int[indexCount]; + + if((this.vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { + this.indexTexCoord = new int[this.texCoordSetCount][]; + if(notUCIO) { + for (int i = 0; i < this.texCoordSetCount; i++) { + this.indexTexCoord[i] = new int[indexCount]; + } + } + maxTexCoordIndices = new int[texCoordSetCount]; + } + + if ((this.vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + this.indexVertexAttr = new int[this.vertexAttrCount][]; + if (notUCIO) { + for (int i = 0; i < this.vertexAttrCount; i++) { + this.indexVertexAttr[i] = new int[indexCount]; + } } + this.maxVertexAttrIndices = new int[this.vertexAttrCount]; } - maxTexCoordIndices = new int[texCoordSetCount]; } - } - - Object cloneNonIndexedGeometry() { - GeometryArrayRetained obj = null; - int vOffset; - - switch (this.geoType) { - case GEO_TYPE_INDEXED_LINE_SET: - obj = new LineArrayRetained(); - break; - case GEO_TYPE_INDEXED_POINT_SET: - obj = new PointArrayRetained(); - break; - case GEO_TYPE_INDEXED_QUAD_SET: - obj = new QuadArrayRetained(); - break; - case GEO_TYPE_INDEXED_TRI_SET: - obj = new TriangleArrayRetained(); - break; - } - obj.createGeometryArrayData(validIndexCount, (vertexFormat & ~(GeometryArray.BY_REFERENCE|GeometryArray.INTERLEAVED|GeometryArray.USE_NIO_BUFFER)), - texCoordSetCount, texCoordSetMap); - obj.cloneSourceArray = this; - obj.unIndexify(this); - - return (Object)obj; - } - void execute(long ctx, RenderAtom ra, boolean isNonUniformScale, - boolean updateAlpha, float alpha) { - throw new RuntimeException(J3dI18N.getString("IndexedGeometryArrayRetained0")); - } + GeometryArrayRetained cloneNonIndexedGeometry() { + GeometryArrayRetained obj = null; + int vOffset; + + switch (this.geoType) { + case GEO_TYPE_INDEXED_LINE_SET: + obj = new LineArrayRetained(); + break; + case GEO_TYPE_INDEXED_POINT_SET: + obj = new PointArrayRetained(); + break; + case GEO_TYPE_INDEXED_QUAD_SET: + obj = new QuadArrayRetained(); + break; + case GEO_TYPE_INDEXED_TRI_SET: + obj = new TriangleArrayRetained(); + break; + default: + assert false; // Should never get here + } + + obj.createGeometryArrayData(validIndexCount, + (vertexFormat & ~(GeometryArray.BY_REFERENCE|GeometryArray.INTERLEAVED|GeometryArray.USE_NIO_BUFFER)), + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + obj.cloneSourceArray = this; + obj.unIndexify(this); + + return obj; + } /** @@ -127,14 +142,19 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { doTexCoordCheck(newMax, i); } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + doVertexAttrCheck(newMax, i); + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { doNormalCheck(newMax); - } - } + } + } } - + void doCoordCheck(int newMax) { - // Check to make sure that the array length defined by the user is ateast maxCoordIndex long + // Check to make sure that the array length defined by the user is ateast maxCoordIndex long if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { if (newMax >= vertexCount) { throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray23")); @@ -404,6 +424,43 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { } + void doVertexAttrCheck(int newMax, int vertexAttrNum) { + + // Check to make sure that the array length defined by the user is ateast maxVertexAttrIndex long + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) == 0) { + return; + } + + // Vertex attributes must not be interleaved + assert (vertexFormat & GeometryArray.INTERLEAVED) == 0; + + if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { + if (newMax >= vertexCount) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30")); + } + } else { + int multiplier = vertexAttrSizes[vertexAttrNum]; + + if(( vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0) { + switch (vertexType & VATTR_DEFINED) { + case AF: + if(multiplier * newMax >= floatBufferRefVertexAttrs[vertexAttrNum].limit()) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30")); + } + break; + } + } else { + switch (vertexType & VATTR_DEFINED) { + case AF: + if (multiplier * newMax >= floatRefVertexAttrs[vertexAttrNum].length) { + throw new ArrayIndexOutOfBoundsException(J3dI18N.getString("IndexedGeometryArray30")); + } + break; + } + } + } + } + /** * Sets the coordinate index associated with the vertex at @@ -426,6 +483,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = newMax; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = newMax; + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { maxNormalIndex = newMax; } @@ -542,6 +604,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = newMax; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = newMax; + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { maxNormalIndex = newMax; } @@ -568,33 +635,21 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { final void setColorIndex(int index, int colorIndex) { int newMax = maxColorIndex; - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndexCheck(index, maxColorIndex, indexColor, colorIndex); - if (newMax > maxColorIndex) { - doColorCheck(newMax); - } - geomLock.getLock(); - // No need to set INDEX_CHANGED since IndexBuffer - // is used only when USE_COORD_INDEX_ONLY specified. - // In this case only coordinate index array is - // considered. - this.indexColor[index] = colorIndex; - maxColorIndex = newMax; - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - } - else { - if ((vertexFormat & GeometryArray.COLOR) != 0) { - if (this.indexColor == null) { - this.indexColor = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1")); - } - } - this.indexColor[index] = colorIndex; - } - + newMax = doIndexCheck(index, maxColorIndex, indexColor, colorIndex); + if (newMax > maxColorIndex) { + doColorCheck(newMax); + } + geomLock.getLock(); + // No need to set INDEX_CHANGED since IndexBuffer + // is used only when USE_COORD_INDEX_ONLY specified. + // In this case only coordinate index array is + // considered. + this.indexColor[index] = colorIndex; + maxColorIndex = newMax; + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } } /** @@ -606,34 +661,20 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { final void setColorIndices(int index, int colorIndices[]) { int i, j, num = colorIndices.length; int newMax; - - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndicesCheck(index, maxColorIndex, indexColor, colorIndices); - if (newMax > maxColorIndex) { - doColorCheck(newMax); - } - geomLock.getLock(); - maxColorIndex = newMax; - for (i=0, j = index; i < num;i++, j++) { - this.indexColor[j] = colorIndices[i]; - } - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - } - else { - if ((vertexFormat & GeometryArray.COLOR) != 0) { - if (this.indexColor == null) { - this.indexColor = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1")); - } - } - for (i=0, j = index; i < num;i++, j++) { - this.indexColor[j] = colorIndices[i]; - } - } + newMax = doIndicesCheck(index, maxColorIndex, indexColor, colorIndices); + if (newMax > maxColorIndex) { + doColorCheck(newMax); + } + geomLock.getLock(); + maxColorIndex = newMax; + for (i=0, j = index; i < num;i++, j++) { + this.indexColor[j] = colorIndices[i]; + } + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } } /** @@ -644,30 +685,18 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { */ final void setNormalIndex(int index, int normalIndex) { int newMax; - - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndexCheck(index, maxNormalIndex, indexNormal, normalIndex); - if (newMax > maxNormalIndex) { - doNormalCheck(newMax); - } - geomLock.getLock(); - maxNormalIndex = newMax; - this.indexNormal[index] = normalIndex; - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - } - else { - if ((vertexFormat & GeometryArray.NORMALS) != 0) { - if (this.indexNormal == null) { - this.indexNormal = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2")); - } - } - this.indexNormal[index] = normalIndex; - } + newMax = doIndexCheck(index, maxNormalIndex, indexNormal, normalIndex); + if (newMax > maxNormalIndex) { + doNormalCheck(newMax); + } + geomLock.getLock(); + maxNormalIndex = newMax; + this.indexNormal[index] = normalIndex; + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } } /** @@ -679,34 +708,20 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { final void setNormalIndices(int index, int normalIndices[]) { int i, j, num = normalIndices.length; int newMax; - - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndicesCheck(index, maxNormalIndex, indexNormal, normalIndices); - if (newMax > maxNormalIndex) { - doNormalCheck(newMax); - } - geomLock.getLock(); - for (i=0, j = index; i < num;i++, j++) { - this.indexNormal[j] = normalIndices[i]; - } - maxNormalIndex = newMax; - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - } - else { - if ((vertexFormat & GeometryArray.NORMALS) != 0) { - if (this.indexNormal == null) { - this.indexNormal = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2")); - } - } - for (i=0, j = index; i < num;i++, j++) { - this.indexNormal[j] = normalIndices[i]; - } - } + newMax = doIndicesCheck(index, maxNormalIndex, indexNormal, normalIndices); + if (newMax > maxNormalIndex) { + doNormalCheck(newMax); + } + geomLock.getLock(); + for (i=0, j = index; i < num;i++, j++) { + this.indexNormal[j] = normalIndices[i]; + } + maxNormalIndex = newMax; + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } } /** @@ -718,33 +733,19 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { */ final void setTextureCoordinateIndex(int texCoordSet, int index, int texCoordIndex) { int newMax; - int [] indices = (int[])this.indexTexCoord[texCoordSet]; - - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndexCheck(index, maxTexCoordIndices[texCoordSet],indices, texCoordIndex); - if (newMax > maxTexCoordIndices[texCoordSet]) { - doTexCoordCheck(newMax, texCoordSet); - } - geomLock.getLock(); - maxTexCoordIndices[texCoordSet] = newMax; - indices[index] = texCoordIndex; - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - } - else { - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - if (indices == null) { - indices = new int[indexCount]; - this.indexTexCoord[texCoordSet] = indices; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3")); - } - } - indices[index] = texCoordIndex; - } - + int [] indices = this.indexTexCoord[texCoordSet]; + newMax = doIndexCheck(index, maxTexCoordIndices[texCoordSet],indices, texCoordIndex); + if (newMax > maxTexCoordIndices[texCoordSet]) { + doTexCoordCheck(newMax, texCoordSet); + } + geomLock.getLock(); + maxTexCoordIndices[texCoordSet] = newMax; + indices[index] = texCoordIndex; + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } } /** @@ -754,42 +755,80 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @param index the vertex index * @param texCoordIndices an array of texture coordinate indices */ - final void setTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) { - int i, j, num = texCoordIndices.length; - int [] indices = (int[])this.indexTexCoord[texCoordSet]; + final void setTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) { + int i, j, num = texCoordIndices.length; + int [] indices = this.indexTexCoord[texCoordSet]; - int newMax; - - if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { - newMax = doIndicesCheck(index, maxTexCoordIndices[texCoordSet], indices, texCoordIndices); - if (newMax > maxTexCoordIndices[texCoordSet]) { - doTexCoordCheck(newMax, texCoordSet); - } - geomLock.getLock(); - maxTexCoordIndices[texCoordSet] = newMax; - for (i=0, j = index; i < num;i++, j++) { - indices[j] = texCoordIndices[i]; - } - geomLock.unLock(); - if (!inUpdater && source != null && source.isLive()) { - sendDataChangedMessage(false); - } - - } - else { - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - if (indices == null) { - indices = new int[indexCount]; - this.indexTexCoord[texCoordSet] = indices; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3")); - } - } - for (i=0, j = index; i < num;i++, j++) { - indices[j] = texCoordIndices[i]; - } - } + int newMax; - } + newMax = doIndicesCheck(index, maxTexCoordIndices[texCoordSet], indices, texCoordIndices); + if (newMax > maxTexCoordIndices[texCoordSet]) { + doTexCoordCheck(newMax, texCoordSet); + } + geomLock.getLock(); + maxTexCoordIndices[texCoordSet] = newMax; + for (i=0, j = index; i < num;i++, j++) { + indices[j] = texCoordIndices[i]; + } + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } + } + + /** + * Sets the vertex attribute index associated with the vertex at + * the specified index for the specified vertex attribute number + * for this object. + */ + public void setVertexAttrIndex(int vertexAttrNum, + int index, + int vertexAttrIndex) { + + int newMax; + int [] indices = this.indexVertexAttr[vertexAttrNum]; + + newMax = doIndexCheck(index, maxVertexAttrIndices[vertexAttrNum],indices, vertexAttrIndex); + if (newMax > maxVertexAttrIndices[vertexAttrNum]) { + doVertexAttrCheck(newMax, vertexAttrNum); + } + geomLock.getLock(); + maxVertexAttrIndices[vertexAttrNum] = newMax; + indices[index] = vertexAttrIndex; + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } + } + + /** + * Sets the vertex attribute indices associated with the vertices + * starting at the specified index for the specified vertex attribute number + * for this object. + */ + public void setVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) { + + int i, j, num = vertexAttrIndices.length; + int [] indices = this.indexVertexAttr[vertexAttrNum]; + + int newMax; + + newMax = doIndicesCheck(index, maxVertexAttrIndices[vertexAttrNum], indices, vertexAttrIndices); + if (newMax > maxVertexAttrIndices[vertexAttrNum]) { + doVertexAttrCheck(newMax, vertexAttrNum); + } + geomLock.getLock(); + maxVertexAttrIndices[vertexAttrNum] = newMax; + for (i=0, j = index; i < num;i++, j++) { + indices[j] = vertexAttrIndices[i]; + } + geomLock.unLock(); + if (!inUpdater && source != null && source.isLive()) { + sendDataChangedMessage(false); + } + } /** * Retrieves the coordinate index associated with the vertex at @@ -807,14 +846,13 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @param index the vertex index * @param coordinateIndices array that will receive the coordinate indices */ - final void getCoordinateIndices(int index, int coordinateIndices[]) { - int i, j, num = coordinateIndices.length; + final void getCoordinateIndices(int index, int coordinateIndices[]) { + int i, j, num = coordinateIndices.length; - for (i=0, j = index;i < num;i++, j++) - { - coordinateIndices[i] = this.indexCoord[j]; - } - } + for (i=0, j = index;i < num;i++, j++) { + coordinateIndices[i] = this.indexCoord[j]; + } + } /** * Retrieves the color index associated with the vertex at @@ -823,13 +861,6 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @return the color index */ final int getColorIndex(int index) { - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.COLOR) != 0)) { - if (this.indexColor == null) { - this.indexColor = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1")); - } - } return this.indexColor[index]; } @@ -839,22 +870,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @param index the vertex index * @param colorIndices array that will receive the color indices */ - final void getColorIndices(int index, int colorIndices[]) { - int i, j, num = colorIndices.length; - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.COLOR) != 0)) { - if (this.indexColor == null) { - this.indexColor = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained1")); + final void getColorIndices(int index, int colorIndices[]) { + int i, j, num = colorIndices.length; + + for (i=0, j = index;i < num;i++, j++) { + colorIndices[i] = this.indexColor[j]; } } - for (i=0, j = index;i < num;i++, j++) - { - colorIndices[i] = this.indexColor[j]; - } - } - /** * Retrieves the normal index associated with the vertex at * the specified index for this object. @@ -862,13 +885,6 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @return the normal index */ final int getNormalIndex(int index) { - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.NORMALS) != 0)) { - if (this.indexNormal == null) { - this.indexNormal = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2")); - } - } return this.indexNormal[index]; } @@ -878,22 +894,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @param index the vertex index * @param normalIndices array that will receive the normal indices */ - final void getNormalIndices(int index, int normalIndices[]) { - int i, j, num = normalIndices.length; - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.NORMALS) != 0)) { - if (this.indexNormal == null) { - this.indexNormal = new int[indexCount]; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained2")); + final void getNormalIndices(int index, int normalIndices[]) { + int i, j, num = normalIndices.length; + + for (i=0, j = index;i < num;i++, j++) { + normalIndices[i] = this.indexNormal[j]; } } - for (i=0, j = index;i < num;i++, j++) - { - normalIndices[i] = this.indexNormal[j]; - } - } - /** * Retrieves the texture coordinate index associated with the vertex at * the specified index for this object. @@ -902,16 +910,9 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @return the texture coordinate index */ final int getTextureCoordinateIndex(int texCoordSet, int index) { - int [] indices = (int[])this.indexTexCoord[texCoordSet]; - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)) { - if (indices == null) { - indices = new int[indexCount]; - this.indexTexCoord[texCoordSet] = indices; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3")); - } - } - return indices[index]; + int [] indices = this.indexTexCoord[texCoordSet]; + + return indices[index]; } /** @@ -921,120 +922,147 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { * @param index the vertex index * @param texCoordIndices array that will receive the texture coordinate indices */ - final void getTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) { - int i, j, num = texCoordIndices.length; - int [] indices = (int[])this.indexTexCoord[texCoordSet]; - if (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) && - ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)) { - if (indices == null) { - indices = new int[indexCount]; - this.indexTexCoord[texCoordSet] = indices; - System.err.println(J3dI18N.getString("IndexedGeometryArrayRetained3")); + final void getTextureCoordinateIndices(int texCoordSet, int index, int texCoordIndices[]) { + int i, j, num = texCoordIndices.length; + int [] indices = this.indexTexCoord[texCoordSet]; + + for (i=0, j = index;i < num;i++, j++) { + texCoordIndices[i] = indices[j]; } } - for (i=0, j = index;i < num;i++, j++) - { - texCoordIndices[i] = indices[j]; - } - } + /** + * Retrieves the vertex attribute index associated with the vertex at + * the specified index for the specified vertex attribute number + * for this object. + */ + public int getVertexAttrIndex(int vertexAttrNum, + int index) { + + int [] indices = this.indexVertexAttr[vertexAttrNum]; - // used for GeometryArrays - native void executeIndexedGeometry(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean useAlpha, - boolean multiScreen, - boolean ignoreVertexColors, - int initialIndexIndex, - int indexCount, - int vertexCount, int vformat, - int texCoordSetCount, int texCoordSetMap[], - int texCoordSetMapLen, - int[] texCoordSetOffset, - int numActiveTexUnitState, - int[] texUnitStateMap, - float[] varray, float[] cdata, - int texUnitIndex, int cdirty, - int[] indexCoord); - - // used for interleaved, by reference, nio buffer - native void executeIndexedGeometryBuffer(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean useAlpha, - boolean multiScreen, - boolean ignoreVertexColors, - int initialIndexIndex, - int indexCount, - int vertexCount, int vformat, - int texCoordSetCount, int texCoordSetMap[], - int texCoordSetMapLen, - int[] texCoordSetOffset, - int numActiveTexUnitState, - int[] texUnitStateMap, - Object varray, float[] cdata, - int texUnitIndex, int cdirty, - int[] indexCoord); + return indices[index]; + } + /** + * Retrieves the vertex attribute indices associated with the vertices + * starting at the specified index for the specified vertex attribute number + * for this object. + */ + public void getVertexAttrIndices(int vertexAttrNum, + int index, + int[] vertexAttrIndices) { - - native void executeIndexedGeometryVA(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean multiScreen, - boolean ignoreVertexColors, - int initialIndexIndex, - int validIndexCount, - int vertexCount, - int vformat, - int vdefined, - float[] vfcoords, double[] vdcoords, - float[] cfdata, byte[] cbdata, - float[] ndata, - int pass, int texcoordmaplength, - int[] texcoordoffset, - int numActiveTexUnitState, int[] texunitstatemap, - int texstride, Object[] texCoords, - int cdirty, - int[] indexCoord); + int i, j, num = vertexAttrIndices.length; + int [] indices = this.indexVertexAttr[vertexAttrNum]; + + for (i=0, j = index;i < num;i++, j++) { + vertexAttrIndices[i] = indices[j]; + } + } + + // by-copy or interleaved, by reference, Java arrays + private native void executeIndexedGeometry(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean useAlpha, + boolean multiScreen, + boolean ignoreVertexColors, + int initialIndexIndex, + int indexCount, + int vertexCount, int vformat, + int vertexAttrCount, int[] vertexAttrSizes, + int texCoordSetCount, int texCoordSetMap[], + int texCoordSetMapLen, + int[] texCoordSetOffset, + int numActiveTexUnitState, + int[] texUnitStateMap, + float[] varray, float[] cdata, + int texUnitIndex, int cdirty, + int[] indexCoord); + + // interleaved, by reference, nio buffer + private native void executeIndexedGeometryBuffer(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean useAlpha, + boolean multiScreen, + boolean ignoreVertexColors, + int initialIndexIndex, + int indexCount, + int vertexCount, int vformat, + int texCoordSetCount, int texCoordSetMap[], + int texCoordSetMapLen, + int[] texCoordSetOffset, + int numActiveTexUnitState, + int[] texUnitStateMap, + Object varray, float[] cdata, + int texUnitIndex, int cdirty, + int[] indexCoord); + + // non interleaved, by reference, Java arrays + private native void executeIndexedGeometryVA(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean multiScreen, + boolean ignoreVertexColors, + int initialIndexIndex, + int validIndexCount, + int vertexCount, + int vformat, + int vdefined, + float[] vfcoords, double[] vdcoords, + float[] cfdata, byte[] cbdata, + float[] ndata, + int vertexAttrCount, int[] vertexAttrSizes, + float[][] vertexAttrData, + int pass, int texcoordmaplength, + int[] texcoordoffset, + int numActiveTexUnitState, int[] texunitstatemap, + int texstride, Object[] texCoords, + int cdirty, + int[] indexCoord); // non interleaved, by reference, nio buffer - native void executeIndexedGeometryVABuffer(long ctx, - GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, - boolean multiScreen, - boolean ignoreVertexColors, - int initialIndexIndex, - int validIndexCount, - int vertexCount, - int vformat, - int vdefined, - Object vcoords, - Object cdataBuffer, - float[] cfdata, byte[] cbdata, - Object normal, - int pass, int texcoordmaplength, - int[] texcoordoffset, - int numActiveTexUnitState, int[] texunitstatemap, - int texstride, Object[] texCoords, - int cdirty, - int[] indexCoord); - - // used for IndexedGeometry - native void buildIndexedGeometry(long ctx, GeometryArrayRetained geo, int geo_type, - boolean isNonUniformScale, boolean updateAlpha, - float alpha, - boolean ignoreVertexColors, - int initialIndexIndex, - int validIndexCount, - int vertexCount, - int vformat, - int texCoordSetCount, int texCoordSetMap[], - int texCoordSetMapLen, - int[] texCoordSetMapOffset, - double[] xform, double[] nxform, - float[] varray, int[] indexCoord); + private native void executeIndexedGeometryVABuffer(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, + boolean multiScreen, + boolean ignoreVertexColors, + int initialIndexIndex, + int validIndexCount, + int vertexCount, + int vformat, + int vdefined, + Object vcoords, + Object cdataBuffer, + float[] cfdata, byte[] cbdata, + Object normal, + int vertexAttrCount, int[] vertexAttrSizes, + Object[] vertexAttrData, + int pass, int texcoordmaplength, + int[] texcoordoffset, + int numActiveTexUnitState, int[] texunitstatemap, + int texstride, Object[] texCoords, + int cdirty, + int[] indexCoord); + + // by-copy geometry + private native void buildIndexedGeometry(long ctx, + GeometryArrayRetained geo, int geo_type, + boolean isNonUniformScale, boolean updateAlpha, + float alpha, + boolean ignoreVertexColors, + int initialIndexIndex, + int validIndexCount, + int vertexCount, + int vformat, + int vertexAttrCount, int[] vertexAttrSizes, + int texCoordSetCount, int texCoordSetMap[], + int texCoordSetMapLen, + int[] texCoordSetMapOffset, + double[] xform, double[] nxform, + float[] varray, int[] indexCoord); void execute(Canvas3D cv, RenderAtom ra, boolean isNonUniformScale, @@ -1081,23 +1109,24 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { // RenderBin render the geometry. So it is safe // just to set the dirty flag here dirtyFlag = 0; - } - - executeIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, - useAlpha, - multiScreen, - ignoreVertexColors, - initialIndexIndex, - validIndexCount, - // Vertex Count is maxCoordIndex + 1 - maxCoordIndex + 1, - ((vertexFormat & GeometryArray.COLOR) != 0)?(vertexFormat|GeometryArray.COLOR_4):vertexFormat, - texCoordSetCount, texCoordSetMap, - (texCoordSetMap == null) ? 0 : texCoordSetMap.length, - texCoordSetMapOffset, - cv.numActiveTexUnit, cv.texUnitStateMap, - vdata, null, - pass, cdirty, indexCoord); + } + + executeIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, + useAlpha, + multiScreen, + ignoreVertexColors, + initialIndexIndex, + validIndexCount, + // Vertex Count is maxCoordIndex + 1 + maxCoordIndex + 1, + ((vertexFormat & GeometryArray.COLOR) != 0)?(vertexFormat|GeometryArray.COLOR_4):vertexFormat, + vertexAttrCount, vertexAttrSizes, + texCoordSetCount, texCoordSetMap, + (texCoordSetMap == null) ? 0 : texCoordSetMap.length, + texCoordSetMapOffset, + cv.numActiveTexUnit, cv.texUnitStateMap, + vdata, null, + pass, cdirty, indexCoord); } // end of non by reference @@ -1127,31 +1156,34 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { } dirtyFlag = 0; } - - executeIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, - useAlpha, - multiScreen, - ignoreVertexColors, - initialIndexIndex, - validIndexCount, - maxCoordIndex + 1, - vertexFormat, - texCoordSetCount, texCoordSetMap, - (texCoordSetMap == null) ? 0 : texCoordSetMap.length, - texCoordSetMapOffset, - cv.numActiveTexUnit, cv.texUnitStateMap, - interLeavedVertexData, cdata, - pass, cdirty, indexCoord); + + executeIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, + useAlpha, + multiScreen, + ignoreVertexColors, + initialIndexIndex, + validIndexCount, + maxCoordIndex + 1, + vertexFormat, + vertexAttrCount, vertexAttrSizes, + texCoordSetCount, texCoordSetMap, + (texCoordSetMap == null) ? 0 : texCoordSetMap.length, + texCoordSetMapOffset, + cv.numActiveTexUnit, cv.texUnitStateMap, + interLeavedVertexData, cdata, + pass, cdirty, indexCoord); } //end of interleaved - else { - // Check if a vertexformat is set, but the array is null + else { + // Check if a vertexformat is set, but the array is null // if yes, don't draw anything if ((vertexType == 0) || ((vertexType & VERTEX_DEFINED) == 0) || (((vertexFormat & GeometryArray.COLOR) != 0) && (vertexType & COLOR_DEFINED) == 0) || (((vertexFormat & GeometryArray.NORMALS) != 0) && - (vertexType & NORMAL_DEFINED) == 0) || + (vertexType & NORMAL_DEFINED) == 0) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + (vertexType & VATTR_DEFINED) == 0) || (((vertexFormat& GeometryArray.TEXTURE_COORDINATE) != 0) && (vertexType & TEXCOORD_DEFINED) == 0)) { return; @@ -1215,29 +1247,32 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { vdefined |= COLOR_BYTE; if((vertexType & NORMAL_DEFINED) != 0) vdefined |= NORMAL_FLOAT; - if((vertexType & TEXCOORD_DEFINED) != 0) - vdefined |= TEXCOORD_FLOAT; - - executeIndexedGeometryVA(cv.ctx, this, geoType, isNonUniformScale, - multiScreen, - ignoreVertexColors, - initialIndexIndex, - validIndexCount, - maxCoordIndex + 1, - (vertexFormat | c4fAllocated), - vdefined, - mirrorFloatRefCoords, mirrorDoubleRefCoords, - cfdata, cbdata, - mirrorFloatRefNormals, - pass, - ((texCoordSetMap == null) ? 0:texCoordSetMap.length), - texCoordSetMap, - cv.numActiveTexUnit, - cv.texUnitStateMap, - texCoordStride, - mirrorRefTexCoords, cdirty, indexCoord); - - } + if((vertexType & VATTR_DEFINED) != 0) + vdefined |= VATTR_FLOAT; + if((vertexType & TEXCOORD_DEFINED) != 0) + vdefined |= TEXCOORD_FLOAT; + + executeIndexedGeometryVA(cv.ctx, this, geoType, isNonUniformScale, + multiScreen, + ignoreVertexColors, + initialIndexIndex, + validIndexCount, + maxCoordIndex + 1, + (vertexFormat | c4fAllocated), + vdefined, + mirrorFloatRefCoords, mirrorDoubleRefCoords, + cfdata, cbdata, + mirrorFloatRefNormals, + vertexAttrCount, vertexAttrSizes, + mirrorFloatRefVertexAttrs, + pass, + ((texCoordSetMap == null) ? 0:texCoordSetMap.length), + texCoordSetMap, + cv.numActiveTexUnit, + cv.texUnitStateMap, + texCoordStride, + mirrorRefTexCoords, cdirty, indexCoord); + } } // end of non interleaved and by reference }//end of non io buffer @@ -1284,15 +1319,17 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { interleavedFloatBufferImpl.getBufferAsObject(), cdata, pass, cdirty, indexCoord); } //end of interleaved - else { - // Check if a vertexformat is set, but the array is null + else { + // Check if a vertexformat is set, but the array is null // if yes, don't draw anything if ((vertexType == 0) || ((vertexType & VERTEX_DEFINED) == 0) || (((vertexFormat & GeometryArray.COLOR) != 0) && (vertexType & COLOR_DEFINED) == 0) || (((vertexFormat & GeometryArray.NORMALS) != 0) && - (vertexType & NORMAL_DEFINED) == 0) || + (vertexType & NORMAL_DEFINED) == 0) || + (((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) && + (vertexType & VATTR_DEFINED) == 0) || (((vertexFormat& GeometryArray.TEXTURE_COORDINATE) != 0) && (vertexType & TEXCOORD_DEFINED) == 0)) { return; @@ -1311,7 +1348,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { cdirty |= COLOR_CHANGED; } } else { - // TODO: handle transparency case + // XXXX: handle transparency case //cfdata = null; cfdata = mirrorFloatRefColors[0]; // if transparency switch between on/off @@ -1334,7 +1371,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { cdirty |= COLOR_CHANGED; } } else { - // TODO: handle transparency case + // XXXX: handle transparency case // cbdata = null; cbdata = mirrorUnsignedByteRefColors[0]; // if transparency switch between on/off @@ -1371,29 +1408,37 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { vdefined |= NORMAL_FLOAT; normal = floatBufferRefNormals.getBufferAsObject(); } - - if((vertexType & TEXCOORD_DEFINED) != 0) - vdefined |= TEXCOORD_FLOAT; - - executeIndexedGeometryVABuffer(cv.ctx, this, geoType, isNonUniformScale, - multiScreen, - ignoreVertexColors, - initialIndexIndex, - validIndexCount, - maxCoordIndex + 1, - (vertexFormat | c4fAllocated), - vdefined, - vcoord, - cdataBuffer, - cfdata, cbdata, - normal, - pass, - ((texCoordSetMap == null) ? 0:texCoordSetMap.length), - texCoordSetMap, - cv.numActiveTexUnit, - cv.texUnitStateMap, - texCoordStride, - refTexCoords, cdirty, indexCoord); + + if ((vertexType & VATTR_DEFINED) != 0) { + vdefined |= VATTR_FLOAT; + } + + if ((vertexType & TEXCOORD_DEFINED) != 0) { + vdefined |= TEXCOORD_FLOAT; + } + + executeIndexedGeometryVABuffer(cv.ctx, + this, geoType, isNonUniformScale, + multiScreen, + ignoreVertexColors, + initialIndexIndex, + validIndexCount, + maxCoordIndex + 1, + (vertexFormat | c4fAllocated), + vdefined, + vcoord, + cdataBuffer, + cfdata, cbdata, + normal, + vertexAttrCount, vertexAttrSizes, + nioFloatBufferRefVertexAttrs, + pass, + ((texCoordSetMap == null) ? 0:texCoordSetMap.length), + texCoordSetMap, + cv.numActiveTexUnit, + cv.texUnitStateMap, + texCoordStride, + refTexCoords, cdirty, indexCoord); } } // end of non interleaved and by reference @@ -1413,7 +1458,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { else { if ((vertexFormat & GeometryArray.BY_REFERENCE) == 0) { - float[] vdata; + float[] vdata; // System.out.println("by-copy"); synchronized (this) { cdirty = dirtyFlag; @@ -1443,19 +1488,26 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { dirtyFlag = 0; } - buildIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, - updateAlpha, alpha, ignoreVertexColors, - initialIndexIndex, - validIndexCount, - maxCoordIndex + 1, - vertexFormat, - texCoordSetCount, texCoordSetMap, - (texCoordSetMap == null) ? 0 : texCoordSetMap.length, - texCoordSetMapOffset, - (xform == null) ? null : xform.mat, - (nxform == null) ? null : nxform.mat, - vdata, indexCoord); + buildIndexedGeometry(cv.ctx, this, geoType, isNonUniformScale, + updateAlpha, alpha, ignoreVertexColors, + initialIndexIndex, + validIndexCount, + maxCoordIndex + 1, + vertexFormat, + vertexAttrCount, vertexAttrSizes, + texCoordSetCount, texCoordSetMap, + (texCoordSetMap == null) ? 0 : texCoordSetMap.length, + texCoordSetMapOffset, + (xform == null) ? null : xform.mat, + (nxform == null) ? null : nxform.mat, + vdata, indexCoord); } + // XXXX: Note that there is no "else" clause here, and no + // buildIndexedGeometryForByRef() method. + // We would need to create one if we ever wanted to support by-ref + // indexed geometry in display lists. Better yet, we could fix + // canBeInDisplayList so that unindexified by-ref geometry could + // go into a display list. } } @@ -1478,11 +1530,12 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { indexColor = new int[indexCount]; if ((vertexFormat & GeometryArray.NORMALS) != 0) indexNormal = new int[indexCount]; - // We only merge if texCoordSetCount = 1 + // We only merge if the texCoordSetCount is 1 and there are no + // vertex attrs if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { - indexTexCoord = new Object[1]; + indexTexCoord = new int[1][]; indexTexCoord[0] = new int[indexCount]; - texCoord = (int[])indexTexCoord[0]; + texCoord = indexTexCoord[0]; } } int curDataOffset = 0; @@ -1500,7 +1553,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { if ((vertexFormat & GeometryArray.NORMALS) != 0) indexNormal[j+curIndexOffset] = geo.indexNormal[j+geo.initialIndexIndex]+curDataOffset; if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0) - texCoord[j+curIndexOffset] = ((int[])geo.indexTexCoord[0])[j+geo.initialIndexIndex]+curDataOffset; + texCoord[j+curIndexOffset] = geo.indexTexCoord[0][j+geo.initialIndexIndex]+curDataOffset; } } maxCoordIndex = geo.maxCoordIndex +curDataOffset; @@ -1517,12 +1570,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { boolean isWriteStatic() { - if (!super.isWriteStatic() || - source.getCapability(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_WRITE ) || - source.getCapability(IndexedGeometryArray.ALLOW_COLOR_INDEX_WRITE) || - source.getCapability(IndexedGeometryArray.ALLOW_NORMAL_INDEX_WRITE) || - source.getCapability(IndexedGeometryArray.ALLOW_TEXCOORD_INDEX_WRITE)) - return false; + if (!super.isWriteStatic() || + source.getCapability(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_WRITE ) || + source.getCapability(IndexedGeometryArray.ALLOW_COLOR_INDEX_WRITE) || + source.getCapability(IndexedGeometryArray.ALLOW_NORMAL_INDEX_WRITE) || + source.getCapability(IndexedGeometryArray.ALLOW_VERTEX_ATTR_INDEX_WRITE) || + source.getCapability(IndexedGeometryArray.ALLOW_TEXCOORD_INDEX_WRITE)) { + return false; + } return true; } @@ -1556,8 +1611,9 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { int newCoordMax =0; int newColorIndex=0; int newNormalIndex=0; - int newTexCoordIndex[]=null; - + int[] newTexCoordIndex = null; + int[] newVertexAttrIndex = null; + newCoordMax = computeMaxIndex(initialIndexIndex, validIndexCount,indexCoord ); doErrorCheck(newCoordMax); if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { @@ -1569,10 +1625,19 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { newTexCoordIndex = new int[texCoordSetCount]; for (int i = 0; i < texCoordSetCount; i++) { newTexCoordIndex[i] = computeMaxIndex(initialIndexIndex,validIndexCount, - (int[])indexTexCoord[i]); + indexTexCoord[i]); doTexCoordCheck(newTexCoordIndex[i], i); } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + newVertexAttrIndex = new int[vertexAttrCount]; + for (int i = 0; i < vertexAttrCount; i++) { + newVertexAttrIndex[i] = computeMaxIndex(initialIndexIndex, + validIndexCount, + indexVertexAttr[i]); + doVertexAttrCheck(newVertexAttrIndex[i], i); + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { newNormalIndex = computeMaxIndex(initialIndexIndex, validIndexCount, indexNormal); doNormalCheck(newNormalIndex); @@ -1589,6 +1654,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = newTexCoordIndex[i]; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = newVertexAttrIndex[i]; + } + } maxNormalIndex = newNormalIndex; } else { @@ -1599,6 +1669,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = maxCoordIndex; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = maxCoordIndex; + } + } } geomLock.unLock(); // bbox is computed for the entries list. @@ -1616,8 +1691,9 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { int newCoordMax =0; int newColorIndex=0; int newNormalIndex=0; - int newTexCoordIndex[]=null; - + int[] newTexCoordIndex = null; + int[] newVertexAttrIndex = null; + newCoordMax = computeMaxIndex(initialIndexIndex, validIndexCount, indexCoord); doErrorCheck(newCoordMax); if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) { @@ -1629,10 +1705,19 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { newTexCoordIndex = new int[texCoordSetCount]; for (int i = 0; i < texCoordSetCount; i++) { newTexCoordIndex[i] = computeMaxIndex(initialIndexIndex,validIndexCount, - (int[])indexTexCoord[i]); + indexTexCoord[i]); doTexCoordCheck(newTexCoordIndex[i], i); } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + newVertexAttrIndex = new int[vertexAttrCount]; + for (int i = 0; i < vertexAttrCount; i++) { + newVertexAttrIndex[i] = computeMaxIndex(initialIndexIndex, + validIndexCount, + indexVertexAttr[i]); + doVertexAttrCheck(newVertexAttrIndex[i], i); + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { newNormalIndex = computeMaxIndex(initialIndexIndex, validIndexCount, indexNormal); doNormalCheck(newNormalIndex); @@ -1650,6 +1735,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = newTexCoordIndex[i]; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = newVertexAttrIndex[i]; + } + } maxNormalIndex = newNormalIndex; } else { @@ -1660,6 +1750,11 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { maxTexCoordIndices[i] = maxCoordIndex; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (int i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = maxCoordIndex; + } + } } geomLock.unLock(); // bbox is computed for the entries list. @@ -1676,6 +1771,7 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { int getValidIndexCount() { return validIndexCount; } + void handleFrequencyChange(int bit) { if ((bit == IndexedGeometryArray.ALLOW_COORDINATE_INDEX_WRITE) || (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) && @@ -1684,10 +1780,14 @@ abstract class IndexedGeometryArrayRetained extends GeometryArrayRetained { (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0) && ((vertexFormat & GeometryArray.NORMALS) != 0) && bit == IndexedGeometryArray.ALLOW_NORMAL_INDEX_WRITE) || + (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0)&& + ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0)&& + bit == IndexedGeometryArray.ALLOW_VERTEX_ATTR_INDEX_WRITE) || (((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) == 0)&& ((vertexFormat & GeometryArray.TEXTURE_COORDINATE) != 0)&& bit == IndexedGeometryArray.ALLOW_TEXCOORD_INDEX_WRITE)) { - setFrequencyChangeMask(bit, 0x1); + + setFrequencyChangeMask(bit, 0x1); } else { super.handleFrequencyChange(bit); diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryStripArray.java b/src/classes/share/javax/media/j3d/IndexedGeometryStripArray.java index adce5e3..8f9073d 100644 --- a/src/classes/share/javax/media/j3d/IndexedGeometryStripArray.java +++ b/src/classes/share/javax/media/j3d/IndexedGeometryStripArray.java @@ -27,21 +27,19 @@ public abstract class IndexedGeometryStripArray extends IndexedGeometryArray { * Constructs an empty IndexedGeometryStripArray object with the specified * number of vertices, vertex format, number of indices, and * array of per-strip index counts. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * * @param stripIndexCounts array that specifies * the count of the number of indices for each separate strip. * The length of this array is the number of separate strips. @@ -49,7 +47,10 @@ public abstract class IndexedGeometryStripArray extends IndexedGeometryArray { * of valid indexed vertices that are rendered (validIndexCount). * * @exception IllegalArgumentException if - * <code>validIndexCount > indexCount</code> + * <code>validIndexCount > indexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public IndexedGeometryStripArray(int vertexCount, int vertexFormat, @@ -67,56 +68,25 @@ public abstract class IndexedGeometryStripArray extends IndexedGeometryArray { * sets, texture coordinate mapping array, number of indices, and * array of per-strip index counts. * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered.<p> + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. * * @param stripIndexCounts array that specifies * the count of the number of indices for each separate strip. @@ -125,7 +95,10 @@ public abstract class IndexedGeometryStripArray extends IndexedGeometryArray { * of valid indexed vertices that are rendered (validIndexCount). * * @exception IllegalArgumentException if - * <code>validIndexCount > indexCount</code> + * <code>validIndexCount > indexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -143,6 +116,69 @@ public abstract class IndexedGeometryStripArray extends IndexedGeometryArray { setStripIndexCounts(stripIndexCounts); } + /** + * Constructs an empty IndexedGeometryStripArray object with the + * specified number of vertices, vertex format, number of texture + * coordinate sets, texture coordinate mapping array, vertex + * attribute count, vertex attribute sizes array, number of + * indices, and array of per-strip index counts. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts array that specifies + * the count of the number of indices for each separate strip. + * The length of this array is the number of separate strips. + * The sum of the elements in this array defines the total number + * of valid indexed vertices that are rendered (validIndexCount). + * + * @exception IllegalArgumentException if + * <code>validIndexCount > indexCount</code> + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedGeometryStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount, + int[] stripIndexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + indexCount); + + ((IndexedGeometryStripArrayRetained)this.retained). + setStripIndexCounts(stripIndexCounts); + } + /** * Get number of strips in the GeometryStripArray * @return numStrips number of strips diff --git a/src/classes/share/javax/media/j3d/IndexedGeometryStripArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedGeometryStripArrayRetained.java index 0b7958a..7e6c09d 100644 --- a/src/classes/share/javax/media/j3d/IndexedGeometryStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedGeometryStripArrayRetained.java @@ -32,15 +32,10 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet /** * Set stripIndexCount data into local array */ - void setStripIndexCounts(int stripIndexCounts[]){ - + void setStripIndexCounts(int stripIndexCounts[]) { int i, num = stripIndexCounts.length, total = 0; - - - - - for (i=0; i < num; i++) { + for (i=0; i < num; i++) { total += stripIndexCounts[i]; if (this instanceof IndexedLineStripArrayRetained) { if (stripIndexCounts[i] < 2) { @@ -65,7 +60,8 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet int newCoordMax =0; int newColorIndex=0; int newNormalIndex=0; - int newTexCoordIndex[]=null; + int[] newTexCoordIndex = null; + int[] newVertexAttrIndex = null; newCoordMax = computeMaxIndex(initialIndexIndex, total, indexCoord); doErrorCheck(newCoordMax); @@ -78,10 +74,19 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet newTexCoordIndex = new int[texCoordSetCount]; for (i = 0; i < texCoordSetCount; i++) { newTexCoordIndex[i] = computeMaxIndex(initialIndexIndex,total, - (int[])indexTexCoord[i]); + indexTexCoord[i]); doTexCoordCheck(newTexCoordIndex[i], i); } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + newVertexAttrIndex = new int[vertexAttrCount]; + for (i = 0; i < vertexAttrCount; i++) { + newVertexAttrIndex[i] = computeMaxIndex(initialIndexIndex, + total, + indexVertexAttr[i]); + doTexCoordCheck(newVertexAttrIndex[i], i); + } + } if ((vertexFormat & GeometryArray.NORMALS) != 0) { newNormalIndex = computeMaxIndex(initialIndexIndex, total, indexNormal); doNormalCheck(newNormalIndex); @@ -103,6 +108,11 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet maxTexCoordIndices[i] = newTexCoordIndex[i]; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = newVertexAttrIndex[i]; + } + } maxNormalIndex = newNormalIndex; } else { @@ -113,6 +123,11 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet maxTexCoordIndices[i] = maxCoordIndex; } } + if ((vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + for (i = 0; i < vertexAttrCount; i++) { + maxVertexAttrIndices[i] = maxCoordIndex; + } + } } geomLock.unLock(); // bbox is computed for the entries list. @@ -123,7 +138,7 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet } - Object cloneNonIndexedGeometry() { + GeometryArrayRetained cloneNonIndexedGeometry() { GeometryStripArrayRetained obj = null; int i; switch (this.geoType) { @@ -137,11 +152,14 @@ abstract class IndexedGeometryStripArrayRetained extends IndexedGeometryArrayRet obj = new TriangleStripArrayRetained(); break; } - obj.createGeometryArrayData(validIndexCount, (vertexFormat & ~(GeometryArray.BY_REFERENCE|GeometryArray.INTERLEAVED|GeometryArray.USE_NIO_BUFFER)), texCoordSetCount, texCoordSetMap); + obj.createGeometryArrayData(validIndexCount, + (vertexFormat & ~(GeometryArray.BY_REFERENCE|GeometryArray.INTERLEAVED|GeometryArray.USE_NIO_BUFFER)), + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); obj.unIndexify(this); obj.setStripVertexCounts(stripIndexCounts); - return (Object)obj; + return obj; } diff --git a/src/classes/share/javax/media/j3d/IndexedLineArray.java b/src/classes/share/javax/media/j3d/IndexedLineArray.java index a28e613..28d267a 100644 --- a/src/classes/share/javax/media/j3d/IndexedLineArray.java +++ b/src/classes/share/javax/media/j3d/IndexedLineArray.java @@ -25,113 +25,142 @@ public class IndexedLineArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedLineArray object with the specified - * number of vertices, vertex format, and number of indices. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedLineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 2, or indexCount is <i>not</i> * a multiple of 2 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public IndexedLineArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount,vertexFormat, indexCount); - if (vertexCount < 1) - throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray0")); + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray0")); - if (indexCount < 2 || ((indexCount%2) != 0)) + if (indexCount < 2 || ((indexCount%2) != 0)) throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray1")); } /** - * Constructs an empty IndexedLineArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and number of indices. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3 or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedLineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 2, or indexCount is <i>not</i> * a multiple of 2 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ public IndexedLineArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int indexCount) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + indexCount); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray0")); + + if (indexCount < 2 || ((indexCount%2) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray1")); + } + + /** + * Constructs an empty IndexedLineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 2, or indexCount is <i>not</i> + * a multiple of 2 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedLineArray(int vertexCount, int vertexFormat, int texCoordSetCount, int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, int indexCount) { super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, indexCount); - if (vertexCount < 1) - throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray0")); + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray0")); - if (indexCount < 2 || ((indexCount%2) != 0)) + if (indexCount < 2 || ((indexCount%2) != 0)) throw new IllegalArgumentException(J3dI18N.getString("IndexedLineArray1")); } @@ -148,22 +177,26 @@ public class IndexedLineArray extends IndexedGeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedLineArrayRetained rt = (IndexedLineArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - IndexedLineArray l; - if (texSetCount == 0) { - l = new IndexedLineArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - l = new IndexedLineArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount()); - } + IndexedLineArrayRetained rt = (IndexedLineArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedLineArray l = new IndexedLineArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount()); l.duplicateNodeComponent(this); return l; } diff --git a/src/classes/share/javax/media/j3d/IndexedLineArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedLineArrayRetained.java index 54b4f14..bb9731f 100644 --- a/src/classes/share/javax/media/j3d/IndexedLineArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedLineArrayRetained.java @@ -25,15 +25,16 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { IndexedLineArrayRetained() { this.geoType = GEO_TYPE_INDEXED_LINE_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { - Point3d pnts[] = new Point3d[2]; + + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { + Point3d pnts[] = new Point3d[2]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; - int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? + int count = 0; + int minICount = 0; + int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); - pnts[0] = new Point3d(); pnts[1] = new Point3d(); @@ -44,15 +45,16 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); - + count += 2; if (intersectLineAndRay(pnts[0], pnts[1], pickRay.origin, pickRay.direction, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -70,20 +72,21 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectLineAndRay(pnts[0], pnts[1], pickSegment.start, dir, sdist, iPnt) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; } - } } break; @@ -94,12 +97,14 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -115,12 +120,14 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -135,12 +142,14 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -154,12 +163,14 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -173,12 +184,14 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); + count += 2; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -194,15 +207,22 @@ class IndexedLineArrayRetained extends IndexedGeometryArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=2); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[2]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 2; + vertexIndices[1] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; - return true; + return true; } return false; - } + } boolean intersect(Point3d[] pnts) { Point3d[] points = new Point3d[2]; diff --git a/src/classes/share/javax/media/j3d/IndexedLineStripArray.java b/src/classes/share/javax/media/j3d/IndexedLineStripArray.java index 6a32086..34dbf3b 100644 --- a/src/classes/share/javax/media/j3d/IndexedLineStripArray.java +++ b/src/classes/share/javax/media/j3d/IndexedLineStripArray.java @@ -30,35 +30,36 @@ public class IndexedLineStripArray extends IndexedGeometryStripArray { } /** - * Constructs an empty IndexedLineStripArray object with the specified - * number of vertices, vertex format, number of indices, and - * array of per-strip index counts. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedLineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 2, * or any element in the stripIndexCounts array is less than 2 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for more exceptions that can be thrown */ public IndexedLineStripArray(int vertexCount, - int vertexFormat, - int indexCount, - int stripIndexCounts[]) { + int vertexFormat, + int indexCount, + int[] stripIndexCounts) { super(vertexCount, vertexFormat, indexCount, stripIndexCounts); @@ -70,81 +71,113 @@ public class IndexedLineStripArray extends IndexedGeometryStripArray { } /** - * Constructs an empty IndexedLineStripArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, number of indices, and - * array of per-strip index counts. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered.<p> - * - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedLineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 2, * or any element in the stripIndexCounts array is less than 2 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ public IndexedLineStripArray(int vertexCount, - int vertexFormat, - int texCoordSetCount, - int[] texCoordSetMap, - int indexCount, - int stripIndexCounts[]) { + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int indexCount, + int[] stripIndexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + indexCount, stripIndexCounts); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineStripArray0")); + + if (indexCount < 2 ) + throw new IllegalArgumentException(J3dI18N.getString("IndexedLineStripArray1")); + } + + /** + * Constructs an empty IndexedLineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 2, + * or any element in the stripIndexCounts array is less than 2 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedLineStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount, + int[] stripIndexCounts) { super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, indexCount, stripIndexCounts); if (vertexCount < 1) @@ -168,29 +201,30 @@ public class IndexedLineStripArray extends IndexedGeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedLineStripArrayRetained rt = - (IndexedLineStripArrayRetained) retained; + IndexedLineStripArrayRetained rt = + (IndexedLineStripArrayRetained) retained; int stripIndexCounts[] = new int[rt.getNumStrips()]; - rt.getStripIndexCounts(stripIndexCounts); - int texSetCount = rt.getTexCoordSetCount(); - IndexedLineStripArray l; - - if (texSetCount == 0) { - l = new IndexedLineStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount(), - stripIndexCounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - l = new IndexedLineStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount(), - stripIndexCounts); - - } + rt.getStripIndexCounts(stripIndexCounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedLineStripArray l = new IndexedLineStripArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount(), + stripIndexCounts); l.duplicateNodeComponent(this); return l; } diff --git a/src/classes/share/javax/media/j3d/IndexedLineStripArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedLineStripArrayRetained.java index 7a91bd5..8791b9f 100644 --- a/src/classes/share/javax/media/j3d/IndexedLineStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedLineStripArrayRetained.java @@ -29,14 +29,14 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { geoType = GEO_TYPE_INDEXED_LINE_STRIP_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[2]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int scount, j, i = 0; int count = 0; + int minICount = 0; pnts[0] = new Point3d(); pnts[1] = new Point3d(); @@ -54,14 +54,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { if (intersectLineAndRay(pnts[0], pnts[1], pickRay.origin, pickRay.direction, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -85,14 +86,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { pickSegment.start, dir, sdist, iPnt) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -111,14 +113,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { getVertexData(indexCoord[count++], pnts[1]); if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -138,14 +141,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { getVertexData(indexCoord[count++], pnts[1]); if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -164,14 +168,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { getVertexData(indexCoord[count++], pnts[1]); if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -189,14 +194,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { getVertexData(indexCoord[count++], pnts[1]); if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -214,14 +220,15 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { getVertexData(indexCoord[count++], pnts[1]); if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -236,14 +243,20 @@ class IndexedLineStripArrayRetained extends IndexedGeometryStripArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=2); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[2]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 2; + vertexIndices[1] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; return true; } return false; - } // intersect pnts[] with every triangle in this object diff --git a/src/classes/share/javax/media/j3d/IndexedPointArray.java b/src/classes/share/javax/media/j3d/IndexedPointArray.java index c780d34..7f01bd2 100644 --- a/src/classes/share/javax/media/j3d/IndexedPointArray.java +++ b/src/classes/share/javax/media/j3d/IndexedPointArray.java @@ -26,25 +26,26 @@ public class IndexedPointArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedPointArray object with the specified - * number of vertices, vertex format, and number of indices. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedPointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1 * or indexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public IndexedPointArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount,vertexFormat, indexCount); @@ -57,63 +58,34 @@ public class IndexedPointArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedPointArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and number of indices. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3 or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedPointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1 * or indexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -135,6 +107,62 @@ public class IndexedPointArray extends IndexedGeometryArray { } /** + * Constructs an empty IndexedPointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1 + * or indexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedPointArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + indexCount); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedPointArray0")); + + if (indexCount < 1 ) + throw new IllegalArgumentException(J3dI18N.getString("IndexedPointArray1")); + } + + /** * Creates the retained mode IndexedPointArrayRetained object that this * IndexedPointArray object will point to. */ @@ -148,22 +176,26 @@ public class IndexedPointArray extends IndexedGeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedPointArrayRetained rt = (IndexedPointArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - IndexedPointArray p; - if (texSetCount == 0) { - p = new IndexedPointArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - p = new IndexedPointArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount()); - } + IndexedPointArrayRetained rt = (IndexedPointArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedPointArray p = new IndexedPointArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount()); p.duplicateNodeComponent(this); return p; } diff --git a/src/classes/share/javax/media/j3d/IndexedPointArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedPointArrayRetained.java index 8c63a73..f7289c5 100644 --- a/src/classes/share/javax/media/j3d/IndexedPointArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedPointArrayRetained.java @@ -25,10 +25,12 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { this.geoType = GEO_TYPE_INDEXED_POINT_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { - double sdist[] = new double[1]; + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { + double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; Point3d pnt = new Point3d(); int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); @@ -39,13 +41,15 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnt); + count++; if (intersectPntAndRay(pnt, pickRay.origin, pickRay.direction, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -62,19 +66,20 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnt); + count++; if (intersectPntAndRay(pnt, pickSegment.start, dir, sdist) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; } - } } break; @@ -85,33 +90,35 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnt); + count++; if (bounds.intersect(pnt)) { - if (dist == null) { + if (flags == 0) { return true; } sdist[0] = pickShape.distance(pnt); if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; } } } - break; case PickShape.PICKCYLINDER: PickCylinder pickCylinder= (PickCylinder) pickShape; while (i < validVertexCount) { getVertexData(indexCoord[i++], pnt); - + count++; if (intersectCylinder(pnt, pickCylinder, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -124,13 +131,14 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { while (i < validVertexCount) { getVertexData(indexCoord[i++], pnt); - + count++; if (intersectCone(pnt, pickCone, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -146,7 +154,13 @@ class IndexedPointArrayRetained extends IndexedGeometryArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=1); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[1]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; diff --git a/src/classes/share/javax/media/j3d/IndexedQuadArray.java b/src/classes/share/javax/media/j3d/IndexedQuadArray.java index 4368340..1c94c4b 100644 --- a/src/classes/share/javax/media/j3d/IndexedQuadArray.java +++ b/src/classes/share/javax/media/j3d/IndexedQuadArray.java @@ -27,26 +27,27 @@ public class IndexedQuadArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedQuadArray object with the specified - * number of vertices, vertex format, and number of indices. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedQuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 4, or indexCount is <i>not</i> * a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public IndexedQuadArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount,vertexFormat, indexCount); @@ -59,64 +60,35 @@ public class IndexedQuadArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedQuadArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and number of indices. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedQuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 4, or indexCount is <i>not</i> * a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -138,6 +110,63 @@ public class IndexedQuadArray extends IndexedGeometryArray { } /** + * Constructs an empty IndexedQuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 4, or indexCount is <i>not</i> + * a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedQuadArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + indexCount); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedQuadArray0")); + + if (indexCount < 4 || ((indexCount%4) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("IndexedQuadArray1")); + } + + /** * Creates the retained mode IndexedQuadArrayRetained object that this * IndexedQuadArray object will point to. */ @@ -151,23 +180,26 @@ public class IndexedQuadArray extends IndexedGeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedQuadArrayRetained rt = (IndexedQuadArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - IndexedQuadArray q; - - if (texSetCount == 0) { - q = new IndexedQuadArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - q = new IndexedQuadArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount()); - } + IndexedQuadArrayRetained rt = (IndexedQuadArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedQuadArray q = new IndexedQuadArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount()); q.duplicateNodeComponent(this); return q; } diff --git a/src/classes/share/javax/media/j3d/IndexedQuadArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedQuadArrayRetained.java index f06c62d..355f471 100644 --- a/src/classes/share/javax/media/j3d/IndexedQuadArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedQuadArrayRetained.java @@ -27,15 +27,15 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { this.geoType = GEO_TYPE_INDEXED_QUAD_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[4]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? - initialVertexIndex : initialCoordIndex); - + initialVertexIndex : initialCoordIndex); pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -50,12 +50,14 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); + count += 4; if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -71,18 +73,19 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); + count += 4; if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } - + } } } break; @@ -94,108 +97,108 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); - + count += 4; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } - break; case PickShape.PICKBOUNDINGSPHERE: BoundingSphere bsphere = (BoundingSphere) ((PickBounds) pickShape).bounds; - while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); - + count += 4; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; case PickShape.PICKBOUNDINGPOLYTOPE: - BoundingPolytope bpolytope = (BoundingPolytope) ((PickBounds) pickShape).bounds; - while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); - + count += 4; if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; case PickShape.PICKCYLINDER: PickCylinder pickCylinder= (PickCylinder) pickShape; - while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); - + count += 4; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; case PickShape.PICKCONE: PickCone pickCone= (PickCone) pickShape; - while (i < validVertexCount) { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); getVertexData(indexCoord[i++], pnts[3]); + count += 4; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; @@ -207,7 +210,16 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 4); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[4]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 4; + vertexIndices[1] = minICount - 3; + vertexIndices[2] = minICount - 2; + vertexIndices[3] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; @@ -215,8 +227,7 @@ class IndexedQuadArrayRetained extends IndexedGeometryArrayRetained { } return false; - } - + } // intersect pnts[] with every quad in this object boolean intersect(Point3d[] pnts) { diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleArray.java b/src/classes/share/javax/media/j3d/IndexedTriangleArray.java index 300a812..3f923a4 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleArray.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleArray.java @@ -27,32 +27,32 @@ public class IndexedTriangleArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedTriangleArray object with the specified - * number of vertices, vertex format, and number of indices. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedTriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, or indexCount is <i>not</i> * a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ - public IndexedTriangleArray(int vertexCount, int vertexFormat, - int indexCount) { + public IndexedTriangleArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount,vertexFormat, indexCount); - if (vertexCount < 1) + if (vertexCount < 1) throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleArray0")); if (indexCount < 3 || ((indexCount%3) != 0)) @@ -60,64 +60,35 @@ public class IndexedTriangleArray extends IndexedGeometryArray { } /** - * Constructs an empty IndexedTriangleArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and number of indices. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. + * Constructs an empty IndexedTriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, or indexCount is <i>not</i> * a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -131,7 +102,64 @@ public class IndexedTriangleArray extends IndexedGeometryArray { texCoordSetCount, texCoordSetMap, indexCount); - if (vertexCount < 1) + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleArray0")); + + if (indexCount < 3 || ((indexCount%3) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleArray1")); + } + + /** + * Constructs an empty IndexedTriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 3, or indexCount is <i>not</i> + * a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedTriangleArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + indexCount); + + if (vertexCount < 1) throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleArray0")); if (indexCount < 3 || ((indexCount%3) != 0)) @@ -152,23 +180,26 @@ public class IndexedTriangleArray extends IndexedGeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedTriangleArrayRetained rt = (IndexedTriangleArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - IndexedTriangleArray t; - - if (texSetCount == 0) { - t = new IndexedTriangleArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - t = new IndexedTriangleArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount()); - } + IndexedTriangleArrayRetained rt = (IndexedTriangleArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedTriangleArray t = new IndexedTriangleArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount()); t.duplicateNodeComponent(this); return t; } diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedTriangleArrayRetained.java index f76dc69..d977894 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleArrayRetained.java @@ -27,14 +27,15 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { this.geoType = GEO_TYPE_INDEXED_TRI_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); - pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -47,15 +48,17 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); + count += 3; if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -66,18 +69,19 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); - if (intersectSegment(pnts, pickSegment.start, - pickSegment.end, sdist, iPnt) - && (sdist[0] <= 1.0)) { - if (dist == null) { + count += 3; + if (intersectSegment(pnts, pickSegment.start, + pickSegment.end, sdist, iPnt)) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; - } + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; + } } } break; @@ -89,15 +93,17 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); + count += 3; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -110,15 +116,17 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); + count += 3; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -131,16 +139,18 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); - if (intersectBoundingPolytope(pnts, bpolytope, + count += 3; + if (intersectBoundingPolytope(pnts, bpolytope, sdist,iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -151,16 +161,18 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); + count += 3; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -172,15 +184,17 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { getVertexData(indexCoord[i++], pnts[0]); getVertexData(indexCoord[i++], pnts[1]); getVertexData(indexCoord[i++], pnts[2]); + count += 3; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } } @@ -194,7 +208,15 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 3; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; @@ -203,7 +225,6 @@ class IndexedTriangleArrayRetained extends IndexedGeometryArrayRetained { return false; } - // intersect pnts[] with every triangle in this object boolean intersect(Point3d[] pnts) { Point3d[] points = new Point3d[3]; diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleFanArray.java b/src/classes/share/javax/media/j3d/IndexedTriangleFanArray.java index 795de14..d094859 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleFanArray.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleFanArray.java @@ -29,39 +29,40 @@ public class IndexedTriangleFanArray extends IndexedGeometryStripArray { IndexedTriangleFanArray() {} /** - * Constructs an empty IndexedTriangleFanArray object with the specified - * number of vertices, vertex format, number of indices, and - * array of per-strip index counts. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedTriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for more exceptions that can be thrown */ public IndexedTriangleFanArray(int vertexCount, int vertexFormat, int indexCount, - int stripIndexCounts[]) { + int[] stripIndexCounts) { super(vertexCount, vertexFormat, indexCount, stripIndexCounts); - if (vertexCount < 1) + if (vertexCount < 1) throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleFanArray0")); if (indexCount < 3 ) @@ -69,69 +70,39 @@ public class IndexedTriangleFanArray extends IndexedGeometryStripArray { } /** - * Constructs an empty IndexedTriangleFanArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, number of indices, and - * array of per-strip index counts. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3 or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered.<p> - * - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedTriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -140,13 +111,75 @@ public class IndexedTriangleFanArray extends IndexedGeometryStripArray { int texCoordSetCount, int[] texCoordSetMap, int indexCount, - int stripIndexCounts[]) { + int[] stripIndexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + indexCount, stripIndexCounts); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleFanArray0")); + + if (indexCount < 3 ) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleFanArray1")); + } + + /** + * Constructs an empty IndexedTriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 3, + * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedTriangleFanArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount, + int[] stripIndexCounts) { super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, indexCount, stripIndexCounts); - if (vertexCount < 1) + if (vertexCount < 1) throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleFanArray0")); if (indexCount < 3 ) @@ -167,29 +200,30 @@ public class IndexedTriangleFanArray extends IndexedGeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedTriangleFanArrayRetained rt = - (IndexedTriangleFanArrayRetained) retained; - int stripIndexCounts[] = new int[rt.getNumStrips()]; - rt.getStripIndexCounts(stripIndexCounts); - int texSetCount = rt.getTexCoordSetCount(); - IndexedTriangleFanArray t; - - if (texSetCount == 0) { - t = new IndexedTriangleFanArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount(), - stripIndexCounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - t = new IndexedTriangleFanArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount(), - stripIndexCounts); - } - + IndexedTriangleFanArrayRetained rt = + (IndexedTriangleFanArrayRetained) retained; + int stripIndexCounts[] = new int[rt.getNumStrips()]; + rt.getStripIndexCounts(stripIndexCounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedTriangleFanArray t = new IndexedTriangleFanArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount(), + stripIndexCounts); t.duplicateNodeComponent(this); return t; } diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleFanArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedTriangleFanArrayRetained.java index b4f0066..c6e37f7 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleFanArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleFanArrayRetained.java @@ -32,15 +32,16 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained geoType = GEO_TYPE_INDEXED_TRI_FAN_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int i = 0; - int j, scount, count = 0; - - pnts[0] = new Point3d(); + int j, scount, count = 0, fSCount; + int minICount = 0; + int minFSCount = 0; + pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -48,22 +49,25 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained case PickShape.PICKRAY: PickRay pickRay= (PickRay) pickShape; - while (i < stripIndexCounts.length) { + while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -74,21 +78,24 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained PickSegment pickSegment = (PickSegment) pickShape; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(j++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -100,20 +107,23 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained ((PickBounds) pickShape).bounds; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -125,22 +135,25 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained ((PickBounds) pickShape).bounds; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -152,22 +165,25 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained ((PickBounds) pickShape).bounds; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -178,21 +194,24 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained PickCylinder pickCylinder= (PickCylinder) pickShape; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -203,21 +222,24 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained PickCone pickCone= (PickCone) pickShape; while (i < stripIndexCounts.length) { + fSCount = count; getVertexData(indexCoord[count++], pnts[0]); getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -232,14 +254,22 @@ class IndexedTriangleFanArrayRetained extends IndexedGeometryStripArrayRetained } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minFSCount; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; - return true; + return true; } return false; - } + } // intersect pnts[] with every triangle in this object boolean intersect(Point3d[] pnts) { diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleStripArray.java b/src/classes/share/javax/media/j3d/IndexedTriangleStripArray.java index 13970bb..b5395db 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleStripArray.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleStripArray.java @@ -31,35 +31,36 @@ public class IndexedTriangleStripArray extends IndexedGeometryStripArray { } /** - * Constructs an empty IndexedTriangleStripArray object with the specified - * number of vertices, vertex format, number of indices, and - * array of per-strip index counts. - * @param vertexCount the number of vertex elements in this object - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered. - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedTriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[])} + * for more exceptions that can be thrown */ public IndexedTriangleStripArray(int vertexCount, int vertexFormat, int indexCount, - int stripIndexCounts[]) { + int[] stripIndexCounts) { super(vertexCount, vertexFormat, indexCount, stripIndexCounts); @@ -71,69 +72,39 @@ public class IndexedTriangleStripArray extends IndexedGeometryStripArray { } /** - * Constructs an empty IndexedTriangleStripArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, number of indices, and - * array of per-strip index counts. - * - * @param vertexCount the number of vertex elements in this object<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code> or - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param indexCount the number of indices in this object. This - * count is the maximum number of vertices that will be rendered.<p> - * - * @param stripIndexCounts array that specifies - * the count of the number of indices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty IndexedTriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1, * or indexCount is less than 3, * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -142,10 +113,72 @@ public class IndexedTriangleStripArray extends IndexedGeometryStripArray { int texCoordSetCount, int[] texCoordSetMap, int indexCount, - int stripIndexCounts[]) { + int[] stripIndexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + indexCount, stripIndexCounts); + + if (vertexCount < 1) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleStripArray0")); + + if (indexCount < 3 ) + throw new IllegalArgumentException(J3dI18N.getString("IndexedTriangleStripArray1")); + } + + /** + * Constructs an empty IndexedTriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param indexCount + * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)} + * for a description of this parameter. + * + * @param stripIndexCounts + * see {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1, + * or indexCount is less than 3, + * or any element in the stripIndexCounts array is less than 3 + * ;<br> + * See {@link IndexedGeometryStripArray#IndexedGeometryStripArray(int,int,int,int[],int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public IndexedTriangleStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int indexCount, + int[] stripIndexCounts) { super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, indexCount, stripIndexCounts); if (vertexCount < 1) @@ -169,28 +202,31 @@ public class IndexedTriangleStripArray extends IndexedGeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - IndexedTriangleStripArrayRetained rt = - (IndexedTriangleStripArrayRetained) retained; + IndexedTriangleStripArrayRetained rt = + (IndexedTriangleStripArrayRetained) retained; int stripIndexCounts[] = new int[rt.getNumStrips()]; - rt.getStripIndexCounts(stripIndexCounts); - int texSetCount = rt.getTexCoordSetCount(); - IndexedTriangleStripArray l; - if (texSetCount == 0) { - l = new IndexedTriangleStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - rt.getIndexCount(), - stripIndexCounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - l = new IndexedTriangleStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - rt.getIndexCount(), - stripIndexCounts); - } - l.duplicateNodeComponent(this); - return l; + rt.getStripIndexCounts(stripIndexCounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + IndexedTriangleStripArray t = new IndexedTriangleStripArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + rt.getIndexCount(), + stripIndexCounts); + t.duplicateNodeComponent(this); + return t; } } diff --git a/src/classes/share/javax/media/j3d/IndexedTriangleStripArrayRetained.java b/src/classes/share/javax/media/j3d/IndexedTriangleStripArrayRetained.java index 5e2b017..888b0de 100644 --- a/src/classes/share/javax/media/j3d/IndexedTriangleStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/IndexedTriangleStripArrayRetained.java @@ -31,14 +31,14 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine geoType = GEO_TYPE_INDEXED_TRI_STRIP_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int i = 0; int j, scount, count = 0; + int minICount = 0; pnts[0] = new Point3d(); pnts[1] = new Point3d(); @@ -54,17 +54,18 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; - } + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; + } } pnts[0].set(pnts[1]); pnts[1].set(pnts[2]); @@ -79,17 +80,18 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(j++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -106,16 +108,17 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine getVertexData(indexCoord[count++], pnts[1]); scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -133,17 +136,18 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -161,17 +165,18 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -188,16 +193,17 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -214,16 +220,17 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine scount = stripIndexCounts[i++]; for (j=2; j < scount; j++) { - getVertexData(count++, pnts[2]); + getVertexData(indexCoord[count++], pnts[2]); if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -239,15 +246,23 @@ class IndexedTriangleStripArrayRetained extends IndexedGeometryStripArrayRetaine } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 3; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; - return true; + return true; } return false; } - + // intersect pnts[] with every triangle in this object boolean intersect(Point3d[] pnts) { int j, end; diff --git a/src/classes/share/javax/media/j3d/IndexedUnorderSet.java b/src/classes/share/javax/media/j3d/IndexedUnorderSet.java index 89d3a4a..54e4b36 100644 --- a/src/classes/share/javax/media/j3d/IndexedUnorderSet.java +++ b/src/classes/share/javax/media/j3d/IndexedUnorderSet.java @@ -60,7 +60,7 @@ package javax.media.j3d; class IndexedUnorderSet implements Cloneable, java.io.Serializable { - // TODO: set to false when release + // XXXX: set to false when release final static boolean debug = false; /** diff --git a/src/classes/share/javax/media/j3d/J3DBuffer.java b/src/classes/share/javax/media/j3d/J3DBuffer.java index 6422dc1..6cc97cf 100644 --- a/src/classes/share/javax/media/j3d/J3DBuffer.java +++ b/src/classes/share/javax/media/j3d/J3DBuffer.java @@ -25,21 +25,11 @@ import com.sun.j3d.internal.ByteOrderWrapper; * <code>rewind</code> on the read-only view, so that elements 0 * through <code>buffer.limit()-1</code> will be available internally. * - * <p> - * NOTE: Use of this class requires version 1.4 of the - * Java<sup><font size="-2">TM</font></sup> 2 Platform. - * Any attempt to access this class on an earlier version of the - * Java 2 Platform will fail with a NoClassDefFoundError. - * Refer to the documentation for version 1.4 of the Java 2 SDK - * for a description of the - * <code> - * <a href="http://java.sun.com/j2se/1.4/docs/api/java/nio/package-summary.html">java.nio</a> - * </code> package. - * * @see GeometryArray#setCoordRefBuffer(J3DBuffer) * @see GeometryArray#setColorRefBuffer(J3DBuffer) * @see GeometryArray#setNormalRefBuffer(J3DBuffer) * @see GeometryArray#setTexCoordRefBuffer(int,J3DBuffer) + * @see GeometryArray#setVertexAttrRefBuffer(int,J3DBuffer) * @see GeometryArray#setInterleavedVertexBuffer(J3DBuffer) * @see CompressedGeometry#CompressedGeometry(CompressedGeometryHeader,J3DBuffer) * diff --git a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java index 2ed6814..439b0f7 100644 --- a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java +++ b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java @@ -140,7 +140,7 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { } } // Behavior Scheduler or other threads - // TODO: may not be legal for behaviorScheduler + // XXXX: may not be legal for behaviorScheduler // May cause deadlock if it is in behaviorScheduler // and we wait for Renderer to finish boolean renderRun = (Thread.currentThread() != @@ -589,13 +589,13 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { public final void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawArc(x, y, width, height, startAngle, arcAngle); } public final void drawGlyphVector(GlyphVector g, float x, float y) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawGlyphVector(g, x, y); } @@ -619,29 +619,29 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { } validate(minx, miny, maxx, maxy); } else { - // TODO: call validate with bounding box of primitive - // TODO: Need to consider Stroke width + // XXXX: call validate with bounding box of primitive + // XXXX: Need to consider Stroke width validate(); } offScreenGraphics2D.drawLine(x1, y1, x2, y2); } public final void drawOval(int x, int y, int width, int height) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawOval(x, y, width, height); } public final void drawPolygon(int xPoints[], int yPoints[], int nPoints) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawPolygon(xPoints, yPoints, nPoints); } public final void drawPolyline(int xPoints[], int yPoints[], int nPoints) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawPolyline(xPoints, yPoints, nPoints); } @@ -661,7 +661,7 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { public final void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawRoundRect(x, y, width, height, arcWidth, arcHeight); @@ -669,14 +669,14 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { public final void drawString(AttributedCharacterIterator iterator, int x, int y) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawString(iterator, x, y); } public final void drawString(AttributedCharacterIterator iterator, float x, float y) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawString(iterator, x, y); } @@ -706,20 +706,20 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { public final void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillArc(x, y, width, height, startAngle, arcAngle); } public final void fillOval(int x, int y, int width, int height) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillOval(x, y, width, height); } public final void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight); @@ -810,59 +810,59 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { public void draw3DRect(int x, int y, int width, int height, boolean raised) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.draw3DRect(x, y, width, height, raised); } public void drawBytes(byte data[], int offset, int length, int x, int y) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawBytes(data, offset, length, x, y); } public void drawChars(char data[], int offset, int length, int x, int y) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawChars(data, offset, length, x, y); } public void drawPolygon(Polygon p) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.drawPolygon(p); } public void drawRect(int x, int y, int width, int height) { - // TODO: call validate with bounding box of primitive - // TODO: need to consider Stroke width + // XXXX: call validate with bounding box of primitive + // XXXX: need to consider Stroke width validate(); offScreenGraphics2D.drawRect(x, y, width, height); } public void fill3DRect(int x, int y, int width, int height, boolean raised) { - // TODO: call validate with bounding box of primitive - // TODO: need to consider Stroke width + // XXXX: call validate with bounding box of primitive + // XXXX: need to consider Stroke width validate(); offScreenGraphics2D.fill3DRect(x, y, width, height, raised); } public void fillPolygon(Polygon p) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillPolygon(p); } public final void fillPolygon(int xPoints[], int yPoints[], int nPoints) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillPolygon(xPoints, yPoints, nPoints); } public final void fillRect(int x, int y, int width, int height) { - // TODO: call validate with bounding box of primitive + // XXXX: call validate with bounding box of primitive validate(); offScreenGraphics2D.fillRect(x, y, width, height); } @@ -888,7 +888,7 @@ final class J3DGraphics2DImpl extends J3DGraphics2D { doDrawAndFlushImage(img, x, y, observer); } else { // Behavior Scheduler or other threads - // TODO: may not be legal for behaviorScheduler + // XXXX: may not be legal for behaviorScheduler // May cause deadlock if it is in behaviorScheduler // and we wait for Renderer to finish boolean renderRun = (Thread.currentThread() != diff --git a/src/classes/share/javax/media/j3d/J3dMessage.java b/src/classes/share/javax/media/j3d/J3dMessage.java index 625f2df..d2d073d 100644 --- a/src/classes/share/javax/media/j3d/J3dMessage.java +++ b/src/classes/share/javax/media/j3d/J3dMessage.java @@ -84,6 +84,9 @@ class J3dMessage extends Object { static final int ORDERED_GROUP_TABLE_CHANGED = 59; static final int BEHAVIOR_REEVALUATE = 60; static final int CREATE_OFFSCREENBUFFER = 61; + static final int SHADER_ATTRIBUTE_CHANGED = 62; + static final int SHADER_ATTRIBUTE_SET_CHANGED = 63; + static final int SHADER_APPEARANCE_CHANGED = 64; /** * This is the time snapshot at which this change occured diff --git a/src/classes/share/javax/media/j3d/J3dNotification.java b/src/classes/share/javax/media/j3d/J3dNotification.java new file mode 100644 index 0000000..8560295 --- /dev/null +++ b/src/classes/share/javax/media/j3d/J3dNotification.java @@ -0,0 +1,42 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * J3dNotification is used to hold data for asynchronous error notification. + */ + +class J3dNotification extends Object { + /** + * The various notification types. + */ + static final int INVALID_TYPE = -1; + static final int SHADER_ERROR = 0; + + /** + * This holds the type of this message + */ + int type = INVALID_TYPE; + + /** + * The universe that this message originated from + */ + VirtualUniverse universe; + + /** + * The arguements for a message, 6 for now + */ + static final int MAX_ARGS = 6; + + Object[] args = new Object[MAX_ARGS]; +} diff --git a/src/classes/share/javax/media/j3d/Light.java b/src/classes/share/javax/media/j3d/Light.java index 2588607..47c479a 100644 --- a/src/classes/share/javax/media/j3d/Light.java +++ b/src/classes/share/javax/media/j3d/Light.java @@ -220,6 +220,14 @@ public abstract class Light extends Leaf { public static final int ALLOW_SCOPE_WRITE = CapabilityBits.LIGHT_ALLOW_SCOPE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_STATE_READ, + ALLOW_COLOR_READ, + ALLOW_INFLUENCING_BOUNDS_READ, + ALLOW_SCOPE_READ + }; + /** * Constructs a Light node with default parameters. The default * values are as follows: @@ -232,6 +240,8 @@ public abstract class Light extends Leaf { * </ul> */ public Light() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -239,7 +249,10 @@ public abstract class Light extends Leaf { * @param color the color of the light source */ public Light(Color3f color) { - ((LightRetained)this.retained).initColor(color); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((LightRetained)this.retained).initColor(color); } /** @@ -249,7 +262,10 @@ public abstract class Light extends Leaf { * @param color the color of the light source */ public Light(boolean lightOn, Color3f color) { - ((LightRetained)this.retained).initEnable(lightOn); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((LightRetained)this.retained).initEnable(lightOn); ((LightRetained)this.retained).initColor(color); } diff --git a/src/classes/share/javax/media/j3d/LineArray.java b/src/classes/share/javax/media/j3d/LineArray.java index f2d0e12..da484d1 100644 --- a/src/classes/share/javax/media/j3d/LineArray.java +++ b/src/classes/share/javax/media/j3d/LineArray.java @@ -27,23 +27,22 @@ public class LineArray extends GeometryArray { } /** - * Constructs an empty LineArray object with the specified - * number of vertices, and vertex format. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. + * Constructs an empty LineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 2 * or vertexCount is <i>not</i> a multiple of 2 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public LineArray(int vertexCount, int vertexFormat) { super(vertexCount,vertexFormat); @@ -53,60 +52,30 @@ public class LineArray extends GeometryArray { } /** - * Constructs an empty LineArray object with the specified - * number of vertices, and vertex format, number of texture coordinate - * sets, and texture coordinate mapping array. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used. + * Constructs an empty LineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 2 * or vertexCount is <i>not</i> a multiple of 2 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -123,6 +92,53 @@ public class LineArray extends GeometryArray { } /** + * Constructs an empty LineArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 2 + * or vertexCount is <i>not</i> a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public LineArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + if (vertexCount < 2 || ((vertexCount%2) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("LineArray0")); + } + + /** * Creates the retained mode LineArrayRetained object that this * LineArray object will point to. */ @@ -137,23 +153,24 @@ public class LineArray extends GeometryArray { */ public NodeComponent cloneNodeComponent() { LineArrayRetained rt = (LineArrayRetained) retained; - - - int texSetCount = rt.getTexCoordSetCount(); - LineArray l; - if (texSetCount == 0) { - l = new LineArray(rt.getVertexCount(), - rt.getVertexFormat()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - l = new LineArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap); - - } - + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + LineArray l = new LineArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes); l.duplicateNodeComponent(this); return l; } diff --git a/src/classes/share/javax/media/j3d/LineArrayRetained.java b/src/classes/share/javax/media/j3d/LineArrayRetained.java index b29597a..2b07b54 100644 --- a/src/classes/share/javax/media/j3d/LineArrayRetained.java +++ b/src/classes/share/javax/media/j3d/LineArrayRetained.java @@ -25,15 +25,16 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { LineArrayRetained() { this.geoType = GEO_TYPE_LINE_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[2]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); - pnts[0] = new Point3d(); pnts[1] = new Point3d(); @@ -44,18 +45,20 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectLineAndRay(pnts[0], pnts[1], pickRay.origin, pickRay.direction, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; @@ -69,20 +72,21 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectLineAndRay(pnts[0], pnts[1], pickSegment.start, dir, sdist, iPnt) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; } - } } break; @@ -92,12 +96,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -113,12 +119,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -133,12 +141,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -152,12 +162,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -171,12 +183,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); + count += 2; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -192,7 +206,14 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=2); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[2]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 2; + vertexIndices[1] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; @@ -200,8 +221,7 @@ class LineArrayRetained extends GeometryArrayRetained implements Cloneable { } return false; - } - + } boolean intersect(Point3d[] pnts) { Point3d[] points = new Point3d[2]; diff --git a/src/classes/share/javax/media/j3d/LineAttributes.java b/src/classes/share/javax/media/j3d/LineAttributes.java index ca2d569..c60a68c 100644 --- a/src/classes/share/javax/media/j3d/LineAttributes.java +++ b/src/classes/share/javax/media/j3d/LineAttributes.java @@ -169,7 +169,13 @@ public class LineAttributes extends NodeComponent { */ public static final int PATTERN_USER_DEFINED = 4; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ANTIALIASING_READ, + ALLOW_PATTERN_READ, + ALLOW_WIDTH_READ + }; + /** * Constructs a LineAttributes object with default parameters. * The default values are as follows: @@ -182,6 +188,8 @@ public class LineAttributes extends NodeComponent { * </ul> */ public LineAttributes(){ + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -197,6 +205,9 @@ public class LineAttributes extends NodeComponent { if (linePattern < PATTERN_SOLID || linePattern > PATTERN_DASH_DOT) throw new IllegalArgumentException(J3dI18N.getString("LineAttributes0")); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((LineAttributesRetained)this.retained).initLineWidth(lineWidth); ((LineAttributesRetained)this.retained).initLinePattern(linePattern); ((LineAttributesRetained)this.retained).initLineAntialiasingEnable(lineAntialiasing); diff --git a/src/classes/share/javax/media/j3d/LineStripArray.java b/src/classes/share/javax/media/j3d/LineStripArray.java index ef9ce5a..00581d2 100644 --- a/src/classes/share/javax/media/j3d/LineStripArray.java +++ b/src/classes/share/javax/media/j3d/LineStripArray.java @@ -30,28 +30,26 @@ public class LineStripArray extends GeometryStripArray { } /** - * Constructs an empty LineStripArray object with the specified - * number of vertices, vertex format, and - * array of per-strip vertex counts. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty LineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 2 * or any element in the stripVertexCounts array is less than 2 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for more exceptions that can be thrown */ public LineStripArray(int vertexCount, int vertexFormat, @@ -64,65 +62,34 @@ public class LineStripArray extends GeometryStripArray { } /** - * Constructs an empty LineStripArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and - * array of per-strip vertex counts. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty LineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 2 * or any element in the stripVertexCounts array is less than 2 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -141,6 +108,59 @@ public class LineStripArray extends GeometryStripArray { } /** + * Constructs an empty LineStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 2 + * or any element in the stripVertexCounts array is less than 2 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public LineStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + stripVertexCounts); + + if (vertexCount < 2 ) + throw new IllegalArgumentException(J3dI18N.getString("LineStripArray0")); + } + + /** * Creates the retained mode LineStripArrayRetained object that this * LineStripArray object will point to. */ @@ -153,24 +173,28 @@ public class LineStripArray extends GeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - LineStripArrayRetained rt = (LineStripArrayRetained) retained; + LineStripArrayRetained rt = (LineStripArrayRetained) retained; int stripcounts[] = new int[rt.getNumStrips()]; - rt.getStripVertexCounts(stripcounts); - int texSetCount = rt.getTexCoordSetCount(); - LineStripArray l; - if (texSetCount == 0) { - l = new LineStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - stripcounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - l = new LineStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - stripcounts); - } + rt.getStripVertexCounts(stripcounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + LineStripArray l = new LineStripArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + stripcounts); l.duplicateNodeComponent(this); return l; } diff --git a/src/classes/share/javax/media/j3d/LineStripArrayRetained.java b/src/classes/share/javax/media/j3d/LineStripArrayRetained.java index 4270d74..69fa80b 100644 --- a/src/classes/share/javax/media/j3d/LineStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/LineStripArrayRetained.java @@ -30,14 +30,15 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { this.geoType = GEO_TYPE_LINE_STRIP_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[2]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int j, end; int i = 0; - + int count = 0; + int minICount = 0; pnts[0] = new Point3d(); pnts[1] = new Point3d(); @@ -49,20 +50,22 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); - + count++; if (intersectLineAndRay(pnts[0], pnts[1], pickRay.origin, pickRay.direction, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -80,21 +83,23 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); - while (j < end) { + count++; + while (j < end) { getVertexData(j++, pnts[1]); - + count++; if (intersectLineAndRay(pnts[0], pnts[1], pickSegment.start, dir, sdist, iPnt) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -109,17 +114,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); + count++; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -135,17 +143,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); + count++; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -160,17 +171,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); + count++; if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -184,18 +198,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); - + count++; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -209,17 +225,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); + count++; while (j < end) { getVertexData(j++, pnts[1]); + count++; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[0].set(pnts[1]); @@ -234,14 +253,20 @@ class LineStripArrayRetained extends GeometryStripArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 2); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[2]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 2; + vertexIndices[1] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; return true; } - return false; - + return false; } boolean intersect(Point3d[] pnts) { diff --git a/src/classes/share/javax/media/j3d/LinearFog.java b/src/classes/share/javax/media/j3d/LinearFog.java index 5232d32..4aa543f 100644 --- a/src/classes/share/javax/media/j3d/LinearFog.java +++ b/src/classes/share/javax/media/j3d/LinearFog.java @@ -25,14 +25,16 @@ import javax.vecmath.Color3f; * the node, but the actual fog equation will ideally take place in eye * coordinates. * <P> - * The linear fog blending factor, f, is computed as follows: - * <P><UL> - * f = backDistance - z / backDistance - frontDistance<P> - * where - * <ul>z is the distance from the viewpoint.<br> - * frontDistance is the distance at which fog starts obscuring objects.<br> - * backDistance is the distance at which fog totally obscurs objects. - * </ul><P></UL> + * The linear fog blending factor, <code>f</code>, is computed as follows: + * <ul> + * <code>f = (backDistance - z) / (backDistance - frontDistance)</code> + * </ul> + * where: + * <ul> + * <code>z</code> is the distance from the viewpoint.<br> + * <code>frontDistance</code> is the distance at which fog starts obscuring objects.<br> + * <code>backDistance</code> is the distance at which fog totally obscurs objects. + * </ul> */ public class LinearFog extends Fog { /** @@ -49,6 +51,11 @@ public class LinearFog extends Fog { public static final int ALLOW_DISTANCE_WRITE = CapabilityBits.LINEAR_FOG_ALLOW_DISTANCE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_DISTANCE_READ + }; + /** * Constructs a LinearFog node with default parameters. * The default values are as follows: @@ -59,6 +66,8 @@ public class LinearFog extends Fog { */ public LinearFog() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -67,6 +76,9 @@ public class LinearFog extends Fog { */ public LinearFog(Color3f color) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -77,6 +89,10 @@ public class LinearFog extends Fog { */ public LinearFog(Color3f color, double frontDistance, double backDistance) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((LinearFogRetained)this.retained).initFrontDistance(frontDistance); ((LinearFogRetained)this.retained).initBackDistance(backDistance); } @@ -89,6 +105,9 @@ public class LinearFog extends Fog { */ public LinearFog(float r, float g, float b) { super(r, g, b); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -102,6 +121,10 @@ public class LinearFog extends Fog { public LinearFog(float r, float g, float b, double frontDistance, double backDistance) { super(r, g, b); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((LinearFogRetained)this.retained).initFrontDistance(frontDistance); ((LinearFogRetained)this.retained).initBackDistance(backDistance); } diff --git a/src/classes/share/javax/media/j3d/LinearFogRetained.java b/src/classes/share/javax/media/j3d/LinearFogRetained.java index 4f7b723..4eff1ec 100644 --- a/src/classes/share/javax/media/j3d/LinearFogRetained.java +++ b/src/classes/share/javax/media/j3d/LinearFogRetained.java @@ -24,12 +24,10 @@ class LinearFogRetained extends FogRetained { /** * Fog front and back distance */ - double frontDistance = 0.1; - double backDistance = 1.0; - double localToVworldScale = 1.0; - double frontDistanceInEc; - double backDistanceInEc; - double vworldToCoexistenceScale; + private double frontDistance = 0.1; + private double backDistance = 1.0; + private double frontDistanceInEc; + private double backDistanceInEc; // dirty bits for LinearFog static final int FRONT_DISTANCE_CHANGED = FogRetained.LAST_DEFINED_BIT << 1; @@ -169,29 +167,21 @@ class LinearFogRetained extends FogRetained { ((LinearFogRetained)mirrorFog).backDistance = ((Double)((Object[])objs[4])[5]).doubleValue(); } - ((LinearFogRetained)mirrorFog).localToVworldScale = - getLastLocalToVworld().getDistanceScale(); - + ((LinearFogRetained)mirrorFog).setLocalToVworldScale(getLastLocalToVworld().getDistanceScale()); super.updateMirrorObject(objs); } /** * Scale distances from local to eye coordinate - */ - - void validateDistancesInEc(double vworldToCoexistenceScale) { + */ + protected void validateDistancesInEc(double vworldToCoexistenceScale) { // vworldToCoexistenceScale can be used here since // CoexistenceToEc has a unit scale - double localToEcScale = localToVworldScale * vworldToCoexistenceScale; + double localToEcScale = getLocalToVworldScale() * vworldToCoexistenceScale; frontDistanceInEc = frontDistance * localToEcScale; backDistanceInEc = backDistance * localToEcScale; } - // Called on mirror object - void updateTransformChange() { - super.updateTransformChange(); - localToVworldScale = sgFog.getLastLocalToVworld().getDistanceScale(); - } } diff --git a/src/classes/share/javax/media/j3d/Link.java b/src/classes/share/javax/media/j3d/Link.java index 151952c..549c3aa 100644 --- a/src/classes/share/javax/media/j3d/Link.java +++ b/src/classes/share/javax/media/j3d/Link.java @@ -34,11 +34,18 @@ public class Link extends Leaf { public static final int ALLOW_SHARED_GROUP_WRITE = CapabilityBits.LINK_ALLOW_SHARED_GROUP_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SHARED_GROUP_READ + }; + /** * Constructs a Link node object that does not yet point to a * SharedGroup node. */ public Link() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -47,7 +54,10 @@ public class Link extends Leaf { * @param sharedGroup the SharedGroup node */ public Link(SharedGroup sharedGroup) { - ((LinkRetained)this.retained).setSharedGroup(sharedGroup); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((LinkRetained)this.retained).setSharedGroup(sharedGroup); } /** diff --git a/src/classes/share/javax/media/j3d/LinkRetained.java b/src/classes/share/javax/media/j3d/LinkRetained.java index f9dafb5..9ba765c 100644 --- a/src/classes/share/javax/media/j3d/LinkRetained.java +++ b/src/classes/share/javax/media/j3d/LinkRetained.java @@ -293,7 +293,7 @@ class LinkRetained extends LeafRetained { super.compile(compState); - // TODO: for now keep the static transform in the parent tg + // XXXX: for now keep the static transform in the parent tg compState.keepTG = true; // don't remove this group node diff --git a/src/classes/share/javax/media/j3d/Locale.java b/src/classes/share/javax/media/j3d/Locale.java index ecb4c86..157cbde 100644 --- a/src/classes/share/javax/media/j3d/Locale.java +++ b/src/classes/share/javax/media/j3d/Locale.java @@ -158,6 +158,7 @@ public class Locale extends Object { throw new MultipleParentException(J3dI18N.getString("Locale0")); } + universe.notifyStructureChangeListeners(true, this, branchGroup); universe.resetWaitMCFlag(); synchronized (universe.sceneGraphLock) { doAddBranchGraph(branchGroup); @@ -377,6 +378,7 @@ public class Locale extends Object { universe); } universe.setLiveState.reset(null); // cleanup memory + universe.notifyStructureChangeListeners(false, this, branchGroup); } /** @@ -408,10 +410,12 @@ public class Locale extends Object { throw new MultipleParentException(J3dI18N.getString("Locale3")); } universe.resetWaitMCFlag(); + universe.notifyStructureChangeListeners(true, this, newGroup); synchronized (universe.sceneGraphLock) { doReplaceBranchGraph(oldGroup, newGroup); universe.setLiveState.reset(this); } + universe.notifyStructureChangeListeners(false, this, oldGroup); universe.waitForMC(); } @@ -494,7 +498,7 @@ public class Locale extends Object { createMessage.args[4] = universe.setLiveState.ogCIOTableList.toArray(); VirtualUniverse.mc.processMessage(createMessage); - // TODO: make these two into one message + // XXXX: make these two into one message createMessage = VirtualUniverse.mc.getMessage(); createMessage.threads = universe.setLiveState.notifyThreads; createMessage.type = J3dMessage.INSERT_NODES; @@ -525,11 +529,8 @@ public class Locale extends Object { createMessage.universe = universe; VirtualUniverse.mc.processMessage(createMessage); - // Free up memory. universe.setLiveState.reset(null); - - } /** @@ -553,7 +554,47 @@ public class Locale extends Object { return branchGroups.elements(); } + + void validateModeFlagAndPickShape(int mode, int flags, PickShape pickShape) { + + if (universe == null) { + throw new IllegalStateException(J3dI18N.getString("Locale4")); + } + + if((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) { + + throw new IllegalArgumentException(J3dI18N.getString("Locale5")); + } + + if((pickShape instanceof PickPoint) && (mode == PickInfo.PICK_GEOMETRY)) { + throw new IllegalArgumentException(J3dI18N.getString("Locale6")); + } + + if(((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) && + ((flags & PickInfo.ALL_GEOM_INFO) != 0)) { + throw new IllegalArgumentException(J3dI18N.getString("Locale7")); + } + + if((mode == PickInfo.PICK_BOUNDS) && + (((flags & (PickInfo.CLOSEST_GEOM_INFO | + PickInfo.ALL_GEOM_INFO | + PickInfo.CLOSEST_DISTANCE | + PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { + + throw new IllegalArgumentException(J3dI18N.getString("Locale8")); + } + + if((pickShape instanceof PickBounds) && + (((flags & (PickInfo.CLOSEST_GEOM_INFO | + PickInfo.ALL_GEOM_INFO | + PickInfo.CLOSEST_DISTANCE | + PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) { + + throw new IllegalArgumentException(J3dI18N.getString("Locale9")); + } + } + /** * Returns an array referencing all the items that are pickable below this * <code>Locale</code> that intersect with PickShape. @@ -571,12 +612,103 @@ public class Locale extends Object { throw new IllegalStateException(J3dI18N.getString("Locale4")); } - return Picking.pickAll( this, pickShape ); + PickInfo[] pickInfoArr = pickAll( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfoArr == null) { + return null; + } + SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length]; + for( int i=0; i<sgpArr.length; i++) { + sgpArr[i] = pickInfoArr[i].getSceneGraphPath(); + } + + return sgpArr; + } /** - * Returns a sorted array of references to all the Pickable items + * Returns an array unsorted references to all the PickInfo objects that are pickable + * below this <code>Locale</code> that intersect with PickShape. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if this Locale has been + * removed from its VirtualUniverse. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see BranchGroup#pickAll(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + + GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape); + + return PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL); + + } + + /** + * Returns a sorted array of references to all the pickable items * that intersect with the pickShape. Element [0] references the * item closest to <i>origin</i> of PickShape successive array * elements are further from the <i>origin</i> @@ -596,9 +728,118 @@ public class Locale extends Object { throw new IllegalStateException(J3dI18N.getString("Locale4")); } - return Picking.pickAllSorted( this, pickShape ); + PickInfo[] pickInfoArr = pickAllSorted( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfoArr == null) { + return null; + } + SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length]; + for( int i=0; i<sgpArr.length; i++) { + sgpArr[i] = pickInfoArr[i].getSceneGraphPath(); + } + + return sgpArr; + } + /** + * Returns a sorted array of PickInfo references to all the pickable + * items that intersect with the pickShape. Element [0] references + * the item closest to <i>origin</i> of PickShape successive array + * elements are further from the <i>origin</i> + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if this Locale has been + * removed from its VirtualUniverse. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see BranchGroup#pickAllSorted(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape); + + if ((geomAtoms == null) || (geomAtoms.length == 0)) { + return null; + } + + PickInfo[] pickInfoArr = null; + + if (mode == PickInfo.PICK_GEOMETRY) { + // Need to have closestDistance set + flags |= PickInfo.CLOSEST_DISTANCE; + pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL); + if (pickInfoArr != null) { + PickInfo.sortPickInfoArray(pickInfoArr); + } + } + else { + PickInfo.sortGeomAtoms(geomAtoms, pickShape); + pickInfoArr= PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ALL); + } + + return pickInfoArr; + } /** * Returns a SceneGraphPath which references the pickable item @@ -615,13 +856,101 @@ public class Locale extends Object { * @see BranchGroup#pickClosest */ public SceneGraphPath pickClosest( PickShape pickShape ) { - if (universe == null) { - throw new IllegalStateException(J3dI18N.getString("Locale4")); - } + if (universe == null) { + throw new IllegalStateException(J3dI18N.getString("Locale4")); + } - return Picking.pickClosest( this, pickShape ); + PickInfo pickInfo = pickClosest( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfo == null) { + return null; + } + return pickInfo.getSceneGraphPath(); } + /** + * Returns a PickInfo which references the pickable item + * which is closest to the origin of <code>pickShape</code>. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if this Locale has been + * removed from its VirtualUniverse. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see BranchGroup#pickClosest(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) { + + PickInfo[] pickInfoArr = null; + + pickInfoArr = pickAllSorted( mode, flags, pickShape ); + + if(pickInfoArr == null) { + return null; + } + + return pickInfoArr[0]; + + } /** * Returns a reference to any item that is Pickable below this @@ -638,10 +967,100 @@ public class Locale extends Object { if (universe == null) { throw new IllegalStateException(J3dI18N.getString("Locale4")); } - - return Picking.pickAny( this, pickShape ); + + PickInfo pickInfo = pickAny( PickInfo.PICK_BOUNDS, + PickInfo.SCENEGRAPHPATH, pickShape); + + if(pickInfo == null) { + return null; + } + return pickInfo.getSceneGraphPath(); + } + /** + * Returns a PickInfo which references the pickable item below this + * Locale which intersects with <code>pickShape</code>. + * The accuracy of the pick is set by the pick mode. The mode include : + * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned + * is specified via a masked variable, flags, indicating which components are + * present in each returned PickInfo object. + * + * @param mode picking mode, one of <code>PickInfo.PICK_BOUNDS</code> or <code>PickInfo.PICK_GEOMETRY</code>. + * + * @param flags a mask indicating which components are present in each PickInfo object. + * This is specified as one or more individual bits that are bitwise "OR"ed together to + * describe the PickInfo data. The flags include : + * <ul> + * <code>PickInfo.SCENEGRAPHPATH</code> - request for computed SceneGraphPath.<br> + * <code>PickInfo.NODE</code> - request for computed intersected Node.<br> + * <code>PickInfo.LOCAL_TO_VWORLD</code> - request for computed local to virtual world transform.<br> + * <code>PickInfo.CLOSEST_INTERSECTION_POINT</code> - request for closest intersection point.<br> + * <code>PickInfo.CLOSEST_DISTANCE</code> - request for the distance of closest intersection.<br> + * <code>PickInfo.CLOSEST_GEOM_INFO</code> - request for only the closest intersection geometry information.<br> + * <code>PickInfo.ALL_GEOM_INFO</code> - request for all intersection geometry information.<br> + * </ul> + * + * @param pickShape the description of this picking volume or area. + * + * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and + * ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode + * is set to PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS + * nor PICK_GEOMETRY. + * + * @exception IllegalArgumentException if pick mode is PICK_BOUNDS + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalArgumentException if pickShape is PickBounds + * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, + * CLOSEST_GEOM_INFO or ALL_GEOM_INFO. + * + * @exception IllegalStateException if this Locale has been + * removed from its VirtualUniverse. + * + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are as follows : + * <ul> + * <li>By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ</li> + * <li>By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ</li> + * <li>Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above)</li> + * </ul> + * + * @see BranchGroup#pickAny(int,int,javax.media.j3d.PickShape) + * @see PickInfo + * + * @since Java 3D 1.4 + * + */ + public PickInfo pickAny( int mode, int flags, PickShape pickShape ) { + + validateModeFlagAndPickShape(mode, flags, pickShape); + GeometryAtom geomAtoms[] = universe.geometryStructure.pickAll(this, pickShape); + + PickInfo[] pickInfoArr = PickInfo.pick(this, geomAtoms, mode, flags, pickShape, PickInfo.PICK_ANY); + + if(pickInfoArr == null) { + return null; + } + + return pickInfoArr[0]; + + } /** * Cleans up resources associated with this Locale diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index c70b268..8e15f3f 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -20,6 +20,8 @@ package javax.media.j3d; import java.util.*; import java.awt.*; +import java.io.File; + class MasterControl { @@ -77,6 +79,8 @@ class MasterControl { static final Integer SET_QUERYPROPERTIES = new Integer(20); static final Integer SET_VIEW = new Integer(21); + private static boolean librariesLoaded = false; + /** * reference to MasterControl thread */ @@ -197,6 +201,9 @@ class MasterControl { // Only one Timer thread in the system. TimerThread timerThread; + // Only one Notification thread in the system. + private NotificationThread notificationThread; + /** * This flag indicates that MC is running */ @@ -305,9 +312,11 @@ class MasterControl { // This is a time stamp used when context is created private long contextTimeStamp = 0; - - // This is a counter for canvas bit - private int canvasBitCount = 0; + + // This is an array of canvasIds in used + private boolean[] canvasIds = null; + private int canvasFreeIndex = 0; + private Object canvasIdLock = new Object(); // This is a counter for rendererBit private int rendererCount = 0; @@ -335,15 +344,28 @@ class MasterControl { // Flag that indicates whether separate specular color is disabled or not boolean disableSeparateSpecularColor = false; - // Maximum number of texture units - int textureUnitMax = 100; - // Flag that indicates whether DisplayList is used or not boolean isDisplayList = true; // If this flag is set, then by-ref geometry will not be // put in display list boolean buildDisplayListIfPossible = false; + + // If this flag is set, then geometry arrays with vertex attributes can + // be in display list. + boolean vertexAttrsInDisplayList = false; + + // The global shading language being used. Using a ShaderProgram + // with a shading language other than the one specified by + // globalShadingLanguage will cause a ShaderError to be generated, + static int globalShadingLanguage = Shader.SHADING_LANGUAGE_GLSL; + + // Flags indicating whether the Cg or GLSL libraries are available; we still need + // to check for the actual extension support when the Canvas3D with its associated context + // is created. Note that these are qualifed by the above globalShadingLanguage, so at + // most one of these two flags will be true; + static boolean cgLibraryAvailable = false; + static boolean glslLibraryAvailable = false; // REQUESTCLEANUP messages argument @@ -390,6 +412,9 @@ class MasterControl { // False to disable rescale normal if OGL support boolean isForceNormalized = false; + // True to allow simulated (multi-pass) multi-texture + boolean allowSimulatedMultiTexture = false; + // Hashtable that maps a GraphicsDevice to its associated // Screen3D--this is only used for on-screen Canvas3Ds Hashtable deviceScreenMap = new Hashtable(); @@ -417,6 +442,13 @@ class MasterControl { private ArrayList timestampUpdateList = new ArrayList(3); private UnorderList freeMessageList = new UnorderList(8); + + // System properties containing the native library search PATH + // The order listed is the order in which they will be searched + private static final String[] systemPathProps = { + "sun.boot.library.path", + "java.library.path" + }; long awt; native long getAWT(); @@ -424,6 +456,9 @@ class MasterControl { // Method to initialize the native J3D library private native boolean initializeJ3D(boolean disableXinerama); + // Method to verify whether the native Cg library is available + private static native boolean loadNativeCgLibrary(String[] libpath); + // Method to get number of procesor private native int getNumberOfProcessor(); @@ -464,7 +499,8 @@ class MasterControl { * VirtualUniverse. */ MasterControl() { - + assert librariesLoaded; + // Get AWT handle awt = getAWT(); @@ -522,23 +558,6 @@ class MasterControl { System.err.println("Java 3D: separate specular color disabled if possible"); } - // Get the maximum number of texture units - final int defaultTextureUnitMax = textureUnitMax; - Integer textureUnitLimit = - (Integer) java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - return Integer.getInteger("j3d.textureUnitMax", - defaultTextureUnitMax); - } - }); - - textureUnitMax = textureUnitLimit.intValue(); - if (textureUnitMax != defaultTextureUnitMax) { - System.err.println("Java 3D: maximum number of texture units = " + - textureUnitMax); - } - isDisplayList = getBooleanProperty("j3d.displaylist", isDisplayList, "display list"); @@ -553,24 +572,41 @@ class MasterControl { "compiled vertex array"); isForceNormalized = - getBooleanProperty("j3d.forceNormalized", isForceNormalized, + getBooleanProperty("j3d.forceNormalized", + isForceNormalized, "force normalized"); + allowSimulatedMultiTexture = + getBooleanProperty("j3d.simulatedMultiTexture", + allowSimulatedMultiTexture, + "simulated multi-texture"); + + if (allowSimulatedMultiTexture) { + System.err.println("************************************************************************"); + System.err.println(J3dI18N.getString("MasterControl2")); + System.err.println(J3dI18N.getString("MasterControl3")); + System.err.println("************************************************************************"); + } - boolean j3dOptimizeSpace = + boolean j3dOptimizeSpace = getBooleanProperty("j3d.optimizeForSpace", true, "optimize for space"); - // Build Display list for by-ref geometry and infrequently changing geometry - // ONLY IF (isDisplayList is true and optimizeForSpace if False) - if (isDisplayList && !j3dOptimizeSpace) { - buildDisplayListIfPossible = true; - } - else { - buildDisplayListIfPossible = false; - } + if (isDisplayList) { + // Build Display list for by-ref geometry + // ONLY IF optimizeForSpace is false + if (!j3dOptimizeSpace) { + buildDisplayListIfPossible = true; + } + + // Build display lists for geometry with vertex attributes + // ONLY if we are in GLSL mode and GLSL shaders are available + if (glslLibraryAvailable) { + vertexAttrsInDisplayList = true; + } + } - // Check to see whether Renderer can run without DSI lock + // Check to see whether Renderer can run without DSI lock doDsiRenderLock = getBooleanProperty("j3d.renderLock", doDsiRenderLock, "render lock"); @@ -682,6 +718,16 @@ class MasterControl { // create the freelists FreeListManager.createFreeLists(); + + // create an array canvas use registers + // The 32 limit can be lifted once the + // resourceXXXMasks in other classes + // are change not to use integer. + canvasIds = new boolean[32]; + for(int i=0; i<canvasIds.length; i++) { + canvasIds[i] = false; + } + canvasFreeIndex = 0; } private static String getProperty(final String prop) { @@ -728,7 +774,9 @@ class MasterControl { * the MasterControl object is created. */ static void loadLibraries() { - // This works around a native load library bug + assert !librariesLoaded; + + // This works around a native load library bug try { java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); toolkit = null; // just making sure GC collects this @@ -745,37 +793,113 @@ class MasterControl { }); // Load the native J3D library - java.security.AccessController.doPrivileged(new + final String oglLibraryName = "j3dcore-ogl"; + final String d3dLibraryName = "j3dcore-d3d"; + final String libraryName = (String) + java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { public Object run() { - + String libName = oglLibraryName; + + // If it is a Windows OS, we want to support dynamic native library selection (ogl, d3d) String osName = System.getProperty("os.name"); - // System.err.println(" os.name is " + osName ); - // If it is a Windows OS, we want to support - // dynamic native library selection (ogl, d3d) - if((osName.length() > 8) && - ((osName.substring(0,7)).equals("Windows"))){ - - // TODO : Will support a more flexible dynamic - // selection scheme via the use of Preferences API. + if (osName != null && osName.startsWith("Windows")) { + // XXXX : Should eventually support a more flexible dynamic + // selection scheme via an API call. String str = System.getProperty("j3d.rend"); - if ((str == null) || (!str.equals("d3d"))) { - // System.err.println("(1) ogl case : j3d.rend is " + str ); - System.loadLibrary("j3dcore-ogl"); - - } - else { - // System.err.println("(2) d3d case : j3d.rend is " + str); - System.loadLibrary("j3dcore-d3d"); + if (str != null && str.equals("d3d")) { + libName = d3dLibraryName; } } - else { - // System.err.println("(3) ogl case"); - System.loadLibrary("j3dcore-ogl"); - } - return null; + + System.loadLibrary(libName); + return libName; } }); + + // Get the global j3d.shadingLanguage 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); + } + } + + // Check whether the Cg library is available + if (globalShadingLanguage == Shader.SHADING_LANGUAGE_CG) { + String cgLibraryName = libraryName + "-cg"; + String[] libpath = setupLibPath(systemPathProps, cgLibraryName); + if (loadNativeCgLibrary(libpath)) { + cgLibraryAvailable = true; + } + } + + // Check whether the GLSL library is available + if (globalShadingLanguage == Shader.SHADING_LANGUAGE_GLSL) { + if (libraryName == oglLibraryName) { + // No need to verify that GLSL is available, since GLSL is part + // of OpenGL as an extension (or part of core in 2.0) + glslLibraryAvailable = true; + } + } + + assert !(glslLibraryAvailable && cgLibraryAvailable) : + "ERROR: cannot support both GLSL and CG at the same time"; + + librariesLoaded = true; + } + + + /** + * Parse the specified System properties containing a PATH and return an + * array of Strings, where each element is an absolute filename consisting of + * the individual component of the path concatenated with the (relative) + * library file name. Only those absolute filenames that exist are included. + * If no absolute filename is found, we will try the relative library name. + */ + private static String[] setupLibPath(String[] props, String libName) { + ArrayList pathList = new ArrayList(); + + String filename = System.mapLibraryName(libName); + for (int n = 0; n < props.length; n++) { + String pathString = getProperty(props[n]); + boolean done = false; + int posStart = 0; + while (!done) { + int posEnd = pathString.indexOf(File.pathSeparator, posStart); + if (posEnd == -1) { + posEnd = pathString.length(); + done = true; + } + String pathDir = pathString.substring(posStart, posEnd); + File pathFile = new File(pathDir, filename); + if (pathFile.exists()) { + pathList.add(pathFile.getAbsolutePath()); + } + + posStart = posEnd + 1; + } + } + + // If no absolute path names exist, add in the relative library name + if (pathList.size() == 0) { + pathList.add(filename); + } + + return (String[])pathList.toArray(new String[0]); } @@ -837,6 +961,14 @@ class MasterControl { 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 @@ -900,28 +1032,39 @@ class MasterControl { FreeListManager.freeObject(FreeListManager.TEXTURE3D, new Integer(id)); } - int getCanvasBit() { - // Master control need to keep count itself - MemoryFreeList cbId = - FreeListManager.getFreeList(FreeListManager.CANVASBIT); - if (cbId.size() > 0) { - return ((Integer)FreeListManager. - getObject(FreeListManager.CANVASBIT)).intValue(); - } - else { - if (canvasBitCount > 31) { + 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 ( canvasFreeIndex >= canvasIds.length) { throw new RuntimeException("Cannot render to more than 32 Canvas3Ds"); } - return (1 << canvasBitCount++); + + canvasIds[i] = true; + canvasFreeIndex = i + 1; } + + return i; + } + void freeCanvasId(int canvasId) { + // Valid range is [0, 31] + synchronized(canvasIdLock) { - void freeCanvasBit(int canvasBit) { - FreeListManager.freeObject(FreeListManager.CANVASBIT, - new Integer(canvasBit)); + canvasIds[canvasId] = false; + if(canvasFreeIndex > canvasId) { + canvasFreeIndex = canvasId; + } + } } - + Transform3D getTransform3D(Transform3D val) { Transform3D t; t = (Transform3D) @@ -1096,6 +1239,10 @@ class MasterControl { timerThread.finish(); timerThread = null; } + if (notificationThread != null) { + notificationThread.finish(); + notificationThread = null; + } requestObjList.clear(); requestTypeList.clear(); return true; @@ -1210,7 +1357,14 @@ class MasterControl { } setWork(); } - + + /** + * This takes the specified notification message and sends it to the + * notification thread for processing. + */ + void sendNotification(J3dNotification notification) { + notificationThread.addNotification(notification); + } /** * Create and start the MasterControl Thread. @@ -2050,6 +2204,19 @@ class MasterControl { } }); timerThread.start(); + + // Create notification thread + java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Object run() { + synchronized (rootThreadGroup) { + notificationThread = new NotificationThread(rootThreadGroup); + notificationThread.setPriority(threadPriority); + } + return null; + } + }); + notificationThread.start(); } /** @@ -2099,6 +2266,10 @@ class MasterControl { timerThread.finish(); timerThread = null; } + if (notificationThread != null) { + notificationThread.finish(); + notificationThread = null; + } // shouldn't all of these be synchronized ??? synchronized (VirtualUniverse.mc.deviceScreenMap) { @@ -2112,8 +2283,11 @@ class MasterControl { // list here because other structure may release them // later - FreeListManager.clearList(FreeListManager.CANVASBIT); - canvasBitCount = 0; + for(int i=0; i<canvasIds.length; i++) { + canvasIds[i] = false; + } + canvasFreeIndex = 0; + renderOnceList.clear(); timestampUpdateList.clear(); @@ -3441,7 +3615,7 @@ class MasterControl { static { /* // Determine whether the JVM is version JDK1.5 or later. - // TODO: replace this with code that checks for the existence + // XXXX: replace this with code that checks for the existence // of a class or method that is defined in 1.5, but not in 1.4 String versionString = (String) java.security.AccessController.doPrivileged( diff --git a/src/classes/share/javax/media/j3d/Material.java b/src/classes/share/javax/media/j3d/Material.java index d35c1d5..deacac9 100644 --- a/src/classes/share/javax/media/j3d/Material.java +++ b/src/classes/share/javax/media/j3d/Material.java @@ -103,7 +103,11 @@ public class Material extends NodeComponent { */ public static final int AMBIENT_AND_DIFFUSE = 4; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_COMPONENT_READ + }; + /** * Constructs and initializes a Material object using default parameters. * The default values are as follows: @@ -119,6 +123,8 @@ public class Material extends NodeComponent { */ public Material() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -139,7 +145,10 @@ public class Material extends NodeComponent { Color3f diffuseColor, Color3f specularColor, float shininess) { - ((MaterialRetained)this.retained).createMaterial(ambientColor, + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((MaterialRetained)this.retained).createMaterial(ambientColor, emissiveColor, diffuseColor, specularColor, shininess); } @@ -602,7 +611,8 @@ public class Material extends NodeComponent { * Capability read bit set will be displayed. */ public String toString() { - StringBuffer str=new StringBuffer("Material Object:"); + StringBuffer str = new StringBuffer(getNamePrefix()); + str.append("javax.media.j3d.Material: "); Color3f color=new Color3f(); try { getAmbientColor(color); diff --git a/src/classes/share/javax/media/j3d/MediaContainer.java b/src/classes/share/javax/media/j3d/MediaContainer.java index 10e1502..e2c6e39 100644 --- a/src/classes/share/javax/media/j3d/MediaContainer.java +++ b/src/classes/share/javax/media/j3d/MediaContainer.java @@ -60,6 +60,12 @@ public class MediaContainer extends NodeComponent { public static final int ALLOW_URL_WRITE = CapabilityBits.MEDIA_CONTAINER_ALLOW_URL_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_CACHE_READ, + ALLOW_URL_READ + }; + /** * Constructs a MediaContainer object with default parameters. * The default values are as follows: @@ -72,6 +78,8 @@ public class MediaContainer extends NodeComponent { */ public MediaContainer() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -81,6 +89,9 @@ public class MediaContainer extends NodeComponent { * @exception SoundException if the URL is not valid or cannot be opened */ public MediaContainer(String path) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((MediaContainerRetained)this.retained).setURLString(path); } @@ -91,6 +102,9 @@ public class MediaContainer extends NodeComponent { * @exception SoundException if the URL is not valid or cannot be opened */ public MediaContainer(URL url) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((MediaContainerRetained)this.retained).setURLObject(url); } @@ -102,6 +116,9 @@ public class MediaContainer extends NodeComponent { * @since Java 3D 1.2 */ public MediaContainer(InputStream stream) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((MediaContainerRetained)this.retained).setInputStream(stream); } diff --git a/src/classes/share/javax/media/j3d/MediaContainerRetained.java b/src/classes/share/javax/media/j3d/MediaContainerRetained.java index 19f2547..f120902 100644 --- a/src/classes/share/javax/media/j3d/MediaContainerRetained.java +++ b/src/classes/share/javax/media/j3d/MediaContainerRetained.java @@ -141,7 +141,7 @@ class MediaContainerRetained extends NodeComponentRetained { * @param stream InputStream that references the sound data */ void setInputStream(InputStream stream, boolean forceLoad) { - // %%% TODO AudioDevice not intellegent enough to process InputStreams yet + // XXXX: AudioDevice not intellegent enough to process InputStreams yet // can NOT set stream field unless the other related fields are null if (stream != null) { if (url != null || urlString != null) diff --git a/src/classes/share/javax/media/j3d/ModelClip.java b/src/classes/share/javax/media/j3d/ModelClip.java index 308af79..6895c2d 100644 --- a/src/classes/share/javax/media/j3d/ModelClip.java +++ b/src/classes/share/javax/media/j3d/ModelClip.java @@ -109,7 +109,14 @@ public class ModelClip extends Leaf { public static final int ALLOW_SCOPE_WRITE = CapabilityBits.MODEL_CLIP_ALLOW_SCOPE_WRITE; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SCOPE_READ, + ALLOW_ENABLE_READ, + ALLOW_INFLUENCING_BOUNDS_READ, + ALLOW_PLANE_READ + }; + /** * Constructs a ModelClip node with default parameters. The default * values are as follows: @@ -128,6 +135,9 @@ public class ModelClip extends Leaf { */ public ModelClip() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } @@ -137,7 +147,10 @@ public class ModelClip extends Leaf { * @param planes an array of 6 model clipping planes */ public ModelClip(Vector4d[] planes) { - ((ModelClipRetained)this.retained).initPlanes(planes); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((ModelClipRetained)this.retained).initPlanes(planes); } @@ -149,6 +162,9 @@ public class ModelClip extends Leaf { * @param enables an array of 6 enable flags */ public ModelClip(Vector4d[] planes, boolean[] enables) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((ModelClipRetained)this.retained).initPlanes(planes); ((ModelClipRetained)this.retained).initEnables(enables); } diff --git a/src/classes/share/javax/media/j3d/Morph.java b/src/classes/share/javax/media/j3d/Morph.java index 9cabaa8..a03edec 100644 --- a/src/classes/share/javax/media/j3d/Morph.java +++ b/src/classes/share/javax/media/j3d/Morph.java @@ -77,6 +77,8 @@ import javax.vecmath.*; * <i>before</i> the indexes are applied. Only the indexes in the * first geometry array (geometry[0]) are used when rendering the * geometry. + * + * @deprecated As of Java 3D version 1.4. */ public class Morph extends Leaf { @@ -149,9 +151,19 @@ public class Morph extends Leaf { public static final int ALLOW_APPEARANCE_OVERRIDE_WRITE = CapabilityBits.MORPH_ALLOW_APPEARANCE_OVERRIDE_WRITE; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_GEOMETRY_ARRAY_READ, + ALLOW_APPEARANCE_READ, + ALLOW_WEIGHTS_READ, + ALLOW_COLLISION_BOUNDS_READ, + ALLOW_APPEARANCE_OVERRIDE_READ + }; + // non public default constructor Morph() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -171,6 +183,7 @@ public class Morph extends Leaf { * a null or zero-length array of GeometryArray objects is * permitted, and specifies that no geometry is drawn. In this case, * the array of weights is initialized to a zero-length array. + * * @exception IllegalArgumentException if any of the specified * geometry array objects differ from each other in any of the * following ways: @@ -187,19 +200,28 @@ public class Morph extends Leaf { * (coord, color, normal, texcoord), * for indexed geometry by-reference</li> * </ul> + * + * @exception UnsupportedOperationException if the specified + * geometry arrays contain vertex attributes (that is, if their + * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag). */ public Morph(GeometryArray geometryArrays[]) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((MorphRetained)retained).setGeometryArrays(geometryArrays); } /** * Constructs and initializes a Morph node with the specified array * of GeometryArray objects and the specified appearance object. + * * @param geometryArrays the geometry components of the Morph node * a null or zero-length array of GeometryArray objects is * permitted, and specifies that no geometry is drawn. In this case, * the array of weights is initialized to a zero-length array. * @param appearance the appearance component of the Morph node + * * @exception IllegalArgumentException if any of the specified * geometry array objects differ from each other in any of the * following ways: @@ -216,9 +238,16 @@ public class Morph extends Leaf { * (coord, color, normal, texcoord), * for indexed geometry by-reference</li> * </ul> + * + * @exception UnsupportedOperationException if the specified + * geometry arrays contain vertex attributes (that is, if their + * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag). */ public Morph(GeometryArray geometryArrays[], Appearance appearance) { - ((MorphRetained)retained).setGeometryArrays(geometryArrays); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((MorphRetained)retained).setGeometryArrays(geometryArrays); ((MorphRetained)this.retained).setAppearance(appearance); } @@ -303,6 +332,10 @@ public class Morph extends Leaf { * (coord, color, normal, texcoord), * for indexed geometry by-reference</li> * </ul> + * + * @exception UnsupportedOperationException if the specified + * geometry arrays contain vertex attributes (that is, if their + * vertexFormat includes the <code>VERTEX_ATTRIBUTES</code> flag). */ public void setGeometryArrays(GeometryArray geometryArrays[]) { @@ -642,7 +675,8 @@ public class Morph extends Leaf { // have the bit set. private void checkForAllowIntersect() { MorphRetained morphR = ((MorphRetained)this.retained); - for (int i = 0; i < morphR.numGeometryArrays; i++) { + int numGeometryArrays = morphR.getNumGeometryArrays(); + for (int i = 0; i < numGeometryArrays; i++) { if (!morphR.geometryArrays[i].source. getCapability(Geometry.ALLOW_INTERSECT)) { diff --git a/src/classes/share/javax/media/j3d/MorphRetained.java b/src/classes/share/javax/media/j3d/MorphRetained.java index 34633f7..351122f 100644 --- a/src/classes/share/javax/media/j3d/MorphRetained.java +++ b/src/classes/share/javax/media/j3d/MorphRetained.java @@ -56,7 +56,7 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { */ GeometryArrayRetained geometryArrays[]; - int numGeometryArrays = 0; + private int numGeometryArrays = 0; /** * The weight vector the morph node. @@ -200,6 +200,13 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { } doErrorCheck(prevGeo, geo); } + + // Check the first one for vertex attributes + geo = (GeometryArrayRetained)geometryArrays[0].retained; + if ((geo.vertexFormat & GeometryArray.VERTEX_ATTRIBUTES) != 0) { + throw new UnsupportedOperationException(J3dI18N.getString("MorphRetained9")); + } + // Check if the first one is in Immediate context if (geometryArrays[0] != null) { geo = (GeometryArrayRetained)geometryArrays[0].retained; @@ -452,8 +459,58 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { boolean getAppearanceOverrideEnable() { return appearanceOverrideEnable; } + + boolean intersect(PickInfo pickInfo, PickShape pickShape, int flags ) { + + Transform3D localToVworld = pickInfo.getLocalToVWorldRef(); + + Transform3D vworldToLocal = new Transform3D(); + vworldToLocal.invert(localToVworld); + PickShape newPS = pickShape.transform(vworldToLocal); + GeometryRetained geo = (GeometryRetained) (morphedGeometryArray.retained); + if (geo.mirrorGeometry != null) { + geo = geo.mirrorGeometry; + } + + if (((flags & PickInfo.CLOSEST_INTERSECTION_POINT) == 0) && + ((flags & PickInfo.CLOSEST_DISTANCE) == 0) && + ((flags & PickInfo.CLOSEST_GEOM_INFO) == 0) && + ((flags & PickInfo.ALL_GEOM_INFO) == 0)) { + return geo.intersect(newPS, null, 0, null); + } else { + Point3d closestIPnt = new Point3d(); + Point3d iPnt = new Point3d(); + Point3d iPntVW = new Point3d(); + PickInfo.IntersectionInfo intersectionInfo + = pickInfo.createIntersectionInfo(); + + if (geo.intersect(newPS, intersectionInfo, flags, iPnt)) { + + iPntVW.set(iPnt); + localToVworld.transform(iPntVW); + double distance = pickShape.distance(iPntVW); + if ((flags & PickInfo.CLOSEST_DISTANCE) != 0) { + pickInfo.setClosestDistance(distance); + } + if((flags & PickInfo.CLOSEST_INTERSECTION_POINT) != 0) { + pickInfo.setClosestIntersectionPoint(iPnt); + } else if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + intersectionInfo.setGeometry((Geometry) geo.source); + intersectionInfo.setGeometryIndex(0); + intersectionInfo.setIntersectionPoint(iPnt); + intersectionInfo.setDistance(distance); + // VertexIndices has been computed in intersect method. + pickInfo.insertIntersectionInfo(intersectionInfo); + } + return true; + } + } + return false; + } + + /** * Check if the geometry component of this shape node under path * intersects with the pickShape. @@ -461,48 +518,38 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { * contains the closest distance of intersection if it is not * equal to null. */ - boolean intersect(SceneGraphPath path, PickShape pickShape, - double[] dist) { - + boolean intersect(SceneGraphPath path, + PickShape pickShape, double[] dist) { + // This method will not do bound intersect check, as it assume caller // has already done that. ( For performance and code simplification // reasons. ) - Transform3D localToVworld = path.getTransform(); - + int flags; + PickInfo pickInfo = new PickInfo(); + + Transform3D localToVworld = path.getTransform(); if (localToVworld == null) { throw new RuntimeException(J3dI18N.getString("MorphRetained5")); } - Transform3D vworldToLocal = VirtualUniverse.mc.getTransform3D(null); - vworldToLocal.invert(localToVworld); - PickShape newPS = pickShape.transform(vworldToLocal); - FreeListManager.freeObject(FreeListManager.TRANSFORM3D, vworldToLocal); - - Point3d iPnt = Shape3DRetained.getPoint3d(); - - GeometryRetained geo = (GeometryRetained) (morphedGeometryArray.retained); - - if (geo.mirrorGeometry != null) { - geo = geo.mirrorGeometry; - } - - boolean isIntersect; - if (dist != null) { - isIntersect = geo.intersect(newPS, dist, iPnt); - if (isIntersect) { - // compute the real distance since the dist return - // above distance may scaled (non-uniform) by transform3d - localToVworld.transform(iPnt); - dist[0] = pickShape.distance(iPnt); - } - } else { - isIntersect = geo.intersect(newPS, null, iPnt); - } - Shape3DRetained.freePoint3d(iPnt); - return isIntersect; - } - + pickInfo.setLocalToVWorldRef( localToVworld); + //System.out.println("MorphRetained.intersect() : "); + if (dist == null) { + //System.out.println(" no dist request ...."); + return intersect(pickInfo, pickShape, 0); + } + + flags = PickInfo.CLOSEST_DISTANCE; + if (intersect(pickInfo, pickShape, flags)) { + dist[0] = pickInfo.getClosestDistance(); + return true; + } + + return false; + + } + /** * Sets the Morph node's weight vector * @param wieghts the new vector of weights for the morph node @@ -571,8 +618,8 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { } else { return super.getBounds(); } - } - + } + Bounds getEffectiveBounds() { if(boundsAutoCompute) { return getBounds(); @@ -604,6 +651,11 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { } } + // Return the number of geometry arrays in this MorphRetained object. + int getNumGeometryArrays() { + return numGeometryArrays; + } + // If the geometry of a morph changes, make sure that the // validVertexCount has not changed void updateMorphedGeometryArray(GeometryArrayRetained geo, boolean coordinatesChanged) { @@ -1767,8 +1819,8 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { } if ((vFormat & GeometryArray.TEXTURE_COORDINATE) != 0) { for (k = 0; k < texCoordSetCount; k++) { - morphedGeo.setTextureCoordinateIndices(k, 0, - (int[]) igeo.indexTexCoord[k]); + morphedGeo.setTextureCoordinateIndices(k, 0, + igeo.indexTexCoord[k]); } } } @@ -1797,7 +1849,7 @@ class MorphRetained extends LeafRetained implements GeometryUpdater { super.compile(compState); - // TODO: for now keep the static transform in the parent tg + // XXXX: for now keep the static transform in the parent tg compState.keepTG = true; if (J3dDebug.devPhase && J3dDebug.debug) { diff --git a/src/classes/share/javax/media/j3d/Node.java b/src/classes/share/javax/media/j3d/Node.java index 9be9ab3..3853a63 100644 --- a/src/classes/share/javax/media/j3d/Node.java +++ b/src/classes/share/javax/media/j3d/Node.java @@ -109,7 +109,34 @@ public abstract class Node extends SceneGraphObject { */ public static final int ALLOW_LOCAL_TO_VWORLD_READ = CapabilityBits.NODE_ALLOW_LOCAL_TO_VWORLD_READ; - + + /** + * Specifies that this Node allows read access to its parent Group node. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_PARENT_READ = CapabilityBits.NODE_ALLOW_PARENT_READ; + + /** + * Specifies that this Node allows read access to its Locale. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_LOCALE_READ = CapabilityBits.NODE_ALLOW_LOCALE_READ; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_BOUNDS_READ, + ALLOW_PICKABLE_READ, + ALLOW_COLLIDABLE_READ, + ALLOW_AUTO_COMPUTE_BOUNDS_READ, + ALLOW_LOCAL_TO_VWORLD_READ, + ALLOW_PARENT_READ, + ALLOW_LOCALE_READ + }; + // for checking for cycles private boolean visited = false; @@ -125,18 +152,22 @@ public abstract class Node extends SceneGraphObject { * </ul> */ public Node() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** - * Retrieves the parent of this Node. This method is only valid - * during the construction of the scene graph. + * @return the parent of this node, or null if this node has no parent - * @exception RestrictedAccessException if this object is part of live - * or compiled scene graph + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph */ public Node getParent() { - if (isLiveOrCompiled()) - throw new RestrictedAccessException(J3dI18N.getString("Node0")); + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_PARENT_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("Node0")); + } + } NodeRetained nr = ((NodeRetained)this.retained).getParent(); return (nr == null ? null : (Node) nr.getSource()); @@ -245,24 +276,36 @@ public abstract class Node extends SceneGraphObject { * of all transforms in the scene graph from the root down to * <code>this</code> node. It is only valid * for nodes that are part of a live scene graph. + * If the node is not part of a live scene graph then the coordinates are + * calculated as if the graph was attached at the origin of a locale. * @param t the object that will receive the local coordinates to * Vworld coordinates transform. - * @exception RestrictedAccessException if the node is <em>not</em> + * @exception RestrictedAccessException if the node is compiled but not * part of a live scene graph * @exception CapabilityNotSetException if appropriate capability is - * not set and this node is part of live scene graph + * not set and this node is part of live or compiled scene graph * @exception IllegalSharingException if the node is a descendant * of a SharedGroup node. */ public void getLocalToVworld(Transform3D t) { - if (!isLive()) - throw new RestrictedAccessException(J3dI18N.getString("Node7")); - - if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) - throw new CapabilityNotSetException(J3dI18N.getString("Node8")); - - ((NodeRetained)this.retained).getLocalToVworld(t); + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("Node8")); + } + + if (!isLive()) { + // TODO Support compiled graphs + if (isCompiled()) + throw new RestrictedAccessException(J3dI18N.getString("Node7")); + + // In 1.4 we support getLocalToVworld for non live nodes + ((NodeRetained)this.retained).computeNonLiveLocalToVworld(t, this); + //throw new RestrictedAccessException(J3dI18N.getString("Node7")); + } else { + ((NodeRetained)this.retained).getLocalToVworld(t); + } } + /** * Retrieves the local coordinates to virtual world coordinates @@ -281,15 +324,44 @@ public abstract class Node extends SceneGraphObject { * @exception IllegalArgumentException if the specified path does * not contain a valid Locale, or if the last node in the path is * different from this node + * @exception IllegalSharingException if the node is not a descendant + * of a SharedGroup node. */ public void getLocalToVworld(SceneGraphPath path, Transform3D t) { - if (!isLive()) + if (!isLive()) { throw new RestrictedAccessException(J3dI18N.getString("Node7")); - - if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) - throw new CapabilityNotSetException(J3dI18N.getString("Node8")); + } + + if(!this.getCapability(ALLOW_LOCAL_TO_VWORLD_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("Node8")); ((NodeRetained)this.retained).getLocalToVworld(path,t); + + } + + /** + * Retrieves the locale to which this node is attached. If the + * node is not part of a live scene graph, null is returned. + * + * @return the locale to which this node is attached. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this node is part of live scene graph + * @exception IllegalSharingException if the node is a descendant + * of a SharedGroup node. + * + * @since Java 3D 1.4 + */ + public Locale getLocale() { + if (!isLive()) { + return null; + } + + if(!this.getCapability(ALLOW_LOCALE_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("Node17")); + } + + return ((NodeRetained)this.retained).getLocale(); } /** diff --git a/src/classes/share/javax/media/j3d/NodeData.java b/src/classes/share/javax/media/j3d/NodeData.java index 90505e2..5c927c6 100644 --- a/src/classes/share/javax/media/j3d/NodeData.java +++ b/src/classes/share/javax/media/j3d/NodeData.java @@ -15,7 +15,7 @@ package javax.media.j3d; class NodeData { // per path node data - // TODO: replace per path mirror objects with node data - // TODO: move other basic node's data here + // XXXX: replace per path mirror objects with node data + // XXXX: move other basic node's data here SwitchState switchState = null; } diff --git a/src/classes/share/javax/media/j3d/NodeRetained.java b/src/classes/share/javax/media/j3d/NodeRetained.java index de91ce4..a8d9467 100644 --- a/src/classes/share/javax/media/j3d/NodeRetained.java +++ b/src/classes/share/javax/media/j3d/NodeRetained.java @@ -374,7 +374,26 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { return; } - + /** + * Compute the LocalToVworld of this node even though it is not live. We + * assume the graph is attached at the origin of a locale + */ + void computeNonLiveLocalToVworld(Transform3D t, Node caller) { + NodeRetained n = getParent(); + + if (n==null) + t.setIdentity(); + else + n.computeNonLiveLocalToVworld(t, caller); + + if (this instanceof TransformGroupRetained && this.source!=caller) { + Transform3D trans = new Transform3D(); + ((TransformGroupRetained)this).getTransform(trans); + t.mul(trans); + } + + } + /** * Get the localToVworld transform for a node. */ @@ -413,7 +432,19 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { HashKey newKey = new HashKey(key); computeLocalToVworld(this, this, newKey, t); } - + + + /** + * Get the Locale to which the node is attached + */ + Locale getLocale() { + if (inSharedGroup) { + throw new IllegalSharingException(J3dI18N.getString("NodeRetained0")); + } + + return locale; + } + /** * Get the current localToVworld transform for a node @@ -868,6 +899,7 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { boolean isStatic() { if (source.getCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ) || + source.getCapability(Node.ALLOW_PARENT_READ) || source.getCapability(Node.ENABLE_PICK_REPORTING) || source.getCapability(Node.ENABLE_COLLISION_REPORTING) || source.getCapability(Node.ALLOW_BOUNDS_READ) || diff --git a/src/classes/share/javax/media/j3d/NotificationThread.java b/src/classes/share/javax/media/j3d/NotificationThread.java new file mode 100644 index 0000000..1d7a44f --- /dev/null +++ b/src/classes/share/javax/media/j3d/NotificationThread.java @@ -0,0 +1,120 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.LinkedList; + +/** + * The NotificationThread class is used for asynchronous error notification, + * such as notifying ShaderError listeners. + */ +class NotificationThread extends Thread { + // action flag for runMonitor + private static final int WAIT = 0; + private static final int NOTIFY = 1; + private static final int STOP = 2; + + private volatile boolean running = true; + private boolean waiting = false; + private boolean ready = false; + + private LinkedList notificationQueue = new LinkedList(); + + /** + * Creates a new instance of NotificationThread + */ + NotificationThread(ThreadGroup t) { + // Only one notification thread for the entire system + super(t, "J3D-NotificationThread"); + } + + /** + * Adds a notification message to the queue + */ + synchronized void addNotification(J3dNotification n) { + notificationQueue.add(n); + runMonitor(NOTIFY); + } + + /** + * Gets the list of queued notification messages + */ + private synchronized J3dNotification[] getNotifications() { + J3dNotification[] notifications = (J3dNotification[])notificationQueue.toArray(new J3dNotification[0]); + notificationQueue.clear(); + return notifications; + } + + /** + * Processes all pending notification messages + */ + private void processNotifications() { + J3dNotification[] notifications = getNotifications(); + + for (int i = 0; i < notifications.length; i++) { + J3dNotification n = notifications[i]; + switch (n.type) { + case J3dNotification.SHADER_ERROR: + n.universe.notifyShaderErrorListeners((ShaderError)n.args[0]); + break; + default: + System.err.println("J3dNotification.processNotifications: unrecognized type = " + n.type); + } + } + } + + // Called from MasterControlThread + void finish() { + runMonitor(STOP); + } + + public void run() { + while (running) { + runMonitor(WAIT); + + processNotifications(); + } +// System.err.println("Notification thread finished"); + } + + + private synchronized void runMonitor(int action) { + switch (action) { + case WAIT: + while (running && !ready) { + waiting = true; + try { + wait(); + } catch (InterruptedException e) { + } + waiting = false; + } + ready = false; + break; + case NOTIFY: + ready = true; + if (waiting) { + notify(); + } + break; + case STOP: + running = false; + notify(); + break; + default: + // Should never get here... + assert(false); + } + } + +} diff --git a/src/classes/share/javax/media/j3d/OrderedGroup.java b/src/classes/share/javax/media/j3d/OrderedGroup.java index e3d4e87..1ffdd93 100644 --- a/src/classes/share/javax/media/j3d/OrderedGroup.java +++ b/src/classes/share/javax/media/j3d/OrderedGroup.java @@ -72,6 +72,10 @@ public class OrderedGroup extends Group { public static final int ALLOW_CHILD_INDEX_ORDER_WRITE = CapabilityBits.ORDERED_GROUP_ALLOW_CHILD_INDEX_ORDER_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_CHILD_INDEX_ORDER_READ + }; /** * Constructs and initializes a new OrderedGroup node object. @@ -79,6 +83,8 @@ public class OrderedGroup extends Group { * that its children are rendered in increasing index order. */ public OrderedGroup() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } diff --git a/src/classes/share/javax/media/j3d/OrientedShape3D.java b/src/classes/share/javax/media/j3d/OrientedShape3D.java index bea85dd..478eb71 100644 --- a/src/classes/share/javax/media/j3d/OrientedShape3D.java +++ b/src/classes/share/javax/media/j3d/OrientedShape3D.java @@ -144,6 +144,14 @@ public class OrientedShape3D extends Shape3D { CapabilityBits.ORIENTED_SHAPE3D_ALLOW_SCALE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_MODE_READ, + ALLOW_AXIS_READ, + ALLOW_POINT_READ, + ALLOW_SCALE_READ + }; + /** * Constructs an OrientedShape3D node with default parameters. * The default values are as follows: @@ -157,6 +165,8 @@ public class OrientedShape3D extends Shape3D { */ public OrientedShape3D() { super(); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } @@ -182,6 +192,10 @@ public class OrientedShape3D extends Shape3D { Vector3f axis) { super(geometry, appearance); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((OrientedShape3DRetained)retained).initAlignmentMode(mode); ((OrientedShape3DRetained)retained).initAlignmentAxis(axis); } @@ -203,6 +217,10 @@ public class OrientedShape3D extends Shape3D { Point3f point) { super(geometry, appearance); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((OrientedShape3DRetained)retained).initAlignmentMode(mode); ((OrientedShape3DRetained)retained).initRotationPoint(point); @@ -240,6 +258,9 @@ public class OrientedShape3D extends Shape3D { super(geometry, appearance); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((OrientedShape3DRetained)retained).initAlignmentMode(mode); ((OrientedShape3DRetained)retained).initAlignmentAxis(axis); ((OrientedShape3DRetained)retained). @@ -272,6 +293,9 @@ public class OrientedShape3D extends Shape3D { super(geometry, appearance); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((OrientedShape3DRetained)retained).initAlignmentMode(mode); ((OrientedShape3DRetained)retained).initRotationPoint(point); ((OrientedShape3DRetained)retained). diff --git a/src/classes/share/javax/media/j3d/PhysicalBody.java b/src/classes/share/javax/media/j3d/PhysicalBody.java index 442e44f..40de532 100644 --- a/src/classes/share/javax/media/j3d/PhysicalBody.java +++ b/src/classes/share/javax/media/j3d/PhysicalBody.java @@ -128,7 +128,7 @@ public class PhysicalBody extends Object { synchronized void notifyUsers() { for (int i=users.size()-1; i>=0; i--) { View view = (View)users.get(i); - // TODO: notifyUsers should have a parameter denoting field changed + // XXXX: notifyUsers should have a parameter denoting field changed if (view.soundScheduler != null) { view.soundScheduler.setListenerFlag( SoundScheduler.EAR_POSITIONS_CHANGED | diff --git a/src/classes/share/javax/media/j3d/PickConeRay.java b/src/classes/share/javax/media/j3d/PickConeRay.java index ebc2d6a..7821e1e 100644 --- a/src/classes/share/javax/media/j3d/PickConeRay.java +++ b/src/classes/share/javax/media/j3d/PickConeRay.java @@ -204,7 +204,7 @@ public final class PickConeRay extends PickCone { double distToEdge; for (i=0;i<ptope.nVerts;i++) { for (j=i;i<ptope.nVerts;i++) { - // TODO: make BoundingPolytope.pointInPolytope available to package + // XXXX: make BoundingPolytope.pointInPolytope available to package // scope midpt.x = (ptope.verts[i].x + ptope.verts[j].x) * 0.5; midpt.y = (ptope.verts[i].y + ptope.verts[j].y) * 0.5; diff --git a/src/classes/share/javax/media/j3d/PickConeSegment.java b/src/classes/share/javax/media/j3d/PickConeSegment.java index fe2c45b..11adb80 100644 --- a/src/classes/share/javax/media/j3d/PickConeSegment.java +++ b/src/classes/share/javax/media/j3d/PickConeSegment.java @@ -233,7 +233,7 @@ public final class PickConeSegment extends PickCone { double distToEdge; for (i=0;i<ptope.nVerts;i++) { for (j=i;i<ptope.nVerts;i++) { - // TODO: make BoundingPolytope.pointInPolytope available to package + // XXXX: make BoundingPolytope.pointInPolytope available to package // scope midpt.x = (ptope.verts[i].x + ptope.verts[j].x) * 0.5; midpt.y = (ptope.verts[i].y + ptope.verts[j].y) * 0.5; diff --git a/src/classes/share/javax/media/j3d/PickCylinder.java b/src/classes/share/javax/media/j3d/PickCylinder.java index 9d805eb..1a624f9 100644 --- a/src/classes/share/javax/media/j3d/PickCylinder.java +++ b/src/classes/share/javax/media/j3d/PickCylinder.java @@ -71,7 +71,7 @@ public abstract class PickCylinder extends PickShape { // This is a duplicate of the same method, declared private inside of // BoundingPolytope - // TODO: remove this once the original method is available (public) in + // XXXX: remove this once the original method is available (public) in // BoundingPolytope static boolean pointInPolytope(BoundingPolytope ptope, double x, double y, double z ){ diff --git a/src/classes/share/javax/media/j3d/PickCylinderRay.java b/src/classes/share/javax/media/j3d/PickCylinderRay.java index 2fb33b1..6b5266f 100644 --- a/src/classes/share/javax/media/j3d/PickCylinderRay.java +++ b/src/classes/share/javax/media/j3d/PickCylinderRay.java @@ -185,7 +185,7 @@ public final class PickCylinderRay extends PickCylinder { double distToEdge; for (i=0;i<ptope.nVerts;i++) { for (j=i;i<ptope.nVerts;i++) { - // TODO: make BoundingPolytope.pointInPolytope available to package + // XXXX: make BoundingPolytope.pointInPolytope available to package // scope midpt.x = (ptope.verts[i].x + ptope.verts[j].x) * 0.5; midpt.y = (ptope.verts[i].y + ptope.verts[j].y) * 0.5; diff --git a/src/classes/share/javax/media/j3d/PickCylinderSegment.java b/src/classes/share/javax/media/j3d/PickCylinderSegment.java index 37bb1a7..6f03cd0 100644 --- a/src/classes/share/javax/media/j3d/PickCylinderSegment.java +++ b/src/classes/share/javax/media/j3d/PickCylinderSegment.java @@ -205,7 +205,7 @@ public final class PickCylinderSegment extends PickCylinder { double distToEdge; for (i=0;i<ptope.nVerts;i++) { for (j=i;i<ptope.nVerts;i++) { - // TODO: make BoundingPolytope.pointInPolytope available to package + // XXXX: make BoundingPolytope.pointInPolytope available to package // scope midpt.x = (ptope.verts[i].x + ptope.verts[j].x) * 0.5; midpt.y = (ptope.verts[i].y + ptope.verts[j].y) * 0.5; diff --git a/src/classes/share/javax/media/j3d/PickInfo.java b/src/classes/share/javax/media/j3d/PickInfo.java new file mode 100644 index 0000000..64a6392 --- /dev/null +++ b/src/classes/share/javax/media/j3d/PickInfo.java @@ -0,0 +1,1056 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; +import java.util.*; + +/** + * The PickInfo object contains the computed information about a pick hit. + * The detailed information about each intersection of the PickShape + * with the picked Node can be inquired. The PickInfo object is constructed with + * basic information and more detailed information can be generated by setting the + * appropriate mask to the flag argument in the pick methods of BranchGroup and + * Locale. + * <p> + * + * @see Locale + * @see BranchGroup + * + * @since Java 3D 1.4 + */ + + +public class PickInfo extends Object { + + static final int PICK_ALL = 1; + + static final int PICK_ANY = 2; + + /* The SceneGraphPath of the intersected pickable item */ + private SceneGraphPath sgp; + + /* The intersected pickable node object */ + private Node node; + + /* A copy of LocalToVworld transform of the pickable node */ + private Transform3D l2vw; + + /* The closest intersection point */ + private Point3d closestIntersectionPoint; + + /* Distance between start point of pickShape and closest intersection point */ + private double closestDistance; + + /* An array to store intersection results */ + private IntersectionInfo[] intersectionInfoArr; + + /* The following references are for internal geometry computation use only */ + private ArrayList intersectionInfoList = new ArrayList(); + private boolean intersectionInfoListSorted = false; + private Transform3D l2vwRef; + private Node nodeRef; + + /** + * Specifies a Pick using the bounds of the pickable nodes. + */ + public static final int PICK_BOUNDS = 1; + + /** + * Specifies a Pick using the geometry of the pickable nodes. + */ + public static final int PICK_GEOMETRY = 2; + + /** + * Specifies that this PickInfo returns the computed SceneGraphPath object. + */ + public static final int SCENEGRAPHPATH = 0x01; + + /** + * Specifies that this PickInfo returns the computed intersected Node object. + */ + public static final int NODE = 0x02; + + /** + * Specifies that this PickInfo returns the computed local to vworld transform. + */ + public static final int LOCAL_TO_VWORLD = 0x04; + + /** + * Specifies that this PickInfo returns the closest intersection point. + */ + public static final int CLOSEST_INTERSECTION_POINT = 0x08; + + /** + * Specifies that this PickInfo returns the closest intersection distance. + */ + public static final int CLOSEST_DISTANCE = 0x10; + + /** + * Specifies that this PickInfo returns only the closest intersection + * geometry information. + */ + public static final int CLOSEST_GEOM_INFO = 0x20; + + /** + * Specifies that this PickInfo returns all the closest intersection + * geometry informations. + */ + public static final int ALL_GEOM_INFO = 0x40; + + + /** PickInfo Constructor */ + PickInfo() { + + } + + void setSceneGraphPath(SceneGraphPath sgp) { + this.sgp = sgp; + } + + void setNode(Node node) { + this.node = node; + } + + void setLocalToVWorld(Transform3D l2vw) { + this.l2vw = l2vw; + } + + void setClosestIntersectionPoint(Point3d cIPt) { + this.closestIntersectionPoint = cIPt; + } + + void setClosestDistance(double cDist) { + this.closestDistance = cDist; + } + + void setLocalToVWorldRef(Transform3D l2vwRef) { + this.l2vwRef = l2vwRef; + } + + void setNodeRef(Node nodeRef) { + this.nodeRef = nodeRef; + } + + IntersectionInfo createIntersectionInfo() { + return new IntersectionInfo(); + } + + void insertIntersectionInfo(IntersectionInfo iInfo) { + intersectionInfoList.add(iInfo); + intersectionInfoListSorted = false; + } + + void sortIntersectionInfoArray(IntersectionInfo[] iInfoArr) { + + class Sort { + + IntersectionInfo iInfoArr[]; + + Sort(IntersectionInfo[] iInfoArr) { + // System.out.println("Sort IntersectionInfo ..."); + this.iInfoArr = iInfoArr; + } + + void sorting() { + if (iInfoArr.length < 7) { + // System.out.println(" -- insertSort."); + insertSort(); + } else { + // System.out.println(" -- quicksort."); + quicksort(0, iInfoArr.length-1); + } + } + + // Insertion sort on smallest arrays + final void insertSort() { + for (int i=0; i<iInfoArr.length; i++) { + for (int j=i; j>0 && + (iInfoArr[j-1].distance > iInfoArr[j].distance); j--) { + IntersectionInfo iInfo = iInfoArr[j]; + iInfoArr[j] = iInfoArr[j-1]; + iInfoArr[j-1] = iInfo; + } + } + } + + final void quicksort( int l, int r ) { + int i = l; + int j = r; + double k = iInfoArr[(l+r) / 2].distance; + + do { + while (iInfoArr[i].distance<k) i++; + while (k<iInfoArr[j].distance) j--; + if (i<=j) { + IntersectionInfo iInfo = iInfoArr[i]; + iInfoArr[i] = iInfoArr[j]; + iInfoArr[j] = iInfo; + i++; + j--; + } + } while (i<=j); + + if (l<j) quicksort(l,j); + if (l<r) quicksort(i,r); + } + } + + (new Sort(iInfoArr)).sorting(); + intersectionInfoListSorted = true; + } + + static void sortPickInfoArray(PickInfo[] pickInfoArr) { + + class Sort { + + PickInfo pIArr[]; + + Sort(PickInfo[] pIArr) { + // System.out.println("Sort PickInfo ..."); + this.pIArr = pIArr; + } + + void sorting() { + if (pIArr.length < 7) { + // System.out.println(" -- insertSort."); + insertSort(); + } else { + // System.out.println(" -- quicksort."); + quicksort(0, pIArr.length-1); + } + } + + // Insertion sort on smallest arrays + final void insertSort() { + for (int i=0; i<pIArr.length; i++) { + for (int j=i; j>0 && + (pIArr[j-1].closestDistance > pIArr[j].closestDistance); j--) { + PickInfo pI = pIArr[j]; + pIArr[j] = pIArr[j-1]; + pIArr[j-1] = pI; + } + } + } + + final void quicksort( int l, int r ) { + int i = l; + int j = r; + double k = pIArr[(l+r) / 2].closestDistance; + + do { + while (pIArr[i].closestDistance<k) i++; + while (k<pIArr[j].closestDistance) j--; + if (i<=j) { + PickInfo pI = pIArr[i]; + pIArr[i] = pIArr[j]; + pIArr[j] = pI; + i++; + j--; + } + } while (i<=j); + + if (l<j) quicksort(l,j); + if (l<r) quicksort(i,r); + } + } + + (new Sort(pickInfoArr)).sorting(); + + } + + + /** + * Retrieves the reference to the SceneGraphPath in this PickInfo object. + * @return the SceneGraphPath object, or null if flag is not set with SCENEGRAPHPATH. + * @see Locale + * @see BranchGroup + */ + public SceneGraphPath getSceneGraphPath() { + return sgp; + } + + /** + * Retrieves the reference to the picked node, either a Shape3D or a Morph, in this PickInfo object. + * @return the picked leaf node object, or null if flag is not set with NODE. + * @see Locale + * @see BranchGroup + */ + public Node getNode() { + return node; + } + + /** + * Retrieves the reference to the LocalToVworld transform of the picked node in this PickInfo object. + * @return the local to vworld transform, or null if flag is not set with LOCAL_TO_VWORLD. + * @see Locale + * @see BranchGroup + */ + public Transform3D getLocalToVWorld() { + return l2vw; + } + + /** + * Retrieves the reference to the closest intersection point in this PickInfo object. + * @return the closest intersection point, or null if flag is not set with CLOSEST_INTERSECTION_POINT. + * @see Locale + * @see BranchGroup + */ + public Point3d getClosestIntersectionPoint() { + return closestIntersectionPoint; + } + + /** + * Retrieves the distance between the start point of the pickShape and the closest intersection point. + * @return the closest distance in double, or NaN if flag is not set with CLOSEST_INTERSECTION_POINT. + * Note : If this PickInfo object is returned by either pickClosest or pickAllSorted method, the return + * value is the closest distance in double even if flag is not set with CLOSET_INTERSECTION_POINT. + * @see Locale + * @see BranchGroup + */ + public double getClosestDistance() { + return closestDistance; + } + + Transform3D getLocalToVWorldRef() { + return l2vwRef; + } + + Node getNodeRef() { + return nodeRef; + } + + /** + * Retrieves the reference to the array of intersection results in this PickInfo object. + * @return an array of 1 IntersectionInfo object if flag is to set CLOSEST_GEOM_INFO, + * or an array of <i>N</i> IntersectionInfo objects containing all intersections of + * the picked node in sorted order if flag is to set ALL_GEOM_INFO, or null if neither + * bit is set. + * @see Locale + * @see BranchGroup + */ + public IntersectionInfo[] getIntersectionInfos() { + if (intersectionInfoListSorted == false) { + intersectionInfoArr = new IntersectionInfo[intersectionInfoList.size()]; + intersectionInfoArr = + (IntersectionInfo []) intersectionInfoList.toArray(intersectionInfoArr); + + sortIntersectionInfoArray(intersectionInfoArr); + } + + return intersectionInfoArr; + } + + /** + * Search the path from nodeR up to Locale. + * Return the search path as ArrayList if found. + * Note that the locale will not insert into path. + */ + static ArrayList initSceneGraphPath(NodeRetained nodeR) { + ArrayList path = new ArrayList(5); + + do { + if (nodeR.source.getCapability(Node.ENABLE_PICK_REPORTING)){ + path.add(nodeR); + } + nodeR = nodeR.parent; + } while (nodeR != null); // reach Locale + + return path; + } + + static private Node[] createPath(NodeRetained srcNode, + BranchGroupRetained bgRetained, + GeometryAtom geomAtom, + ArrayList initpath) { + + ArrayList path = retrievePath(srcNode, bgRetained, + geomAtom.source.key); + assert(path != null); + + return mergePath(path, initpath); + + } + + + /** + * Return true if bg is inside cachedBG or bg is null + */ + static private boolean inside(BranchGroupRetained bgArr[], + BranchGroupRetained bg) { + + if ((bg == null) || (bgArr == null)) { + return true; + } + + for (int i=0; i < bgArr.length; i++) { + if (bgArr[i] == bg) { + return true; + } + } + return false; + } + + /** + * search the full path from the bottom of the scene graph - + * startNode, up to the Locale if endNode is null. + * If endNode is not null, the path is found up to, but not + * including, endNode or return null if endNode not hit + * during the search. + */ + static private ArrayList retrievePath(NodeRetained startNode, + NodeRetained endNode, + HashKey key) { + + ArrayList path = new ArrayList(5); + NodeRetained nodeR = startNode; + + if (nodeR.inSharedGroup) { + // getlastNodeId() will destroy this key + key = new HashKey(key); + } + + do { + if (nodeR == endNode) { // we found it ! + return path; + } + + if (nodeR.source.getCapability(Node.ENABLE_PICK_REPORTING)) { + path.add(nodeR); + } + + if (nodeR instanceof SharedGroupRetained) { + // retrieve the last node ID + String nodeId = key.getLastNodeId(); + Vector parents = ((SharedGroupRetained) nodeR).parents; + int sz = parents.size(); + NodeRetained prevNodeR = nodeR; + for(int i=0; i< sz; i++) { + NodeRetained linkR = (NodeRetained) parents.elementAt(i); + if (linkR.nodeId.equals(nodeId)) { + nodeR = linkR; + // Need to add Link to the path report + path.add(nodeR); + // since !(endNode instanceof Link), we + // can skip the check (nodeR == endNode) and + // proceed to parent of link below + break; + } + } + if (nodeR == prevNodeR) { + // branch is already detach + return null; + } + } + nodeR = nodeR.parent; + } while (nodeR != null); // reach Locale + + if (endNode == null) { + // user call pickxxx(Locale locale, PickShape shape) + return path; + } + + // user call pickxxx(BranchGroup endNode, PickShape shape) + // if locale is reached and endNode not hit, this is not + // the path user want to select + return null; + } + + /** + * copy p1, (follow by) p2 into a new array, p2 can be null + * The path is then reverse before return. + */ + static private Node[] mergePath(ArrayList p1, ArrayList p2) { + int s = p1.size(); + int len; + int i; + int l; + if (p2 == null) { + len = s; + } else { + len = s + p2.size(); + } + + Node nodes[] = new Node[len]; + l = len-1; + for (i=0; i < s; i++) { + nodes[l-i] = (Node) ((NodeRetained) p1.get(i)).source; + } + for (int j=0; i< len; i++, j++) { + nodes[l-i] = (Node) ((NodeRetained) p2.get(j)).source; + } + return nodes; + } + + /** + * Sort the GeometryAtoms distance from shape in ascending order + * geomAtoms.length must be >= 1 + */ + static void sortGeomAtoms(GeometryAtom geomAtoms[], + PickShape shape) { + + final double distance[] = new double[geomAtoms.length]; + Point4d pickPos = new Point4d(); + + for (int i=0; i < geomAtoms.length; i++) { + shape.intersect(geomAtoms[i].source.vwcBounds, pickPos); + distance[i] = pickPos.w; + } + + class Sort { + + GeometryAtom atoms[]; + + Sort(GeometryAtom[] atoms) { + this.atoms = atoms; + } + + void sorting() { + if (atoms.length < 7) { + insertSort(); + } else { + quicksort(0, atoms.length-1); + } + } + + // Insertion sort on smallest arrays + final void insertSort() { + for (int i=0; i<atoms.length; i++) { + for (int j=i; j>0 && + (distance[j-1] > distance[j]); j--) { + double t = distance[j]; + distance[j] = distance[j-1]; + distance[j-1] = t; + GeometryAtom p = atoms[j]; + atoms[j] = atoms[j-1]; + atoms[j-1] = p; + } + } + } + + final void quicksort( int l, int r ) { + int i = l; + int j = r; + double k = distance[(l+r) / 2]; + + do { + while (distance[i]<k) i++; + while (k<distance[j]) j--; + if (i<=j) { + double tmp = distance[i]; + distance[i] =distance[j]; + distance[j] = tmp; + + GeometryAtom p=atoms[i]; + atoms[i]=atoms[j]; + atoms[j]=p; + i++; + j--; + } + } while (i<=j); + + if (l<j) quicksort(l,j); + if (l<r) quicksort(i,r); + } + } + + (new Sort(geomAtoms)).sorting(); + } + + + /** + * return all PickInfo[] of the geomAtoms. + * If initpath is null, the path is search from + * geomAtom Shape3D/Morph Node up to Locale + * (assume the same locale). + * Otherwise, the path is search up to node or + * null is return if it is not hit. + */ + static ArrayList getPickInfos(ArrayList initpath, + BranchGroupRetained bgRetained, + GeometryAtom geomAtoms[], + Locale locale, int flags, int pickType) { + + ArrayList pickInfoList = new ArrayList(5); + NodeRetained srcNode; + ArrayList text3dList = null; + + if ((geomAtoms == null) || (geomAtoms.length == 0)) { + return null; + } + + for (int i=0; i < geomAtoms.length; i++) { + assert((geomAtoms[i] != null) && + (geomAtoms[i].source != null)); + + PickInfo pickInfo = null; + Shape3DRetained shape = geomAtoms[i].source; + srcNode = shape.sourceNode; + + if (srcNode == null) { + // The node is just detach from branch so sourceNode = null + continue; + } + + // Special case, for Text3DRetained, it is possible + // for different geomAtoms pointing to the same + // source Text3DRetained. So we need to combine + // those cases and report only once. + if (srcNode instanceof Shape3DRetained) { + Shape3DRetained s3dR = (Shape3DRetained) srcNode; + GeometryRetained geomR = null; + for(int cnt=0; cnt<s3dR.geometryList.size(); cnt++) { + geomR = (GeometryRetained) s3dR.geometryList.get(cnt); + if(geomR != null) + break; + } + + if (geomR == null) + continue; + + if (geomR instanceof Text3DRetained) { + // assume this case is not frequent, we allocate + // ArrayList only when necessary and we use ArrayList + // instead of HashMap since the case of when large + // number of distingish Text3DRetained node hit is + // rare. + if (text3dList == null) { + text3dList = new ArrayList(3); + } else { + int size = text3dList.size(); + boolean found = false; + for (int j=0; j < size; j++) { + if (text3dList.get(j) == srcNode) { + found = true; + break; + } + } + if (found) { + continue; // try next geomAtom + } + } + text3dList.add(srcNode); + } + } + + // If srcNode is instance of compile retained, then loop thru + // the entire source list and add it to the scene graph path + if (srcNode instanceof Shape3DCompileRetained) { + + Shape3DCompileRetained s3dCR = (Shape3DCompileRetained)srcNode; + + Node[] mpath = null; + boolean first = true; + + for (int n = 0; n < s3dCR.srcList.length; n++) { + + pickInfo = null; + + // PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath. + if (((flags & SCENEGRAPHPATH) != 0) && + (inside(shape.branchGroupPath,bgRetained))){ + + if(first) { + mpath = createPath(srcNode, bgRetained, geomAtoms[i], initpath); + first = false; + } + + if(mpath != null) { + SceneGraphPath sgpath = new SceneGraphPath(locale, + mpath, (Node) s3dCR.srcList[n]); + sgpath.setTransform(shape.getCurrentLocalToVworld(0)); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setSceneGraphPath(sgpath); + } + } + + // PickInfo.NODE - request for computed intersected Node. + if ((flags & NODE) != 0) { + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setNode((Node) s3dCR.srcList[n]); + } + + // PickInfo.LOCAL_TO_VWORLD + // - request for computed local to virtual world transform. + if ((flags & LOCAL_TO_VWORLD) != 0) { + Transform3D l2vw = geomAtoms[i].source.getCurrentLocalToVworld(); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setLocalToVWorld( new Transform3D(l2vw)); + } + + // NOTE : Piggy bag for geometry computation by caller. + if (((flags & CLOSEST_DISTANCE) != 0) || + ((flags & CLOSEST_GEOM_INFO) != 0) || + ((flags & CLOSEST_INTERSECTION_POINT) != 0) || + ((flags & ALL_GEOM_INFO) != 0)) { + + pickInfo.setNodeRef((Node) s3dCR.srcList[n]); + Transform3D l2vw = geomAtoms[i].source.getCurrentLocalToVworld(); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setLocalToVWorldRef(l2vw); + } + + if(pickInfo != null) + pickInfoList.add(pickInfo); + if(pickType == PICK_ANY) { + return pickInfoList; + } + } + } + else { + Node[] mpath = null; + + // PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath. + if (((flags & SCENEGRAPHPATH) != 0) && + (inside(shape.branchGroupPath,bgRetained))) { + + mpath = createPath(srcNode, bgRetained, geomAtoms[i], initpath); + + if(mpath != null) { + SceneGraphPath sgpath = new SceneGraphPath(locale, mpath, + (Node) srcNode.source); + sgpath.setTransform(shape.getCurrentLocalToVworld(0)); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setSceneGraphPath(sgpath); + } + } + + // PickInfo.NODE - request for computed intersected Node. + if ((flags & NODE) != 0) { + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setNode((Node) srcNode.source); + } + + // PickInfo.LOCAL_TO_VWORLD + // - request for computed local to virtual world transform. + if ((flags & LOCAL_TO_VWORLD) != 0) { + Transform3D l2vw = geomAtoms[i].source.getCurrentLocalToVworld(); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setLocalToVWorld( new Transform3D(l2vw)); + } + + // NOTE : Piggy bag for geometry computation by caller. + if (((flags & CLOSEST_DISTANCE) != 0) || + ((flags & CLOSEST_GEOM_INFO) != 0) || + ((flags & CLOSEST_INTERSECTION_POINT) != 0) || + ((flags & ALL_GEOM_INFO) != 0)) { + + pickInfo.setNodeRef((Node) srcNode.source); + Transform3D l2vw = geomAtoms[i].source.getCurrentLocalToVworld(); + if(pickInfo == null) + pickInfo = new PickInfo(); + pickInfo.setLocalToVWorldRef(l2vw); + } + + if(pickInfo != null) + pickInfoList.add(pickInfo); + if(pickType == PICK_ANY) { + return pickInfoList; + } + } + } + + return pickInfoList; + } + + static PickInfo[] pick(Object node, GeometryAtom[] geomAtoms, + int mode, int flags, PickShape pickShape, int pickType) { + + int pickInfoListSize; + PickInfo[] pickInfoArr = null; + Locale locale = null; + BranchGroupRetained bgRetained = null; + ArrayList initPath = null; + ArrayList pickInfoList = null; + + if (node instanceof Locale) { + locale = (Locale) node; + } + else if ( node instanceof BranchGroupRetained) { + bgRetained = (BranchGroupRetained) node; + locale = bgRetained.locale; + } + synchronized (locale.universe.sceneGraphLock) { + if ( bgRetained != null) { + initPath = initSceneGraphPath(bgRetained); + } + pickInfoList = getPickInfos(initPath, bgRetained, geomAtoms, + locale, flags, pickType); + } + + // We're done with PICK_BOUNDS case, but there is still more work for PICK_GEOMETRY case. + if((mode == PICK_GEOMETRY) && ((pickInfoListSize = pickInfoList.size()) > 0)) { + + //System.out.println("PickInfo.pick() - In geometry case : pickInfoList.size() is " + pickInfoListSize); + PickInfo pickInfo = null; + Node pickNode = null; + + // Order is impt. Need to do in reverse order. + for(int i = pickInfoListSize - 1; i >= 0; i--) { + pickInfo = (PickInfo) pickInfoList.get(i); + pickNode = pickInfo.getNode(); + + if (pickNode instanceof Shape3D) { + + /* + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are + * as follows : + * + * By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ + * By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ + * Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above) + * + */ + + if (!pickNode.getCapability(Shape3D.ALLOW_GEOMETRY_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo0")); + } + + for (int j = 0; j < ((Shape3D)pickNode).numGeometries(); j++) { + Geometry geo = ((Shape3D)pickNode).getGeometry(j); + + if(!geo.getCapability(Geometry.ALLOW_INTERSECT)) { + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo1")); + } + + if (geo instanceof GeometryArray) { + if(!geo.getCapability(GeometryArray.ALLOW_COORDINATE_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo2")); + if(!geo.getCapability(GeometryArray.ALLOW_COUNT_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo3")); + if(!geo.getCapability(GeometryArray.ALLOW_FORMAT_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo4")); + if (geo instanceof IndexedGeometryArray) { + if(!geo.getCapability(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo5")); + } + } else if (geo instanceof CompressedGeometry) { + if(!geo.getCapability(CompressedGeometry.ALLOW_GEOMETRY_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo0")); + } + } + + if (((Shape3DRetained)(pickNode.retained)).intersect(pickInfo, pickShape, flags) == false) { + // System.out.println(" ---- geom " + i + " not intersected"); + + pickInfoList.remove(i); + + } + else if(pickType == PICK_ANY) { + pickInfoArr = new PickInfo[1]; + pickInfoArr[0] = pickInfo; + return pickInfoArr; + } + } else if (pickNode instanceof Morph) { + + /* + * @exception CapabilityNotSetException if the mode is + * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit + * is not set in any Geometry objects referred to by any shape + * node whose bounds intersects the PickShape. + * + * @exception CapabilityNotSetException if flags contains any of + * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO + * or ALL_GEOM_INFO, and the capability bits that control reading of + * coordinate data are not set in any GeometryArray object referred + * to by any shape node that intersects the PickShape. + * The capability bits that must be set to avoid this exception are + * as follows : + * + * By-copy geometry : GeometryArray.ALLOW_COORDINATE_READ + * By-reference geometry : GeometryArray.ALLOW_REF_DATA_READ + * Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ + * (in addition to one of the above) + * + */ + + if (!pickNode.getCapability(Morph.ALLOW_GEOMETRY_ARRAY_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo6")); + } + + int numGeo = ((MorphRetained)(pickNode.retained)).getNumGeometryArrays(); + for (int j = 0; j < numGeo; j++) { + GeometryArray geo = ((Morph)pickNode).getGeometryArray(j); + + if(!geo.getCapability(Geometry.ALLOW_INTERSECT)) { + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo1")); + } + + if(!geo.getCapability(GeometryArray.ALLOW_COORDINATE_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo2")); + if(!geo.getCapability(GeometryArray.ALLOW_COUNT_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo3")); + if(!geo.getCapability(GeometryArray.ALLOW_FORMAT_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo4")); + + if (geo instanceof IndexedGeometryArray) { + if(!geo.getCapability(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("PickInfo5")); + } + } + + if (((MorphRetained)(pickNode.retained)).intersect(pickInfo, pickShape, flags) == false) { + pickInfoList.remove(i); + } + else if(pickType == PICK_ANY) { + pickInfoArr = new PickInfo[1]; + pickInfoArr[0] = pickInfo; + return pickInfoArr; + } + } + } + } + + // System.out.println("PickInfo : pickInfoList " + pickInfoList); + + if ((pickInfoList != null) && (pickInfoList.size() > 0)) { + // System.out.println(" --- : pickInfoList.size() " + pickInfoList.size()); + // System.out.println(" --- : pickInfoList's sgp " + + // ((PickInfo)(pickInfoList.get(0))).getSceneGraphPath()); + pickInfoArr = new PickInfo[pickInfoList.size()]; + return (PickInfo []) pickInfoList.toArray(pickInfoArr); + } + + return null; + + } + + /** + * The IntersectionInfo object holds extra information about an intersection + * of a PickShape with a Node as part of a PickInfo. Information such as + * the intersected geometry, the intersected point, and the vertex indices + * can be inquired. + * The local coordinates, normal, color and texture coordiantes of at the + * intersection can be computed, if they are present and readable, using the + * interpolation weights and vertex indices. + * <p> + * If the Shape3D being picked has multiple geometry arrays, the possible arrays + * of IntersectionInfo are stored in the PickInfo and referred to by a geometry + * index. If the picked geometry is of type, Text3D or CompressGeometry, + * getVertexIndices is invalid. If the picked Node is an Morph + * object, the geometry used in pick computation is alway at index 0. + * <p> + * + * @since Java 3D 1.4 + */ + + public class IntersectionInfo extends Object { + + /* The index to the intersected geometry in the pickable node */ + private int geomIndex; + + /* The reference to the intersected geometry in the pickable object */ + private Geometry geom; + + /* The intersection point */ + private Point3d intersectionPoint; + + /* Distance between start point of pickShape and intersection point */ + private double distance; + + /* The vertex indices of the intersected primitive in the geometry */ + private int[] vertexIndices; + + /* The interpolation weights for each of the verticies of the primitive */ + // private float[] weights; Not supported. Should be done in util. package + + /** IntersectionInfo Constructor */ + IntersectionInfo() { + + } + + void setGeometryIndex(int geomIndex) { + this.geomIndex = geomIndex; + } + + void setGeometry(Geometry geom) { + this.geom = geom; + } + + void setIntersectionPoint(Point3d intersectionPoint) { + this.intersectionPoint = intersectionPoint; + } + + void setDistance(double distance) { + this.distance = distance; + } + + void setVertexIndices(int[] vertexIndices) { + this.vertexIndices = vertexIndices; + } + + + /** + * Retrieves the index to the intersected geometry in the picked node, either a Shape3D or Morph. + * @return the index of the intersected geometry in the pickable node. + */ + public int getGeometryIndex() { + return geomIndex; + } + + /** + * Retrieves the reference to the intersected geometry in the picked object, either a Shape3D or Morph. + * @return the intersected geometry in the pickable node. + */ + public Geometry getGeometry() { + return geom; + } + + /** + * Retrieves the reference to the intersection point in the pickable node. + * @return the intersected point in the pickable node. + */ + public Point3d getIntersectionPoint() { + return intersectionPoint; + } + + /** + * Retrieves the distance between the start point of the pickShape and the + * intersection point. + * @return distance between the start point of the pickShape and the + * intersection point. + */ + public double getDistance() { + return distance; + } + + /** + * Retrieves the vertex indices of the intersected primitive in the geometry. + * @return the vertex indices of the intersected primitive. + */ + public int[] getVertexIndices() { + return vertexIndices; + } + + } +} + + diff --git a/src/classes/share/javax/media/j3d/PickPoint.java b/src/classes/share/javax/media/j3d/PickPoint.java index 3001af1..22ec12b 100644 --- a/src/classes/share/javax/media/j3d/PickPoint.java +++ b/src/classes/share/javax/media/j3d/PickPoint.java @@ -20,6 +20,10 @@ import javax.vecmath.*; * * @see BranchGroup#pickAll * @see Locale#pickAll + * @see PickBounds + * + * @deprecated As of Java 3D version 1.4, use PickBounds with a + * BoundingSphere that has a small radius. */ public final class PickPoint extends PickShape { diff --git a/src/classes/share/javax/media/j3d/Picking.java b/src/classes/share/javax/media/j3d/Picking.java deleted file mode 100644 index 952248d..0000000 --- a/src/classes/share/javax/media/j3d/Picking.java +++ /dev/null @@ -1,660 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -package javax.media.j3d; - -import javax.vecmath.*; -import java.util.*; - - -/** - * Internal class that implements picking functionality. - */ - -class Picking { - - static SceneGraphPath[] pickAll(Locale locale, PickShape shape) { - if(locale == null) { - return null; - } - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - // although getSceneGraphPath() also return null, we - // save time for synchronization - return null; - } - synchronized (locale.universe.sceneGraphLock) { - return getSceneGraphPath(null, null, geomAtoms, locale); - } - } - - - - static SceneGraphPath[] pickAll(BranchGroup node, - PickShape shape) { - if (node == null) { - return null; - } - - BranchGroupRetained nodeR = (BranchGroupRetained) node.retained; - - if (nodeR.inSharedGroup) { - throw new RestrictedAccessException(J3dI18N.getString("Picking0")); - } - - Locale locale = nodeR.locale; - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - synchronized (nodeR.universe.sceneGraphLock) { - return getSceneGraphPath(initSceneGraphPath(nodeR), - nodeR, geomAtoms, locale); - } - } - - - static SceneGraphPath[] pickAllSorted(Locale locale, - PickShape shape) { - if(locale == null) { - return null; - } - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - sortGeomAtoms(geomAtoms, shape); - - synchronized (locale.universe.sceneGraphLock) { - return getSceneGraphPath(null, null, geomAtoms, locale); - } - } - - - static SceneGraphPath[] pickAllSorted(BranchGroup node, - PickShape shape) { - if (node == null) { - return null; - } - - BranchGroupRetained nodeR = (BranchGroupRetained) node.retained; - - if (nodeR.inSharedGroup) { - throw new RestrictedAccessException(J3dI18N.getString("Picking0")); - } - - Locale locale = nodeR.locale; - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - // we have to sort first before eliminate duplicate Text3D - // since we want the closest geometry atoms of Text3D - sortGeomAtoms(geomAtoms, shape); - - synchronized (nodeR.universe.sceneGraphLock) { - return getSceneGraphPath(initSceneGraphPath(nodeR), - nodeR, geomAtoms, locale); - } - } - - - static SceneGraphPath pickClosest(Locale locale, - PickShape shape) { - - if(locale == null) { - return null; - } - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - - GeometryAtom geomAtom = selectClosest(geomAtoms, shape); - - - synchronized (locale.universe.sceneGraphLock) { - return getSceneGraphPath(null, null, geomAtom, locale); - } - } - - - static SceneGraphPath pickClosest(BranchGroup node, - PickShape shape) { - if (node == null) { - return null; - } - - BranchGroupRetained nodeR = (BranchGroupRetained) node.retained; - - if (nodeR.inSharedGroup) { - throw new RestrictedAccessException(J3dI18N.getString("Picking0")); - } - - Locale locale = nodeR.locale; - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - - // We must sort all since the closest one in geomAtoms may not - // under the BranchGroup node - sortGeomAtoms(geomAtoms, shape); - - synchronized (nodeR.universe.sceneGraphLock) { - return getFirstSceneGraphPath(initSceneGraphPath(nodeR), - nodeR, geomAtoms, locale); - - } - } - - - static SceneGraphPath pickAny(Locale locale, PickShape shape) { - - if(locale == null) { - return null; - } - - GeometryAtom geomAtom = - locale.universe.geometryStructure.pickAny(locale, shape); - - if (geomAtom == null) { - return null; - } - - - synchronized (locale.universe.sceneGraphLock) { - return getSceneGraphPath(null, null, geomAtom, locale); - } - } - - static SceneGraphPath pickAny(BranchGroup node, PickShape shape) { - - if (node == null) { - return null; - } - - BranchGroupRetained nodeR = (BranchGroupRetained) node.retained; - - if (nodeR.inSharedGroup) { - throw new RestrictedAccessException(J3dI18N.getString("Picking0")); - } - - Locale locale = nodeR.locale; - - // since PickAny return from geometry may not lie under - // BranchGroup node, we have to use pickAll - - GeometryAtom geomAtoms[] = - locale.universe.geometryStructure.pickAll(locale, shape); - - if ((geomAtoms == null) || (geomAtoms.length == 0)) { - return null; - } - - synchronized (nodeR.universe.sceneGraphLock) { - return getFirstSceneGraphPath(initSceneGraphPath(nodeR), - nodeR, geomAtoms, locale); - } - } - - - /** - * Search the path from nodeR up to Locale. - * Return the search path as ArrayList if found. - * Note that the locale will not insert into path. - */ - static private ArrayList initSceneGraphPath(NodeRetained nodeR) { - ArrayList path = new ArrayList(5); - - do { - if (nodeR.source.getCapability(Node.ENABLE_PICK_REPORTING)){ - path.add(nodeR); - } - nodeR = nodeR.parent; - } while (nodeR != null); // reach Locale - - return path; - } - - /** - * return all SceneGraphPath[] of the geomAtoms. - * If initpath is null, the path is search from - * geomAtom Shape3D/Morph Node up to Locale - * (assume the same locale). - * Otherwise, the path is search up to node or - * null is return if it is not hit. - */ - static private SceneGraphPath[] getSceneGraphPath(ArrayList initpath, - BranchGroupRetained node, - GeometryAtom geomAtoms[], - Locale locale) { - - ArrayList paths = new ArrayList(5); - GeometryAtom geomAtom; - NodeRetained target; - ArrayList texts = null; - - if (geomAtoms == null) { - return null; - } - - - for (int i=0; i < geomAtoms.length; i++) { - geomAtom = (GeometryAtom) geomAtoms[i]; - Shape3DRetained shape = geomAtom.source; - - // isPickable and currentSwitchOn has been check in BHTree - - if (!inside(shape.branchGroupPath, node)) { - continue; - } - - target = shape.sourceNode; - - if (target == null) { - // The node is just detach from branch so sourceNode = null - continue; - } - - // Special case, for Text3DRetained, it is possible - // for different geomAtoms pointing to the same - // source Text3DRetained. So we need to combine - // those cases and report only once. - if (target instanceof Shape3DRetained) { - Shape3DRetained s3dR = (Shape3DRetained) target; - GeometryRetained geomR = null; - for(int cnt=0; cnt<s3dR.geometryList.size(); cnt++) { - geomR = (GeometryRetained) s3dR.geometryList.get(cnt); - if(geomR != null) - break; - } - - if (geomR == null) - continue; - - if (geomR instanceof Text3DRetained) { - // assume this case is not frequent, we allocate - // ArrayList only when necessary and we use ArrayList - // instead of HashMap since the case of when large - // number of distingish Text3DRetained node hit is - // rare. - if (texts == null) { - texts = new ArrayList(3); - } else { - int size = texts.size(); - boolean found = false; - for (int j=0; j < size; j++) { - if (texts.get(j) == target) { - found = true; - break; - } - } - if (found) { - continue; // try next geomAtom - } - } - texts.add(target); - } - } - - ArrayList path = retrievePath(target, node, - geomAtom.source.key); - - if (path == null) { - continue; - } - - // If target is instance of compile retained, then loop thru - // the entire source list and add it to the scene graph path - if (target instanceof Shape3DCompileRetained) { - Shape3DCompileRetained s3dCR = (Shape3DCompileRetained)target; - Node[] mpath = mergePath(path, initpath); - for (int n = 0; n < s3dCR.srcList.length; n++) { - SceneGraphPath sgpath = new SceneGraphPath(locale, - mpath, - (Node) s3dCR.srcList[n]); - sgpath.setTransform(shape.getCurrentLocalToVworld(0)); - paths.add(sgpath); - } - - } - else { - SceneGraphPath sgpath = new SceneGraphPath(locale, - mergePath(path, initpath), - (Node) target.source); - sgpath.setTransform(shape.getCurrentLocalToVworld(0)); - paths.add(sgpath); - } - - - } - SceneGraphPath pathArray[] = new SceneGraphPath[paths.size()]; - return (SceneGraphPath []) paths.toArray(pathArray); - } - - /** - * return the SceneGraphPath of the geomAtom. - * If initpath is null, the path is search from - * geomAtom Shape3D/Morph Node up to Locale - * (assume the same locale). - * Otherwise, the path is search up to node or - * null is return if it is not hit. - */ - static private SceneGraphPath getSceneGraphPath(ArrayList initpath, - BranchGroupRetained node, - GeometryAtom geomAtom, - Locale locale) { - if (geomAtom == null) { - return null; - } - - Shape3DRetained shape = geomAtom.source; - NodeRetained target = shape.sourceNode; - - if (target == null) { - // The node is just detach from branch so sourceNode = null - return null; - } - - if (!inside(shape.branchGroupPath, node)) { - return null; - } - - ArrayList path = retrievePath(target, node, shape.key); - - if (path == null) { - return null; - } - - SceneGraphPath sgpath = new SceneGraphPath(locale, - mergePath(path, initpath), - (Node) - target.source); - sgpath.setTransform(shape.getCurrentLocalToVworld(0)); - return sgpath; - } - - /** - * Return true if bg is inside cachedBG or bg is null - */ - static private boolean inside(BranchGroupRetained bgArr[], - BranchGroupRetained bg) { - - if ((bg == null) || (bgArr == null)) { - return true; - } - - for (int i=0; i < bgArr.length; i++) { - if (bgArr[i] == bg) { - return true; - } - } - return false; - } - - - /** - * return the first SceneGraphPath of the geomAtom. - * If initpath is null, the path is search from - * geomAtom Shape3D/Morph Node up to Locale - * (assume the same locale). - * Otherwise, the path is search up to node or - * null is return if it is not hit. - */ - static private SceneGraphPath getFirstSceneGraphPath(ArrayList initpath, - BranchGroupRetained node, - GeometryAtom geomAtoms[], - Locale locale) { - if (geomAtoms == null) { - return null; - } - - for (int i=0; i < geomAtoms.length; i++) { - Shape3DRetained shape = geomAtoms[i].source; - NodeRetained target = shape.sourceNode; - - if (target == null) { - // The node is just detach from branch so sourceNode = null - continue; - } - if (!inside(shape.branchGroupPath, node)) { - continue; - } - ArrayList path = retrievePath(target, node, geomAtoms[i].source.key); - - if (path == null) { - continue; - } - SceneGraphPath sgpath = new SceneGraphPath(locale, - mergePath(path, initpath), - (Node) target.source); - sgpath.setTransform(shape.getCurrentLocalToVworld(0)); - return sgpath; - } - return null; - } - - - /** - * search the full path from the botton of the scene graph - - * startNode, up to the Locale if endNode is null. - * If endNode is not null, the path is found up to, but not - * including, endNode or return null if endNode not hit - * during the search. - */ - static private ArrayList retrievePath(NodeRetained startNode, - NodeRetained endNode, - HashKey key) { - - ArrayList path = new ArrayList(5); - NodeRetained nodeR = startNode; - - if (nodeR.inSharedGroup) { - // getlastNodeId() will destroy this key - key = new HashKey(key); - } - - do { - if (nodeR == endNode) { // we found it ! - return path; - } - - if (nodeR.source.getCapability(Node.ENABLE_PICK_REPORTING)) { - path.add(nodeR); - } - - if (nodeR instanceof SharedGroupRetained) { - // retrieve the last node ID - String nodeId = key.getLastNodeId(); - Vector parents = ((SharedGroupRetained) nodeR).parents; - int sz = parents.size(); - NodeRetained prevNodeR = nodeR; - for(int i=0; i< sz; i++) { - NodeRetained linkR = (NodeRetained) parents.elementAt(i); - if (linkR.nodeId.equals(nodeId)) { - nodeR = linkR; - // Need to add Link to the path report - path.add(nodeR); - // since !(endNode instanceof Link), we - // can skip the check (nodeR == endNode) and - // proceed to parent of link below - break; - } - } - if (nodeR == prevNodeR) { - // branch is already detach - return null; - } - } - nodeR = nodeR.parent; - } while (nodeR != null); // reach Locale - - if (endNode == null) { - // user call pickxxx(Locale locale, PickShape shape) - return path; - } - - // user call pickxxx(BranchGroup endNode, PickShape shape) - // if locale is reached and endNode not hit, this is not - // the path user want to select - return null; - } - - /** - * copy p1, (follow by) p2 into a new array, p2 can be null - * The path is then reverse before return. - */ - static private Node[] mergePath(ArrayList p1, ArrayList p2) { - int s = p1.size(); - int len; - int i; - int l; - if (p2 == null) { - len = s; - } else { - len = s + p2.size(); - } - - Node nodes[] = new Node[len]; - l = len-1; - for (i=0; i < s; i++) { - nodes[l-i] = (Node) ((NodeRetained) p1.get(i)).source; - } - for (int j=0; i< len; i++, j++) { - nodes[l-i] = (Node) ((NodeRetained) p2.get(j)).source; - } - return nodes; - } - - /** - * Select the closest geomAtoms from shape - * geomAtoms.length must be >= 1 - */ - static private GeometryAtom selectClosest(GeometryAtom geomAtoms[], - PickShape shape) { - Point4d pickPos = new Point4d(); - GeometryAtom closestAtom = geomAtoms[0]; - shape.intersect(closestAtom.source.vwcBounds, pickPos); - double distance = pickPos.w; - - for (int i=1; i < geomAtoms.length; i++) { - shape.intersect(geomAtoms[i].source.vwcBounds, pickPos); - if (pickPos.w < distance) { - distance = pickPos.w; - closestAtom = geomAtoms[i]; - } - } - return closestAtom; - } - - /** - * Sort the GeometryAtoms distance from shape in ascending order - * geomAtoms.length must be >= 1 - */ - static private void sortGeomAtoms(GeometryAtom geomAtoms[], - PickShape shape) { - - final double distance[] = new double[geomAtoms.length]; - Point4d pickPos = new Point4d(); - - for (int i=0; i < geomAtoms.length; i++) { - shape.intersect(geomAtoms[i].source.vwcBounds, pickPos); - distance[i] = pickPos.w; - } - - class Sort { - - GeometryAtom atoms[]; - - Sort(GeometryAtom[] atoms) { - this.atoms = atoms; - } - - void sorting() { - if (atoms.length < 7) { - insertSort(); - } else { - quicksort(0, atoms.length-1); - } - } - - // Insertion sort on smallest arrays - final void insertSort() { - for (int i=0; i<atoms.length; i++) { - for (int j=i; j>0 && - (distance[j-1] > distance[j]); j--) { - double t = distance[j]; - distance[j] = distance[j-1]; - distance[j-1] = t; - GeometryAtom p = atoms[j]; - atoms[j] = atoms[j-1]; - atoms[j-1] = p; - } - } - } - - final void quicksort( int l, int r ) { - int i = l; - int j = r; - double k = distance[(l+r) / 2]; - - do { - while (distance[i]<k) i++; - while (k<distance[j]) j--; - if (i<=j) { - double tmp = distance[i]; - distance[i] =distance[j]; - distance[j] = tmp; - - GeometryAtom p=atoms[i]; - atoms[i]=atoms[j]; - atoms[j]=p; - i++; - j--; - } - } while (i<=j); - - if (l<j) quicksort(l,j); - if (l<r) quicksort(i,r); - } - } - - (new Sort(geomAtoms)).sorting(); - } - -} diff --git a/src/classes/share/javax/media/j3d/PointArray.java b/src/classes/share/javax/media/j3d/PointArray.java index 412f4d5..421960d 100644 --- a/src/classes/share/javax/media/j3d/PointArray.java +++ b/src/classes/share/javax/media/j3d/PointArray.java @@ -23,22 +23,21 @@ public class PointArray extends GeometryArray { PointArray() {} /** - * Constructs an empty PointArray object with the specified - * number of vertices, and vertex format. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. + * Constructs an empty PointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public PointArray(int vertexCount, int vertexFormat) { super(vertexCount,vertexFormat); @@ -48,59 +47,29 @@ public class PointArray extends GeometryArray { } /** - * Constructs an empty PointArray object with the specified - * number of vertices, and vertex format, number of texture coordinate - * sets, and texture coordinate mapping array. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used. + * Constructs an empty PointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -117,6 +86,52 @@ public class PointArray extends GeometryArray { } /** + * Constructs an empty PointArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 1 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public PointArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + if (vertexCount < 1 ) + throw new IllegalArgumentException(J3dI18N.getString("PointArray0")); + } + + /** * Creates the retained mode PointArrayRetained object that this * PointArray object will point to. */ @@ -130,21 +145,26 @@ public class PointArray extends GeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - PointArrayRetained rt = (PointArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - PointArray p; - if (texSetCount == 0) { - p = new PointArray(rt.getVertexCount(), - rt.getVertexFormat()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - p = new PointArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap); - } - p.duplicateNodeComponent(this); + PointArrayRetained rt = (PointArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + PointArray p = new PointArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes); + p.duplicateNodeComponent(this); return p; } } diff --git a/src/classes/share/javax/media/j3d/PointArrayRetained.java b/src/classes/share/javax/media/j3d/PointArrayRetained.java index b06e410..319a643 100644 --- a/src/classes/share/javax/media/j3d/PointArrayRetained.java +++ b/src/classes/share/javax/media/j3d/PointArrayRetained.java @@ -25,13 +25,15 @@ class PointArrayRetained extends GeometryArrayRetained { this.geoType = GEO_TYPE_POINT_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; - Point3d pnt = new Point3d(); + int count = 0; + int minICount = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); + Point3d pnt = new Point3d(); switch (pickShape.getPickType()) { case PickShape.PICKRAY: @@ -39,13 +41,15 @@ class PointArrayRetained extends GeometryArrayRetained { while (i < validVertexCount) { getVertexData(i++, pnt); - if (intersectPntAndRay(pnt, pickRay.origin, + count++; + if (intersectPntAndRay(pnt, pickRay.origin, pickRay.direction, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -61,14 +65,16 @@ class PointArrayRetained extends GeometryArrayRetained { pickSegment.end.z - pickSegment.start.z); while (i < validVertexCount) { getVertexData(i++, pnt); + count++; if (intersectPntAndRay(pnt, pickSegment.start, dir, sdist) && (sdist[0] <= 1.0)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -84,13 +90,15 @@ class PointArrayRetained extends GeometryArrayRetained { while (i < validVertexCount) { getVertexData(i++, pnt); + count++; if (bounds.intersect(pnt)) { - if (dist == null) { + if (flags == 0) { return true; } sdist[0] = pickShape.distance(pnt); if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -104,13 +112,14 @@ class PointArrayRetained extends GeometryArrayRetained { while (i < validVertexCount) { getVertexData(i++, pnt); - + count++; if (intersectCylinder(pnt, pickCylinder, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -123,13 +132,14 @@ class PointArrayRetained extends GeometryArrayRetained { while (i < validVertexCount) { getVertexData(i++, pnt); - + count++; if (intersectCone(pnt, pickCone, sdist)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = pnt.x; y = pnt.y; z = pnt.z; @@ -145,14 +155,19 @@ class PointArrayRetained extends GeometryArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=1); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[1]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; return true; } return false; - } boolean intersect(Point3d[] pnts) { diff --git a/src/classes/share/javax/media/j3d/PointAttributes.java b/src/classes/share/javax/media/j3d/PointAttributes.java index 29b9e92..66c4e39 100644 --- a/src/classes/share/javax/media/j3d/PointAttributes.java +++ b/src/classes/share/javax/media/j3d/PointAttributes.java @@ -65,6 +65,12 @@ public class PointAttributes extends NodeComponent { public static final int ALLOW_ANTIALIASING_WRITE = CapabilityBits.POINT_ATTRIBUTES_ALLOW_ANTIALIASING_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SIZE_READ, + ALLOW_ANTIALIASING_READ + }; + /** * Constructs a PointAttributes object with default parameters. * The default values are as follows: @@ -74,6 +80,8 @@ public class PointAttributes extends NodeComponent { * </ul> */ public PointAttributes(){ + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -82,8 +90,10 @@ public class PointAttributes extends NodeComponent { * @param pointAntialiasing flag to set point antialising ON or OFF */ public PointAttributes(float pointSize, boolean pointAntialiasing){ + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); - ((PointAttributesRetained)this.retained).initPointSize(pointSize); + ((PointAttributesRetained)this.retained).initPointSize(pointSize); ((PointAttributesRetained)this.retained).initPointAntialiasingEnable(pointAntialiasing); } diff --git a/src/classes/share/javax/media/j3d/PointLight.java b/src/classes/share/javax/media/j3d/PointLight.java index 3e87f84..147c186 100644 --- a/src/classes/share/javax/media/j3d/PointLight.java +++ b/src/classes/share/javax/media/j3d/PointLight.java @@ -80,6 +80,12 @@ public class PointLight extends Light { public static final int ALLOW_ATTENUATION_WRITE = CapabilityBits.POINT_LIGHT_ALLOW_ATTENUATION_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_POSITION_READ, + ALLOW_ATTENUATION_READ + }; + /** * Constructs a PointLight node with default parameters. * The default values are as follows: @@ -89,6 +95,8 @@ public class PointLight extends Light { * </ul> */ public PointLight() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -101,6 +109,10 @@ public class PointLight extends Light { Point3f position, Point3f attenuation) { super(color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointLightRetained)this.retained).initPosition(position); ((PointLightRetained)this.retained).initAttenuation(attenuation); } @@ -117,6 +129,10 @@ public class PointLight extends Light { Point3f position, Point3f attenuation) { super(lightOn, color); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointLightRetained)this.retained).initPosition(position); ((PointLightRetained)this.retained).initAttenuation(attenuation); } diff --git a/src/classes/share/javax/media/j3d/PointSound.java b/src/classes/share/javax/media/j3d/PointSound.java index 1f005eb..4af92dd 100644 --- a/src/classes/share/javax/media/j3d/PointSound.java +++ b/src/classes/share/javax/media/j3d/PointSound.java @@ -99,6 +99,13 @@ public class PointSound extends Sound { public static final int ALLOW_DISTANCE_GAIN_WRITE = CapabilityBits.POINT_SOUND_ALLOW_DISTANCE_GAIN_WRITE; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_POSITION_READ, + ALLOW_DISTANCE_GAIN_READ + }; + /** * Constructs and initializes a new PointSound node using default * parameters. The following default values are used: @@ -111,6 +118,9 @@ public class PointSound extends Sound { public PointSound() { // Uses default values defined for Sound and PointSound nodes super(); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } /** @@ -126,6 +136,10 @@ public class PointSound extends Sound { float initialGain, Point3f position) { super(soundData, initialGain); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(position); } @@ -144,6 +158,10 @@ public class PointSound extends Sound { float initialGain, float posX, float posY, float posZ ) { super(soundData, initialGain); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(posX,posY,posZ); } @@ -180,6 +198,10 @@ public class PointSound extends Sound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(position); ((PointSoundRetained)this.retained).setDistanceGain(distanceGain); } @@ -215,6 +237,10 @@ public class PointSound extends Sound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(posX,posY,posZ); ((PointSoundRetained)this.retained).setDistanceGain(distanceGain); } @@ -249,6 +275,10 @@ public class PointSound extends Sound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(position); ((PointSoundRetained)this.retained).setDistanceGain( attenuationDistance, attenuationGain); @@ -286,6 +316,10 @@ public class PointSound extends Sound { super(soundData, initialGain, loopCount, release, continuous, enable, region, priority ); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PointSoundRetained)this.retained).setPosition(posX,posY,posZ); ((PointSoundRetained)this.retained).setDistanceGain( attenuationDistance, attenuationGain); diff --git a/src/classes/share/javax/media/j3d/PolygonAttributes.java b/src/classes/share/javax/media/j3d/PolygonAttributes.java index 25b1269..ec676e2 100644 --- a/src/classes/share/javax/media/j3d/PolygonAttributes.java +++ b/src/classes/share/javax/media/j3d/PolygonAttributes.java @@ -146,6 +146,14 @@ public class PolygonAttributes extends NodeComponent { */ public static final int CULL_FRONT = 2; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_CULL_FACE_READ, + ALLOW_MODE_READ, + ALLOW_NORMAL_FLIP_READ, + ALLOW_OFFSET_READ + }; + /** * Constructs a PolygonAttributes object with default parameters. * The default values are as follows: @@ -159,6 +167,8 @@ public class PolygonAttributes extends NodeComponent { */ public PolygonAttributes() { // Just use defaults for all attributes + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -216,6 +226,9 @@ public class PolygonAttributes extends NodeComponent { if (cullFace < CULL_NONE || cullFace > CULL_FRONT) throw new IllegalArgumentException(J3dI18N.getString("PolygonAttributes12")); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((PolygonAttributesRetained)this.retained).initPolygonMode(polygonMode); ((PolygonAttributesRetained)this.retained).initCullFace(cullFace); ((PolygonAttributesRetained)this.retained).initPolygonOffset(polygonOffset); diff --git a/src/classes/share/javax/media/j3d/QuadArray.java b/src/classes/share/javax/media/j3d/QuadArray.java index 79818d3..ee7ab2f 100644 --- a/src/classes/share/javax/media/j3d/QuadArray.java +++ b/src/classes/share/javax/media/j3d/QuadArray.java @@ -25,23 +25,22 @@ public class QuadArray extends GeometryArray { QuadArray() {} /** - * Constructs an empty QuadArray object with the specified - * number of vertices, and vertex format. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. + * Constructs an empty QuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 4 * or vertexCount is <i>not</i> a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public QuadArray(int vertexCount, int vertexFormat) { super(vertexCount,vertexFormat); @@ -51,60 +50,30 @@ public class QuadArray extends GeometryArray { } /** - * Constructs an empty QuadArray object with the specified - * number of vertices, and vertex format, number of texture coordinate - * sets, and texture coordinate mapping array. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3 or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used. + * Constructs an empty QuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 4 * or vertexCount is <i>not</i> a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -121,6 +90,53 @@ public class QuadArray extends GeometryArray { } /** + * Constructs an empty QuadArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 4 + * or vertexCount is <i>not</i> a multiple of 4 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public QuadArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + if (vertexCount < 4 || ((vertexCount%4) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("QuadArray0")); + } + + /** * Creates the retained mode QuadArrayRetained object that this * QuadArray object will point to. */ @@ -134,21 +150,26 @@ public class QuadArray extends GeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - QuadArrayRetained rt = (QuadArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - QuadArray q; - if (texSetCount == 0) { - q = new QuadArray(rt.getVertexCount(), - rt.getVertexFormat()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - q = new QuadArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap); - } - q.duplicateNodeComponent(this); + QuadArrayRetained rt = (QuadArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + QuadArray q = new QuadArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes); + q.duplicateNodeComponent(this); return q; } diff --git a/src/classes/share/javax/media/j3d/QuadArrayRetained.java b/src/classes/share/javax/media/j3d/QuadArrayRetained.java index b33f605..5e95b76 100644 --- a/src/classes/share/javax/media/j3d/QuadArrayRetained.java +++ b/src/classes/share/javax/media/j3d/QuadArrayRetained.java @@ -27,14 +27,15 @@ class QuadArrayRetained extends GeometryArrayRetained { this.geoType = GEO_TYPE_QUAD_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[4]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); - pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -49,12 +50,14 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); + count += 4; if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -70,18 +73,19 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); + count += 4; if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; } - } } break; @@ -93,20 +97,20 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); - + count += 4; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; } } } - break; case PickShape.PICKBOUNDINGSPHERE: BoundingSphere bsphere = (BoundingSphere) @@ -117,13 +121,14 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); - + count += 4; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -141,13 +146,14 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); - + count += 4; if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -163,13 +169,14 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); - + count += 4; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -185,12 +192,14 @@ class QuadArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); getVertexData(i++, pnts[3]); + count += 4; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -206,7 +215,16 @@ class QuadArrayRetained extends GeometryArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 4); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[4]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 4; + vertexIndices[1] = minICount - 3; + vertexIndices[2] = minICount - 2; + vertexIndices[3] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; @@ -215,7 +233,7 @@ class QuadArrayRetained extends GeometryArrayRetained { return false; } - + // intersect pnts[] with every quad in this object boolean intersect(Point3d[] pnts) { Point3d[] points = new Point3d[4]; diff --git a/src/classes/share/javax/media/j3d/Raster.java b/src/classes/share/javax/media/j3d/Raster.java index d14eaf7..d95fee7 100644 --- a/src/classes/share/javax/media/j3d/Raster.java +++ b/src/classes/share/javax/media/j3d/Raster.java @@ -180,6 +180,17 @@ public class Raster extends Geometry { ALLOW_CLIP_MODE_WRITE = CapabilityBits.RASTER_ALLOW_CLIP_MODE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_POSITION_READ, + ALLOW_OFFSET_READ, + ALLOW_IMAGE_READ, + ALLOW_DEPTH_COMPONENT_READ, + ALLOW_SIZE_READ, + ALLOW_TYPE_READ, + ALLOW_CLIP_MODE_READ + }; + /** * Constructs a Raster object with default parameters. * The default values are as follows: @@ -195,6 +206,8 @@ public class Raster extends Geometry { * </ul> */ public Raster() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -223,6 +236,9 @@ public class Raster extends Geometry { ImageComponent2D image, DepthComponent depthComponent) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((RasterRetained)this.retained).setPosition(pos); ((RasterRetained)this.retained).setType(type); ((RasterRetained)this.retained).setSrcOffset(xSrcOffset, ySrcOffset); @@ -252,6 +268,9 @@ public class Raster extends Geometry { ImageComponent2D image, DepthComponent depthComponent) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((RasterRetained)this.retained).setPosition(pos); ((RasterRetained)this.retained).setType(type); ((RasterRetained)this.retained).setSrcOffset(srcOffset.x, srcOffset.y); @@ -289,6 +308,9 @@ public class Raster extends Geometry { ImageComponent2D image, DepthComponent depthComponent) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((RasterRetained)this.retained).setPosition(pos); ((RasterRetained)this.retained).setType(type); ((RasterRetained)this.retained).setClipMode(clipMode); diff --git a/src/classes/share/javax/media/j3d/RasterRetained.java b/src/classes/share/javax/media/j3d/RasterRetained.java index d580cd7..bd591b9 100644 --- a/src/classes/share/javax/media/j3d/RasterRetained.java +++ b/src/classes/share/javax/media/j3d/RasterRetained.java @@ -687,9 +687,10 @@ class RasterRetained extends GeometryRetained { ImageComponentUpdateInfo value) { } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { return false; } + boolean intersect(Bounds targetBound) { return false; } diff --git a/src/classes/share/javax/media/j3d/RenderBin.java b/src/classes/share/javax/media/j3d/RenderBin.java index e252bef..23ba119 100644 --- a/src/classes/share/javax/media/j3d/RenderBin.java +++ b/src/classes/share/javax/media/j3d/RenderBin.java @@ -46,6 +46,12 @@ class RenderBin extends J3dStructure implements ObjectUpdate { ArrayList aBinUpdateList = new ArrayList(); /** + * List of ShaderBin that are soleUser that + * needs to have its components updated @updateObject time + */ + ArrayList sBinUpdateList = new ArrayList(); + + /** * List of TextureBin that are soleUser that * needs to have its components updated @updateObject time */ @@ -95,6 +101,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { ArrayList lightBinFreelist = new ArrayList(5); ArrayList envSetFreelist = new ArrayList(5); ArrayList attrBinFreelist = new ArrayList(5); + ArrayList shaderBinFreelist = new ArrayList(5); ArrayList textureBinFreelist = new ArrayList(5); ArrayList renderMoleculeFreelist = new ArrayList(5); ArrayList transparentInfoFreeList = new ArrayList(5); @@ -167,6 +174,8 @@ class RenderBin extends J3dStructure implements ObjectUpdate { */ View view = null; + private Comparator transparencySortComparator = null; + ArrayList toBeAddedTextureResourceFreeList = new ArrayList(5); ArrayList displayListResourceFreeList = new ArrayList(5); boolean resourceToFree = false; @@ -526,10 +535,15 @@ class RenderBin extends J3dStructure implements ObjectUpdate { for (i = 0; i < size; i++) { AttributeBin abin = (AttributeBin)aBinUpdateList.get(i); abin.updateNodeComponent(); - } } + if ((size = sBinUpdateList.size()) > 0) { + for (i = 0; i < size; i++) { + ShaderBin sbin = (ShaderBin)sBinUpdateList.get(i); + sbin.updateNodeComponent(); + } + } // Update the sole user TextureBins. if (tbUpdateList.size() > 0) { @@ -544,12 +558,12 @@ class RenderBin extends J3dStructure implements ObjectUpdate { // texture in the first texture unit state for (i = 0; i < size; i++) { tb = (TextureBin) tbUpdateList.get(i); - // Bug Id : 4701430 - Have to be sure tb.attributeBin is + // Bug Id : 4701430 - Have to be sure tb.shaderBin is // not equal to null. This is a temporary fix for j3d1.3. if (((tb.tbFlag & TextureBin.RESORT) != 0) && - (tb.attributeBin != null)) { + (tb.shaderBin != null)) { - tb.attributeBin.reInsertTextureBin(tb); + tb.shaderBin.reInsertTextureBin(tb); tb.tbFlag &= ~TextureBin.RESORT; } } @@ -823,7 +837,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { continue; zVal = renderAtom.geometryAtom.centroid[k].distanceSquared(eyeInVworld); renderAtom.parentTInfo[k].zVal = zVal; - + renderAtom.parentTInfo[k].geometryAtom = renderAtom.geometryAtom; } } @@ -923,7 +937,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { } // lock list of dlist - // TODO: Instead of copying could we keep 2 arrays + // XXXX: Instead of copying could we keep 2 arrays // and just toggle? size = dirtyRenderMoleculeList.size(); for (i = 0; i < size; i++) { @@ -964,7 +978,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { RenderAtomListInfo arr[]; RenderAtomListInfo ra; - // TODO: there is a possible problem in the case of multiple + // XXXX: there is a possible problem in the case of multiple // renderers (i.e., multiple screens). Unless the // MasterControl sends us a separate message for each // renderer, we won't create a new display list for renderers @@ -1125,6 +1139,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { rmUpdateList.clear(); ogCIOList.clear(); aBinUpdateList.clear(); + sBinUpdateList.clear(); tbUpdateList.clear(); removeRenderAtomInRMList.clear(); addOpaqueBin = null; @@ -1334,6 +1349,10 @@ class RenderBin extends J3dStructure implements ObjectUpdate { } } texIdObj = new Integer(id); + // XXXX: The following code seems wrong -- why add it to + // the list if it is already there? Maybe one is for the + // texture and the other (idential value) is for the + // detail texture? if (cv.textureIdResourceFreeList.contains(texIdObj)) { cv.textureIdResourceFreeList.add(texIdObj); dtex.resourceCreationMask[tex.format] &= ~cv.canvasBit; @@ -1616,8 +1635,13 @@ class RenderBin extends J3dStructure implements ObjectUpdate { // Texture is always in a sole user position processTextureChanged((NodeComponentRetained) m.args[0], (GeometryAtom[])m.args[3], - m.args); - + m.args); + m.decRefcount(); + break; + case J3dMessage.SHADER_APPEARANCE_CHANGED: + case J3dMessage.SHADER_ATTRIBUTE_SET_CHANGED: + case J3dMessage.SHADER_ATTRIBUTE_CHANGED: + processShaderComponentChanged(m.args); m.decRefcount(); break; case J3dMessage.RENDERINGATTRIBUTES_CHANGED: @@ -1695,7 +1719,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { updateViewPlatform((ViewPlatformRetained)vp.retained, ((Float)m.args[1]).floatValue()); visQuery = true; - // TODO : Handle view.visibilityPolicy changed. + // XXXX : Handle view.visibilityPolicy changed. if(((View.VISIBILITY_POLICY_DIRTY != 0) && (View.VISIBILITY_DRAW_ALL != view.viewCache.visibilityPolicy)) || locale != ((ViewPlatformRetained) (vp.retained)).locale) { @@ -2050,7 +2074,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { RenderAtom ra = null; TextureBin tb; - AttributeBin ab; + ShaderBin sb; boolean reInsertNeeded = false; if (nc.mirror.changedFrequent == 0) { @@ -2101,9 +2125,9 @@ class RenderBin extends J3dStructure implements ObjectUpdate { tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TA; } else { - ab= ra.renderMolecule.textureBin.attributeBin; + sb= ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); - reInsertTextureBin(ab, ra); + reInsertTextureBin(sb, ra); } } } @@ -2113,7 +2137,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { RenderAtom ra = null; TextureBin tb; - AttributeBin ab; + ShaderBin sb; boolean reInsertNeeded = false; if (nc.mirror.changedFrequent == 0) { @@ -2164,9 +2188,9 @@ class RenderBin extends J3dStructure implements ObjectUpdate { tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TC; } else { - ab= ra.renderMolecule.textureBin.attributeBin; + sb= ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); - reInsertTextureBin(ab, ra); + reInsertTextureBin(sb, ra); } } } @@ -2178,7 +2202,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { RenderAtom ra = null; TextureBin tb; - AttributeBin ab; + ShaderBin sb; boolean reInsertNeeded = false; int command = ((Integer)args[1]).intValue(); @@ -2275,7 +2299,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { GeometryAtom[] gaArr) { RenderAtom ra = null; TextureBin tb; - AttributeBin ab; + ShaderBin sb; boolean mirrorSet = false; boolean firstTextureBin = true; @@ -2313,9 +2337,9 @@ class RenderBin extends J3dStructure implements ObjectUpdate { tb.soleUserCompDirty |= TextureBin.SOLE_USER_DIRTY_TUS; } else { - ab= ra.renderMolecule.textureBin.attributeBin; + sb = ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); - reInsertTextureBin(ab, ra); + reInsertTextureBin(sb, ra); } } } @@ -2359,7 +2383,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { if (ra== null || !ra.inRenderBin()) continue; if (restructure && !ra.renderMolecule.textureBin.attributeBin.soleUser) { - EnvironmentSet e= ra.renderMolecule.textureBin.attributeBin.environmentSet; + EnvironmentSet e= ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); /* @@ -2400,6 +2424,131 @@ class RenderBin extends J3dStructure implements ObjectUpdate { } } + /** + * This processes a shader component change. + */ + void processShaderComponentChanged(Object[] args) { + + // System.out.println("RenderBin : processShaderComponentChanged"); + + int component = ((Integer)args[1]).intValue(); + int i; + GeometryAtom[] gaArr = (GeometryAtom[] )args[3]; + GeometryAtom ga; + RenderAtom ra = null; + /* TODO : JADA - Sole user logic is incomplete. Will disable for JavaOne */ + // Note : args[0] may be a ShaderAppearanceRetained or ShaderAttributeSetRetained + //ShaderAppearanceRetained sApp = (ShaderAppearanceRetained) args[0]; + int start = -1; + + + // Get the first ra that is visible + for (i = 0; (i < gaArr.length && (start < 0)); i++) { + ra = gaArr[i].getRenderAtom(view); + if (ra== null || !ra.inRenderBin()) { + continue; + } + else { + start = i; + } + } + if (start >= 0) { + + + + boolean spUpdate = + ((component & ShaderAppearanceRetained.SHADER_PROGRAM) != 0); + boolean sasUpdate = + (((component & ShaderAppearanceRetained.SHADER_ATTRIBUTE_SET) != 0) || + ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_PUT) != 0) || + ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_REMOVE) != 0) || + ((component & ShaderAttributeSetRetained.ATTRIBUTE_SET_CLEAR) != 0) || + ((component & ShaderAttributeRetained.SHADER_ATTRIBUTE_VALUE_UPDATE) != 0)); + + if (spUpdate) { + /* TODO : JADA - Sole user logic is incomplete. Will disable for JavaOne */ + //if (false && (sApp.mirror.changedFrequent & component) != 0) { + if(false) { + /* + System.out.println("RenderBin : Shader sole user (SHADER_PROGRAM)" + + ra.renderMolecule.textureBin.shaderBin); + */ + + ShaderBin sBin; + + for (i = start; i < gaArr.length; i++) { + ra = gaArr[i].getRenderAtom(view); + if (ra== null || !ra.inRenderBin()) + continue; + + sBin = ra.renderMolecule.textureBin.shaderBin; + + if (sBin.componentDirty == 0) { + sBinUpdateList.add(sBin); + sBin.componentDirty |= ShaderBin.SHADER_PROGRAM_DIRTY; + } + } + } else { + /* + System.out.println("RenderBin : not soleUser (SHADER_PROGRAM)" + + ra.renderMolecule.textureBin.shaderBin); + */ + + for (i = 0; i < gaArr.length; i++) { + ra = gaArr[i].getRenderAtom(view); + if (ra== null || !ra.inRenderBin()) + continue; + + AttributeBin attrBin = ra.renderMolecule.textureBin.attributeBin; + ra.renderMolecule.removeRenderAtom(ra); + reInsertShaderBin(attrBin, ra); + } + } + } else if (sasUpdate) { + /* TODO : JADA - Sole user logic is incomplete. Will disable for JavaOne */ + //if (false && (sApp.mirror.changedFrequent & component) != 0) { + if(false) { + /* + System.out.println("RenderBin : sole user (SHADER_ATTRIBUTE_SET)" + + ra.renderMolecule.textureBin.shaderBin); + */ + + ShaderBin sBin; + + for (i = 0; i < gaArr.length; i++) { + ra = gaArr[i].getRenderAtom(view); + if (ra== null || !ra.inRenderBin()) + continue; + + + sBin = ra.renderMolecule.textureBin.shaderBin; + + if (sBin.componentDirty == 0) { + sBinUpdateList.add(sBin); + sBin.componentDirty |= ShaderBin.SHADER_ATTRIBUTE_SET_DIRTY; + } + } + } else { + /* + System.out.println("RenderBin :not soleUser (SHADER_ATTRIBUTE_SET) " + + ra.renderMolecule.textureBin.shaderBin); + */ + + for (i = 0; i < gaArr.length; i++) { + ra = gaArr[i].getRenderAtom(view); + if (ra== null || !ra.inRenderBin()) + continue; + + AttributeBin attrBin = ra.renderMolecule.textureBin.attributeBin; + ra.renderMolecule.removeRenderAtom(ra); + reInsertShaderBin(attrBin, ra); + } + } + } + } + + } + void processFogChanged(Object[] args) { FogRetained fog = (FogRetained)args[0]; @@ -2464,7 +2613,7 @@ class RenderBin extends J3dStructure implements ObjectUpdate { if ((component & TEXTURE_STATE_CHANGED) != 0) { - if (((app.changedFrequent & TEXTURE_STATE_CHANGED) != 0) && + if (((app.mirror.changedFrequent & TEXTURE_STATE_CHANGED) != 0) && ((ra.renderMolecule.textureBin.tbFlag & TextureBin.SOLE_USER) != 0)) { @@ -2501,8 +2650,8 @@ System.out.println("renderbin. texture state changed tb not sole user " + System.out.println("......tb.soleUser= " + ((ra.renderMolecule.textureBin.tbFlag & TextureBin.SOLE_USER) != 0) + - " app.changedFrequent= " + - ((app.changedFrequent & TEXTURE_STATE_CHANGED) != 0)); + " app.mirror.changedFrequent= " + + ((app.mirror.changedFrequent & TEXTURE_STATE_CHANGED) != 0)); */ @@ -2510,9 +2659,9 @@ System.out.println("......tb.soleUser= " + ra = gaArr[i].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) continue; - AttributeBin ab = ra.renderMolecule.textureBin.attributeBin; + ShaderBin sb = ra.renderMolecule.textureBin.shaderBin; ra.renderMolecule.removeRenderAtom(ra); - reInsertTextureBin(ab, ra); + reInsertTextureBin(sb, ra); } } } else if ((component & AppearanceRetained.RENDERING) != 0) { @@ -2551,7 +2700,7 @@ System.out.println("......tb.soleUser= " + ra = gaArr[i].getRenderAtom(view); if (ra== null || !ra.inRenderBin()) continue; - EnvironmentSet e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + EnvironmentSet e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2656,7 +2805,7 @@ System.out.println("......tb.soleUser= " + Object[] users = (Object[])(args[3]); int i; - // TODO: Handle other object affected by bounding leaf changes + // XXXX: Handle other object affected by bounding leaf changes for (i = 0; i < users.length; i++) { LeafRetained leaf = (LeafRetained)users[i]; switch(leaf.nodeType) { @@ -2725,7 +2874,7 @@ System.out.println("......tb.soleUser= " + continue; } ra.app = ra.geometryAtom.source.appearance; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2740,7 +2889,7 @@ System.out.println("......tb.soleUser= " + if (ra.app == ra.geometryAtom.source.otherAppearance) continue; ra.app = ra.geometryAtom.source.appearance; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2793,7 +2942,7 @@ System.out.println("......tb.soleUser= " + app = saveApp; } ra.app = app; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2860,7 +3009,7 @@ System.out.println("......tb.soleUser= " + continue; } ra.app = ra.geometryAtom.source.appearance; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2875,7 +3024,7 @@ System.out.println("......tb.soleUser= " + if (ra.app == ra.geometryAtom.source.otherAppearance) continue; ra.app = ra.geometryAtom.source.appearance; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -2926,7 +3075,7 @@ System.out.println("......tb.soleUser= " + app = saveApp; } ra.app = app; - e = ra.renderMolecule.textureBin.attributeBin.environmentSet; + e = ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } @@ -3243,7 +3392,7 @@ System.out.println("......tb.soleUser= " + } } - void processText3DTransformChanged(Object[] list, + private void processText3DTransformChanged(Object[] list, Object[] transforms, long referenceTime) { int i, j, numShapes; @@ -3290,7 +3439,7 @@ System.out.println("......tb.soleUser= " + } - void processOrderedGroupRemoved(J3dMessage m) { + private void processOrderedGroupRemoved(J3dMessage m) { int i, n; Object[] ogList = (Object[])m.args[0]; Object[] ogChildIdList = (Object[])m.args[1]; @@ -3329,7 +3478,7 @@ System.out.println("......tb.soleUser= " + } - void processOrderedGroupInserted(J3dMessage m) { + private void processOrderedGroupInserted(J3dMessage m) { Object[] ogList = (Object[])m.args[0]; Object[] ogChildIdList = (Object[])m.args[1]; Object[] ogOrderedIdList = (Object[])m.args[2]; @@ -3368,7 +3517,7 @@ System.out.println("......tb.soleUser= " + } } - void processTransformChanged(long referenceTime) { + private void processTransformChanged(long referenceTime) { int i, j, k, numRenderMolecules, n; Shape3DRetained s; RenderMolecule rm; @@ -3435,8 +3584,7 @@ System.out.println("......tb.soleUser= " + else { app = ra.geometryAtom.source.appearance; } - // TODO: Should we do a more extensive equals - // app? + // XXXX: Should we do a more extensive equals app? if (ra.envSet.equals(ra, lights, fog, modelClip) && app == ra.app) { @@ -3614,7 +3762,7 @@ System.out.println("......tb.soleUser= " + /** * This processes a LIGHT change. */ - void processLightChanged() { + private void processLightChanged() { int i, j, k, l, n; LightRetained lt; EnvironmentSet e; @@ -3785,7 +3933,7 @@ System.out.println("......tb.soleUser= " + - void processBgGeometryAtoms(GeometryAtom[] nodes, long referenceTime) { + private void processBgGeometryAtoms(GeometryAtom[] nodes, long referenceTime) { int i; GeometryAtom ga; RenderAtom renderAtom; @@ -3826,7 +3974,7 @@ System.out.println("......tb.soleUser= " + * This method looks through the list of RenderAtoms to see if * compaction is needed. */ - void checkForCompaction() { + private void checkForCompaction() { int i, numRas; int numDead = 0; int numAlive = 0; @@ -3879,7 +4027,7 @@ System.out.println("......tb.soleUser= " + } - void reEvaluateAlternateAppearance() { + private void reEvaluateAlternateAppearance() { AppearanceRetained app; EnvironmentSet e; Object[] retVal; @@ -3924,7 +4072,7 @@ System.out.println("......tb.soleUser= " + } - void reEvaluateAllRenderAtoms(boolean altAppDirty) { + private void reEvaluateAllRenderAtoms(boolean altAppDirty) { int sz = renderAtoms.size(); @@ -3966,7 +4114,7 @@ System.out.println("......tb.soleUser= " + // If the lights/fog/model_clip of the render atom is the same // as the old set of lights/fog/model_clip, then move on to the // next renderAtom - // TODO: Should app test for equivalent? + // XXXX: Should app test for equivalent? if (ra.envSet.equals(ra, lights, newfog, newModelClip) && app == ra.app) continue; @@ -3996,7 +4144,7 @@ System.out.println("......tb.soleUser= " + - void getNewEnvironment(RenderAtom ra, LightRetained[] lights, + private void getNewEnvironment(RenderAtom ra, LightRetained[] lights, FogRetained fog, ModelClipRetained modelClip, AppearanceRetained app) { @@ -4176,28 +4324,36 @@ System.out.println("......tb.soleUser= " + reInsertAttributeBin(eNew, ra); } - void reInsertAttributeBin(EnvironmentSet e, RenderAtom ra) { + + private void reInsertAttributeBin(EnvironmentSet e, RenderAtom ra) { AttributeBin ab; // Just go up to the environment and re-insert ab = findAttributeBin(e, ra); - reInsertTextureBin(ab, ra); + reInsertShaderBin(ab, ra); } + private void reInsertShaderBin(AttributeBin ab, RenderAtom ra) { + ShaderBin sb; + + // System.out.println("RenderBin.reInsertShaderBin() ra= " + ra); + sb = findShaderBin(ab, ra); + reInsertTextureBin(sb, ra); + } - void reInsertTextureBin(AttributeBin ab, RenderAtom ra) { + private void reInsertTextureBin(ShaderBin sb, RenderAtom ra) { TextureBin tb; - tb = findTextureBin(ab, ra); + tb = findTextureBin(sb, ra); reInsertRenderAtom(tb, ra); } - void reInsertRenderAtom(TextureBin tb, RenderAtom ra) { + private void reInsertRenderAtom(TextureBin tb, RenderAtom ra) { RenderMolecule newRm; // Just go up to the texture bin and re-insert newRm = findRenderMolecule(tb, ra); } - void computeViewFrustumBBox(BoundingBox viewFrustumBBox) { + private void computeViewFrustumBBox(BoundingBox viewFrustumBBox) { //Initial view frustumBBox BBox viewFrustumBBox.lower.x = Float.POSITIVE_INFINITY; viewFrustumBBox.lower.y = Float.POSITIVE_INFINITY; @@ -4241,10 +4397,11 @@ System.out.println("......tb.soleUser= " + /** * This inserts a RenderAtom into the appropriate bin. */ - RenderMolecule insertRenderAtom(RenderAtom ra) { + private RenderMolecule insertRenderAtom(RenderAtom ra) { LightBin lightBin; EnvironmentSet environmentSet; AttributeBin attributeBin; + ShaderBin shaderBin; TextureBin textureBin; RenderMolecule renderMolecule; OrderedCollection oc; @@ -4301,7 +4458,11 @@ System.out.println("......tb.soleUser= " + // determined environmentSet = findEnvironmentSet(ra); attributeBin = findAttributeBin(environmentSet, ra); - textureBin = findTextureBin(attributeBin, ra); + + // System.out.println("RenderBin : findShaderBin()"); + shaderBin = findShaderBin(attributeBin, ra); + + textureBin = findTextureBin(shaderBin, ra); renderMolecule = findRenderMolecule(textureBin, ra); ra.setRenderBin(true); renderAtoms.add(ra); @@ -4347,7 +4508,7 @@ System.out.println("......tb.soleUser= " + return (renderMolecule); } - OrderedCollection findOrderedCollection(GeometryAtom ga, + private OrderedCollection findOrderedCollection(GeometryAtom ga, boolean doBackground) { int i, n; int oi; // an id which identifies a children of the orderedGroup @@ -4509,7 +4670,7 @@ System.out.println("......tb.soleUser= " + return (oc); } - void removeOrderedHeadLightBin(LightBin lightBin) { + private void removeOrderedHeadLightBin(LightBin lightBin) { int i, k; int oi; // an id which identifies a children of the orderedGroup int ci; // child index of the ordered group @@ -4541,7 +4702,7 @@ System.out.println("......tb.soleUser= " + * This gets a new EnviornmentSet. It creates one if there are none * on the freelist. */ - EnvironmentSet getEnvironmentSet(RenderAtom ra, LightRetained[] lights, + private EnvironmentSet getEnvironmentSet(RenderAtom ra, LightRetained[] lights, FogRetained fog, ModelClipRetained modelClip) { EnvironmentSet envSet; @@ -4554,10 +4715,11 @@ System.out.println("......tb.soleUser= " + } return (envSet); } + /** * This finds or creates an AttributeBin for a given RenderAtom. */ - AttributeBin findAttributeBin(EnvironmentSet envSet, RenderAtom ra) { + private AttributeBin findAttributeBin(EnvironmentSet envSet, RenderAtom ra) { int i; AttributeBin currentBin; RenderingAttributesRetained renderingAttributes; @@ -4566,7 +4728,6 @@ System.out.println("......tb.soleUser= " + } else { renderingAttributes = ra.app.renderingAttributes; } - currentBin = envSet.attributeBinList; while (currentBin != null) { @@ -4575,7 +4736,6 @@ System.out.println("......tb.soleUser= " + } currentBin = currentBin.next; } - // Check the "to-be-added" list of attributeBins for a match for (i = 0; i < envSet.addAttributeBins.size(); i++) { currentBin = (AttributeBin)envSet.addAttributeBins.get(i); @@ -4583,59 +4743,88 @@ System.out.println("......tb.soleUser= " + return(currentBin); } } - currentBin = getAttributeBin(ra.app, renderingAttributes); envSet.addAttributeBin(currentBin, this); return(currentBin); } /** - * This finds or creates a TextureBin for a given RenderAtom. + * This finds or creates an ShaderBin for a given RenderAtom. */ - TextureBin findTextureBin(AttributeBin attributeBin, RenderAtom ra) { + private ShaderBin findShaderBin(AttributeBin attributeBin, RenderAtom ra) { + int i, size; + ShaderBin currentBin; + ShaderAppearanceRetained sApp; + if((ra != null) && (ra.app instanceof ShaderAppearanceRetained)) + sApp = (ShaderAppearanceRetained)ra.app; + else + sApp = null; - int i; + currentBin = attributeBin.shaderBinList; + while (currentBin != null) { + if (currentBin.equals(sApp)) { + return currentBin; + } + currentBin = currentBin.next; + } + + // Check the "to-be-added" list of shaderBins for a match + size = attributeBin.addShaderBins.size(); + for (i = 0; i < size; i++) { + currentBin = (ShaderBin)attributeBin.addShaderBins.get(i); + if (currentBin.equals(sApp)) { + return currentBin; + } + } + + currentBin = getShaderBin(sApp); + attributeBin.addShaderBin(currentBin, this, sApp); + return currentBin; + } + + /** + * This finds or creates a TextureBin for a given RenderAtom. + */ + private TextureBin findTextureBin(ShaderBin shaderBin, RenderAtom ra) { + int i, size; TextureBin currentBin; TextureRetained texture; TextureUnitStateRetained texUnitState[]; - RenderingAttributesRetained rAttrs = - (ra.geometryAtom.source.appearance == null)? null: - ra.geometryAtom.source.appearance.renderingAttributes; - if (ra.app == null) { texUnitState = null; } else { texUnitState = ra.app.texUnitState; } - currentBin = attributeBin.textureBinList; + currentBin = shaderBin.textureBinList; while (currentBin != null) { if (currentBin.equals(texUnitState, ra)) { - //System.out.println("1: Equal"); + //System.out.println("1: Equal"); return(currentBin); } currentBin = currentBin.next; } // Check the "to-be-added" list of TextureBins for a match - for (i = 0; i < attributeBin.addTBs.size(); i++) { - currentBin = (TextureBin)attributeBin.addTBs.get(i); + size = shaderBin.addTextureBins.size(); + for (i = 0; i < size; i++) { + currentBin = (TextureBin)shaderBin.addTextureBins.get(i); if (currentBin.equals(texUnitState, ra)) { - //System.out.println("2: Equal"); + //System.out.println("2: Equal"); return(currentBin); } } // get a new texture bin for this texture unit state currentBin = getTextureBin(texUnitState, ra.app); - attributeBin.addTextureBin(currentBin, this, ra); + shaderBin.addTextureBin(currentBin, this, ra); return(currentBin); } /** * This finds or creates a RenderMolecule for a given RenderAtom. */ - RenderMolecule findRenderMolecule(TextureBin textureBin, + private RenderMolecule findRenderMolecule(TextureBin textureBin, RenderAtom ra) { RenderMolecule currentBin; @@ -4691,7 +4880,7 @@ System.out.println("......tb.soleUser= " + ra.geometryAtom.source.localToVworld[0])) { currentBin.addRenderAtom(ra, this); - ra.envSet = ra.renderMolecule.textureBin.attributeBin.environmentSet; + ra.envSet = ra.renderMolecule.textureBin.environmentSet; // If the locale has changed for an existing renderMolecule // handle the RmlocaleToVworld return(currentBin); @@ -4731,12 +4920,26 @@ System.out.println("......tb.soleUser= " + return(currentBin); } + /** + * This gets a new ShaderBin. It creates one if there are none + * on the freelist. + */ + private ShaderBin getShaderBin(ShaderAppearanceRetained sApp) { + ShaderBin shaderBin; + if (shaderBinFreelist.size() > 0) { + shaderBin = (ShaderBin)shaderBinFreelist.remove(shaderBinFreelist.size()-1); + shaderBin.reset(sApp, this); + } else { + shaderBin = new ShaderBin( sApp, this); + } + return (shaderBin); + } /** * This gets a new AttributeBin. It creates one if there are none * on the freelist. */ - AttributeBin getAttributeBin(AppearanceRetained app, RenderingAttributesRetained ra) { + private AttributeBin getAttributeBin(AppearanceRetained app, RenderingAttributesRetained ra) { AttributeBin attrBin; if (attrBinFreelist.size() > 0) { attrBin = (AttributeBin)attrBinFreelist.remove( @@ -4754,7 +4957,7 @@ System.out.println("......tb.soleUser= " + * This gets a new LightBin. It creates one if there are none * on the freelist. */ - LightBin getLightBin(int maxLights, BackgroundRetained bg, boolean inOpaque) { + private LightBin getLightBin(int maxLights, BackgroundRetained bg, boolean inOpaque) { LightBin lightBin; if (lightBinFreelist.size() > 0) { @@ -4772,7 +4975,7 @@ System.out.println("......tb.soleUser= " + * This gets a new TextureBin. It creates one if there are none * on the freelist. */ - TextureBin getTextureBin(TextureUnitStateRetained texUnitState[], + private TextureBin getTextureBin(TextureUnitStateRetained texUnitState[], AppearanceRetained app) { TextureBin textureBin; @@ -4791,7 +4994,7 @@ System.out.println("......tb.soleUser= " + * This gets a new RenderMolecule. It creates one if there are none * on the freelist. */ - RenderMolecule getRenderMolecule(GeometryAtom ga, + private RenderMolecule getRenderMolecule(GeometryAtom ga, PolygonAttributesRetained polya, LineAttributesRetained linea, PointAttributesRetained pointa, @@ -4823,7 +5026,7 @@ System.out.println("......tb.soleUser= " + * This finds or creates an EnviornmentSet for a given RenderAtom. * This also deals with empty LightBin lists. */ - EnvironmentSet findEnvironmentSet(RenderAtom ra) { + private EnvironmentSet findEnvironmentSet(RenderAtom ra) { LightBin currentBin, lightBin ; EnvironmentSet currentEnvSet, newBin; int i; @@ -5040,9 +5243,9 @@ System.out.println("......tb.soleUser= " + */ void renderOpaque(Canvas3D cv) { LightBin currentBin = opaqueBin; - // System.out.println("========> renderOpaque"); + //System.out.println("========> renderOpaque"); while (currentBin != null) { - // System.out.println("====> rendering Opaque Bin "); + //System.out.println("====> rendering Opaque Bin "); currentBin.render(cv); currentBin = currentBin.next; } @@ -5055,9 +5258,10 @@ System.out.println("......tb.soleUser= " + void renderTransparent(Canvas3D cv) { boolean savedDepthBufferWriteEnable = true; + //System.out.println("====> renderTransparent"); TransparentRenderingInfo tinfo = transparentInfo; if (tinfo != null) { - // System.out.println("====> rendering transparent Bin"); + //System.out.println("====> rendering transparent Bin"); if (cv.view.depthBufferFreezeTransparent) { cv.setDepthBufferWriteEnableOverride(true); @@ -5110,9 +5314,7 @@ System.out.println("......tb.soleUser= " + OrderedCollection oc; boolean depthBufferEnable = true; OrderedGroupRetained og = orderedBin.source; - boolean isDecal = (og instanceof DecalGroupRetained) && - ((cv.extensionsSupported & Canvas3D.STENCIL_BUFFER) != 0); - + boolean isDecal = (og instanceof DecalGroupRetained) && cv.systemStencilAvailable; int size = orderedBin.orderedCollections.size(); // System.out.println("RB : orderedBin.orderedCollections.size() " + size); @@ -5198,9 +5400,14 @@ System.out.println("......tb.soleUser= " + Canvas3D canvases[] = view.getCanvases(); for (int i=0; i< canvases.length; i++) { Canvas3D canvas = canvases[i]; - if(cvDirty) - canvas.cvDirtyMask |= Canvas3D.BACKGROUND_DIRTY; - canvas.cvDirtyMask |= Canvas3D.BACKGROUND_IMAGE_DIRTY; + synchronized (canvas.dirtyMaskLock) { + if(cvDirty) { + canvas.cvDirtyMask[0] |= Canvas3D.BACKGROUND_DIRTY; + canvas.cvDirtyMask[1] |= Canvas3D.BACKGROUND_DIRTY; + } + canvas.cvDirtyMask[0] |= Canvas3D.BACKGROUND_IMAGE_DIRTY; + canvas.cvDirtyMask[1] |= Canvas3D.BACKGROUND_IMAGE_DIRTY; + } } } @@ -5801,6 +6008,7 @@ System.out.println("......tb.soleUser= " + lightBinFreelist.clear(); envSetFreelist.clear(); attrBinFreelist.clear(); + shaderBinFreelist.clear(); textureBinFreelist.clear(); renderMoleculeFreelist.clear(); @@ -5848,22 +6056,26 @@ System.out.println("......tb.soleUser= " + AttributeBin abin = envSet.attributeBinList; while (abin != null) { System.out.println(" ABin = "+abin); - TextureBin tbin = abin.textureBinList; - while (tbin != null) { - System.out.println(" Tbin = "+tbin); - RenderMolecule rm = tbin.opaqueRMList; - System.out.println("===> Begin Dumping OpaqueBin"); - dumpRM(rm); - System.out.println("===> End Dumping OpaqueBin"); - rm = tbin.transparentRMList; - System.out.println("===> Begin Dumping transparentBin"); - dumpRM(rm); - System.out.println("===> End Dumping transparentBin"); - tbin = tbin.next; + ShaderBin sbin = abin.shaderBinList; + while (sbin != null) { + System.out.println(" SBin = "+sbin); + TextureBin tbin = sbin.textureBinList; + while (tbin != null) { + System.out.println(" Tbin = "+tbin); + RenderMolecule rm = tbin.opaqueRMList; + System.out.println("===> Begin Dumping OpaqueBin"); + dumpRM(rm); + System.out.println("===> End Dumping OpaqueBin"); + rm = tbin.transparentRMList; + System.out.println("===> Begin Dumping transparentBin"); + dumpRM(rm); + System.out.println("===> End Dumping transparentBin"); + tbin = tbin.next; + } + sbin = sbin.next; } abin = abin.next; } - envSet = envSet.next; } obin = obin.next; @@ -5914,7 +6126,7 @@ System.out.println("......tb.soleUser= " + // System.out.println("&&&&&&&&&&&&removeTransparentObject r = "+obj); if (obj instanceof TextureBin) { TextureBin tb = (TextureBin) obj; - if (tb.attributeBin.environmentSet.lightBin.geometryBackground != null) { + if (tb.environmentSet.lightBin.geometryBackground != null) { TransparentRenderingInfo t = tb.parentTInfo; // Remove the element from the transparentInfo struct @@ -6018,7 +6230,7 @@ System.out.println("......tb.soleUser= " + if (obj instanceof TextureBin) { TextureBin tb = (TextureBin) obj; // Background geometry - if (tb.attributeBin.environmentSet.lightBin.geometryBackground != null) { + if (tb.environmentSet.lightBin.geometryBackground != null) { bgTransparentInfo = computeDirtyAcrossTransparentBins(tb, bgTransparentInfo); } else { @@ -6063,8 +6275,8 @@ System.out.println("......tb.soleUser= " + TransparentRenderingInfo computeDirtyAcrossTransparentBins(TextureBin tb, TransparentRenderingInfo startinfo) { TransparentRenderingInfo tinfo = getTransparentInfo(); /* - tinfo.lightBin = tb.attributeBin.environmentSet.lightBin; - tinfo.envSet = tb.attributeBin.environmentSet; + tinfo.lightBin = tb.environmentSet.lightBin; + tinfo.envSet = tb.environmentSet; tinfo.aBin = tb.attributeBin; */ tinfo.rm = tb.transparentRMList; @@ -6257,7 +6469,16 @@ System.out.println("......tb.soleUser= " + zval1 = input1.zVal; zval2 = input2.zVal; // Put the newList before the current one - if (zval2 > zval1) { + +// System.out.print("Code path 1 "); +// if (transparencySortComparator!=null) +// if (zval2 > zval1 && (transparencySortComparator.compare(input2, input1)>0)) +// System.out.println("PASS"); +// else +// System.out.println("FAIL"); + + if ((transparencySortComparator==null && zval2 > zval1) || + (transparencySortComparator!=null && (transparencySortComparator.compare(input2, input1)>0))){ // System.out.println("===> path1"); if (input1.prev == null) { input1.prev = input2; @@ -6293,38 +6514,48 @@ System.out.println("......tb.soleUser= " + return oldList; } - void insertDepthSort(RenderAtom r) { - TransparentRenderingInfo tinfo = null; - // System.out.println("&&&&&&&&insertDepthSort"); - for (int i = 0; i < r.rListInfo.length; i++) { - if (r.parentTInfo[i] == null) - continue; - - if (transparentInfo == null) { - transparentInfo = r.parentTInfo[i]; - transparentInfo.prev = null; - transparentInfo.next = null; - } - else { - tinfo = transparentInfo; - TransparentRenderingInfo prevInfo = transparentInfo; - while (tinfo != null&& r.parentTInfo[i].zVal < tinfo.zVal) { - prevInfo = tinfo; - tinfo = tinfo.next; - } - r.parentTInfo[i].prev = prevInfo; - if (prevInfo.next != null) { - prevInfo.next.prev = r.parentTInfo[i]; - } - r.parentTInfo[i].next = prevInfo.next; - prevInfo.next = r.parentTInfo[i]; - - } - - } - } - - +// void insertDepthSort(RenderAtom r) { +// TransparentRenderingInfo tinfo = null; +// // System.out.println("&&&&&&&&insertDepthSort"); +// for (int i = 0; i < r.rListInfo.length; i++) { +// if (r.parentTInfo[i] == null) +// continue; +// +// if (transparentInfo == null) { +// transparentInfo = r.parentTInfo[i]; +// transparentInfo.prev = null; +// transparentInfo.next = null; +// } +// else { +// tinfo = transparentInfo; +// TransparentRenderingInfo prevInfo = transparentInfo; +// if (transparencySortComparator==null) +// while (tinfo != null && r.parentTInfo[i].zVal < tinfo.zVal) { +// prevInfo = tinfo; +// tinfo = tinfo.next; +// } +// else { +// System.out.println("Code Path 2 "); +// if (tinfo!=null && (transparencySortComparator.compare(r.parentTInfo[i], tinfo)<0)==r.parentTInfo[i].zVal < tinfo.zVal) +// System.out.println("PASS"); +// else +// System.out.println("FAIL"); +// while (tinfo != null && transparencySortComparator.compare(r.parentTInfo[i], tinfo)<0) { +// prevInfo = tinfo; +// tinfo = tinfo.next; +// } +// } +// r.parentTInfo[i].prev = prevInfo; +// if (prevInfo.next != null) { +// prevInfo.next.prev = r.parentTInfo[i]; +// } +// r.parentTInfo[i].next = prevInfo.next; +// prevInfo.next = r.parentTInfo[i]; +// +// } +// +// } +// } TransparentRenderingInfo collectDirtyTRInfo( TransparentRenderingInfo dirtyList, RenderAtom r) { @@ -6371,6 +6602,7 @@ System.out.println("......tb.soleUser= " + TransparentRenderingInfo depthSortAll(TransparentRenderingInfo startinfo) { + transparencySortComparator = com.sun.j3d.utils.scenegraph.transparency.TransparencySortController.getComparator(view); TransparentRenderingInfo tinfo, previnfo, nextinfo; double curZ; // System.out.println("&&&&&&&&&&&depthSortAll"); @@ -6390,10 +6622,21 @@ System.out.println("......tb.soleUser= " + previnfo = tinfo.prev; // Find the correct location for tinfo - while (previnfo != null && previnfo.zVal < curZ) { - previnfo = previnfo.prev; - - } + if (transparencySortComparator==null) { + while (previnfo != null && previnfo.zVal < curZ) { + previnfo = previnfo.prev; + } + } else { +// System.out.println("Code Path 3 "); +// if (tinfo!=null && (transparencySortComparator.compare(previnfo, tinfo)<0)==previnfo.zVal < curZ) +// System.out.println("PASS"); +// else +// System.out.println("FAIL"); + while (previnfo != null && transparencySortComparator.compare(previnfo,tinfo)<0) { + previnfo = previnfo.prev; + } + } + if (tinfo.prev != previnfo) { if (previnfo == null) { if (tinfo.next != null) { @@ -6764,7 +7007,7 @@ System.out.println("......tb.soleUser= " + // context creation bits for this canvas, but don't do anything // with the geo's user list. if (geo.dlistId > 0) { - // TODO: for the shared ctx case, we really should + // XXXX: for the shared ctx case, we really should // only free the display lists if this is the last // Canvas in the renderer. However, since the // display lists will be recreated, it doesn't @@ -6936,14 +7179,14 @@ System.out.println("......tb.soleUser= " + if (ra== null || !ra.inRenderBin()) continue; - EnvironmentSet e= ra.renderMolecule.textureBin.attributeBin.environmentSet; + EnvironmentSet e= ra.renderMolecule.textureBin.environmentSet; ra.renderMolecule.removeRenderAtom(ra); reInsertAttributeBin(e, ra); } } else { - // TODO: handle texture + // XXXX: handle texture } diff --git a/src/classes/share/javax/media/j3d/RenderMolecule.java b/src/classes/share/javax/media/j3d/RenderMolecule.java index d52cd93..61672cf 100644 --- a/src/classes/share/javax/media/j3d/RenderMolecule.java +++ b/src/classes/share/javax/media/j3d/RenderMolecule.java @@ -45,7 +45,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen AppearanceRetained.TRANSPARENCY| AppearanceRetained.COLOR); - // TODO: use definingMaterial etc. instead of these + // XXXX: use definingMaterial etc. instead of these // when sole user is completely implement PolygonAttributesRetained polygonAttributes = null; LineAttributesRetained lineAttributes = null; @@ -740,7 +740,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen k++; } - // TODO: Add tags + // XXXX: Add tags switch (ga.geoType) { case GeometryRetained.GEO_TYPE_POINT_SET: case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET: @@ -788,7 +788,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen return (false); } /* - // TODO : Check this + // XXXX : Check this if (useDisplayList && (ga.geometry.isEditable || ga.geometry.refCount > 1 || @@ -811,7 +811,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen return (false); } - // TODO: Its is necessary to have same vformat for dl, + // XXXX: Its is necessary to have same vformat for dl, // Howabout iteration, should we have 2 vformats in rm? if (geo instanceof GeometryArrayRetained) { GeometryArrayRetained gr = (GeometryArrayRetained)geo; @@ -845,7 +845,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen return (false); } } else { - //TODO: compare isEditable + //XXXX: compare isEditable if (this.vertexFormat != -1) { return (false); } @@ -1143,7 +1143,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen renderBin.orientedRAs.remove(renderBin.orientedRAs.indexOf(r)); } - if ((textureBin.attributeBin.environmentSet.lightBin.geometryBackground == null) && + if ((textureBin.environmentSet.lightBin.geometryBackground == null) && !isOpaqueOrInOG && renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) { renderBin.removeTransparentObject(r); } @@ -1318,7 +1318,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen } // If transparent and not in bg geometry and is depth sorted transparency - if (!isOpaqueOrInOG && (textureBin.attributeBin.environmentSet.lightBin.geometryBackground == null)&& + if (!isOpaqueOrInOG && (textureBin.environmentSet.lightBin.geometryBackground == null)&& (renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY)) { GeometryRetained geo = null; int k = 0; @@ -1401,36 +1401,11 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen } boolean canBeInDisplayList(GeometryRetained geo, GeometryAtom ga) { - boolean inDL = false; - inDL = geo.canBeInDisplayList(ga.alphaEditable); - // If can not in DL, then check if all the attrs affecting - // it are infrequently changing, if yes then put it - // Exclude Morph and indexed-by-ref-use-index-coord only for now - // in displayList if OptimizeForSpace if false - - // System.out.println("inDL = "+inDL); - // System.out.println("geo.cachedChangedFrequent = "+geo.cachedChangedFrequent); - // System.out.println("inDL = "+inDL); - // System.out.println("COLOR = "+((((GeometryArrayRetained)geo).vertexFormat& - // GeometryArray.COLOR) != 0)); - // System.out.println("Before: inDL = "+inDL); - // System.out.println("VirtualUniverse.mc.buildDisplayListIfPossible = "+VirtualUniverse.mc.buildDisplayListIfPossible); - if (VirtualUniverse.mc.buildDisplayListIfPossible && - !inDL && - !(ga.source.sourceNode instanceof MorphRetained || - (geo instanceof GeometryArrayRetained && - ((((GeometryArrayRetained)geo).vertexFormat & (GeometryArray.USE_NIO_BUFFER|GeometryArray.INTERLEAVED)) ==(GeometryArray.USE_NIO_BUFFER|GeometryArray.INTERLEAVED))) || - (geo instanceof IndexedGeometryArrayRetained && - ((((IndexedGeometryArrayRetained)geo).vertexFormat & (GeometryArray.BY_REFERENCE|GeometryArray.USE_COORD_INDEX_ONLY)) == (GeometryArray.BY_REFERENCE|GeometryArray.USE_COORD_INDEX_ONLY))))) { - // Check if geometry is frequentlyEditable - boolean alphaFreqEditable = ga.source.isAlphaFrequentlyEditable(geo); - inDL = !((geo.cachedChangedFrequent != 0) || - ((!(geo instanceof GeometryArrayRetained) && alphaFreqEditable)|| - (alphaFreqEditable && ((((GeometryArrayRetained)geo).vertexFormat& - GeometryArray.COLOR) != 0)))); - } - // System.out.println("After: inDL = "+inDL); - return inDL; + if (ga.source.sourceNode instanceof MorphRetained) { + return false; + } + + return geo.canBeInDisplayList(ga.alphaEditable); } // If dlist will be altered due to alpha or ignoreVertexColors, then don't @@ -1498,7 +1473,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen RenderAtomListInfo r; int index; - renderAtom.envSet = textureBin.attributeBin.environmentSet; + renderAtom.envSet = textureBin.environmentSet; renderAtom.renderMolecule = this; renderAtom.dirtyMask &= ~RenderAtom.NEED_SEPARATE_LOCALE_VWC_BOUNDS; @@ -1732,8 +1707,6 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen void evalAlphaUsage(RenderingAttributesRetained renderAttrs, TextureUnitStateRetained[] texUnits) { - RenderingAttributesRetained ra; - TextureAttributesRetained ta; boolean alphaBlend, alphaTest, textureBlend = false; alphaBlend = @@ -1847,7 +1820,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen // we'll have to punt to vertex array as well. if ((pass != TextureBin.USE_DISPLAYLIST) || - (texCoordSetMapLen > cv.numTexCoordSupported) || + (texCoordSetMapLen > cv.maxTexCoordSets) || (VirtualUniverse.mc.isD3D() && (((definingPolygonAttributes != null) && ((isQuadGeometryArray && @@ -1862,7 +1835,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen /* System.out.println("texCoord " + texCoordSetMapLen + " " + - cv.numTexCoordSupported + " " + modeSupportDL); + cv.maxTexCoordSets + " " + modeSupportDL); System.out.println("primaryMoleculeType = "+primaryMoleculeType+" primaryRenderAtomList ="+primaryRenderAtomList+" separateDlistRenderAtomList ="+separateDlistRenderAtomList+" vertexArrayRenderAtomList ="+vertexArrayRenderAtomList); */ @@ -1934,7 +1907,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen } - // TODO: In the case of independent primitives such as quads, + // XXXX: In the case of independent primitives such as quads, // it would still be better to call multi draw arrays if (vertexArrayRenderAtomList != null) { if (pass == TextureBin.USE_DISPLAYLIST) { @@ -2171,7 +2144,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen // instead. if ((pass != TextureBin.USE_DISPLAYLIST) || - (texCoordSetMapLen > cv.numTexCoordSupported) || + (texCoordSetMapLen > cv.maxTexCoordSets) || (VirtualUniverse.mc.isD3D() && (((definingPolygonAttributes != null) && ((isQuadGeometryArray && @@ -2188,7 +2161,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen // System.out.println("r.isOpaque = "+isOpaque+" rinfo = "+tinfo.rInfo+" groupType = "+tinfo.rInfo.groupType); // Only support individual dlist or varray // If this rInfo is a part of a bigger dlist, render as VA - // TODO: What to do with Text3D, Raster, CG? + // XXXX: What to do with Text3D, Raster, CG? if ((tinfo.rInfo.groupType & RenderAtom.SEPARATE_DLIST_PER_RINFO) != 0) { RenderAtomListInfo save= tinfo.rInfo.next; // Render only one geometry @@ -2353,7 +2326,7 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen void checkEquivalenceWithLeftNeighbor(RenderMolecule rm, int dirtyBits) { boolean reload_color = reloadColor(rm); - // TODO : For now ignore the dirtyBits being sent in + // XXXX : For now ignore the dirtyBits being sent in dirtyAttrsAcrossRms = ALL_DIRTY_BITS ; @@ -2703,6 +2676,30 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen } + // Issue 129: method to add or remove all rendering atoms in this + // RenderMolecule to or from the transparent info list when we are + // in depth sorted transparency mode and the RenderMolecule + // changes from opaque to transparent or vice versa. + void addRemoveTransparentObject(RenderBin renderBin, boolean add) { + addRemoveTransparentObject(renderBin, add, primaryRenderAtomList); + addRemoveTransparentObject(renderBin, add, separateDlistRenderAtomList); + addRemoveTransparentObject(renderBin, add, vertexArrayRenderAtomList); + } + + private void addRemoveTransparentObject(RenderBin renderBin, + boolean add, + RenderAtomListInfo rinfo) { + while (rinfo != null) { + if (add) { + renderBin.addTransparentObject(rinfo.renderAtom); + } + else { + renderBin.removeTransparentObject(rinfo.renderAtom); + } + rinfo = rinfo.next; + } + } + void evalMaterialCachedState() { if (definingMaterial == null) { enableLighting = false;; @@ -3118,7 +3115,3 @@ class RenderMolecule extends IndexedObject implements ObjectUpdate, NodeComponen } } } - - - - diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java index 4f52a06..bb61822 100644 --- a/src/classes/share/javax/media/j3d/Renderer.java +++ b/src/classes/share/javax/media/j3d/Renderer.java @@ -96,6 +96,8 @@ class Renderer extends J3dThread { // an unique bit to identify this renderer int rendererBit = 0; + // an unique number to identify this renderer : ( rendererBit = 1 << rendererId) + int rendererId = 0; // List of renderMolecules that are dirty due to additions // or removal of renderAtoms from their display list set @@ -117,10 +119,6 @@ class Renderer extends J3dThread { ArrayList textureReloadList = new ArrayList(); - // This is a local copy of canvas view cache. It is used as a data storage for the - // renderer. Note: This isn't the "real" canvasViewCache references by the Canvas. - CanvasViewCache copyOfCvCache = new CanvasViewCache(null, null, null); - J3dMessage[] renderMessage; // The screen for this Renderer. Note that this renderer may share @@ -178,7 +176,8 @@ class Renderer extends J3dThread { setName("J3D-Renderer-" + getInstanceNum()); type = J3dThread.RENDER_THREAD; - rendererBit = VirtualUniverse.mc.getRendererBit(); + rendererId = VirtualUniverse.mc.getRendererId(); + rendererBit = (1 << rendererId); renderMessage = new J3dMessage[1]; } @@ -391,7 +390,25 @@ class Renderer extends J3dThread { c.doubleBufferAvailable = nct.hasDoubleBuffer(c); c.stereoAvailable = nct.hasStereo(c); } - c.sceneAntialiasingMultiSamplesAvailable = + + // Setup stencil related variables. + c.actualStencilSize = nct.getStencilSize(c); + boolean userOwnsStencil = c.requestedStencilSize > 0; + + c.userStencilAvailable = + (userOwnsStencil && (c.actualStencilSize > 0)); + c.systemStencilAvailable = + (!userOwnsStencil && (c.actualStencilSize > 0)); + + /* + System.out.println("Renderer :check for nct configuration"); + System.out.println("-- userStencilAvailable " + + c.userStencilAvailable); + System.out.println("-- systemStencilAvailable " + + c.systemStencilAvailable); + */ + + c.sceneAntialiasingMultiSamplesAvailable = nct.hasSceneAntialiasingMultisample(c); if (c.sceneAntialiasingMultiSamplesAvailable) { @@ -667,13 +684,7 @@ class Renderer extends J3dThread { } synchronized (VirtualUniverse.mc.contextCreationLock) { - sharedCtx = - canvas.createNewContext(canvas.screen.display, - canvas.window, - canvas.vid, - canvas.fbConfig, - 0, true, - canvas.offScreen); + sharedCtx = canvas.createNewContext(0, true); if (sharedCtx == 0) { canvas.drawingSurfaceObject.unLock(); if ((offBufRetained != null) && @@ -706,15 +717,9 @@ class Renderer extends J3dThread { } synchronized (VirtualUniverse.mc.contextCreationLock) { - canvas.ctx = - canvas.createNewContext(canvas.screen.display, - canvas.window, canvas.vid, - canvas.fbConfig, sharedCtx, - false, canvas.offScreen); - - + canvas.ctx = canvas.createNewContext(sharedCtx, false); - if (canvas.ctx == 0) { + if (canvas.ctx == 0) { canvas.drawingSurfaceObject.unLock(); if ((offBufRetained != null) && offBufRetained.isByReference()) { @@ -737,56 +742,29 @@ class Renderer extends J3dThread { NodeComponentRetained nc = (NodeComponentRetained)renderBin.nodeComponentList.get(i); nc.evaluateExtensions(canvas.extensionsSupported); } - } - - - // query for the number of texture units supported - if (canvas.multiTexAccelerated) { - canvas.numTexUnitSupported = - canvas.getTextureUnitCount(canvas.ctx); - if (VirtualUniverse.mc.textureUnitMax < canvas.numTexUnitSupported) { - canvas.numTexUnitSupported = VirtualUniverse.mc.textureUnitMax; - } - } + } - // enable separate specular color + // enable separate specular color canvas.enableSeparateSpecularColor(); - } + // create the cache texture state in canvas + // for state download checking purpose + if (canvas.texUnitState == null) { + canvas.createTexUnitState(); + } - // create the cache texture state in canvas - // for state download checking purpose - - if (canvas.texUnitState == null) { - canvas.texUnitState = - new TextureUnitStateRetained[ - canvas.numTexCoordSupported]; - for (int t = 0; t < canvas.numTexCoordSupported; - t++) { - canvas.texUnitState[t] = - new TextureUnitStateRetained(); - canvas.texUnitState[t].texture = null; - canvas.texUnitState[t].mirror = null; - } - } - + // Create the texture unit state map + if (canvas.texUnitStateMap == null) { + canvas.createTexUnitStateMap(); + } - // also create the texture unit state map - // which is a mapping from texture unit state to - // the actual underlying texture unit + canvas.resetImmediateRendering(Canvas3D.NOCHANGE); + canvas.drawingSurfaceObject.contextValidated(); - if (canvas.texUnitStateMap == null) { - canvas.texUnitStateMap = - new int[canvas.numTexCoordSupported]; - } - - canvas.resetImmediateRendering(Canvas3D.NOCHANGE); - canvas.drawingSurfaceObject.contextValidated(); - - if (!canvas.useSharedCtx) { - canvas.needToRebuildDisplayList = true; - } + if (!canvas.useSharedCtx) { + canvas.needToRebuildDisplayList = true; + } canvas.drawingSurfaceObject.unLock(); } else { @@ -819,30 +797,22 @@ class Renderer extends J3dThread { // save the BACKGROUND_IMAGE_DIRTY before canvas.updateViewCache // clean it - background_image_update = - ((canvas.cvDirtyMask & Canvas3D.BACKGROUND_IMAGE_DIRTY) != 0); - - // copyOfcvCache is a copy of canvas view - // cache. It is used as a data storage for the - // renderer. Note: This isn't the "real" - // canvasViewCache references by the Canvas. - // - // Note : For performance reason, copyOfcvCache - // doesn't contain are valid canvasViewCache info., - // only data needed by the renderer are stored. - // - // The valid data are : useStereo, canvasWidth, - // canvasHeight, leftProjection, rightProjection, - // leftVpcToEc, rightVpcToEc, leftFrustumPlanes, - // rightFrustumPlanes, vpcToVworld and vworldToVpc. + synchronized (canvas.dirtyMaskLock) { + background_image_update = + ((canvas.cvDirtyMask[Canvas3D.RENDERER_DIRTY_IDX] & Canvas3D.BACKGROUND_IMAGE_DIRTY) != 0); + } if (VirtualUniverse.mc.doDsiRenderLock) { canvas.drawingSurfaceObject.unLock(); } + // Issue 109 : removed copyOfCvCache now that we have + // a separate canvasViewCache for computing view frustum + CanvasViewCache cvCache = canvas.canvasViewCache; + // Deadlock if we include updateViewCache in // drawingSurfaceObject sync. - canvas.updateViewCache(false, copyOfCvCache, null, + canvas.updateViewCache(false, null, null, renderBin.geometryBackground != null); if ((VirtualUniverse.mc.doDsiRenderLock) && @@ -856,8 +826,8 @@ class Renderer extends J3dThread { // setup viewport canvas.setViewport(canvas.ctx, 0, 0, - copyOfCvCache.getCanvasWidth(), - copyOfCvCache.getCanvasHeight()); + cvCache.getCanvasWidth(), + cvCache.getCanvasHeight()); @@ -915,7 +885,7 @@ class Renderer extends J3dThread { // stereo setup - boolean useStereo = copyOfCvCache.getUseStereo(); + boolean useStereo = cvCache.getUseStereo(); if (useStereo) { num_stereo_passes = 2; stereo_mode = Canvas3D.FIELD_LEFT; @@ -942,7 +912,7 @@ class Renderer extends J3dThread { num_accum_passes = NUM_ACCUMULATION_SAMPLES; System.arraycopy( - copyOfCvCache.getLeftProjection().mat, + cvCache.getLeftProjection().mat, 0, accumLeftProjMat, 0, 16); @@ -960,7 +930,7 @@ class Renderer extends J3dThread { if (useStereo) { System.arraycopy( - copyOfCvCache.getRightProjection().mat, + cvCache.getRightProjection().mat, 0, accumRightProjMat, 0, 16); accumRightX = accumRightProjMat[3]; accumRightY = accumRightProjMat[7]; @@ -968,13 +938,13 @@ class Renderer extends J3dThread { if (renderBin.geometryBackground != null) { System.arraycopy( - copyOfCvCache.getInfLeftProjection().mat, + cvCache.getInfLeftProjection().mat, 0, accumInfLeftProjMat, 0, 16); accumInfLeftX = accumInfLeftProjMat[3]; accumInfLeftY = accumInfLeftProjMat[7]; if (useStereo) { System.arraycopy( - copyOfCvCache.getInfRightProjection().mat, + cvCache.getInfRightProjection().mat, 0, accumInfRightProjMat, 0, 16); accumInfRightX = accumInfRightProjMat[3]; accumInfRightY = accumInfRightProjMat[7]; @@ -1044,8 +1014,8 @@ class Renderer extends J3dThread { canvas.beginScene(); // this is if the background image resizes with the canvas - int winWidth = copyOfCvCache.getCanvasWidth(); - int winHeight = copyOfCvCache.getCanvasHeight(); + int winWidth = cvCache.getCanvasWidth(); + int winHeight = cvCache.getCanvasHeight(); // clear background if not full screen antialiasing @@ -1217,7 +1187,7 @@ class Renderer extends J3dThread { // setup rendering matrices if (pass == 0) { canvas.vpcToEc = - copyOfCvCache.getInfLeftVpcToEc(); + cvCache.getInfLeftVpcToEc(); if (doAccum) { canvas.setProjectionMatrix( canvas.ctx, @@ -1225,11 +1195,11 @@ class Renderer extends J3dThread { } else { canvas.setProjectionMatrix( canvas.ctx, - copyOfCvCache.getInfLeftProjection().mat); + cvCache.getInfLeftProjection().mat); } } else { canvas.vpcToEc = - copyOfCvCache.getInfRightVpcToEc(); + cvCache.getInfRightVpcToEc(); if (doAccum) { canvas.setProjectionMatrix( canvas.ctx, @@ -1237,11 +1207,11 @@ class Renderer extends J3dThread { } else { canvas.setProjectionMatrix( canvas.ctx, - copyOfCvCache.getInfRightProjection().mat); + cvCache.getInfRightProjection().mat); } } canvas.vworldToEc.mul(canvas.vpcToEc, - copyOfCvCache.getInfVworldToVpc()); + cvCache.getInfVworldToVpc()); // render background geometry renderBin.renderBackground(canvas); @@ -1249,33 +1219,33 @@ class Renderer extends J3dThread { // setup rendering matrices if (pass == 0) { - canvas.vpcToEc = copyOfCvCache.getLeftVpcToEc(); + canvas.vpcToEc = cvCache.getLeftVpcToEc(); if (doAccum) { canvas.setProjectionMatrix( canvas.ctx, accumLeftProjMat); } else { canvas.setProjectionMatrix(canvas.ctx, - copyOfCvCache.getLeftProjection().mat); + cvCache.getLeftProjection().mat); } } else { - canvas.vpcToEc = copyOfCvCache.getRightVpcToEc(); + canvas.vpcToEc = cvCache.getRightVpcToEc(); if (doAccum) { canvas.setProjectionMatrix( canvas.ctx, accumRightProjMat); } else { canvas.setProjectionMatrix(canvas.ctx, - copyOfCvCache.getRightProjection().mat); + cvCache.getRightProjection().mat); } } canvas.vworldToEc.mul(canvas.vpcToEc, - copyOfCvCache.getVworldToVpc()); + cvCache.getVworldToVpc()); - synchronized (copyOfCvCache) { + synchronized (cvCache) { if (pass == 0) { - canvas.setFrustumPlanes(copyOfCvCache.getLeftFrustumPlanesInVworld()); + canvas.setFrustumPlanes(cvCache.getLeftFrustumPlanesInVworld()); } else { - canvas.setFrustumPlanes(copyOfCvCache.getRightFrustumPlanesInVworld()); + canvas.setFrustumPlanes(cvCache.getRightFrustumPlanesInVworld()); } } @@ -1464,7 +1434,6 @@ class Renderer extends J3dThread { dirtyDlistPerRinfoList.clear(); textureIdResourceFreeList.clear(); displayListResourceFreeList.clear(); - copyOfCvCache = new CanvasViewCache(null, null, null); onScreen = null; offScreen = null; m = null; @@ -1630,12 +1599,15 @@ class Renderer extends J3dThread { // restore current context currentCanvas.makeCtxCurrent(); } - if (texture.equals("2D")){ - VirtualUniverse.mc.freeTexture2DId(texId); - } - else if(texture.equals("3D")){ - VirtualUniverse.mc.freeTexture3DId(texId); - } + // Issue 162: TEMPORARY FIX -- don't free the texture ID, since it will + // be freed once per canvas / screen and will subsequently cause the ID + // to be used for multiple textures. +// if (texture.equals("2D")){ +// VirtualUniverse.mc.freeTexture2DId(texId); +// } +// else if(texture.equals("3D")){ +// VirtualUniverse.mc.freeTexture3DId(texId); +// } } diff --git a/src/classes/share/javax/media/j3d/RenderingAttributes.java b/src/classes/share/javax/media/j3d/RenderingAttributes.java index d3cb2be..d4c444a 100644 --- a/src/classes/share/javax/media/j3d/RenderingAttributes.java +++ b/src/classes/share/javax/media/j3d/RenderingAttributes.java @@ -16,38 +16,72 @@ package javax.media.j3d; * The RenderingAttributes object defines common rendering attributes * for all primitive types. The rendering attributes are:<p> * <ul> - * <li>Alpha test function - used to compare the alpha test value with - * each per-pixel alpha value. If the test passes, the pixel is + * <li>Depth test function - used to compare the incoming (source) depth of + * each pixel with depth of the pixel stored in frame buffer. If the test + * passes, the pixel is written, otherwise the pixel is not written. The depth test + * function is set with the <code>setDepthTestFunction</code> + * method. By default, LESS_OR_EQUAL is the function used. The depth test + * function is one of the following:</li><p> + * <ul> + * <li>ALWAYS - pixels are always drawn, irrespective of the depth + * value. This effectively disables depth testing.</li><p> + * + * <li>NEVER - pixels are never drawn, irrespective of the depth + * value.</li><p> + * + * <li>EQUAL - pixels are drawn if the incoming pixel depth is equal + * to the stored pixel depth in the frame buffer.</li><p> + * + * <li>NOT_EQUAL - pixels are drawn if the incoming pixel depth is + * not equal to the stored pixel depth in the frame buffer.</li><p> + * + * <li>LESS - pixels are drawn if the incoming pixel depth is less + * than the stored pixel depth in the frame buffer.</li><p> + * + * <li>LESS_OR_EQUAL - pixels are drawn if the incoming pixel depth + * is less than or equal to the stored pixel depth in the frame buffer. + * This is the default setting.</li><p> + * + * <li>GREATER - pixels are drawn if the incoming pixel depth is greater + * than the stored pixel depth in the frame buffer.</li><p> + * + * <li>GREATER_OR_EQUAL - pixels are drawn if the incoming pixel depth + * is greater than or equal to the stored pixel depth in the frame buffer.</li><p> + * </ul> + * + * <li>Alpha test function - used to compare the incoming (source) alpha value + * of each pixel with the alpha test value. If the test passes, the pixel is * written, otherwise the pixel is not written. The alpha test * function is set with the <code>setAlphaTestFunction</code> * method. The alpha test * function is one of the following:</li><p> * <ul> * <li>ALWAYS - pixels are always drawn, irrespective of the alpha - * value. This effectively disables alpha testing. This is - * the default setting.</li><p> + * value. This effectively disables alpha testing. + * This is the default setting.</li><p> * * <li>NEVER - pixels are never drawn, irrespective of the alpha * value.</li><p> * - * <li>EQUAL - pixels are drawn if the pixel alpha value is equal + * <li>EQUAL - pixels are drawn if the incoming pixel alpha value is equal * to the alpha test value.</li><p> * - * <li>NOT_EQUAL - pixels are drawn if the pixel alpha value is + * <li>NOT_EQUAL - pixels are drawn if the incoming pixel alpha value is * not equal to the alpha test value.</li><p> * - * <li>LESS - pixels are drawn if the pixel alpha value is less + * <li>LESS - pixels are drawn if the incoming pixel alpha value is less * than the alpha test value.</li><p> * - * <li>LESS_OR_EQUAL - pixels are drawn if the pixel alpha value + * <li>LESS_OR_EQUAL - pixels are drawn if the incoming pixel alpha value * is less than or equal to the alpha test value.</li><p> * - * <li>GREATER - pixels are drawn if the pixel alpha value is greater + * <li>GREATER - pixels are drawn if the incoming pixel alpha value is greater * than the alpha test value.</li><p> * - * <li>GREATER_OR_EQUAL - pixels are drawn if the pixel alpha + * <li>GREATER_OR_EQUAL - pixels are drawn if the incoming pixel alpha * value is greater than or equal to the alpha test value.</li><p> * </ul> + * * <li>Alpha test value - the test value used by the alpha test function. * This value is compared to the alpha value of each rendered pixel. * The alpha test value is set with the <code>setAlphaTestValue</code> @@ -59,8 +93,22 @@ package javax.media.j3d; * is enabled or disabled with the <code>setRasterOpEnable</code> * method. The raster operation is one of the following:</li><p> * <ul> + * <li>ROP_CLEAR - DST = 0.</li> + * <li>ROP_AND DST = SRC & DST.</li> + * <li>ROP_AND_REVERSE DST = SRC & ~DST.</li> * <li>ROP_COPY - DST = SRC. This is the default operation.</li> - * <li>ROP_XOR - DST = SRC ^ DST.</li><p> + * <li>ROP_AND_INVERTED - DST = ~SRC & DST.</li> + * <li>ROP_NOOP - DST = DST.</li> + * <li>ROP_XOR - DST = SRC ^ DST.</li> + * <li>ROP_OR - DST = DST | SRC.</li> + * <li>ROP_NOR - DST = ~( DST | SRC .)</li> + * <li>ROP_EQUIV - DST = ~( DST ^ SRC .)</li> + * <li>ROP_INVERT - DST = ~DST.</li> + * <li>ROP_OR_REVERSE - DST = src | ~DST.</li> + * <li>ROP_COPY_INVERTED - DST = ~SRC.</li> + * <li>ROP_OR_INVERTED - DST = ~SRC | DST.</li> + * <li>ROP_NAND - DST = ~(SRC & DST.)</li> + * <li>ROP_SET - DST = 1.</li><p> * </ul> * <li>Vertex colors - vertex colors can be ignored for this * RenderingAttributes object. This capability is set with the @@ -93,12 +141,79 @@ package javax.media.j3d; * include opaque objects or primitives rendered with * SCREEN_DOOR transparency. By default, the depth buffer * is enabled and the depth buffer write is enabled.</li><p> + * + * <li>Stencil buffer - can be enabled or disabled for this RenderingAttributes + * component object using the <code>setStencilEnable</code> method. If the + * stencil buffer is disabled, the stencil operation and function are ignored. + * If a scene graph is rendered on a Canvas3D that does not have a stencil + * buffer, the stencil buffer will be implicitly disabled for that + * canvas.</li><p> + * + * <li>Stencil write mask - mask that controls which bits of the stencil + * buffer are written when the stencil buffer is enabled. The default value is + * <code>~0</code> (all ones).</li><p> + * + * <li>Stencil operation - a set of three stencil operations performed + * when: 1) the stencil test fails; 2) the stencil test passes, but + * the depth test fails; or 3) both the stencil test and depth test pass. + * The stencil operations are set with the <code>setStencilOp</code> + * method. The stencil operation is one of the following:</li><p> + * <ul> + * <li>STENCIL_KEEP - keeps the current value (no operation performed). + * This is the default setting.</li> + * <li>STENCIL_ZERO - Sets the stencil buffer value to 0.</li> + * <li>STENCIL_REPLACE - Sets the stencil buffer value to + * <code>refValue</code>, as specified by <code>setStencilFunction</code>.</li> + * <li>STENCIL_INCR - Increments the current stencil buffer value.</li> + * <li>STENCIL_DECR - Decrements the current stencil buffer value.</li> + * <li>STENCIL_INVERT - Bitwise inverts the current stencil buffer value.</li><p> * </ul> * - * @see Appearance + * <li>Stencil test function - used to compare the stencil reference value with + * the per-pixel stencil value stored in the frame buffer. If the test passes, + * the pixel is written, otherwise the pixel is not written. The stencil + * test function, reference value, and comparison mask are set with the + * <code>setStencilFunction</code> method. The stencil comparison mask is + * bitwise-ANDed with both the stencil reference value and the stored stencil + * value prior to doing the comparison. The default value for the reference value + * is 0. The default value for the comparison mask is <code>~0</code> (all ones). + * The stencil test function is one of the following:</li><p> + * <ul> + * <li>ALWAYS - pixels are always drawn, irrespective of the stencil + * value. This effectively disables stencil testing. + * This is the default setting.</li><p> + * + * <li>NEVER - pixels are never drawn, irrespective of the stencil + * value.</li><p> + * + * <li>EQUAL - pixels are drawn if the stencil reference value is equal + * to the stored stencil value in the frame buffer.</li><p> + * + * <li>NOT_EQUAL - pixels are drawn if the stencil reference value is + * not equal to the stored stencil value in the frame buffer.</li><p> + * + * <li>LESS - pixels are drawn if the stencil reference value is less + * than the stored stencil value in the frame buffer.</li><p> * + * <li>LESS_OR_EQUAL - pixels are drawn if the stencil reference value + * is less than or equal to the stored stencil value in the frame buffer.</li><p> + * + * <li>GREATER - pixels are drawn if the stencil reference value is greater + * than the stored stencil value in the frame buffer.</li><p> + * + * <li>GREATER_OR_EQUAL - pixels are drawn if the stencil reference value + * is greater than or equal to the stored stencil value in the frame buffer.</li><p> + * </ul> + * + * </ul> + * + * <p>Note: the alpha test, depth test, and stencil functions all use + * the same enums.</p> + * + * @see Appearance */ public class RenderingAttributes extends NodeComponent { + /** * Specifies that this RenderingAttributes object * allows reading its alpha test value component information. @@ -127,6 +242,24 @@ public class RenderingAttributes extends NodeComponent { public static final int ALLOW_ALPHA_TEST_FUNCTION_WRITE = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_ALPHA_TEST_FUNCTION_WRITE; + /** + * Specifies that this RenderingAttributes object + * allows reading its depth test function component information. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_DEPTH_TEST_FUNCTION_READ = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_READ; + + /** + * Specifies that this RenderingAttributes object + * allows writing its depth test function component information. + * + * @since Java 3D 1.4 + */ + public static final int + ALLOW_DEPTH_TEST_FUNCTION_WRITE = CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_DEPTH_TEST_FUNCTION_WRITE; + /** * Specifies that this RenderingAttributes object * allows reading its depth buffer enable and depth buffer write enable @@ -200,84 +333,322 @@ public class RenderingAttributes extends NodeComponent { CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_RASTER_OP_WRITE; /** - * Indicates pixels are always drawn irrespective of alpha value. - * This effectively disables alpha testing. + * Specifies that this RenderingAttributes object allows reading + * its stencil enable, stencil op, stencil function, and + * stencil write mask information. + * + * @since Java 3D 1.4 + */ + public static final int ALLOW_STENCIL_ATTRIBUTES_READ = + CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_READ; + + /** + * Specifies that this RenderingAttributes object allows writing + * its stencil enable, stencil op, stencil function, and + * stencil write mask information. + * + * @since Java 3D 1.4 + */ + public static final int ALLOW_STENCIL_ATTRIBUTES_WRITE = + CapabilityBits.RENDERING_ATTRIBUTES_ALLOW_STENCIL_ATTRIBUTES_WRITE; + + + // + // Enums for alpha test, depth test, and stencil test + // + + /** + * Specifies that pixels are always drawn irrespective of the + * values being tested. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * This setting effectively disables alpha, depth, or stencil testing. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int ALWAYS = 0; /** - * Indicates pixels are never drawn irrespective of alpha value. + * Specifies that pixels are never drawn irrespective of the + * values being tested. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int NEVER = 1; /** - * Indicates pixels are drawn if pixel alpha value is equal - * to alpha test value. + * Specifies that pixels are drawn if the two values being tested are equal. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int EQUAL = 2; /** - * Indicates pixels are drawn if pixel alpha value is not equal - * to alpha test value. + * Specifies that pixels are drawn if the two values being tested are not equal. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int NOT_EQUAL = 3; /** - * Indicates pixels are drawn if pixel alpha value is less - * than alpha test value. + * Specifies that pixels are drawn if the source/reference value is less + * than the destination/test value. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int LESS = 4; /** - * Indicates pixels are drawn if pixel alpha value is less - * than or equal to alpha test value. + * Specifies that pixels are drawn if the source/reference value is less + * than or equal to the destination/test value. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int LESS_OR_EQUAL = 5; /** - * Indicates pixels are drawn if pixel alpha value is greater - * than alpha test value. + * Specifies that pixels are drawn if the source/reference value is greater + * than the destination/test value. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int GREATER = 6; /** - * Indicates pixels are drawn if pixel alpha value is greater - * than or equal to alpha test value. + * Specifies that pixels are drawn if the source/reference value is greater + * than or equal to the destination/test value. + * Can be used to specify the alpha test function, the depth test function, + * or the stencil function. + * + * @see #setAlphaTestFunction + * @see #setDepthTestFunction + * @see #setStencilFunction(int,int,int) */ public static final int GREATER_OR_EQUAL = 7; -// public static final int ROP_CLEAR = 0x0; -// public static final int ROP_AND = 0x1; -// public static final int ROP_AND_REVERSE = 0x2; + // + // Raster op enums + // + + /** + * Raster operation: <code>DST = 0</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_CLEAR = 0x0; + + /** + * Raster operation: <code>DST = SRC & DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_AND = 0x1; + + /** + * Raster operation: <code>DST = SRC & ~DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_AND_REVERSE = 0x2; /** * Raster operation: <code>DST = SRC</code>. * @see #setRasterOp + * * @since Java 3D 1.2 */ public static final int ROP_COPY = 0x3; -// public static final int ROP_AND_INVERTED = 0x4; -// public static final int ROP_NOOP = 0x5; + /** + * Raster operation: <code>DST = ~SRC & DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_AND_INVERTED = 0x4; + + /** + * Raster operation: <code>DST = DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_NOOP = 0x5; /** * Raster operation: <code>DST = SRC ^ DST</code>. * @see #setRasterOp + * * @since Java 3D 1.2 */ public static final int ROP_XOR = 0x6; -// public static final int ROP_OR = 0x7; -// public static final int ROP_NOR = 0x8; -// public static final int ROP_EQUIV = 0x9; -// public static final int ROP_INVERT = 0xA; -// public static final int ROP_OR_REVERSE = 0xB; -// public static final int ROP_COPY_INVERTED = 0xC; -// public static final int ROP_OR_INVERTED = 0xD; -// public static final int ROP_NAND = 0xE; -// public static final int ROP_SET = 0xF; + /** + * Raster operation: <code>DST = DST | SRC</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_OR = 0x7; + + /** + * Raster operation: <code>DST = ~( DST | SRC )</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_NOR = 0x8; + + /** + * Raster operation: <code>DST = ~( DST ^ SRC )</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_EQUIV = 0x9; + + /** + * Raster operation: <code>DST = ~DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_INVERT = 0xA; + + /** + * Raster operation: <code>DST = src | ~DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_OR_REVERSE = 0xB; + /** + * Raster operation: <code>DST = ~SRC</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_COPY_INVERTED = 0xC; + + /** + * Raster operation: <code>DST = ~SRC | DST</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_OR_INVERTED = 0xD; + + /** + * Raster operation: <code>DST = ~(SRC & DST)</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_NAND = 0xE; + + /** + * Raster operation: <code>DST = 1</code>. + * @see #setRasterOp + * + * @since Java 3D 1.4 + */ + public static final int ROP_SET = 0xF; + + + // + // Stencil op enums + // + + /** + * Stencil operation: <code>DST = DST</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_KEEP = 1; + + /** + * Stencil operation: <code>DST = 0</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_ZERO = 2; + + /** + * Stencil operation: <code>DST = REF</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_REPLACE = 3; + + /** + * Stencil operation: <code>DST = DST + 1</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_INCR = 4; + + /** + * Stencil operation: <code>DST = DST - 1</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_DECR = 5; + + /** + * Stencil operation: <code>DST = ~DST</code> + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public static final int STENCIL_INVERT = 6; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ALPHA_TEST_FUNCTION_READ, + ALLOW_ALPHA_TEST_VALUE_READ, + ALLOW_DEPTH_ENABLE_READ, + ALLOW_DEPTH_TEST_FUNCTION_READ, + ALLOW_IGNORE_VERTEX_COLORS_READ, + ALLOW_RASTER_OP_READ, + ALLOW_STENCIL_ATTRIBUTES_READ, + ALLOW_VISIBLE_READ + }; /** * Constructs a RenderingAttributes object with default parameters. @@ -286,15 +657,26 @@ public class RenderingAttributes extends NodeComponent { * depth buffer enable : true<br> * depth buffer write enable : true<br> * alpha test function : ALWAYS<br> - * alpha test value : 0.0<br> + * alpha test value : 0.0f<br> * visible : true<br> * ignore vertex colors : false<br> * raster operation enable : false<br> * raster operation : ROP_COPY<br> + * depth test: LESS_OR_EQUAL<br> + * stencil enable : false<br> + * stencil write mask : ~0 (all ones)<br> + * stencil op - failOp : STENCIL_KEEP<br> + * stencil op - zFailOp : STENCIL_KEEP<br> + * stencil op - zPassOp : STENCIL_KEEP<br> + * stencil function : ALWAYS<br> + * stencil reference value : 0<br> + * stencil comparison mask : ~0 (all ones) * </ul> */ public RenderingAttributes() { // Just use default attributes + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -327,8 +709,10 @@ public class RenderingAttributes extends NodeComponent { * @param rasterOpEnable a flag that specifies whether logical * raster operations are enabled for this RenderingAttributes object. * This disables all alpha blending operations. - * @param rasterOp the logical raster operation, one of ROP_COPY or - * ROP_XOR. + * @param rasterOp the logical raster operation, one of: + * ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED, + * ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT, + * ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET * * @since Java 3D 1.2 */ @@ -340,6 +724,8 @@ public class RenderingAttributes extends NodeComponent { boolean ignoreVertexColors, boolean rasterOpEnable, int rasterOp) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); ((RenderingAttributesRetained)this.retained).initDepthBufferEnable(depthBufferEnable); ((RenderingAttributesRetained)this.retained).initDepthBufferWriteEnable(depthBufferWriteEnable); @@ -356,9 +742,13 @@ public class RenderingAttributes extends NodeComponent { /** * Enables or disables depth buffer mode for this RenderingAttributes * component object. + * * @param state true or false to enable or disable depth buffer mode + * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph + * + * @see GraphicsConfigTemplate3D#setDepthSize */ public void setDepthBufferEnable(boolean state){ if (isLiveOrCompiled()) @@ -401,7 +791,6 @@ public class RenderingAttributes extends NodeComponent { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_DEPTH_ENABLE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes2")); - if (isLive()) ((RenderingAttributesRetained)this.retained).setDepthBufferWriteEnable(state); else @@ -456,9 +845,9 @@ public class RenderingAttributes extends NodeComponent { } /** - * Set alpha test function. This function is used to compare the - * alpha test value with each per-pixel alpha value. If the test - * passes, the pixel is written otherwise the pixel is not + * Set alpha test function. This function is used to compare + * each incoming (source) per-pixel alpha value with the alpha test value. + * If the test passes, the pixel is written otherwise the pixel is not * written. * @param function the new alpha test function. One of * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, @@ -639,8 +1028,10 @@ public class RenderingAttributes extends NodeComponent { * Sets the raster operation function for this RenderingAttributes * component object. * - * @param rasterOp the logical raster operation, one of ROP_COPY or - * ROP_XOR + * @param rasterOp the logical raster operation, one of: + * ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED, + * ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT, + * ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @@ -660,7 +1051,10 @@ public class RenderingAttributes extends NodeComponent { /** * Retrieves the current raster operation for this RenderingAttributes * object. - * @return one of ROP_COPY or ROP_XOR. + * @return one of: + * ROP_CLEAR, ROP_AND, ROP_AND_REVERSE, ROP_COPY, ROP_AND_INVERTED, + * ROP_NOOP, ROP_XOR, ROP_OR, ROP_NOR, ROP_EQUIV, ROP_INVERT, + * ROP_OR_REVERSE, ROP_COPY_INVERTED, ROP_OR_INVERTED, ROP_NAND or ROP_SET * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @@ -723,13 +1117,368 @@ public class RenderingAttributes extends NodeComponent { rt.initDepthBufferEnable(attr.getDepthBufferEnable()); rt.initDepthBufferWriteEnable(attr.getDepthBufferWriteEnable()); + rt.initDepthTestFunction(attr.getDepthTestFunction()); rt.initAlphaTestValue(attr.getAlphaTestValue()); rt.initAlphaTestFunction(attr.getAlphaTestFunction()); rt.initVisible(attr.getVisible()); rt.initIgnoreVertexColors(attr.getIgnoreVertexColors()); rt.initRasterOpEnable(attr.getRasterOpEnable()); rt.initRasterOp(attr.getRasterOp()); + rt.initStencilEnable(attr.getStencilEnable()); + int[] ops = new int[3]; + attr.getStencilOp(ops); + rt.initStencilOp(ops[0], ops[1], ops[2]); + attr.getStencilFunction(ops); + rt.initStencilFunction(ops[0], ops[1], ops[2]); + rt.initStencilWriteMask(attr.getStencilWriteMask()); + + } + + /** + * Set depth test function. This function is used to compare each + * incoming (source) per-pixel depth test value with the stored per-pixel + * depth value in the frame buffer. If the test + * passes, the pixel is written, otherwise the pixel is not + * written. + * @param function the new depth test function. One of + * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, + * or GREATER_OR_EQUAL. + * The default value is LESS_OR_EQUAL. + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void setDepthTestFunction(int function){ + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes14")); + if (isLive()) + ((RenderingAttributesRetained)this.retained).setDepthTestFunction(function); + else + ((RenderingAttributesRetained)this.retained).initDepthTestFunction(function); + } + + /** + * Retrieves current depth test function. + * @return the current depth test function + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public int getDepthTestFunction(){ + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_DEPTH_TEST_FUNCTION_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes15")); + + return ((RenderingAttributesRetained)this.retained).getDepthTestFunction(); + } + + /** + * Enables or disables the stencil buffer for this RenderingAttributes + * component object. If the stencil buffer is disabled, the + * stencil operation and function are ignored. If a scene graph + * is rendered on a Canvas3D that does not have a stencil buffer, + * the stencil buffer will be implicitly disabled for that canvas. + * + * @param state true or false to enable or disable stencil buffer + * operations. + * If this is set to false, the stencilOp and stencilFunction parameters + * are not used. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @see GraphicsConfigTemplate3D#setStencilSize + * + * @since Java 3D 1.4 + */ + public void setStencilEnable(boolean state) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilEnable(state); + else + ((RenderingAttributesRetained)this.retained).initStencilEnable(state); + + } + + /** + * Retrieves the stencil buffer enable flag for this RenderingAttributes + * object. + * + * @return true if stencil buffer operations are enabled; false + * if stencil buffer operations are disabled. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public boolean getStencilEnable() { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); + } + } + + return ((RenderingAttributesRetained)this.retained).getStencilEnable(); + } + + /** + * Sets the stencil operations for this RenderingAttributes object to the + * specified parameters. + * + * @param failOp operation performed when the stencil test fails, one of: + * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, + * or STENCIL_INVERT. + * + * @param zFailOp operation performed when the stencil test passes and the + * depth test fails, one of: + * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, + * or STENCIL_INVERT. + * + * @param zPassOp operation performed when both the stencil test and the + * depth test pass, one of: + * STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCR, STENCIL_DECR, + * or STENCIL_INVERT. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void setStencilOp(int failOp, int zFailOp, int zPassOp) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilOp(failOp, + zFailOp, + zPassOp); + else + ((RenderingAttributesRetained)this.retained).initStencilOp(failOp, + zFailOp, + zPassOp); + + } + + /** + * Sets the stencil operations for this RenderingAttributes object to the + * specified parameters. + * + * @param stencilOps an array of three integers that specifies the new + * set of stencil operations. Element 0 of the array specifies the + * <code>failOp</code> parameter, element 1 specifies the + * <code>zFailOp</code> parameter, and element 2 specifies the + * <code>zPassOp</code> parameter. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @see #setStencilOp(int,int,int) + * + * @since Java 3D 1.4 + */ + public void setStencilOp(int[] stencilOps) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilOp(stencilOps[0], + stencilOps[1], + stencilOps[2]); + else + ((RenderingAttributesRetained)this.retained).initStencilOp(stencilOps[0], + stencilOps[1], + stencilOps[2]); + } + + /** + * Retrieves the current set of stencil operations, and copies them + * into the specified array. The caller must ensure that this array + * has been allocated with enough space to hold the results. + * + * @param stencilOps array that will receive the current set of + * three stencil operations. The <code>failOp</code> parameter is copied + * into element 0 of the array, the <code>zFailOp</code> parameter is copied + * into element 1, and the <code>zPassOp</code> parameter is copied + * into element 2. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void getStencilOp(int[] stencilOps) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); + } + } + + ((RenderingAttributesRetained)this.retained).getStencilOp(stencilOps); + } + + /** + * Sets the stencil function, reference value, and comparison mask + * for this RenderingAttributes object to the specified parameters. + * + * @param function the stencil test function, used to compare the + * stencil reference value with the stored per-pixel + * stencil value in the frame buffer. If the test + * passes, the pixel is written, otherwise the pixel is not + * written. The stencil function is one of: + * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, + * or GREATER_OR_EQUAL. + * + * @param refValue the stencil reference value that is tested against + * the stored per-pixel stencil value + * + * @param compareMask a mask that limits which bits are compared; it is + * bitwise-ANDed with both the stencil reference value and the stored + * per-pixel stencil value before doing the comparison. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void setStencilFunction(int function, int refValue, int compareMask) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilFunction(function, + refValue, + compareMask); + else + ((RenderingAttributesRetained)this.retained).initStencilFunction(function, + refValue, + compareMask); + } + + /** + * Sets the stencil function, reference value, and comparison mask + * for this RenderingAttributes object to the specified parameters. + * + * @param params an array of three integers that specifies the new + * stencil function, reference value, and comparison mask. + * Element 0 of the array specifies the + * stencil function, element 1 specifies the + * reference value, and element 2 specifies the + * comparison mask. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @see #setStencilFunction(int,int,int) + * + * @since Java 3D 1.4 + */ + public void setStencilFunction(int[] params) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilFunction(params[0], + params[1], + params[2]); + else + ((RenderingAttributesRetained)this.retained).initStencilFunction(params[0], + params[1], + params[2]); + + } + + /** + * Retrieves the stencil function, reference value, and comparison mask, + * and copies them into the specified array. The caller must ensure + * that this array has been allocated with enough space to hold the results. + * + * @param params array that will receive the current stencil function, + * reference value, and comparison mask. The stencil function is copied + * into element 0 of the array, the reference value is copied + * into element 1, and the comparison mask is copied + * into element 2. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void getStencilFunction(int[] params) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); + } + } + + ((RenderingAttributesRetained)this.retained).getStencilFunction(params); + } + + /** + * Sets the stencil write mask for this RenderingAttributes + * object. This mask controls which bits of the + * stencil buffer are written. + * The default value is <code>~0</code> (all ones). + * + * @param mask the new stencil write mask. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public void setStencilWriteMask(int mask) { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_WRITE)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes16")); + } + } + + if (isLive()) + ((RenderingAttributesRetained)this.retained).setStencilWriteMask(mask); + else + ((RenderingAttributesRetained)this.retained).initStencilWriteMask(mask); + } + + /** + * Retrieves the current stencil write mask for this RenderingAttributes + * object. + * + * @return the stencil write mask. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @since Java 3D 1.4 + */ + public int getStencilWriteMask() { + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_STENCIL_ATTRIBUTES_READ)) { + throw new CapabilityNotSetException(J3dI18N.getString("RenderingAttributes17")); + } + } + + return ((RenderingAttributesRetained)this.retained).getStencilWriteMask(); } } diff --git a/src/classes/share/javax/media/j3d/RenderingAttributesRetained.java b/src/classes/share/javax/media/j3d/RenderingAttributesRetained.java index 1847fdf..44afe88 100644 --- a/src/classes/share/javax/media/j3d/RenderingAttributesRetained.java +++ b/src/classes/share/javax/media/j3d/RenderingAttributesRetained.java @@ -37,6 +37,15 @@ class RenderingAttributesRetained extends NodeComponentRetained { static final int RASTER_OP_VALUE = 0x80; + static final int DEPTH_TEST_FUNC = 0x100; + + static final int STENCIL_ENABLE = 0x200; + + static final int STENCIL_OP_VALUES = 0x400; + + static final int STENCIL_FUNC = 0x800; + + static final int STENCIL_WRITE_MASK = 0x1000; // depth buffer Enable for hidden surface removal boolean depthBufferEnable = true; @@ -47,6 +56,8 @@ class RenderingAttributesRetained extends NodeComponentRetained { int alphaTestFunction = RenderingAttributes.ALWAYS; + int depthTestFunction = RenderingAttributes.LESS_OR_EQUAL; + boolean visible = true; boolean ignoreVertexColors = false; @@ -54,8 +65,19 @@ class RenderingAttributesRetained extends NodeComponentRetained { // raster operation boolean rasterOpEnable = false; int rasterOp = RenderingAttributes.ROP_COPY; - + + // stencil operation + boolean stencilEnable = false; + int stencilFailOp = RenderingAttributes.STENCIL_KEEP; + int stencilZFailOp = RenderingAttributes.STENCIL_KEEP; + int stencilZPassOp = RenderingAttributes.STENCIL_KEEP; + int stencilFunction = RenderingAttributes.ALWAYS; + int stencilReferenceValue = 0; + int stencilCompareMask = ~0; + int stencilWriteMask = ~0; + // depth buffer comparison function. Used by multi-texturing only + //[PEPE] NOTE: they are both unused. Candidates for removal. static final int LESS = 0; static final int LEQUAL = 1; @@ -113,16 +135,33 @@ class RenderingAttributesRetained extends NodeComponentRetained { return visible; } - final void initIgnoreVertexColors(boolean state) { + + /** + * Enables or disables vertex colors for this RenderAttributes + * component object. + * @param state true or false to enable or disable vertex colors + */ + final void initIgnoreVertexColors(boolean state) { ignoreVertexColors = state; } + /** + * Enables or disables vertex colors for this RenderAttributes + * component object and sends a + * message notifying the interested structures of the change. + * @param state true or false to enable or disable depth vertex colors + */ final void setIgnoreVertexColors(boolean state) { initIgnoreVertexColors(state); sendMessage(IGNORE_VCOLOR, (state ? Boolean.TRUE: Boolean.FALSE)); } + /** + * Retrieves the state of vertex color Enable flag + * @return true if vertex colors are enabled, false + * if vertex colors are disabled + */ final boolean getIgnoreVertexColors() { return ignoreVertexColors; } @@ -260,6 +299,47 @@ class RenderingAttributesRetained extends NodeComponentRetained { return alphaTestFunction; } + /** + * Set depth test function. This function is used to compare the + * depth test value with each per-pixel alpha value. If the test + * passes, then the pixel is written otherwise the pixel is not + * written. + * @param function the new depth test function. One of: + * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, + * GREATER_OR_EQUAL. + * Default value is LESS_OR_EQUAL + * @since Java 3D 1.4 + */ + final void initDepthTestFunction(int function){ + depthTestFunction = function; + } + + /** + * Set depth test function. This function is used to compare the + * depth test value with each per-pixel depth value. If the test + * passes, the pixel is written otherwise the pixel is not + * written. + * @param function the new depth test function. One of + * ALWAYS, NEVER, EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, + * GREATER_OR_EQUAL + * Default value is LESS_OR_EQUAL + * @since Java 3D 1.4 + */ + final void setDepthTestFunction(int function){ + initDepthTestFunction(function); + sendMessage(DEPTH_TEST_FUNC, new Integer(function)); + } + + /** + * Retrieves current depth test function. + * @return the current depth test function + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * @since Java 3D 1.4 + */ + final int getDepthTestFunction(){ + return depthTestFunction; + } /** * Initialize the raster op enable flag @@ -306,30 +386,149 @@ class RenderingAttributesRetained extends NodeComponentRetained { } + // Stencil operations + /** + * Initialize the stencil enable state + */ + final void initStencilEnable(boolean state) { + stencilEnable = state; + } + + /** + * Set the stencil enable state + */ + final void setStencilEnable(boolean state) { + initStencilEnable(state); + sendMessage(STENCIL_ENABLE, new Boolean(state)); + } + + /** + * Retrieves the current stencil enable state. + */ + final boolean getStencilEnable() { + return stencilEnable; + } + + /** + * Initialize the stencil op. value + */ + final void initStencilOp(int failOp, int zFailOp, int zPassOp) { + stencilFailOp = failOp; + stencilZFailOp = zFailOp; + stencilZPassOp = zPassOp; + } + + /** + * Set the stencil op. value + */ + final void setStencilOp(int failOp, int zFailOp, int zPassOp) { + initStencilOp(failOp, zFailOp, zPassOp); + + ArrayList arrList = new ArrayList(3); + arrList.add(new Integer(failOp)); + arrList.add(new Integer(zFailOp)); + arrList.add(new Integer(zPassOp)); + sendMessage(STENCIL_OP_VALUES, arrList); + } + + /** + * Retrieves the current stencil op. value + */ + final void getStencilOp(int[] stencilOps) { + stencilOps[0] = stencilFailOp; + stencilOps[1] = stencilZFailOp; + stencilOps[2] = stencilZPassOp; + } + + + /** + * Initialize the stencil function value + */ + final void initStencilFunction(int function, int refValue, int compareMask) { + stencilFunction = function; + stencilReferenceValue = refValue; + stencilCompareMask = compareMask; + } + + /** + * Set the stencil function value + */ + final void setStencilFunction(int function, int refValue, int compareMask) { + initStencilOp(function, refValue, compareMask); + + ArrayList arrList = new ArrayList(3); + arrList.add(new Integer(function)); + arrList.add(new Integer(refValue)); + arrList.add(new Integer(compareMask)); + sendMessage(STENCIL_FUNC, arrList); + } + + /** + * Retrieves the current stencil op. value + */ + final void getStencilFunction(int[] params) { + params[0] = stencilFunction; + params[1] = stencilReferenceValue; + params[2] = stencilCompareMask; + } + + + /** + * Initialize the stencil write mask + */ + final void initStencilWriteMask(int mask) { + stencilWriteMask = mask; + } + + /** + * Set the stencil write mask + */ + final void setStencilWriteMask(int mask) { + initStencilWriteMask(mask); + sendMessage(STENCIL_WRITE_MASK, new Integer(mask)); + } + + /** + * Retrieves the current stencil write mask + */ + final int getStencilWriteMask() { + return stencilWriteMask; + } + /** * Updates the native context. */ + + // TODO : Need to handle stencil operation on the native side -- Chien native void updateNative(long ctx, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride, boolean depthBufferEnable, boolean depthBufferWriteEnable, + int depthTestFunction, float alphaTestValue, int alphaTestFunction, boolean ignoreVertexColors, - boolean rasterOpEnable, int rasterOp); + boolean rasterOpEnable, int rasterOp, + boolean userStencilAvailable, boolean stencilEnable, + int stencilFailOp, int stencilZFailOp, int stencilZPassOp, + int stencilFunction, int stencilReferenceValue, + int stencilCompareMask, int stencilWriteMask ); /** * Updates the native context. */ - void updateNative(long ctx, + void updateNative(Canvas3D c3d, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride) { - updateNative(ctx, + updateNative(c3d.ctx, depthBufferWriteEnableOverride, depthBufferEnableOverride, - depthBufferEnable, depthBufferWriteEnable, alphaTestValue, - alphaTestFunction, ignoreVertexColors, - rasterOpEnable, rasterOp); + depthBufferEnable, depthBufferWriteEnable, depthTestFunction, + alphaTestValue, alphaTestFunction, ignoreVertexColors, + rasterOpEnable, rasterOp, c3d.userStencilAvailable, stencilEnable, + stencilFailOp, stencilZFailOp, stencilZPassOp, + stencilFunction, stencilReferenceValue, stencilCompareMask, + stencilWriteMask ); } /** @@ -368,14 +567,17 @@ class RenderingAttributesRetained extends NodeComponentRetained { * given "value" */ synchronized void updateMirrorObject(int component, Object value) { - RenderingAttributesRetained mirrorRa = (RenderingAttributesRetained)mirror; - + RenderingAttributesRetained mirrorRa = (RenderingAttributesRetained)mirror; + if ((component & DEPTH_ENABLE) != 0) { mirrorRa.depthBufferEnable = ((Boolean)value).booleanValue(); } else if ((component & DEPTH_WRITE_ENABLE) != 0) { mirrorRa.depthBufferWriteEnable = ((Boolean)value).booleanValue(); } + else if ((component & DEPTH_TEST_FUNC) != 0) { + mirrorRa.depthTestFunction = ((Integer)value).intValue(); + } else if ((component & ALPHA_TEST_VALUE) != 0) { mirrorRa.alphaTestValue = ((Float)value).floatValue(); } @@ -393,7 +595,25 @@ class RenderingAttributesRetained extends NodeComponentRetained { } else if ((component & RASTER_OP_VALUE) != 0) { mirrorRa.rasterOp = (((Integer)value).intValue()); - } + } + else if ((component & STENCIL_ENABLE) != 0) { + mirrorRa.stencilEnable = (((Boolean)value).booleanValue()); + } + else if ((component & STENCIL_OP_VALUES) != 0) { + ArrayList arrlist = (ArrayList) value; + mirrorRa.stencilFailOp = (((Integer)arrlist.get(0)).intValue()); + mirrorRa.stencilZFailOp = (((Integer)arrlist.get(1)).intValue()); + mirrorRa.stencilZPassOp = (((Integer)arrlist.get(2)).intValue()); + } + else if ((component & STENCIL_FUNC) != 0) { + ArrayList arrlist = (ArrayList) value; + mirrorRa.stencilFunction = (((Integer)arrlist.get(0)).intValue()); + mirrorRa.stencilReferenceValue = (((Integer)arrlist.get(1)).intValue()); + mirrorRa.stencilCompareMask = (((Integer)arrlist.get(2)).intValue()); + } + else if ((component & STENCIL_WRITE_MASK) != 0) { + mirrorRa.stencilWriteMask = (((Integer)value).intValue()); + } } boolean equivalent(RenderingAttributesRetained rr) { @@ -406,7 +626,16 @@ class RenderingAttributesRetained extends NodeComponentRetained { (rr.visible == visible) && (rr.ignoreVertexColors == ignoreVertexColors) && (rr.rasterOpEnable == rasterOpEnable) && - (rr.rasterOp == rasterOp)); + (rr.rasterOp == rasterOp) && + (rr.depthTestFunction == depthTestFunction) && + (rr.stencilEnable == stencilEnable) && + (rr.stencilFailOp == stencilFailOp) && + (rr.stencilZFailOp == stencilZFailOp) && + (rr.stencilZPassOp == stencilZPassOp) && + (rr.stencilFunction == stencilFunction) && + (rr.stencilReferenceValue == stencilReferenceValue) && + (rr.stencilCompareMask == stencilCompareMask) && + (rr.stencilWriteMask == stencilWriteMask)); } protected void set(RenderingAttributesRetained ra) { @@ -415,10 +644,20 @@ class RenderingAttributesRetained extends NodeComponentRetained { depthBufferWriteEnable = ra.depthBufferWriteEnable; alphaTestValue = ra.alphaTestValue; alphaTestFunction = ra.alphaTestFunction; + depthTestFunction = ra.depthTestFunction; visible = ra.visible; ignoreVertexColors = ra.ignoreVertexColors; rasterOpEnable = ra.rasterOpEnable; rasterOp = ra.rasterOp; + stencilEnable = ra.stencilEnable; + stencilFailOp = ra.stencilFailOp; + stencilZFailOp = ra.stencilZFailOp; + stencilZPassOp = ra.stencilZPassOp; + stencilFunction = ra.stencilFunction; + stencilReferenceValue = ra.stencilReferenceValue; + stencilCompareMask = ra.stencilCompareMask; + stencilWriteMask = ra.stencilWriteMask; + } final void sendMessage(int attrMask, Object attr) { @@ -462,7 +701,7 @@ class RenderingAttributesRetained extends NodeComponentRetained { } - + // TODO : Need to handle stencil operation -- Chien void handleFrequencyChange(int bit) { int mask = 0; @@ -478,6 +717,16 @@ class RenderingAttributesRetained extends NodeComponentRetained { mask = RASTER_OP_ENABLE; if(bit == RenderingAttributes.ALLOW_DEPTH_ENABLE_WRITE) mask = DEPTH_WRITE_ENABLE; + if( bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE) + mask = DEPTH_TEST_FUNC; + + if( bit == RenderingAttributes.ALLOW_STENCIL_ATTRIBUTES_WRITE) + mask = DEPTH_TEST_FUNC; + + if( bit == RenderingAttributes.ALLOW_DEPTH_TEST_FUNCTION_WRITE) + mask = STENCIL_ENABLE | STENCIL_OP_VALUES | STENCIL_FUNC | + STENCIL_WRITE_MASK; + if (mask != 0) setFrequencyChangeMask(bit, mask); // System.out.println("changedFreqent2 = "+changedFrequent); diff --git a/src/classes/share/javax/media/j3d/RenderingAttributesStructure.java b/src/classes/share/javax/media/j3d/RenderingAttributesStructure.java index d81a58a..abe2180 100644 --- a/src/classes/share/javax/media/j3d/RenderingAttributesStructure.java +++ b/src/classes/share/javax/media/j3d/RenderingAttributesStructure.java @@ -42,11 +42,13 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate for (int i=0; i < nMsg; i++) { m = messages[i]; switch (m.type) { - // Apperance is always updated immediately, since rBin needs + // Appearance is always updated immediately, since rBin needs // the most up-to-date values for restructuring case J3dMessage.APPEARANCE_CHANGED: - case J3dMessage.TEXTURE_UNIT_STATE_CHANGED: // TODO: Is this correct? + case J3dMessage.SHADER_APPEARANCE_CHANGED: + case J3dMessage.TEXTURE_UNIT_STATE_CHANGED: { + // System.out.println("1 RAS : J3dMessage type : " + m.type); int component = ((Integer)m.args[1]).intValue(); NodeComponentRetained nc = (NodeComponentRetained)m.args[0]; nc.mirror.changedFrequent = ((Integer)m.args[3]).intValue(); @@ -69,7 +71,11 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate case J3dMessage.TRANSPARENCYATTRIBUTES_CHANGED: case J3dMessage.MATERIAL_CHANGED: case J3dMessage.TEXCOORDGENERATION_CHANGED: + case J3dMessage.SHADER_ATTRIBUTE_CHANGED: + case J3dMessage.SHADER_ATTRIBUTE_SET_CHANGED: { + // System.out.println("2 RAS : J3dMessage type : " + m.type); + NodeComponentRetained nc = (NodeComponentRetained)m.args[0]; nc.mirror.changedFrequent = ((Integer)m.args[3]).intValue(); if (nc.mirror.changedFrequent != 0) { @@ -105,8 +111,6 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate NodeComponentRetained nc = (NodeComponentRetained)m.args[0]; nc.mirror.changedFrequent = ((Integer)m.args[4]).intValue(); - - if (nc.mirror.changedFrequent != 0) { objList.add(m); addMirrorObj = true; @@ -118,11 +122,9 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate } } break; - case J3dMessage.TEXTURE_CHANGED: { NodeComponentRetained nc = (NodeComponentRetained)m.args[0]; - int attrMask = ((Integer)m.args[1]).intValue(); nc.mirror.changedFrequent = ((Integer)m.args[3]).intValue(); objList.add(m); @@ -190,6 +192,7 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate updateTextureAttributes((Object[])m.args); } else if (m.type == J3dMessage.APPEARANCE_CHANGED || + m.type == J3dMessage.SHADER_APPEARANCE_CHANGED || m.type == J3dMessage.TEXTURE_UNIT_STATE_CHANGED){ NodeComponentRetained nc = (NodeComponentRetained)m.args[0]; nc.mirror.compChanged = 0; @@ -206,12 +209,13 @@ class RenderingAttributesStructure extends J3dStructure implements ObjectUpdate } - void updateNodeComponent(Object[] args) { - NodeComponentRetained n = (NodeComponentRetained)args[0]; - n.updateMirrorObject(((Integer)args[1]).intValue(), args[2]); + private void updateNodeComponent(Object[] args) { + // System.out.println("RAS : updateNodeComponent : " + this); + NodeComponentRetained n = (NodeComponentRetained)args[0]; + n.updateMirrorObject(((Integer)args[1]).intValue(), args[2]); } - void updateTextureAttributes(Object[] args) { + private void updateTextureAttributes(Object[] args) { TextureAttributesRetained n = (TextureAttributesRetained)args[0]; n.updateMirrorObject(((Integer)args[1]).intValue(), args[2], args[3]); } diff --git a/src/classes/share/javax/media/j3d/SceneGraphObject.java b/src/classes/share/javax/media/j3d/SceneGraphObject.java index bfae7f3..32c52b8 100644 --- a/src/classes/share/javax/media/j3d/SceneGraphObject.java +++ b/src/classes/share/javax/media/j3d/SceneGraphObject.java @@ -15,9 +15,37 @@ package javax.media.j3d; import java.util.Hashtable; /** - * SceneGraphObject is a common superclass for - * all scene graph component objects. This includes Node, - * Geometry, Appearance, etc. + * SceneGraphObject is the common superclass for all scene graph + * objects. Scene graph objects are classified into two main types: + * nodes and node components. The Node object is the common superclass + * of all nodes, which includes TransformGroup, Shape3D, etc. + * The NodeComponent object is the common superclass of all node + * components, which includes Geometry, Appearance, etc. + * + * <p> + * All scene graph objects have a name, a user data object, a set of + * capability bits, and a set of capabilityIsFrequent bits. + * + * <p> + * Capability bits control whether a particular attribute in a node or + * node component is readable or writable. For live or compiled scene + * graphs, only those attributes whose capabilities are set before the + * scene graph is compiled or made live may be read or written. The + * default value for all <i>read</i> capability bits is true, meaning + * that all attributes may be read by default. The default value for + * all <i>write</i> capability bits is false, meaning that no + * attributes may be written by default. Read capability bits are + * defined as those capability bits of the form <code>ALLOW_*_READ</code>, + * plus the <code>ALLOW_INTERSECT</code> capability bit. Write + * capability bits are defined as those capability bits of the form + * <code>ALLOW_*_WRITE</code>, plus the <code>ALLOW_CHILDREN_EXTEND</code> + * and <code>ALLOW_DETACH</code> capability bits. + * + * <p> + * NOTE that the <code>ENABLE_COLLISION_REPORTING</code> and + * <code>ENABLE_PICK_REPORTING</code> bits are not really capability bits, + * although they are set with the setCapability method. The default value + * for each of the <code>ENABLE_*_REPORTING bits</code> is false. */ public abstract class SceneGraphObject extends Object { // Any global flags? (e.g., execution cullable, collideable) @@ -43,6 +71,9 @@ public abstract class SceneGraphObject extends Object { // A reference to user data private Object userData = null; + // Optional name for object. + private String objectName = null; + // use for cloneTree/cloneNode only, set to null after the operation Hashtable nodeHashtable = null; @@ -52,10 +83,13 @@ public abstract class SceneGraphObject extends Object { * Constructs a SceneGraphObject with default parameters. The default * values are as follows: * <ul> - * capability bits : clear (all bits)<br> + * all <i>read</i> capability bits : set (true)<br> + * all <i>write</i> capability bits : clear (false)<br> + * all capabilityIsFrequent bits : set (true)<br> * isLive : false<br> * isCompiled : false<br> * user data : null<br> + * name : null<br> * </ul> */ public SceneGraphObject() { @@ -76,7 +110,18 @@ public abstract class SceneGraphObject extends Object { // this.retained = new <ClassName>Retained(); // this.retained.setSource(this); } - + + /** + * Method to set default read capability bits to true + */ + void setDefaultReadCapabilities(int[] bits) { + if (true /*VirtualUniverse.mc.defaultReadCapability*/) { + for (int i=0; i < bits.length; i++) { + setCapability(bits[i]); + } + } + } + /** * Retrieves the specified capability bit. Note that only one capability * bit may be retrieved per method invocation--capability bits cannot @@ -331,6 +376,28 @@ public abstract class SceneGraphObject extends Object { public void updateNodeReferences(NodeReferenceTable referenceTable) { } + /** + * Sets the name of this object. Object names are for information + * only. + * + * @param name the new name of this object + * + * @since Java 3D 1.4 + */ + public void setName( String name ) { + objectName = name; + } + + /** + * Returns the name of this object. + * + * @return the name of this object + * + * @since Java 3D 1.4 + */ + public String getName() { + return objectName; + } /** * Copies all SceneGraphObject information from @@ -353,6 +420,7 @@ public abstract class SceneGraphObject extends Object { // Duplicate any class specific data here. capabilityBits = originalNode.capabilityBits; userData = originalNode.userData; + objectName = originalNode.objectName; } @@ -402,4 +470,25 @@ public abstract class SceneGraphObject extends Object { return originalNodeComponent; } } + + // Internal method to make a prefix out of the name of this object + String getNamePrefix() { + String name = getName(); + + if (name != null) { + return "[" + name + "] "; + } + + return ""; + } + + /** + * Returns a String representation of this SceneGraphObject. + * If its name is non-null, then it is concatenated with + * super.toString(). + */ + public String toString() { + return getNamePrefix() + super.toString(); + } + } diff --git a/src/classes/share/javax/media/j3d/ScreenViewCache.java b/src/classes/share/javax/media/j3d/ScreenViewCache.java index a3802d4..397367a 100644 --- a/src/classes/share/javax/media/j3d/ScreenViewCache.java +++ b/src/classes/share/javax/media/j3d/ScreenViewCache.java @@ -37,7 +37,12 @@ class ScreenViewCache extends Object { // Mask that indicates Screen3D view dependence info. has changed, // and CanvasViewCache may need to recompute the final view matries. - int scrvcDirtyMask = 0; + // Issue 163: Array of dirty bits is used because the Renderer and + // RenderBin run asynchronously. Now that they each have a separate + // instance of CanvasViewCache (due to the fix for Issue 109), they + // need separate dirty bits. Array element 0 is used for the Renderer and + // element 1 is used for the RenderBin. + int[] scrvcDirtyMask = new int[2]; // // Tracker-base coordinate system to image-plate coordinate @@ -72,17 +77,20 @@ class ScreenViewCache extends Object { * Take snapshot of all per-screen API parameters. */ synchronized void snapshot() { - - // accumulate the dirty bits for offscreen because - // the dirty bits will not be processed until renderOffScreen - // or triggered by RenderBin at some little time - if (screen.offScreen) - scrvcDirtyMask |= screen.scrDirtyMask; - else - scrvcDirtyMask = screen.scrDirtyMask; - - screen.scrDirtyMask = 0; - physicalScreenWidth = screen.physicalScreenWidth; + + // accumulate the dirty bits for offscreen because + // the dirty bits will not be processed until renderOffScreen + // or triggered by RenderBin at some little time + if (screen.offScreen) { + scrvcDirtyMask[0] |= screen.scrDirtyMask; + scrvcDirtyMask[1] |= screen.scrDirtyMask; + } else { + scrvcDirtyMask[0] = screen.scrDirtyMask; + scrvcDirtyMask[1] = screen.scrDirtyMask; + } + screen.scrDirtyMask = 0; + + physicalScreenWidth = screen.physicalScreenWidth; physicalScreenHeight = screen.physicalScreenHeight; screenWidth = screen.screenSize.width; screenHeight = screen.screenSize.height; diff --git a/src/classes/share/javax/media/j3d/Sensor.java b/src/classes/share/javax/media/j3d/Sensor.java index ef44ac6..05df43a 100644 --- a/src/classes/share/javax/media/j3d/Sensor.java +++ b/src/classes/share/javax/media/j3d/Sensor.java @@ -59,29 +59,35 @@ public class Sensor { /** * Set predictor type to do no prediction; this is the default. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public static final int PREDICT_NONE = 1; /** - * Set predictor type to generate the SensorRead to correspond with - * the next frame time. + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public static final int PREDICT_NEXT_FRAME_TIME = 2; /** * Use no prediction policy; this is the default. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public static final int NO_PREDICTOR = 16; /** - * Set the predictor policy to assume the sensor is predicting head - * position/orientation. + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public static final int HEAD_PREDICTOR = 32; /** - * Set the predictor policy to assume the sensor is predicting hand - * position/orientation. + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public static final int HAND_PREDICTOR = 64; @@ -110,11 +116,11 @@ public class Sensor { // size of the sensor read buffer int sensorReadCount; - // Default prediction policy: don't predict - int predictionPolicy = NO_PREDICTOR; + // Prediction policy -- unused + private int predictionPolicy = NO_PREDICTOR; - // Default Predictor none - int predictorType = PREDICT_NONE; + // Predictor type -- unused + private int predictorType = PREDICT_NONE; // This sensor's associated device InputDevice device; @@ -135,12 +141,6 @@ public class Sensor { Matrix3d temp_rot = new Matrix3d(); Matrix3d local_svd = new Matrix3d(); - // Prediction workspace -- these may go away when the readings array - // is used. - static int MAX_PREDICTION_LENGTH = 20; - Transform3D[] previousReads = new Transform3D[MAX_PREDICTION_LENGTH]; - long[] times = new long[MAX_PREDICTION_LENGTH]; - /** * Constructs a Sensor object for the specified input device using @@ -149,8 +149,8 @@ public class Sensor { * sensor read count : 30<br> * sensor button count : 0<br> * hot spot : (0,0,0)<br> - * predictor : PREDICT_NONE<br> - * prediction policy : NO_PREDICTOR<br> + * predictor : PREDICT_NONE — <i>this attribute is unused</i><br> + * prediction policy : NO_PREDICTOR — <i>this attribute is unused</i><br> * </ul> * @param device the Sensor's associated device. */ @@ -237,11 +237,6 @@ public class Sensor { } currentIndex = 0; this.hotspot = new Point3d(hotspot); - - // prediction initialization - for(int i=0 ; i<MAX_PREDICTION_LENGTH ; i++) { - previousReads[i] = new Transform3D(); - } } // argument of 0 is last reading (ie, currentIndex), argument @@ -252,11 +247,16 @@ public class Sensor { } /** - * This function sets the type of predictor to use with this sensor. + * Sets the type of predictor to use with this sensor. + * Since prediction is not implemented (and never has been), this + * attribute has no effect. * @param predictor predictor type one of PREDICT_NONE or * PREDICT_NEXT_FRAME_TIME * @exception IllegalArgumentException if an invalid predictor type * is specified. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public void setPredictor(int predictor){ if (predictor != PREDICT_NONE && predictor != PREDICT_NEXT_FRAME_TIME) { @@ -267,20 +267,27 @@ public class Sensor { } /** - * This function returns the type of predictor used by this sensor. - * @return returns the predictor type. One of PREDICT_NONE or - * PREDICT_NEXT_FRAME_TIME. + * Returns the type of predictor used by this sensor. + * @return the predictor type. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public int getPredictor(){ return predictorType; } /** - * This function sets the prediction policy use by this sensor. + * Sets the prediction policy use by this sensor. + * Since prediction is not implemented (and never has been), this + * attribute has no effect. * @param policy prediction policy one of NO_PREDICTOR, HEAD_PREDICTOR, * or HAND_PREDICTOR * @exception IllegalArgumentException if an invalid prediction policy * is specified. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public void setPredictionPolicy(int policy){ if (policy != NO_PREDICTOR && policy != HEAD_PREDICTOR && @@ -291,9 +298,11 @@ public class Sensor { } /** - * This function returns the prediction policy used by this sensor. - * @return returns the prediction policy. one of NO_PREDICTOR, - * HEAD_PREDICTOR, or HAND_PREDICTOR. + * Returns the prediction policy used by this sensor. + * @return the prediction policy. + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature. */ public int getPredictionPolicy(){ return predictionPolicy; @@ -332,79 +341,30 @@ public class Sensor { } /** - * Computes the sensor reading consistent with the prediction policy - * and copies that value into the specified argument; calling this method - * with a prediction policy of NO_PREDICTOR will return the last sensor - * reading; calling this method with a prediction policy of HAND_PREDICTOR, - * or HEAD_PREDICTOR will extrapolate previous sensor readings to the - * current time. - * @param read The matrix that will receive the predicted sensor reading + * Retrieves the last sensor reading and copies that value into + * the specified argument. + * + * @param read the matrix that will receive the sensor reading */ - public void getRead(Transform3D read){ - long time; - + public void getRead(Transform3D read) { if(demand_driven == true) device.pollAndProcessInput(); - time = System.currentTimeMillis(); - - // before using prediction, fill in some values - if(num_reads_so_far < 40*SENSOR_READ_COUNT_BUFFER) { - num_reads_so_far++; - read.set(readings[currentIndex].read); - return; - } - - switch(predictionPolicy) { - case NO_PREDICTOR: - read.set(readings[currentIndex].read); - break; - case HAND_PREDICTOR: - read.set(readings[currentIndex].read); - //getPredictedRead(read, time, 3, 2); - break; - case HEAD_PREDICTOR: - read.set(readings[currentIndex].read); - //getPredictedRead(read, time, 3, 2); - break; - } + read.set(readings[currentIndex].read); } /** - * Computes the sensor reading consistent as of time deltaT in the future - * and copies that value into the specified argument; the reading is - * computed using the current prediction policy; a prediction policy of - * NO_PREDICTOR will yield the most recent sensor reading for any - * deltaT argument (i.e., this method is the same as getRead for a prediction - * policy of NO_PREDICTOR). The time argument must be >= 0. - * @param read the matrix that will receive the predicted sensor reading - * @param deltaT the time delta into the future for this read + * Retrieves the last sensor reading and copies that value into + * the specified argument. + * + * @param read the matrix that will receive the sensor reading + * @param deltaT this parameter is ignored + * + * @deprecated As of Java 3D version 1.4, prediction is not a + * supported feature; use <code>getRead(Transform3D)</code> instead. */ public void getRead(Transform3D read, long deltaT){ - long current_time; - - if(deltaT < 0L) { - throw new IllegalArgumentException(J3dI18N.getString("Sensor2")); - } - - if(demand_driven == true) - device.pollAndProcessInput(); - - current_time = System.currentTimeMillis(); - - switch(predictionPolicy) { - case NO_PREDICTOR: - read.set(readings[currentIndex].read); - break; - case HAND_PREDICTOR: - read.set(readings[currentIndex].read); - //getPredictedRead(read, current_time + deltaT, 3, 2); - break; - case HEAD_PREDICTOR: - read.set(readings[currentIndex].read); - //getPredictedRead(read, current_time + deltaT, 3, 2); - break; - } + getRead(read); } /** @@ -566,132 +526,4 @@ public class Sensor { currentIndex = temp; } - /** - * This routine does an nth order fit of the last num_readings, which - * can be plotted on a graph of time vs. sensor reading. There is a - * separate fit done for each of the 16 matrix elements, then an SVD - * done on the final matrix. The curve that is produced takes into - * account non-constant times between each sample (it is fully general). - * This curve can then be used to produce a prediction for any - * time in the future by simply inserting a time value and using the - * solution matrix. - */ - void getPredictedRead(Transform3D transform, long time, int num_readings, - int order) { - - int index = currentIndex; // lock in current_index for MT-safety - long time_basis = readings[index].time; - long tempTime; - - time -= time_basis; - - GMatrix A = new GMatrix(num_readings, order+1); - - for(int i=0 ; i<num_readings ; i++) { - A.setElement(i, 0, 1.0); - tempTime = lastTimeRelative(num_readings-i-1, index, time_basis); - A.setElement(i, 1, (double)tempTime); - for(int j=2; j<=order ; j++) { - // powerAndDiv(time, n) = times^n/n - A.setElement(i, j, powerAndDiv(tempTime, j)); - } - } - - GMatrix A_Transpose = new GMatrix(A); - A_Transpose.transpose(); - GMatrix M = new GMatrix(order+1, order+1); - M.mul(A_Transpose, A); - try { - M.invert(); - } catch (SingularMatrixException e) { - System.out.println("SINGULAR MATRIX EXCEPTION in prediction"); - System.out.println(M); - } - - // TODO: can be class scope - double[] transformArray = new double[16]; - GMatrix solMatrix = new GMatrix(order+1, num_readings); - solMatrix.mul(M,A_Transpose); - - GVector P = new GVector(order+1); - - // fill in the time for which we are trying to predict a sensor value - GVector predTimeVec = new GVector(order+1); - predTimeVec.setElement(0, 1); - predTimeVec.setElement(1, time); - for(int i=2 ; i<=order ; i++) { - predTimeVec.setElement(i, powerAndDiv(time, i)); - } - - GVector R = new GVector(num_readings); - - for(int transElement=0 ; transElement<16 ; transElement++) { - - for(int i=0 ; i<num_readings ; i++) { - R.setElement(i, lastReadRelative(num_readings-i-1, index, - transElement)); - } - - P.mul(solMatrix,R); - transformArray[transElement] = P.dot(predTimeVec); - } - - //Matrix4d temp = new Matrix4d(transformArray); - //localSVD(temp); - //transform.set(temp); - transform.set(transformArray); - transform.normalize(); - } - - /** - * Extracts the kth most recent sensor reading and copies that value into - * the specified argument; where 0 is the most recent sensor reading, 1 is - * the next most recent sensor reading, etc. - * @param read The matrix that will receive the most recent sensor reading - * @param k The kth previous sensor reading - */ - double lastReadRelative(int kth, int base_index, int mat_element){ - // kth should be < sensorReadCount - return - readings[previousIndexRelative(kth, base_index)].read.mat[mat_element]; - } - - /** - * Returns the time associated with the kth most recent sensor reading; - * where 0 is the most recent sensor reading, 1 is the next most recent - * sensor reading, etc. However, unlike the public method, returns - * the kth reading relative to the index given, instead of the - * current_index and returns the time relative to timeBasis. - * @return the time associated with the kthmost recent sensor reading. - */ - long lastTimeRelative(int k, int base_index, long timeBasis){ - // kth should be < sensorReadCount - long time; - time = timeBasis - readings[previousIndexRelative(k, base_index)].time; - return time; - } - - // argument of 0 is last reading, argument of 1 means next to last - // index, etc. , but all of these are relative to *base_index* - int previousIndexRelative(int k, int base_index){ - int temp = base_index - k; - return(temp >= 0 ? temp : MaxSensorReadIndex + temp + 1); - } - - // this method returns (value^order)/order - double powerAndDiv(double value, int order) { - - if(order == 0) - return 1; - else if(order == 1) - return value; - - double total = 1.0; - for(int i=0 ; i< order ; i++) - total *= value; - - total = total / (double)order; - return total; - } - } diff --git a/src/classes/share/javax/media/j3d/SetLiveState.java b/src/classes/share/javax/media/j3d/SetLiveState.java index 84ff55a..6c81c4e 100644 --- a/src/classes/share/javax/media/j3d/SetLiveState.java +++ b/src/classes/share/javax/media/j3d/SetLiveState.java @@ -243,7 +243,7 @@ class SetLiveState extends Object { localToVworldIndex = null; localToVworldKeys = null; - // TODO: optimization for targetThreads computation, require + // XXXX: optimization for targetThreads computation, require // cleanup in GroupRetained.doSetLive() //transformTargetThreads = 0; diff --git a/src/classes/share/javax/media/j3d/Shader.java b/src/classes/share/javax/media/j3d/Shader.java new file mode 100644 index 0000000..f5870ee --- /dev/null +++ b/src/classes/share/javax/media/j3d/Shader.java @@ -0,0 +1,131 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The Shader object is the abstract base class for programmable + * shader code. Currently, only text-based source code shaders are + * supported, so the only subclass of Shader is SourceCodeShader. We + * leave open the possibility for binary (object code) shaders in the + * future. + * + * <p> + * Each instance of a Shader object allows an application to specify + * the source code used in programming the Graphics Pipeline Unit + * (GPU) of the graphics accelerator. A Shader object is constructed + * with modes that specify the <i>shading language</i> and the + * <i>shader type</i>. + * + * <p> + * The shading language specifies the language and runtime environment + * used to program the GPU. The currently defined shading languages + * are GLSL (also known as the OpenGL 2.0 shading language) and + * Cg. Note that not all shading languages are supported on all + * platforms. It is up to the application or utility to query whether + * a particular shading language is supported before using it. The + * value of the <code>shadingLanguage</code> mode is one of: + * <code>SHADING_LANGUAGE_GLSL</code> or + * <code>SHADING_LANGUAGE_CG</code>. + * + *<p> + * The shader type specifies whether the shader is a <i>vertex + * shader</i> or a <i>fragment shader</i>. A vertex shader replaces + * the fixed-function graphics pipeline for vertex operations + * (transformation and lighting). A fragment shader replaces the + * fixed-function graphics pipeline for fragment shading operations + * (texture mapping, texture application, coloring, shading, and so + * forth). The value of the <code>shaderType</code> mode is one of: + * <code>SHADER_TYPE_VERTEX</code> or + * <code>SHADER_TYPE_FRAGMENT</code>. + * + * <p> + * Both the shading language and shader type are immutable modes of + * the Shader object. + * + * <p> + * NOTE: Applications should <i>not</i> extend this class. + * + * @see ShaderProgram + * @see Canvas3D#isShadingLanguageSupported + * + * @since Java 3D 1.4 + */ + +public abstract class Shader extends NodeComponent { + + + /** + * This constant indicates the GLSL shading language. It is one + * of the possible values of the shadingLanguage parameter. + */ + public static final int SHADING_LANGUAGE_GLSL = 1; + + /** + * This constant indicates the Cg shading language. It is one + * of the possible values of the shadingLanguage parameter. + */ + public static final int SHADING_LANGUAGE_CG = 2; + + + /** + * This constant indicates that the shader type is a vertex + * shader. It is one of the possible values of the shaderType + * parameter. + */ + public static final int SHADER_TYPE_VERTEX = 1; + + /** + * This constant indicates that the shader type is a fragment + * shader. It is one of the possible values of the shaderType + * parameter. + */ + public static final int SHADER_TYPE_FRAGMENT = 2; + + + /** + * Not a public constructor, for internal use + */ + Shader() { + } + + /** + * Package scope constructor so it can't be subclassed by classes + * outside the javax.media.j3d package. + */ + Shader(int shadingLanguage, int shaderType) { + ((ShaderRetained)this.retained).initializeShader(shadingLanguage, shaderType); + } + + /** + * Returns the shading language of this shader. + * + * @return the shading language of this shader, one of: + * <code>SHADING_LANGUAGE_GLSL</code> or + * <code>SHADING_LANGUAGE_CG</code>. + */ + public int getShadingLanguage() { + return ((ShaderRetained)this.retained).getShadingLanguage(); + } + + /** + * Returns the type of this shader. + * + * @return the shader type, one of: + * <code>SHADER_TYPE_VERTEX</code> or + * <code>SHADER_TYPE_FRAGMENT</code>. + */ + public int getShaderType() { + return ((ShaderRetained)this.retained).getShaderType(); + } +} + diff --git a/src/classes/share/javax/media/j3d/ShaderAppearance.java b/src/classes/share/javax/media/j3d/ShaderAppearance.java new file mode 100644 index 0000000..2b9be8c --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAppearance.java @@ -0,0 +1,285 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.Hashtable; + +/** + * <p>The ShaderAppearance object defines programmable shading attributes + * that can be set as a component object of a Shape3D node. The + * ShaderAppearance rendering state adds the following attributes in + * addition to those defined by Appearance:</p> + * + * <ul> + * <li>Shader program - specifies the shader program...</li> + * + * <p></p> + * <li>Shader attribute set - specifies the shader parameters, both as + * explicit attributes and as implicit bindings to Java 3D + * state...</li> + * </ul> + * + * <p>The ShaderAppearance object modifies the definition of some of the + * attributes in Appearance:</p> + * + * <ul> + * <li>Coloring attributes - XXXXX</li> + * + * <p></p> + * <li>Line attributes - XXXXX</li> + * + * <p></p> + * <li>Point attributes - XXXXX</li> + * + * <p></p> + * <li>Polygon attributes - XXXXX</li> + * + * <p></p> + * <li>Rendering attributes - XXXXX</li> + * + * <p></p> + * <li>Transparency attributes - XXXXX</li> + * + * <p></p> + * <li>Material - XXXXX</li> + * + * <p></p> + * <li>Texture - XXXXX</li> + * + * <p></p> + * <li>Texture attributes - XXXXX</li> + * + * <p></p> + * <li>Texture coordinate generation - XXXXX</li> + * + * <p></p> + * <li>Texture unit state - XXXXX</li> + * </ul> + * + * @see ShaderProgram + * @see ShaderAttributeSet + * + * @since Java 3D 1.4 + */ +public class ShaderAppearance extends Appearance { + /** + * Specifies that this ShaderAppearance object allows reading its + * ShaderProgram component information. + */ + public static final int + ALLOW_SHADER_PROGRAM_READ = + CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_READ; + + /** + * Specifies that this ShaderAppearance object allows writing its + * ShaderProgram component information. + */ + public static final int + ALLOW_SHADER_PROGRAM_WRITE = + CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_PROGRAM_WRITE; + + /** + * Specifies that this ShaderAppearance object allows reading its + * ShaderAttributeSet component information. + */ + public static final int + ALLOW_SHADER_ATTRIBUTE_SET_READ = + CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_READ; + + /** + * Specifies that this ShaderAppearance object allows writing its + * ShaderAttributeSet component information. + */ + public static final int + ALLOW_SHADER_ATTRIBUTE_SET_WRITE = + CapabilityBits.SHADER_APPEARANCE_ALLOW_SHADER_ATTRIBUTE_SET_WRITE; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SHADER_PROGRAM_READ, + ALLOW_SHADER_ATTRIBUTE_SET_READ + }; + + /** + * Constructs a ShaderAppearance component object using defaults for all + * state variables. All component object references are initialized + * to null. + */ + public ShaderAppearance() { + // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } + + /** + * Creates the retained mode ShaderAppearanceRetained object that this + * ShaderAppearance component object will point to. + */ + void createRetained() { + this.retained = new ShaderAppearanceRetained(); + this.retained.setSource(this); + } + + /** + * Sets the ShaderProgram object to the specified object. Setting it to + * null causes a default pass-through shader to be used ??? + * + * @param shaderProgram object that specifies the desired shader program + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void setShaderProgram(ShaderProgram shaderProgram) { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADER_PROGRAM_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAppearance0")); + } + + ((ShaderAppearanceRetained)this.retained).setShaderProgram(shaderProgram); + + } + + + /** + * Retrieves the current ShaderProgram object. + * + * @return the ShaderProgram object + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public ShaderProgram getShaderProgram() { + + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADER_PROGRAM_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAppearance1")); + } + return ((ShaderAppearanceRetained)this.retained).getShaderProgram(); + } + + + /** + * Sets the ShaderAttributeSet object to the specified object. Setting it to + * null is equivalent to specifying an empty set of attributes. + * + * @param shaderAttributeSet object that specifies the desired shader attributes + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void setShaderAttributeSet(ShaderAttributeSet shaderAttributeSet) { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADER_ATTRIBUTE_SET_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAppearance2")); + } + + ((ShaderAppearanceRetained)this.retained).setShaderAttributeSet(shaderAttributeSet); + } + + + /** + * Retrieves the current ShaderAttributeSet object. + * + * @return the ShaderAttributeSet object + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public ShaderAttributeSet getShaderAttributeSet() { + if (isLiveOrCompiled()) { + if(!this.getCapability(ALLOW_SHADER_ATTRIBUTE_SET_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAppearance3")); + } + return ((ShaderAppearanceRetained)this.retained).getShaderAttributeSet(); + } + + + /** + * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) + */ + public NodeComponent cloneNodeComponent() { + ShaderAppearance a = new ShaderAppearance(); + a.duplicateNodeComponent(this); + return a; + } + + /** + * NOTE: Applications should <i>not</i> call this method directly. + * It should only be called by the cloneNode method. + * + * @deprecated replaced with duplicateNodeComponent( + * NodeComponent originalNodeComponent, boolean forceDuplicate) + */ + public void duplicateNodeComponent(NodeComponent originalNodeComponent) { + checkDuplicateNodeComponent(originalNodeComponent); + } + + /** + * Copies all ShaderAppearance information from + * <code>originalNodeComponent</code> into + * the current node. This method is called from the + * <code>cloneNode</code> method which is, in turn, called by the + * <code>cloneTree</code> method.<P> + * + * @param originalNodeComponent the original node to duplicate. + * @param forceDuplicate when set to <code>true</code>, causes the + * <code>duplicateOnCloneTree</code> flag to be ignored. When + * <code>false</code>, the value of each node's + * <code>duplicateOnCloneTree</code> variable determines whether + * NodeComponent data is duplicated or copied. + * + * @exception RestrictedAccessException if this object is part of a live + * or compiled scenegraph. + * + * @see Node#cloneTree + * @see NodeComponent#setDuplicateOnCloneTree + */ + void duplicateAttributes(NodeComponent originalNodeComponent, + boolean forceDuplicate) { + super.duplicateAttributes(originalNodeComponent, forceDuplicate); + + Hashtable hashtable = originalNodeComponent.nodeHashtable; + + ShaderAppearanceRetained app = + (ShaderAppearanceRetained) originalNodeComponent.retained; + + ShaderAppearanceRetained rt = (ShaderAppearanceRetained) retained; + + rt.setShaderProgram((ShaderProgram) getNodeComponent(app.getShaderProgram(), + forceDuplicate, + hashtable)); + } + + /** + * This function is called from getNodeComponent() to see if any of + * the sub-NodeComponents duplicateOnCloneTree flag is true. + * If it is the case, current NodeComponent needs to + * duplicate also even though current duplicateOnCloneTree flag is false. + * This should be overwrite by NodeComponent which contains sub-NodeComponent. + */ + boolean duplicateChild() { + if (super.duplicateChild()) + return true; + + if (getDuplicateOnCloneTree()) + return true; + + ShaderAppearanceRetained rt = (ShaderAppearanceRetained) retained; + + NodeComponent nc; + + nc = rt.getShaderProgram(); + if ((nc != null) && nc.getDuplicateOnCloneTree()) + return true; + + return false; + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java b/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java new file mode 100644 index 0000000..b8a1936 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAppearanceRetained.java @@ -0,0 +1,360 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.Vector; +import java.util.BitSet; +import java.util.ArrayList; + + +/** + * The Appearance object defines all rendering state that can be set + * as a component object of a Shape3D node. + */ +class ShaderAppearanceRetained extends AppearanceRetained { + + // + // State variables: these should all be initialized to approproate + // Java 3D defaults. + // + + protected ShaderProgramRetained shaderProgram = null; + protected ShaderAttributeSetRetained shaderAttributeSet = null; + protected boolean isMirror = false; // For Debugging. + + static final int SHADER_PROGRAM = 0x0800; + static final int SHADER_ATTRIBUTE_SET = 0x1000; + + /** + * Set the shader program object to the specified object. + * @param shaderProgram object that specifies the desired shader program + * and shader program attributes. + */ + void setShaderProgram(ShaderProgram sp) { + synchronized(liveStateLock) { + if (source.isLive()) { + // System.out.println("**** ShaderAppearceRetained.setShaderProgram()"); + + if (this.shaderProgram != null) { + this.shaderProgram.clearLive(refCount); + this.shaderProgram.removeMirrorUsers(this); + } + + if (sp != null) { + ((ShaderProgramRetained)sp.retained).setLive(inBackgroundGroup, + refCount); + ((ShaderProgramRetained)sp.retained).copyMirrorUsers(this); + } + + sendMessage(SHADER_PROGRAM, + (sp != null ? ((ShaderProgramRetained)sp.retained).mirror : null)); + + } + + if (sp == null) { + this.shaderProgram = null; + } else { + this.shaderProgram = (ShaderProgramRetained)sp.retained; + } + } + } + + + /** + * Retrieves the current shader program object. + * @return current shader program object + */ + ShaderProgram getShaderProgram() { + return (shaderProgram == null ? null : (ShaderProgram)shaderProgram.source); + } + + + /** + * Sets the ShaderAttributeSet object to the specified object. Setting it to + * null is equivalent to specifying an empty set of attributes. + * + * @param shaderAttributeSet object that specifies the desired shader attributes + */ + void setShaderAttributeSet(ShaderAttributeSet sas) { + synchronized(liveStateLock) { + if (source.isLive()) { + // System.out.println("**** ShaderAppearceRetained.setShaderAttributeSet()"); + + if (this.shaderAttributeSet != null) { + this.shaderAttributeSet.clearLive(refCount); + this.shaderAttributeSet.removeMirrorUsers(this); + } + + if (sas != null) { + ((ShaderAttributeSetRetained)sas.retained).setLive(inBackgroundGroup, + refCount); + ((ShaderAttributeSetRetained)sas.retained).copyMirrorUsers(this); + } + + // System.out.println(" -- testing needed!"); + sendMessage(SHADER_ATTRIBUTE_SET, + (sas != null ? + ((ShaderAttributeSetRetained)sas.retained).mirror : null)); + + } + + if (sas == null) { + this.shaderAttributeSet = null; + } else { + this.shaderAttributeSet = (ShaderAttributeSetRetained)sas.retained; + } + } + } + + + /** + * Retrieves the current ShaderAttributeSet object. + * @return current ShaderAttributeSet object + */ + ShaderAttributeSet getShaderAttributeSet() { + return (shaderAttributeSet == null ? null : (ShaderAttributeSet)shaderAttributeSet.source); + + } + + + public boolean equals(Object obj) { + System.out.println("ShaderAppearanceRetained : equals() not tested yet!"); + return ((obj instanceof ShaderAppearanceRetained) && + equals((ShaderAppearanceRetained) obj)); + } + + boolean equals(ShaderAppearanceRetained sApp) { + boolean flag; + flag = (sApp == this); + + // If the reference is the same, we can stop check. + if(flag) + return flag; + + // Check each member's reference for equal. + flag = ((sApp != null) && + (shaderProgram == sApp.shaderProgram) && + (shaderAttributeSet == sApp.shaderAttributeSet)); + + + if (!flag) + return flag; + + return super.equals(sApp); + + } + + + + synchronized void createMirrorObject() { + // System.out.println("ShaderAppearanceRetained : createMirrorObject()"); + + if (mirror == null) { + // we can't check isStatic() since it sub-NodeComponent + // create a new one, we should create a + // new AppearanceRetained() even though isStatic() = true. + // For simplicity, always create a retained side. + mirror = new ShaderAppearanceRetained(); + ((ShaderAppearanceRetained)mirror).isMirror = true; // For Debugging. + } + initMirrorObject(); + } + + /** + * This routine updates the mirror appearance for this appearance. + * It also calls the update method for each node component if it + * is not null. + */ + synchronized void initMirrorObject() { + // System.out.println("ShaderAppearanceRetained : initMirrorObject()"); + + super.initMirrorObject(); + + ShaderAppearanceRetained mirrorApp = (ShaderAppearanceRetained)mirror; + + if(shaderProgram != null) { + mirrorApp.shaderProgram = (ShaderProgramRetained)shaderProgram.mirror; + } + else { + mirrorApp.shaderProgram = null; + } + + if(shaderAttributeSet != null) { + mirrorApp.shaderAttributeSet = + (ShaderAttributeSetRetained)shaderAttributeSet.mirror; + } + else { + // System.out.println("shaderAttributeSet is null"); + mirrorApp.shaderAttributeSet = null; + } + + } + + /** + * Update the "component" field of the mirror object with the + * given "value" + */ + synchronized void updateMirrorObject(int component, Object value) { + + // System.out.println("ShaderAppearanceRetained : updateMirrorObject() this " + this); + super.updateMirrorObject(component, value); + ShaderAppearanceRetained mirrorApp = (ShaderAppearanceRetained)mirror; + if ((component & SHADER_PROGRAM) != 0) { + mirrorApp.shaderProgram = (ShaderProgramRetained)value; + } + else if ((component & SHADER_ATTRIBUTE_SET) != 0) { + mirrorApp.shaderAttributeSet = (ShaderAttributeSetRetained)value; + } + + } + + /** + * This method calls the setLive method of all appearance bundle + * objects. + */ + void doSetLive(boolean backgroundGroup, int refCount) { + // System.out.println("ShaderAppearceRetained.doSetLive()"); + + + if (shaderProgram != null) { + shaderProgram.setLive(backgroundGroup, refCount); + } + + if (shaderAttributeSet != null) { + shaderAttributeSet.setLive(backgroundGroup, refCount); + } + + + // Increment the reference count and initialize the appearance + // mirror object + super.doSetLive(backgroundGroup, refCount); + } + + + /** + * This clearLive routine first calls the superclass's method, then + * it removes itself to the list of lights + */ + void clearLive(int refCount) { + super.clearLive(refCount); + + if (shaderProgram != null) { + shaderProgram.clearLive(refCount); + } + + if (shaderAttributeSet != null) { + shaderAttributeSet.clearLive(refCount); + } + } + + synchronized void addAMirrorUser(Shape3DRetained shape) { + + super.addAMirrorUser(shape); + if (shaderProgram != null) + shaderProgram.addAMirrorUser(shape); + if (shaderAttributeSet != null) + shaderAttributeSet.addAMirrorUser(shape); + } + + synchronized void removeAMirrorUser(Shape3DRetained shape) { + + super.removeAMirrorUser(shape); + if (shaderProgram != null) + shaderProgram.removeAMirrorUser(shape); + if (shaderAttributeSet != null) + shaderAttributeSet.removeAMirrorUser(shape); + } + + + final void sendMessage(int attrMask, Object attr) { + ArrayList univList = new ArrayList(); + ArrayList gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList); + // Send to rendering attribute structure, regardless of + // whether there are users or not (alternate appearance case ..) + J3dMessage createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES; + createMessage.type = J3dMessage.SHADER_APPEARANCE_CHANGED; + createMessage.universe = null; + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + createMessage.args[3] = new Integer(changedFrequent); + + VirtualUniverse.mc.processMessage(createMessage); + + //System.out.println("univList.size is " + univList.size()); + for(int i=0; i<univList.size(); i++) { + createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDER; + createMessage.type = J3dMessage.SHADER_APPEARANCE_CHANGED; + + createMessage.universe = (VirtualUniverse) univList.get(i); + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + + ArrayList gL = (ArrayList) gaList.get(i); + GeometryAtom[] gaArr = new GeometryAtom[gL.size()]; + gL.toArray(gaArr); + createMessage.args[3] = gaArr; + + VirtualUniverse.mc.processMessage(createMessage); + } + } + + + boolean isStatic() { + if (!super.isStatic()) { + return false; + } + + boolean flag = + source.capabilityBitsEmpty() && + ((shaderProgram == null) || + shaderProgram.source.capabilityBitsEmpty()) && + ((shaderAttributeSet == null) || + shaderAttributeSet.source.capabilityBitsEmpty()); + + return flag; + } + + + + boolean isOpaque(int geoType) { + + if (!super.isOpaque(geoType)) { + return false; + } + + // TODO: IMPLEMENT THIS + // TODO: How do we determine whether a ShaderAppearance is opaque??? + return true; + } + + void handleFrequencyChange(int bit) { + // System.out.println("ShaderAppearanceRetained : handleFrequencyChange()"); + super.handleFrequencyChange(bit); + + int mask = 0; + if (bit == ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE) + mask = SHADER_PROGRAM; + else if (bit == ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_WRITE) + mask = SHADER_ATTRIBUTE_SET; + + + if (mask != 0) + setFrequencyChangeMask(bit, mask); + } +} + + diff --git a/src/classes/share/javax/media/j3d/ShaderAttribute.java b/src/classes/share/javax/media/j3d/ShaderAttribute.java new file mode 100644 index 0000000..7618492 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttribute.java @@ -0,0 +1,77 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttribute object encapsulates a uniform attribute for a + * shader programs. Uniform attributes (variables) are those + * attributes whose values are constant during the rendering of a + * primitive. Their values may change from primitive to primitive, but + * are constant for each vertex (for vertex shaders) or fragment (for + * fragment shaders) of a single primitive. Examples of uniform + * attributes include a transformation matrix, a texture map, lights, + * lookup tables, etc. + * + * <p> + * There are two ways in which values can be specified for uniform + * attributes: explicitly, by providing a value; and implicitly, by + * defining a binding between a Java 3D system attribute and a uniform + * attribute. This functionality is provided by two subclasses of + * ShaderAttribute as follows: + * + * <ul> + * <li>ShaderAttributeObject, in which attributes are expressed as + * <code>(attrName, value)</code> pairs, is used for explicitly + * defined attributes</li> + * <li>ShaderAttributeBinding, in which attributes are expressed as + * <code>(attrName, j3dAttrName)</code> pairs, is used for + * implicitly defined, automatically tracked attributes</li> + * </ul> + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public abstract class ShaderAttribute extends NodeComponent { + /** + * Name of the shader attribute (immutable) + */ + + /** + * Package scope constructor + * + */ + ShaderAttribute(String attrName) { + if (attrName == null) { + throw new NullPointerException(); + } + + ((ShaderAttributeRetained)this.retained).initializeAttrName(attrName); + } + + /** + * Retrieves the name of this shader attribute. + * + * @return the name of this shader attribute + */ + public String getAttributeName() { + + return ((ShaderAttributeRetained)this.retained).getAttributeName(); + + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeArray.java b/src/classes/share/javax/media/j3d/ShaderAttributeArray.java new file mode 100644 index 0000000..c5ee3db --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeArray.java @@ -0,0 +1,147 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeArray object encapsulates a uniform shader + * attribute whose value is specified explicitly. The shader variable + * <code>attrName</code> is explicitly set to the specified + * <code>value</code> during rendering. <code>attrName</code> must be + * the name of a valid uniform attribute in the shader in which it is + * used. Otherwise, the attribute name will be ignored and a runtime + * error may be generated. The <code>value</code> must be an array + * of one of the allowed classes. The allowed classes are: + * <code>Integer[]</code>, <code>Float[]</code>, + * <code>Tuple{2,3,4}{i,f}[]</code>, <code>Matrix{3,4}f[]</code>. A + * ClassCastException will be thrown if a specified <code>value</code> + * object is not one of the allowed types. Further, the type and length of the + * value is immutable once a ShaderAttributeArray is constructed. + * Subsequent setValue operations must be called with an array of the + * same type and length as the one that was used to construct the + * ShaderAttributeArray. Finally, the type of the <code>value</code> + * object must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public class ShaderAttributeArray extends ShaderAttributeObject { + /** + * Constructs a new ShaderAttributeArray object with the specified + * <code>(attrName, value)</code> pair. The specified value + * must be an array of one of the allowed class types. + * A deep copy of the array is stored. + * + * @param attrName the name of the shader attribute + * @param value the value of the shader attribute + * + * @exception NullPointerException if attrName or value is null + * + * @exception ClassCastException if value is not an array of + * one of the allowed classes + */ + public ShaderAttributeArray(String attrName, Object value) { + super(attrName, value); + } + + // Implement abstract getValue method + public Object getValue() { + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject0")); + + return ((ShaderAttributeArrayRetained)this.retained).getValue(); + } + + // Implement abstract setValue method + public void setValue(Object value) { + if (value == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject1")); + + if (isLive()) + ((ShaderAttributeArrayRetained)this.retained).setValue(value); + else + ((ShaderAttributeArrayRetained)this.retained).initValue(value); + + } + + + /** + * Sets the specified array element of the value of this shader + * attribute to the specified value. + * A copy of the object is stored. + * + * @param value the new value of the shader attribute + * + * @exception NullPointerException if value is null + * + * @exception ClassCastException if value is not an instance of + * the same base class as the individual elements of the array object + * used to construct this shader attribute object. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void setValue(int index, Object value) { + if (value == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject1")); + + if (isLive()) + ((ShaderAttributeArrayRetained)this.retained).setValue(index, value); + else { + ((ShaderAttributeArrayRetained)this.retained).initValue(index, value); + } + } + + /** + * Returns the number of elements in the value array. + * + * @return the number of elements in the value array + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public int length() { + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject0")); + + return ((ShaderAttributeArrayRetained)this.retained).length(); + } + + /** + * Creates a retained mode ShaderAttributeArrayRetained object that this + * ShaderAttributeArray component object will point to. + */ + void createRetained() { + this.retained = new ShaderAttributeArrayRetained(); + this.retained.setSource(this); + } +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeArrayRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeArrayRetained.java new file mode 100644 index 0000000..f4d4a42 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeArrayRetained.java @@ -0,0 +1,996 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeArray object encapsulates a uniform shader + * attribute whose value is specified explicitly. The shader variable + * <code>attrName</code> is explicitly set to the specified + * <code>value</code> during rendering. <code>attrName</code> must be + * the name of a valid uniform attribute in the shader in which it is + * used. Otherwise, the attribute name will be ignored and a runtime + * error may be generated. The <code>value</code> must be an array + * of one of the allowed classes. The allowed classes are: + * <code>Integer[]</code>, <code>Float[]</code>, + * <code>Tuple{2,3,4}{i,f}[]</code>, <code>Matrix{3,4}f[]</code>. A + * ClassCastException will be thrown if a specified <code>value</code> + * object is not one of the allowed types. Further, the type and length of the + * value is immutable once a ShaderAttributeArray is constructed. + * Subsequent setValue operations must be called with an array of the + * same type and length as the one that was used to construct the + * ShaderAttributeArray. Finally, the type of the <code>value</code> + * object must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +class ShaderAttributeArrayRetained extends ShaderAttributeObjectRetained { + + ShaderAttributeArrayRetained() { + } + + void initValue(int index, Object value) { + /* + System.err.println("ShaderAttributeObjectRetained : attrName = " + attrName + + ", index = " + index + ", value = " + value + + ", value.class = " + value.getClass()); + */ + ((ArrayWrapper)attrWrapper).set(index, value); + + } + + + /** + * Sets the specified array element of the value of this shader + * attribute to the specified value. + * A copy of the object is stored. + * + * @param value the new value of the shader attribute + * + * @exception NullPointerException if value is null + * + * @exception ClassCastException if value is not an instance of + * the same base class as the individual elements of the array object + * used to construct this shader attribute object. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + void setValue(int index, Object value) { + initValue(index, value); + // We should only need to update the array instead of replacing it. + // Until this become a really bottleneck, it will just be a convenience + // method for end user. + // An efficient approach is to + // (1) Create a new ShaderAttributeValue object for the "value" object + // and pass it to sendMessage(), (2) Create a new sendMessage that take in + // a third arguement, ie. index. + setValue(attrWrapper.getRef()); + } + + /** + * Returns the number of elements in the value array. + * + * @return the number of elements in the value array + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + int length() { + return ((ArrayWrapper)attrWrapper).length(); + + } + + // Helper methods ... + + synchronized void createMirrorObject() { + // System.out.println("ShaderAttributeArrayRetained : createMirrorObject"); + // This method should only call by setLive(). + if (mirror == null) { + ShaderAttributeArrayRetained mirrorSAA = new ShaderAttributeArrayRetained(); + mirrorSAA.createObjectData(getValue()); + mirror = mirrorSAA; + mirror.source = source; + + } + initMirrorObject(); + } + + + /** + * Computes the base class from the specified object. A + * ClassCastException is thrown if the object is not an array of + * one of the allowed classes. + */ + int computeClassType(Object value) { + Class objClass = value.getClass(); + if (!objClass.isArray()) { + throw new ClassCastException(objClass + " -- must be array class"); + } + + for (int i = 0; i < classTable.length; i++) { + if (classTableArr[i].isInstance(value)) { + return i; + } + } + throw new ClassCastException(objClass + " -- unrecognized class"); + } + + /** + * Returns the base class represented by the specified class type. + */ + Class getBaseClass(int classType) { + return classTableArr[classType]; + } + + /** + * Creates an attribute wrapper object of the specified class + * type, and stores the specified array of objects. + */ + AttrWrapper createAttrWrapper(Object value, int classType) { + ArrayWrapper attrWrapper = null; + switch (classType) { + case TYPE_INTEGER: + attrWrapper = new IntegerArrayWrapper(); + break; + case TYPE_FLOAT: + attrWrapper = new FloatArrayWrapper(); + break; +// case TYPE_DOUBLE: +// attrWrapper = new DoubleArrayWrapper(); +// break; + case TYPE_TUPLE2I: + attrWrapper = new Tuple2iArrayWrapper(); + break; + case TYPE_TUPLE2F: + attrWrapper = new Tuple2fArrayWrapper(); + break; +// case TYPE_TUPLE2D: +// attrWrapper = new Tuple2dArrayWrapper(); +// break; + case TYPE_TUPLE3I: + attrWrapper = new Tuple3iArrayWrapper(); + break; + case TYPE_TUPLE3F: + attrWrapper = new Tuple3fArrayWrapper(); + break; +// case TYPE_TUPLE3D: +// attrWrapper = new Tuple3dArrayWrapper(); +// break; + case TYPE_TUPLE4I: + attrWrapper = new Tuple4iArrayWrapper(); + break; + case TYPE_TUPLE4F: + attrWrapper = new Tuple4fArrayWrapper(); + break; +// case TYPE_TUPLE4D: +// attrWrapper = new Tuple4dArrayWrapper(); +// break; + case TYPE_MATRIX3F: + attrWrapper = new Matrix3fArrayWrapper(); + break; +// case TYPE_MATRIX3D: +// attrWrapper = new Matrix3dArrayWrapper(); +// break; + case TYPE_MATRIX4F: + attrWrapper = new Matrix4fArrayWrapper(); + break; +// case TYPE_MATRIX4D: +// attrWrapper = new Matrix4dArrayWrapper(); +// break; + default: + // Should never get here + assert false; + return null; + } + + attrWrapper.set(value); + return attrWrapper; + } + + + // + // The following wrapper classes are used to store a copy of the + // user-specified shader attribute value. There is a wrapper class + // for each supported base class. + // + + // Base wrapper class for array attribute types + static abstract class ArrayWrapper extends AttrWrapper { + int length = 0; + + /** + * Returns the length of the array + */ + int length() { + return length; + } + + /** + * Sets the specified array element of the value of this + * shader attribute to the specified value. + */ + abstract void set(int index, Object value); + } + + // Wrapper class for Integer + static class IntegerArrayWrapper extends ArrayWrapper { + private int[] value = new int[0]; + + void set(Object value) { + Integer[] arr = (Integer[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new int[this.length]; + } + for (int i = 0; i < this.length; i++) { + this.value[i] = arr[i].intValue(); + } + } + + void set(int index, Object value) { + this.value[index] = ((Integer)value).intValue(); + } + + Object get() { + Integer[] arr = new Integer[this.length]; + for (int i = 0; i < this.length; i++) { + arr[i] = new Integer(this.value[i]); + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + // Wrapper class for Float + static class FloatArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Float[] arr = (Float[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length]; + } + for (int i = 0; i < this.length; i++) { + this.value[i] = arr[i].floatValue(); + } + } + + void set(int index, Object value) { + this.value[index] = ((Float)value).floatValue(); + } + + Object get() { + Float[] arr = new Float[this.length]; + for (int i = 0; i < this.length; i++) { + arr[i] = new Float(this.value[i]); + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Double + static class DoubleArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Double[] arr = (Double[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length]; + } + for (int i = 0; i < this.length; i++) { + this.value[i] = arr[i].doubleValue(); + } + } + + void set(int index, Object value) { + this.value[index] = ((Double)value).doubleValue(); + } + + Object get() { + Double[] arr = new Double[this.length]; + for (int i = 0; i < this.length; i++) { + arr[i] = new Double(this.value[i]); + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ + + // Wrapper class for Tuple2i + static class Tuple2iArrayWrapper extends ArrayWrapper { + private int[] value = new int[0]; + + void set(Object value) { + Tuple2i[] arr = (Tuple2i[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new int[this.length*2]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 2; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + } + } + + void set(int index, Object value) { + int j = index * 2; + this.value[j+0] = ((Tuple2i)value).x; + this.value[j+1] = ((Tuple2i)value).y; + } + + Object get() { + Tuple2i[] arr = new Tuple2i[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 2; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + // Wrapper class for Tuple2f + static class Tuple2fArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Tuple2f[] arr = (Tuple2f[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length*2]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 2; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + } + } + + void set(int index, Object value) { + int j = index * 2; + this.value[j+0] = ((Tuple2f)value).x; + this.value[j+1] = ((Tuple2f)value).y; + } + + Object get() { + Tuple2f[] arr = new Tuple2f[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 2; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Tuple2d + static class Tuple2dArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Tuple2d[] arr = (Tuple2d[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length*2]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 2; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + } + } + + void set(int index, Object value) { + int j = index * 2; + this.value[j+0] = ((Tuple2d)value).x; + this.value[j+1] = ((Tuple2d)value).y; + } + + Object get() { + Tuple2d[] arr = new Tuple2d[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 2; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ + + // Wrapper class for Tuple3i + static class Tuple3iArrayWrapper extends ArrayWrapper { + private int[] value = new int[0]; + + void set(Object value) { + Tuple3i[] arr = (Tuple3i[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new int[this.length*3]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 3; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + } + } + + void set(int index, Object value) { + int j = index * 3; + this.value[j+0] = ((Tuple3i)value).x; + this.value[j+1] = ((Tuple3i)value).y; + this.value[j+2] = ((Tuple3i)value).z; + } + + Object get() { + Tuple3i[] arr = new Tuple3i[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 3; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + // Wrapper class for Tuple3f + static class Tuple3fArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Tuple3f[] arr = (Tuple3f[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length*3]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 3; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + } + } + + void set(int index, Object value) { + int j = index * 3; + this.value[j+0] = ((Tuple3f)value).x; + this.value[j+1] = ((Tuple3f)value).y; + this.value[j+2] = ((Tuple3f)value).z; + } + + Object get() { + Tuple3f[] arr = new Tuple3f[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 3; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Tuple3d + static class Tuple3dArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Tuple3d[] arr = (Tuple3d[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length*3]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 3; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + } + } + + void set(int index, Object value) { + int j = index * 3; + this.value[j+0] = ((Tuple3d)value).x; + this.value[j+1] = ((Tuple3d)value).y; + this.value[j+2] = ((Tuple3d)value).z; + } + + Object get() { + Tuple3d[] arr = new Tuple3d[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 3; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ + + // Wrapper class for Tuple4i + static class Tuple4iArrayWrapper extends ArrayWrapper { + private int[] value = new int[0]; + + void set(Object value) { + Tuple4i[] arr = (Tuple4i[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new int[this.length*4]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 4; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + this.value[j+3] = arr[i].w; + } + } + + void set(int index, Object value) { + int j = index * 4; + this.value[j+0] = ((Tuple4i)value).x; + this.value[j+1] = ((Tuple4i)value).y; + this.value[j+2] = ((Tuple4i)value).z; + this.value[j+3] = ((Tuple4i)value).w; + } + + Object get() { + Tuple4i[] arr = new Tuple4i[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 4; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + arr[i].w = this.value[j+3]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + // Wrapper class for Tuple4f + static class Tuple4fArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Tuple4f[] arr = (Tuple4f[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length*4]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 4; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + this.value[j+3] = arr[i].w; + } + } + + void set(int index, Object value) { + int j = index * 4; + this.value[j+0] = ((Tuple4f)value).x; + this.value[j+1] = ((Tuple4f)value).y; + this.value[j+2] = ((Tuple4f)value).z; + this.value[j+3] = ((Tuple4f)value).w; + } + + Object get() { + Tuple4f[] arr = new Tuple4f[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 4; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + arr[i].w = this.value[j+3]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Tuple4d + static class Tuple4dArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Tuple4d[] arr = (Tuple4d[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length*4]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 4; + this.value[j+0] = arr[i].x; + this.value[j+1] = arr[i].y; + this.value[j+2] = arr[i].z; + this.value[j+3] = arr[i].w; + } + } + + void set(int index, Object value) { + int j = index * 4; + this.value[j+0] = ((Tuple4d)value).x; + this.value[j+1] = ((Tuple4d)value).y; + this.value[j+2] = ((Tuple4d)value).z; + this.value[j+3] = ((Tuple4d)value).w; + } + + Object get() { + Tuple4d[] arr = new Tuple4d[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 4; + arr[i].x = this.value[j+0]; + arr[i].y = this.value[j+1]; + arr[i].z = this.value[j+2]; + arr[i].w = this.value[j+3]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ + + // Wrapper class for Matrix3f + static class Matrix3fArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Matrix3f[] arr = (Matrix3f[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length * 9]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 9; + this.value[j+0] = arr[i].m00; + this.value[j+1] = arr[i].m01; + this.value[j+2] = arr[i].m02; + this.value[j+3] = arr[i].m10; + this.value[j+4] = arr[i].m11; + this.value[j+5] = arr[i].m12; + this.value[j+6] = arr[i].m20; + this.value[j+7] = arr[i].m21; + this.value[j+8] = arr[i].m22; + } + } + + void set(int index, Object value) { + int j = index * 9; + Matrix3f m = (Matrix3f)value; + + this.value[j+0] = m.m00; + this.value[j+1] = m.m01; + this.value[j+2] = m.m02; + this.value[j+3] = m.m10; + this.value[j+4] = m.m11; + this.value[j+5] = m.m12; + this.value[j+6] = m.m20; + this.value[j+7] = m.m21; + this.value[j+8] = m.m22; + } + + Object get() { + Matrix3f[] arr = new Matrix3f[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 9; + arr[i].m00 = this.value[j+0]; + arr[i].m01 = this.value[j+1]; + arr[i].m02 = this.value[j+2]; + arr[i].m10 = this.value[j+3]; + arr[i].m11 = this.value[j+4]; + arr[i].m12 = this.value[j+5]; + arr[i].m20 = this.value[j+6]; + arr[i].m21 = this.value[j+7]; + arr[i].m22 = this.value[j+8]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Matrix3d + static class Matrix3dArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Matrix3d[] arr = (Matrix3d[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length * 9]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 9; + this.value[j+0] = arr[i].m00; + this.value[j+1] = arr[i].m01; + this.value[j+2] = arr[i].m02; + this.value[j+3] = arr[i].m10; + this.value[j+4] = arr[i].m11; + this.value[j+5] = arr[i].m12; + this.value[j+6] = arr[i].m20; + this.value[j+7] = arr[i].m21; + this.value[j+8] = arr[i].m22; + } + } + + void set(int index, Object value) { + int j = index * 9; + Matrix3d m = (Matrix3d)value; + + this.value[j+0] = m.m00; + this.value[j+1] = m.m01; + this.value[j+2] = m.m02; + this.value[j+3] = m.m10; + this.value[j+4] = m.m11; + this.value[j+5] = m.m12; + this.value[j+6] = m.m20; + this.value[j+7] = m.m21; + this.value[j+8] = m.m22; + } + + Object get() { + Matrix3d[] arr = new Matrix3d[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 9; + arr[i].m00 = this.value[j+0]; + arr[i].m01 = this.value[j+1]; + arr[i].m02 = this.value[j+2]; + arr[i].m10 = this.value[j+3]; + arr[i].m11 = this.value[j+4]; + arr[i].m12 = this.value[j+5]; + arr[i].m20 = this.value[j+6]; + arr[i].m21 = this.value[j+7]; + arr[i].m22 = this.value[j+8]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ + + // Wrapper class for Matrix4f + static class Matrix4fArrayWrapper extends ArrayWrapper { + private float[] value = new float[0]; + + void set(Object value) { + Matrix4f[] arr = (Matrix4f[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new float[this.length * 16]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 16; + this.value[j+0] = arr[i].m00; + this.value[j+1] = arr[i].m01; + this.value[j+2] = arr[i].m02; + this.value[j+3] = arr[i].m03; + this.value[j+4] = arr[i].m10; + this.value[j+5] = arr[i].m11; + this.value[j+6] = arr[i].m12; + this.value[j+7] = arr[i].m13; + this.value[j+8] = arr[i].m20; + this.value[j+9] = arr[i].m21; + this.value[j+10] = arr[i].m22; + this.value[j+11] = arr[i].m23; + this.value[j+12] = arr[i].m30; + this.value[j+13] = arr[i].m31; + this.value[j+14] = arr[i].m32; + this.value[j+15] = arr[i].m33; + } + } + + void set(int index, Object value) { + int j = index * 16; + Matrix4f m = (Matrix4f)value; + + this.value[j+0] = m.m00; + this.value[j+1] = m.m01; + this.value[j+2] = m.m02; + this.value[j+3] = m.m03; + this.value[j+4] = m.m10; + this.value[j+5] = m.m11; + this.value[j+6] = m.m12; + this.value[j+7] = m.m13; + this.value[j+8] = m.m20; + this.value[j+9] = m.m21; + this.value[j+10] = m.m22; + this.value[j+11] = m.m23; + this.value[j+12] = m.m30; + this.value[j+13] = m.m31; + this.value[j+14] = m.m32; + this.value[j+15] = m.m33; + } + + Object get() { + Matrix4f[] arr = new Matrix4f[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 16; + arr[i].m00 = this.value[j+0]; + arr[i].m01 = this.value[j+1]; + arr[i].m02 = this.value[j+2]; + arr[i].m03 = this.value[j+3]; + arr[i].m10 = this.value[j+4]; + arr[i].m11 = this.value[j+5]; + arr[i].m12 = this.value[j+6]; + arr[i].m13 = this.value[j+7]; + arr[i].m20 = this.value[j+8]; + arr[i].m21 = this.value[j+9]; + arr[i].m22 = this.value[j+10]; + arr[i].m23 = this.value[j+11]; + arr[i].m30 = this.value[j+12]; + arr[i].m31 = this.value[j+13]; + arr[i].m32 = this.value[j+14]; + arr[i].m33 = this.value[j+15]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Matrix4d + static class Matrix4dArrayWrapper extends ArrayWrapper { + private double[] value = new double[0]; + + void set(Object value) { + Matrix4d[] arr = (Matrix4d[])value; + if (this.length != arr.length) { + this.length = arr.length; + this.value = new double[this.length * 16]; + } + for (int i = 0; i < this.length; i++) { + int j = i * 16; + this.value[j+0] = arr[i].m00; + this.value[j+1] = arr[i].m01; + this.value[j+2] = arr[i].m02; + this.value[j+3] = arr[i].m03; + this.value[j+4] = arr[i].m10; + this.value[j+5] = arr[i].m11; + this.value[j+6] = arr[i].m12; + this.value[j+7] = arr[i].m13; + this.value[j+8] = arr[i].m20; + this.value[j+9] = arr[i].m21; + this.value[j+10] = arr[i].m22; + this.value[j+11] = arr[i].m23; + this.value[j+12] = arr[i].m30; + this.value[j+13] = arr[i].m31; + this.value[j+14] = arr[i].m32; + this.value[j+15] = arr[i].m33; + } + } + + void set(int index, Object value) { + int j = index * 16; + Matrix4d m = (Matrix4d)value; + + this.value[j+0] = m.m00; + this.value[j+1] = m.m01; + this.value[j+2] = m.m02; + this.value[j+3] = m.m03; + this.value[j+4] = m.m10; + this.value[j+5] = m.m11; + this.value[j+6] = m.m12; + this.value[j+7] = m.m13; + this.value[j+8] = m.m20; + this.value[j+9] = m.m21; + this.value[j+10] = m.m22; + this.value[j+11] = m.m23; + this.value[j+12] = m.m30; + this.value[j+13] = m.m31; + this.value[j+14] = m.m32; + this.value[j+15] = m.m33; + } + + Object get() { + Matrix4d[] arr = new Matrix4d[this.length]; + for (int i = 0; i < this.length; i++) { + int j = i * 16; + arr[i].m00 = this.value[j+0]; + arr[i].m01 = this.value[j+1]; + arr[i].m02 = this.value[j+2]; + arr[i].m03 = this.value[j+3]; + arr[i].m10 = this.value[j+4]; + arr[i].m11 = this.value[j+5]; + arr[i].m12 = this.value[j+6]; + arr[i].m13 = this.value[j+7]; + arr[i].m20 = this.value[j+8]; + arr[i].m21 = this.value[j+9]; + arr[i].m22 = this.value[j+10]; + arr[i].m23 = this.value[j+11]; + arr[i].m30 = this.value[j+12]; + arr[i].m31 = this.value[j+13]; + arr[i].m32 = this.value[j+14]; + arr[i].m33 = this.value[j+15]; + } + return arr; + } + + Object getRef() { + return this.value; + } + } + */ +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeBinding.java b/src/classes/share/javax/media/j3d/ShaderAttributeBinding.java new file mode 100644 index 0000000..608fbfc --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeBinding.java @@ -0,0 +1,128 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeBinding object encapsulates a uniform attribute + * whose value is bound to a Java 3D system attribute. The + * shader variable <code>attrName</code> is implicitly set to the + * value of the corresponding Java 3D system attribute + * <code>j3dAttrName</code> during rendering. <code>attrName</code> + * must be the name of a valid uniform attribute in the shader in + * which it is used. Otherwise, the attribute name will be ignored and + * a runtime error may be generated. <code>j3dAttrName</code> must be + * the name of a predefined Java 3D system attribute. An + * IllegalArgumentException will be thrown if the specified + * <code>j3dAttrName</code> is not one of the predefined system + * attributes. Further, the type of the <code>j3dAttrName</code> + * attribute must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + * + * <p> + * Following is the list of predefined Java 3D system attributes:<br> + * + * <ul> + * <font color="#ff0000"><i>TODO: replace the following with + * the real system attributes table</i></font><br> + * <table BORDER=1 CELLSPACING=2 CELLPADDING=2> + * <tr> + * <td><b>Name</b></td> + * <td><b>Type</b></td> + * <td><b>Description</b></td> + * </tr> + * <tr> + * <td><code>something</code></td> + * <td>Float</td> + * <td>This is something (of course)</td> + * </tr> + * <tr> + * <td><code>somethingElse</code></td> + * <td>Tuple3f</td> + * <td>This is something else</td> + * </tr> + * </table> + * </ul> + * + * <p> + * Depending on the shading language (and profile) being used, several + * Java 3D state attributes are automatically made available to the + * shader program as pre-defined uniform attributes. The application + * doesn't need to do anything to pass these attributes in to the + * shader program. The implementation of each shader language (e.g., + * Cg, GLSL) defines its own mapping from Java 3D attribute to uniform + * variable name. + * + * <p> + * A list of these attributes for each shader language can be found in + * the concrete subclass of ShaderProgram for that shader language. + * + * <p> + * <font color="#ff0000"><i>NOTE: This class is not yet + * implemented.</i></font><br> + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public class ShaderAttributeBinding extends ShaderAttribute { + + /** + * Constructs a new ShaderAttributeBinding from the specified + * <code>(attrName, j3dAttrName)</code> pair. + * + * @param attrName the name of the shader attribute to be added + * @param j3dAttrName the name of the Java 3D attribute + * to bind to the shader attribute + * + * @exception UnsupportedOperationException this class is not + * yet implemented + * + * @exception NullPointerException if attrName or j3dAttrName is null + * + * @exception IllegalArgumentException if j3dAttrName is not the name + * of a valid predefined Java 3D system attribute + */ + public ShaderAttributeBinding(String attrName, String j3dAttrName) { + super(attrName); + ((ShaderAttributeBindingRetained)this.retained).initJ3dAttrName(j3dAttrName); + // TODO: implement this class + throw new UnsupportedOperationException(J3dI18N.getString("ShaderAttributeBinding0")); + } + + /** + * Retrieves the name of the Java 3D system attribute that is bound to this + * shader attribute. + * + * @return the name of the Java 3D system attribute that is bound to this + * shader attribute + */ + public String getJ3DAttributeName() { + return ((ShaderAttributeBindingRetained)this.retained).getJ3DAttributeName(); + } + + /** + * Creates a retained mode ShaderAttributeBindingRetained object that this + * ShaderAttributeBinding component object will point to. + */ + void createRetained() { + this.retained = new ShaderAttributeBindingRetained(); + this.retained.setSource(this); + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeBindingRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeBindingRetained.java new file mode 100644 index 0000000..b580406 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeBindingRetained.java @@ -0,0 +1,57 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeBinding object encapsulates a uniform attribute + * whose value is bound to a Java 3D system attribute. The + * shader variable <code>attrName</code> is implicitly set to the + * value of the corresponding Java 3D system attribute + * <code>j3dAttrName</code> during rendering. <code>attrName</code> + * must be the name of a valid uniform attribute in the shader in + * which it is used. Otherwise, the attribute name will be ignored and + * a runtime error may be generated. <code>j3dAttrName</code> must be + * the name of a predefined Java 3D system attribute. An + * IllegalArgumentException will be thrown if the specified + * <code>j3dAttrName</code> is not one of the predefined system + * attributes. Further, the type of the <code>j3dAttrName</code> + * attribute must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + */ + +class ShaderAttributeBindingRetained extends ShaderAttributeRetained { + String j3dAttrName; + + ShaderAttributeBindingRetained() { + } + + void initJ3dAttrName(String j3dAttrName) { + this.j3dAttrName = j3dAttrName; + } + + /** + * Retrieves the name of the Java 3D system attribute that is bound to this + * shader attribute. + * + * @return the name of the Java 3D system attribute that is bound to this + * shader attribute + */ + String getJ3DAttributeName() { + return j3dAttrName; + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeObject.java b/src/classes/share/javax/media/j3d/ShaderAttributeObject.java new file mode 100644 index 0000000..b3a275d --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeObject.java @@ -0,0 +1,130 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeObject class is an abstract class that + * encapsulates a uniform shader attribute whose value is specified + * explicitly. This class has concrete subclasses for single-value + * attributes (ShaderAttributeValue) and array attributes + * (ShaderAttributeArray). The shader variable <code>attrName</code> + * is explicitly set to the specified <code>value</code> during + * rendering. <code>attrName</code> must be the name of a valid + * uniform attribute in the shader in which it is used. Otherwise, the + * attribute name will be ignored and a runtime error may be + * generated. The <code>value</code> must be an instance of one of the + * allowed classes or an array of one the allowed classes. The allowed + * classes are: <code>Integer</code>, <code>Float</code>, + * <code>Tuple{2,3,4}{i,f}</code>, + * <code>Matrix{3,4}f</code>. A ClassCastException will be thrown + * if a specified <code>value</code> object is not one of the allowed + * types. Further, the type of the value is immutable once a + * ShaderAttributeObject is constructed. Subsequent setValue + * operations must be called with an object of the same type as the + * one that was used to construct the ShaderAttributeObject. Finally, + * the type of the <code>value</code> object must match the type of + * the corresponding <code>attrName</code> variable in the shader in + * which it is used. Otherwise, the shader will not be able to use the + * attribute and a runtime error may be generated. + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public abstract class ShaderAttributeObject extends ShaderAttribute { + + /** + * Specifies that this ShaderAttributeObject allows reading its value. + */ + public static final int + ALLOW_VALUE_READ = + CapabilityBits.SHADER_ATTRIBUTE_OBJECT_ALLOW_VALUE_READ; + + /** + * Specifies that this ShaderAttributeObject allows writing its value. + */ + public static final int + ALLOW_VALUE_WRITE = + CapabilityBits.SHADER_ATTRIBUTE_OBJECT_ALLOW_VALUE_WRITE; + + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_VALUE_READ + }; + + + /** + * Package scope constructor + */ + ShaderAttributeObject(String attrName, Object value) { + super(attrName); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((ShaderAttributeObjectRetained)this.retained).createObjectData(value); + } + + + /** + * Retrieves the value of this shader attribute. + * A copy of the object is returned. + * + * @return a copy of the value of this shader attribute + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public abstract Object getValue(); + + /** + * Sets the value of this shader attribute to the specified value. + * A copy of the object is stored. + * + * @param value the new value of the shader attribute + * + * @exception NullPointerException if value is null + * + * @exception ClassCastException if value is not an instance of + * the same base class as the object used to construct this shader + * attribute object. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public abstract void setValue(Object value); + + /** + * Retrieves the base class of the value of this shader attribute. + * This class will always be one of the allowable classes, even if + * a subclass was used to construct this shader attribute object. + * For example, if this shader attribute object was constructed + * with an instance of <code>javax.vecmath.Point3f</code>, the + * returned class would be <code>javax.vecmath.Tuple3f</code>. + * + * @return the base class of the value of this shader attribute + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public Class getValueClass() { + + return ((ShaderAttributeObjectRetained)this.retained).getValueClass(); + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java new file mode 100644 index 0000000..a66335c --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeObjectRetained.java @@ -0,0 +1,311 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.ArrayList; +import javax.vecmath.*; + +/** + * The ShaderAttributeObjectRetained class is an abstract class that + * encapsulates a uniform shader attribute whose value is specified + * explicitly. This class has concrete subclasses for single-value + * attributes (ShaderAttributeValueRetained) and array attributes + * (ShaderAttributeArrayRetained). The shader variable <code>attrName</code> + * is explicitly set to the specified <code>value</code> during + * rendering. <code>attrName</code> must be the name of a valid + * uniform attribute in the shader in which it is used. Otherwise, the + * attribute name will be ignored and a runtime error may be + * generated. The <code>value</code> must be an instance of one of the + * allowed classes or an array of one the allowed classes. The allowed + * classes are: <code>Integer</code>, <code>Float</code>, + * <code>Tuple{2,3,4}{i,f}</code>, + * <code>Matrix{3,4}f</code>. A ClassCastException will be thrown + * if a specified <code>value</code> object is not one of the allowed + * types. Further, the type of the value is immutable once a + * ShaderAttributeObjectRetained is constructed. Subsequent setValue + * operations must be called with an object of the same type as the + * one that was used to construct the ShaderAttributeObjectRetained. + * Finally, the type of the <code>value</code> object must match the type + * of the corresponding <code>attrName</code> variable in the shader in + * which it is used. Otherwise, the shader will not be able to use the + * attribute and a runtime error may be generated. + * + * @see ShaderAttributeSetRetained + * @see ShaderProgramRetained + * + * @since Java 3D 1.4 + */ + +abstract class ShaderAttributeObjectRetained extends ShaderAttributeRetained { + + private int classType; + private Class baseClass; + AttrWrapper attrWrapper; + + /** + * Package scope constructor + */ + ShaderAttributeObjectRetained() { + } + + void createObjectData(Object value) { + + classType = computeClassType(value); + baseClass = getBaseClass(classType); + attrWrapper = createAttrWrapper(value, classType); + /* + System.err.println(" classType = " + classType + + ", baseClass = " + baseClass + + ", attrWrapper.get() = " + attrWrapper.get()); + */ + } + + + void initValue(Object value) { + /* + System.err.println("ShaderAttributeObjectRetained : attrName = " + attrName + + ", value = " + value + + ", value.class = " + value.getClass()); + */ + attrWrapper.set(value); + + } + + /** + * Retrieves the value of this shader attribute. + * A copy of the object is returned. + */ + Object getValue() { + return attrWrapper.get(); + } + + /** + * Sets the value of this shader attribute to the specified value. + * A copy of the object is stored. + * + * @param value the new value of the shader attribute + * + * @exception NullPointerException if value is null + * + * @exception ClassCastException if value is not an instance of + * the same base class as the object used to construct this shader + * attribute object. + * + */ + void setValue(Object value) { + initValue(value); + AttrWrapper valueWrapper = createAttrWrapper(value, this.classType); + sendMessage(SHADER_ATTRIBUTE_VALUE_UPDATE, valueWrapper); + } + + /** + * Retrieves the base class of the value of this shader attribute. + * This class will always be one of the allowable classes, even if + * a subclass was used to construct this shader attribute object. + * For example, if this shader attribute object was constructed + * with an instance of <code>javax.vecmath.Point3f</code>, the + * returned class would be <code>javax.vecmath.Tuple3f</code>. + * + * @return the base class of the value of this shader attribute + */ + Class getValueClass() { + return baseClass; + } + + /** + * Initializes a mirror object. + */ + synchronized void initMirrorObject() { + super.initMirrorObject(); + ((ShaderAttributeObjectRetained)mirror).initValue(getValue()); + } + + /** + * Update the "component" field of the mirror object with the given "value" + */ + synchronized void updateMirrorObject(int component, Object value) { + + //System.out.println("ShaderAttributeObjectRetained : updateMirrorObject"); + ShaderAttributeObjectRetained mirrorSAV = (ShaderAttributeObjectRetained)mirror; + if ((component & SHADER_ATTRIBUTE_VALUE_UPDATE) != 0) { + //System.out.println(" -- SHADER_ATTRIBUTE_VALUE_UPDATE"); + mirrorSAV.attrWrapper = (AttrWrapper) value; + } + } + + final void sendMessage(int attrMask, Object attr) { + + ArrayList univList = new ArrayList(); + ArrayList gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList); + + // Send to rendering attribute structure, regardless of + // whether there are users or not (alternate appearance case ..) + J3dMessage createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES; + createMessage.type = J3dMessage.SHADER_ATTRIBUTE_CHANGED; + createMessage.universe = null; + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + // System.out.println("changedFreqent1 = "+changedFrequent); + createMessage.args[3] = new Integer(changedFrequent); + VirtualUniverse.mc.processMessage(createMessage); + + // System.out.println("univList.size is " + univList.size()); + for(int i=0; i<univList.size(); i++) { + createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDER; + createMessage.type = J3dMessage.SHADER_ATTRIBUTE_CHANGED; + + createMessage.universe = (VirtualUniverse) univList.get(i); + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + + ArrayList gL = (ArrayList)gaList.get(i); + GeometryAtom[] gaArr = new GeometryAtom[gL.size()]; + gL.toArray(gaArr); + createMessage.args[3] = gaArr; + + VirtualUniverse.mc.processMessage(createMessage); + } + + } + + + // Enumerated types representing allowed classes for shader + // attributes. + // + // NOTE that the values for these enums are used as an index into + // the tables of classes, so the values must start at 0 and + // increment by 1. Also, the order must be the same as the order + // of the entries in each of the two class tables. + static final int TYPE_INTEGER = 0; + static final int TYPE_FLOAT = 1; + static final int TYPE_TUPLE2I = 2; + static final int TYPE_TUPLE2F = 3; + static final int TYPE_TUPLE3I = 4; + static final int TYPE_TUPLE3F = 5; + static final int TYPE_TUPLE4I = 6; + static final int TYPE_TUPLE4F = 7; + static final int TYPE_MATRIX3F = 8; + static final int TYPE_MATRIX4F = 9; + + // Double-precision is not supported in the current version. Uncomment the + // following if future support is done. +// static final int TYPE_DOUBLE = 10; +// static final int TYPE_TUPLE2D = 11; +// static final int TYPE_TUPLE3D = 12; +// static final int TYPE_TUPLE4D = 13; +// static final int TYPE_MATRIX3D = 14; +// static final int TYPE_MATRIX4D = 15; + + static final Class classTable[] = { + Integer.class, + Float.class, + Tuple2i.class, + Tuple2f.class, + Tuple3i.class, + Tuple3f.class, + Tuple4i.class, + Tuple4f.class, + Matrix3f.class, + Matrix4f.class, + + // Double-precision is not supported in the current version. Uncomment the + // following if future support is done. +// Double.class, +// Tuple2d.class, +// Tuple3d.class, +// Tuple4d.class, +// Matrix3d.class, +// Matrix4d.class, + }; + + static final Class classTableArr[] = { + Integer[].class, + Float[].class, + Tuple2i[].class, + Tuple2f[].class, + Tuple3i[].class, + Tuple3f[].class, + Tuple4i[].class, + Tuple4f[].class, + Matrix3f[].class, + Matrix4f[].class, + + // Double-precision is not supported in the current version. Uncomment the + // following if future support is done. +// Double[].class, +// Tuple2d[].class, +// Tuple3d[].class, +// Tuple4d[].class, +// Matrix3d[].class, +// Matrix4d[].class, + }; + + + /** + * Computes the base class from the specified object. A + * ClassCastException is thrown if the object is not an instance + * or array of one of the allowed classes. + */ + abstract int computeClassType(Object value); + + /** + * Returns the base class represented by the specified class type. + */ + abstract Class getBaseClass(int classType); + + /** + * Creates an attribute wrapper object of the specified class + * type, and stores the specified object. + */ + abstract AttrWrapper createAttrWrapper(Object value, int classType); + + + /** + * Base wrapper class for subclasses that are used to store a copy + * of the user-specified shader attribute value. There is a + * wrapper class for each supported base class in ShaderAttributeValue + * and ShaderAttributeArray. The value is stored in a Java primitive array. + */ + static abstract class AttrWrapper { + /** + * Stores a copy of the specified object in the wrapper object + */ + abstract void set(Object value); + + /** + * Returns a copy of the wrapped object + */ + abstract Object get(); + + /** + * Returns a reference to the internal primitive array used to + * wrap the object; note that the caller of this method must + * treat the data as read-only. It is intended only as a means + * to pass data down to native methods. + */ + abstract Object getRef(); + } + + int getClassType() { + return classType; + } + + void setClassType(int classType) { + this.classType = classType; + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java new file mode 100644 index 0000000..64cbdc0 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeRetained.java @@ -0,0 +1,82 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeRetained object encapsulates a uniform attribute for a + * shader programs. Uniform attributes (variables) are those + * attributes whose values are constant during the rendering of a + * primitive. Their values may change from primitive to primitive, but + * are constant for each vertex (for vertex shaders) or fragment (for + * fragment shaders) of a single primitive. Examples of uniform + * attributes include a transformation matrix, a texture map, lights, + * lookup tables, etc. + * + * <p> + * There are two ways in which values can be specified for uniform + * attributes: explicitly, by providing a value; and implicitly, by + * defining a binding between a Java 3D system attribute and a uniform + * attribute. This functionality is provided by two subclasses of + * ShaderAttributeRetained as follows: + * + * <ul> + * <li>ShaderAttributeObjectRetained, in which attributes are expressed as + * <code>(attrName, value)</code> pairs, is used for explicitly + * defined attributes</li> + * <li>ShaderAttributeBindingRetained, in which attributes are expressed as + * <code>(attrName, j3dAttrName)</code> pairs, is used for + * implicitly defined, automatically tracked attributes</li> + * </ul> + * + * @see ShaderAttributeSetRetained + * @see ShaderProgramRetained + * + * @since Java 3D 1.4 + */ + +abstract class ShaderAttributeRetained extends NodeComponentRetained { + // A list of pre-defined bits to indicate which component + // in this ShaderAttribute object changed. + static final int SHADER_ATTRIBUTE_VALUE_UPDATE = 0x001; + + /** + * Name of the shader attribute (immutable) + */ + String attrName; + + /** + * Package scope constructor + */ + ShaderAttributeRetained() { + } + + void initializeAttrName(String attrName) { + this.attrName = attrName; + } + + /** + * Retrieves the name of this shader attribute. + * + * @return the name of this shader attribute + */ + String getAttributeName() { + return attrName; + } + + void initMirrorObject() { + ((ShaderAttributeObjectRetained)mirror).initializeAttrName(this.attrName); + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeSet.java b/src/classes/share/javax/media/j3d/ShaderAttributeSet.java new file mode 100644 index 0000000..ad75b11 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeSet.java @@ -0,0 +1,263 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.Iterator; +import java.util.Map; +import java.util.HashMap; +import javax.vecmath.*; + +/** + * The ShaderAttributeSet object provides uniform attributes to shader + * programs. Uniform attributes (variables) are those attributes whose + * values are constant during the rendering of a primitive. Their + * values may change from primitive to primitive, but are constant for + * each vertex (for vertex shaders) or fragment (for fragment shaders) + * of a single primitive. Examples of uniform attributes include a + * transformation matrix, a texture map, lights, lookup tables, etc. + * The ShaderAttributeSet object contains a set of ShaderAttribute + * objects. Each ShaderAttribute object defines the value of a single + * uniform shader variable. The set of attributes is unique with respect + * to attribute names: no two attributes in the set will have the same + * name. + * + * <p> + * There are two ways in which values can be specified for uniform + * attributes: explicitly, by providing a value; and implicitly, by + * defining a binding between a Java 3D system attribute and a uniform + * attribute. This functionality is provided by two subclasses of + * ShaderAttribute: ShaderAttributeObject, which is used to specify + * explicitly defined attributes; and ShaderAttributeBinding, which is + * used to specify implicitly defined, automatically tracked attributes. + * + * <p> + * Depending on the shading language (and profile) being used, several + * Java 3D state attributes are automatically made available to the + * shader program as pre-defined uniform attributes. The application + * doesn't need to do anything to pass these attributes in to the + * shader program. The implementation of each shader language (e.g., + * Cg, GLSL) defines its own bindings from Java 3D attribute to uniform + * variable name. A list of these attributes for each shader language + * can be found in the concrete subclass of ShaderProgram for that + * shader language. + * + * @see ShaderAttribute + * @see ShaderProgram + * @see ShaderAppearance#setShaderAttributeSet + * + * @since Java 3D 1.4 + */ + +public class ShaderAttributeSet extends NodeComponent { + + /** + * Specifies that this ShaderAttributeSet object allows reading + * its attributes. + */ + public static final int + ALLOW_ATTRIBUTES_READ = + CapabilityBits.SHADER_ATTRIBUTE_SET_ALLOW_ATTRIBUTES_READ; + + /** + * Specifies that this ShaderAttributeSet object allows writing + * its attributes. + */ + public static final int + ALLOW_ATTRIBUTES_WRITE = + CapabilityBits.SHADER_ATTRIBUTE_SET_ALLOW_ATTRIBUTES_WRITE; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ATTRIBUTES_READ + }; + + /** + * Constructs an empty ShaderAttributeSet object. The attributes set + * is initially empty. + */ + public ShaderAttributeSet() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } + + // + // Methods for dealing with the (name, value) pairs for explicit + // attributes + // + + /** + * Adds the specified shader attribute to the attributes set. + * The newly specified attribute replaces an attribute with the + * same name, if one already exists in the attributes set. + * + * @param attr the shader attribute to be added to the set + * + * @exception NullPointerException if attr is null + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void put(ShaderAttribute attr) { + if (attr == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet1")); + + ((ShaderAttributeSetRetained)this.retained).put(attr); + + } + + /** + * Retrieves the shader attribute with the specified + * <code>attrName</code> from the attributes set. If attrName does + * not exist in the attributes set, null is returned. + * + * @param attrName the name of the shader attribute to be retrieved + * + * @exception NullPointerException if attrName is null + * + * @return a the shader attribute associated with the specified + * attribute name, or null if the name is not in the attributes + * set + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public ShaderAttribute get(String attrName) { + + if (attrName == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet0")); + + return ((ShaderAttributeSetRetained)this.retained).get(attrName); + } + + /** + * Removes the shader attribute with the specified + * <code>attrName</code> from the attributes set. If attrName does + * not exist in the attributes set then nothing happens. + * + * @param attrName the name of the shader attribute to be removed + * + * @exception NullPointerException if attrName is null + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void remove(String attrName) { + if (attrName == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet1")); + + ((ShaderAttributeSetRetained)this.retained).remove(attrName); + } + + /** + * Removes the specified shader attribute from the attributes + * set. If the attribute does not exist in the attributes set then + * nothing happens. Note that this method will <i>not</i> remove a + * shader object other than the one specified, even if it has the + * same name as the specified attribute. Applications that wish to + * remove an attribute by name should use + * <code>removeAttribute(String)</code>. + * + * @param attr the shader attribute to be removed + * + * @exception NullPointerException if attr is null + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void remove(ShaderAttribute attr) { + if (attr == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet1")); + + ((ShaderAttributeSetRetained)this.retained).remove(attr); + } + + /** + * Removes all shader attributes from the attributes set. The + * attributes set will be empty following this call. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public void clear() { + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet1")); + + ((ShaderAttributeSetRetained)this.retained).clear(); + } + + /** + * Returns a shallow copy of the attributes set. + * + * @return a shallow copy of the attributes set + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public ShaderAttribute[] getAll() { + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet0")); + + return ((ShaderAttributeSetRetained)this.retained).getAll(); + } + + /** + * Returns the number of elements in the attributes set. + * + * @return the number of elements in the attributes set + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public int size() { + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_ATTRIBUTES_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeSet0")); + + return ((ShaderAttributeSetRetained)this.retained).size(); + } + + /** + * Creates a retained mode ShaderAttributeSetRetained object that this + * ShaderAttributeSet component object will point to. + */ + void createRetained() { + // System.out.println("ShaderAttributeSet : createRetained() ..."); + this.retained = new ShaderAttributeSetRetained(); + this.retained.setSource(this); + } +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java new file mode 100644 index 0000000..965387b --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java @@ -0,0 +1,390 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.Iterator; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; +import javax.vecmath.*; + +/** + * The ShaderAttributeSet object provides uniform attributes to shader + * programs. Uniform attributes (variables) are those attributes whose + * values are constant during the rendering of a primitive. Their + * values may change from primitive to primitive, but are constant for + * each vertex (for vertex shaders) or fragment (for fragment shaders) + * of a single primitive. Examples of uniform attributes include a + * transformation matrix, a texture map, lights, lookup tables, etc. + * The ShaderAttributeSet object contains a set of ShaderAttribute + * objects. Each ShaderAttribute object defines the value of a single + * uniform shader variable. The set of attributes is unique with respect + * to attribute names: no two attributes in the set will have the same + * name. + * + * <p> + * There are two ways in which values can be specified for uniform + * attributes: explicitly, by providing a value; and implicitly, by + * defining a binding between a Java 3D system attribute and a uniform + * attribute. This functionality is provided by two subclasses of + * ShaderAttribute: ShaderAttributeObject, which is used to specify + * explicitly defined attributes; and ShaderAttributeBinding, which is + * used to specify implicitly defined, automatically tracked attributes. + * + * <p> + * Depending on the shading language (and profile) being used, several + * Java 3D state attributes are automatically made available to the + * shader program as pre-defined uniform attributes. The application + * doesn't need to do anything to pass these attributes in to the + * shader program. The implementation of each shader language (e.g., + * Cg, GLSL) defines its own bindings from Java 3D attribute to uniform + * variable name. A list of these attributes for each shader language + * can be found in the concrete subclass of ShaderProgram for that + * shader language. + * + * @see ShaderAttribute + * @see ShaderProgram + * @see ShaderAppearance#setShaderAttributeSet + * + * @since Java 3D 1.4 + */ + +class ShaderAttributeSetRetained extends NodeComponentRetained { + // A list of pre-defined bits to indicate which attribute + // operation in this ShaderAttributeSet object is needed. + static final int ATTRIBUTE_SET_PUT = 0x01; + + static final int ATTRIBUTE_SET_REMOVE = 0x02; + + static final int ATTRIBUTE_SET_CLEAR = 0x04; + + private Map attrs = new HashMap(); + + // Lock used for synchronization of live state + Object liveStateLock = new Object(); + + /** + * Constructs an empty ShaderAttributeSetretained object. The attributes set + * is initially empty. + */ + ShaderAttributeSetRetained() { + } + + // + // Methods for dealing with the (name, value) pairs for explicit + // attributes + // + + /** + * Adds the specified shader attribute to the attributes set. + * The newly specified attribute replaces an attribute with the + * same name, if one already exists in the attributes set. + * + * @param attr the shader attribute to be added to the set + * + */ + void put(ShaderAttribute attr) { + synchronized(liveStateLock) { + // System.out.println("ShaderAttributeSetRetained : put()"); + ShaderAttributeRetained sAttr = (ShaderAttributeRetained)attr.retained; + // System.out.println("attr is " + attr ); + // System.out.println("attrName is " + sAttr.attrName + " attr.Retained is "+ sAttr ); + assert(sAttr != null); + attrs.put(sAttr.attrName, sAttr); + + if (source.isLive()) { + sAttr.setLive(inBackgroundGroup, refCount); + sAttr.copyMirrorUsers(this); + + sendMessage(ATTRIBUTE_SET_PUT, sAttr.mirror); + } + } + } + + /** + * Retrieves the shader attribute with the specified + * <code>attrName</code> from the attributes set. If attrName does + * not exist in the attributes set, null is returned. + * + * @param attrName the name of the shader attribute to be retrieved + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + ShaderAttribute get(String attrName) { + return (ShaderAttribute)((ShaderAttributeRetained)attrs.get(attrName)).source; + } + + /** + * Removes the shader attribute with the specified + * <code>attrName</code> from the attributes set. If attrName does + * not exist in the attributes set then nothing happens. + * + * @param attrName the name of the shader attribute to be removed + */ + void remove(String attrName) { + synchronized(liveStateLock) { + ShaderAttributeRetained sAttr = (ShaderAttributeRetained)attrs.get(attrName); + attrs.remove(attrName); + if (source.isLive()) { + sAttr.clearLive(refCount); + sAttr.removeMirrorUsers(this); + + sendMessage(ATTRIBUTE_SET_REMOVE, attrName); + } + } + } + + /** + * Removes the specified shader attribute from the attributes + * set. If the attribute does not exist in the attributes set then + * nothing happens. Note that this method will <i>not</i> remove a + * shader object other than the one specified, even if it has the + * same name as the specified attribute. Applications that wish to + * remove an attribute by name should use + * <code>removeAttribute(String)</code>. + * + * @param attr the shader attribute to be removed + */ + void remove(ShaderAttribute attr) { + synchronized(liveStateLock) { + String attrName = attr.getAttributeName(); + if (attrs.get(attrName) == attr) { + attrs.remove(attrName); + if (source.isLive()) { + ((ShaderAttributeRetained)attr.retained).clearLive(refCount); + ((ShaderAttributeRetained)attr.retained).removeMirrorUsers(this); + + sendMessage(ATTRIBUTE_SET_REMOVE, attrName); + } + } + } + } + + /** + * Removes all shader attributes from the attributes set. The + * attributes set will be empty following this call. + * + */ + void clear() { + synchronized(liveStateLock) { + attrs.clear(); + if(source.isLive()) { + ShaderAttributeRetained[] sAttrs = new ShaderAttributeRetained[attrs.size()]; + sAttrs = (ShaderAttributeRetained[])attrs.values().toArray(sAttrs); + for (int i = 0; i < sAttrs.length; i++) { + sAttrs[i].clearLive(refCount); + sAttrs[i].removeMirrorUsers(this); + } + sendMessage(ATTRIBUTE_SET_CLEAR, null); + } + } + } + + /** + * Returns a shallow copy of the attributes set. + * + * @return a shallow copy of the attributes set + * + */ + ShaderAttribute[] getAll() { + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + ShaderAttribute[] sAttrs = new ShaderAttribute[sAttrsRetained.length]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrs[i] = (ShaderAttribute) sAttrsRetained[i].source; + } + + return sAttrs; + } + + /** + * Returns the number of elements in the attributes set. + * + * @return the number of elements in the attributes set + * + */ + int size() { + return attrs.size(); + } + + + void updateNative(Canvas3D cv, ShaderProgramRetained shaderProgram) { + shaderProgram.setShaderAttributes(cv, this); + } + + Map getAttrs() { + return attrs; + } + + + void setLive(boolean backgroundGroup, int refCount) { + + // System.out.println("ShaderAttributeSetRetained.setLive()"); + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].setLive(backgroundGroup, refCount); + } + + super.doSetLive(backgroundGroup, refCount); + super.markAsLive(); + } + + synchronized void addAMirrorUser(Shape3DRetained shape) { + + super.addAMirrorUser(shape); + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].addAMirrorUser(shape); + } + } + + synchronized void removeAMirrorUser(Shape3DRetained shape) { + super.removeAMirrorUser(shape); + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].removeAMirrorUser(shape); + } + } + + + synchronized void removeMirrorUsers(NodeComponentRetained node) { + super.removeMirrorUsers(node); + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].removeMirrorUsers(node); + } + } + + synchronized void copyMirrorUsers(NodeComponentRetained node) { + super.copyMirrorUsers(node); + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].copyMirrorUsers(node); + } + } + + void clearLive(int refCount) { + // System.out.println("ShaderAttributeSetRetained.clearLive()"); + + super.clearLive(refCount); + + ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; + sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + for(int i=0; i < sAttrsRetained.length; i++) { + sAttrsRetained[i].clearLive(refCount); + } + } + + synchronized void createMirrorObject() { + // System.out.println("ShaderAttributeSetRetained : createMirrorObject"); + // This method should only call by setLive(). + if (mirror == null) { + ShaderAttributeSetRetained mirrorSAS = new ShaderAttributeSetRetained(); + mirror = mirrorSAS; + mirror.source = source; + + } + initMirrorObject(); + } + + void initMirrorObject() { + + ShaderAttributeRetained[] sAttrs = new ShaderAttributeRetained[attrs.size()]; + sAttrs = (ShaderAttributeRetained[])attrs.values().toArray(sAttrs); + // Need to copy the mirror attrs + for (int i = 0; i < sAttrs.length; i++) { + ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained) sAttrs[i].mirror; + assert(mirrorSA != null); + ((ShaderAttributeSetRetained)mirror).attrs.put(mirrorSA.attrName, mirrorSA); + } + } + + /** + * Update the "component" field of the mirror object with the given "value" + */ + synchronized void updateMirrorObject(int component, Object value) { + + // System.out.println("ShaderAttributeSetRetained : updateMirrorObject"); + + ShaderAttributeSetRetained mirrorSAS = (ShaderAttributeSetRetained)mirror; + + if ((component & ATTRIBUTE_SET_PUT) != 0) { + // System.out.println(" -- ATTRIBUTE_SET_PUT"); + ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained)value; + assert(mirrorSA != null); + ((ShaderAttributeSetRetained)mirror).attrs.put(mirrorSA.attrName, mirrorSA); + } + else if((component & ATTRIBUTE_SET_REMOVE) != 0) { + // System.out.println(" -- ATTRIBUTE_SET_REMOVE"); + ((ShaderAttributeSetRetained)mirror).attrs.remove((String)value); + } + else if((component & ATTRIBUTE_SET_CLEAR) != 0) { + // System.out.println(" -- ATTRIBUTE_SET_CLEAR"); + ((ShaderAttributeSetRetained)mirror).attrs.clear(); + } + else { + assert(false); + } + } + + final void sendMessage(int attrMask, Object attr) { + + ArrayList univList = new ArrayList(); + ArrayList gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList); + + // Send to rendering attribute structure, regardless of + // whether there are users or not (alternate appearance case ..) + J3dMessage createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES; + createMessage.type = J3dMessage.SHADER_ATTRIBUTE_SET_CHANGED; + createMessage.universe = null; + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + // System.out.println("changedFreqent1 = "+changedFrequent); + createMessage.args[3] = new Integer(changedFrequent); + VirtualUniverse.mc.processMessage(createMessage); + + // System.out.println("univList.size is " + univList.size()); + for(int i=0; i<univList.size(); i++) { + createMessage = VirtualUniverse.mc.getMessage(); + createMessage.threads = J3dThread.UPDATE_RENDER; + createMessage.type = J3dMessage.SHADER_ATTRIBUTE_SET_CHANGED; + + createMessage.universe = (VirtualUniverse) univList.get(i); + createMessage.args[0] = this; + createMessage.args[1]= new Integer(attrMask); + createMessage.args[2] = attr; + + ArrayList gL = (ArrayList)gaList.get(i); + GeometryAtom[] gaArr = new GeometryAtom[gL.size()]; + gL.toArray(gaArr); + createMessage.args[3] = gaArr; + + VirtualUniverse.mc.processMessage(createMessage); + } + + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeValue.java b/src/classes/share/javax/media/j3d/ShaderAttributeValue.java new file mode 100644 index 0000000..1f9dc0a --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeValue.java @@ -0,0 +1,100 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeValue object encapsulates a uniform shader + * attribute whose value is specified explicitly. The shader variable + * <code>attrName</code> is explicitly set to the specified + * <code>value</code> during rendering. <code>attrName</code> must be + * the name of a valid uniform attribute in the shader in which it is + * used. Otherwise, the attribute name will be ignored and a runtime + * error may be generated. The <code>value</code> must be an instance + * of one of the allowed classes. The allowed classes are: + * <code>Integer</code>, <code>Float</code>, + * <code>Tuple{2,3,4}{i,f}</code>, <code>Matrix{3,4}f</code>. A + * ClassCastException will be thrown if a specified <code>value</code> + * object is not one of the allowed types. Further, the type of the + * value is immutable once a ShaderAttributeValue is constructed. + * Subsequent setValue operations must be called with an object of the + * same type as the one that was used to construct the + * ShaderAttributeValue. Finally, the type of the <code>value</code> + * object must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + * + * @see ShaderAttributeSet + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public class ShaderAttributeValue extends ShaderAttributeObject { + /** + * Constructs a new ShaderAttributeValue object with the specified + * <code>(attrName, value)</code> pair. + * A copy of the object is stored. + * + * @param attrName the name of the shader attribute + * @param value the value of the shader attribute + * + * @exception NullPointerException if attrName or value is null + * + * @exception ClassCastException if value is not an instance of + * one of the allowed classes + */ + public ShaderAttributeValue(String attrName, Object value) { + super(attrName, value); + } + + // Implement abstract getValue method + public Object getValue() { + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_READ)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject0")); + + return ((ShaderAttributeValueRetained)this.retained).getValue(); + } + + // Implement abstract setValue method + public void setValue(Object value) { + + if (value == null) { + throw new NullPointerException(); + } + + if (isLiveOrCompiled()) + if (!this.getCapability(ALLOW_VALUE_WRITE)) + throw new CapabilityNotSetException(J3dI18N.getString("ShaderAttributeObject1")); + + if (isLive()) + ((ShaderAttributeValueRetained)this.retained).setValue(value); + else + ((ShaderAttributeValueRetained)this.retained).initValue(value); + + } + + /** + * Creates a retained mode ShaderAttributeValueRetained object that this + * ShaderAttributeValue component object will point to. + */ + void createRetained() { + this.retained = new ShaderAttributeValueRetained(); + this.retained.setSource(this); + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeValueRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeValueRetained.java new file mode 100644 index 0000000..758672c --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderAttributeValueRetained.java @@ -0,0 +1,499 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; + +/** + * The ShaderAttributeValueRetained object encapsulates a uniform shader + * attribute whose value is specified explicitly. The shader variable + * <code>attrName</code> is explicitly set to the specified + * <code>value</code> during rendering. <code>attrName</code> must be + * the name of a valid uniform attribute in the shader in which it is + * used. Otherwise, the attribute name will be ignored and a runtime + * error may be generated. The <code>value</code> must be an instance + * of one of the allowed classes. The allowed classes are: + * <code>Integer</code>, <code>Float</code>, + * <code>Tuple{2,3,4}{i,f}</code>, <code>Matrix{3,4}f</code>. A + * ClassCastException will be thrown if a specified <code>value</code> + * object is not one of the allowed types. Further, the type of the + * value is immutable once a ShaderAttributeValue is constructed. + * Subsequent setValue operations must be called with an object of the + * same type as the one that was used to construct the + * ShaderAttributeValue. Finally, the type of the <code>value</code> + * object must match the type of the corresponding + * <code>attrName</code> variable in the shader in which it is + * used. Otherwise, the shader will not be able to use the attribute + * and a runtime error may be generated. + * + * @see ShaderAttributeSetRetained + * @see ShaderProgramRetained + * + * @since Java 3D 1.4 + */ + +class ShaderAttributeValueRetained extends ShaderAttributeObjectRetained { + + ShaderAttributeValueRetained() { + } + + synchronized void createMirrorObject() { + // System.out.println("ShaderAttributeValueRetained : createMirrorObject"); + // This method should only call by setLive(). + if (mirror == null) { + ShaderAttributeValueRetained mirrorSAV = new ShaderAttributeValueRetained(); + mirrorSAV.createObjectData(getValue()); + mirror = mirrorSAV; + mirror.source = source; + + } + initMirrorObject(); + } + + /** + * Computes the base class from the specified object. A + * ClassCastException is thrown if the object is not an instance + * of one of the allowed classes. + */ + int computeClassType(Object value) { + Class objClass = value.getClass(); + if (objClass.isArray()) { + throw new ClassCastException(objClass + " -- array class not allowed"); + } + + for (int i = 0; i < classTable.length; i++) { + if (classTable[i].isInstance(value)) { + return i; + } + } + throw new ClassCastException(objClass + " -- unrecognized class"); + } + + /** + * Returns the base class represented by the specified class type. + */ + Class getBaseClass(int classType) { + return classTable[classType]; + } + + /** + * Creates an attribute wrapper object of the specified class + * type, and stores the specified object. + */ + AttrWrapper createAttrWrapper(Object value, int classType) { + ValueWrapper attrWrapper = null; + switch (classType) { + case TYPE_INTEGER: + attrWrapper = new IntegerWrapper(); + break; + case TYPE_FLOAT: + attrWrapper = new FloatWrapper(); + break; +// case TYPE_DOUBLE: +// attrWrapper = new DoubleWrapper(); +// break; + case TYPE_TUPLE2I: + attrWrapper = new Tuple2iWrapper(); + break; + case TYPE_TUPLE2F: + attrWrapper = new Tuple2fWrapper(); + break; +// case TYPE_TUPLE2D: +// attrWrapper = new Tuple2dWrapper(); +// break; + case TYPE_TUPLE3I: + attrWrapper = new Tuple3iWrapper(); + break; + case TYPE_TUPLE3F: + attrWrapper = new Tuple3fWrapper(); + break; +// case TYPE_TUPLE3D: +// attrWrapper = new Tuple3dWrapper(); +// break; + case TYPE_TUPLE4I: + attrWrapper = new Tuple4iWrapper(); + break; + case TYPE_TUPLE4F: + attrWrapper = new Tuple4fWrapper(); + break; +// case TYPE_TUPLE4D: +// attrWrapper = new Tuple4dWrapper(); +// break; + case TYPE_MATRIX3F: + attrWrapper = new Matrix3fWrapper(); + break; +// case TYPE_MATRIX3D: +// attrWrapper = new Matrix3dWrapper(); +// break; + case TYPE_MATRIX4F: + attrWrapper = new Matrix4fWrapper(); + break; +// case TYPE_MATRIX4D: +// attrWrapper = new Matrix4dWrapper(); +// break; + default: + // Should never get here + assert false; + return null; + } + + attrWrapper.set(value); + return attrWrapper; + } + + // + // The following wrapper classes are used to store a copy of the + // user-specified shader attribute value. There is a wrapper class + // for each supported base class. + // + + // Base wrapper class for non-array attribute types + static abstract class ValueWrapper extends AttrWrapper { + // No additional fields or methods are defined in this class + } + + // Wrapper class for Integer + static class IntegerWrapper extends ValueWrapper { + private int[] value = new int[1]; + + void set(Object value) { + this.value[0] = ((Integer)value).intValue(); + } + + Object get() { + return new Integer(this.value[0]); + } + + Object getRef() { + return this.value; + } + } + + // Wrapper class for Float + static class FloatWrapper extends ValueWrapper { + private float[] value = new float[1]; + + void set(Object value) { + this.value[0] = ((Float)value).floatValue(); + } + + Object get() { + return new Float(this.value[0]); + } + + Object getRef() { + return this.value; + } + } + + /* + // Wrapper class for Double + static class DoubleWrapper extends ValueWrapper { + private double[] value = new double[1]; + + void set(Object value) { + this.value[0] = ((Double)value).doubleValue(); + } + + Object get() { + return new Double(value[0]); + } + + Object getRef() { + return value; + } + } + */ + + // Wrapper class for Tuple2i + static class Tuple2iWrapper extends ValueWrapper { + private int[] value = new int[2]; + + void set(Object value) { + ((Tuple2i)value).get(this.value); + } + + Object get() { + return new Point2i(value); + } + + Object getRef() { + return value; + } + } + + // Wrapper class for Tuple2f + static class Tuple2fWrapper extends ValueWrapper { + private float[] value = new float[2]; + + void set(Object value) { + ((Tuple2f)value).get(this.value); + } + + Object get() { + return new Point2f(value); + } + + Object getRef() { + return value; + } + } + + /* + // Wrapper class for Tuple2d + static class Tuple2dWrapper extends ValueWrapper { + private double[] value = new double[2]; + + void set(Object value) { + ((Tuple2d)value).get(this.value); + } + + Object get() { + return new Point2d(value); + } + + Object getRef() { + return value; + } + } + */ + + // Wrapper class for Tuple3i + static class Tuple3iWrapper extends ValueWrapper { + private int[] value = new int[3]; + + void set(Object value) { + ((Tuple3i)value).get(this.value); + } + + Object get() { + return new Point3i(value); + } + + Object getRef() { + return value; + } + } + + // Wrapper class for Tuple3f + static class Tuple3fWrapper extends ValueWrapper { + private float[] value = new float[3]; + + void set(Object value) { + ((Tuple3f)value).get(this.value); + } + + Object get() { + return new Point3f(value); + } + + Object getRef() { + return value; + } + } + + /* + // Wrapper class for Tuple3d + static class Tuple3dWrapper extends ValueWrapper { + private double[] value = new double[3]; + + void set(Object value) { + ((Tuple3d)value).get(this.value); + } + + Object get() { + return new Point3d(value); + } + + Object getRef() { + return value; + } + } + */ + + // Wrapper class for Tuple4i + static class Tuple4iWrapper extends ValueWrapper { + private int[] value = new int[4]; + + void set(Object value) { + ((Tuple4i)value).get(this.value); + } + + Object get() { + return new Point4i(value); + } + + Object getRef() { + return value; + } + } + + // Wrapper class for Tuple4f + static class Tuple4fWrapper extends ValueWrapper { + private float[] value = new float[4]; + + void set(Object value) { + ((Tuple4f)value).get(this.value); + } + + Object get() { + return new Point4f(value); + } + + Object getRef() { + return value; + } + } + + /* + // Wrapper class for Tuple4d + static class Tuple4dWrapper extends ValueWrapper { + private double[] value = new double[4]; + + void set(Object value) { + ((Tuple4d)value).get(this.value); + } + + Object get() { + return new Point4d(value); + } + + Object getRef() { + return value; + } + } + */ + + // Wrapper class for Matrix3f + static class Matrix3fWrapper extends ValueWrapper { + private float[] value = new float[9]; + + void set(Object value) { + Matrix3f m = (Matrix3f)value; + this.value[0] = m.m00; + this.value[1] = m.m01; + this.value[2] = m.m02; + this.value[3] = m.m10; + this.value[4] = m.m11; + this.value[5] = m.m12; + this.value[6] = m.m20; + this.value[7] = m.m21; + this.value[8] = m.m22; + } + + Object get() { + return new Matrix3f(value); + } + + Object getRef() { + return value; + } + } + + /* + // Wrapper class for Matrix3d + static class Matrix3dWrapper extends ValueWrapper { + private double[] value = new double[9]; + + void set(Object value) { + Matrix3d m = (Matrix3d)value; + this.value[0] = m.m00; + this.value[1] = m.m01; + this.value[2] = m.m02; + this.value[3] = m.m10; + this.value[4] = m.m11; + this.value[5] = m.m12; + this.value[6] = m.m20; + this.value[7] = m.m21; + this.value[8] = m.m22; + } + + Object get() { + return new Matrix3d(value); + } + + Object getRef() { + return value; + } + } + */ + + // Wrapper class for Matrix4f + static class Matrix4fWrapper extends ValueWrapper { + private float[] value = new float[16]; + + void set(Object value) { + Matrix4f m = (Matrix4f)value; + this.value[0] = m.m00; + this.value[1] = m.m01; + this.value[2] = m.m02; + this.value[3] = m.m03; + this.value[4] = m.m10; + this.value[5] = m.m11; + this.value[6] = m.m12; + this.value[7] = m.m13; + this.value[8] = m.m20; + this.value[9] = m.m21; + this.value[10] = m.m22; + this.value[11] = m.m23; + this.value[12] = m.m30; + this.value[13] = m.m31; + this.value[14] = m.m32; + this.value[15] = m.m33; + } + + Object get() { + return new Matrix4f(value); + } + + Object getRef() { + return value; + } + } + + /* + // Wrapper class for Matrix4d + static class Matrix4dWrapper extends ValueWrapper { + private double[] value = new double[16]; + + void set(Object value) { + Matrix4d m = (Matrix4d)value; + this.value[0] = m.m00; + this.value[1] = m.m01; + this.value[2] = m.m02; + this.value[3] = m.m03; + this.value[4] = m.m10; + this.value[5] = m.m11; + this.value[6] = m.m12; + this.value[7] = m.m13; + this.value[8] = m.m20; + this.value[9] = m.m21; + this.value[10] = m.m22; + this.value[11] = m.m23; + this.value[12] = m.m30; + this.value[13] = m.m31; + this.value[14] = m.m32; + this.value[15] = m.m33; + } + + Object get() { + return new Matrix4d(value); + } + + Object getRef() { + return value; + } + } + */ + +} diff --git a/src/classes/share/javax/media/j3d/ShaderBin.java b/src/classes/share/javax/media/j3d/ShaderBin.java new file mode 100644 index 0000000..0e4ad74 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderBin.java @@ -0,0 +1,363 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import javax.vecmath.*; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; + + +// XXXX : We should have a common Bin object that all other Bins extend from. + + +//class ShaderBin extends Object implements ObjectUpdate, NodeComponentUpdate { +class ShaderBin implements ObjectUpdate { + + /** + * Node component dirty mask. + */ + static final int SHADER_PROGRAM_DIRTY = 0x1; + static final int SHADER_ATTRIBUTE_SET_DIRTY = 0x2; + + + /** + * The RenderBin for this object + */ + RenderBin renderBin = null; + + /** + * The AttributeBin that this ShaderBin resides + */ + AttributeBin attributeBin = null; + + /** + * The references to the next and previous ShaderBins in the + * list. + */ + ShaderBin next = null; + ShaderBin prev = null; + + /** + * The list of TextureBins in this ShaderBin + */ + TextureBin textureBinList = null; + + /** + * The list of TextureBins to be added for the next frame + */ + ArrayList addTextureBins = new ArrayList(); + + boolean onUpdateList = false; + + int numEditingTextureBins = 0; + + int componentDirty = 0; + ShaderAppearanceRetained shaderAppearance = null; + ShaderProgramRetained shaderProgram = null; + ShaderAttributeSetRetained shaderAttributeSet = new ShaderAttributeSetRetained(); + + ShaderBin(ShaderAppearanceRetained sApp, RenderBin rBin) { + reset(sApp, rBin); + } + + void reset(ShaderAppearanceRetained sApp, RenderBin rBin) { + prev = null; + next = null; + renderBin = rBin; + attributeBin = null; + textureBinList = null; + onUpdateList = false; + numEditingTextureBins = 0; + addTextureBins.clear(); + if(sApp != null) { + shaderProgram = sApp.shaderProgram; + shaderAttributeSet = sApp.shaderAttributeSet; + } + else { + shaderProgram = null; + shaderAttributeSet = null; + } + shaderAppearance = sApp; + } + + void clear() { + reset(null, null); + } + + /** + * This tests if the qiven ra.shaderProgram match this shaderProgram + */ + boolean equals(ShaderAppearanceRetained sApp) { + + ShaderProgramRetained sp; + ShaderAttributeSetRetained ss; + + if (sApp == null) { + sp = null; + ss = null; + } else { + sp = sApp.shaderProgram; + ss = sApp.shaderAttributeSet; + } + + if((shaderProgram != sp) || (shaderAttributeSet != ss)) { + return false; + } + + return true; + + } + + public void updateObject() { + TextureBin t; + int i; + + if (addTextureBins.size() > 0) { + t = (TextureBin)addTextureBins.get(0); + if (textureBinList == null) { + textureBinList = t; + + } + else { + // Look for a TextureBin that has the same texture + insertTextureBin(t); + } + for (i = 1; i < addTextureBins.size() ; i++) { + t = (TextureBin)addTextureBins.get(i); + // Look for a TextureBin that has the same texture + insertTextureBin(t); + + } + } + addTextureBins.clear(); + onUpdateList = false; + + } + + void insertTextureBin(TextureBin t) { + TextureBin tb; + int i; + TextureRetained texture = null; + + if (t.texUnitState != null && t.texUnitState.length > 0) { + if (t.texUnitState[0] != null) { + texture = t.texUnitState[0].texture; + } + } + + // use the texture in the first texture unit as the sorting criteria + if (texture != null) { + tb = textureBinList; + while (tb != null) { + if (tb.texUnitState == null || tb.texUnitState[0] == null || + tb.texUnitState[0].texture != texture) { + tb = tb.next; + } else { + // put it here + t.next = tb; + t.prev = tb.prev; + if (tb.prev == null) { + textureBinList = t; + } + else { + tb.prev.next = t; + } + tb.prev = t; + return; + } + } + } + // Just put it up front + t.prev = null; + t.next = textureBinList; + textureBinList.prev = t; + textureBinList = t; + + t.tbFlag &= ~TextureBin.RESORT; + } + + + /** + * reInsert textureBin if the first texture is different from + * the previous bin and different from the next bin + */ + void reInsertTextureBin(TextureBin tb) { + + TextureRetained texture = null, + prevTexture = null, + nextTexture = null; + + if (tb.texUnitState != null && tb.texUnitState[0] != null) { + texture = tb.texUnitState[0].texture; + } + + if (tb.prev != null && tb.prev.texUnitState != null) { + prevTexture = tb.prev.texUnitState[0].texture; + } + + if (texture != prevTexture) { + if (tb.next != null && tb.next.texUnitState != null) { + nextTexture = tb.next.texUnitState[0].texture; + } + if (texture != nextTexture) { + if (tb.prev != null && tb.next != null) { + tb.prev.next = tb.next; + tb.next.prev = tb.prev; + insertTextureBin(tb); + } + } + } + } + + + + /** + * Adds the given TextureBin to this AttributeBin. + */ + void addTextureBin(TextureBin t, RenderBin rb, RenderAtom ra) { + + t.environmentSet = this.attributeBin.environmentSet; + t.attributeBin = this.attributeBin; + t.shaderBin = this; + + attributeBin.updateFromShaderBin(ra); + addTextureBins.add(t); + + if (!onUpdateList) { + rb.objUpdateList.add(this); + onUpdateList = true; + } + } + + /** + * Removes the given TextureBin from this ShaderBin. + */ + void removeTextureBin(TextureBin t) { + + // If the TextureBin being remove is contained in addTextureBins, + // then remove the TextureBin from the addList + if (addTextureBins.contains(t)) { + addTextureBins.remove(addTextureBins.indexOf(t)); + } + else { + if (t.prev == null) { // At the head of the list + textureBinList = t.next; + if (t.next != null) { + t.next.prev = null; + } + } else { // In the middle or at the end. + t.prev.next = t.next; + if (t.next != null) { + t.next.prev = t.prev; + } + } + } + + t.shaderBin = null; + t.prev = null; + t.next = null; + + t.clear(); + + renderBin.textureBinFreelist.add(t); + + if (textureBinList == null && addTextureBins.size() == 0 ) { + // Note: Removal of this shaderBin as a user of the rendering + // atttrs is done during removeRenderAtom() in RenderMolecule.java + attributeBin.removeShaderBin(this); + } + } + + /** + * Renders this ShaderBin + */ + void render(Canvas3D cv) { + + TextureBin tb; + + // System.out.println("ShaderBin.render() shaderProgram = " + shaderProgram); + + // include this ShaderBin to the to-be-updated list in canvas + cv.setStateToUpdate(Canvas3D.SHADERBIN_BIT, this); + + tb = textureBinList; + while (tb != null) { + tb.render(cv); + tb = tb.next; + } + } + + void updateTransparentAttributes(Canvas3D cv) { + + // include this ShaderBin to the to-be-updated state set in canvas + cv.setStateToUpdate(Canvas3D.SHADERBIN_BIT, this); + } + + void updateAttributes(Canvas3D cv) { + + // System.out.println("ShaderBin.updateAttributes() shaderProgram is " + shaderProgram); + if (shaderProgram != null) { + // Compile, link, and enable shader program + shaderProgram.updateNative(cv, true); + + if (shaderAttributeSet != null) { + shaderAttributeSet.updateNative(cv, shaderProgram); + } + + } + else { + if (cv.shaderProgram != null) { + // Disable shader program + cv.shaderProgram.updateNative(cv, false); + } + } + + cv.shaderBin = this; + cv.shaderProgram = shaderProgram; + } + + void updateNodeComponent() { + // System.out.println("ShaderBin.updateNodeComponent() ..."); + + // We don't need to clone shaderProgram. + // ShaderProgram object can't be modified once it is live, + // so each update should be a new reference. + if ((componentDirty & SHADER_PROGRAM_DIRTY) != 0) { + // System.out.println(" - SHADER_PROGRAM_DIRTY"); + + shaderProgram = shaderAppearance.shaderProgram; + } + + // We need to clone the shaderAttributeSet. + if ((componentDirty & SHADER_ATTRIBUTE_SET_DIRTY) != 0) { + // System.out.println(" - SHADER_ATTRIBUTE_SET_DIRTY"); + + HashMap attrs = (HashMap)shaderAttributeSet.getAttrs(); + attrs.clear(); + if(shaderAppearance.shaderAttributeSet != null) { + attrs.putAll(shaderAppearance.shaderAttributeSet.getAttrs()); + } + } + + componentDirty = 0; + } + + void incrActiveTextureBin() { + numEditingTextureBins++; + } + + void decrActiveTextureBin() { + numEditingTextureBins--; + } +} diff --git a/src/classes/share/javax/media/j3d/ShaderError.java b/src/classes/share/javax/media/j3d/ShaderError.java new file mode 100644 index 0000000..52c60f7 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderError.java @@ -0,0 +1,410 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.io.PrintStream; + +/** + * ShaderError is a container object that holds the details of + * a runtime error that occurs while compiling or executing a + * programmable shader. + * + * @since Java 3D 1.4 + */ +public class ShaderError extends Object { + private int errorCode = NO_ERROR; + private String errorMessage = null; + private String detailMessage = null; + private Canvas3D canvas = null; + private Shape3D shape = null; + private Geometry geometry = null; + private ShaderAppearance shaderApp = null; + private ShaderProgram shaderProgram = null; + private Shader shader = null; + private ShaderAttributeSet shaderAttributeSet = null; + private ShaderAttribute shaderAttribute = null; + + /** + * Indicates that no error occurred. + */ + public static final int NO_ERROR = 0; + + /** + * Indicates that an error occurred while compiling a shader. + */ + public static final int COMPILE_ERROR = 1; + + /** + * Indicates that an error occurred while linking a shader. + */ + public static final int LINK_ERROR = 2; + + /** + * Indicates a error in looking up a vertex attribute + * name within a given shader program. + */ + public static final int VERTEX_ATTRIBUTE_LOOKUP_ERROR = 3; + + /** + * Indicates a error in looking up the location of a uniform + * shader attribute name within a given shader program. + */ + public static final int SHADER_ATTRIBUTE_LOOKUP_ERROR = 4; + + /** + * Indicates a error caused by a ShaderAttribute whose name does not + * appear in the list of shader attribute names in the corresponding + * ShaderProgram object. + */ + public static final int SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR = 5; + + /** + * Indicates a error in the type of the attribute versus what the shader + * program was expecting. + */ + public static final int SHADER_ATTRIBUTE_TYPE_ERROR = 6; + + /** + * Indicates that the specified shading language is not supported + * on the screen display device. + */ + public static final int UNSUPPORTED_LANGUAGE_ERROR = 7; + + + /** + * Constructs a new ShaderError object indicating no error. The + * error code is set to <code>NO_ERROR</code>. All other fields + * are initialized to null, including the error message. + */ + public ShaderError() { + } + + /** + * Constructs a new ShaderError object with the given error code + * and message. All other fields are initialized to null. + * + * @param errorCode the error code for this shader error. + * + * @param errorMessage a short error message describing this + * shader error. + */ + public ShaderError(int errorCode, String errorMessage) { + this.errorCode = errorCode; + this.errorMessage = errorMessage; + } + + /** + * Prints a verbose error report to System.err. This verbose + * output includes the error code, error message, detail message, + * and all relevant Java 3D objects. + */ + public void printVerbose() { + printVerbose(System.err); + } + + /** + * Prints a verbose error report to the specified PrintStream. + * This verbose output includes the error code, error message, + * detail message, and all relevant Java 3D objects. + * + * @param printStream the print stream on which to print the error + * report. + */ + public void printVerbose(PrintStream printStream) { + printStream.println(this); + if (canvas != null) { + printStream.println("canvas = " + canvas); + } + if (shape != null) { + printStream.println("shape = " + shape); + } + if (geometry != null) { + printStream.println("geometry = " + geometry); + } + if (shaderApp != null) { + printStream.println("shaderApp = " + shaderApp); + } + if (shaderProgram != null) { + printStream.println("shaderProgram = " + shaderProgram); + } + if (shader != null) { + printStream.println("shader = " + shader); + } + if (shaderAttributeSet != null) { + printStream.println("shaderAttributeSet = " + shaderAttributeSet); + } + if (shaderAttribute != null) { + printStream.println("shaderAttribute = " + shaderAttribute); + } + + if (detailMessage != null) { + printStream.println(); + printStream.println("Detail Message"); + printStream.println("--------------"); + printStream.println(detailMessage); + } + } + + /** + * Sets the error code for this shader error. This represents the + * type of error that occurred. + * + * @param errorCode the error code for this shader error. + */ + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + /** + * Returns the error code for this shader error. + * + * @return the error code. + */ + public int getErrorCode() { + return errorCode; + } + + /** + * Sets the error message for this shader error. This is a short + * message describing the error, and is included as part of + * toString(). + * + * @param errorMessage a short error message describing this + * shader error. + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Returns the error message for this shader error. + * + * @return a short error message describing this shader error. + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the detail message for this shader error. This is a + * detailed error message, typically produced by the shader + * compiler, and is not included as part of toString(). + * + * @param detailMessage a detailed message describing this shader + * error in more detail. + */ + public void setDetailMessage(String detailMessage) { + this.detailMessage = detailMessage; + } + + /** + * Returns the detail message for this shader error. + * + * @return the detail message for this shader error. + */ + public String getDetailMessage() { + return detailMessage; + } + + /** + * Sets the canvas associated with this shader error. + * + * @param canvas the canvas associated with this shader error. + */ + public void setCanvas3D(Canvas3D canvas) { + this.canvas = canvas; + } + + /** + * Returns the canvas associated with this shader error. + * + * @return the canvas associated with this shader error. + */ + public Canvas3D getCanvas3D() { + return this.canvas; + } + + /** + * Sets the shape node associated with this shader error. + * + * @param shape the shape node associated with this shader error. + */ + public void setShape3D(Shape3D shape) { + this.shape = shape; + } + + /** + * Returns the shape node associated with this shader error. + * + * @return the shape node associated with this shader error. + */ + public Shape3D getShape3D() { + return this.shape; + } + + /** + * Sets the geometry associated with this shader error. + * + * @param geometry the geometry associated with this shader error. + */ + public void setGeometry(Geometry geometry) { + this.geometry = geometry; + } + + /** + * Returns the geometry associated with this shader error. + * + * @return the geometry associated with this shader error. + */ + public Geometry getGeometry() { + return this.geometry; + } + + /** + * Sets the shader appearance associated with this shader error. + * + * @param shaderApp the shader appearance associated with this shader error. + */ + public void setShaderAppearance(ShaderAppearance shaderApp) { + this.shaderApp = shaderApp; + } + + /** + * Returns the shader appearance associated with this shader error. + * + * @return the shader appearance associated with this shader error. + */ + public ShaderAppearance getShaderAppearance() { + return this.shaderApp; + } + + /** + * Sets the shader program associated with this shader error. + * + * @param shaderProgram the shader program associated with this shader error. + */ + public void setShaderProgram(ShaderProgram shaderProgram) { + this.shaderProgram = shaderProgram; + } + + /** + * Returns the shader program associated with this shader error. + * + * @return the shader program associated with this shader error. + */ + public ShaderProgram getShaderProgram() { + return this.shaderProgram; + } + + /** + * Sets the shader object associated with this shader error. + * + * @param shader the shader object associated with this shader error. + */ + public void setShader(Shader shader) { + this.shader = shader; + } + + /** + * Returns the shader object associated with this shader error. + * + * @return the shader object associated with this shader error. + */ + public Shader getShader() { + return this.shader; + } + + /** + * Sets the shader attribute set associated with this shader error. + * + * @param shaderAttributeSet the shader attribute set associated with this shader error. + */ + public void setShaderAttributeSet(ShaderAttributeSet shaderAttributeSet) { + this.shaderAttributeSet = shaderAttributeSet; + } + + /** + * Returns the shader attribute set associated with this shader error. + * + * @return the shader attribute set associated with this shader error. + */ + public ShaderAttributeSet getShaderAttributeSet() { + return this.shaderAttributeSet; + } + + /** + * Sets the shader attribute associated with this shader error. + * + * @param shaderAttribute the shader attribute associated with this shader error. + */ + public void setShaderAttribute(ShaderAttribute shaderAttribute) { + this.shaderAttribute = shaderAttribute; + } + + /** + * Returns the shader attribute associated with this shader error. + * + * @return the shader attribute associated with this shader error. + */ + public ShaderAttribute getShaderAttribute() { + return this.shaderAttribute; + } + + + /** + * Returns a short string that describes this shader error. The + * string is composed of the textual description of the errorCode, + * a ": ", and the errorMessage field. If the errorMessage is + * null then the ": " and the errorMessage are omitted. + * + * @return a string representation of this shader error. + */ + public String toString() { + // Concatenate string representation of error code with error message + String errorCodeStr; + switch (errorCode) { + case NO_ERROR: + errorCodeStr = "NO_ERROR"; + break; + case COMPILE_ERROR: + errorCodeStr = "COMPILE_ERROR"; + break; + case LINK_ERROR: + errorCodeStr = "LINK_ERROR"; + break; + case VERTEX_ATTRIBUTE_LOOKUP_ERROR: + errorCodeStr = "VERTEX_ATTRIBUTE_LOOKUP_ERROR"; + break; + case SHADER_ATTRIBUTE_LOOKUP_ERROR: + errorCodeStr = "SHADER_ATTRIBUTE_LOOKUP_ERROR"; + break; + case SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR: + errorCodeStr = "SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR"; + break; + case SHADER_ATTRIBUTE_TYPE_ERROR: + errorCodeStr = "SHADER_ATTRIBUTE_TYPE_ERROR"; + break; + case UNSUPPORTED_LANGUAGE_ERROR: + errorCodeStr = "UNSUPPORTED_LANGUAGE_ERROR"; + break; + default: + errorCodeStr = "UNKNOWN ERROR CODE (" + errorCode + ")"; + } + + if (errorMessage == null) { + return errorCodeStr; + } + + return errorCodeStr + ": " + errorMessage; + } +} diff --git a/src/classes/share/javax/media/j3d/ShaderErrorListener.java b/src/classes/share/javax/media/j3d/ShaderErrorListener.java new file mode 100644 index 0000000..978a251 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderErrorListener.java @@ -0,0 +1,33 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * Listener interface for monitoring errors in Shader Programs. + * Compile and link errors are reported by the shader compiler, as are + * runtime errors, such as those resulting from shader attributes that + * aren't found or are of the wrong type. + * + * @see VirtualUniverse#addShaderErrorListener + * + * @since Java 3D 1.4 + */ +public interface ShaderErrorListener { + /** + * Invoked when an error occurs while compiling, linking or + * executing a programmable shader. + * + * @param error object that contains the details of the error. + */ + public void errorOccurred(ShaderError error); +} diff --git a/src/classes/share/javax/media/j3d/ShaderProgram.java b/src/classes/share/javax/media/j3d/ShaderProgram.java new file mode 100644 index 0000000..2d4fc72 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderProgram.java @@ -0,0 +1,194 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The ShaderProgram node component object is the abstract base class + * for programmable shader programs. Each concrete instance of a + * ShaderProgram is a container for a set of Shader objects. The set + * of Shaders contained in the ShaderProgram is a complete program for + * the Graphics Pipeline Unit (GPU) of the graphics accelerator. It is + * specified using the shader language defined by the + * ShaderProgram. The currently defined shader languages are: Cg and + * GLSL. + * + * <p> + * NOTE: Applications should <i>not</i> extend this class. + * + * @see Shader + * @see ShaderAppearance#setShaderProgram + * + * @since Java 3D 1.4 + */ + +public abstract class ShaderProgram extends NodeComponent { + + /** + * Specifies that this ShaderProgram object allows reading + * its shaders. + */ + public static final int ALLOW_SHADERS_READ = + CapabilityBits.SHADER_PROGRAM_ALLOW_SHADERS_READ; + + /** + * Specifies that this ShaderProgram object allows reading + * its shader or vertex attribute names. + */ + public static final int ALLOW_NAMES_READ = + CapabilityBits.SHADER_PROGRAM_ALLOW_NAMES_READ; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SHADERS_READ, + ALLOW_NAMES_READ + }; + + /* + * Default values (copied from GeometryArray.java): + * + * vertexAttrNames : null<br> + */ + + /** + * Package scope constructor so it can't be subclassed by classes + * outside the javax.media.j3d package. + */ + ShaderProgram() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } + + /** + * Sets the vertex attribute names array for this ShaderProgram + * object. Each element in the array specifies the shader + * attribute name that is bound to the corresponding numbered + * vertex attribute within a GeometryArray object that uses this + * shader program. Array element 0 specifies the name of + * GeometryArray vertex attribute 0, array element 1 specifies the + * name of GeometryArray vertex attribute 1, and so forth. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * @param vertexAttrNames array of vertex attribute names for this + * shader program. A copy of this array is made. + * + * @exception RestrictedAccessException if the method is called + * when this object is part of live or compiled scene graph. + * + * @exception NullPointerException if any element in the + * vertexAttrNames array is null. + */ + public abstract void setVertexAttrNames(String[] vertexAttrNames); + + /** + * Retrieves the vertex attribute names array from this + * ShaderProgram object. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @return a copy of this ShaderProgram's array of vertex attribute names. + */ + public abstract String[] getVertexAttrNames(); + + + /** + * Sets the shader attribute names array for this ShaderProgram + * object. Each element in the array specifies a shader + * attribute name that may be set via a ShaderAttribute object. + * Only those attributes whose names that appear in the shader + * attribute names array can be set for a given shader program. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * <p> + * TODO: finish this. + * + * @param shaderAttrNames array of shader attribute names for this + * shader program. A copy of this array is made. + * + * @exception RestrictedAccessException if the method is called + * when this object is part of live or compiled scene graph. + * + * @exception NullPointerException if any element in the + * shaderAttrNames array is null. + */ + public abstract void setShaderAttrNames(String[] shaderAttrNames); + + /** + * Retrieves the shader attribute names array from this + * ShaderProgram object. + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @return a copy of this ShaderProgram's array of shader attribute names. + */ + public abstract String[] getShaderAttrNames(); + + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading + * language of each shader in the array must match the + * subclass. Subclasses may impose additional restrictions. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception RestrictedAccessException if the method is called + * when this object is part of live or compiled scene graph. + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array doesn't match the type of the + * subclass. + * + * @exception NullPointerException if any element in the + * shaders array is null. + */ + public abstract void setShaders(Shader[] shaders); + + /** + * Retrieves the array of shaders from this shader program. A + * shallow copy of the array is returned. The return value may + * be null. + * + * @return a copy of this ShaderProgram's array of Shader objects + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + */ + public abstract Shader[] getShaders(); + + + // Default shader error listener class + private static ShaderErrorListener defaultErrorListener = null; + + synchronized static ShaderErrorListener getDefaultErrorListener() { + if (defaultErrorListener == null) { + defaultErrorListener = new DefaultErrorListener(); + } + + return defaultErrorListener; + } + + static class DefaultErrorListener implements ShaderErrorListener { + public void errorOccurred(ShaderError error) { + System.err.println(); + System.err.println("DefaultShaderErrorListener.errorOccurred:"); + error.printVerbose(); + } + } +} diff --git a/src/classes/share/javax/media/j3d/ShaderProgramRetained.java b/src/classes/share/javax/media/j3d/ShaderProgramRetained.java new file mode 100644 index 0000000..fadcda0 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderProgramRetained.java @@ -0,0 +1,1196 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.*; +import javax.vecmath.*; + +/** + * The ShaderProgramRetained object is a component object of an AppearanceRetained + * object that defines the shader properties used when programmable shader is + * enabled. ShaderProgramRetained object is an abstract class. All shader program + * objects must be created as either a GLSLShaderProgramRetained object or a + * CgShaderProgramRetained object. + */ +abstract class ShaderProgramRetained extends NodeComponentRetained { + + // Each element in the array corresponds to a unique renderer if shared + // context or a unique canvas otherwise. + protected ShaderProgramData shaderProgramData[]; + + // Flag indicating whether an UNSUPPORTED_LANGUAGE_ERROR has + // already been reported for this shader program object. It is + // set in verifyShaderProgram and cleared in setLive or clearLive. + // TODO KCR: Add code to clear this in setLive or clearLive + private boolean unsupportedErrorReported = false; + + // Flag indicating whether a LINK_ERROR has occurred for this shader program + // object. It is set in updateNative to indicate that the linkShaderProgram + // operation failed. It is cleared in setLive or clearLive. + // TODO KCR: Add code to clear this in setLive or clearLive + private boolean linkErrorOccurred = false; + + // an array of shaders used by this shader program + protected ShaderRetained[] shaders; + + // an array of vertex attribute names + protected String[] vertexAttrNames; + + // an array of (uniform) shader attribute names + protected String[] shaderAttrNames; + + // Set of ShaderAttribute objects for which we have already reported an error + private HashSet shaderAttrErrorSet = null; + + // need to synchronize access from multiple rendering threads + Object resourceLock = new Object(); + + /** + * Sets the vertex attribute names array for this ShaderProgram + * object. Each element in the array specifies the shader + * attribute name that is bound to the corresponding numbered + * vertex attribute within a GeometryArray object that uses this + * shader program. Array element 0 specifies the name of + * GeometryArray vertex attribute 0, array element 1 specifies the + * name of GeometryArray vertex attribute 1, and so forth. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * @param vertexAttrNames array of vertex attribute names for this + * shader program. A copy of this array is made. + */ + void setVertexAttrNames(String[] vertexAttrNames) { + if (vertexAttrNames == null) { + this.vertexAttrNames = null; + } + else { + this.vertexAttrNames = (String[])vertexAttrNames.clone(); + } + } + + + /** + * Retrieves the vertex attribute names array from this + * ShaderProgram object. + * + * @return a copy of this ShaderProgram's array of vertex attribute names. + */ + String[] getVertexAttrNames() { + + if (vertexAttrNames == null) { + return null; + } + + return (String[])vertexAttrNames.clone(); + + } + + + /** + * Sets the shader attribute names array for this ShaderProgram + * object. Each element in the array specifies a shader + * attribute name that may be set via a ShaderAttribute object. + * Only those attributes whose names that appear in the shader + * attribute names array can be set for a given shader program. + * The array of names may be null or empty (0 length), but the + * elements of the array must be non-null. + * + * @param shaderAttrNames array of shader attribute names for this + * shader program. A copy of this array is made. + */ + void setShaderAttrNames(String[] shaderAttrNames) { + if (shaderAttrNames == null) { + this.shaderAttrNames = null; + } + else { + this.shaderAttrNames = (String[])shaderAttrNames.clone(); + } + } + + + /** + * Retrieves the shader attribute names array from this + * ShaderProgram object. + * + * @return a copy of this ShaderProgram's array of shader attribute names. + */ + + String[] getShaderAttrNames() { + + if (shaderAttrNames == null) { + return null; + } + + return (String[])shaderAttrNames.clone(); + + } + + + + /** + * Copies the specified array of shaders into this shader + * program. This method makes a shallow copy of the array. The + * array of shaders may be null or empty (0 length), but the + * elements of the array must be non-null. The shading + * language of each shader in the array must match the + * subclass. Subclasses may impose additional restrictions. + * + * @param shaders array of Shader objects to be copied into this + * ShaderProgram + * + * @exception CapabilityNotSetException if appropriate capability is + * not set and this object is part of live or compiled scene graph + * + * @exception IllegalArgumentException if the shading language of + * any shader in the shaders array doesn't match the type of the + * subclass. + */ + void setShaders(Shader[] shaders) { + + if (shaders == null) { + this.shaders = null; + return; + } + + this.shaders = new ShaderRetained[shaders.length]; + + // Copy vertex and fragment shader + for (int i = 0; i < shaders.length; i++) { + this.shaders[i] = (ShaderRetained)shaders[i].retained; + } + + } + + /** + * Retrieves the array of shaders from this shader program. A + * shallow copy of the array is returned. The return value may + * be null. + * + * @return a copy of this ShaderProgram's array of Shader objects + * + */ + Shader[] getShaders() { + + if (shaders == null) { + return null; + } else { + Shader shads[] = + new Shader[shaders.length]; + for (int i = 0; i < shaders.length; i++) { + if (shaders[i] != null) { + shads[i] = (Shader) shaders[i].source; + } else { + shads[i] = null; + } + } + return shads; + } + } + + /** + * Method to create the native shader. + */ + abstract ShaderError createShader(long ctx, ShaderRetained shader, long[] shaderIdArr); + + /** + * Method to destroy the native shader. + */ + abstract ShaderError destroyShader(long ctx, long shaderId); + + /** + * Method to compile the native shader. + */ + abstract ShaderError compileShader(long ctx, long shaderId, String source); + + /** + * Method to create the native shader program. + */ + abstract ShaderError createShaderProgram(long ctx, long[] shaderProgramIdArr); + + /** + * Method to destroy the native shader program. + */ + abstract ShaderError destroyShaderProgram(long ctx, long shaderProgramId); + + /** + * Method to link the native shader program. + */ + abstract ShaderError linkShaderProgram(long ctx, long shaderProgramId, long[] shaderIds); + + /** + * Method to bind a vertex attribute name to the specified index. + */ + abstract ShaderError bindVertexAttrName(long ctx, long shaderProgramId, String attrName, int attrIndex); + + /** + * Method to lookup a list of (uniform) shader attribute names and return + * information about the attributes. + */ + abstract void lookupShaderAttrNames(long ctx, long shaderProgramId, String[] attrNames, AttrNameInfo[] attrNameInfoArr); + + /* + * Method to lookup a list of vertex attribute names. + */ + abstract void lookupVertexAttrNames(long ctx, long shaderProgramId, String[] attrNames, boolean[] errArr); + + /** + * Method to use the native shader program. + */ + abstract ShaderError enableShaderProgram(long ctx, long shaderProgramId); + + /** + * Method to disable the native shader program. + */ + abstract ShaderError disableShaderProgram(long ctx); + + // ShaderAttributeValue methods + + abstract ShaderError setUniform1i(long ctx, + long shaderProgramId, + long uniformLocation, + int value); + + abstract ShaderError setUniform1f(long ctx, + long shaderProgramId, + long uniformLocation, + float value); + + abstract ShaderError setUniform2i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + abstract ShaderError setUniform2f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + abstract ShaderError setUniform3i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + abstract ShaderError setUniform3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + abstract ShaderError setUniform4i(long ctx, + long shaderProgramId, + long uniformLocation, + int[] value); + + abstract ShaderError setUniform4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + abstract ShaderError setUniformMatrix3f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + abstract ShaderError setUniformMatrix4f(long ctx, + long shaderProgramId, + long uniformLocation, + float[] value); + + + // ShaderAttributeArray methods + + abstract ShaderError setUniform1iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + abstract ShaderError setUniform1fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + abstract ShaderError setUniform2iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + abstract ShaderError setUniform2fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + abstract ShaderError setUniform3iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + abstract ShaderError setUniform3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + abstract ShaderError setUniform4iArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + int[] value); + + abstract ShaderError setUniform4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + abstract ShaderError setUniformMatrix3fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + abstract ShaderError setUniformMatrix4fArray(long ctx, + long shaderProgramId, + long uniformLocation, + int numElements, + float[] value); + + + /** + * Method to return a flag indicating whether this + * ShaderProgram is supported on the specified Canvas. + */ + abstract boolean isSupported(Canvas3D cv); + + + void setLive(boolean backgroundGroup, int refCount) { + + // System.out.println("ShaderProgramRetained.setLive()"); + + if (shaders != null) { + for (int i = 0; i < shaders.length; i++){ + shaders[i].setLive(backgroundGroup, refCount); + } + } + + super.doSetLive(backgroundGroup, refCount); + super.markAsLive(); + + } + + void clearLive(int refCount) { + + // System.out.println("ShaderProgramRetained.clearLive()"); + + super.clearLive(refCount); + + if (shaders != null) { + for (int i = 0; i < shaders.length; i++) { + shaders[i].clearLive(refCount); + } + } + } + + /** + * Method to enable the native shader program. + */ + private ShaderError enableShaderProgram(Canvas3D cv, int cvRdrIndex) { + assert(cvRdrIndex >= 0); + synchronized(resourceLock) { + return enableShaderProgram(cv.ctx, + shaderProgramData[cvRdrIndex].getShaderProgramId()); + } + + } + + /** + * Method to disable the native shader program. + */ + private ShaderError disableShaderProgram(Canvas3D cv) { + return disableShaderProgram(cv.ctx); + } + + /** + * Initializes a mirror object. + */ + synchronized void initMirrorObject() { + + // Create mirror copy of shaders + if (this.shaders == null) { + ((ShaderProgramRetained)mirror).shaders = null; + } + else { + ((ShaderProgramRetained)mirror).shaders = new ShaderRetained[this.shaders.length]; + // Copy vertex and fragment shader + for (int i = 0; i < this.shaders.length; i++) { + ((ShaderProgramRetained)mirror).shaders[i] = + (ShaderRetained)this.shaders[i].mirror; + } + } + ((ShaderProgramRetained)mirror).shaderProgramData = null; + + // Create mirror copy of vertex attribute names + if (this.vertexAttrNames == null) { + ((ShaderProgramRetained)mirror).vertexAttrNames = null; + } + else { + ((ShaderProgramRetained)mirror).vertexAttrNames = (String[])this.vertexAttrNames.clone(); + } + + // Create mirror copy of shader attribute names + if (this.shaderAttrNames == null) { + ((ShaderProgramRetained)mirror).shaderAttrNames = null; + } + else { + ((ShaderProgramRetained)mirror).shaderAttrNames = (String[])this.shaderAttrNames.clone(); + } + + // Clear shader attribute error set + ((ShaderProgramRetained)mirror).shaderAttrErrorSet = null; + } + + /** + * Update the "component" field of the mirror object with the given "value" + */ + synchronized void updateMirrorObject(int component, Object value) { + + // ShaderProgram can't be modified once it is live. + assert(false); + System.out.println("ShaderProgramRetained : updateMirrorObject NOT IMPLEMENTED YET"); + } + + /** + * Method to create a ShaderProgramData object for the specified + * canvas/renderer if it doesn't already exist + */ + private void createShaderProgramData(int cvRdrIndex) { + // Create shaderProgram resources if it has not been done. + synchronized(resourceLock) { + if(shaderProgramData == null) { + // We rely on Java to initial the array elements to null. + shaderProgramData = new ShaderProgramData[cvRdrIndex+1]; + } + else if(shaderProgramData.length <= cvRdrIndex) { + // We rely on Java to initial the array elements to null. + ShaderProgramData[] tempSPData = new ShaderProgramData[cvRdrIndex+1]; + System.arraycopy(shaderProgramData, 0, + tempSPData, 0, + shaderProgramData.length); + shaderProgramData = tempSPData; + } + + if(shaderProgramData[cvRdrIndex] == null) { + shaderProgramData[cvRdrIndex] = new ShaderProgramData(); + } + } + } + + /** + * Method to create the native shader program. We must already have + * called createShaderProgramData for this cvRdrIndex. + */ + private ShaderError createShaderProgram(Canvas3D cv, int cvRdrIndex) { + // Create shaderProgram resources if it has not been done. + synchronized(resourceLock) { + assert(shaderProgramData[cvRdrIndex].getShaderProgramId() == 0); + + long[] spIdArr = new long[1]; + ShaderError err = createShaderProgram(cv.ctx, spIdArr); + if(err != null) { + return err; + } + shaderProgramData[cvRdrIndex].setShaderProgramId(spIdArr[0]); + } + + return null; + } + + /** + * Method to link the native shader program. + */ + private ShaderError linkShaderProgram(Canvas3D cv, int cvRdrIndex, + ShaderRetained[] shaders) { + synchronized(resourceLock) { + long[] shaderIds = new long[shaders.length]; + for(int i=0; i<shaders.length; i++) { + synchronized(shaders[i]) { + shaderIds[i] = shaders[i].shaderIds[cvRdrIndex]; + } + } + ShaderError err = + linkShaderProgram(cv.ctx, + shaderProgramData[cvRdrIndex].getShaderProgramId(), + shaderIds); + if(err != null) { + return err; + } + shaderProgramData[cvRdrIndex].setLinked(true); + } + + return null; + } + + + private ShaderError bindVertexAttrName(Canvas3D cv, int cvRdrIndex, String attrName, int attrIndex) { + assert(attrName != null); + synchronized(resourceLock) { + long shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); +// System.err.println("attrName = " + attrName); + ShaderError err = bindVertexAttrName(cv.ctx, shaderProgramId, attrName, attrIndex); + if (err != null) { + return err; + } + } + return null; + } + + private void lookupVertexAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) { + synchronized(resourceLock) { + long shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + + boolean[] errArr = new boolean[attrNames.length]; + lookupVertexAttrNames(cv.ctx, shaderProgramId, attrNames, errArr); + + for (int i = 0; i < attrNames.length; i++) { + // Report non-fatal error if detected + if (errArr[i]) { + String errMsg = "Vertex Attribute name lookup failed: " + attrNames[i]; + ShaderError err = new ShaderError(ShaderError.VERTEX_ATTRIBUTE_LOOKUP_ERROR, errMsg); + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + + private void lookupShaderAttrNames(Canvas3D cv, int cvRdrIndex, String[] attrNames) { + synchronized(resourceLock) { + long shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + + AttrNameInfo[] attrNameInfoArr = new AttrNameInfo[attrNames.length]; + lookupShaderAttrNames(cv.ctx, shaderProgramId, attrNames, attrNameInfoArr); + + for (int i = 0; i < attrNames.length; i++) { + shaderProgramData[cvRdrIndex].setAttrNameInfo(attrNames[i], attrNameInfoArr[i]); + + // Report non-fatal error if location is invalid (-1) + if (attrNameInfoArr[i].getLocation() == -1) { + String errMsg = "Attribute name lookup failed: " + attrNames[i]; + ShaderError err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_LOOKUP_ERROR, errMsg); + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + + /** + * Method to return the shaderProgram data for the specified canvas or renderer + */ + private ShaderProgramData getShaderProgramData(int cvRdrIndex) { + synchronized(resourceLock) { + return shaderProgramData[cvRdrIndex]; + } + } + + /** + * Method to create the native shader. + */ + private ShaderError createShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { + + // Create shaderProgram resources if it has not been done. + synchronized(shader.resourceLock) { + if(shader.shaderIds == null){ + // We rely on Java to initial the array elements to 0 or false; + shader.shaderIds = new long[cvRdrIndex+1]; + shader.compiled = new boolean[cvRdrIndex+1]; + } else if( shader.shaderIds.length <= cvRdrIndex) { + // We rely on Java to initial the array elements to 0 or false; + long[] tempSIds = new long[cvRdrIndex+1]; + boolean[] tempCompiled = new boolean[cvRdrIndex+1]; + + System.arraycopy(shader.shaderIds, 0, + tempSIds, 0, + shader.shaderIds.length); + shader.shaderIds = tempSIds; + + System.arraycopy(shader.compiled, 0, + tempCompiled, 0, + shader.compiled.length); + shader.compiled = tempCompiled; + } + + if(shader.shaderIds[cvRdrIndex] != 0) { + // We have already created the shaderId for this Canvas. + return null; + } + + long[] shaderIdArr = new long[1]; + ShaderError err = createShader(cv.ctx, shader, shaderIdArr); + if(err != null) { + return err; + } + shader.shaderIds[cvRdrIndex] = shaderIdArr[0]; + } + return null; + } + + /** + * Method to compile the native shader. + */ + private ShaderError compileShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { + + synchronized(shader.resourceLock) { + + if(shader.compiled[cvRdrIndex] == true) { + // We have already compiled the shaderId for this Canvas. + return null; + } + + String source = ((SourceCodeShaderRetained)shader).getShaderSource(); + ShaderError err = compileShader(cv.ctx, shader.shaderIds[cvRdrIndex], source); + if(err != null) { + return err; + } + shader.compiled[cvRdrIndex] = true; + } + + return null; + } + + /** + * Send a message to the notification thread, which will call the + * shader error listeners. + */ + void notifyErrorListeners(Canvas3D cv, ShaderError err) { + J3dNotification notification = new J3dNotification(); + notification.type = J3dNotification.SHADER_ERROR; + notification.universe = cv.view.universe; + notification.args[0] = err; + VirtualUniverse.mc.sendNotification(notification); + } + + + /** + * This method checks whether this ShaderProgram is supported on + * the specified Canvas. If it isn't supported, it will report a + * ShaderError unless an error has already been reported for this + * shader program. + */ + private boolean verifyShaderProgramSupported(Canvas3D cv) { + boolean supported = isSupported(cv); + if (!supported && !unsupportedErrorReported) { + String errorMsg = J3dI18N.getString("ShaderProgramRetained0"); + ShaderError err = new ShaderError(ShaderError.UNSUPPORTED_LANGUAGE_ERROR, errorMsg); + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + unsupportedErrorReported = true; + } + return supported; + } + + /** + * Method to destroy the native shader. + */ + void destroyShader(Canvas3D cv, int cvRdrIndex, ShaderRetained shader) { + if (!verifyShaderProgramSupported(cv)) { + return; + } + + // Destroy shader resource if it exists + synchronized(shader.resourceLock) { + // Check whether an entry in the shaderIds array has been allocated + if (shader.shaderIds == null || shader.shaderIds.length <= cvRdrIndex) { + return; + } + + // Nothing to do if the shaderId is 0 + if (shader.shaderIds[cvRdrIndex] == 0) { + return; + } + + // Destroy the native resource and set the ID to 0 for this canvas/renderer + // Ignore any possible shader error, because there is no meaningful way to report it + destroyShader(cv.ctx, shader.shaderIds[cvRdrIndex]); + shader.shaderIds[cvRdrIndex] = 0; + } + } + + + /** + * Method to destroy the native shader program. + */ + void destroyShaderProgram(Canvas3D cv, int cvRdrIndex) { + if (!verifyShaderProgramSupported(cv)) { + return; + } + + // Destroy shaderProgram resource if it exists + synchronized(resourceLock) { + assert(shaderProgramData != null && + shaderProgramData.length > cvRdrIndex && + shaderProgramData[cvRdrIndex] != null); + +// // Check whether an entry in the shaderProgramData array has been allocated +// if (shaderProgramData == null || +// shaderProgramData.length <= cvRdrIndex || +// shaderProgramData[cvRdrIndex] == null) { +// return; +// } + + long shaderProgramId = shaderProgramData[cvRdrIndex].getShaderProgramId(); + // Nothing to do if the shaderProgramId is 0 + if (shaderProgramId == 0) { + return; + } + + // Destroy the native resource, set the ID to 0 for this canvas/renderer, + // and clear the bit in the resourceCreationMask + // Ignore any possible shader error, because there is no meaningful way to report it + destroyShaderProgram(cv.ctx, shaderProgramId); + // Reset this ShaderProgramData object. + shaderProgramData[cvRdrIndex].reset(); + } + } + + + /** + * updateNative is called while traversing the RenderBin to + * update the shader program state + */ + void updateNative(Canvas3D cv, boolean enable) { + // System.out.println("ShaderProgramRetained.updateNative : "); + + final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != 0; + final int cvRdrIndex = useSharedCtx ? cv.screen.renderer.rendererId : cv.canvasId; + + // Create ShaderProgramData object for this canvas/renderer if it doesn't already exist + createShaderProgramData(cvRdrIndex); + + // Check whether this shader program type is supported for this canvas + if (!verifyShaderProgramSupported(cv)) { + return; + } + + // Just disable shader program and return if enable parameter is set to false + if (!enable) { + // Given the current design, disableShaderProgram cannot return a non-null value, + // so no need to check it + disableShaderProgram(cv); + return; + } + + // Just disable shader program and return if array of shaders is empty, + // or if a previous attempt to link resulted in an error + if (shaders == null || shaders.length == 0 || linkErrorOccurred) { + disableShaderProgram(cv); + return; + } + + boolean loadShaderProgram = false; // flag indicating whether to reload all shaderProgram states + if (getShaderProgramData(cvRdrIndex).getShaderProgramId() == 0) { + loadShaderProgram = true; + } + + //System.out.println(".... loadShaderProgram = " + loadShaderProgram); + //System.out.println(".... resourceCreationMask= " + resourceCreationMask); + + ShaderError err = null; + boolean errorOccurred = false; + if (loadShaderProgram) { + if (useSharedCtx) { + // TODO : Need to test useSharedCtx case. ** Untested case ** + cv.makeCtxCurrent(cv.screen.renderer.sharedCtx); + } + + // Create shader resources if not already done + for(int i=0; i < shaders.length; i++) { + if (shaders[i].compileErrorOccurred) { + errorOccurred = true; + } + else { + err = createShader(cv, cvRdrIndex, shaders[i]); + if (err != null) { + err.setShaderProgram((ShaderProgram)this.source); + err.setShader((Shader)shaders[i].source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + errorOccurred = true; + } + else { + err = compileShader(cv, cvRdrIndex, shaders[i]); + if (err != null) { + err.setShaderProgram((ShaderProgram)this.source); + err.setShader((Shader)shaders[i].source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + destroyShader(cv, cvRdrIndex, shaders[i]); + shaders[i].compileErrorOccurred = true; + errorOccurred = true; + } + } + } + } + + // Create shader program + if (!errorOccurred) { + err = createShaderProgram(cv, cvRdrIndex); + if (err != null) { + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + errorOccurred = true; + } + } + + boolean linked = getShaderProgramData(cvRdrIndex).isLinked(); + if (!linked) { + // Bind vertex attribute names + if (!errorOccurred) { + if (vertexAttrNames != null) { +// System.err.println("vertexAttrNames.length = " + vertexAttrNames.length); + for (int i = 0; i < vertexAttrNames.length; i++) { + err = bindVertexAttrName(cv, cvRdrIndex, vertexAttrNames[i], i); + // Report non-fatal error, if one was detected + if (err != null) { + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + // Link shader program + if (!errorOccurred) { + err = linkShaderProgram(cv, cvRdrIndex, shaders); + if (err != null) { + err.setShaderProgram((ShaderProgram)this.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + destroyShaderProgram(cv, cvRdrIndex); + linkErrorOccurred = true; + errorOccurred = true; + } + } + + // lookup vertex attribute names + if (!errorOccurred) { + if (vertexAttrNames != null) { + lookupVertexAttrNames(cv, cvRdrIndex, vertexAttrNames); + } + } + + // Lookup shader attribute names + if (!errorOccurred) { + if (shaderAttrNames != null) { +// System.err.println("shaderAttrNames.length = " + shaderAttrNames.length); + lookupShaderAttrNames(cv, cvRdrIndex, shaderAttrNames); + } + } + } + + // Restore current context if we changed it to the shareCtx + if (useSharedCtx) { + cv.makeCtxCurrent(cv.ctx); + } + + // If compilation or link error occured, disable shader program and return + if (errorOccurred) { + disableShaderProgram(cv); + return; + } + } + + // Now we can enable the shader program + enableShaderProgram(cv, cvRdrIndex); + } + + /** + * Update native value for ShaderAttributeValue class + */ + ShaderError setUniformAttrValue(long ctx, long shaderProgramId, long loc, + ShaderAttributeValueRetained sav) { + + switch (sav.getClassType()) { + case ShaderAttributeObjectRetained.TYPE_INTEGER: + return setUniform1i(ctx, shaderProgramId, loc, + ((int[])sav.attrWrapper.getRef())[0]); + + case ShaderAttributeObjectRetained.TYPE_FLOAT: + return setUniform1f(ctx, shaderProgramId, loc, + ((float[])sav.attrWrapper.getRef())[0]); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2I: + return setUniform2i(ctx, shaderProgramId, loc, + (int[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2F: + return setUniform2f(ctx, shaderProgramId, loc, + (float[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3I: + return setUniform3i(ctx, shaderProgramId, loc, + (int[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3F: + return setUniform3f(ctx, shaderProgramId, loc, + (float[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4I: + return setUniform4i(ctx, shaderProgramId, loc, + (int[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4F: + return setUniform4f(ctx, shaderProgramId, loc, + (float[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX3F: + return setUniformMatrix3f(ctx, shaderProgramId, loc, + (float[])sav.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX4F: + return setUniformMatrix4f(ctx, shaderProgramId, loc, + (float[])sav.attrWrapper.getRef()); + + default: + // Should never get here + assert false : "Unrecognized ShaderAttributeValue classType"; + return null; + } + } + + /** + * Update native value for ShaderAttributeArray class + */ + ShaderError setUniformAttrArray(long ctx, long shaderProgramId, long loc, + ShaderAttributeArrayRetained saa) { + + switch (saa.getClassType()) { + case ShaderAttributeObjectRetained.TYPE_INTEGER: + return setUniform1iArray(ctx, shaderProgramId, loc, saa.length(), + ((int[])saa.attrWrapper.getRef())); + + case ShaderAttributeObjectRetained.TYPE_FLOAT: + return setUniform1fArray(ctx, shaderProgramId, loc, saa.length(), + ((float[])saa.attrWrapper.getRef())); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2I: + return setUniform2iArray(ctx, shaderProgramId, loc, saa.length(), + (int[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE2F: + return setUniform2fArray(ctx, shaderProgramId, loc, saa.length(), + (float[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3I: + return setUniform3iArray(ctx, shaderProgramId, loc, saa.length(), + (int[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE3F: + return setUniform3fArray(ctx, shaderProgramId, loc, saa.length(), + (float[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4I: + return setUniform4iArray(ctx, shaderProgramId, loc, saa.length(), + (int[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_TUPLE4F: + return setUniform4fArray(ctx, shaderProgramId, loc, saa.length(), + (float[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX3F: + return setUniformMatrix3fArray(ctx, shaderProgramId, loc, saa.length(), + (float[])saa.attrWrapper.getRef()); + + case ShaderAttributeObjectRetained.TYPE_MATRIX4F: + return setUniformMatrix4fArray(ctx, shaderProgramId, loc, saa.length(), + (float[])saa.attrWrapper.getRef()); + + default: + // Should never get here + assert false : "Unrecognized ShaderAttributeArray classType"; + return null; + } + + } + + + void setShaderAttributes(Canvas3D cv, ShaderAttributeSetRetained attributeSet) { + final boolean useSharedCtx = cv.useSharedCtx && cv.screen.renderer.sharedCtx != 0; + final int cvRdrIndex = useSharedCtx ? cv.screen.renderer.rendererId : cv.canvasId; + ShaderProgramData spData = getShaderProgramData(cvRdrIndex); + + // Just return if shader program wasn't linked successfully + if (!spData.isLinked()) { + return; + } + + long shaderProgramId = spData.getShaderProgramId(); + + Iterator attrs = attributeSet.getAttrs().values().iterator(); + while (attrs.hasNext()) { + ShaderError err = null; + ShaderAttributeRetained saRetained = (ShaderAttributeRetained)attrs.next(); + + // Lookup attribute info for the specified attrName; null means + // that the name does not appear in the ShaderProgram, so we will + // report an error. + AttrNameInfo attrNameInfo = spData.getAttrNameInfo(saRetained.getAttributeName()); + if(attrNameInfo == null) { +// System.err.println("ShaderProgramRetained : attrLocation (" + saRetained.getAttributeName() + ") is null."); + String errMsg = "Attribute name not set in ShaderProgram: " + saRetained.getAttributeName(); // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_NAME_NOT_SET_ERROR, errMsg); + } else { + long loc = attrNameInfo.getLocation(); + if (loc != -1) { + if (saRetained instanceof ShaderAttributeValueRetained) { + ShaderAttributeValueRetained savRetained = (ShaderAttributeValueRetained)saRetained; + if (attrNameInfo.isArray() || + (savRetained.getClassType() != attrNameInfo.getType())) { + String errMsg = "Attribute type mismatch: " + savRetained.getAttributeName(); // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else { + err = setUniformAttrValue(cv.ctx, shaderProgramId, loc, savRetained); + } + } else if (saRetained instanceof ShaderAttributeArrayRetained) { + ShaderAttributeArrayRetained saaRetained = (ShaderAttributeArrayRetained)saRetained; + if (!attrNameInfo.isArray() || + (saaRetained.getClassType() != attrNameInfo.getType())) { + String errMsg = "Attribute type mismatch: " + saaRetained.getAttributeName(); // TODO: I18N + err = new ShaderError(ShaderError.SHADER_ATTRIBUTE_TYPE_ERROR, errMsg); + } + else { + err = setUniformAttrArray(cv.ctx, shaderProgramId, loc, saaRetained); + } + } else if (saRetained instanceof ShaderAttributeBindingRetained) { + assert false; + throw new RuntimeException("not implemented"); + } else { + assert false; + } + } + } + + if (err != null) { + // Before reporting the ShaderAttribute error, check + // whether it has already been reported for this ShaderProgram + if (shaderAttrErrorSet == null) { + shaderAttrErrorSet = new HashSet(); + } + if (shaderAttrErrorSet.add(saRetained.source)) { + err.setShaderProgram((ShaderProgram)this.source); + err.setShaderAttributeSet((ShaderAttributeSet)attributeSet.source); + err.setShaderAttribute((ShaderAttribute)saRetained.source); + err.setCanvas3D(cv); + notifyErrorListeners(cv, err); + } + } + } + } + + class ShaderProgramData extends Object { + + // shaderProgramId use by native code. + private long shaderProgramId = 0; + + // linked flag for native. + private boolean linked = false; + + // A map of locations for ShaderAttributes. + private HashMap attrNameInfoMap = new HashMap(); + + /** ShaderProgramData Constructor */ + ShaderProgramData() { + } + + void reset() { + shaderProgramId = 0; + linked = false; + attrNameInfoMap.clear(); + } + + void setShaderProgramId(long shaderProgramId) { + this.shaderProgramId = shaderProgramId; + } + + long getShaderProgramId() { + return this.shaderProgramId; + } + + void setLinked(boolean linked) { + this.linked = linked; + } + + boolean isLinked() { + return linked; + } + + void setAttrNameInfo(String shaderAttribute, AttrNameInfo attrNameInfo) { + assert(shaderAttribute != null); + attrNameInfoMap.put(shaderAttribute, attrNameInfo); + } + + AttrNameInfo getAttrNameInfo(String shaderAttribute) { + return (AttrNameInfo) attrNameInfoMap.get(shaderAttribute); + } + + + } + + // Data associated with an attribute name + class AttrNameInfo { + void setLocation(long loc) { + this.loc = loc; + } + + long getLocation() { + return loc; + } + + void setType(int type) { + this.type = type; + } + + int getType() { + return type; + } + + boolean isArray() { + return isArray; + } + + void setArray(boolean isArray) { + this.isArray = isArray; + } + + // Location of attribute name in linked shader program + private long loc; + + // boolean indicating whether the attribute is an array + private boolean isArray; + + // type of shader attribute + private int type; + } + +} diff --git a/src/classes/share/javax/media/j3d/ShaderRetained.java b/src/classes/share/javax/media/j3d/ShaderRetained.java new file mode 100644 index 0000000..a050b50 --- /dev/null +++ b/src/classes/share/javax/media/j3d/ShaderRetained.java @@ -0,0 +1,78 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +import java.util.*; + +/** + * The ShaderRetained object is the abstract base class for programmable + * shader code. Currently, only text-based source code shaders are + * supported, so the only subclass of Shader is SourceCodeShader. We + * leave open the possibility for binary (object code) shaders in the + * future. + */ +abstract class ShaderRetained extends NodeComponentRetained { + int shadingLanguage; + int shaderType; + + // shaderId use by native code. One per Canvas. + long[] shaderIds; + boolean[] compiled; + + // Flag indicating whether a COMPILE_ERROR has occurred for this shader + // object. It is set in updateNative to indicate that the compileShader + // operation failed. It is cleared in setLive or clearLive. + // TODO KCR: Add code to clear this in setLive or clearLive + boolean compileErrorOccurred = false; + + // need to synchronize access from multiple rendering threads + Object resourceLock = new Object(); + + void initializeShader(int shadingLanguage, int shaderType) { + this.shadingLanguage = shadingLanguage; + this.shaderType = shaderType; + } + + int getShadingLanguage() { + return shadingLanguage; + } + + int getShaderType() { + return shaderType; + } + + void setLive(boolean inBackgroundGroup, int refCount) { + // System.out.println("SourceCodeShaderRetained.setLive()"); + super.setLive(inBackgroundGroup, refCount); + } + + void clearLive(int refCount) { + // System.out.println("SourceCodeShaderRetained.clearLive()"); + super.clearLive(refCount); + } + + /** + * Shader object doesn't really have mirror object. + * But it's using the updateMirrorObject interface to propagate + * the changes to the users + */ + synchronized void updateMirrorObject(int component, Object value) { + System.out.println("Shader.updateMirrorObject not implemented yet!"); + } + + void handleFrequencyChange(int bit) { + System.out.println("Shader.handleFrequencyChange not implemented yet!"); + } + +} + diff --git a/src/classes/share/javax/media/j3d/Shape3D.java b/src/classes/share/javax/media/j3d/Shape3D.java index 6a9f5d7..5c4394c 100644 --- a/src/classes/share/javax/media/j3d/Shape3D.java +++ b/src/classes/share/javax/media/j3d/Shape3D.java @@ -111,6 +111,14 @@ public class Shape3D extends Leaf { public static final int ALLOW_APPEARANCE_OVERRIDE_WRITE = CapabilityBits.SHAPE3D_ALLOW_APPEARANCE_OVERRIDE_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_GEOMETRY_READ, + ALLOW_APPEARANCE_READ, + ALLOW_COLLISION_BOUNDS_READ, + ALLOW_APPEARANCE_OVERRIDE_READ + }; + /** * Constructs a Shape3D node with default parameters. The default * values are as follows: @@ -127,6 +135,8 @@ public class Shape3D extends Leaf { * that default values are used for all appearance attributes. */ public Shape3D() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -141,7 +151,10 @@ public class Shape3D extends Leaf { * this shape node. */ public Shape3D(Geometry geometry) { - ((Shape3DRetained)retained).setGeometry(geometry, 0); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((Shape3DRetained)retained).setGeometry(geometry, 0); } /** @@ -155,7 +168,10 @@ public class Shape3D extends Leaf { * @param appearance the appearance component of the shape node */ public Shape3D(Geometry geometry, Appearance appearance) { - ((Shape3DRetained)retained).setGeometry(geometry, 0); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((Shape3DRetained)retained).setGeometry(geometry, 0); ((Shape3DRetained)retained).setAppearance(appearance); } diff --git a/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java b/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java index e4514d4..a3e604d 100644 --- a/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java +++ b/src/classes/share/javax/media/j3d/Shape3DCompileRetained.java @@ -424,81 +424,139 @@ class Shape3DCompileRetained extends Shape3DRetained { * @exception IllegalArgumentException if <code>path</code> is * invalid. */ - boolean intersect(SceneGraphPath path, - PickShape pickShape, double[] dist) { - - // This method will not do bound intersect check, as it assume - // caller has already done that. ( For performance and code - // simplification reasons. ) - - Transform3D localToVworld = path.getTransform(); - int i; - - if (localToVworld == null) { + PickShape pickShape, double[] dist) { + + int flags; + PickInfo pickInfo = new PickInfo(); + + Transform3D localToVworld = path.getTransform(); + if (localToVworld == null) { throw new IllegalArgumentException(J3dI18N.getString("Shape3DRetained3")); } - - Transform3D t3d = VirtualUniverse.mc.getTransform3D(null); - t3d.invert(localToVworld); - PickShape newPS = pickShape.transform(t3d); - FreeListManager.freeObject(FreeListManager.TRANSFORM3D, t3d); - - Shape3D shape = (Shape3D) path.getObject(); + pickInfo.setLocalToVWorldRef( localToVworld); + + Shape3D shape = (Shape3D) path.getObject(); // Get the geometries for this shape only, since the compiled // geomtryList contains several shapes - ArrayList glist = (ArrayList) geometryInfo.get(shape.id); - - int geomListSize = glist.size(); - - Point3d iPnt = Shape3DRetained.getPoint3d(); + ArrayList glist = (ArrayList) geometryInfo.get(shape.id); + + // System.out.println("Shape3DCompileRetained.intersect() : "); + if (dist == null) { + // System.out.println(" no dist request ...."); + return intersect(pickInfo, pickShape, 0, glist); + } + + flags = PickInfo.CLOSEST_DISTANCE; + if (intersect(pickInfo, pickShape, flags, glist)) { + dist[0] = pickInfo.getClosestDistance(); + return true; + } + + return false; + + } + + boolean intersect(PickInfo pickInfo, PickShape pickShape, int flags, + ArrayList geometryList) { + + Transform3D localToVworld = pickInfo.getLocalToVWorldRef(); + + Transform3D t3d = new Transform3D(); + t3d.invert(localToVworld); + PickShape newPS = pickShape.transform(t3d); + + int geomListSize = geometryList.size(); GeometryRetained geometry; - if (dist == null) { - for (i=0; i < geomListSize; i++) { - Geometry g = (Geometry) glist.get(i); - if (g != null && g.retained != null) { - geometry = (GeometryRetained)g.retained; + if (((flags & PickInfo.CLOSEST_INTERSECTION_POINT) == 0) && + ((flags & PickInfo.CLOSEST_DISTANCE) == 0) && + ((flags & PickInfo.CLOSEST_GEOM_INFO) == 0) && + ((flags & PickInfo.ALL_GEOM_INFO) == 0)) { + + for (int i=0; i < geomListSize; i++) { + geometry = (GeometryRetained) geometryList.get(i); + if (geometry != null) { if (geometry.mirrorGeometry != null) { geometry = geometry.mirrorGeometry; } - - if (geometry.intersect(newPS, null, iPnt)) { - Shape3DRetained.freePoint3d(iPnt); + // Need to modify this method + // if (geometry.intersect(newPS, null, null)) { + if (geometry.intersect(newPS, null, 0, null)) { return true; } } } - } else { + } + else { + double distance; double minDist = Double.POSITIVE_INFINITY; - // TODO : BugId 4351579 -- Need to return the index of nearest - // intersected geometry too. - - for (i=0; i < geomListSize; i++) { - Geometry g = (Geometry) glist.get(i); - if (g != null && g.retained != null) { - geometry = (GeometryRetained)g.retained; + Point3d closestIPnt = new Point3d(); + Point3d iPnt = new Point3d(); + Point3d iPntVW = new Point3d(); + PickInfo.IntersectionInfo closestInfo = null; + PickInfo.IntersectionInfo intersectionInfo + = pickInfo.createIntersectionInfo(); + + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + closestInfo = pickInfo.createIntersectionInfo(); + } + + for (int i=0; i < geomListSize; i++) { + geometry = (GeometryRetained) geometryList.get(i); + if (geometry != null) { if (geometry.mirrorGeometry != null) { geometry = geometry.mirrorGeometry; } - if (geometry.intersect(newPS, dist, iPnt)) { - localToVworld.transform(iPnt); - dist[0] = pickShape.distance(iPnt); - if (minDist > dist[0]) { - minDist = dist[0]; - } + if (geometry.intersect(newPS, intersectionInfo, flags, iPnt)) { + + iPntVW.set(iPnt); + localToVworld.transform(iPntVW); + distance = pickShape.distance(iPntVW); + + if (minDist > distance) { + minDist = distance; + closestIPnt.set(iPnt); + + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + closestInfo.setGeometry((Geometry) geometry.source); + closestInfo.setGeometryIndex(i); + closestInfo.setIntersectionPoint(closestIPnt); + closestInfo.setDistance(distance); + closestInfo.setVertexIndices(intersectionInfo.getVertexIndices()); + } + } + + if ((flags & PickInfo.ALL_GEOM_INFO) != 0) { + + intersectionInfo.setGeometry((Geometry) geometry.source); + intersectionInfo.setGeometryIndex(i); + intersectionInfo.setIntersectionPoint(iPnt); + intersectionInfo.setDistance(distance); + // VertexIndices has been computed in intersect method. + pickInfo.insertIntersectionInfo(intersectionInfo); + intersectionInfo = pickInfo.createIntersectionInfo(); + } } } } - - if (minDist < Double.POSITIVE_INFINITY) { - dist[0] = minDist; - Shape3DRetained.freePoint3d(iPnt); + + if (minDist < Double.POSITIVE_INFINITY) { + if ((flags & PickInfo.CLOSEST_DISTANCE) != 0) { + pickInfo.setClosestDistance(minDist); + } + if((flags & PickInfo.CLOSEST_INTERSECTION_POINT) != 0) { + pickInfo.setClosestIntersectionPoint(closestIPnt); + } + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + pickInfo.insertIntersectionInfo(closestInfo); + } return true; } } - - Shape3DRetained.freePoint3d(iPnt); + return false; - } + + } + } diff --git a/src/classes/share/javax/media/j3d/Shape3DRetained.java b/src/classes/share/javax/media/j3d/Shape3DRetained.java index 8e097bd..8d3002c 100644 --- a/src/classes/share/javax/media/j3d/Shape3DRetained.java +++ b/src/classes/share/javax/media/j3d/Shape3DRetained.java @@ -580,97 +580,6 @@ class Shape3DRetained extends LeafRetained { return (appearance == null ? null: (Appearance) appearance.source); } - - /** - * Check if the geometry component of this shape node under path - * intersects with the pickShape. - * This is an expensive method. It should only be called if and only - * if the path's bound intersects pickShape. - * @exception IllegalArgumentException if <code>path</code> is - * invalid. - */ - - boolean intersect(SceneGraphPath path, - PickShape pickShape, double[] dist) { - - // This method will not do bound intersect check, as it assume - // caller has already done that. ( For performance and code - // simplification reasons. ) - - Transform3D localToVworld = path.getTransform(); - int i; - - if (localToVworld == null) { - throw new IllegalArgumentException(J3dI18N.getString("Shape3DRetained3")); - } - - // Support OrientedShape3D here. - // TODO - BugId : 4363899 - APIs issue : OrientedShape3D's intersect needs view - // info. temp. fix use the primary view. - if (this instanceof OrientedShape3DRetained) { - Transform3D orientedTransform = ((OrientedShape3DRetained)this). - getOrientedTransform(getPrimaryViewIdx()); - localToVworld.mul(orientedTransform); - } - - Transform3D t3d = VirtualUniverse.mc.getTransform3D(null); - t3d.invert(localToVworld); - PickShape newPS = pickShape.transform(t3d); - FreeListManager.freeObject(FreeListManager.TRANSFORM3D, t3d); - - // TODO: For optimization - Should do a geobounds check of - // each geometry first. But this doesn't work for - // OrientedShape3D case... - int geomListSize = geometryList.size(); - Point3d iPnt = getPoint3d(); - GeometryRetained geometry; - - if (dist == null) { - for (i=0; i < geomListSize; i++) { - geometry = (GeometryRetained) geometryList.get(i); - if (geometry != null) { - if (geometry.mirrorGeometry != null) { - geometry = geometry.mirrorGeometry; - } - if (geometry.intersect(newPS, null, iPnt)) { - freePoint3d(iPnt); - return true; - } - } - } - } else { - double minDist = Double.POSITIVE_INFINITY; - // TODO : BugId 4351579 -- Need to return the index of nearest - // intersected geometry too. - - for (i=0; i < geomListSize; i++) { - geometry = (GeometryRetained) geometryList.get(i); - if (geometry != null) { - if (geometry.mirrorGeometry != null) { - geometry = geometry.mirrorGeometry; - } - if (geometry.intersect(newPS, dist, iPnt)) { - localToVworld.transform(iPnt); - dist[0] = pickShape.distance(iPnt); - if (minDist > dist[0]) { - minDist = dist[0]; - } - } - } - } - - if (minDist < Double.POSITIVE_INFINITY) { - dist[0] = minDist; - freePoint3d(iPnt); - return true; - } - } - - freePoint3d(iPnt); - - return false; - } - void setAppearanceOverrideEnable(boolean flag) { if (((Shape3D)this.source).isLive()) { @@ -703,7 +612,153 @@ class Shape3DRetained extends LeafRetained { boolean getAppearanceOverrideEnable() { return appearanceOverrideEnable; } + + boolean intersect(PickInfo pickInfo, PickShape pickShape, int flags ) { + + Transform3D localToVworld = pickInfo.getLocalToVWorldRef(); + + // Support OrientedShape3D here. + // Note - BugId : 4363899 - APIs issue : OrientedShape3D's intersect needs view + // info. temp. fix use the primary view. + if (this instanceof OrientedShape3DRetained) { + Transform3D orientedTransform = ((OrientedShape3DRetained)this). + getOrientedTransform(getPrimaryViewIdx()); + localToVworld.mul(orientedTransform); + } + + Transform3D t3d = new Transform3D(); + t3d.invert(localToVworld); + PickShape newPS = pickShape.transform(t3d); + // Note: For optimization - Should do a geobounds check of + // each geometry first. But this doesn't work for + // OrientedShape3D case... + int geomListSize = geometryList.size(); + GeometryRetained geometry; + + if (((flags & PickInfo.CLOSEST_INTERSECTION_POINT) == 0) && + ((flags & PickInfo.CLOSEST_DISTANCE) == 0) && + ((flags & PickInfo.CLOSEST_GEOM_INFO) == 0) && + ((flags & PickInfo.ALL_GEOM_INFO) == 0)) { + + for (int i=0; i < geomListSize; i++) { + geometry = (GeometryRetained) geometryList.get(i); + if (geometry != null) { + if (geometry.mirrorGeometry != null) { + geometry = geometry.mirrorGeometry; + } + if (geometry.intersect(newPS, null, 0, null)) { + return true; + } + } + } + } else { + double distance; + double minDist = Double.POSITIVE_INFINITY; + Point3d closestIPnt = new Point3d(); + Point3d iPnt = new Point3d(); + Point3d iPntVW = new Point3d(); + PickInfo.IntersectionInfo closestInfo = null; + PickInfo.IntersectionInfo intersectionInfo + = pickInfo.createIntersectionInfo(); + + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + closestInfo = pickInfo.createIntersectionInfo(); + } + + for (int i=0; i < geomListSize; i++) { + geometry = (GeometryRetained) geometryList.get(i); + if (geometry != null) { + if (geometry.mirrorGeometry != null) { + geometry = geometry.mirrorGeometry; + } + if (geometry.intersect(newPS, intersectionInfo, flags, iPnt)) { + + iPntVW.set(iPnt); + localToVworld.transform(iPntVW); + distance = pickShape.distance(iPntVW); + + if (minDist > distance) { + minDist = distance; + closestIPnt.set(iPnt); + + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + closestInfo.setGeometry((Geometry) geometry.source); + closestInfo.setGeometryIndex(i); + closestInfo.setIntersectionPoint(closestIPnt); + closestInfo.setDistance(distance); + closestInfo.setVertexIndices(intersectionInfo.getVertexIndices()); + } + } + + if ((flags & PickInfo.ALL_GEOM_INFO) != 0) { + + intersectionInfo.setGeometry((Geometry) geometry.source); + intersectionInfo.setGeometryIndex(i); + intersectionInfo.setIntersectionPoint(iPnt); + intersectionInfo.setDistance(distance); + // VertexIndices has been computed in intersect method. + pickInfo.insertIntersectionInfo(intersectionInfo); + intersectionInfo = pickInfo.createIntersectionInfo(); + } + } + } + } + + if (minDist < Double.POSITIVE_INFINITY) { + if ((flags & PickInfo.CLOSEST_DISTANCE) != 0) { + pickInfo.setClosestDistance(minDist); + } + if((flags & PickInfo.CLOSEST_INTERSECTION_POINT) != 0) { + pickInfo.setClosestIntersectionPoint(closestIPnt); + } + if ((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) { + pickInfo.insertIntersectionInfo(closestInfo); + } + return true; + } + } + + return false; + + } + + + /** + * Check if the geometry component of this shape node under path + * intersects with the pickShape. + * This is an expensive method. It should only be called if and only + * if the path's bound intersects pickShape. + * @exception IllegalArgumentException if <code>path</code> is + * invalid. + */ + + boolean intersect(SceneGraphPath path, + PickShape pickShape, double[] dist) { + + int flags; + PickInfo pickInfo = new PickInfo(); + + Transform3D localToVworld = path.getTransform(); + if (localToVworld == null) { + throw new IllegalArgumentException(J3dI18N.getString("Shape3DRetained3")); + } + pickInfo.setLocalToVWorldRef( localToVworld); + //System.out.println("Shape3DRetained.intersect() : "); + if (dist == null) { + //System.out.println(" no dist request ...."); + return intersect(pickInfo, pickShape, 0); + } + + flags = PickInfo.CLOSEST_DISTANCE; + if (intersect(pickInfo, pickShape, flags)) { + dist[0] = pickInfo.getClosestDistance(); + return true; + } + + return false; + + } /** * This sets the immedate mode context flag diff --git a/src/classes/share/javax/media/j3d/SharedGroup.java b/src/classes/share/javax/media/j3d/SharedGroup.java index 3f7ce8d..446c3f2 100644 --- a/src/classes/share/javax/media/j3d/SharedGroup.java +++ b/src/classes/share/javax/media/j3d/SharedGroup.java @@ -67,11 +67,17 @@ public class SharedGroup extends Group { public static final int ALLOW_LINK_READ = CapabilityBits.SHARED_GROUP_ALLOW_LINK_READ; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_LINK_READ + }; /** * Constructs and initializes a new SharedGroup node object. */ public SharedGroup() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } @@ -82,10 +88,12 @@ public class SharedGroup extends Group { * @since Java 3D 1.3 */ public Link[] getLinks() { - if (isLiveOrCompiled()) - if (!this.getCapability(ALLOW_LINK_READ)) + if (isLiveOrCompiled()) { + if (!this.getCapability(ALLOW_LINK_READ)) { throw new CapabilityNotSetException(J3dI18N.getString("SharedGroup1")); - return ((SharedGroupRetained)retained).getLinks(); + } + } + return ((SharedGroupRetained)retained).getLinks(); } diff --git a/src/classes/share/javax/media/j3d/SharedGroupRetained.java b/src/classes/share/javax/media/j3d/SharedGroupRetained.java index ed69d9f..694671f 100644 --- a/src/classes/share/javax/media/j3d/SharedGroupRetained.java +++ b/src/classes/share/javax/media/j3d/SharedGroupRetained.java @@ -329,7 +329,7 @@ class SharedGroupRetained extends GroupRetained implements TargetsInterface { s.transformTargets = savedTransformTargets; s.hashkeyIndex = savedHashkeyIndex; /* -// TODO : port this +// XXXX : port this for (int i=0; i < children.size(); i++) { if ((childContains[i][0] & ILLEGAL_LEAF_MASK) != 0) { throw new IllegalSharingException(J3dI18N.getString("SharedGroupRetained0")); } @@ -472,7 +472,7 @@ class SharedGroupRetained extends GroupRetained implements TargetsInterface { s.switchTargets = null; - // TODO: This is a hack since removeNodeData is called before + // XXXX: This is a hack since removeNodeData is called before // children are clearLives int[] tempIndex = null; // Don't keep the indices if everything will be cleared @@ -778,7 +778,7 @@ class SharedGroupRetained extends GroupRetained implements TargetsInterface { public void propagateTargetThreads(int type, int childTargetThreads) { if (type == TargetsInterface.TRANSFORM_TARGETS) { LinkRetained ln; - // TODO : For now we'll OR more than exact. + // XXXX : For now we'll OR more than exact. //targetThreads = localTargetThreads | childTargetThreads; targetThreads = targetThreads | childTargetThreads; for(int i=0; i<parents.size(); i++) { diff --git a/src/classes/share/javax/media/j3d/Sound.java b/src/classes/share/javax/media/j3d/Sound.java index a11d8a9..ac70b9b 100644 --- a/src/classes/share/javax/media/j3d/Sound.java +++ b/src/classes/share/javax/media/j3d/Sound.java @@ -440,7 +440,26 @@ public abstract class Sound extends Leaf { */ public static final int INFINITE_LOOPS = -1; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_CHANNELS_USED_READ, + ALLOW_CONT_PLAY_READ, + ALLOW_DURATION_READ, + ALLOW_ENABLE_READ, + ALLOW_INITIAL_GAIN_READ, + ALLOW_IS_PLAYING_READ, + ALLOW_IS_READY_READ, + ALLOW_LOOP_READ, + ALLOW_MUTE_READ, + ALLOW_PAUSE_READ, + ALLOW_PRIORITY_READ, + ALLOW_RATE_SCALE_FACTOR_READ, + ALLOW_RELEASE_READ, + ALLOW_SCHEDULING_BOUNDS_READ, + ALLOW_SOUND_DATA_READ + }; + + /** * Constructs and initializes a new Sound node using default * parameters. The following defaults values are used: @@ -460,6 +479,8 @@ public abstract class Sound extends Leaf { * </ul> */ public Sound() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -471,6 +492,9 @@ public abstract class Sound extends Leaf { * @param initialGain overall amplitude scale factor applied to sound source */ public Sound(MediaContainer soundData, float initialGain) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SoundRetained)this.retained).setSoundData(soundData); ((SoundRetained)this.retained).setInitialGain(initialGain); } @@ -498,6 +522,9 @@ public abstract class Sound extends Leaf { boolean enable, Bounds region, float priority ) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SoundRetained)this.retained).setSoundData(soundData); ((SoundRetained)this.retained).setInitialGain(initialGain); ((SoundRetained)this.retained).setLoop(loopCount); @@ -533,6 +560,9 @@ public abstract class Sound extends Leaf { Bounds region, float priority, float rateFactor ) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SoundRetained)this.retained).setSoundData(soundData); ((SoundRetained)this.retained).setInitialGain(initialGain); ((SoundRetained)this.retained).setLoop(loopCount); diff --git a/src/classes/share/javax/media/j3d/SoundRetained.java b/src/classes/share/javax/media/j3d/SoundRetained.java index 5d6e744..f0b2145 100644 --- a/src/classes/share/javax/media/j3d/SoundRetained.java +++ b/src/classes/share/javax/media/j3d/SoundRetained.java @@ -448,7 +448,7 @@ abstract class SoundRetained extends LeafRetained if (debugFlag) debugPrint("setSchedulingBounds for a NULL region"); } - // TODO: test that this works - could not new Bounds() since + // XXXX: test that this works - could not new Bounds() since // Bounds is an abstract class and can't be instantiated dispatchAttribChange(BOUNDS_DIRTY_BIT, region); if (source != null && source.isLive()) { @@ -501,7 +501,7 @@ abstract class SoundRetained extends LeafRetained } else { boundingLeaf = null; } - // TODO: since BoundingLeaf constructor only takes Bounds + // XXXX: since BoundingLeaf constructor only takes Bounds // test if region passed into dispatchAttribChange correctly. dispatchAttribChange(BOUNDING_LEAF_DIRTY_BIT, region); if (source != null && source.isLive()) { @@ -628,7 +628,7 @@ abstract class SoundRetained extends LeafRetained } loadedAtoms[atomCount-1] = atom; // store reference to new atom // all atoms sample durations SHOULD be the same so store it in node - this.duration = atom.sampleLength; // TODO: refine later? in ms + this.duration = atom.sampleLength; // XXXX: refine later? in ms } else { // atom is NOT loaded or has been unloaded; remove from list if (atomCount == 0) @@ -1004,7 +1004,7 @@ abstract class SoundRetained extends LeafRetained ms.inImmCtx = inImmCtx; ms.setSoundData(getSoundData()); -// TODO: copy ms.atoms array from this.atoms +// XXXX: copy ms.atoms array from this.atoms ms.parent = parent; ms.inSharedGroup = false; @@ -1136,7 +1136,7 @@ abstract class SoundRetained extends LeafRetained super.clearLive(s); -// TODO: if (inSharedGroup) +// XXXX: if (inSharedGroup) if (s.inSharedGroup) { for (int i=0; i<s.keys.length; i++) { @@ -1195,7 +1195,7 @@ abstract class SoundRetained extends LeafRetained /* // This makes passed in sound look just like this sound // QUESTION: DOesn't appread to be called -// TODO: ...if so, remove... +// XXXX: ...if so, remove... synchronized void update(SoundRetained sound) { if (debugFlag) debugPrint("Sound.update ******** entered ***** this = " + this + @@ -1219,13 +1219,13 @@ abstract class SoundRetained extends LeafRetained // QUESTION: With code below, no sound schedulingRegion found // sound.schedulingRegion = schedulingRegion; // sound.boundingLeaf = boundingLeaf; -// TODO: clone of region used in Traverse code, why not here??? +// XXXX: clone of region used in Traverse code, why not here??? // if (schedulingRegion != null) // sound.schedulingRegion = (Bounds)schedulingRegion.clone(); -// TODO: BoundingLeafRetained boundingLeaf ... +// XXXX: BoundingLeafRetained boundingLeaf ... // WHAT ABOUT transformedRegion?? -// TODO: Update ALL fields +// XXXX: Update ALL fields // ALL THE BELOW USED TO COMMENTED OUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvv sound.sampleLength = sampleLength; sound.loopStartOffset = loopStartOffset; diff --git a/src/classes/share/javax/media/j3d/SoundScheduler.java b/src/classes/share/javax/media/j3d/SoundScheduler.java index 778c366..15981b6 100644 --- a/src/classes/share/javax/media/j3d/SoundScheduler.java +++ b/src/classes/share/javax/media/j3d/SoundScheduler.java @@ -102,7 +102,7 @@ class SoundScheduler extends J3dStructure { * This prioritized sound list is NO longer re-create instead sounds * are insert, shuffled or removed as messages are processed. */ - // TODO: (Enhancement) should have a seperate list for + // XXXX: (Enhancement) should have a seperate list for // background sound and a list for positional sounds ArrayList prioritizedSounds = new ArrayList(); @@ -322,7 +322,7 @@ class SoundScheduler extends J3dStructure { auralAttribsChanged = true; } else if (node instanceof ViewPlatformRetained) { - // TODO: don't support multiple viewPlatforms per scheduler + // XXXX: don't support multiple viewPlatforms per scheduler /* // useful for resetting VP ?? addViewPlatform((ViewPlatformRetained) node); @@ -753,7 +753,7 @@ class SoundScheduler extends J3dStructure { debugPrint(".deactivate()"); // - // TODO: The following code is clearly erroneous. + // XXXX: The following code is clearly erroneous. // The indendation, along with the 2nd test of // "if (debugFlag)" in the else clause, suggests that // the intent was to make the else clause apply to @@ -858,7 +858,7 @@ class SoundScheduler extends J3dStructure { return; } - // TODO: Does not support multiple canvases per view, thus + // XXXX: Does not support multiple canvases per view, thus // multiple GraphicsContext3Ds // QUESTION: what does that mean for sound - // being applied to only ONE graphics context? @@ -929,7 +929,7 @@ class SoundScheduler extends J3dStructure { int numActiveSounds = 0; if (debugFlag) debugPrint(" renderChanges begun"); - // TODO: BUG?? should wait if audioDevice is NULL or nSounds = 0 + // XXXX: BUG?? should wait if audioDevice is NULL or nSounds = 0 // when a new sound is added or deleted from list, or // when the audioDevice is set into PhysicalEnvironment @@ -955,7 +955,7 @@ class SoundScheduler extends J3dStructure { if (debugFlag) debugPrint(" "+ nIntersected + " active SoundScapes found"); - // TODO: (Performance) calling clone everytime, even + // XXXX: (Performance) calling clone everytime, even // though closest AA has NOT changed, is expensive aaRetained = (AuralAttributesRetained) (findClosestAAttribs(nIntersected)).clone(); @@ -1007,7 +1007,7 @@ class SoundScheduler extends J3dStructure { if (!prioritizedSounds.isEmpty()) { prioritizedSounds.clear(); } - // TODO: sync soundStructure sound list + // XXXX: sync soundStructure sound list UnorderList retainedSounds = universe.soundStructure.getSoundList(view); // QUESTION: what is in this sound list?? // mirror node or actual node??? @@ -1020,7 +1020,7 @@ class SoundScheduler extends J3dStructure { addPrioritizedSound((SoundRetained)retainedSounds.get(i)); nRetainedSounds++; } - // TODO: sync canvases + // XXXX: sync canvases Enumeration canvases = view.getAllCanvas3Ds(); while (canvases.hasMoreElements()) { Canvas3D canvas = (Canvas3D)canvases.nextElement(); @@ -1300,7 +1300,7 @@ class SoundScheduler extends J3dStructure { if (attribs != null) { synchronized (attribs) { /* - // TODO: remove use of aaDirty from AuralAttrib node + // XXXX: remove use of aaDirty from AuralAttrib node if ((attribs != lastAA) || attribs.aaDirty) */ if (debugFlag) { @@ -1476,7 +1476,7 @@ class SoundScheduler extends J3dStructure { // Sounds that have finished playing are not put into list if ((soundAtom.status == SoundSchedulerAtom.SOUND_COMPLETE) && (soundAtom.enabled != SoundSchedulerAtom.PENDING_ON )) { - // TODO:/QUESTION test for immediate mode (?) + // XXXX:/QUESTION test for immediate mode (?) // Unless the sound has been re-started, there's no need // to process sound the finished playing the last time thru @@ -2050,7 +2050,7 @@ class SoundScheduler extends J3dStructure { synchronized (prioritizedSounds) { nAtoms = prioritizedSounds.size(); for (int i=0; i<nAtoms; i++) { - // TODO: (Enhancement) Get all sound node fields here + // XXXX: (Enhancement) Get all sound node fields here // and store locally for performance soundAtom = (SoundSchedulerAtom)prioritizedSounds.get(i); mirSound = soundAtom.sound; @@ -2070,7 +2070,7 @@ class SoundScheduler extends J3dStructure { // check to see if aural attributes changed and have to be updated // must be done before list of sound processed so that Aural Attributes // that affect Sound fields can be set in AudioDevice - // TODO: this is not effient if auralAttribs always the same + // XXXX: this is not effient if auralAttribs always the same if (sound.getInImmCtx()) { if (graphicsCtx !=null && graphicsCtx.auralAttributes !=null) { aaImmed = (AuralAttributesRetained) @@ -2154,7 +2154,7 @@ class SoundScheduler extends J3dStructure { case SoundSchedulerAtom.MAKE_SILENT: // change status to silent AFTER calling render so // that a currently audible sound will be muted. - // TODO: why set status AFTER?? + // XXXX: why set status AFTER?? render(false, soundAtom, attribs); soundAtom.status = SoundSchedulerAtom.SOUND_SILENT; numActiveSounds++; @@ -2373,7 +2373,7 @@ class SoundScheduler extends J3dStructure { if (debugFlag) debugPrint("silenceAll " + nAtoms + " Sounds"); for (int i=0; i<nAtoms; i++) { - // TODO: (Enhancement) Get all sound node fields here + // XXXX: (Enhancement) Get all sound node fields here // and store locally for performance soundAtom = (SoundSchedulerAtom)prioritizedSounds.get(i); mirSound = soundAtom.sound; @@ -2430,7 +2430,7 @@ class SoundScheduler extends J3dStructure { if (debugFlag) debugPrint(":pauseAll " + nAtoms + " Sounds"); for (int i=0; i<nAtoms; i++) { - // TODO: (Enhancement) Get all sound node fields here + // XXXX: (Enhancement) Get all sound node fields here // and store locally for performance SoundSchedulerAtom soundAtom = (SoundSchedulerAtom)prioritizedSounds.get(i); @@ -2475,7 +2475,7 @@ class SoundScheduler extends J3dStructure { debugPrint(": resumeAll " + nAtoms + " Sounds "); for (int i=0; i<nAtoms; i++) { - // TODO: (Enhancement) Get all sound node fields here + // XXXX: (Enhancement) Get all sound node fields here // and store locally for performance SoundSchedulerAtom soundAtom = (SoundSchedulerAtom)prioritizedSounds.get(i); @@ -2528,7 +2528,7 @@ class SoundScheduler extends J3dStructure { debugPrint(": stopAll " + nAtoms + " Sounds "); for (int i=0; i<nAtoms; i++) { - // TODO: (Enhancement) Get all sound node fields here + // XXXX: (Enhancement) Get all sound node fields here // and store locally for performance SoundSchedulerAtom soundAtom = (SoundSchedulerAtom)prioritizedSounds.get(i); @@ -2547,7 +2547,7 @@ class SoundScheduler extends J3dStructure { debugPrint(".stopAllSounds exited"); } - // TODO: Mute All Sounds, complementary to Stop All Sounds + // XXXX: Mute All Sounds, complementary to Stop All Sounds // "should return from run loop - but simply WAIT until sounds // are unmuted. " ??? @@ -2618,7 +2618,7 @@ class SoundScheduler extends J3dStructure { // Set Transform /* - // TODO: per sound tranforms can now be passed to AudioDevice + // XXXX: per sound tranforms can now be passed to AudioDevice // modify and execute the code below // MoveAppBoundingLeaf > ~/Current/MoveAppBoundingLeaf.outted, @@ -2652,7 +2652,7 @@ class SoundScheduler extends J3dStructure { } audioDevice3D.setVworldXfrm(index, xform); soundAtom.clearStateDirtyFlag( SoundRetained.XFORM_DIRTY_BIT); - // TODO: make sure position and direction are already transformed and stored + // XXXX: make sure position and direction are already transformed and stored // into xformXxxxxxx fields. } // ^^^^^^^^^^^^^^^^^^^^^ @@ -2679,7 +2679,7 @@ class SoundScheduler extends J3dStructure { ConeSoundRetained cn = (ConeSoundRetained)mirrorPtSound; ConeSoundRetained cnSound = (ConeSoundRetained)mirrorPtSound.sgSound; if (updateAll || - // TODO: test for XFORM_DIRTY only in for 1.2 + // XXXX: test for XFORM_DIRTY only in for 1.2 soundAtom.testDirtyFlag(soundAtom.attribsDirty, (SoundRetained.DIRECTION_DIRTY_BIT | SoundRetained.XFORM_DIRTY_BIT) ) ) { @@ -2992,7 +2992,7 @@ class SoundScheduler extends J3dStructure { soundAtom.sampleLength = duration; soundAtom.loopLength = soundAtom.sampleLength; - // TODO: for most this will be 0 but not all + // XXXX: for most this will be 0 but not all soundAtom.loopStartOffset = 0; soundAtom.attackLength = 0; // portion of sample before loop section soundAtom.releaseLength = 0; // portion of sample after loop section @@ -3027,7 +3027,7 @@ class SoundScheduler extends J3dStructure { atomFound++; // orginal app node pass into method // QUESTION: is mirror node still correct? - // TODO: ensure only mirror nodes passed into method + // XXXX: ensure only mirror nodes passed into method if (atomFound == nthInstance) { returnAtom = soundAtom; break; diff --git a/src/classes/share/javax/media/j3d/SoundSchedulerAtom.java b/src/classes/share/javax/media/j3d/SoundSchedulerAtom.java index 1ebf628..a4dcccc 100644 --- a/src/classes/share/javax/media/j3d/SoundSchedulerAtom.java +++ b/src/classes/share/javax/media/j3d/SoundSchedulerAtom.java @@ -241,7 +241,7 @@ class SoundSchedulerAtom extends Object { } -// TODO: remove this +// XXXX: remove this // just set the state after debug no longer needed void setEnableState(int state) { enabled = state; @@ -269,7 +269,7 @@ class SoundSchedulerAtom extends Object { } } -// TODO: remove this +// XXXX: remove this // just set the state after debug no longer needed void setMuteState(int state) { muted = state; @@ -297,7 +297,7 @@ class SoundSchedulerAtom extends Object { } } -// TODO: remove this +// XXXX: remove this // just set the state after debug no longer needed void setPauseState(int state) { paused = state; @@ -603,8 +603,8 @@ class SoundSchedulerAtom extends Object { return (action); } // end of calcInactiveSchedAction -// TODO isPLaying -// TODO setLoadingState +// XXXX: isPLaying +// XXXX: setLoadingState // Debug print mechanism for Sound nodes static final boolean debugFlag = false; diff --git a/src/classes/share/javax/media/j3d/SoundStructure.java b/src/classes/share/javax/media/j3d/SoundStructure.java index 90fdba5..e2407b6 100644 --- a/src/classes/share/javax/media/j3d/SoundStructure.java +++ b/src/classes/share/javax/media/j3d/SoundStructure.java @@ -99,7 +99,7 @@ class SoundStructure extends J3dStructure { break; case J3dMessage.SOUNDSCAPE_CHANGED: case J3dMessage.AURALATTRIBUTES_CHANGED: - // TODO: this needs to be changed + // XXXX: this needs to be changed changeNodeAttrib(m); break; case J3dMessage.TRANSFORM_CHANGED: @@ -115,7 +115,7 @@ class SoundStructure extends J3dStructure { case J3dMessage.VIEWSPECIFICGROUP_CHANGED: updateViewSpecificGroupChanged(m); break; - // TODO: case J3dMessage.BOUNDINGLEAF_CHANGED + // XXXX: case J3dMessage.BOUNDINGLEAF_CHANGED } /* @@ -187,7 +187,7 @@ class SoundStructure extends J3dStructure { } } /* - // TODO: + // XXXX: if (node instanceof AuralAttributesRetained) { } else if (node instanceof ViewPlatformRetained) { @@ -326,7 +326,7 @@ class SoundStructure extends J3dStructure { if (debugFlag) debugPrint(" Sound node dirty bit = " + attribDirty); if ((attribDirty & SoundRetained.PRIORITY_DIRTY_BIT) > 0) { - // TODO: shuffle in SoundScheduler + // XXXX: shuffle in SoundScheduler /* shuffleSound((SoundRetained) node); */ @@ -346,7 +346,7 @@ class SoundStructure extends J3dStructure { /* } */ -// TODO: have no dirty flag for soundscape, just auralAttributes... +// XXXX: have no dirty flag for soundscape, just auralAttributes... // what if reference to AA changes in soundscape??? } @@ -400,7 +400,7 @@ class SoundStructure extends J3dStructure { View[] views = vpLists[i].getViewList(); for (int j=(views.length-1); j>=0; j--) { View v = (View)(views[j]); -// TODO: Shouldn't this be done with messages?? +// XXXX: Shouldn't this be done with messages?? v.soundScheduler.loadSound(sound, forceLoad); } } @@ -501,7 +501,7 @@ class SoundStructure extends J3dStructure { /* -// TODO: how is immediate mode handled? below code taken from SoundSchedule +// XXXX: how is immediate mode handled? below code taken from SoundSchedule // Don't know how we'll process immediate mode sounds; // Append immediate mode sounds to live sounds list if (graphicsCtx != null) { diff --git a/src/classes/share/javax/media/j3d/Soundscape.java b/src/classes/share/javax/media/j3d/Soundscape.java index b995bc9..2e61e42 100644 --- a/src/classes/share/javax/media/j3d/Soundscape.java +++ b/src/classes/share/javax/media/j3d/Soundscape.java @@ -72,7 +72,12 @@ public class Soundscape extends Leaf { public static final int ALLOW_ATTRIBUTES_WRITE = CapabilityBits.SOUNDSCAPE_ALLOW_ATTRIBUTES_WRITE; - /** + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_APPLICATION_BOUNDS_READ, + ALLOW_ATTRIBUTES_READ + }; + /** * Constructs and initializes a new Sound node using following * defaults: *<UL> application region: null (no active region)</UL> @@ -80,6 +85,8 @@ public class Soundscape extends Leaf { */ public Soundscape() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -90,6 +97,9 @@ public class Soundscape extends Leaf { */ public Soundscape(Bounds region, AuralAttributes attributes) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SoundscapeRetained)this.retained).setApplicationBounds(region); ((SoundscapeRetained)this.retained).setAuralAttributes(attributes); } diff --git a/src/classes/share/javax/media/j3d/SourceCodeShader.java b/src/classes/share/javax/media/j3d/SourceCodeShader.java new file mode 100644 index 0000000..b940255 --- /dev/null +++ b/src/classes/share/javax/media/j3d/SourceCodeShader.java @@ -0,0 +1,121 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The SourceCodeShader object is a shader that is defined using + * text-based source code. It is used to define the source code for + * both vertex and fragment shaders. The currently supported shading + * languages are Cg and GLSL. + * + * @see ShaderProgram + * + * @since Java 3D 1.4 + */ + +public class SourceCodeShader extends Shader { + + /** + * Not a public constructor, for internal use + */ + SourceCodeShader() { + } + + /** + * Constructs a new shader object of the specified shading + * language and shader type from the specified source string. + * + * @param shadingLanguage the specified shading language, one of: + * <code>SHADING_LANGUAGE_GLSL</code> or + * <code>SHADING_LANGUAGE_CG</code>. + * + * @param shaderType the shader type, one of: + * <code>SHADER_TYPE_VERTEX</code> or + * <code>SHADER_TYPE_FRAGMENT</code>. + * + * @param shaderSource the shader source code + * + * @exception NullPointerException if shaderSource is null. + */ + + public SourceCodeShader(int shadingLanguage, int shaderType, String shaderSource) { + super(shadingLanguage, shaderType); + if (shaderSource == null) { + throw new NullPointerException(); + } + ((SourceCodeShaderRetained)this.retained).initShaderSource(shaderSource); + } + + /** + * Retrieves the shader source string from this shader object. + * + * @return the shader source string. + */ + public String getShaderSource() { + return ((SourceCodeShaderRetained)this.retained).getShaderSource(); + } + + + /** + * Creates a retained mode SourceCodeShaderRetained object that this + * SourceCodeShader component object will point to. + */ + void createRetained() { + this.retained = new SourceCodeShaderRetained(); + this.retained.setSource(this); + // System.out.println("SourceCodeShader.createRetained()"); + } + + /** + * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) + */ + public NodeComponent cloneNodeComponent() { + SourceCodeShaderRetained scsRetained = (SourceCodeShaderRetained) retained; + + SourceCodeShader scs = new SourceCodeShader(scsRetained.getShadingLanguage(), + scsRetained.getShaderType(), + scsRetained.getShaderSource()); + scs.duplicateNodeComponent(this); + return scs; + } + + + /** + * Copies all node information from <code>originalNodeComponent</code> + * into the current node. This method is called from the + * <code>duplicateNode</code> method. This routine does + * the actual duplication of all "local data" (any data defined in + * this object). + * + * @param originalNodeComponent the original node to duplicate + * @param forceDuplicate when set to <code>true</code>, causes the + * <code>duplicateOnCloneTree</code> flag to be ignored. When + * <code>false</code>, the value of each node's + * <code>duplicateOnCloneTree</code> variable determines whether + * NodeComponent data is duplicated or copied. + * + * @see Node#cloneTree + * @see NodeComponent#setDuplicateOnCloneTree + */ + void duplicateAttributes(NodeComponent originalNodeComponent, + boolean forceDuplicate) { + super.duplicateAttributes(originalNodeComponent, forceDuplicate); + + String sc = ((SourceCodeShaderRetained) originalNodeComponent.retained).getShaderSource(); + + if (sc != null) { + ((SourceCodeShaderRetained) retained).setShaderSource(sc); + } + } + +} diff --git a/src/classes/share/javax/media/j3d/SourceCodeShaderRetained.java b/src/classes/share/javax/media/j3d/SourceCodeShaderRetained.java new file mode 100644 index 0000000..d415ae8 --- /dev/null +++ b/src/classes/share/javax/media/j3d/SourceCodeShaderRetained.java @@ -0,0 +1,85 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +package javax.media.j3d; + +/** + * The SourceCodeShaderRetained object is a shader that is defined using + * text-based source code. It is used to define the source code for + * both vertex and fragment shaders. The currently supported shading + * languages are Cg and GLSL. + */ + +class SourceCodeShaderRetained extends ShaderRetained { + + private String shaderSource = null; + + /** + * Constructs a new shader retained object of the specified shading + * language and shader type from the specified source string. + */ + + SourceCodeShaderRetained() { + } + + // This method is similar to setShaderSource(). + // To conform to j3d frame in retained creation, we will stick with method + // with init name. + final void initShaderSource(String shaderSource) { + this.shaderSource = shaderSource; + } + + final void set(int shadingLanguage, int shaderType, String shaderSource) { + this.shadingLanguage = shadingLanguage; + this.shaderType = shaderType; + this.shaderSource = shaderSource; + } + + /** + * Retrieves the shader source string from this shader object. + * + * @return the shader source string. + */ + final String getShaderSource() { + return shaderSource; + } + + final void setShaderSource(String shaderSource) { + this.shaderSource = shaderSource; + } + + synchronized void createMirrorObject() { + // System.out.println("SourceCodeShaderRetained : createMirrorObject"); + + if (mirror == null) { + SourceCodeShaderRetained mirrorSCS = new SourceCodeShaderRetained(); + mirror = mirrorSCS; + } + + initMirrorObject(); + } + + /** + * Initializes a mirror object. + */ + synchronized void initMirrorObject() { + mirror.source = source; + + ((SourceCodeShaderRetained) mirror).set(shadingLanguage, shaderType, shaderSource); + ((SourceCodeShaderRetained) mirror).shaderIds = null; + } + + synchronized void updateMirrorObject(int component, Object value) { + System.out.println("SourceCodeShader.updateMirrorObject not implemented yet!"); + } + +} diff --git a/src/classes/share/javax/media/j3d/SpotLight.java b/src/classes/share/javax/media/j3d/SpotLight.java index b8fc2fc..9f2900d 100644 --- a/src/classes/share/javax/media/j3d/SpotLight.java +++ b/src/classes/share/javax/media/j3d/SpotLight.java @@ -94,6 +94,13 @@ public class SpotLight extends PointLight { public static final int ALLOW_DIRECTION_READ = CapabilityBits.SPOT_LIGHT_ALLOW_DIRECTION_READ; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SPREAD_ANGLE_READ, + ALLOW_CONCENTRATION_READ, + ALLOW_DIRECTION_READ + }; + /** * Constructs a SpotLight node with default parameters. * The default values are as follows: @@ -104,6 +111,8 @@ public class SpotLight extends PointLight { * </ul> */ public SpotLight() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -124,6 +133,10 @@ public class SpotLight extends PointLight { float spreadAngle, float concentration) { super(color, position, attenuation); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SpotLightRetained)this.retained).initDirection(direction); ((SpotLightRetained)this.retained).initSpreadAngle(spreadAngle); ((SpotLightRetained)this.retained).initConcentration(concentration); @@ -148,6 +161,10 @@ public class SpotLight extends PointLight { float spreadAngle, float concentration) { super(lightOn, color, position, attenuation); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((SpotLightRetained)this.retained).initDirection(direction); ((SpotLightRetained)this.retained).initSpreadAngle(spreadAngle); ((SpotLightRetained)this.retained).initConcentration(concentration); diff --git a/src/classes/share/javax/media/j3d/Switch.java b/src/classes/share/javax/media/j3d/Switch.java index 28acc2a..359e365 100644 --- a/src/classes/share/javax/media/j3d/Switch.java +++ b/src/classes/share/javax/media/j3d/Switch.java @@ -64,6 +64,11 @@ public class Switch extends Group { */ public static final int CHILD_MASK = -3; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_SWITCH_READ + }; + /** * Constructs a Switch node with default parameters. * The default values are as follows: @@ -73,6 +78,8 @@ public class Switch extends Group { * </ul> */ public Switch() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -81,7 +88,10 @@ public class Switch extends Group { * @param whichChild the initial child selection index */ public Switch(int whichChild) { - ((SwitchRetained)this.retained).setWhichChild(whichChild, true); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((SwitchRetained)this.retained).setWhichChild(whichChild, true); } /** @@ -91,7 +101,10 @@ public class Switch extends Group { * @param childMask the initial child selection mask */ public Switch(int whichChild, BitSet childMask){ - ((SwitchRetained)this.retained).setWhichChild(whichChild, true); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((SwitchRetained)this.retained).setWhichChild(whichChild, true); ((SwitchRetained)this.retained).setChildMask(childMask); } diff --git a/src/classes/share/javax/media/j3d/TexCoordGeneration.java b/src/classes/share/javax/media/j3d/TexCoordGeneration.java index 2915a27..f19c34c 100644 --- a/src/classes/share/javax/media/j3d/TexCoordGeneration.java +++ b/src/classes/share/javax/media/j3d/TexCoordGeneration.java @@ -230,6 +230,14 @@ public class TexCoordGeneration extends NodeComponent { */ public static final int TEXTURE_COORDINATE_4 = 2; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ENABLE_READ, + ALLOW_FORMAT_READ, + ALLOW_MODE_READ, + ALLOW_PLANE_READ + }; + /** * Constructs a TexCoordGeneration object with default parameters. * The default values are as follows: @@ -245,6 +253,8 @@ public class TexCoordGeneration extends NodeComponent { */ public TexCoordGeneration() { // Just use the defaults + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -259,7 +269,10 @@ public class TexCoordGeneration extends NodeComponent { * @see Canvas3D#queryProperties */ public TexCoordGeneration(int genMode, int format) { - ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); ((TexCoordGenerationRetained)this.retained).initFormat(format); } @@ -276,7 +289,10 @@ public class TexCoordGeneration extends NodeComponent { * @see Canvas3D#queryProperties */ public TexCoordGeneration(int genMode, int format, Vector4f planeS) { - ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); ((TexCoordGenerationRetained)this.retained).initFormat(format); ((TexCoordGenerationRetained)this.retained).initPlaneS(planeS); } @@ -296,7 +312,10 @@ public class TexCoordGeneration extends NodeComponent { */ public TexCoordGeneration(int genMode, int format, Vector4f planeS, Vector4f planeT) { - ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); ((TexCoordGenerationRetained)this.retained).initFormat(format); ((TexCoordGenerationRetained)this.retained).initPlaneS(planeS); ((TexCoordGenerationRetained)this.retained).initPlaneT(planeT); @@ -317,7 +336,10 @@ public class TexCoordGeneration extends NodeComponent { */ public TexCoordGeneration(int genMode, int format, Vector4f planeS, Vector4f planeT, Vector4f planeR) { - ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); ((TexCoordGenerationRetained)this.retained).initFormat(format); ((TexCoordGenerationRetained)this.retained).initPlaneS(planeS); ((TexCoordGenerationRetained)this.retained).initPlaneT(planeT); @@ -343,7 +365,10 @@ public class TexCoordGeneration extends NodeComponent { public TexCoordGeneration(int genMode, int format, Vector4f planeS, Vector4f planeT, Vector4f planeR, Vector4f planeQ) { - ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TexCoordGenerationRetained)this.retained).initGenMode(genMode); ((TexCoordGenerationRetained)this.retained).initFormat(format); ((TexCoordGenerationRetained)this.retained).initPlaneS(planeS); ((TexCoordGenerationRetained)this.retained).initPlaneT(planeT); diff --git a/src/classes/share/javax/media/j3d/Text3D.java b/src/classes/share/javax/media/j3d/Text3D.java index af9e81d..c62fee4 100644 --- a/src/classes/share/javax/media/j3d/Text3D.java +++ b/src/classes/share/javax/media/j3d/Text3D.java @@ -206,6 +206,17 @@ public class Text3D extends Geometry { */ public static final int PATH_DOWN = 3; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_FONT3D_READ, + ALLOW_STRING_READ, + ALLOW_POSITION_READ, + ALLOW_ALIGNMENT_READ, + ALLOW_PATH_READ, + ALLOW_CHARACTER_SPACING_READ, + ALLOW_BOUNDING_BOX_READ + }; + /** * Constructs a Text3D object with default parameters. * The default values are as follows: @@ -219,6 +230,8 @@ public class Text3D extends Geometry { * </ul> */ public Text3D() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -227,6 +240,9 @@ public class Text3D extends Geometry { * @see Font3D */ public Text3D(Font3D font3D) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((Text3DRetained)this.retained).setFont3D(font3D); } @@ -239,6 +255,9 @@ public class Text3D extends Geometry { * @see Font3D */ public Text3D(Font3D font3D, String string) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((Text3DRetained)this.retained).setFont3D(font3D); ((Text3DRetained)this.retained).setString(string); } @@ -252,6 +271,9 @@ public class Text3D extends Geometry { * @see Font3D */ public Text3D(Font3D font3D, String string, Point3f position) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((Text3DRetained)this.retained).setFont3D(font3D); ((Text3DRetained)this.retained).setString(string); ((Text3DRetained)this.retained).setPosition(position); @@ -268,6 +290,9 @@ public class Text3D extends Geometry { */ public Text3D(Font3D font3D, String string, Point3f position, int alignment, int path) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((Text3DRetained)this.retained).setFont3D(font3D); ((Text3DRetained)this.retained).setString(string); ((Text3DRetained)this.retained).setPosition(position); diff --git a/src/classes/share/javax/media/j3d/Text3DRetained.java b/src/classes/share/javax/media/j3d/Text3DRetained.java index f446850..23c2ae6 100644 --- a/src/classes/share/javax/media/j3d/Text3DRetained.java +++ b/src/classes/share/javax/media/j3d/Text3DRetained.java @@ -472,7 +472,7 @@ class Text3DRetained extends GeometryRetained { // use its bounds and not localBounds. // bounds is actually a reference to // mirrorShape3D.source.localBounds. - // TODO : Should only need to update distinct localBounds. + // XXXX : Should only need to update distinct localBounds. s.getCombineBounds((BoundingBox)s.bounds); } @@ -838,45 +838,39 @@ class Text3DRetained extends GeometryRetained { super.markAsLive(); } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { - Transform3D tempT3D = VirtualUniverse.mc.getTransform3D(null); + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { + Transform3D tempT3D = new Transform3D(); GeometryArrayRetained geo = null; int sIndex = -1; PickShape newPS; - double x = 0, y = 0, z = 0; double minDist = Double.MAX_VALUE; - + double distance =0.0; + Point3d closestIPnt = new Point3d(); + for (int i=0; i < numChars; i++) { geo= geometryList[i]; if (geo != null) { tempT3D.invert(charTransforms[i]); newPS = pickShape.transform(tempT3D); - if (geo.intersect(newPS, dist, iPnt)) { - if (dist == null) { + if (geo.intersect(newPS, iInfo, flags, iPnt)) { + if (flags == 0) { return true; } - if (dist[0] < minDist) { + distance = newPS.distance(iPnt); + if (distance < minDist) { sIndex = i; - minDist = dist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minDist = distance; + closestIPnt.set(iPnt); } } } } - FreeListManager.freeObject(FreeListManager.TRANSFORM3D, tempT3D); - if (sIndex >= 0) { // We need to transform iPnt to the vworld to compute the actual distance. // In this method we'll transform iPnt by its char. offset. Shape3D will // do the localToVworld transform. - iPnt.x = x; - iPnt.y = y; - iPnt.z = z; - dist[0] = minDist; + iPnt.set(closestIPnt); charTransforms[sIndex].transform(iPnt); return true; } diff --git a/src/classes/share/javax/media/j3d/Texture.java b/src/classes/share/javax/media/j3d/Texture.java index 4eaae1e..7e28ef8 100644 --- a/src/classes/share/javax/media/j3d/Texture.java +++ b/src/classes/share/javax/media/j3d/Texture.java @@ -534,6 +534,22 @@ public abstract class Texture extends NodeComponent { */ public static final int ANISOTROPIC_SINGLE_VALUE = 1; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_ANISOTROPIC_FILTER_READ, + ALLOW_BOUNDARY_COLOR_READ, + ALLOW_BOUNDARY_MODE_READ, + ALLOW_ENABLE_READ, + ALLOW_FILTER4_READ, + ALLOW_FILTER_READ, + ALLOW_FORMAT_READ, + ALLOW_IMAGE_READ, + ALLOW_LOD_RANGE_READ, + ALLOW_MIPMAP_MODE_READ, + ALLOW_SHARPEN_TEXTURE_READ, + ALLOW_SIZE_READ + }; + /** * Constructs a Texture object with default parameters. * The default values are as follows: @@ -566,6 +582,8 @@ public abstract class Texture extends NodeComponent { */ public Texture() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -600,6 +618,9 @@ public abstract class Texture extends NodeComponent { (format != RGB) && (format != RGBA)) { throw new IllegalArgumentException(J3dI18N.getString("Texture1")); } + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); int widPower = getPowerOf2(width); if (widPower == -1) @@ -654,6 +675,9 @@ public abstract class Texture extends NodeComponent { throw new IllegalArgumentException(J3dI18N.getString("Texture1")); } + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + int widPower = getPowerOf2(width); if (widPower == -1) throw new IllegalArgumentException(J3dI18N.getString("Texture2")); @@ -1722,7 +1746,8 @@ public abstract class Texture extends NodeComponent { rt.initImage(i, image); } } - // TODO: clone new v1.2 attributes + // XXXX: clone new v1.2 attributes? + // NOTE: This sppears to have already been done } /** diff --git a/src/classes/share/javax/media/j3d/Texture2D.java b/src/classes/share/javax/media/j3d/Texture2D.java index 5fa7be7..dc5be50 100644 --- a/src/classes/share/javax/media/j3d/Texture2D.java +++ b/src/classes/share/javax/media/j3d/Texture2D.java @@ -131,7 +131,10 @@ public class Texture2D extends Texture { */ public static final int DETAIL_MODULATE = 1; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_DETAIL_TEXTURE_READ + }; /** * Constructs a texture object using default values. @@ -149,6 +152,9 @@ public class Texture2D extends Texture { */ public Texture2D() { super(); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + } /** @@ -173,6 +179,9 @@ public class Texture2D extends Texture { int height){ super(mipMapMode, format, width, height); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } @@ -209,6 +218,9 @@ public class Texture2D extends Texture { int boundaryWidth) { super(mipMapMode, format, width, height, boundaryWidth); + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** diff --git a/src/classes/share/javax/media/j3d/TextureAttributes.java b/src/classes/share/javax/media/j3d/TextureAttributes.java index d302e50..cb2f002 100644 --- a/src/classes/share/javax/media/j3d/TextureAttributes.java +++ b/src/classes/share/javax/media/j3d/TextureAttributes.java @@ -411,6 +411,15 @@ public class TextureAttributes extends NodeComponent { */ public static final int COMBINE_ONE_MINUS_SRC_ALPHA = 3; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_BLEND_COLOR_READ, + ALLOW_COLOR_TABLE_READ, + ALLOW_COMBINE_READ, + ALLOW_MODE_READ, + ALLOW_TRANSFORM_READ + }; + /** * Constructs a TextureAttributes object with default parameters. * The default values are as follows: @@ -441,6 +450,8 @@ public class TextureAttributes extends NodeComponent { * </ul> */ public TextureAttributes() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -474,7 +485,10 @@ public class TextureAttributes extends NodeComponent { throw new IllegalArgumentException(J3dI18N.getString("TextureAttributes9")); } - ((TextureAttributesRetained)this.retained).initTextureMode(textureMode); + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + + ((TextureAttributesRetained)this.retained).initTextureMode(textureMode); ((TextureAttributesRetained)this.retained).initTextureBlendColor(textureBlendColor); ((TextureAttributesRetained)this.retained).initTextureTransform(transform); ((TextureAttributesRetained)this.retained).initPerspectiveCorrectionMode(perspCorrectionMode); diff --git a/src/classes/share/javax/media/j3d/TextureAttributesRetained.java b/src/classes/share/javax/media/j3d/TextureAttributesRetained.java index c77e743..d4b0993 100644 --- a/src/classes/share/javax/media/j3d/TextureAttributesRetained.java +++ b/src/classes/share/javax/media/j3d/TextureAttributesRetained.java @@ -525,9 +525,11 @@ class TextureAttributesRetained extends NodeComponentRetained { int[] combineRgbFcn, int[] combineAlphaFcn, int combineRgbScale, int combineAlphaScale); - native void restoreBlend1Pass(long ctx); - native void updateBlend2Pass(long ctx); - + // NOTE: the following native methods are not used any more, since + // we no longer do simulated multi-pass by default + // (and with shaders, this won't work anyway) +// native void restoreBlend1Pass(long ctx); +// native void updateBlend2Pass(long ctx); void updateNative(Canvas3D cv, boolean simulate, int textureFormat) { @@ -653,31 +655,31 @@ class TextureAttributesRetained extends NodeComponentRetained { case TextureAttributes.COMBINE: case TextureAttributes.REPLACE: cv.setBlendFunc(cv.ctx, - TransparencyAttributesRetained.BLEND_ONE, - TransparencyAttributesRetained.BLEND_ZERO); + TransparencyAttributes.BLEND_ONE, + TransparencyAttributes.BLEND_ZERO); break; case TextureAttributes.MODULATE: cv.setBlendFunc(cv.ctx, - TransparencyAttributesRetained.BLEND_DST_COLOR, - TransparencyAttributesRetained.BLEND_ZERO); + TransparencyAttributes.BLEND_DST_COLOR, + TransparencyAttributes.BLEND_ZERO); break; case TextureAttributes.DECAL: if (textureFormat == Texture.RGBA) { cv.setBlendFunc(cv.ctx, - TransparencyAttributesRetained.BLEND_SRC_ALPHA, - TransparencyAttributesRetained.BLEND_ONE_MINUS_SRC_ALPHA); + TransparencyAttributes.BLEND_SRC_ALPHA, + TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA); } else { cv.setBlendFunc(cv.ctx, - TransparencyAttributesRetained.BLEND_ONE, - TransparencyAttributesRetained.BLEND_ZERO); + TransparencyAttributes.BLEND_ONE, + TransparencyAttributes.BLEND_ZERO); } break; case TextureAttributes.BLEND: cv.setBlendColor(cv.ctx, textureBlendColor.x, textureBlendColor.y, textureBlendColor.z, textureBlendColor.w); cv.setBlendFunc(cv.ctx, - TransparencyAttributesRetained.BLEND_CONSTANT_COLOR, - TransparencyAttributesRetained.BLEND_ONE_MINUS_SRC_COLOR); + TransparencyAttributes.BLEND_CONSTANT_COLOR, + TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR); break; } } diff --git a/src/classes/share/javax/media/j3d/TextureBin.java b/src/classes/share/javax/media/j3d/TextureBin.java index 7145adf..3e1c91f 100644 --- a/src/classes/share/javax/media/j3d/TextureBin.java +++ b/src/classes/share/javax/media/j3d/TextureBin.java @@ -27,10 +27,10 @@ class TextureBin extends Object implements ObjectUpdate { TextureUnitStateRetained [] texUnitState = null; // last active texture unit - int lastActiveTexUnitIndex; + private int lastActiveTexUnitIndex; // number of active texture unit - int numActiveTexUnit; + private int numActiveTexUnit; /** * The RenderBin for this object @@ -38,11 +38,21 @@ class TextureBin extends Object implements ObjectUpdate { RenderBin renderBin = null; /** - * The AttribureBin that this TextureBin resides + * The EnvironmentSet that this TextureBin resides + */ + EnvironmentSet environmentSet = null; + + /** + * The AttributeBin that this TextureBin resides */ AttributeBin attributeBin = null; /** + * The ShaderBin that this TextureBin resides + */ + ShaderBin shaderBin = null; + + /** * The references to the next and previous TextureBins in the * list. */ @@ -172,7 +182,6 @@ class TextureBin extends Object implements ObjectUpdate { int i, j; boolean foundDisableUnit = false; numActiveTexUnit = 0; - boolean d3dBlendMode = false; lastActiveTexUnitIndex = 0; boolean soleUser = ((tbFlag & TextureBin.SOLE_USER) != 0); TextureRetained prevFirstTexture = null; @@ -321,11 +330,13 @@ class TextureBin extends Object implements ObjectUpdate { } - // track the last active texture unit - // and the total number of active texture unit + // Track the last active texture unit and the total number + // of active texture units. Note that this total number + // now includes disabled units so that there is always + // a one-to-one mapping. We no longer remap texture units. if (texUnitState[i].isTextureEnabled()) { - numActiveTexUnit++; lastActiveTexUnitIndex = i; + numActiveTexUnit = i + 1; if (foundDisableUnit) { @@ -337,7 +348,7 @@ class TextureBin extends Object implements ObjectUpdate { foundDisableUnit = true; } } - } + } // check to see if the TextureBin sorting criteria is // modified for this textureBin; if yes, mark that @@ -698,12 +709,14 @@ class TextureBin extends Object implements ObjectUpdate { tbFlag |= TextureBin.CONTIGUOUS_ACTIVE_UNITS; for (int i = 0; i < texUnitState.length; i++) { - // track the last active texture unit - // and the total number of active texture unit + // Track the last active texture unit and the total number + // of active texture units. Note that this total number + // now includes disabled units so that there is always + // a one-to-one mapping. We no longer remap texture units. if (texUnitState[i] != null && texUnitState[i].isTextureEnabled()) { - numActiveTexUnit++; lastActiveTexUnitIndex = i; + numActiveTexUnit = i + 1; if (foundDisableUnit) { @@ -754,7 +767,7 @@ class TextureBin extends Object implements ObjectUpdate { // sorted transparency if (transparentRMList == null && (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || - attributeBin.environmentSet.lightBin.geometryBackground != null)) { + environmentSet.lightBin.geometryBackground != null)) { // System.out.println("========> addTransparentTextureBin "+this); transparentRMList = addAll(transparentRenderMoleculeMap, addTransparentRMs, transparentRMList, false); @@ -895,7 +908,7 @@ class TextureBin extends Object implements ObjectUpdate { } - // TODO: Could the analysis be done during insertRenderMolecule? + // XXXX: Could the analysis be done during insertRenderMolecule? // Return the head of the list, // if the insertion occurred at beginning of the list RenderMolecule insertRenderMolecule(RenderMolecule r, @@ -1046,7 +1059,7 @@ class TextureBin extends Object implements ObjectUpdate { } // If the renderMolecule removed is not opaque then .. if (!r.isOpaqueOrInOG && transparentRMList == null && (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || - attributeBin.environmentSet.lightBin.geometryBackground != null)) { + environmentSet.lightBin.geometryBackground != null)) { renderBin.removeTransparentObject(this); } // If the rm removed is the one that is referenced in the tinfo @@ -1065,12 +1078,11 @@ class TextureBin extends Object implements ObjectUpdate { renderBin.removeTextureBin(this); } - attributeBin.removeTextureBin(this); + shaderBin.removeTextureBin(this); texUnitState = null; } } - /** * This method is called to update the state for this * TextureBin. This is only applicable in the single-pass case. @@ -1078,28 +1090,48 @@ class TextureBin extends Object implements ObjectUpdate { * state update. */ void updateAttributes(Canvas3D cv, int pass) { - + boolean dirty = ((cv.canvasDirty & (Canvas3D.TEXTUREBIN_DIRTY| Canvas3D.TEXTUREATTRIBUTES_DIRTY)) != 0); - if (cv.textureBin == this && !dirty) { return; } cv.textureBin = this; - + // save the current number of active texture unit so as // to be able to reset the one that is not enabled in this bin int lastActiveTexUnitIdx = -1; - // set the number active texture unit in Canvas3D - cv.setNumActiveTexUnit(numActiveTexUnit); + // Get the number of available texture units; this depends on + // whether or not shaders are being used. + boolean useShaders = (shaderBin.shaderProgram != null); + int availableTextureUnits = + useShaders ? cv.maxTextureImageUnits : cv.maxTextureUnits; + + // If the number of active texture units is greater than the number of + // supported units, and we don't allow simulated multi-texture, then we + // need to set a flag indicating that the texture units are invalid. + boolean disableTexture = false; + + if (pass < 0 && numActiveTexUnit > availableTextureUnits) { + disableTexture = true; +// System.err.println("*** TextureBin : number of texture units exceeded"); + } + + // set the number active texture unit in Canvas3D + if (disableTexture) { + cv.setNumActiveTexUnit(0); + } + else { + cv.setNumActiveTexUnit(numActiveTexUnit); + } // state update - if (numActiveTexUnit <= 0) { - if (cv.getLastActiveTexUnit() >= 0) { + if (numActiveTexUnit <= 0 || disableTexture) { + if (cv.getLastActiveTexUnit() >= 0) { // no texture units enabled // when the canvas supports multi texture units, @@ -1117,20 +1149,8 @@ class TextureBin extends Object implements ObjectUpdate { cv.setLastActiveTexUnit(-1); } } else if (pass < 0) { - int j = 0; - boolean oneToOneMapping; - - if ((pass == USE_VERTEXARRAY) || VirtualUniverse.mc.isD3D()) { - // d3d or when the texUnitStateMap requires more texture - // units than what is supported by the canvas, then - // we'll need a compact texture unit mapping, that is, - // only the enabled texUnitStates will be mapped to - // texture units. And as a matter of fact, the - // render atoms will be rendered as vertex array. - oneToOneMapping = false; - } else { - oneToOneMapping = true; - } + + int j = 0; for (int i = 0; i < texUnitState.length; i++) { @@ -1156,24 +1176,13 @@ class TextureBin extends Object implements ObjectUpdate { // unit to a texture unit state lastActiveTexUnitIdx = j; - cv.setTexUnitStateMap(i, j++); - - - } else if (oneToOneMapping) { - // one to one mapping is needed when display list - // is used to render multi-textured geometries, - // since when display list is created, the texture - // unit state to texture unit mapping is based on - // the geometry texCoordMap only. At render time, - // the texture unit state enable flags could have - // been changed. In keeping a one to one mapping, - // we'll not need to rebuild the display list + } else { if (j <= cv.getLastActiveTexUnit()) { cv.resetTexture(cv.ctx, j); } - - cv.setTexUnitStateMap(i, j++); } + + j++; } // make sure to disable the remaining texture units @@ -1196,7 +1205,7 @@ class TextureBin extends Object implements ObjectUpdate { cv.activeTextureUnit(cv.ctx, 0); } else { - // update the last active texture unit state + // update the last active texture unit state if (dirty || cv.texUnitState[0].mirror == null || cv.texUnitState[0].mirror != texUnitState[lastActiveTexUnitIndex].mirror) { @@ -1205,7 +1214,6 @@ class TextureBin extends Object implements ObjectUpdate { cv.texUnitState[0].mirror = texUnitState[lastActiveTexUnitIndex].mirror; - cv.setTexUnitStateMap(0, 0); cv.setLastActiveTexUnit(0); } } @@ -1222,46 +1230,43 @@ class TextureBin extends Object implements ObjectUpdate { void render(Canvas3D cv, Object rlist) { - boolean d3dBlendMode = false; cv.texLinearMode = false; /* System.out.println("TextureBin/render " + this + " numActiveTexUnit= " + numActiveTexUnit + - " numTexUnitSupported= " + cv.numTexUnitSupported); + " maxTextureUnits= " + cv.maxTextureUnits); */ // include this TextureBin to the to-be-updated state set in canvas cv.setStateToUpdate(Canvas3D.TEXTUREBIN_BIT, this); - - if ((texUnitState != null) && - VirtualUniverse.mc.isD3D()) { + + // For D3D - set the texLinearMode flag in the canvas if texcoord + // generation is enabled in object_linear mode for any texture unit. + if ((texUnitState != null) && VirtualUniverse.mc.isD3D()) { TextureUnitStateRetained tus; - // use multi-pass if one of the stage use blend mode for (int i = 0; i < texUnitState.length; i++) { tus = texUnitState[i]; - if ((tus != null) && - tus.isTextureEnabled()) { - if (tus.needBlend2Pass(cv)) { - d3dBlendMode = true; - } + if ((tus != null) && tus.isTextureEnabled()) { if ((tus.texGen != null) && - (tus.texGen.genMode == - TexCoordGeneration.OBJECT_LINEAR)) { + (tus.texGen.genMode == TexCoordGeneration.OBJECT_LINEAR)) { cv.texLinearMode = true; } } } - } + } + + // If shaders are not being used, and if allowSimulatedMultiTexture + // property is set, then we will use simulated (multi-pass) + // multi-texture when the requested number of texture units exceeds + // the available number of texture units + boolean useShaders = (shaderBin.shaderProgram != null); + int availableTextureUnits = + useShaders ? cv.maxTextureImageUnits : cv.maxTextureUnits; - if ((numActiveTexUnit > cv.numTexUnitSupported) || - d3dBlendMode) { + if (!useShaders && (numActiveTexUnit > availableTextureUnits) && + VirtualUniverse.mc.allowSimulatedMultiTexture) { multiPassRender(cv, rlist); - } else if ((numActiveTexUnit > 0) && - !VirtualUniverse.mc.isD3D() && - (texUnitState.length > cv.numTexUnitSupported) && - ((tbFlag & TextureBin.CONTIGUOUS_ACTIVE_UNITS) == 0)) { - renderList(cv, USE_VERTEXARRAY, rlist); } else { renderList(cv, USE_DISPLAYLIST, rlist); } @@ -1286,7 +1291,7 @@ class TextureBin extends Object implements ObjectUpdate { */ void renderList(Canvas3D cv, int pass, RenderMolecule rlist) { - // bit mask of all attr fields that are equivalent across + // bit mask of all attr fields that are equivalent across // renderMolecules thro. ORing of invisible RMs. int combinedDirtyBits = 0; boolean rmVisible = true; @@ -1330,9 +1335,11 @@ class TextureBin extends Object implements ObjectUpdate { /** * multi rendering pass to simulate multiple texture units */ - void multiPassRender(Canvas3D cv, Object rlist) { + private void multiPassRender(Canvas3D cv, Object rlist) { + + assert VirtualUniverse.mc.allowSimulatedMultiTexture; - boolean startToSimulate = false; + boolean startToSimulate = false; boolean isFogEnabled = false; // No lazy download of texture for multi-pass, @@ -1366,7 +1373,7 @@ class TextureBin extends Object implements ObjectUpdate { // first check if there is fog in the path // if there is, then turn off fog now and turn it back on // for the last pass only - isFogEnabled = (attributeBin.environmentSet.fog != null); + isFogEnabled = (environmentSet.fog != null); TextureUnitStateRetained tus; @@ -1388,31 +1395,12 @@ class TextureBin extends Object implements ObjectUpdate { } } - if (!tus.needBlend2Pass(cv)) { - // turn on fog again in the last pass + // turn on fog again in the last pass - if (i == lastActiveTexUnitIndex && isFogEnabled) { - cv.setFogEnableFlag(cv.ctx, true); - } - renderList(cv, i, rlist); - - } else { - // D3d needs two passes to simulate Texture.Blend mode - tus.texAttrs.updateNative(cv, false, tus.texture.format); - renderList(cv, i, rlist); - - tus.texAttrs.updateBlend2Pass(cv.ctx); - - // turn on fog again in the last pass - - if (i == lastActiveTexUnitIndex && isFogEnabled) { - cv.setFogEnableFlag(cv.ctx, true); - } - renderList(cv, i, rlist); - - // restore original blend mode in case - tus.texAttrs.restoreBlend1Pass(cv.ctx); - } + if (i == lastActiveTexUnitIndex && isFogEnabled) { + cv.setFogEnableFlag(cv.ctx, true); + } + renderList(cv, i, rlist); } } @@ -1465,16 +1453,22 @@ class TextureBin extends Object implements ObjectUpdate { transparentRMList = head; if (transparentRMList == null && (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || - attributeBin.environmentSet.lightBin.geometryBackground != null)) { + environmentSet.lightBin.geometryBackground != null)) { renderBin.removeTransparentObject(this); } + // Issue 129: remove the RM's render atoms from the + // list of transparent render atoms + if ((renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) && + (environmentSet.lightBin.geometryBackground == null)) { + r.addRemoveTransparentObject(renderBin, false); + } } } HashMap renderMoleculeMap; RenderMolecule startList; // Now insert in the other bin - r.evalAlphaUsage(attributeBin.definingRenderingAttributes, texUnitState); + r.evalAlphaUsage(shaderBin.attributeBin.definingRenderingAttributes, texUnitState); r.isOpaqueOrInOG = r.isOpaque() ||r.inOrderedGroup; if (r.isOpaqueOrInOG) { startList = opaqueRMList; @@ -1565,14 +1559,20 @@ class TextureBin extends Object implements ObjectUpdate { // If transparent and not in bg geometry and inodepth sorted transparency if (transparentRMList == null&& (renderBin.transpSortMode == View.TRANSPARENCY_SORT_NONE || - attributeBin.environmentSet.lightBin.geometryBackground != null)) { + environmentSet.lightBin.geometryBackground != null)) { transparentRMList = startList; renderBin.addTransparentObject(this); } else { transparentRMList = startList; } - + // Issue 129: add the RM's render atoms to the list of + // transparent render atoms + // XXXX: do we need to resort the list after the add??? + if ((renderBin.transpSortMode == View.TRANSPARENCY_SORT_GEOMETRY) && + (environmentSet.lightBin.geometryBackground == null)) { + r.addRemoveTransparentObject(renderBin, true); + } } } @@ -1659,10 +1659,10 @@ class TextureBin extends Object implements ObjectUpdate { if (numEditingRenderMolecules == 0) { // if number of editing renderMolecules goes to 0, - // inform the attributeBin that this textureBin goes to + // inform the shaderBin that this textureBin goes to // zombie state - attributeBin.decrActiveTextureBin(); + shaderBin.decrActiveTextureBin(); } } @@ -1671,9 +1671,9 @@ class TextureBin extends Object implements ObjectUpdate { if (numEditingRenderMolecules == 0) { // if this textureBin is in zombie state, inform - // the attributeBin that this textureBin is activated again. + // the shaderBin that this textureBin is activated again. - attributeBin.incrActiveTextureBin(); + shaderBin.incrActiveTextureBin(); } numEditingRenderMolecules++; diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java index 190c43b..545ad3a 100644 --- a/src/classes/share/javax/media/j3d/TextureRetained.java +++ b/src/classes/share/javax/media/j3d/TextureRetained.java @@ -12,9 +12,9 @@ package javax.media.j3d; +import java.awt.image.BufferedImage; import java.util.*; import javax.vecmath.*; -import java.awt.image.DataBuffer; import java.awt.image.DataBufferByte; /** @@ -949,7 +949,7 @@ abstract class TextureRetained extends NodeComponentRetained { super.doSetLive(backgroundGroup, refCount); - // TODO: for now, do setLive for all the defined images. + // XXXX: for now, do setLive for all the defined images. // But in theory, we only need to setLive those within the // baseLevel and maximumLevel range. But then we'll need // setLive and clearLive image when the range changes. @@ -1366,8 +1366,9 @@ abstract class TextureRetained extends NodeComponentRetained { yoffset = image.height - yoffset - height; } else { + // Fix issue 132 imageData = ((DataBufferByte) - image.bImage[0].getData().getDataBuffer()).getData(); + ((BufferedImage)image.bImage[0]).getRaster().getDataBuffer()).getData(); // based on the yUp flag in the associated ImageComponent, // adjust the yoffset @@ -2031,12 +2032,12 @@ abstract class TextureRetained extends NodeComponentRetained { if (arg == null) { // no subimage info, so the entire image is to be updated info.entireImage = true; - - } else if ((arg.width >= width/2) && (arg.height >= height/2)) { - - // if the subimage dimension is close to the complete dimension, - // use the full update (it's more efficient) - info.entireImage = true; + // Fix issue 117 using ogl subimage always +// } else if ((arg.width >= width/2) && (arg.height >= height/2)) { +// +// // if the subimage dimension is close to the complete dimension, +// // use the full update (it's more efficient) +// info.entireImage = true; } else { info.entireImage = false; } @@ -2137,30 +2138,30 @@ abstract class TextureRetained extends NodeComponentRetained { mirrorTexture.addImageUpdateInfo(level, face, null); } else if ((component & IMAGES_CHANGED) != 0) { - + Object [] arg = (Object []) value; ImageComponent [] images = (ImageComponent[])arg[0]; - int face = ((Integer)arg[1]).intValue(); - + int face = ((Integer)arg[1]).intValue(); + for (int i = 0; i < images.length; i++) { - + // first remove texture from the userList of the current - // referencing image - if (mirrorTexture.images[face][i] != null) { - mirrorTexture.images[face][i].removeUser(mirror); - } - - // assign the new image and add texture to the userList - if (images[i] == null) { - mirrorTexture.images[face][i] = null; - } else { - mirrorTexture.images[face][i] = - (ImageComponentRetained)images[i].retained; - mirrorTexture.images[face][i].addUser(mirror); - } + // referencing image + if (mirrorTexture.images[face][i] != null) { + mirrorTexture.images[face][i].removeUser(mirror); + } + + // assign the new image and add texture to the userList + if (images[i] == null) { + mirrorTexture.images[face][i] = null; + } else { + mirrorTexture.images[face][i] = + (ImageComponentRetained)images[i].retained; + mirrorTexture.images[face][i].addUser(mirror); + } } mirrorTexture.updateResourceCreationMask(); - + // NOTE: the old images have to be removed from the // renderBins' NodeComponentList and new image have to be // added to the lists. This will be taken care of @@ -2169,7 +2170,7 @@ abstract class TextureRetained extends NodeComponentRetained { } else if ((component & BASE_LEVEL_CHANGED) != 0) { int level = ((Integer)value).intValue(); - + if (level < mirrorTexture.baseLevel) { // add texture to the userList of those new levels of diff --git a/src/classes/share/javax/media/j3d/TextureUnitState.java b/src/classes/share/javax/media/j3d/TextureUnitState.java index 635a499..fa9949c 100644 --- a/src/classes/share/javax/media/j3d/TextureUnitState.java +++ b/src/classes/share/javax/media/j3d/TextureUnitState.java @@ -66,7 +66,11 @@ public class TextureUnitState extends NodeComponent { public static final int ALLOW_STATE_WRITE = CapabilityBits.TEXTURE_UNIT_STATE_ALLOW_STATE_WRITE; - + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_STATE_READ + }; + /** * Constructs a TextureUnitState component object using defaults for all * state variables. All component object references are initialized @@ -74,6 +78,8 @@ public class TextureUnitState extends NodeComponent { */ public TextureUnitState() { // Just use default values + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -90,6 +96,8 @@ public class TextureUnitState extends NodeComponent { public TextureUnitState(Texture texture, TextureAttributes textureAttributes, TexCoordGeneration texCoordGeneration) { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); ((TextureUnitStateRetained)this.retained).initTexture(texture); ((TextureUnitStateRetained)this.retained).initTextureAttributes( diff --git a/src/classes/share/javax/media/j3d/TextureUnitStateRetained.java b/src/classes/share/javax/media/j3d/TextureUnitStateRetained.java index 86dce99..266ef12 100644 --- a/src/classes/share/javax/media/j3d/TextureUnitStateRetained.java +++ b/src/classes/share/javax/media/j3d/TextureUnitStateRetained.java @@ -592,17 +592,6 @@ class TextureUnitStateRetained extends NodeComponentRetained { return (texture != null && texture.enable); } - // use by D3D to simulate OGL blend mode using multi-pass - final boolean needBlend2Pass(Canvas3D cv) { - return ((texAttrs != null) && - VirtualUniverse.mc.isD3D() && - ((cv.textureExtendedFeatures & - Canvas3D.TEXTURE_LERP) == 0) && - (texAttrs.textureMode == TextureAttributes.BLEND) && - (texture.format != Texture.ALPHA) && - (texture.format != Texture.INTENSITY)); - } - void handleFrequencyChange(int bit) { switch (bit) { case TextureUnitState.ALLOW_STATE_WRITE: { diff --git a/src/classes/share/javax/media/j3d/TimerThread.java b/src/classes/share/javax/media/j3d/TimerThread.java index ae34fc6..a5f8878 100644 --- a/src/classes/share/javax/media/j3d/TimerThread.java +++ b/src/classes/share/javax/media/j3d/TimerThread.java @@ -33,7 +33,7 @@ class TimerThread extends Thread { // Wakeup {all?} Sound Scheduler{s} for every sample time reach // QUESTION: this sampling time is set to a very large value so Sound // Schedulers are not pinged often unless explicitly requested - // TODO: need a way to remove/null this condition when all + // XXXX: need a way to remove/null this condition when all // soundschedulers are halted private WakeupOnElapsedTime soundSchedCond = new WakeupOnElapsedTime(120000); // every 2 minutes @@ -61,7 +61,7 @@ class TimerThread extends Thread { } void addSoundSchedCond(long wakeupTime) { - // TODO: there are potentially multiple sound schedulers. + // XXXX: there are potentially multiple sound schedulers. // this code will force a wait up on ALL sound schedulers // even though only one needs to process the sound that // this wakeup condition is triggered by. diff --git a/src/classes/share/javax/media/j3d/Transform3D.java b/src/classes/share/javax/media/j3d/Transform3D.java index 69e5c62..99920d4 100644 --- a/src/classes/share/javax/media/j3d/Transform3D.java +++ b/src/classes/share/javax/media/j3d/Transform3D.java @@ -4588,7 +4588,7 @@ public class Transform3D { double[] svdScales = new double[3]; - // TODO: initialize to 0's if alread allocd? Should not have to, since + // XXXX: initialize to 0's if alread allocd? Should not have to, since // no operations depend on these being init'd to zero. int converged, negCnt=0; @@ -4833,7 +4833,7 @@ public class Transform3D { } } - // TODO: could eliminate use of t1 and t1 by making a new method which + // XXXX: could eliminate use of t1 and t1 by making a new method which // transposes and multiplies two matricies transpose_mat(u1, t1); transpose_mat(v1, t2); diff --git a/src/classes/share/javax/media/j3d/TransformGroup.java b/src/classes/share/javax/media/j3d/TransformGroup.java index 5aae8d2..a4b3f19 100644 --- a/src/classes/share/javax/media/j3d/TransformGroup.java +++ b/src/classes/share/javax/media/j3d/TransformGroup.java @@ -61,11 +61,18 @@ public class TransformGroup extends Group { public static final int ALLOW_TRANSFORM_WRITE = CapabilityBits.TRANSFORM_GROUP_ALLOW_TRANSFORM_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_TRANSFORM_READ + }; + /** * Constructs and initializes a TransformGroup using an * identity transform. */ public TransformGroup() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -74,11 +81,14 @@ public class TransformGroup extends Group { * @param t1 the transform3D object * @exception BadTransformException if the transform is not affine. */ - public TransformGroup(Transform3D t1) { + public TransformGroup(Transform3D t1) { if (!t1.isAffine()) { throw new BadTransformException(J3dI18N.getString("TransformGroup0")); } - + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); + ((TransformGroupRetained)this.retained).setTransform(t1); } diff --git a/src/classes/share/javax/media/j3d/TransformGroupData.java b/src/classes/share/javax/media/j3d/TransformGroupData.java index e41a086..e14d3c3 100644 --- a/src/classes/share/javax/media/j3d/TransformGroupData.java +++ b/src/classes/share/javax/media/j3d/TransformGroupData.java @@ -14,8 +14,8 @@ package javax.media.j3d; class TransformGroupData extends NodeData { // per path node data - // TODO: replace per path mirror objects with node data - // TODO: move other TransfromGroup related data here + // XXXX: replace per path mirror objects with node data + // XXXX: move other TransfromGroup related data here boolean switchDirty = false; // use for eliminate multiple updates and generate unique targets diff --git a/src/classes/share/javax/media/j3d/TransformGroupRetained.java b/src/classes/share/javax/media/j3d/TransformGroupRetained.java index 734a6b3..0672359 100644 --- a/src/classes/share/javax/media/j3d/TransformGroupRetained.java +++ b/src/classes/share/javax/media/j3d/TransformGroupRetained.java @@ -92,7 +92,7 @@ class TransformGroupRetained extends GroupRetained implements TargetsInterface // User copy. CachedTargets[] cachedTargets = null; - // Contains per path data, TODO: move to NodeRetained + // Contains per path data, XXXX: move to NodeRetained TransformGroupData[] perPathData = null; @@ -512,7 +512,7 @@ class TransformGroupRetained extends GroupRetained implements TargetsInterface int len; Object obj; - // TODO - optimization for targetThreads computation, require + // XXXX - optimization for targetThreads computation, require // cleanup in GroupRetained.doSetLive() //int savedTargetThreads = 0; //savedTargetThreads = s.transformTargetThreads; @@ -765,7 +765,7 @@ class TransformGroupRetained extends GroupRetained implements TargetsInterface } } } - // TODO: recontruct targetThreads + // XXXX: recontruct targetThreads } @@ -1155,7 +1155,7 @@ class TransformGroupRetained extends GroupRetained implements TargetsInterface // type is ignored here, only need for SharedGroup if (type == TargetsInterface.TRANSFORM_TARGETS) { - // TODO : For now we'll OR more than exact. + // XXXX : For now we'll OR more than exact. //targetThreads = localTargetThreads | childTargetThreads; targetThreads = targetThreads | childTargetThreads; if (parentTransformLink != null) { diff --git a/src/classes/share/javax/media/j3d/TransformStructure.java b/src/classes/share/javax/media/j3d/TransformStructure.java index 0232f98..0edc91c 100644 --- a/src/classes/share/javax/media/j3d/TransformStructure.java +++ b/src/classes/share/javax/media/j3d/TransformStructure.java @@ -182,7 +182,7 @@ class TransformStructure extends J3dStructure implements ObjectUpdate { } processCurrentLocalToVworld(); - // TODO: temporary -- processVwcBounds will be + // XXXX: temporary -- processVwcBounds will be // done in GeometryStructure if (objectList.size() > 0) { processGeometryAtomVwcBounds(); @@ -393,7 +393,7 @@ class TransformStructure extends J3dStructure implements ObjectUpdate { tg = (TransformGroupRetained)dirtyTransformGroups.get(i); // Check if the transformGroup is still alive - // TODO: This is a hack, should be fixed after EA + // XXXX: This is a hack, should be fixed after EA // Null pointer checking should be removed! // should call trans = tg.getCurrentChildLocalToVworld(key); synchronized(tg) { diff --git a/src/classes/share/javax/media/j3d/TransparencyAttributes.java b/src/classes/share/javax/media/j3d/TransparencyAttributes.java index 9e88f62..d5be231 100644 --- a/src/classes/share/javax/media/j3d/TransparencyAttributes.java +++ b/src/classes/share/javax/media/j3d/TransparencyAttributes.java @@ -14,18 +14,18 @@ package javax.media.j3d; /** * The TransparencyAttributes object defines all attributes affecting - * transparency of the object. The transparency attributes are:<P> - * <UL> - * <LI>Transparency mode - defines how transparency is applied to - * this Appearance component object:</LI><P> - * <UL> - * <LI>FASTEST - uses the fastest available method for transparency.</LI><P> - * <LI>NICEST - uses the nicest available method for transparency.</LI><P> - * <LI>SCREEN_DOOR - uses screen-door transparency. This is done using + * transparency of the object. The transparency attributes are:<p> + * <ul> + * <li>Transparency mode - defines how transparency is applied to + * this Appearance component object:</li><p> + * <ul> + * <li>FASTEST - uses the fastest available method for transparency.</li><p> + * <li>NICEST - uses the nicest available method for transparency.</li><p> + * <li>SCREEN_DOOR - uses screen-door transparency. This is done using * an on/off stipple pattern in which the percentage of transparent pixels * is approximately equal to the value specified by the transparency - * parameter.</LI><P> - * <LI>BLENDED - uses alpha blended transparency. The blend equation is + * parameter.</li><p> + * <li>BLENDED - uses alpha blended transparency. The blend equation is * specified by the srcBlendFunction and dstBlendFunction attributes. * The default equation is: * <ul> @@ -45,27 +45,36 @@ package javax.media.j3d; * alpha<sub><font size=-1>pix</font></sub> * * (1-transparency)</code>. * </ul> - * </LI><P> - * <LI>NONE - no transparency; opaque object.</LI><P> - * </UL> - * <LI>Blend function - used in blended transparency and antialiasing + * </li><p> + * <li>NONE - no transparency; opaque object.</li><p> + * </ul> + * <li>Transparency value - the amount of transparency to be applied to this + * Appearance component object. The transparency values are in the + * range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being + * fully transparent.</li><p> + * <li>Blend function - used in blended transparency and antialiasing * operations. The source function specifies the factor that is * multiplied by the source color. This value is added to the product * of the destination factor and the destination color. The default * source blend function is BLEND_SRC_ALPHA. The source blend function - * is one of the following:</LI><P> - * <UL> - * <LI>BLEND_ZERO - the blend function is <code>f = 0</code>.</LI> - * <LI>BLEND_ONE - the blend function is <code>f = 1</code>.</LI> - * <LI>BLEND_SRC_ALPHA - the blend function is <code>f = - * alpha<sub><font size=-1>src</font></sub></code>.</LI> - * <LI>BLEND_ONE_MINUS_SRC_ALPHA - the blend function is <code>f = - * 1 - alpha<sub><font size=-1>src</font></sub></code>.</LI></UL><P> - * <LI>Blend value - the amount of transparency to be applied to this - * Appearance component object. The transparency values are in the - * range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being - * fully transparent.</LI><P> - * </UL> + * is one of the following:</li><p> + * <ul> + * <li>BLEND_ZERO - the blend function is <code>f = 0</code></li> + * <li>BLEND_ONE - the blend function is <code>f = 1</code></li> + * <li>BLEND_SRC_ALPHA - the blend function is <code>f = + * alpha<sub><font size=-1>src</font></sub></code></li> + * <li>BLEND_ONE_MINUS_SRC_ALPHA - the blend function is <code>f = + * 1 - alpha<sub><font size=-1>src</font></sub></code></li> + * <li>BLEND_DST_COLOR - the blend function is <code>f = + * color<sub><font size=-1>dst</font></sub></code></li> + * <li>BLEND_ONE_MINUS_DST_COLOR - the blend function is <code>f = + * 1 - color<sub><font size=-1>dst</font></sub></code></li> + * <li>BLEND_SRC_COLOR - the blend function is <code>f = + * color<sub><font size=-1>src</font></sub></code></li> + * <li>BLEND_ONE_MINUS_SRC_COLOR - the blend function is <code>f = + * 1 - color<sub><font size=-1>src</font></sub></code></li> + * </ul> + * </ul> */ public class TransparencyAttributes extends NodeComponent { /** @@ -173,6 +182,7 @@ public class TransparencyAttributes extends NodeComponent { * Blend function: <code>f = 0</code>. * @see #setSrcBlendFunction * @see #setDstBlendFunction + * * @since Java 3D 1.2 */ public static final int BLEND_ZERO = 0; @@ -181,6 +191,7 @@ public class TransparencyAttributes extends NodeComponent { * Blend function: <code>f = 1</code>. * @see #setSrcBlendFunction * @see #setDstBlendFunction + * * @since Java 3D 1.2 */ public static final int BLEND_ONE = 1; @@ -190,6 +201,7 @@ public class TransparencyAttributes extends NodeComponent { * <code>f = alpha<sub><font size=-1>src</font></sub></code>. * @see #setSrcBlendFunction * @see #setDstBlendFunction + * * @since Java 3D 1.2 */ public static final int BLEND_SRC_ALPHA = 2; @@ -199,12 +211,67 @@ public class TransparencyAttributes extends NodeComponent { * <code>f = 1-alpha<sub><font size=-1>src</font></sub></code>. * @see #setSrcBlendFunction * @see #setDstBlendFunction + * * @since Java 3D 1.2 */ public static final int BLEND_ONE_MINUS_SRC_ALPHA = 3; + /** + * Blend function: + * <code>f = color<sub><font size=-1>dst</font></sub></code>. + * <p>Note that this function may <i>only</i> be used as a source + * blend function.</p> + * @see #setSrcBlendFunction + * + * @since Java 3D 1.4 + */ + public static final int BLEND_DST_COLOR = 4; + + /** + * Blend function: + * <code>f = 1-color<sub><font size=-1>dst</font></sub></code>. + * <p>Note that this function may <i>only</i> be used as a source + * blend function.</p> + * @see #setSrcBlendFunction + * + * @since Java 3D 1.4 + */ + public static final int BLEND_ONE_MINUS_DST_COLOR = 5; /** + * Blend function: + * <code>f = color<sub><font size=-1>src</font></sub></code>. + * <p>Note that this function may <i>only</i> be used as a destination + * blend function.</p> + * @see #setDstBlendFunction + * + * @since Java 3D 1.4 + */ + public static final int BLEND_SRC_COLOR = 6; + + /** + * Blend function: + * <code>f = 1-color<sub><font size=-1>src</font></sub></code>. + * <p>Note that this function may <i>only</i> be used as a destination + * blend function.</p> + * @see #setDstBlendFunction + * + * @since Java 3D 1.4 + */ + public static final int BLEND_ONE_MINUS_SRC_COLOR = 7; + + static final int BLEND_CONSTANT_COLOR = 8; + + static final int MAX_BLEND_FUNC_TABLE_SIZE = 9; + + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_BLEND_FUNCTION_READ, + ALLOW_MODE_READ, + ALLOW_VALUE_READ + }; + + /** * Constructs a TransparencyAttributes object with default parameters. * The default values are as follows: * <ul> @@ -216,6 +283,8 @@ public class TransparencyAttributes extends NodeComponent { */ public TransparencyAttributes() { // Just use the default for all attributes + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** @@ -238,20 +307,20 @@ public class TransparencyAttributes extends NodeComponent { * @param tVal the transparency value * @param srcBlendFunction the blend function to be used for the source * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, + * <code>BLEND_DST_COLOR</code>, or <code>BLEND_ONE_MINUS_DST_COLOR</code>. * @param dstBlendFunction the blend function to be used for the * destination * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, + * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>. * @exception IllegalArgumentException if * <code>tMode</code> is a value other than * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>, * <code>SCREEN_DOOR</code>, or <code>BLENDED</code> * @exception IllegalArgumentException if * <code>srcBlendFunction</code> or <code>dstBlendFunction</code> - * is a value other than <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or - * <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ @@ -263,15 +332,32 @@ public class TransparencyAttributes extends NodeComponent { throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes6")); } - if ((srcBlendFunction < BLEND_ZERO) || - (srcBlendFunction > BLEND_ONE_MINUS_SRC_ALPHA)) { - throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); - } - - if ((dstBlendFunction < BLEND_ZERO) || - (dstBlendFunction > BLEND_ONE_MINUS_SRC_ALPHA)) { - throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); - } + switch (srcBlendFunction) { + case BLEND_ZERO: + case BLEND_ONE: + case BLEND_SRC_ALPHA: + case BLEND_ONE_MINUS_SRC_ALPHA: + case BLEND_DST_COLOR: + case BLEND_ONE_MINUS_DST_COLOR: + break; + default: + throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); + } + + switch (dstBlendFunction) { + case BLEND_ZERO: + case BLEND_ONE: + case BLEND_SRC_ALPHA: + case BLEND_ONE_MINUS_SRC_ALPHA: + case BLEND_SRC_COLOR: + case BLEND_ONE_MINUS_SRC_COLOR: + break; + default: + throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); + } + + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); ((TransparencyAttributesRetained)this.retained).initTransparencyMode(tMode); ((TransparencyAttributesRetained)this.retained).initTransparency(tVal); @@ -370,15 +456,13 @@ public class TransparencyAttributes extends NodeComponent { * * @param blendFunction the blend function to be used for the source * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, + * <code>BLEND_DST_COLOR</code>, or <code>BLEND_ONE_MINUS_DST_COLOR</code>. + * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph - * @exception IllegalArgumentException if - * <code>blendFunction</code> - * is a value other than <code>BLEND_ZERO</code>, - * <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or - * <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * @exception IllegalArgumentException if <code>blendFunction</code> + * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ @@ -388,11 +472,17 @@ public class TransparencyAttributes extends NodeComponent { throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes4")); - if ((blendFunction < BLEND_ZERO) || - (blendFunction > BLEND_ONE_MINUS_SRC_ALPHA)) { - throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); - } - + switch (blendFunction) { + case BLEND_ZERO: + case BLEND_ONE: + case BLEND_SRC_ALPHA: + case BLEND_ONE_MINUS_SRC_ALPHA: + case BLEND_DST_COLOR: + case BLEND_ONE_MINUS_DST_COLOR: + break; + default: + throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); + } if (isLive()) ((TransparencyAttributesRetained)this.retained).setSrcBlendFunction(blendFunction); @@ -428,15 +518,13 @@ public class TransparencyAttributes extends NodeComponent { * * @param blendFunction the blend function to be used for the destination * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, + * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>. + * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph - * @exception IllegalArgumentException if - * <code>blendFunction</code> - * is a value other than <code>BLEND_ZERO</code>, - * <code>BLEND_ONE</code>, - * <code>BLEND_SRC_ALPHA</code>, or - * <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. + * @exception IllegalArgumentException if <code>blendFunction</code> + * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ @@ -445,10 +533,17 @@ public class TransparencyAttributes extends NodeComponent { if (!this.getCapability(ALLOW_BLEND_FUNCTION_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes4")); - if ((blendFunction < BLEND_ZERO) || - (blendFunction > BLEND_ONE_MINUS_SRC_ALPHA)) { - throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); - } + switch (blendFunction) { + case BLEND_ZERO: + case BLEND_ONE: + case BLEND_SRC_ALPHA: + case BLEND_ONE_MINUS_SRC_ALPHA: + case BLEND_SRC_COLOR: + case BLEND_ONE_MINUS_SRC_COLOR: + break; + default: + throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); + } if (isLive()) ((TransparencyAttributesRetained)this.retained).setDstBlendFunction(blendFunction); diff --git a/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java b/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java index 0123fc2..defbb44 100644 --- a/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java +++ b/src/classes/share/javax/media/j3d/TransparencyAttributesRetained.java @@ -38,16 +38,6 @@ class TransparencyAttributesRetained extends NodeComponentRetained { int srcBlendFunction = TransparencyAttributes.BLEND_SRC_ALPHA; int dstBlendFunction = TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA; - // Here are some blend functions that are used in multi-pass only - static final int BLEND_ZERO = 0; - static final int BLEND_ONE = 1; - static final int BLEND_SRC_ALPHA = 2; - static final int BLEND_ONE_MINUS_SRC_ALPHA = 3; - static final int BLEND_DST_COLOR = 4; - static final int BLEND_SRC_COLOR = 5; - static final int BLEND_ONE_MINUS_SRC_COLOR = 6; - static final int BLEND_CONSTANT_COLOR = 7; - /** * Sets the transparency mode for this * appearance component object. diff --git a/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java b/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java index bca1018..27c4e7d 100644 --- a/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java +++ b/src/classes/share/javax/media/j3d/TransparentRenderingInfo.java @@ -11,10 +11,9 @@ */ package javax.media.j3d; -import javax.vecmath.*; -import java.util.*; -class TransparentRenderingInfo extends Object { + +class TransparentRenderingInfo extends Object implements com.sun.j3d.utils.scenegraph.transparency.TransparencySortGeom { // For DepthSortedTransparency, rm is the rendermolecule // that this rInfo is part of // For non depth sorted transparency, rm is one of the rendermolecules @@ -24,8 +23,9 @@ class TransparentRenderingInfo extends Object { RenderAtomListInfo rInfo; TransparentRenderingInfo prev; TransparentRenderingInfo next; + GeometryAtom geometryAtom; double zVal; // Used in DepthSorted Transparency - // TODO: Add Dirty info + // XXXX: Add Dirty info /** * update state before rendering transparent objects @@ -34,7 +34,8 @@ class TransparentRenderingInfo extends Object { TextureBin textureBin = rm.textureBin; AttributeBin attributeBin = textureBin.attributeBin; - + ShaderBin shaderBin = textureBin.shaderBin; + // Get a collection to check if switch is on RenderMolecule rm = textureBin.transparentRMList ; @@ -57,40 +58,44 @@ class TransparentRenderingInfo extends Object { return false; } - if (cv.environmentSet != attributeBin.environmentSet) { - - boolean visible = (attributeBin.definingRenderingAttributes == null || - attributeBin.definingRenderingAttributes.visible); + // XXXX : Code cleanup needed : The following code segment should simply test + // each bin independently and update it if necessary. + if (cv.environmentSet != attributeBin.environmentSet) { + + boolean visible = (attributeBin.definingRenderingAttributes == null || + attributeBin.definingRenderingAttributes.visible); + + if ( (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy + == View.VISIBILITY_DRAW_VISIBLE && !visible) || + (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy + == View.VISIBILITY_DRAW_INVISIBLE && visible)) { + return false; + } + attributeBin.environmentSet.lightBin.updateAttributes(cv); + attributeBin.environmentSet.updateAttributes(cv); + attributeBin.updateAttributes(cv); + shaderBin.updateTransparentAttributes(cv); + } else if (cv.attributeBin != attributeBin) { + boolean visible = (attributeBin.definingRenderingAttributes == null || + attributeBin.definingRenderingAttributes.visible); + + if ( (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy + == View.VISIBILITY_DRAW_VISIBLE && !visible) || + (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy + == View.VISIBILITY_DRAW_INVISIBLE && visible)) { + return false; + } + attributeBin.updateAttributes(cv); + shaderBin.updateTransparentAttributes(cv); + } else if (cv.shaderBin != shaderBin) { + shaderBin.updateTransparentAttributes(cv); + } - if ( (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy - == View.VISIBILITY_DRAW_VISIBLE && !visible) || - (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy - == View.VISIBILITY_DRAW_INVISIBLE && visible)) { - return false; - } - attributeBin.environmentSet.lightBin.updateAttributes(cv); - attributeBin.environmentSet.updateAttributes(cv); - attributeBin.updateAttributes(cv); - } - else { - if (cv.attributeBin != attributeBin) { - boolean visible = (attributeBin.definingRenderingAttributes == null || - attributeBin.definingRenderingAttributes.visible); - - if ( (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy - == View.VISIBILITY_DRAW_VISIBLE && !visible) || - (attributeBin.environmentSet.renderBin.view.viewCache.visibilityPolicy - == View.VISIBILITY_DRAW_INVISIBLE && visible)) { - return false; - } - attributeBin.updateAttributes(cv); - } - } - return true; + return true; } void render(Canvas3D cv) { - if (updateState(cv)) { + if (updateState(cv)) { rm.textureBin.render(cv, rm.textureBin.transparentRMList); } } @@ -101,4 +106,25 @@ class TransparentRenderingInfo extends Object { rm.textureBin.render(cv, this); } } + + public double getDistanceSquared() { + return zVal; + } + + public Geometry getGeometry() { + // XXXX: verify 0 is always the correct index. Assumption is that for + // Shape3D with multiple geometry each geometry is put in it's + // own geometryAtom. + if (geometryAtom.geometryArray[0]==null) + return null; + return (Geometry)geometryAtom.geometryArray[0].source; + } + + public void getLocalToVWorld(Transform3D localToVW) { + localToVW.set(rm.localToVworld[NodeRetained.LAST_LOCAL_TO_VWORLD]); + } + + public Shape3D getShape3D() { + return (Shape3D)geometryAtom.source.source; + } } diff --git a/src/classes/share/javax/media/j3d/TriangleArray.java b/src/classes/share/javax/media/j3d/TriangleArray.java index 32bb57b..8487007 100644 --- a/src/classes/share/javax/media/j3d/TriangleArray.java +++ b/src/classes/share/javax/media/j3d/TriangleArray.java @@ -24,23 +24,22 @@ public class TriangleArray extends GeometryArray { TriangleArray() {} /** - * Constructs an empty TriangleArray object with the specified - * number of vertices, and vertex format. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. + * Constructs an empty TriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * * @exception IllegalArgumentException if vertexCount is less than 3 * or vertexCount is <i>not</i> a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int)} + * for more exceptions that can be thrown */ public TriangleArray(int vertexCount, int vertexFormat) { super(vertexCount,vertexFormat); @@ -50,60 +49,30 @@ public class TriangleArray extends GeometryArray { } /** - * Constructs an empty TriangleArray object with the specified - * number of vertices, and vertex format, number of texture coordinate - * sets, and texture coordinate mapping array. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used. + * Constructs an empty TriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 3 * or vertexCount is <i>not</i> a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -120,6 +89,54 @@ public class TriangleArray extends GeometryArray { } /** + * Constructs an empty TriangleArray object using the specified + * parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 3 + * or vertexCount is <i>not</i> a multiple of 3 + * ;<br> + * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public TriangleArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes); + + if (vertexCount < 3 || ((vertexCount%3) != 0)) + throw new IllegalArgumentException(J3dI18N.getString("TriangleArray0")); + } + + + /** * Creates the retained mode TriangleArrayRetained object that this * TriangleArray object will point to. */ @@ -133,22 +150,26 @@ public class TriangleArray extends GeometryArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - TriangleArrayRetained rt = (TriangleArrayRetained) retained; - int texSetCount = rt.getTexCoordSetCount(); - TriangleArray t; - - if (texSetCount == 0) { - t = new TriangleArray(rt.getVertexCount(), - rt.getVertexFormat()); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - t = new TriangleArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap); - } - t.duplicateNodeComponent(this); + TriangleArrayRetained rt = (TriangleArrayRetained) retained; + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + TriangleArray t = new TriangleArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes); + t.duplicateNodeComponent(this); return t; } } diff --git a/src/classes/share/javax/media/j3d/TriangleArrayRetained.java b/src/classes/share/javax/media/j3d/TriangleArrayRetained.java index 6332bad..577495f 100644 --- a/src/classes/share/javax/media/j3d/TriangleArrayRetained.java +++ b/src/classes/share/javax/media/j3d/TriangleArrayRetained.java @@ -27,14 +27,15 @@ class TriangleArrayRetained extends GeometryArrayRetained { this.geoType = GEO_TYPE_TRI_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int i = ((vertexFormat & GeometryArray.BY_REFERENCE) == 0 ? initialVertexIndex : initialCoordIndex); - + int count = 0; + int minICount = 0; pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -47,12 +48,14 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { - minDist = sdist[0]; + minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -62,22 +65,24 @@ class TriangleArrayRetained extends GeometryArrayRetained { break; case PickShape.PICKSEGMENT: PickSegment pickSegment = (PickSegment) pickShape; - while (i < validVertexCount) { + + while (i < validVertexCount) { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectSegment(pnts, pickSegment.start, - pickSegment.end, sdist, iPnt) - && (sdist[0] <= 1.0)) { - if (dist == null) { + pickSegment.end, sdist, iPnt)) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } } break; @@ -89,15 +94,17 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; - z = iPnt.z; + z = iPnt.z; } } } @@ -110,12 +117,14 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -131,13 +140,15 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectBoundingPolytope(pnts, bpolytope, sdist,iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -151,13 +162,15 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -172,12 +185,14 @@ class TriangleArrayRetained extends GeometryArrayRetained { getVertexData(i++, pnts[0]); getVertexData(i++, pnts[1]); getVertexData(i++, pnts[2]); + count += 3; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -194,7 +209,15 @@ class TriangleArrayRetained extends GeometryArrayRetained { if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 3; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; @@ -263,8 +286,7 @@ class TriangleArrayRetained extends GeometryArrayRetained { break; } return false; - } - + } boolean intersect(Transform3D thisToOtherVworld, GeometryRetained geom) { diff --git a/src/classes/share/javax/media/j3d/TriangleFanArray.java b/src/classes/share/javax/media/j3d/TriangleFanArray.java index d8a9539..e536158 100644 --- a/src/classes/share/javax/media/j3d/TriangleFanArray.java +++ b/src/classes/share/javax/media/j3d/TriangleFanArray.java @@ -30,28 +30,26 @@ public class TriangleFanArray extends GeometryStripArray { TriangleFanArray() {} /** - * Constructs an empty TriangleFanArray object with the specified - * number of vertices, vertex format, and - * array of per-strip vertex counts. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty TriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 3 * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for more exceptions that can be thrown */ public TriangleFanArray(int vertexCount, int vertexFormat, @@ -64,65 +62,34 @@ public class TriangleFanArray extends GeometryStripArray { } /** - * Constructs an empty TriangleFanArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and - * array of per-strip vertex counts. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty TriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 3 * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -141,6 +108,59 @@ public class TriangleFanArray extends GeometryStripArray { } /** + * Constructs an empty TriangleFanArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 3 + * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public TriangleFanArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + stripVertexCounts); + + if (vertexCount < 3 ) + throw new IllegalArgumentException(J3dI18N.getString("TriangleFanArray0")); + } + + /** * Creates the retained mode TriangleFanArrayRetained object that this * TriangleFanArray object will point to. */ @@ -154,25 +174,29 @@ public class TriangleFanArray extends GeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - TriangleFanArrayRetained rt = (TriangleFanArrayRetained) retained; - int stripcounts[] = new int[rt.getNumStrips()]; - rt.getStripVertexCounts(stripcounts); - int texSetCount = rt.getTexCoordSetCount(); - TriangleFanArray t; - if (texSetCount == 0) { - t = new TriangleFanArray(rt.getVertexCount(), - rt.getVertexFormat(), - stripcounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - t = new TriangleFanArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - stripcounts); - } - t.duplicateNodeComponent(this); + TriangleFanArrayRetained rt = (TriangleFanArrayRetained) retained; + int stripcounts[] = new int[rt.getNumStrips()]; + rt.getStripVertexCounts(stripcounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + TriangleFanArray t = new TriangleFanArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + stripcounts); + t.duplicateNodeComponent(this); return t; } diff --git a/src/classes/share/javax/media/j3d/TriangleFanArrayRetained.java b/src/classes/share/javax/media/j3d/TriangleFanArrayRetained.java index ba29127..1c77d6c 100644 --- a/src/classes/share/javax/media/j3d/TriangleFanArrayRetained.java +++ b/src/classes/share/javax/media/j3d/TriangleFanArrayRetained.java @@ -32,14 +32,16 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { this.geoType = GEO_TYPE_TRI_FAN_SET; } - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; int i = 0; int j, end; - + int count = 0, fSCount; + int minICount = 0; + int minFSCount = 0; pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -51,19 +53,24 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; + fSCount = count; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); - if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + count++; + if (intersectRay(pnts, pickRay, sdist, iPnt)) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = count; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -76,20 +83,25 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; + fSCount = count; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); - if (intersectSegment(pnts, pickSegment.start, + count++; + if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -103,19 +115,24 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; + fSCount = count; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -129,20 +146,25 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; - getVertexData(j++, pnts[0]); + fSCount = count; + getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); - while (j < end) { + count += 2; + while (j < end) { getVertexData(j++, pnts[2]); - if (intersectBoundingSphere(pnts, bsphere, sdist, + count++; + if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -156,20 +178,25 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; + fSCount = count; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); - if (intersectBoundingPolytope(pnts, bpolytope, + count++; + if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -184,17 +211,22 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + fSCount = count; + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -207,19 +239,24 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { while (i < stripVertexCounts.length) { j = stripStartVertexIndices[i]; end = j + stripVertexCounts[i++]; - getVertexData(j++, pnts[0]); + fSCount = count; + getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; - x = iPnt.x; - y = iPnt.y; - z = iPnt.z; + minFSCount = fSCount; + minICount = count; + x = iPnt.x; + y = iPnt.y; + z = iPnt.z; } } pnts[1].set(pnts[2]); @@ -234,14 +271,22 @@ class TriangleFanArrayRetained extends GeometryStripArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >= 3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minFSCount; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; - return true; + return true; } return false; - } + } // intersect pnts[] with every triangle in this object boolean intersect(Point3d[] pnts) { diff --git a/src/classes/share/javax/media/j3d/TriangleStripArray.java b/src/classes/share/javax/media/j3d/TriangleStripArray.java index 9c6c324..e6c9ed8 100644 --- a/src/classes/share/javax/media/j3d/TriangleStripArray.java +++ b/src/classes/share/javax/media/j3d/TriangleStripArray.java @@ -29,28 +29,26 @@ public class TriangleStripArray extends GeometryStripArray { TriangleStripArray() {} /** - * Constructs an empty TriangleStripArray object with the specified - * number of vertices, vertex format, and - * array of per-strip vertex counts. - * @param vertexCount the number of vertex elements in this array - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D. - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty TriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int)} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 3 * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int[])} + * for more exceptions that can be thrown */ public TriangleStripArray(int vertexCount, int vertexFormat, @@ -63,65 +61,34 @@ public class TriangleStripArray extends GeometryStripArray { } /** - * Constructs an empty TriangleStripArray object with the specified - * number of vertices, vertex format, number of texture coordinate - * sets, texture coordinate mapping array, and - * array of per-strip vertex counts. - * - * @param vertexCount the number of vertex elements in this array<p> - * - * @param vertexFormat a mask indicating which components are - * present in each vertex. This is specified as one or more - * individual flags that are bitwise "OR"ed together to describe - * the per-vertex data. - * The flags include: COORDINATES, to signal the inclusion of - * vertex positions--always present; NORMALS, to signal - * the inclusion of per vertex normals; one of COLOR_3, - * COLOR_4, to signal the inclusion of per vertex - * colors (without or with color information); and one of - * TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3 or TEXTURE_COORDINATE_4, - * to signal the - * inclusion of per-vertex texture coordinates 2D, 3D or 4D.<p> - * - * @param texCoordSetCount the number of texture coordinate sets - * in this GeometryArray object. If <code>vertexFormat</code> - * does not include one of <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3 or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetCount</code> parameter is not used.<p> - * - * @param texCoordSetMap an array that maps texture coordinate - * sets to texture units. The array is indexed by texture unit - * number for each texture unit in the associated Appearance - * object. The values in the array specify the texture coordinate - * set within this GeometryArray object that maps to the - * corresponding texture - * unit. All elements within the array must be less than - * <code>texCoordSetCount</code>. A negative value specifies that - * no texture coordinate set maps to the texture unit - * corresponding to the index. If there are more texture units in - * any associated Appearance object than elements in the mapping - * array, the extra elements are assumed to be -1. The same - * texture coordinate set may be used for more than one texture - * unit. Each texture unit in every associated Appearance must - * have a valid source of texture coordinates: either a - * non-negative texture coordinate set must be specified in the - * mapping array or texture coordinate generation must be enabled. - * Texture coordinate generation will take precedence for those - * texture units for which a texture coordinate set is specified - * and texture coordinate generation is enabled. If - * <code>vertexFormat</code> does not include one of - * <code>TEXTURE_COORDINATE_2</code>, - * <code>TEXTURE_COORDINATE_3</code> or - * <code>TEXTURE_COORDINATE_4</code>, the - * <code>texCoordSetMap</code> array is not used.<p> - * - * @param stripVertexCounts array that specifies - * the count of the number of vertices for each separate strip. - * The length of this array is the number of separate strips. + * Constructs an empty TriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for a description of this parameter. * * @exception IllegalArgumentException if vertexCount is less than 3 * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int[])} + * for more exceptions that can be thrown * * @since Java 3D 1.2 */ @@ -140,6 +107,59 @@ public class TriangleStripArray extends GeometryStripArray { } /** + * Constructs an empty TriangleStripArray object using the + * specified parameters. + * + * @param vertexCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexFormat + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param texCoordSetMap + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrCount + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param vertexAttrSizes + * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} + * for a description of this parameter. + * + * @param stripVertexCounts + * see {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for a description of this parameter. + * + * @exception IllegalArgumentException if vertexCount is less than 3 + * or any element in the stripVertexCounts array is less than 3 + * ;<br> + * See {@link GeometryStripArray#GeometryStripArray(int,int,int,int[],int,int[],int[])} + * for more exceptions that can be thrown + * + * @since Java 3D 1.4 + */ + public TriangleStripArray(int vertexCount, + int vertexFormat, + int texCoordSetCount, + int[] texCoordSetMap, + int vertexAttrCount, + int[] vertexAttrSizes, + int[] stripVertexCounts) { + + super(vertexCount, vertexFormat, + texCoordSetCount, texCoordSetMap, + vertexAttrCount, vertexAttrSizes, + stripVertexCounts); + + if (vertexCount < 3 ) + throw new IllegalArgumentException(J3dI18N.getString("TriangleStripArray0")); + } + + /** * Creates the retained mode TriangleStripArrayRetained object that this * TriangleStripArray object will point to. */ @@ -153,26 +173,29 @@ public class TriangleStripArray extends GeometryStripArray { * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { - TriangleStripArrayRetained rt = (TriangleStripArrayRetained) retained; + TriangleStripArrayRetained rt = (TriangleStripArrayRetained) retained; int stripcounts[] = new int[rt.getNumStrips()]; - rt.getStripVertexCounts(stripcounts); - int texSetCount = rt.getTexCoordSetCount(); - TriangleStripArray t; - if (texSetCount == 0) { - t = new TriangleStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - stripcounts); - } else { - int texMap[] = new int[rt.getTexCoordSetMapLength()]; - rt.getTexCoordSetMap(texMap); - t = new TriangleStripArray(rt.getVertexCount(), - rt.getVertexFormat(), - texSetCount, - texMap, - stripcounts); - - } - t.duplicateNodeComponent(this); + rt.getStripVertexCounts(stripcounts); + int texSetCount = rt.getTexCoordSetCount(); + int[] texMap = null; + int vertexAttrCount = rt.getVertexAttrCount(); + int[] vertexAttrSizes = null; + if (texSetCount > 0) { + texMap = new int[rt.getTexCoordSetMapLength()]; + rt.getTexCoordSetMap(texMap); + } + if (vertexAttrCount > 0) { + vertexAttrSizes = new int[vertexAttrCount]; + rt.getVertexAttrSizes(vertexAttrSizes); + } + TriangleStripArray t = new TriangleStripArray(rt.getVertexCount(), + rt.getVertexFormat(), + texSetCount, + texMap, + vertexAttrCount, + vertexAttrSizes, + stripcounts); + t.duplicateNodeComponent(this); return t; } } diff --git a/src/classes/share/javax/media/j3d/TriangleStripArrayRetained.java b/src/classes/share/javax/media/j3d/TriangleStripArrayRetained.java index db4b8ba..14c177a 100644 --- a/src/classes/share/javax/media/j3d/TriangleStripArrayRetained.java +++ b/src/classes/share/javax/media/j3d/TriangleStripArrayRetained.java @@ -30,15 +30,16 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { TriangleStripArrayRetained() { this.geoType = GEO_TYPE_TRI_STRIP_SET; } - - boolean intersect(PickShape pickShape, double dist[], Point3d iPnt) { + + boolean intersect(PickShape pickShape, PickInfo.IntersectionInfo iInfo, int flags, Point3d iPnt) { Point3d pnts[] = new Point3d[3]; double sdist[] = new double[1]; double minDist = Double.MAX_VALUE; double x = 0, y = 0, z = 0; + int count = 0; + int minICount = 0; int i = 0; int j, end; - pnts[0] = new Point3d(); pnts[1] = new Point3d(); pnts[2] = new Point3d(); @@ -52,18 +53,21 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectRay(pnts, pickRay, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; - } + } } pnts[0].set(pnts[1]); pnts[1].set(pnts[2]); @@ -78,15 +82,18 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectSegment(pnts, pickSegment.start, pickSegment.end, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -106,14 +113,17 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectBoundingBox(pnts, bbox, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -133,15 +143,18 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectBoundingSphere(pnts, bsphere, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -161,15 +174,18 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); - if (intersectBoundingPolytope(pnts, bpolytope, + count++; + if (intersectBoundingPolytope(pnts, bpolytope, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -188,14 +204,17 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); - if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { - if (dist == null) { + count++; + if (intersectCylinder(pnts, pickCylinder, sdist, iPnt)) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -214,14 +233,17 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { end = j + stripVertexCounts[i++]; getVertexData(j++, pnts[0]); getVertexData(j++, pnts[1]); + count += 2; while (j < end) { getVertexData(j++, pnts[2]); + count++; if (intersectCone(pnts, pickCone, sdist, iPnt)) { - if (dist == null) { + if (flags == 0) { return true; } if (sdist[0] < minDist) { minDist = sdist[0]; + minICount = count; x = iPnt.x; y = iPnt.y; z = iPnt.z; @@ -240,7 +262,15 @@ class TriangleStripArrayRetained extends GeometryStripArrayRetained { } if (minDist < Double.MAX_VALUE) { - dist[0] = minDist; + assert(minICount >=3); + int[] vertexIndices = iInfo.getVertexIndices(); + if (vertexIndices == null) { + vertexIndices = new int[3]; + iInfo.setVertexIndices(vertexIndices); + } + vertexIndices[0] = minICount - 3; + vertexIndices[1] = minICount - 2; + vertexIndices[2] = minICount - 1; iPnt.x = x; iPnt.y = y; iPnt.z = z; diff --git a/src/classes/share/javax/media/j3d/View.java b/src/classes/share/javax/media/j3d/View.java index 2b54b6a..daf6cd4 100644 --- a/src/classes/share/javax/media/j3d/View.java +++ b/src/classes/share/javax/media/j3d/View.java @@ -3305,7 +3305,7 @@ public class View extends Object { } // This is a temporary fix for bug 4267395 - // TODO:cleanup in RenderBin after View detach + // XXXX:cleanup in RenderBin after View detach // universe.addViewIdToFreeList(viewId); // using new property -Dj3d.forceReleaseView to disable bug fix 4267395 diff --git a/src/classes/share/javax/media/j3d/ViewCache.java b/src/classes/share/javax/media/j3d/ViewCache.java index 5aeec71..b506793 100644 --- a/src/classes/share/javax/media/j3d/ViewCache.java +++ b/src/classes/share/javax/media/j3d/ViewCache.java @@ -312,8 +312,7 @@ class ViewCache extends Object { trackerBaseToHeadTracker.setIdentity(); } - // TODO: implement head to vworld tracking if userHeadToVworldEnable - // is set + // XXXX: implement head to vworld tracking if userHeadToVworldEnable is set userHeadToVworld.setIdentity(); } diff --git a/src/classes/share/javax/media/j3d/ViewPlatform.java b/src/classes/share/javax/media/j3d/ViewPlatform.java index 59ebf66..bd518f2 100644 --- a/src/classes/share/javax/media/j3d/ViewPlatform.java +++ b/src/classes/share/javax/media/j3d/ViewPlatform.java @@ -108,6 +108,11 @@ public class ViewPlatform extends Leaf { public static final int ALLOW_POLICY_WRITE = CapabilityBits.VIEW_PLATFORM_ALLOW_POLICY_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_POLICY_READ + }; + /** * Constructs a ViewPlatform object with default parameters. * The default values are as follows: @@ -117,6 +122,8 @@ public class ViewPlatform extends Leaf { * </ul> */ public ViewPlatform() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } /** diff --git a/src/classes/share/javax/media/j3d/ViewPlatformRetained.java b/src/classes/share/javax/media/j3d/ViewPlatformRetained.java index 230235a..c523108 100644 --- a/src/classes/share/javax/media/j3d/ViewPlatformRetained.java +++ b/src/classes/share/javax/media/j3d/ViewPlatformRetained.java @@ -164,7 +164,6 @@ class ViewPlatformRetained extends LeafRetained { /** * This sets the view that is associated with this view platform. */ - // TODO: This must be changed to a list of views! void setView(View v) { synchronized (viewList) { if (!viewList.contains(v)) { diff --git a/src/classes/share/javax/media/j3d/ViewSpecificGroup.java b/src/classes/share/javax/media/j3d/ViewSpecificGroup.java index 8203551..bd87d04 100644 --- a/src/classes/share/javax/media/j3d/ViewSpecificGroup.java +++ b/src/classes/share/javax/media/j3d/ViewSpecificGroup.java @@ -71,11 +71,17 @@ public class ViewSpecificGroup extends Group { public static final int ALLOW_VIEW_WRITE = CapabilityBits.VIEW_SPECIFIC_GROUP_ALLOW_VIEW_WRITE; + // Array for setting default read capabilities + private static final int[] readCapabilities = { + ALLOW_VIEW_READ + }; /** * Constructs and initializes a new ViewSpecificGroup node object. */ public ViewSpecificGroup() { + // set default read capabilities + setDefaultReadCapabilities(readCapabilities); } @@ -324,7 +330,7 @@ public class ViewSpecificGroup extends Group { */ void duplicateAttributes(Node originalNode, boolean forceDuplicate) { - // TODO: implement this + // XXXX: implement this? super.duplicateAttributes(originalNode, forceDuplicate); ViewSpecificGroupRetained attr = (ViewSpecificGroupRetained) originalNode.retained; diff --git a/src/classes/share/javax/media/j3d/ViewSpecificGroupRetained.java b/src/classes/share/javax/media/j3d/ViewSpecificGroupRetained.java index 58cc08f..f60d052 100644 --- a/src/classes/share/javax/media/j3d/ViewSpecificGroupRetained.java +++ b/src/classes/share/javax/media/j3d/ViewSpecificGroupRetained.java @@ -517,7 +517,7 @@ class ViewSpecificGroupRetained extends GroupRetained { // don't remove this group node mergeFlag = SceneGraphObjectRetained.DONT_MERGE; - // TODO: complete this + // XXXX: complete this } void setLive(SetLiveState s) { @@ -549,7 +549,7 @@ class ViewSpecificGroupRetained extends GroupRetained { s.viewScopedNodeList = new ArrayList(); s.scopedNodesViewList = new ArrayList(); } - // TODO: This is a hack since removeNodeData is called before + // XXXX: This is a hack since removeNodeData is called before // children are clearLives int[] tempIndex = null; // Don't keep the indices if everything will be cleared diff --git a/src/classes/share/javax/media/j3d/VirtualUniverse.java b/src/classes/share/javax/media/j3d/VirtualUniverse.java index bb9b14d..20c783b 100644 --- a/src/classes/share/javax/media/j3d/VirtualUniverse.java +++ b/src/classes/share/javax/media/j3d/VirtualUniverse.java @@ -15,6 +15,8 @@ package javax.media.j3d; import java.util.Vector; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; /** @@ -155,6 +157,12 @@ public class VirtualUniverse extends Object { boolean isSceneGraphLock = false; private Object waitLock = new Object(); + + private HashSet structureChangeListenerSet = null; + + private HashSet shaderErrorListenerSet = null; + private ShaderErrorListener defaultShaderErrorListener = + ShaderProgram.getDefaultErrorListener(); /** * Constructs a new VirtualUniverse. @@ -549,7 +557,7 @@ public class VirtualUniverse extends Object { /** * This returns the next available nodeId as a string. */ - // TODO: reuse of id's imply a slight collision problem in the + // XXXX: reuse of id's imply a slight collision problem in the // render queue's. // BUG 4181362 String getNodeId() { @@ -990,4 +998,184 @@ public class VirtualUniverse extends Object { isSceneGraphLock = false; } } + + /** + * Adds the specified GraphStructureChangeListener to the set of listeners + * that will be notified when the graph structure is changed on a live + * scene graph. If the specifed listener is null no action is taken and no + * exception is thrown. + * + * @param listener the listener to add to the set. + * + * @since Java 3D 1.4 + */ + public void addGraphStructureChangeListener(GraphStructureChangeListener listener) { + if (listener == null) { + return; + } + + if (structureChangeListenerSet == null) { + structureChangeListenerSet = new HashSet(); + } + + synchronized(structureChangeListenerSet) { + structureChangeListenerSet.add(listener); + } + } + + /** + * Removes the specified GraphStructureChangeListener from the set of listeners. This + * method performs no function, nor does it throw an exception if the specified listener + * is not currently in the set or is null. + * + * @param listener the listener to remove from the set. + * + * @since Java 3D 1.4 + */ + public void removeGraphStructureChangeListener(GraphStructureChangeListener listener) { + if (structureChangeListenerSet == null) { + return; + } + + synchronized(structureChangeListenerSet) { + structureChangeListenerSet.remove(listener); + } + } + + /** + * Processes all live BranchGroup add and removes and notifies + * any registered listeners. Used for add and remove + */ + void notifyStructureChangeListeners(boolean add, Object parent, BranchGroup child) { + if (structureChangeListenerSet == null) { + return; + } + + synchronized(structureChangeListenerSet) { + Iterator it = structureChangeListenerSet.iterator(); + while(it.hasNext()) { + GraphStructureChangeListener listener = (GraphStructureChangeListener)it.next(); + try { + if (add) { + listener.branchGroupAdded(parent, child); + } else { + listener.branchGroupRemoved(parent, child); + } + } + catch (RuntimeException e) { + System.err.println("Exception occurred in GraphStructureChangeListener:"); + e.printStackTrace(); + } + } + } + } + + /** + * Processes all live BranchGroup moves and notifies + * any registered listeners. Used for moveTo + */ + void notifyStructureChangeListeners(Object oldParent, Object newParent, BranchGroup child) { + if (structureChangeListenerSet == null) { + return; + } + + synchronized(structureChangeListenerSet) { + Iterator it = structureChangeListenerSet.iterator(); + while(it.hasNext()) { + GraphStructureChangeListener listener = (GraphStructureChangeListener)it.next(); + try { + listener.branchGroupMoved(oldParent, newParent, child); + } + catch (RuntimeException e) { + System.err.println("Exception occurred in GraphStructureChangeListener:"); + e.printStackTrace(); + } + } + } + } + + + /** + * Adds the specified ShaderErrorListener to the set of listeners + * that will be notified when a programmable shader error is + * detected on a live scene graph. If the specifed listener is + * null no action is taken and no exception is thrown. + * If a shader error occurs, the listeners will be called + * asynchronously from a separate notification thread. The Java 3D + * renderer and behavior scheduler will continue to run as if the + * error had not occurred, except that shading will be disabled + * for the objects in error. If applications desire to detach or + * modify the scene graph as a result of the error, they should + * use a behavior post if they want that change to be + * synchronous with the renderer. + * + * @param listener the listener to add to the set. + * + * @since Java 3D 1.4 + */ + public void addShaderErrorListener(ShaderErrorListener listener) { + if (listener == null) { + return; + } + + if (shaderErrorListenerSet == null) { + shaderErrorListenerSet = new HashSet(); + } + + synchronized(shaderErrorListenerSet) { + shaderErrorListenerSet.add(listener); + } + } + + /** + * Removes the specified ShaderErrorListener from the set of + * listeners. This method performs no function, nor does it throw + * an exception if the specified listener is not currently in the + * set or is null. + * + * @param listener the listener to remove from the set. + * + * @since Java 3D 1.4 + */ + public void removeShaderErrorListener(ShaderErrorListener listener) { + if (shaderErrorListenerSet == null) { + return; + } + + synchronized(shaderErrorListenerSet) { + shaderErrorListenerSet.remove(listener); + } + } + + /** + * Notifies all listeners of a shader error. If no listeners exist, a default + * listener is notified. + */ + void notifyShaderErrorListeners(ShaderError error) { + boolean errorReported = false; + + // Notify all error listeners in the set + if (shaderErrorListenerSet != null) { + synchronized(shaderErrorListenerSet) { + Iterator it = shaderErrorListenerSet.iterator(); + while(it.hasNext()) { + ShaderErrorListener listener = (ShaderErrorListener)it.next(); + try { + listener.errorOccurred(error); + } + catch (RuntimeException e) { + System.err.println("Exception occurred in ShaderErrorListener:"); + e.printStackTrace(); + } + errorReported = true; + } + } + } + + // Notify the default error listener if the set is null or empty + if (!errorReported) { + defaultShaderErrorListener.errorOccurred(error); + } + } + } diff --git a/src/classes/share/javax/media/j3d/WakeupIndexedList.java b/src/classes/share/javax/media/j3d/WakeupIndexedList.java index c0a52ec..4a20594 100644 --- a/src/classes/share/javax/media/j3d/WakeupIndexedList.java +++ b/src/classes/share/javax/media/j3d/WakeupIndexedList.java @@ -59,7 +59,7 @@ package javax.media.j3d; class WakeupIndexedList implements Cloneable, java.io.Serializable { - // TODO: set to false when release + // XXXX: set to false when release final static boolean debug = false; /** diff --git a/src/classes/solaris/javax/media/j3d/J3dGraphicsConfig.java b/src/classes/solaris/javax/media/j3d/J3dGraphicsConfig.java index ab4f06d..855271b 100644 --- a/src/classes/solaris/javax/media/j3d/J3dGraphicsConfig.java +++ b/src/classes/solaris/javax/media/j3d/J3dGraphicsConfig.java @@ -30,11 +30,10 @@ class J3dGraphicsConfig { } static boolean isValidConfig(GraphicsConfiguration gc) { - // Check to see if a valid fbConfig pointer has been cached. + // Check to see if a valid FBConfig pointer has been cached. Object fbConfigObject = Canvas3D.fbConfigTable.get(gc); return ((fbConfigObject != null) && - (fbConfigObject instanceof Long)); - + (fbConfigObject instanceof GraphicsConfigInfo)); } diff --git a/src/classes/solaris/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/solaris/javax/media/j3d/NativeConfigTemplate3D.java index fad96ea..f443635 100644 --- a/src/classes/solaris/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/solaris/javax/media/j3d/NativeConfigTemplate3D.java @@ -35,7 +35,8 @@ class NativeConfigTemplate3D { final static int DOUBLEBUFFER = 6; final static int STEREO = 7; final static int ANTIALIASING = 8; - final static int NUM_ITEMS = 9; + final static int STENCIL_SIZE = 9; + final static int NUM_ITEMS = 10; // Native method to get an OpenGL visual id and a pointer to the // GLXFBConfig structure list itself. @@ -52,7 +53,7 @@ class NativeConfigTemplate3D { native boolean isDoubleBufferAvailable(long display, int screen, int vid); native boolean isSceneAntialiasingAccumAvailable(long display, int screen, int vid); native boolean isSceneAntialiasingMultisampleAvailable(long display, int screen, int vid); - + native int getStencilSize(long display, int screen, int vid); /* * Chooses the best FBConfig for Java 3D apps. @@ -110,6 +111,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; int visID = chooseOglVisual(display, screen, attrList, fbConfig); @@ -137,15 +141,18 @@ class NativeConfigTemplate3D { // returns, since this is not cached with X11GraphicsConfig and there // are no public constructors to allow us to extend it. synchronized (Canvas3D.fbConfigTable) { - if (Canvas3D.fbConfigTable.get(gc1) == null) - Canvas3D.fbConfigTable.put(gc1, new Long(fbConfig[0])); - else + if (Canvas3D.fbConfigTable.get(gc1) == null) { + GraphicsConfigInfo gcInfo = new GraphicsConfigInfo(); + gcInfo.setFBConfig(fbConfig[0]); + gcInfo.setRequestedStencilSize(attrList[STENCIL_SIZE]); + Canvas3D.fbConfigTable.put(gc1, gcInfo); + } else { freeFBConfig(fbConfig[0]); - } - - return gc1; + } + } + return gc1; } - + /* * Determine if a given GraphicsConfiguration object can be used * by Java 3D. @@ -179,6 +186,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); long[] fbConfig = new long[1]; int visID = chooseOglVisual(display, screen, attrList, fbConfig); @@ -205,6 +215,21 @@ class NativeConfigTemplate3D { return isStereoAvailable(display, screen, vid); } + // Return the stencil of this canvas. + int getStencilSize(Canvas3D c3d) { + GraphicsConfiguration gc = c3d.graphicsConfiguration; + + X11GraphicsDevice gd = + (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); + NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); + + long display = nativeScreenInfo.getDisplay(); + int screen = nativeScreenInfo.getScreen(); + int vid = ((X11GraphicsConfig)gc).getVisual(); + + return getStencilSize(display, screen, vid); + } + // Return whether a double buffer is available. boolean hasDoubleBuffer(Canvas3D c3d) { GraphicsConfiguration gc = c3d.graphicsConfiguration; diff --git a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java index 90719f3..6bea6e1 100644 --- a/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/win32/javax/media/j3d/NativeConfigTemplate3D.java @@ -34,7 +34,8 @@ class NativeConfigTemplate3D { final static int DOUBLEBUFFER = 6; final static int STEREO = 7; final static int ANTIALIASING = 8; - final static int NUM_ITEMS = 9; + final static int STENCIL_SIZE = 9; + final static int NUM_ITEMS = 10; /** * selects the proper visual @@ -52,6 +53,7 @@ class NativeConfigTemplate3D { native boolean isDoubleBufferAvailable(long pFormatInfo, boolean offScreen); native boolean isSceneAntialiasingAccumAvailable(long pFormatInfo, boolean offScreen); native boolean isSceneAntialiasingMultisampleAvailable(long pFormatInfo, boolean offScreen, int screen); + native int getStencilSize(long pFormatInfo, boolean offScreen); /** * Chooses the best PixelFormat for Java 3D apps. @@ -86,6 +88,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); int screen = nativeScreenInfo.getScreen(); @@ -119,10 +124,14 @@ class NativeConfigTemplate3D { // returns, since this is not cached with J3dGraphicsConfig and there // are no public constructors to allow us to extend it. synchronized (Canvas3D.fbConfigTable) { - if (Canvas3D.fbConfigTable.get(gc1) == null) - Canvas3D.fbConfigTable.put(gc1, new Long(pFormatInfo[0])); - else + if (Canvas3D.fbConfigTable.get(gc1) == null) { + GraphicsConfigInfo gcInfo = new GraphicsConfigInfo(); + gcInfo.setFBConfig(pFormatInfo[0]); + gcInfo.setRequestedStencilSize(attrList[STENCIL_SIZE]); + Canvas3D.fbConfigTable.put(gc1, gcInfo); + } else { freePixelFormatInfo(pFormatInfo[0]); + } } return gc1; @@ -161,6 +170,9 @@ class NativeConfigTemplate3D { attrList[DOUBLEBUFFER] = template.getDoubleBuffer(); attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); + attrList[STENCIL_SIZE] = template.getStencilSize(); + // System.out.println("NativeConfigTemplate3D : getStencilSize " + + // attrList[STENCIL_SIZE]); NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); int screen = nativeScreenInfo.getScreen(); @@ -177,7 +189,8 @@ class NativeConfigTemplate3D { if (pixelFormat < 0) { // current mode don't support the minimum config return false; - } else return true; + } else + return true; } @@ -186,6 +199,11 @@ class NativeConfigTemplate3D { return isStereoAvailable(c3d.fbConfig, c3d.offScreen); } + // Return the stencil of this canvas. + int getStencilSize(Canvas3D c3d) { + return getStencilSize(c3d.fbConfig, c3d.offScreen); + } + // Return whether a double buffer is available. boolean hasDoubleBuffer(Canvas3D c3d) { return isDoubleBufferAvailable(c3d.fbConfig, c3d.offScreen); diff --git a/src/native/build.xml b/src/native/build.xml index 8bd6b91..12c82e0 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -18,38 +18,50 @@ <project name="Java 3D" default="compile-opt"> <target name="nativeSetup-debug-solaris" if="isSolarisOnSparc"> - <property name="bldFlag" value="g"/> + <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/sparc/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/sparc/libj3dutils.so"/> </target> + <target name="nativeSetup-debug-solaris-x86" if="isSolarisOnX86"> + <property name="bldFlag" value="-g -DDEBUG"/> + <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> + <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> + </target> + <target name="nativeSetup-debug-linux" if="isLinuxOnX86"> - <property name="bldFlag" value="g"/> + <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux-amd64" if="isLinuxOnAmd64"> - <property name="bldFlag" value="g -fPIC -march=k8 -msse2 -mfpmath=sse"/> + <property name="bldFlag" value="-g -DDEBUG -fPIC -march=k8 -msse2 -mfpmath=sse"/> <property name="coreLibDependency" value="lib/amd64/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/amd64/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux-ia64" if="isLinuxOnIA64"> - <property name="bldFlag" value="g"/> + <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/ia64/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/ia64/libj3dutils.so"/> </target> + + <target name="nativeSetup-debug-linux-ppc" if="isLinuxOnPPC"> + <property name="bldFlag" value="-g -DDEBUG"/> + <property name="coreLibDependency" value="lib/ppc/libj3dcore-ogl.so"/> + <property name="coreUtilsLibDependency" value="lib/ppc/libj3dutils.so"/> + </target> <target name="nativeSetup-debug-win32" if="isWindowsOnX86"> <property name="bldFlag" - value="-DWIN32 -DDEBUG -D_WINDOWS"/> + value="-DDEBUG -DWIN32 -D_WINDOWS"/> <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> <property name="coreUtilsLibDependency" value="bin/j3dutils.dll"/> </target> - <target name="nativeSetup-debug" depends="nativeSetup-debug-solaris, nativeSetup-debug-linux, nativeSetup-debug-linux-amd64, nativeSetup-debug-linux-ia64, nativeSetup-debug-win32"> + <target name="nativeSetup-debug" depends="nativeSetup-debug-solaris, nativeSetup-debug-solaris-x86, nativeSetup-debug-linux, nativeSetup-debug-linux-amd64, nativeSetup-debug-linux-ia64, nativeSetup-debug-linux-ppc, nativeSetup-debug-win32"> <property name="bldType" value="debug"/> <property name="javahCoreSrc" location="${src}/classes/share/javax/media/j3d"/> @@ -62,37 +74,49 @@ </target> <target name="nativeSetup-opt-solaris" if="isSolarisOnSparc"> - <property name="bldFlag" value="O"/> + <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/sparc/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/sparc/libj3dutils.so"/> </target> + <target name="nativeSetup-opt-solaris-x86" if="isSolarisOnX86"> + <property name="bldFlag" value="-O"/> + <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> + <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> + </target> + <target name="nativeSetup-opt-linux" if="isLinuxOnX86"> - <property name="bldFlag" value="O"/> + <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux-amd64" if="isLinuxOnAmd64"> - <property name="bldFlag" value="O -fPIC -march=k8 -msse2 -mfpmath=sse"/> + <property name="bldFlag" value="-O -fPIC -march=k8 -msse2 -mfpmath=sse"/> <property name="coreLibDependency" value="lib/amd64/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/amd64/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux-ia64" if="isLinuxOnIA64"> - <property name="bldFlag" value="O"/> + <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/ia64/libj3dcore-ogl.so"/> <property name="coreUtilsLibDependency" value="lib/ia64/libj3dutils.so"/> </target> + <target name="nativeSetup-opt-linux-ppc" if="isLinuxOnPPC"> + <property name="bldFlag" value="-O"/> + <property name="coreLibDependency" value="lib/ppc/libj3dcore-ogl.so"/> + <property name="coreUtilsLibDependency" value="lib/ppc/libj3dutils.so"/> + </target> + <target name="nativeSetup-opt-win32" if="isWindowsOnX86"> <property name="bldFlag" - value="-DWIN32 -DNDEBUG -D_WINDOWS"/> + value="-DWIN32 -D_WINDOWS"/> <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> <property name="coreUtilsLibDependency" value="bin/j3dutils.dll"/> </target> - <target name="nativeSetup-opt" depends="nativeSetup-opt-solaris, nativeSetup-opt-linux, nativeSetup-opt-linux-amd64, nativeSetup-opt-linux-ia64, nativeSetup-opt-win32"> + <target name="nativeSetup-opt" depends="nativeSetup-opt-solaris, nativeSetup-opt-solaris-x86, nativeSetup-opt-linux, nativeSetup-opt-linux-amd64, nativeSetup-opt-linux-ia64, nativeSetup-opt-linux-ppc, nativeSetup-opt-win32"> <property name="bldType" value="opt"/> <property name="javahCoreSrc" location="${src}/classes/share/javax/media/j3d"/> @@ -188,6 +212,9 @@ srcfile="${javahCoreSrc}/ModelClipRetained.java" targetfile="${javahCoreTarget}/javax_media_j3d_ModelClipRetained.h"/> <uptodate + srcfile="${javahCoreSrc}/NativeAPIInfo.java" + targetfile="${javahCoreTarget}/javax_media_j3d_NativeAPIInfo.h"/> + <uptodate srcfile="${src}/classes/${ostype}/javax/media/j3d/NativeConfigTemplate3D.java" targetfile="${javahCoreTarget}/javax_media_j3d_NativeConfigTemplate3D.h"/> <uptodate @@ -266,6 +293,21 @@ srcfile="${javahCoreSrc}/TransparencyAttributesRetained.java" targetfile="${javahCoreTarget}/javax_media_j3d_TransparencyAttributesRetained.h"/> <uptodate + srcfile="${javahCoreSrc}/GLSLShaderProgramRetained.java" + targetfile="${javahCoreTarget}/javax_media_j3d_GLSLShaderProgramRetained.h"/> + <uptodate + srcfile="${javahCoreSrc}/CgShaderProgramRetained.java" + targetfile="${javahCoreTarget}/javax_media_j3d_CgShaderProgramRetained.h"/> + <uptodate + srcfile="${javahCoreSrc}/Shader.java" + targetfile="${javahCoreTarget}/javax_media_j3d_Shader.h"/> + <uptodate + srcfile="${javahCoreSrc}/ShaderAttributeObjectRetained.java" + targetfile="${javahCoreTarget}/javax_media_j3d_ShaderAttributeObjectRetained.h"/> + <uptodate + srcfile="${javahCoreSrc}/ShaderError.java" + targetfile="${javahCoreTarget}/javax_media_j3d_ShaderError.h"/> + <uptodate srcfile="${javahUtilsSrc}/J3DTimer.java" targetfile="${javahUtilsTarget}/com_sun_j3d_utils_timer_J3DTimer.h"/> </and> @@ -331,6 +373,7 @@ <class name="javax.media.j3d.Material"/> <class name="javax.media.j3d.MaterialRetained"/> <class name="javax.media.j3d.ModelClipRetained"/> + <class name="javax.media.j3d.NativeAPIInfo"/> <class name="javax.media.j3d.NativeConfigTemplate3D"/> <class name="javax.media.j3d.NodeRetained"/> <class name="javax.media.j3d.PointAttributesRetained"/> @@ -357,6 +400,11 @@ <class name="javax.media.j3d.TextureUnitStateRetained"/> <class name="javax.media.j3d.TransparencyAttributes"/> <class name="javax.media.j3d.TransparencyAttributesRetained"/> + <class name="javax.media.j3d.GLSLShaderProgramRetained"/> + <class name="javax.media.j3d.CgShaderProgramRetained"/> + <class name="javax.media.j3d.Shader"/> + <class name="javax.media.j3d.ShaderAttributeObjectRetained"/> + <class name="javax.media.j3d.ShaderError"/> </javah> diff --git a/src/native/d3d/Attributes.cpp b/src/native/d3d/Attributes.cpp index 6d97058..c4fd82f 100644 --- a/src/native/d3d/Attributes.cpp +++ b/src/native/d3d/Attributes.cpp @@ -306,7 +306,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setViewport( width = d3dCtx->devmode.dmPelsWidth; height = d3dCtx->devmode.dmPelsHeight; } - D3DVIEWPORT8 vp = {x, y, width, height, 0.0f, 1.0f}; + D3DVIEWPORT9 vp = {x, y, width, height, 0.0f, 1.0f}; device->SetViewport(&vp); } @@ -422,11 +422,21 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( jboolean db_enable_override, jboolean db_enable, jboolean db_write_enable, + jint db_func, jfloat at_value, jint at_func, jboolean ignoreVertexColors, jboolean rasterOpEnable, - jint rasterOp) + jint rasterOp, + jboolean userStencilAvailable, + jboolean stencilEnable, + jint stencilFailOp, + jint stencilZFailOp, + jint stencilZPassOp, + jint stencilFunction, + jint stencilReferenceValue, + jint stencilCompareMask, + jint stencilWriteMask) { GetDevice(); @@ -499,7 +509,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes( device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); d3dCtx->twoSideLightingEnable = false; - device->SetRenderState(D3DRS_ZBIAS, 0); + device->SetRenderState(D3DRS_DEPTHBIAS, 0); } @@ -535,7 +545,7 @@ void JNICALL Java_javax_media_j3d_PolygonAttributesRetained_updateNative( } } - device->SetRenderState(D3DRS_ZBIAS, zbias_w); + device->SetRenderState(D3DRS_DEPTHBIAS, zbias_w); if (cullFace == javax_media_j3d_PolygonAttributes_CULL_NONE) { d3dCtx->cullMode = D3DCULL_NONE; @@ -582,14 +592,16 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( // D3D don't support Line width // glLineWidth(1); - + //D3D9 doesnot support line Patterns + // must update this to use ID3DXLine Interface +/* D3DLINEPATTERN pattern; pattern.wRepeatFactor = 0; pattern.wLinePattern = 0; device->SetRenderState(D3DRS_LINEPATTERN, *((LPDWORD) (&pattern))); - +*/ } @@ -608,7 +620,8 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( { GetDevice(); - D3DLINEPATTERN pattern; + //Alessandro + //D3DLINEPATTERN pattern; /* if (lineWidth > 1) { @@ -619,12 +632,14 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( } */ // glLineWidth(lineWidth); - + /** Alessandro if (linePattern == javax_media_j3d_LineAttributes_PATTERN_SOLID) { pattern.wRepeatFactor = 0; pattern.wLinePattern = 0; } else { + **/ + /* if (!d3dCtx->deviceInfo->linePatternSupport) { if (debug && !isLinePatternMessOutput) { @@ -633,6 +648,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( } } */ + /** alessandro if (linePattern == javax_media_j3d_LineAttributes_PATTERN_DASH) { // dashed lines pattern.wRepeatFactor = 1; pattern.wLinePattern = 0x00ff; @@ -650,7 +666,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( device->SetRenderState(D3DRS_LINEPATTERN, *((LPDWORD) (&pattern))); - + **/ /* if (lineAntialiasing == JNI_TRUE) { glEnable (GL_LINE_SMOOTH); @@ -1378,7 +1394,7 @@ void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative( jint colorTarget, jboolean lightEnable) { - D3DMATERIAL8 material; + D3DMATERIAL9 material; GetDevice(); @@ -1650,8 +1666,8 @@ void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture( if (objectId >= d3dCtx->textureTableLen) { DWORD i; DWORD len = max(objectId+1, d3dCtx->textureTableLen << 1); - LPDIRECT3DTEXTURE8 *newTable = (LPDIRECT3DTEXTURE8 *) - malloc(sizeof(LPDIRECT3DTEXTURE8) * len); + LPDIRECT3DTEXTURE9 *newTable = (LPDIRECT3DTEXTURE9 *) + malloc(sizeof(LPDIRECT3DTEXTURE9) * len); if (newTable == NULL) { printf("Not enough memory to alloc texture table of size %d.\n", len); @@ -1698,31 +1714,31 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( switch (minFilter) { case javax_media_j3d_Texture_FASTEST: case javax_media_j3d_Texture_BASE_LEVEL_POINT: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MINFILTER, D3DTEXF_POINT); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MIPFILTER, D3DTEXF_POINT); + device->SetSamplerState(d3dCtx->texUnitStage, + D3DSAMP_MINFILTER, D3DTEXF_POINT); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MIPFILTER, D3DTEXF_POINT); break; case javax_media_j3d_Texture_BASE_LEVEL_LINEAR: - d3dCtx->texLinearMode = true; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MINFILTER, D3DTEXF_LINEAR); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MIPFILTER, D3DTEXF_POINT); + d3dCtx->texLinearMode = true; + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MIPFILTER, D3DTEXF_POINT); break; case javax_media_j3d_Texture_MULTI_LEVEL_POINT: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MINFILTER, D3DTEXF_POINT); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MIPFILTER, D3DTEXF_LINEAR); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MINFILTER, D3DTEXF_POINT); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); break; case javax_media_j3d_Texture_NICEST: case javax_media_j3d_Texture_MULTI_LEVEL_LINEAR: d3dCtx->texLinearMode = true; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MINFILTER, D3DTEXF_LINEAR); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MIPFILTER, D3DTEXF_LINEAR); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); break; } @@ -1730,14 +1746,14 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( switch (magFilter) { case javax_media_j3d_Texture_FASTEST: case javax_media_j3d_Texture_BASE_LEVEL_POINT: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MAGFILTER, D3DTEXF_POINT); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MAGFILTER, D3DTEXF_POINT); break; case javax_media_j3d_Texture_NICEST: case javax_media_j3d_Texture_BASE_LEVEL_LINEAR: d3dCtx->texLinearMode = true; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MAGFILTER, D3DTEXF_LINEAR); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); break; } @@ -1797,19 +1813,19 @@ void updateTextureBoundary(JNIEnv *env, switch (boundaryModeS) { case javax_media_j3d_Texture_WRAP: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSU, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); break; case javax_media_j3d_Texture_CLAMP: if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) { - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSU, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); } else { useBorderMode = TRUE; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSU, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); } break; @@ -1817,19 +1833,19 @@ void updateTextureBoundary(JNIEnv *env, switch (boundaryModeT) { case javax_media_j3d_Texture_WRAP: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSV, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); break; case javax_media_j3d_Texture_CLAMP: if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) { - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSV, - D3DTADDRESS_CLAMP); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSV, + D3DTADDRESS_CLAMP); } else { useBorderMode = TRUE; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSV, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); } break; @@ -1838,19 +1854,19 @@ void updateTextureBoundary(JNIEnv *env, if (boundaryModeR >= 0) { switch (boundaryModeR) { case javax_media_j3d_Texture_WRAP: - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSW, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP); break; case javax_media_j3d_Texture_CLAMP: if (!d3dCtx->texLinearMode || !d3dCtx->deviceInfo->texBorderModeSupport) { - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSW, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP); } else { useBorderMode = TRUE; - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_ADDRESSW, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_ADDRESSW, D3DTADDRESS_BORDER); } break; @@ -1861,8 +1877,8 @@ void updateTextureBoundary(JNIEnv *env, D3DCOLOR color = D3DCOLOR_COLORVALUE(boundaryRed, boundaryGreen, boundaryBlue, boundaryAlpha); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_BORDERCOLOR, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_BORDERCOLOR, *((DWORD *) &color)); } } @@ -1918,24 +1934,24 @@ void updateTextureAnisotropicFilter( DWORD deg = degree + 0.5f; // round float to int // This will overwrite the previous setting in // updateTextureFilterModes() - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MINFILTER, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MAGFILTER, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MIPFILTER, + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC); - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MAXANISOTROPY, deg); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MAXANISOTROPY, deg); } else { // updateTextureFilterModes() will always invoke before // updateTextureAnisotropicFilter() to set Filter mode // correctly. - device->SetTextureStageState(d3dCtx->texUnitStage, - D3DTSS_MAXANISOTROPY, 1); + device->SetSamplerState (d3dCtx->texUnitStage, + D3DSAMP_MAXANISOTROPY, 1); } } @@ -2010,7 +2026,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSubImage( return; } - LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[currBindTex]; + LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[currBindTex]; if ((surf == NULL) || ((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) { @@ -2074,7 +2090,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureImage( return; } - LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[currBindTex]; + LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[currBindTex]; if (level == 0) { if (surf != NULL) { @@ -2225,8 +2241,8 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_bindTexture( if (objectId >= d3dCtx->volumeTableLen) { DWORD i; DWORD len = max(objectId+1, d3dCtx->volumeTableLen << 1); - LPDIRECT3DVOLUMETEXTURE8 *newTable = (LPDIRECT3DVOLUMETEXTURE8 *) - malloc(sizeof(LPDIRECT3DVOLUMETEXTURE8) * len); + LPDIRECT3DVOLUMETEXTURE9 *newTable = (LPDIRECT3DVOLUMETEXTURE9 *) + malloc(sizeof(LPDIRECT3DVOLUMETEXTURE9) * len); if (newTable == NULL) { printf("Not enough memory to alloc volume texture table of size %d.\n", len); @@ -2371,7 +2387,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( return; } - LPDIRECT3DVOLUMETEXTURE8 surf = d3dCtx->volumeTable[currBindTex]; + LPDIRECT3DVOLUMETEXTURE9 surf = d3dCtx->volumeTable[currBindTex]; if (level == 0) { if (surf != NULL) { @@ -2465,7 +2481,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( return; } - LPDIRECT3DVOLUMETEXTURE8 surf = d3dCtx->volumeTable[currBindTex]; + LPDIRECT3DVOLUMETEXTURE9 surf = d3dCtx->volumeTable[currBindTex]; if ((surf == NULL) || ((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) { @@ -2520,8 +2536,8 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture( if (objectId >= d3dCtx->cubeMapTableLen) { DWORD i; DWORD len = max(objectId+1, d3dCtx->cubeMapTableLen << 1); - LPDIRECT3DCUBETEXTURE8 *newTable = (LPDIRECT3DCUBETEXTURE8 *) - malloc(sizeof(LPDIRECT3DCUBETEXTURE8) * len); + LPDIRECT3DCUBETEXTURE9 *newTable = (LPDIRECT3DCUBETEXTURE9 *) + malloc(sizeof(LPDIRECT3DCUBETEXTURE9) * len); if (newTable == NULL) { printf("Not enough memory to alloc cubeMap table of size %d.\n", len); @@ -2641,7 +2657,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSubImage( return; } - LPDIRECT3DCUBETEXTURE8 surf = d3dCtx->cubeMapTable[currBindTex]; + LPDIRECT3DCUBETEXTURE9 surf = d3dCtx->cubeMapTable[currBindTex]; if ((surf == NULL) || ((level > 0) && (!d3dCtx->deviceInfo->supportMipmap))) { @@ -2707,7 +2723,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( return; } - LPDIRECT3DCUBETEXTURE8 surf = d3dCtx->cubeMapTable[currBindTex]; + LPDIRECT3DCUBETEXTURE9 surf = d3dCtx->cubeMapTable[currBindTex]; if (level == 0) { if (surf != NULL) { diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp index 4195f14..3636e6d 100644 --- a/src/native/d3d/Canvas3D.cpp +++ b/src/native/d3d/Canvas3D.cpp @@ -55,9 +55,11 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( jlong fbConfigListPtr, jlong sharedCtx, jboolean isSharedCtx, - jboolean offScreen) + jboolean offScreen, + jboolean glslLibraryAvailable, + jboolean cgLibraryAvailable) { - HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window)); + HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window))); lock(); D3dCtx* ctx = new D3dCtx(env, obj, hwnd, offScreen, vid); @@ -109,9 +111,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( jlong fbConfigListPtr, jboolean offScreen, jint width, - jint height) + jint height, + jboolean glslLibraryAvailable, + jboolean cgLibraryAvailable) { - HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window)); + HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window))); lock(); // always use offscreen for property since it @@ -187,7 +191,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_composite( // However we use the following texturemapping function instead // so this will not invoke. if (d3dCtx->backSurface == NULL) { - device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, + device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO,//iSwapChain is 0 &d3dCtx->backSurface); } jbyte *byteData = (jbyte *) (env->GetPrimitiveArrayCritical( @@ -262,7 +266,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( env, texture, ctx, 0, minX, minY, J3D_RGBA, format, minX, minY, rasWidth, maxX-minX, maxY-minY, imageYdown); - LPDIRECT3DTEXTURE8 surf = d3dCtx->textureTable[objectId]; + LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[objectId]; if (surf == NULL) { if (debug) { @@ -366,7 +370,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( id = env->GetFieldID(pa2d_class, "height", "I"); int height = env->GetIntField(pa2d, id); - LPDIRECT3DTEXTURE8 surf; + LPDIRECT3DTEXTURE9 surf; if ((d3dImage == NULL) || (d3dImage->surf == NULL)) { surf = createSurfaceFromImage(env, pa2d, ctx, @@ -420,11 +424,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( sw = winWidth/(float) width; sh = winHeight/(float) height; if (sw >= sh) { - scaleWidth = width*sh; + scaleWidth = int(width*sh); scaleHeight = winHeight; } else { scaleWidth = winWidth; - scaleHeight = height*sw; + scaleHeight = int(height*sw); } texModeRepeat = FALSE; break; @@ -435,9 +439,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( sh = winHeight/(float) height; if (sw >= sh) { scaleWidth = winWidth; - scaleHeight = height*sw; + scaleHeight = int(height*sw); } else { - scaleWidth = width*sh; + scaleWidth = int(width*sh); scaleHeight = winHeight; } texModeRepeat = FALSE; @@ -551,7 +555,7 @@ VOID freePointerList() if (useFreePointerList0) { if (freePointerList1.size() > 0) { lockSurfaceList(); - for (void **p = freePointerList1.begin(); + for (ITER_VOID p = freePointerList1.begin(); p != freePointerList1.end(); ++p) { delete (*p); } @@ -563,7 +567,7 @@ VOID freePointerList() } else { if (freePointerList0.size() > 0) { lockSurfaceList(); - for (void **p = freePointerList0.begin(); + for (ITER_VOID p = freePointerList0.begin(); p != freePointerList0.end(); ++p) { delete (*p); } @@ -599,7 +603,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( if (D3DERR_DEVICENOTRESET == hr) { if (debug) { printf("Buffer swap error %s, try Reset() the surface... \n", - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); } retCode = d3dCtx->resetSurface(env, obj); GetDevice2(); @@ -607,7 +611,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( if (FAILED(hr)) { if (debug) { printf("Buffer swap error %s \n", - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); } } } @@ -891,11 +895,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer( } if (d3dCtx->backSurface == NULL) { - HRESULT hr = device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, + HRESULT hr = device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO, //iSwapChain is 0 &d3dCtx->backSurface); if (FAILED(hr)) { printf("[Java 3D] GetBackBuffer fail %s\n", - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); return; } } diff --git a/src/native/d3d/CompressedGeometryRetained.cpp b/src/native/d3d/CompressedGeometryRetained.cpp deleted file mode 100644 index df44ebb..0000000 --- a/src/native/d3d/CompressedGeometryRetained.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include "StdAfx.h" - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_CompressedGeometryRetained_execute - (JNIEnv *env, jobject obj, jlong ctx, jint version, jint bufferType, - jint bufferContents, jint renderFlags, jint offset, jint size, - jbyteArray geometry) -{ - // Not support by D3D, problem should not call this. - printf("Error: CompressedGeometryRetained execute should not invoke by D3D"); -} - -extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressByRef - (JNIEnv *env, jobject obj, jlong ctx) -{ - // Not support by D3D - return JNI_FALSE ; -} - -extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressHW - (JNIEnv *env, jobject obj, jlong ctx, jint majorVersion, jint minorVersion) -{ - // Not support by D3D - return JNI_FALSE ; -} diff --git a/src/native/d3d/D3dCtx.cpp b/src/native/d3d/D3dCtx.cpp index 05f0bc5..85c81b6 100644 --- a/src/native/d3d/D3dCtx.cpp +++ b/src/native/d3d/D3dCtx.cpp @@ -20,14 +20,14 @@ D3dCtxVector d3dCtxList; * D3dCtx ctx* = new D3dCtx(env, obj, hwnd, offScreen, vid); * if (ctx->initialize(env, obj)) { * delete ctx; - * } + * } * d3dCtxList.push_back(ctx); - * + * * * When ctx remove : * * d3dCtxList.erase(find(d3dCtxList.begin(), d3dCtxList.end(), ctx); - * delete ctx; + * delete ctx; * */ @@ -37,10 +37,10 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, jint vid) { int i; - + jniEnv = env; monitor = NULL; hwnd = _hwnd; - pD3D = NULL; + pD3D = NULL; pDevice = NULL; offScreen = _offScreen; offScreenWidth = 0; @@ -57,6 +57,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, inToggle = false; useFreeList0 = true; reIndexifyTable = NULL; + bFastDrawQuads = getSystemProperty(env,"j3d.d3dForceFastQuads","true"); // set default RenderingState variable cullMode = D3DCULL_CW; @@ -107,37 +108,37 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, bindTextureId = NULL; bindTextureIdLen = 0; - textureTable = (LPDIRECT3DTEXTURE8 *) malloc( - sizeof(LPDIRECT3DTEXTURE8) * TEXTURETABLESIZE); + textureTable = (LPDIRECT3DTEXTURE9 *) malloc( + sizeof(LPDIRECT3DTEXTURE9) * TEXTURETABLESIZE); if (textureTable == NULL) { error(OUTOFMEMORY); exit(1); } - ZeroMemory(textureTable, sizeof(LPDIRECT3DTEXTURE8)*TEXTURETABLESIZE); + ZeroMemory(textureTable, sizeof(LPDIRECT3DTEXTURE9)*TEXTURETABLESIZE); textureTableLen = TEXTURETABLESIZE; bindTextureId = NULL; - volumeTable = (LPDIRECT3DVOLUMETEXTURE8 *) malloc( - sizeof(LPDIRECT3DVOLUMETEXTURE8) * TEXTURETABLESIZE); + volumeTable = (LPDIRECT3DVOLUMETEXTURE9 *) malloc( + sizeof(LPDIRECT3DVOLUMETEXTURE9) * TEXTURETABLESIZE); if (volumeTable == NULL) { error(OUTOFMEMORY); exit(1); } - ZeroMemory(volumeTable, sizeof(LPDIRECT3DVOLUMETEXTURE8)*TEXTURETABLESIZE); + ZeroMemory(volumeTable, sizeof(LPDIRECT3DVOLUMETEXTURE9)*TEXTURETABLESIZE); volumeTableLen = TEXTURETABLESIZE; - cubeMapTable = (LPDIRECT3DCUBETEXTURE8 *) malloc( - sizeof(LPDIRECT3DCUBETEXTURE8) * TEXTURETABLESIZE); + cubeMapTable = (LPDIRECT3DCUBETEXTURE9 *) malloc( + sizeof(LPDIRECT3DCUBETEXTURE9) * TEXTURETABLESIZE); if (cubeMapTable == NULL) { error(OUTOFMEMORY); exit(1); } - ZeroMemory(cubeMapTable, sizeof(LPDIRECT3DCUBETEXTURE8)*TEXTURETABLESIZE); + ZeroMemory(cubeMapTable, sizeof(LPDIRECT3DCUBETEXTURE9)*TEXTURETABLESIZE); cubeMapTableLen = TEXTURETABLESIZE; @@ -152,14 +153,14 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, if (d3dDriverList == NULL) { // keep trying to initialize even though - // last time it fail. + // last time it fail. D3dDriverInfo::initialize(env); } if (d3dDriverList == NULL) { /* * This happen when either - * (1) D3D v8.0 not install or + * (1) D3D v9.0 not install or * (2) Not enough memory or * (3) No adapter found in the system. */ @@ -167,13 +168,13 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, return; } - pD3D = Direct3DCreate8( D3D_SDK_VERSION ); + pD3D = Direct3DCreate9( D3D_SDK_VERSION ); if (pD3D == NULL) { error(D3DNOTFOUND); return; } - // find current monitor handle before + // find current monitor handle before // get current display mode monitor = findMonitor(); @@ -185,7 +186,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, warning(NEEDSWITCHMODE); } - // find the adapter for this + // find the adapter for this setDriverInfo(); GetWindowRect(topHwnd, &savedTopRect); @@ -193,9 +194,9 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, for (i=0; i < 4; i++) { rasterRect[i].sx = 0; - rasterRect[i].sy = 0; + rasterRect[i].sy = 0; rasterRect[i].sz = 0; - rasterRect[i].rhw = 0; + rasterRect[i].rhw = 0; } rasterRect[0].tu = 0; @@ -216,7 +217,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, GetWindowRect(hwnd, &windowRect); } -D3dCtx::~D3dCtx() +D3dCtx::~D3dCtx() { release(); SafeRelease(pD3D); @@ -270,7 +271,7 @@ VOID D3dCtx::releaseTexture() D3dImageComponent::remove(&BackgroundImageList, this); unlockBackground(); - // free list0 + // free list0 freeList(); // free list1 freeList(); @@ -281,7 +282,7 @@ VOID D3dCtx::setViewport() int renderWidth = getWidth(); int renderHeight = getHeight(); HRESULT hr; - D3DVIEWPORT8 vp = {0, 0, renderWidth, renderHeight, 0.0f, 1.0f}; + D3DVIEWPORT9 vp = {0, 0, renderWidth, renderHeight, 0.0f, 1.0f}; hr = pDevice->SetViewport( &vp ); @@ -314,14 +315,15 @@ VOID D3dCtx::releaseVB() while (p != NULL) { vbVector = p->vbVector; if (vbVector != NULL) { - for (r = vbVector->begin(); r != vbVector->end(); ++r) { + for (ITER_LPD3DVERTEXBUFFER r = vbVector->begin(); + r != vbVector->end(); ++r) { if (*r == p) { vbVector->erase(r); found = true; break; } } - } + } q = p; p = p->next; delete q; @@ -352,7 +354,7 @@ VOID D3dCtx::release() quadIndexBufferSize = 0; releaseVB(); - // trying to free VertexBuffer + // trying to free VertexBuffer // This will crash the driver if Indices/StreamSource // Not set before. // pDevice->SetIndices(NULL, 0); @@ -360,7 +362,7 @@ VOID D3dCtx::release() SafeRelease(depthStencilSurface); SafeRelease(frontSurface); SafeRelease(backSurface); - + SafeRelease(pDevice); currDisplayListID = 0; multiTextureSupport = false; @@ -397,7 +399,7 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) oldWidth = offScreenWidth; offScreenWidth = driverInfo->desktopMode.Width; needBiggerRenderSurface = true; - + } if (offScreenHeight > driverInfo->desktopMode.Height) { @@ -410,7 +412,7 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) needBiggerRenderSurface = true; } */ - + if (!bFullScreen) { getScreenRect(hwnd, &savedClientRect); CopyMemory(&screenRect, &savedClientRect, sizeof (RECT)); @@ -419,21 +421,22 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) dwBehavior = findBehavior(); if (debug) { - printf("Use %s, ", driverInfo->adapterIdentifier.Description); - + printf("[Java3D]: Use %s, ", driverInfo->adapterIdentifier.Description); + if (deviceInfo->isHardwareTnL && - (dwBehavior == D3DCREATE_SOFTWARE_VERTEXPROCESSING)) { + (dwBehavior == D3DCREATE_SOFTWARE_VERTEXPROCESSING)) + { // user select non-TnL device printf("Hardware Rasterizer\n"); } else { - printf("%s \n", deviceInfo->deviceName); + printf("%s (TnL) \n", deviceInfo->deviceName); } } setPresentParams(env, obj); - + if (debug) { - printf("\nCreate device :\n"); + printf("\n[Java3D]: Create device :\n"); printInfo(&d3dPresent); } @@ -441,27 +444,75 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) if ((d3dPresent.BackBufferWidth <= 0) || (d3dPresent.BackBufferHeight <= 0)) { if (debug) { - printf("D3D: Can't create device of buffer size %dx%d\n", + printf("[Java3D]: D3D: Can't create device of buffer size %dx%d\n", d3dPresent.BackBufferWidth, d3dPresent.BackBufferHeight); } return false; } - hr = pD3D->CreateDevice(driverInfo->iAdapter, +if(bUseNvPerfHUD) +{ + // using NVIDIA NvPerfHUD profiler + printf("\n[Java3D]: running in NVIDIA NvPerfHUD mode:"); + UINT adapterToUse=driverInfo->iAdapter; + D3DDEVTYPE deviceType=deviceInfo->deviceType; + DWORD behaviorFlags = dwBehavior; + bool isHUDavail = false; + + // Look for 'NVIDIA NVPerfHUD' adapter + // If it is present, override default settings + for (UINT adapter=0;adapter<pD3D->GetAdapterCount(); adapter++) + { + D3DADAPTER_IDENTIFIER9 identifier; + HRESULT Res=pD3D->GetAdapterIdentifier(adapter,0,&identifier); + printf("\n Adapter identifier : %s",identifier.Description); + if (strcmp(identifier.Description,"NVIDIA NVPerfHUD")==0) + { + adapterToUse=adapter; + deviceType=D3DDEVTYPE_REF; + behaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; + isHUDavail = true; + printf("\n[Java3D]: found a NVIDIA NvPerfHUD adapter"); + break; + } + } + hr = pD3D->CreateDevice( adapterToUse, + deviceType, + topHwnd, + behaviorFlags, + &d3dPresent, + &pDevice); + if(!FAILED(hr)&& isHUDavail) + { + printf("\n[Java3D]: Using NVIDIA NvPerfHUD ! \n"); + } + else + { + printf("\n[Java3D]: No suitable device found for NVIDIA NvPerfHUD ! \n"); + } +} +else +{ + // NORMAL Mode + hr = pD3D->CreateDevice(driverInfo->iAdapter, deviceInfo->deviceType, topHwnd, dwBehavior, &d3dPresent, &pDevice); +} + - if (FAILED(hr) && (requiredDeviceID < 0)) { + if (FAILED(hr) && (requiredDeviceID < 0)) + { + printf("\n[Java3D]: Using D3DDEVTYPE_REF mode.\n"); if (deviceInfo->deviceType != D3DDEVTYPE_REF) { // switch to reference mode warning(CREATEDEVICEFAIL, hr); deviceInfo = driverInfo->d3dDeviceList[DEVICE_REF]; - dwBehavior = findBehavior(); - deviceInfo->findDepthStencilFormat(minZDepth); + dwBehavior = findBehavior(); + deviceInfo->findDepthStencilFormat(minZDepth); d3dPresent.AutoDepthStencilFormat = deviceInfo->depthStencilFormat; if (deviceInfo->depthStencilFormat == D3DFMT_UNKNOWN) { @@ -471,8 +522,8 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) return false; } if (debug) { - printf("Fallback to create reference device :\n"); - printInfo(&d3dPresent); + printf("[Java3D]: Fallback to create reference device :\n"); + printInfo(&d3dPresent); } hr = pD3D->CreateDevice(driverInfo->iAdapter, @@ -482,12 +533,12 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) &d3dPresent, &pDevice); } - } + } /* if (offScreen && needBiggerRenderSurface) { - IDirect3DSurface8 *pRenderTarget; - IDirect3DSurface8 *pStencilDepthTarget; + IDirect3DSurface9 *pRenderTarget; + IDirect3DSurface9 *pStencilDepthTarget; hr = pDevice->CreateRenderTarget(oldWidth, oldHeight, @@ -495,9 +546,9 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) D3DMULTISAMPLE_NONE, true, &pRenderTarget); - + if (FAILED(hr)) { - printf("Fail to CreateRenderTarget %s\n", DXGetErrorString8(hr)); + printf("Fail to CreateRenderTarget %s\n", DXGetErrorString9(hr)); } else { hr = pDevice->CreateDepthStencilSurface(oldWidth, oldHeight, @@ -505,13 +556,13 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) D3DMULTISAMPLE_NONE, &pStencilDepthTarget); if (FAILED(hr)) { - printf("Fail to CreateDepthStencilSurface %s\n", DXGetErrorString8(hr)); + printf("Fail to CreateDepthStencilSurface %s\n", DXGetErrorString9(hr)); pRenderTarget->Release(); } else { hr = pDevice->SetRenderTarget(pRenderTarget, pStencilDepthTarget); if (FAILED(hr)) { - printf("Fail to SetRenderTarget %s\n", DXGetErrorString8(hr)); + printf("Fail to SetRenderTarget %s\n", DXGetErrorString9(hr)); pRenderTarget->Release(); pStencilDepthTarget->Release(); } else { @@ -541,8 +592,12 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) bindTextureIdLen = 1; } - jclass canvasCls = env->GetObjectClass(obj); - jfieldID id = env->GetFieldID(canvasCls, "numTexCoordSupported", "I"); + + jclass canvasCls = env->GetObjectClass(obj); + jfieldID id; + + // TODO check it !!!! + id = env->GetFieldID(canvasCls, "maxTexCoordSets", "I"); //was numtexCoordSupported env->SetIntField(obj, id, TEXSTAGESUPPORT); if (bindTextureIdLen > 1) { @@ -551,9 +606,11 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) bindTextureIdLen = TEXSTAGESUPPORT; } multiTextureSupport = true; - id = env->GetFieldID(canvasCls, "multiTexAccelerated", "Z"); + id = env->GetFieldID(canvasCls, "multiTexAccelerated", "Z"); env->SetBooleanField(obj, id, JNI_TRUE); - id = env->GetFieldID(canvasCls, "numTexUnitSupported", "I"); + + // TODO check it !!!! + id = env->GetFieldID(canvasCls, "maxTextureUnits", "I"); //was numTexUnitSupported env->SetIntField(obj, id, bindTextureIdLen); } else { bindTextureIdLen = 1; @@ -573,10 +630,10 @@ BOOL D3dCtx::initialize(JNIEnv *env, jobject obj) if (debug && (deviceInfo != NULL)) { if (multiTextureSupport) { - printf("Max Texture Unit Stage support : %d \n", + printf("Max Texture Unit Stage support : %d \n", deviceInfo->maxTextureBlendStages); - printf("Max Simultaneous Texture unit support : %d \n", + printf("Max Simultaneous Texture unit support : %d \n", deviceInfo->maxSimultaneousTextures); } else { printf("MultiTexture support : false\n"); @@ -606,7 +663,7 @@ INT D3dCtx::resize(JNIEnv *env, jobject obj) BOOL moveRequest; - GetWindowRect(hwnd, &windowRect); + GetWindowRect(hwnd, &windowRect); if ((windowRect.right == screenRect.right) && (windowRect.left == screenRect.left) && @@ -624,22 +681,22 @@ INT D3dCtx::resize(JNIEnv *env, jobject obj) moveRequest = false; } - + HMONITOR oldMonitor = monitor; monitor = findMonitor(); - getScreenRect(hwnd, &screenRect); + getScreenRect(hwnd, &screenRect); if (monitor != oldMonitor) { - enumDisplayMode(&devmode); + enumDisplayMode(&devmode); setDriverInfo(); release(); initialize(env, obj); - return RECREATEDDRAW; - } + return RECREATEDDRAW; + } if (!moveRequest) { - + retValue = resetSurface(env, obj); if (retValue != RECREATEDFAIL) { return retValue; @@ -656,16 +713,16 @@ INT D3dCtx::toggleMode(BOOL _bFullScreen, JNIEnv *env, jobject obj) INT retValue; if ((pDevice == NULL) || - (!_bFullScreen && + (!_bFullScreen && !deviceInfo->canRenderWindowed)) { // driver did not support window mode return NOCHANGE; } - + int onScreenCount = 0; - - for (D3dCtx **p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) { - if (!(*p)->offScreen && + + for (ITER_D3dCtxVector p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) { + if (!(*p)->offScreen && // (monitor == (*p)->monitor) && (++onScreenCount > 1)) { // don't toggle if there are more than one onScreen ctx exists @@ -683,7 +740,7 @@ INT D3dCtx::toggleMode(BOOL _bFullScreen, JNIEnv *env, jobject obj) if (retValue != RECREATEDFAIL) { forceResize = true; } else { - // Switch back to window mode if fall to toggle fullscreen + // Switch back to window mode if fall to toggle fullscreen // and vice versa bFullScreen = !bFullScreen; release(); @@ -729,7 +786,7 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj) GetWindowRect(hwnd, &savedClientRect); d3dPresent.Windowed = false; - d3dPresent.hDeviceWindow = topHwnd; + d3dPresent.hDeviceWindow = topHwnd; if ((antialiasing != UNNECESSARY) && deviceInfo->supportAntialiasing()) { @@ -741,7 +798,10 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj) d3dPresent.BackBufferHeight = driverInfo->desktopMode.Height; d3dPresent.BackBufferFormat = driverInfo->desktopMode.Format; d3dPresent.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; - d3dPresent.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE; + if (deviceInfo->supportRasterPresImmediate) + d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + else + d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_ONE; } else { d3dPresent.Windowed = true; @@ -757,7 +817,11 @@ VOID D3dCtx::setPresentParams(JNIEnv *env, jobject obj) d3dPresent.BackBufferHeight = getHeight(); d3dPresent.BackBufferFormat = driverInfo->desktopMode.Format; d3dPresent.FullScreen_RefreshRateInHz = 0; - d3dPresent.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; + + if (deviceInfo->supportRasterPresImmediate) + d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + else + d3dPresent.PresentationInterval = D3DPRESENT_INTERVAL_ONE; } @@ -788,15 +852,15 @@ INT D3dCtx::resetSurface(JNIEnv *env, jobject obj) setPresentParams(env, obj); if (debug) { printf("\nReset Device :\n"); - printInfo(&d3dPresent); - } + printInfo(&d3dPresent); + } // Must release any non default pool surface, otherwise // Reset() will fail SafeRelease(depthStencilSurface); SafeRelease(frontSurface); SafeRelease(backSurface); - + releaseVB(); SafeRelease(lineModeIndexBuffer); quadIndexBufferSize = 0; @@ -822,12 +886,12 @@ INT D3dCtx::resetSurface(JNIEnv *env, jobject obj) } -VOID D3dCtx::error(int idx) +VOID D3dCtx::error(int idx) { error(getErrorMessage(idx)); } -VOID D3dCtx::error(int idx, HRESULT hr) +VOID D3dCtx::error(int idx, HRESULT hr) { error(getErrorMessage(idx), hr); } @@ -835,37 +899,37 @@ VOID D3dCtx::error(int idx, HRESULT hr) VOID D3dCtx::warning(int idx) { - printf("%s\n", getErrorMessage(idx)); + printf("[Java3D] Warning : %s\n", getErrorMessage(idx)); } -VOID D3dCtx::warning(int idx, HRESULT hr) +VOID D3dCtx::warning(int idx, HRESULT hr) { - printf("%s - %s\n", getErrorMessage(idx), DXGetErrorString8(hr)); + printf("[Java3D] Warning : %s - %s\n", getErrorMessage(idx), DXGetErrorString9(hr)); } -VOID D3dCtx::error(char *s) +VOID D3dCtx::error(char *s) { showError(hwnd, s, bFullScreen); } -VOID D3dCtx::error(char *s, HRESULT hr) +VOID D3dCtx::error(char *s, HRESULT hr) { char message[400]; - sprintf(message, "%s - %s", s, DXGetErrorString8(hr)); - showError(hwnd, message, bFullScreen); + sprintf(message, "%s - %s", s, DXGetErrorString9(hr)); + showError(hwnd, message, bFullScreen); } VOID D3dCtx::d3dWarning(int idx) { - printf("%s\n", getErrorMessage(idx)); + printf("[Java3D] Warning: %s\n", getErrorMessage(idx)); } - -VOID D3dCtx::d3dWarning(int idx, HRESULT hr) + +VOID D3dCtx::d3dWarning(int idx, HRESULT hr) { - printf("%s - %s\n", - getErrorMessage(idx), DXGetErrorString8(hr)); + printf("[Java3D] Warning: %s - %s\n", + getErrorMessage(idx), DXGetErrorString9(hr)); } @@ -889,7 +953,7 @@ VOID D3dCtx::showError(HWND hwnd, char *s, BOOL bFullScreen) firstError = false; if (bFullScreen) { // In full screen mode, we can't see message box - printf("[Java 3D] %s\n", s); + printf("[Java3D] Error: %s\n", s); exit(1); } else { MessageBox(hwnd, s, "Java 3D", MB_OK|MB_ICONERROR); @@ -898,7 +962,7 @@ VOID D3dCtx::showError(HWND hwnd, char *s, BOOL bFullScreen) } -DWORD D3dCtx::getWidth() +DWORD D3dCtx::getWidth() { if (!offScreen) { return screenRect.right - screenRect.left; @@ -909,7 +973,7 @@ DWORD D3dCtx::getWidth() } -DWORD D3dCtx::getHeight() +DWORD D3dCtx::getHeight() { if (!offScreen) { return screenRect.bottom - screenRect.top; @@ -927,10 +991,10 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID, D3dDeviceInfo *pDevice; for (int i=0; i < numDeviceTypes; i++) { - pDevice = driverInfo->d3dDeviceList[i]; + pDevice = driverInfo->d3dDeviceList[i]; if ((((deviceID == DEVICE_HAL) || (deviceID == DEVICE_HAL_TnL)) && (pDevice->deviceType == D3DDEVTYPE_HAL)) || - (deviceID == DEVICE_REF) && + (deviceID == DEVICE_REF) && (pDevice->deviceType == D3DDEVTYPE_REF)) { if ((*bFullScreen && !pDevice->fullscreenCompatible) || (!*bFullScreen && !pDevice->desktopCompatible)) { @@ -943,7 +1007,7 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID, exit(1); } if (pDevice->maxZBufferDepthSize == 0) { - if (pDevice->deviceType == D3DDEVTYPE_HAL) { + if (pDevice->deviceType == D3DDEVTYPE_HAL) { d3dError(HALNOTCOMPATIBLE); } else { // should not happen, REF device always support @@ -964,7 +1028,7 @@ D3dDeviceInfo* D3dCtx::selectDevice(int deviceID, exit(1); } return pDevice; - } + } } @@ -989,7 +1053,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo, if (pDevice->depthStencilFormat == D3DFMT_UNKNOWN) { if (pDevice->deviceType == D3DDEVTYPE_REF) { - d3dError(DEPTHSTENCILNOTFOUND); + d3dError(DEPTHSTENCILNOTFOUND); return NULL; } else { continue; @@ -1015,7 +1079,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo, } } } - } + } } if (bestDevice == NULL) { @@ -1023,7 +1087,7 @@ D3dDeviceInfo* D3dCtx::selectBestDevice(D3dDriverInfo *driverInfo, d3dError(DEVICENOTFOUND); return NULL; } - + // TODO: suggest another display mode for user /* if (bestDevice->deviceType == D3DDEVTYPE_REF) { @@ -1053,14 +1117,14 @@ VOID D3dCtx::setDeviceFromProperty(JNIEnv *env) if ( systemClass != NULL ) { - jmethodID method = env->GetStaticMethodID( + jmethodID method = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" ); if ( method != NULL ) { jstring name = env->NewStringUTF( "j3d.d3ddevice" ); jstring property = reinterpret_cast<jstring>( - env->CallStaticObjectMethod( + env->CallStaticObjectMethod( systemClass, method, name )); jboolean isCopy; @@ -1086,12 +1150,12 @@ VOID D3dCtx::setDeviceFromProperty(JNIEnv *env) } name = env->NewStringUTF( "j3d.d3ddriver" ); property = reinterpret_cast<jstring>( - env->CallStaticObjectMethod( + env->CallStaticObjectMethod( systemClass, method, name )); if ( property != NULL ) { const char* chars = env->GetStringUTFChars( - property, &isCopy); + property, &isCopy); if ( chars != 0 ) { // atoi() return 0, our default value, on error. @@ -1112,14 +1176,14 @@ VOID D3dCtx::setFullScreenFromProperty(JNIEnv *env) if ( systemClass != NULL ) { - jmethodID method = env->GetStaticMethodID( + jmethodID method = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" ); if ( method != NULL ) { jstring name = env->NewStringUTF( "j3d.fullscreen" ); jstring property = reinterpret_cast<jstring>( - env->CallStaticObjectMethod( + env->CallStaticObjectMethod( systemClass, method, name )); if ( property != NULL ) { @@ -1149,14 +1213,14 @@ VOID D3dCtx::setVBLimitProperty(JNIEnv *env) if ( systemClass != NULL ) { - jmethodID method = env->GetStaticMethodID( + jmethodID method = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" ); if ( method != NULL ) { jstring name = env->NewStringUTF( "j3d.vertexbufferlimit" ); jstring property = reinterpret_cast<jstring>( - env->CallStaticObjectMethod( + env->CallStaticObjectMethod( systemClass, method, name )); if ( property != NULL ) { @@ -1190,14 +1254,14 @@ VOID D3dCtx::setDebugProperty(JNIEnv *env) if ( systemClass != NULL ) { - jmethodID method = env->GetStaticMethodID( + jmethodID method = env->GetStaticMethodID( systemClass, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;" ); if ( method != NULL ) { jstring name = env->NewStringUTF( "j3d.debug" ); jstring property = reinterpret_cast<jstring>( - env->CallStaticObjectMethod( + env->CallStaticObjectMethod( systemClass, method, name )); if ( property != NULL ) { @@ -1219,6 +1283,41 @@ VOID D3dCtx::setDebugProperty(JNIEnv *env) } } +BOOL D3dCtx::getSystemProperty(JNIEnv *env, char *strName, char *strValue) +{ + jclass systemClass = env->FindClass( "javax/media/j3d/MasterControl" ); + + if ( systemClass != NULL ) + { + jmethodID method = env->GetStaticMethodID( + systemClass, "getProperty", + "(Ljava/lang/String;)Ljava/lang/String;" ); + if ( method != NULL ) + { + jstring name = env->NewStringUTF( strName ); + jstring property = reinterpret_cast<jstring>( + env->CallStaticObjectMethod( + systemClass, method, name )); + if ( property != NULL ) + { + jboolean isCopy; + const char * chars = env->GetStringUTFChars(property, &isCopy ); + if ( chars != 0 && stricmp( chars, strValue ) == 0 ) + { + env->ReleaseStringUTFChars( property, chars ); + return true; + } + else + { + env->ReleaseStringUTFChars( property, chars ); + return false; + } + } + } + } + return false; +} + VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env) { jclass cls = env->FindClass("javax/media/j3d/VirtualUniverse"); @@ -1227,7 +1326,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env) implicitMultisample = false; return; } - + jfieldID fieldID = env->GetStaticFieldID(cls, "mc", "Ljavax/media/j3d/MasterControl;"); if (fieldID == NULL) { @@ -1242,7 +1341,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env) return; } - cls = env->FindClass("javax/media/j3d/MasterControl"); + cls = env->FindClass("javax/media/j3d/MasterControl"); if (cls == NULL) { implicitMultisample = false; @@ -1262,7 +1361,7 @@ VOID D3dCtx::setImplicitMultisamplingProperty(JNIEnv *env) // Callback to notify Canvas3D which mode it is currently running -VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj) +VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj) { int mask = javax_media_j3d_Canvas3D_EXT_ABGR | javax_media_j3d_Canvas3D_EXT_BGR; @@ -1276,11 +1375,11 @@ VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj) } jclass canvasCls = env->GetObjectClass(obj); - jfieldID id = env->GetFieldID(canvasCls, "fullScreenMode", "Z"); + jfieldID id = env->GetFieldID(canvasCls, "fullScreenMode", "Z"); env->SetBooleanField(obj, id, bFullScreen); - id = env->GetFieldID(canvasCls, "fullscreenWidth", "I"); + id = env->GetFieldID(canvasCls, "fullscreenWidth", "I"); env->SetIntField(obj, id, driverInfo->desktopMode.Width); - id = env->GetFieldID(canvasCls, "fullscreenHeight", "I"); + id = env->GetFieldID(canvasCls, "fullscreenHeight", "I"); env->SetIntField(obj, id, driverInfo->desktopMode.Height); id = env->GetFieldID(canvasCls, "textureExtendedFeatures", "I"); @@ -1288,35 +1387,54 @@ VOID D3dCtx::setCanvasProperty(JNIEnv *env, jobject obj) id = env->GetFieldID(canvasCls, "extensionsSupported", "I"); env->SetIntField(obj, id, mask); - + id = env->GetFieldID(canvasCls, "nativeGraphicsVersion", "Ljava/lang/String;"); - char *version = "DirectX 8.0 or above"; + char *version = "DirectX 9.0 or above"; env->SetObjectField(obj, id, env->NewStringUTF(version)); - float degree = deviceInfo->maxAnisotropy; + float degree = float(deviceInfo->maxAnisotropy); id = env->GetFieldID(canvasCls, "anisotropicDegreeMax", "F"); env->SetFloatField(obj, id, degree); id = env->GetFieldID(canvasCls, "textureWidthMax", "I"); - env->SetIntField(obj, id, deviceInfo->maxTextureWidth); + env->SetIntField(obj, id, deviceInfo->maxTextureWidth); id = env->GetFieldID(canvasCls, "textureHeightMax", "I"); - env->SetIntField(obj, id, deviceInfo->maxTextureHeight); + env->SetIntField(obj, id, deviceInfo->maxTextureHeight); if (deviceInfo->maxTextureDepth > 0) { id = env->GetFieldID(canvasCls, "texture3DWidthMax", "I"); - env->SetIntField(obj, id, deviceInfo->maxTextureWidth); + env->SetIntField(obj, id, deviceInfo->maxTextureWidth); id = env->GetFieldID(canvasCls, "texture3DHeightMax", "I"); - env->SetIntField(obj, id, deviceInfo->maxTextureHeight); + env->SetIntField(obj, id, deviceInfo->maxTextureHeight); id = env->GetFieldID(canvasCls, "texture3DDepthMax", "I"); env->SetIntField(obj, id, deviceInfo->maxTextureDepth); + + // issue 135 + // private String nativeGraphicsVendor = "<UNKNOWN>"; + // private String nativeGraphicsRenderer = "<UNKNOWN>"; + id = env->GetFieldID(canvasCls, "nativeGraphicsVendor", "Ljava/lang/String;"); + //char *nGVendor = driverInfo->adapterIdentifier.DeviceName ; + char *nGVendor = deviceInfo->deviceVendor ; + env->SetObjectField(obj, id, env->NewStringUTF(nGVendor)); + // printf("DEBUG vendor : %s ", nGVendor); + + id = env->GetFieldID(canvasCls, "nativeGraphicsRenderer", "Ljava/lang/String;"); + // char *nGRenderer = driverInfo->adapterIdentifier.Description; + char *nGRenderer = deviceInfo->deviceRenderer; + env->SetObjectField(obj, id, env->NewStringUTF(nGRenderer)); + + } } -VOID D3dCtx::createVertexBuffer() + + + +VOID D3dCtx::createVertexBuffer() { if (srcVertexBuffer != NULL) { // Each pDevice has its own vertex buffer, @@ -1328,27 +1446,45 @@ VOID D3dCtx::createVertexBuffer() if (dstVertexBuffer != NULL) { dstVertexBuffer->Release(); } + DWORD usage_D3DVERTEX = D3DUSAGE_DONOTCLIP| + D3DUSAGE_WRITEONLY| + D3DUSAGE_SOFTWAREPROCESSING; + + DWORD usage_D3DTLVERTEX= D3DUSAGE_DONOTCLIP| + D3DUSAGE_SOFTWAREPROCESSING; + +//# if NVIDIA_DEBUG + if(deviceInfo->isHardwareTnL) + { + // remove SoftwareProcessing + usage_D3DVERTEX = D3DUSAGE_DONOTCLIP| + D3DUSAGE_WRITEONLY; + + usage_D3DTLVERTEX = D3DUSAGE_DONOTCLIP; + } +// # endif HRESULT hr = pDevice->CreateVertexBuffer(sizeof(D3DVERTEX), - D3DUSAGE_DONOTCLIP| - D3DUSAGE_WRITEONLY| - D3DUSAGE_SOFTWAREPROCESSING, + usage_D3DVERTEX, D3DFVF_XYZ, D3DPOOL_MANAGED, - &srcVertexBuffer); + &srcVertexBuffer, + NULL); if (FAILED(hr)) { + printf("\n[Java3D] Failed to create VertexBuffer (D3DVERTEX)\n"); error(CREATEVERTEXBUFFER, hr); + } hr = pDevice->CreateVertexBuffer(sizeof(D3DTLVERTEX), - D3DUSAGE_DONOTCLIP| - D3DUSAGE_SOFTWAREPROCESSING, + usage_D3DTLVERTEX, D3DFVF_XYZRHW|D3DFVF_TEX1, D3DPOOL_MANAGED, - &dstVertexBuffer); + &dstVertexBuffer,NULL); if (FAILED(hr)) { + printf("\n[Java3D] Warning: Failed to create VertexBuffer (D3DTLVERTEX)\n"); error(CREATEVERTEXBUFFER, hr); } } @@ -1377,34 +1513,39 @@ VOID D3dCtx::transform(D3DVERTEX *worldCoord, D3DTLVERTEX *screenCoord) { if (!softwareVertexProcessing) { // ProcessVertices() only work in software vertex // processing mode - pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, - TRUE); + //pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE); + pDevice->SetSoftwareVertexProcessing(TRUE); } pDevice->SetRenderState(D3DRS_CLIPPING, FALSE); - hr = srcVertexBuffer->Lock(0, 0, (BYTE **)&pv, 0); + hr = srcVertexBuffer->Lock(0, 0, (VOID **)&pv, 0); if (FAILED(hr)) { if (debug) { - printf("Fail to lock buffer %s\n", DXGetErrorString8(hr)); + printf("[Java3D] Fail to lock buffer %s\n", DXGetErrorString9(hr)); } } else { pv[0].x = worldCoord->x; pv[0].y = worldCoord->y; pv[0].z = worldCoord->z; - + srcVertexBuffer->Unlock(); - pDevice->SetStreamSource(0, srcVertexBuffer, - sizeof(D3DVERTEX)); - pDevice->SetVertexShader(D3DFVF_XYZ); + pDevice->SetStreamSource(0, srcVertexBuffer,0, sizeof(D3DVERTEX)); + + //pDevice->SetVertexShader(D3DFVF_XYZ); + pDevice->SetVertexShader(NULL); + pDevice->SetFVF(D3DFVF_XYZ); + hr = pDevice->ProcessVertices(0, 0, 1, - dstVertexBuffer, 0); - + dstVertexBuffer, + NULL, + 0); + if (FAILED(hr)) { if (debug) { - printf("Fail to processVertices %s\n", DXGetErrorString8(hr)); + printf("[Java3D] Fail to processVertices %s\n", DXGetErrorString9(hr)); } } else { - hr = dstVertexBuffer->Lock(0, 0, (BYTE **)&tlpv, D3DLOCK_READONLY); + hr = dstVertexBuffer->Lock(0, 0, (VOID **)&tlpv, D3DLOCK_READONLY); if (SUCCEEDED(hr)) { screenCoord->sx = tlpv[0].sx; screenCoord->sy = tlpv[0].sy; @@ -1420,12 +1561,12 @@ VOID D3dCtx::transform(D3DVERTEX *worldCoord, D3DTLVERTEX *screenCoord) { } pDevice->SetRenderState(D3DRS_CLIPPING, TRUE); if (!softwareVertexProcessing) { - pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, - FALSE); + //pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE); + pDevice->SetSoftwareVertexProcessing(FALSE); } // restore original texture state pDevice->SetTextureStageState(0, D3DTSS_COLOROP, texState); - } + } } @@ -1437,13 +1578,13 @@ VOID D3dCtx::getScreenRect(HWND hwnd, RECT *rect) { if ((deviceInfo->isHardware) && (numDriver > 1)) { - MONITORINFO info; + MONITORINFO info; HMONITOR hMonitor = driverInfo->hMonitor; info.cbSize = sizeof(MONITORINFO); if (hMonitor == NULL) { - hMonitor = MonitorFromWindow(hwnd, - MONITOR_DEFAULTTONEAREST); + hMonitor = MonitorFromWindow(hwnd, + MONITOR_DEFAULTTONEAREST); } GetMonitorInfo(hMonitor, &info); monitorLeft = info.rcMonitor.left; @@ -1463,20 +1604,20 @@ VOID D3dCtx::getScreenRect(HWND hwnd, RECT *rect) { * Return NULL if this window intersect several monitor */ -HMONITOR D3dCtx::findMonitor() +HMONITOR D3dCtx::findMonitor() { if ((osvi.dwMajorVersion < 4) || (numDriver < 2)) { return NULL; - } + } RECT rect; - MONITORINFO info; - HMONITOR hmonitor = MonitorFromWindow(hwnd, - MONITOR_DEFAULTTONEAREST); + MONITORINFO info; + HMONITOR hmonitor = MonitorFromWindow(hwnd, + MONITOR_DEFAULTTONEAREST); info.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hmonitor, &info); + GetMonitorInfo(hmonitor, &info); GetWindowRect(hwnd, &rect); if ((info.rcMonitor.left <= rect.left) && @@ -1502,7 +1643,7 @@ D3dDeviceInfo* D3dCtx::setDeviceInfo(D3dDriverInfo *driverInfo, int minZDepth) { if (requiredDeviceID >= 0) { - return selectDevice(requiredDeviceID, driverInfo, + return selectDevice(requiredDeviceID, driverInfo, bFullScreen, minZDepth); } else { return selectBestDevice(driverInfo, bFullScreen, @@ -1528,7 +1669,7 @@ VOID D3dCtx::setDriverInfo() if (d3dDriverList[i]->hMonitor == monitor) { newDriver = d3dDriverList[i]; break; - } + } } } } else { @@ -1545,26 +1686,27 @@ VOID D3dCtx::setDriverInfo() VOID D3dCtx::setDefaultAttributes() { - pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, - softwareVertexProcessing); + /*pDevice->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, + softwareVertexProcessing);*/ + pDevice->SetSoftwareVertexProcessing(softwareVertexProcessing); pDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); pDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); pDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); - // Default specular is FALSE + // Default specular is FALSE pDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE); // Texture & CULL mode default value for D3D is different from OGL pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); - // Default in D3D is D3DCMP_LESSEQUAL, OGL is D3DCMP_LESS + // Default in D3D is D3DCMP_LESSEQUAL, OGL is D3DCMP_LESS // Set Range based fog - pDevice->SetRenderState(D3DRS_RANGEFOGENABLE, + pDevice->SetRenderState(D3DRS_RANGEFOGENABLE, deviceInfo->rangeFogEnable); - + // disable antialiasing (default is true in D3D) if (!implicitMultisample) { pDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE); @@ -1582,13 +1724,13 @@ VOID D3dCtx::setDefaultAttributes() pDevice->SetTextureStageState(i, D3DTSS_COLORARG1, D3DTA_TEXTURE); pDevice->SetTextureStageState(i, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); pDevice->SetTextureStageState(i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); - pDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); - pDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); + //pDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); + //pDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); bindTextureId[i] = -1; } } - + for (int i=0; i < TEXSTAGESUPPORT; i++) { texGenMode[i] = TEX_GEN_NONE; texTransformSet[i] = false; @@ -1599,11 +1741,11 @@ VOID D3dCtx::setDefaultAttributes() } } -VOID D3dCtx::enumDisplayMode(DEVMODE* dmode) +VOID D3dCtx::enumDisplayMode(DEVMODE* dmode) { MONITORINFOEX mi; - + if (monitor == NULL) { EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, dmode ); } else { @@ -1613,22 +1755,70 @@ VOID D3dCtx::enumDisplayMode(DEVMODE* dmode) EnumDisplaySettings( mi.szDevice, ENUM_CURRENT_SETTINGS, dmode); } } - -DWORD D3dCtx::findBehavior() +// check what kind of Vertex processing will be used +DWORD D3dCtx::findBehavior() { + bForceHwdVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","hardware"); + bForceMixVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","mixed"); + bForceSWVertexProcess = getSystemProperty(jniEnv,"j3d.d3dVertexProcess","software"); + + bUseNvPerfHUD = getSystemProperty(jniEnv,"j3d.useNvPerfHUD","true"); + + if (bUseNvPerfHUD) // must have bForceHwdVertexProcess as true + { + printf("\n[Java3D]: using j3d.useNvPerfHUD=true\n"); + bForceHwdVertexProcess = true; + bForceMixVertexProcess = false; + bForceSWVertexProcess = false; + } + + if (bForceHwdVertexProcess) + { + softwareVertexProcessing = FALSE; + printf("\n[Java3D]: using d3dVertexProcess=hardware\n"); + return D3DCREATE_HARDWARE_VERTEXPROCESSING; + } + + if (bForceMixVertexProcess) + { + printf("\n[Java3D]: using d3dVertexProcess=mixed\n"); + softwareVertexProcessing = FALSE; + return D3DCREATE_MIXED_VERTEXPROCESSING; + } + + if (bForceSWVertexProcess) + { + printf("\n[Java3D]: using d3dVertexProcess=software\n"); + softwareVertexProcessing = TRUE; + return D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } + // high-end video cards: NV25 and above + if (deviceInfo->isHardwareTnL && deviceInfo->supportShaders11 && + ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL))) + { + if (debug){printf("\n[Java3D]: using hardware Vertex Processing.\n");} + softwareVertexProcessing = FALSE; + return D3DCREATE_HARDWARE_VERTEXPROCESSING; + } + // midle-end video cards if (deviceInfo->isHardwareTnL && - ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL))) { - softwareVertexProcessing = FALSE; - return D3DCREATE_MIXED_VERTEXPROCESSING; - } else { - softwareVertexProcessing = TRUE; - return D3DCREATE_SOFTWARE_VERTEXPROCESSING; - } + ((requiredDeviceID < 0) || (requiredDeviceID == DEVICE_HAL_TnL))) + { + if (debug){printf("\n[Java3D]: using mixed Vertex Processing.\n");} + softwareVertexProcessing = FALSE; + return D3DCREATE_MIXED_VERTEXPROCESSING; + } + else // low-end vcards use Software Vertex Processing + { + if (debug){printf("\n[Java3D]: using software Vertex Processing.\n");} + softwareVertexProcessing = TRUE; + return D3DCREATE_SOFTWARE_VERTEXPROCESSING; + } } -VOID D3dCtx::printInfo(D3DPRESENT_PARAMETERS *d3dPresent) +VOID D3dCtx::printInfo(D3DPRESENT_PARAMETERS *d3dPresent) { - + if (d3dPresent->Windowed) { printf("Window "); } else { @@ -1652,11 +1842,11 @@ VOID D3dCtx::setWindowMode() SetWindowLong(topHwnd, GWL_STYLE, winStyle); SetWindowPos(topHwnd, HWND_NOTOPMOST, savedTopRect.left, savedTopRect.top, savedTopRect.right - savedTopRect.left, - savedTopRect.bottom - savedTopRect.top, + savedTopRect.bottom - savedTopRect.top, SWP_SHOWWINDOW); } else { SetWindowLong(topHwnd, GWL_STYLE, - WS_POPUP|WS_SYSMENU|WS_VISIBLE); + WS_POPUP|WS_SYSMENU|WS_VISIBLE); } } @@ -1672,7 +1862,7 @@ VOID D3dCtx::setAmbientLightMaterial() pDevice->GetMaterial(&savedMaterial); pDevice->GetLightEnable(0, &savedLightEnable); - CopyColor(ambientMaterial.Ambient, + CopyColor(ambientMaterial.Ambient, currentColor_r, currentColor_g, currentColor_b, @@ -1700,18 +1890,19 @@ VOID D3dCtx::restoreDefaultLightMaterial() pDevice->LightEnable(0, savedLightEnable); } -VOID D3dCtx::freeVBList(D3dVertexBufferVector *v) +VOID D3dCtx::freeVBList(D3dVertexBufferVector *v) { - LPD3DVERTEXBUFFER *p, r; + //LPD3DVERTEXBUFFER *p; + LPD3DVERTEXBUFFER r; lockGeometry(); - for (p = v->begin(); p != v->end(); ++p) { + for (ITER_LPD3DVERTEXBUFFER p = v->begin(); p != v->end(); ++p) { // Remove itself from current ctx vertexBufferTable list r = (*p)->next; if (r != NULL) { r->previous = (*p)->previous; - } + } (*p)->previous->next = r; // Now we can free current VB delete (*p); @@ -1721,9 +1912,9 @@ VOID D3dCtx::freeVBList(D3dVertexBufferVector *v) } -VOID D3dCtx::freeResourceList(LPDIRECT3DRESOURCE8Vector *v) +VOID D3dCtx::freeResourceList(LPDIRECT3DRESOURCE9Vector *v) { - LPDIRECT3DRESOURCE8 *s; + ITER_LPDIRECT3DRESOURCE9 s; lockSurfaceList(); for (s = v->begin(); s != v->end(); ++s) { @@ -1754,7 +1945,7 @@ VOID D3dCtx::freeList() } } -VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb) +VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb) { if (vb != NULL) { lockSurfaceList(); @@ -1768,14 +1959,14 @@ VOID D3dCtx::freeVB(LPD3DVERTEXBUFFER vb) } -VOID D3dCtx::freeResource(LPDIRECT3DRESOURCE8 res) +VOID D3dCtx::freeResource(LPDIRECT3DRESOURCE9 res) { if (res != NULL) { lockSurfaceList(); if (useFreeList0) { freeResourceList0.push_back(res); } else { - freeResourceList1.push_back(res); + freeResourceList1.push_back(res); } unlockSurfaceList(); } @@ -1785,14 +1976,18 @@ BOOL D3dCtx::createFrontBuffer() { HRESULT hr; - hr = pDevice->CreateImageSurface(driverInfo->desktopMode.Width, + /*CreateImageSurface*/ + hr = pDevice->CreateOffscreenPlainSurface( + driverInfo->desktopMode.Width, driverInfo->desktopMode.Height, D3DFMT_A8R8G8B8, - &frontSurface); + D3DPOOL_SCRATCH, + &frontSurface, + NULL); if (FAILED(hr)) { if (debug) { - printf("[Java3D] Fail to CreateImageSurface %s\n", - DXGetErrorString8(hr)); + printf("[Java3D] Fail to CreateOffscreenPlainSurface %s\n", + DXGetErrorString9(hr)); } frontSurface = NULL; return false; @@ -1800,5 +1995,74 @@ BOOL D3dCtx::createFrontBuffer() return true; } +jboolean D3dCtx::getJavaBoolEnv(JNIEnv *env, char* envStr) +{ + jclass systemClass = env->FindClass( "javax/media/j3d/MasterControl" ); + + if ( systemClass != NULL ) + { + jmethodID method = env->GetStaticMethodID( + systemClass, "getProperty", + "(Ljava/lang/String;)Ljava/lang/String;" ); + if ( method != NULL ) + { + jstring name = env->NewStringUTF( envStr ); + jstring property = reinterpret_cast<jstring>( + env->CallStaticObjectMethod( + systemClass, method, name )); + if ( property != NULL ) + { + jboolean isCopy; + const char * chars = env->GetStringUTFChars( + property, &isCopy ); + if ( chars != 0 ) + { + if ( stricmp( chars, "true" ) == 0 ) + { + env->ReleaseStringUTFChars( property, chars ); + return true; + } + else + { + env->ReleaseStringUTFChars( property, chars ); + return false; + } + env->ReleaseStringUTFChars( property, chars ); + } + } + } + } + return false; +} + + + +/** +// this routine is not safe using current D3D routines +VOID D3dCtx::getDXVersion(CHAR* strResult) +{ + HRESULT hr; + // TCHAR strResult[128]; + + DWORD dwDirectXVersion = 0; + TCHAR strDirectXVersion[10]; + + hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 ); + if( SUCCEEDED(hr) ) + { + strcpy( strResult, "DirectX "); + if( dwDirectXVersion > 0 ) + + strcpy( strResult, strDirectXVersion ); + else + strcpy( strResult, "not installed") ); + } + else + { + strcpy( strResult, "Unknown version of DirectX installed"); + } + +} + **/ diff --git a/src/native/d3d/D3dCtx.hpp b/src/native/d3d/D3dCtx.hpp index 230f099..96a111a 100644 --- a/src/native/d3d/D3dCtx.hpp +++ b/src/native/d3d/D3dCtx.hpp @@ -18,7 +18,7 @@ #include "D3dVertexBuffer.hpp" #include "D3dDisplayList.hpp" -#define TEXTURETABLESIZE 8 +#define TEXTURETABLESIZE 8 #define TEXSTAGESUPPORT 8 #define DISPLAYLIST_INITSIZE 8 #define NOCHANGE 0 @@ -26,6 +26,9 @@ #define RECREATEDDRAW 2 #define RECREATEDFAIL -1 +#undef javax_media_j3d_Canvas3D_STENCIL_BUFFER +#define javax_media_j3d_Canvas3D_STENCIL_BUFFER 4096L + // Use in texCoordPosition[] // Must be negative number @@ -47,8 +50,11 @@ typedef struct _D3DTLVERTEX { float tu, tv; } D3DTLVERTEX; -typedef vector<LPDIRECT3DRESOURCE8> LPDIRECT3DRESOURCE8Vector; -typedef vector<LPDIRECT3DVERTEXBUFFER8> LPDIRECT3DVERTEXBUFFER8Vector; +typedef vector<LPDIRECT3DRESOURCE9> LPDIRECT3DRESOURCE9Vector; +typedef vector<LPDIRECT3DVERTEXBUFFER9> LPDIRECT3DVERTEXBUFFER9Vector; +//issue 135 iterator for vectors +typedef vector<LPDIRECT3DRESOURCE9>::iterator ITER_LPDIRECT3DRESOURCE9; +typedef vector<LPDIRECT3DVERTEXBUFFER9>::iterator ITER_LPDIRECT3DVERTEXBUFFER9; class D3dCtx { public: @@ -56,47 +62,54 @@ public: HWND hwnd; // window handle HWND topHwnd; // Top window handle D3dDriverInfo *driverInfo; // Driver use - D3dDeviceInfo *deviceInfo; // Device use - - LPDIRECT3D8 pD3D; // Direct3D interface - LPDIRECT3DDEVICE8 pDevice; // Instance of D3D Device - - LPDIRECT3DSURFACE8 depthStencilSurface; + D3dDeviceInfo *deviceInfo; // Device use + + LPDIRECT3D9 pD3D; // Direct3D interface + LPDIRECT3DDEVICE9 pDevice; // Instance of D3D Device + + LPDIRECT3DSURFACE9 depthStencilSurface; // This is used for readRaster and offscreen rendering // Only allocate the memory area if necessary - LPDIRECT3DSURFACE8 frontSurface; + LPDIRECT3DSURFACE9 frontSurface; - LPDIRECT3DSURFACE8 backSurface; + LPDIRECT3DSURFACE9 backSurface; // Parameters use for CreateDevice() - D3DPRESENT_PARAMETERS d3dPresent; + D3DPRESENT_PARAMETERS d3dPresent; DWORD dwBehavior; - + BOOL bForceHwdVertexProcess; // true if j3d.d3dVertexProcess is hardware + BOOL bForceMixVertexProcess; // true if j3d.d3dVertexProcess is mixed + BOOL bForceSWVertexProcess; // true if j3d.d3dVertexProcess is software + + BOOL bUseNvPerfHUD; // true if j3d.useNvPerfHUD is true + // it also makes bForceHwdVertexProcess true + BOOL offScreen; // true if it is offScreen rendering // in this case only backSurface is used + BOOL bFastDrawQuads; DWORD offScreenWidth; DWORD offScreenHeight; - + BOOL bFullScreen; // true if in full screen mode BOOL bFullScreenRequired; // true if must run in full // screen mode or die - BOOL inToggle; // in toggle fullscreen/window mode + BOOL inToggle; // in toggle fullscreen/window mode RECT screenRect; // coordinate of window relative to // the whole desktop in multiple monitor RECT windowRect; // coordinate of window relative to - // the current monitor desktop only + // the current monitor desktop only INT minZDepth; // min Z depth set in NativeConfigTemplate DEVMODE devmode; // current display mode DWORD antialiasing; // PREFERRED, REQUIRED or UNNECESSARY - + // Store current color as in OGL glColor() float currentColor_r; - float currentColor_g; - float currentColor_b; - float currentColor_a; + float currentColor_g; + float currentColor_b; + float currentColor_a; // Two side light is used. Note that D3D don't support two side // lighting. @@ -113,16 +126,16 @@ public: DWORD zEnable; // Ambient material used when coloring Attributes - D3DMATERIAL8 ambientMaterial; + D3DMATERIAL9 ambientMaterial; // temporary variables for ambient light setting - D3DLIGHT8 savedLight; - D3DMATERIAL8 savedMaterial; + D3DLIGHT9 savedLight; + D3DMATERIAL9 savedMaterial; BOOL savedLightEnable; // temporary variables used for building VertexBuffer LPD3DVERTEXBUFFER pVB; // point to the current VB being update - DWORD texSetUsed; + DWORD texSetUsed; DWORD texStride[TEXSTAGESUPPORT]; // true when in toggle mode @@ -132,25 +145,25 @@ public: INT *bindTextureId; DWORD bindTextureIdLen; - LPDIRECT3DTEXTURE8 *textureTable; + LPDIRECT3DTEXTURE9 *textureTable; DWORD textureTableLen; // Volume Texture related variables // Since 2d & 3d texture ID can't be the same from Java3D. // We don't need bindVolumeId - LPDIRECT3DVOLUMETEXTURE8 *volumeTable; + LPDIRECT3DVOLUMETEXTURE9 *volumeTable; DWORD volumeTableLen; // Texture Cube Mapping related variables - LPDIRECT3DCUBETEXTURE8 *cubeMapTable; + LPDIRECT3DCUBETEXTURE9 *cubeMapTable; DWORD cubeMapTableLen; - + // true if hardware support MultiTexture BOOL multiTextureSupport; // handle to monitor that this ctx belongs to. This is equal to // NULL if this window is a primary display screen or it covers - // more than one screen. + // more than one screen. HMONITOR monitor; // D3D don't have concept of current texture unit stage, @@ -160,7 +173,7 @@ public: // true if linear filtering is to be used BOOL texLinearMode; - + // This is used temporary to store the blend function // when two pass texture is used to simulate BLEND mode @@ -169,10 +182,10 @@ public: DWORD blendEnable; - // This is used for to transform vertex + // This is used for to transform vertex // from world to screen coordinate - LPDIRECT3DVERTEXBUFFER8 srcVertexBuffer; - LPDIRECT3DVERTEXBUFFER8 dstVertexBuffer; + LPDIRECT3DVERTEXBUFFER9 srcVertexBuffer; + LPDIRECT3DVERTEXBUFFER9 dstVertexBuffer; // For Rect of texture map in Raster write D3DTLVERTEX rasterRect[4]; @@ -188,7 +201,7 @@ public: BOOL texTransformSet[TEXSTAGESUPPORT]; // Remember the last Texture Transform pass down, since - // TexCoordGen may destroy it in some mode so we have to + // TexCoordGen may destroy it in some mode so we have to // restore it later manually. D3DXMATRIX texTransform[TEXSTAGESUPPORT]; @@ -215,11 +228,11 @@ public: BOOL resetColorTarget; // Use for QuadArray - LPDIRECT3DINDEXBUFFER8 quadIndexBuffer; + LPDIRECT3DINDEXBUFFER9 quadIndexBuffer; DWORD quadIndexBufferSize; // Use for Quad Polygon Line mode - LPDIRECT3DINDEXBUFFER8 lineModeIndexBuffer; + LPDIRECT3DINDEXBUFFER9 lineModeIndexBuffer; // Use temporary for reindexing DWORD *reIndexifyTable; @@ -237,8 +250,8 @@ public: // Use to free resource surface in swap() BOOL useFreeList0; - LPDIRECT3DRESOURCE8Vector freeResourceList0; - LPDIRECT3DRESOURCE8Vector freeResourceList1; + LPDIRECT3DRESOURCE9Vector freeResourceList0; + LPDIRECT3DRESOURCE9Vector freeResourceList1; D3dVertexBufferVector freeVBList0; D3dVertexBufferVector freeVBList1; @@ -280,14 +293,14 @@ public: VOID setPresentParams(JNIEnv *env, jobject obj); VOID setAmbientLightMaterial(); VOID restoreDefaultLightMaterial(); - VOID freeResource(LPDIRECT3DRESOURCE8 surf); + VOID freeResource(LPDIRECT3DRESOURCE9 surf); VOID freeVB(LPD3DVERTEXBUFFER vb); - + VOID freeList(); - VOID freeResourceList(LPDIRECT3DRESOURCE8Vector *v); - VOID freeVBList(D3dVertexBufferVector *v); + VOID freeResourceList(LPDIRECT3DRESOURCE9Vector *v); + VOID freeVBList(D3dVertexBufferVector *v); BOOL createFrontBuffer(); - + static D3dDeviceInfo* selectDevice(int deviceID, D3dDriverInfo *driverInfo, BOOL *bFullScreen, @@ -296,15 +309,20 @@ public: BOOL *bFullScreen, int minZDepth); static VOID setDeviceFromProperty(JNIEnv *env); + static BOOL getSystemProperty(JNIEnv *env, char *strName, char *strValue); static VOID setDebugProperty(JNIEnv *env); static VOID setVBLimitProperty(JNIEnv *env); - static VOID setImplicitMultisamplingProperty(JNIEnv *env); + static VOID setImplicitMultisamplingProperty(JNIEnv *env); + + private: RECT savedTopRect; // for toggle between fullscreen mode - RECT savedClientRect; + RECT savedClientRect; DWORD winStyle; + // a private reference for JNIEnv + JNIEnv* jniEnv; VOID createVertexBuffer(); @@ -315,11 +333,14 @@ private: static VOID printWarningMessage(D3dDeviceInfo *deviceInfo); static VOID showError(HWND hwnd, char *s, BOOL bFullScreen); VOID setDefaultAttributes(); - VOID printInfo(D3DPRESENT_PARAMETERS *d3dPresent); + VOID printInfo(D3DPRESENT_PARAMETERS *d3dPresent); VOID setWindowMode(); + jboolean getJavaBoolEnv(JNIEnv *env, char* envStr); }; typedef vector<D3dCtx *> D3dCtxVector; +//issue 135 added iterator for D3dCtxVector +typedef vector<D3dCtx *>::iterator ITER_D3dCtxVector; extern D3dCtxVector d3dCtxList; const extern D3DXMATRIX identityMatrix; #endif diff --git a/src/native/d3d/D3dDeviceInfo.cpp b/src/native/d3d/D3dDeviceInfo.cpp index 5628273..7fffdf5 100644 --- a/src/native/d3d/D3dDeviceInfo.cpp +++ b/src/native/d3d/D3dDeviceInfo.cpp @@ -22,63 +22,95 @@ D3dDeviceInfo::~D3dDeviceInfo() { } -VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) { - - if (deviceType == D3DDEVTYPE_HAL) { - isHardware = true; - isHardwareTnL = (d3dCaps->DevCaps & - D3DDEVCAPS_HWTRANSFORMANDLIGHT); - } else { - isHardware = false; - isHardwareTnL = false; +VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) +{ + if (deviceType == D3DDEVTYPE_HAL ) + { + isHardware = true; + isHardwareTnL = (d3dCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT); + } + else // D3DDEVTYPE_REF + { + isHardware = false; + isHardwareTnL = false; } + + // check if it supports at least vertex shader 1.1 + if(d3dCaps->VertexShaderVersion < D3DVS_VERSION(1,1)) + { + supportShaders11 = false; + } + else + { + supportShaders11 = true; + } + DWORD vsVersion = d3dCaps->VertexShaderVersion; + if (debug) + { + char* dt; + if (isHardware) + dt = "HAL"; + else + dt ="REL"; + + printf("Java3D: Supported Shaders = %d.%d in mode %s ", + HIBYTE(LOWORD(vsVersion)), + LOBYTE(LOWORD(vsVersion)), + dt); + + } + + //supportStreamOffset = + + supportDepthBias = (d3dCaps->RasterCaps & D3DPRASTERCAPS_DEPTHBIAS) != 0; + maxTextureBlendStages = d3dCaps->MaxTextureBlendStages; maxSimultaneousTextures = d3dCaps->MaxSimultaneousTextures; - maxTextureUnitStageSupport = min(maxTextureBlendStages, - maxSimultaneousTextures); - supportMipmap = ((d3dCaps->TextureCaps & - D3DPTEXTURECAPS_MIPMAP) != 0); - texturePow2Only = ((d3dCaps->TextureCaps & - D3DPTEXTURECAPS_POW2) != 0); - textureSquareOnly = ((d3dCaps->TextureCaps & - D3DPTEXTURECAPS_SQUAREONLY) != 0); - linePatternSupport = ((d3dCaps->PrimitiveMiscCaps & - D3DPMISCCAPS_LINEPATTERNREP) != 0); - texBorderModeSupport = ((d3dCaps->TextureAddressCaps & - D3DPTADDRESSCAPS_BORDER) != 0); - texLerpSupport = ((d3dCaps->TextureOpCaps & - D3DTEXOPCAPS_LERP) != 0); - canRenderWindowed = ((d3dCaps->Caps2 & - D3DCAPS2_CANRENDERWINDOWED) != 0); + + maxTextureUnitStageSupport = min(maxTextureBlendStages, maxSimultaneousTextures); + + supportMipmap = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0); + + texturePow2Only = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_POW2) != 0); + + textureSquareOnly = ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) != 0); + + linePatternSupport = false; //((d3dCaps->PrimitiveMiscCaps & D3DPMISCCAPS_LINEPATTERNREP) != 0); + + texBorderModeSupport = ((d3dCaps->TextureAddressCaps & D3DPTADDRESSCAPS_BORDER) != 0); + + texLerpSupport = ((d3dCaps->TextureOpCaps & D3DTEXOPCAPS_LERP) != 0); + + canRenderWindowed = true;//((d3dCaps->Caps2 & D3DCAPS2_CANRENDERWINDOWED) != 0); + maxPrimitiveCount = d3dCaps->MaxPrimitiveCount; - maxVertexIndex = min(vertexBufferMaxVertexLimit, - d3dCaps->MaxVertexIndex); + maxVertexIndex = min(vertexBufferMaxVertexLimit, d3dCaps->MaxVertexIndex); + maxTextureHeight = d3dCaps->MaxTextureHeight; maxTextureWidth = d3dCaps->MaxTextureWidth; maxTextureDepth = d3dCaps->MaxVolumeExtent; maxActiveLights = d3dCaps->MaxActiveLights; - maxPointSize = d3dCaps->MaxPointSize; + maxPointSize = DWORD(d3dCaps->MaxPointSize); maxAnisotropy = d3dCaps->MaxAnisotropy; - maxVertexCount[GEO_TYPE_QUAD_SET] = min(vertexBufferMaxVertexLimit, + maxVertexCount[GEO_TYPE_QUAD_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount << 1); // Since index is used, we need to make sure than index range // is also support. - maxVertexCount[GEO_TYPE_QUAD_SET] = min(maxVertexCount[GEO_TYPE_QUAD_SET], - maxVertexIndex); - - maxVertexCount[GEO_TYPE_TRI_SET] = min(vertexBufferMaxVertexLimit, - maxPrimitiveCount*3); - maxVertexCount[GEO_TYPE_POINT_SET] = min(vertexBufferMaxVertexLimit, - maxPrimitiveCount); - maxVertexCount[GEO_TYPE_LINE_SET] = min(vertexBufferMaxVertexLimit, - maxPrimitiveCount << 1); - maxVertexCount[GEO_TYPE_TRI_STRIP_SET] = min(vertexBufferMaxVertexLimit, - maxPrimitiveCount + 2); - maxVertexCount[GEO_TYPE_TRI_FAN_SET] = min(vertexBufferMaxVertexLimit, - maxPrimitiveCount + 2); + maxVertexCount[GEO_TYPE_QUAD_SET] = min(maxVertexCount[GEO_TYPE_QUAD_SET], maxVertexIndex); + + maxVertexCount[GEO_TYPE_TRI_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount*3); + + maxVertexCount[GEO_TYPE_POINT_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount); + + maxVertexCount[GEO_TYPE_LINE_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount << 1); + + maxVertexCount[GEO_TYPE_TRI_STRIP_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount + 2); + + maxVertexCount[GEO_TYPE_TRI_FAN_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount + 2); + maxVertexCount[GEO_TYPE_LINE_STRIP_SET] = min(vertexBufferMaxVertexLimit, maxPrimitiveCount +1); maxVertexCount[GEO_TYPE_INDEXED_QUAD_SET] = maxVertexCount[GEO_TYPE_QUAD_SET]; @@ -89,38 +121,57 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) { maxVertexCount[GEO_TYPE_INDEXED_TRI_FAN_SET] = maxVertexCount[GEO_TYPE_TRI_FAN_SET]; maxVertexCount[GEO_TYPE_INDEXED_LINE_STRIP_SET] = maxVertexCount[GEO_TYPE_LINE_STRIP_SET]; + if ( (d3dCaps->PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) != 0) + supportRasterPresImmediate = true; + else + supportRasterPresImmediate = false; if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) && - ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0)) { + ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0)) + { // use pixel w-fog fogMode = D3DRS_FOGTABLEMODE; rangeFogEnable = false; - } else if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) && - ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0)) { - // use vertex range based fog - fogMode = D3DRS_FOGVERTEXMODE; - rangeFogEnable = true; - } else if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) { - // use pixel z-fog - fogMode = D3DRS_FOGTABLEMODE; - rangeFogEnable = false; - } else if (D3DPRASTERCAPS_FOGVERTEX) { - // use vertex z-fog - fogMode = D3DRS_FOGVERTEXMODE; - rangeFogEnable = false; - } else { - if (debug) { - printf("[Java 3D] Fog not support in this device !\n"); - } + } + else + if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) && + ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0)) + + { + // use vertex range based fog + fogMode = D3DRS_FOGVERTEXMODE; + rangeFogEnable = true; + } + else + if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) + { + // use pixel z-fog + fogMode = D3DRS_FOGTABLEMODE; + rangeFogEnable = false; + } + else + if (D3DPRASTERCAPS_FOGVERTEX) + { + // use vertex z-fog + fogMode = D3DRS_FOGVERTEXMODE; + rangeFogEnable = false; + } + else + { + if (debug) + { + printf("[Java 3D] Fog not support in this device !\n"); + } } texMask = 0; if ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) && - (maxTextureDepth > 0)) { + (maxTextureDepth > 0)) + { texMask |= javax_media_j3d_Canvas3D_TEXTURE_3D; - } + } if (d3dCaps->TextureCaps & D3DPTEXTURECAPS_CUBEMAP) { texMask |= javax_media_j3d_Canvas3D_TEXTURE_CUBE_MAP; @@ -137,17 +188,17 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS8 *d3dCaps) { if (d3dCaps->TextureOpCaps & D3DTEXOPCAPS_SUBTRACT) { texMask |= javax_media_j3d_Canvas3D_TEXTURE_COMBINE_SUBTRACT; } - + if (d3dCaps->TextureOpCaps & D3DTEXOPCAPS_LERP) { texMask |= (javax_media_j3d_Canvas3D_TEXTURE_LERP| javax_media_j3d_Canvas3D_TEXTURE_COMBINE); - } else if (d3dCaps->TextureOpCaps & + } else if (d3dCaps->TextureOpCaps & (D3DTEXOPCAPS_DOTPRODUCT3|D3DTEXOPCAPS_SUBTRACT| D3DTEXOPCAPS_MODULATE|D3DTEXOPCAPS_ADD| D3DTEXOPCAPS_ADDSIGNED)) { texMask |= javax_media_j3d_Canvas3D_TEXTURE_COMBINE; } - + if (maxAnisotropy > 1) { texMask |= javax_media_j3d_Canvas3D_TEXTURE_ANISOTROPIC_FILTER; @@ -164,7 +215,7 @@ void D3dDeviceInfo::findDepthStencilFormat(int minZDepth) depthStencilFormat = D3DFMT_UNKNOWN; for (int i=0; i < D3DDEPTHFORMATSIZE; i++) { if (depthFormatSupport[i]) { - // prefer one with stencil buffer, follow by D3DFMT_D16_LOCKABLE, + // prefer one with stencil buffer, follow by D3DFMT_D16_LOCKABLE, if (d3dDepthTable[i] >= minZDepth) { depthStencilFormat = (D3DFORMAT) d3dDepthFormat[i]; break; diff --git a/src/native/d3d/D3dDeviceInfo.hpp b/src/native/d3d/D3dDeviceInfo.hpp index 4008011..ffb4587 100644 --- a/src/native/d3d/D3dDeviceInfo.hpp +++ b/src/native/d3d/D3dDeviceInfo.hpp @@ -24,12 +24,16 @@ public: // Hardware Rasterizer // Transform & Light Hardware Rasterizer // Reference Rasterizer - char deviceName[40]; // One of above name - D3DDEVTYPE deviceType; // D3DDEVTYPE_HAL or D3DDEVTYPE_REF + char deviceName[40]; // One of above name + D3DDEVTYPE deviceType; // D3DDEVTYPE_HAL or D3DDEVTYPE_REF BOOL desktopCompatible; // Can render in desktop mode BOOL fullscreenCompatible; // Can render in fullscreen mode // using current desktop mode setting - + //issue 135 - adding device info + char* deviceVendor; + char* deviceRenderer; + char* deviceVersion; + // each bitmask correspond to the support of // D3DMULTISAMPLE_i_SAMPLES type, i = 2...16 DWORD multiSampleSupport; @@ -43,11 +47,14 @@ public: // max z buffer depth support UINT maxZBufferDepthSize; - // Max vetex count support for each primitive + // Max vertex count support for each primitive DWORD maxVertexCount[GEO_TYPE_INDEXED_LINE_STRIP_SET+1]; + BOOL supportShaders11; BOOL isHardware; BOOL isHardwareTnL; + BOOL supportDepthBias; + BOOL supportRasterPresImmediate; BOOL canRenderWindowed; BOOL supportMipmap; BOOL texturePow2Only; @@ -66,19 +73,23 @@ public: DWORD maxActiveLights; DWORD maxPointSize; DWORD rangeFogEnable; - D3DRENDERSTATETYPE fogMode; + D3DRENDERSTATETYPE fogMode; int texMask; int maxAnisotropy; + BOOL supportStreamOffset; + D3dDeviceInfo(); ~D3dDeviceInfo(); // set capabilities of this device - VOID setCaps(D3DCAPS8 *d3dCaps); + VOID setCaps(D3DCAPS9 *d3dCaps); BOOL supportAntialiasing(); D3DMULTISAMPLE_TYPE getBestMultiSampleType(); int getTextureFeaturesMask(); void findDepthStencilFormat(int minZDepth); + + }; #endif diff --git a/src/native/d3d/D3dDisplayList.cpp b/src/native/d3d/D3dDisplayList.cpp index 73c0fd2..48eaf34 100644 --- a/src/native/d3d/D3dDisplayList.cpp +++ b/src/native/d3d/D3dDisplayList.cpp @@ -19,7 +19,7 @@ D3dDisplayList::D3dDisplayList() D3dDisplayList::~D3dDisplayList() { - for (D3dVertexBuffer **p = vBufferVec.begin(); + for (ITER_LPD3DVERTEXBUFFER p = vBufferVec.begin(); p != vBufferVec.end(); p++) { SafeDelete(*p); } @@ -28,7 +28,7 @@ D3dDisplayList::~D3dDisplayList() VOID D3dDisplayList::render(D3dCtx *d3dCtx) { - for (D3dVertexBuffer **p = vBufferVec.begin(); + for (ITER_LPD3DVERTEXBUFFER p = vBufferVec.begin(); p != vBufferVec.end(); p++) { (*p)->render(d3dCtx); } @@ -49,17 +49,17 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx) { D3dVertexBufferVector vCloneBufferVec; - D3dVertexBuffer **r = vBufferVec.begin(); - - for (; r != vBufferVec.end(); r++) { + D3dVertexBuffer **r = &(*vBufferVec.begin()); + + for (; r != &(*vBufferVec.end()); r++) { vCloneBufferVec.push_back(*r); } vBufferVec.erase(vBufferVec.begin(), vBufferVec.end()); - D3dVertexBuffer **vbegin = vCloneBufferVec.begin(); - D3dVertexBuffer **vend = vCloneBufferVec.end(); + D3dVertexBuffer **vbegin = &(*vCloneBufferVec.begin()); + D3dVertexBuffer **vend = &(*vCloneBufferVec.end()); D3dVertexBuffer **q = vbegin; D3dVertexBuffer **p; int primitiveType, vcounts, climit; @@ -92,7 +92,7 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx) ((*p)->isIndexPrimitive == isIndexPrimitive) && (isQuad(*p) == quadFlag) && ((*p)->isPointFlagUsed == isPointFlagUsed) && - // This means Mutliple VBs already use + // This means Mutliple VBs already use ((*p)->totalVertexCount == (*p)->vcount)) { vcounts += (*p)->totalVertexCount; if ((*p)->indexBuffer != NULL) { @@ -106,7 +106,7 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx) } else { break; } - } + } if (merge) { mergedVB = createMergedVB(d3dCtx, q, p, vcounts, indexCounts); @@ -119,8 +119,8 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx) for (r = q; r != p; r++) { vBufferVec.push_back(*r); } - } - } else { + } + } else { vBufferVec.push_back(*q); } q = p; @@ -131,13 +131,14 @@ VOID D3dDisplayList::optimize(D3dCtx *d3dCtx) + LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, D3dVertexBuffer **vstart, D3dVertexBuffer **vend, DWORD vcount, DWORD indexCount) { - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; D3dVertexBuffer **r; UINT i; HRESULT hr; @@ -158,43 +159,46 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, D3DUSAGE_WRITEONLY, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } else { hr = device->CreateVertexBuffer(vb->stride*vcount, D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } if (FAILED(hr)) { return NULL; } + BYTE *bdst = NULL; + WORD *wdst = NULL; + UINT *idst = NULL; - BYTE *bdst = NULL; - WORD *wdst = NULL; - UINT *idst = NULL; - - hr = vb->buffer->Lock(0, 0, (BYTE**) &bdst, 0); + hr = vb->buffer->Lock(0, 0,(VOID**) &bdst , 0); if (FAILED(hr)) { SafeRelease(vb->buffer); return NULL; } if (indexCount > 0) { - if (indexCount <= 0xffff) { + if (indexCount < 0xffff) { hr = device->CreateIndexBuffer(indexCount*sizeof(WORD), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, - &vb->indexBuffer); - + &vb->indexBuffer, + NULL); + } else { hr = device->CreateIndexBuffer(indexCount*sizeof(UINT), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, - &vb->indexBuffer); + &vb->indexBuffer, + NULL); } if (FAILED(hr)) { vb->buffer->Unlock(); @@ -202,9 +206,9 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, return NULL; } if (indexCount <= 0xffff) { - hr = vb->indexBuffer->Lock(0, 0, (BYTE**) &wdst, 0); + hr = vb->indexBuffer->Lock(0, 0,(VOID**) &wdst, 0); } else { - hr = vb->indexBuffer->Lock(0, 0, (BYTE**) &idst, 0); + hr = vb->indexBuffer->Lock(0, 0,(VOID**) &idst, 0); } if (FAILED(hr)) { vb->buffer->Unlock(); @@ -214,10 +218,10 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, } } - BYTE *bsrc = NULL; - WORD *wsrc = NULL; - UINT *isrc = NULL; - UINT offset = 0; + BYTE *bsrc = NULL; + WORD *wsrc = NULL; + UINT *isrc = NULL; + UINT offset = 0; DWORD len; BOOL stripType = true; @@ -233,16 +237,16 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, vb->numVerticesLen = 1; vb->stripLen = 1; stripType = false; - } + } for (r = vstart; r != vend; r++) { - hr = (*r)->buffer->Lock(0, 0, (BYTE **) &bsrc, 0); + hr = (*r)->buffer->Lock(0, 0,(VOID**) &bsrc, 0); if (FAILED(hr)) { vb->buffer->Unlock(); if (indexCount > 0) { vb->indexBuffer->Unlock(); - } + } SafeRelease(vb->buffer); SafeRelease(vb->indexBuffer); return NULL; @@ -250,9 +254,9 @@ LPD3DVERTEXBUFFER D3dDisplayList::createMergedVB(D3dCtx *d3dCtx, if (indexCount > 0) { if (indexCount <= 0xffff) { - hr = (*r)->indexBuffer->Lock(0, 0, (BYTE**) &wsrc, 0); + hr = (*r)->indexBuffer->Lock(0, 0, (VOID**)&wsrc, 0); } else { - hr = (*r)->indexBuffer->Lock(0, 0, (BYTE**) &isrc, 0); + hr = (*r)->indexBuffer->Lock(0, 0,(VOID**) &isrc, 0); } if (FAILED(hr)) { (*r)->buffer->Unlock(); diff --git a/src/native/d3d/D3dDriverInfo.cpp b/src/native/d3d/D3dDriverInfo.cpp index 01a3694..a2d848f 100644 --- a/src/native/d3d/D3dDriverInfo.cpp +++ b/src/native/d3d/D3dDriverInfo.cpp @@ -47,7 +47,7 @@ D3DFORMAT d3dDepthFormat[D3DDEPTHFORMATSIZE] = {D3DFMT_D15S1, // This should match the depth bit in the above array int d3dDepthTable[D3DDEPTHFORMATSIZE] = {15, 24, 24, 16, 16, 32}; -D3DLIGHT8 ambientLight; +D3DLIGHT9 ambientLight; D3dDriverInfo::D3dDriverInfo() { @@ -97,7 +97,41 @@ VOID computeRGBDepth(D3dDriverInfo *pDriver) } -VOID buildDriverList(LPDIRECT3D8 pD3D) + +VOID setInfo(D3dDeviceInfo* pDevice,D3DADAPTER_IDENTIFIER9 *identifier) +{ + char* str = (char *)"UNKNOW Vendor "; + + switch( identifier->VendorId ) + { + // A more complete list can be found from http://www.pcidatabase.com/vendors.php?sort=id + case 0x1002: str = (char *) "ATI Technologies Inc."; break; + case 0x1013: str = (char *) "Cirrus Logic."; break; + case 0x1023: str = (char *) "Trident Microsistems."; break; + case 0x102B: str = (char *) "Matrox Electronic Systems Ltd."; break; + case 0x108E: str = (char *) "Sun Microsystems."; break; + case 0x10DE: str = (char *) "NVIDIA Corporation"; break; + case 0x121A: str = (char *) "3dfx Interactive Inc"; break; + case 0x3D3D: str = (char *) "3Dlabs Inc, Ltd."; break; + case 0x5333: str = (char *) "S3 Graphics Co., Ltd."; break; + case 0x8086: str = (char *) "Intel Corporation"; break; + default: sprintf( str, "vendor ID %x.",identifier->VendorId); + break; + } + pDevice->deviceVendor = str; + + pDevice->deviceRenderer = identifier->Description; + + char version[ 128 ]; + sprintf( version, "%d.%d.%d.%d", HIWORD( identifier->DriverVersion.HighPart ), + LOWORD( identifier->DriverVersion.HighPart ), + HIWORD( identifier->DriverVersion.LowPart ), + LOWORD( identifier->DriverVersion.LowPart ) ); + pDevice->deviceVersion = (char *)version; +} + + +VOID buildDriverList(LPDIRECT3D9 pD3D) { numDriver = pD3D->GetAdapterCount(); @@ -120,16 +154,17 @@ VOID buildDriverList(LPDIRECT3D8 pD3D) { pDriver = new D3dDriverInfo(); d3dDriverList[i] = pDriver; - pD3D->GetAdapterIdentifier(i, D3DENUM_NO_WHQL_LEVEL, + pD3D->GetAdapterIdentifier(i, 0, &pDriver->adapterIdentifier); pD3D->GetAdapterDisplayMode(i, &pDriver->desktopMode); computeRGBDepth(pDriver); pDriver->hMonitor = pD3D->GetAdapterMonitor(i); pDriver->iAdapter = i; + for (int j = 0; j < numDeviceTypes; j++ ) { - D3DCAPS8 d3dCaps; + D3DCAPS9 d3dCaps; D3dDeviceInfo* pDevice = pDriver->d3dDeviceList[j]; pDevice->deviceType = deviceTypes[j]; pD3D->GetDeviceCaps(i, deviceTypes[j], &d3dCaps); @@ -152,7 +187,9 @@ VOID buildDriverList(LPDIRECT3D8 pD3D) strcpy(pDevice->deviceName, "Hardware Rasterizer"); } else { strcpy(pDevice->deviceName, "Reference Rasterizer"); - } + } + //issue 135 put here info about vendor and device model + setInfo(pDevice, &pDriver->adapterIdentifier); for (int k=0; k < D3DDEPTHFORMATSIZE; k++) { pDevice->depthFormatSupport[k] = @@ -176,12 +213,13 @@ VOID buildDriverList(LPDIRECT3D8 pD3D) DWORD bitmask = 1 << 2; pDevice->multiSampleSupport = 0; for (int mtype = D3DMULTISAMPLE_2_SAMPLES; - mtype <= D3DMULTISAMPLE_16_SAMPLES; mtype++) { + mtype <= D3DMULTISAMPLE_16_SAMPLES; mtype++) { // consider desktop mode only for multisampling if (SUCCEEDED(pD3D->CheckDeviceMultiSampleType(i, deviceTypes[j], pDriver->desktopMode.Format, TRUE, - (D3DMULTISAMPLE_TYPE) mtype))) { + (D3DMULTISAMPLE_TYPE) mtype,NULL) + )) { pDevice->multiSampleSupport |= bitmask; } bitmask <<= 1; @@ -204,7 +242,7 @@ VOID D3dDriverInfo::release() VOID printInfo() { - printf("Java 3D 1.3.3, Windows version is %d.%d ", + printf("Java 3D 1.4, Windows version is %d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion); printf("Build: %d, ", LOWORD(osvi.dwBuildNumber)); @@ -217,7 +255,7 @@ VOID printInfo() printf("Windows 95/98"); break; case VER_PLATFORM_WIN32_NT: - printf("Windows NT"); + printf("Windows NT/2000/XP"); break; } @@ -226,7 +264,7 @@ VOID printInfo() D3dDriverInfo *pDriver; for (int i=0; i < numDriver; i++) { pDriver = d3dDriverList[i]; - D3DADAPTER_IDENTIFIER8 *id = &pDriver->adapterIdentifier; + D3DADAPTER_IDENTIFIER9 *id = &pDriver->adapterIdentifier; D3DDISPLAYMODE *dm = &pDriver->desktopMode; printf("\n[Display Driver] %s, %s, Product %d\n", id->Driver, id->Description, @@ -234,8 +272,9 @@ VOID printInfo() printf(" Version %d.%d, Build %d, VendorId %d\n", LOWORD(id->DriverVersion.HighPart), HIWORD(id->DriverVersion.LowPart), - LOWORD(id->DriverVersion.LowPart)); - printf(" DeviceId 0x%x, SubSysId 0x%x, Revision 0x%d\n", + LOWORD(id->DriverVersion.LowPart), + id->VendorId); + printf(" DeviceId %d, SubSysId %d, Revision %d\n", id->VendorId, id->DeviceId, id->SubSysId, id->Revision); printf(" [Desktop Mode] %dx%d ", @@ -262,19 +301,22 @@ VOID printInfo() // Construct the D3dDriverList by enumerate all the drivers VOID D3dDriverInfo::initialize(JNIEnv *env) { - HINSTANCE hD3D8DLL = LoadLibrary( "D3D8.DLL" ); + HINSTANCE hD3D9DLL = LoadLibrary( "D3D9.DLL" ); - // Simply see if D3D8.dll exists. - if ( hD3D8DLL == NULL ) + // Simply see if D3D9.dll exists. + if ( hD3D9DLL == NULL ) { D3dCtx::d3dError(D3DNOTFOUND); return; } - FreeLibrary(hD3D8DLL); - + FreeLibrary(hD3D9DLL); - LPDIRECT3D8 pD3D = Direct3DCreate8( D3D_SDK_VERSION ); + LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION ); + printf("[Java3D] Using DirectX D3D 9.0 or higher.\n"); + if (debug){ + printf("[Java3D] DirectX D3D renderer build 1.4.2005.10.10\n"); + } if (pD3D == NULL) { D3dCtx::d3dError(D3DNOTFOUND); return; @@ -317,4 +359,3 @@ VOID D3dDriverInfo::initialize(JNIEnv *env) - diff --git a/src/native/d3d/D3dDriverInfo.hpp b/src/native/d3d/D3dDriverInfo.hpp index e164fe8..5c5f0ca 100644 --- a/src/native/d3d/D3dDriverInfo.hpp +++ b/src/native/d3d/D3dDriverInfo.hpp @@ -26,7 +26,7 @@ extern int d3dDepthTable[D3DDEPTHFORMATSIZE]; class D3dDriverInfo { public: // DDraw Driver info - D3DADAPTER_IDENTIFIER8 adapterIdentifier; + D3DADAPTER_IDENTIFIER9 adapterIdentifier; // Desktop display mode for this adapter D3DDISPLAYMODE desktopMode; // monitor handle for this adapter @@ -56,6 +56,6 @@ extern const DWORD numDeviceTypes; extern const D3DDEVTYPE deviceTypes[2]; extern int requiredDeviceID; // force to use HAL/REF or exit extern int requiredDriverID; // force to use specific adapte -extern D3DLIGHT8 ambientLight; // constant ambient light +extern D3DLIGHT9 ambientLight; // constant ambient light extern BOOL implicitMultisample; #endif diff --git a/src/native/d3d/D3dImageComponent.cpp b/src/native/d3d/D3dImageComponent.cpp index 0b15c16..64031bb 100644 --- a/src/native/d3d/D3dImageComponent.cpp +++ b/src/native/d3d/D3dImageComponent.cpp @@ -20,7 +20,7 @@ D3dImageComponent::D3dImageComponent() D3dImageComponent::D3dImageComponent(D3dCtx *_ctx, int _hashCode, - LPDIRECT3DTEXTURE8 _surf) + LPDIRECT3DTEXTURE9 _surf) { ctx = _ctx; hashCode = _hashCode; @@ -46,7 +46,7 @@ VOID D3dImageComponent::init() D3dImageComponent* D3dImageComponent::add(D3dImageComponent *list, D3dCtx *ctx, int hashCode, - LPDIRECT3DTEXTURE8 surf) + LPDIRECT3DTEXTURE9 surf) { D3dImageComponent *p = list->next; diff --git a/src/native/d3d/D3dImageComponent.hpp b/src/native/d3d/D3dImageComponent.hpp index 0fb9743..4abedd3 100644 --- a/src/native/d3d/D3dImageComponent.hpp +++ b/src/native/d3d/D3dImageComponent.hpp @@ -18,7 +18,7 @@ class D3dImageComponent { public: - LPDIRECT3DTEXTURE8 surf; + LPDIRECT3DTEXTURE9 surf; D3dCtx *ctx; int hashCode; D3dImageComponent *next; @@ -26,7 +26,7 @@ public: D3dImageComponent(); D3dImageComponent(D3dCtx *ctx, int hashCode, - LPDIRECT3DTEXTURE8 surf); + LPDIRECT3DTEXTURE9 surf); ~D3dImageComponent(); @@ -37,7 +37,7 @@ public: static D3dImageComponent* add(D3dImageComponent *list, D3dCtx *ctx, int hashCode, - LPDIRECT3DTEXTURE8 surf); + LPDIRECT3DTEXTURE9 surf); static VOID remove(D3dImageComponent *list, D3dCtx *ctx, int hashCode); static VOID remove(D3dImageComponent *list, D3dCtx *ctx); diff --git a/src/native/d3d/D3dUtil.cpp b/src/native/d3d/D3dUtil.cpp index 117c623..81d2182 100644 --- a/src/native/d3d/D3dUtil.cpp +++ b/src/native/d3d/D3dUtil.cpp @@ -20,7 +20,7 @@ HANDLE backgroundSema = CreateSemaphore(NULL, 1, 1, HANDLE geometrySema = CreateSemaphore(NULL, 1, 1, "Java3d_GeometryArrayLock"); HANDLE surfaceListSema = CreateSemaphore(NULL, 1, 1, "Java3d_SurfaceListLock"); - + BOOL firstError = true; BOOL firstWarning = true; BOOL debug; @@ -33,7 +33,7 @@ BOOL useFreePointerList0 = true; char *D3dErrorMessage[] = { "Can't found 3D Driver !", "Current display driver did not support renderer inside window. Now switch to full screen mode...", - "DirectX 8.0 or above is required for this version of Java3D.", + "DirectX 9.0 or above is required for this version of Java3D.", "Your graphics card did not support >= 16 bit color mode which Java 3D required.", "Please switch your display mode to at least 16 bit color depth.", "No compatible device found, please switch to other display mode and try again !", @@ -47,7 +47,7 @@ char *D3dErrorMessage[] = { "Graphics card did not support Hardware acceleration", "Graphics card did not support Transform and light hardware acceleration", "No Stencil buffer found in current display mode. DecalGroup may not work correctly.", - "Can't found a valid texture format, please try to use reference mode", + "Can't found a valid texture format, please try to use reference mode. DirectX SDK must be installed to use reference mode", "Fail to create offscreen image for background", "Fail to create Vertex Buffer", "Fail to Reset() D3D device, try Recreate device again.", @@ -94,7 +94,7 @@ D3DFORMAT d3dFormatTable[] = { D3DFMT_X8L8V8U8, D3DFMT_Q8W8V8U8, D3DFMT_V16U16, - D3DFMT_W11V11U10, +// D3DFMT_W11V11U10, D3DFMT_UYVY, D3DFMT_YUY2, D3DFMT_DXT1, @@ -116,7 +116,7 @@ D3DFORMAT d3dFormatTable[] = { char *d3dFormatTableChar[] = { "D3DFMT_UNKNOWN", - "D3DFMT_R8G8B8", + "D3DFMT_R8G8B8", "D3DFMT_A8R8G8B8", "D3DFMT_X8R8G8B8", "D3DFMT_R5G6B5", @@ -137,7 +137,7 @@ char *d3dFormatTableChar[] = { "D3DFMT_X8L8V8U8", "D3DFMT_Q8W8V8U8", "D3DFMT_V16U16", - "D3DFMT_W11V11U10", + // "D3DFMT_W11V11U10", "D3DFMT_UYVY", "D3DFMT_YUY2", "D3DFMT_DXT1", @@ -200,9 +200,9 @@ D3DCUBEMAP_FACES textureCubeMapFace[] = { typedef struct _PIXELFORMAT { DWORD dwRGBBitCount; DWORD dwRBitMask; - DWORD dwGBitMask; - DWORD dwBBitMask; - DWORD dwRGBAlphaBitMask; + DWORD dwGBitMask; + DWORD dwBBitMask; + DWORD dwRGBAlphaBitMask; BOOL noAlpha; } PIXELFORMAT; @@ -213,7 +213,7 @@ typedef struct _DEPTHPIXELFORMAT { } DEPTHPIXELFORMAT; -char *getSwapEffectName(D3DSWAPEFFECT swapEffect) +char *getSwapEffectName(D3DSWAPEFFECT swapEffect) { int t = (int) swapEffect; if ((t < 0) || (t > 4)) { @@ -222,7 +222,7 @@ char *getSwapEffectName(D3DSWAPEFFECT swapEffect) return swapEffectTable[t]; } -char *getMultiSampleName(D3DMULTISAMPLE_TYPE mtype) +char *getMultiSampleName(D3DMULTISAMPLE_TYPE mtype) { int t = (int) mtype; if ((t < 0) || (t > 16)) { @@ -238,7 +238,7 @@ char* getPixelFormatName(D3DFORMAT f) if (f == d3dFormatTable[i]) { return d3dFormatTableChar[i]; } - } + } // should not happen return d3dFormatTableChar[0]; } @@ -246,7 +246,7 @@ char* getPixelFormatName(D3DFORMAT f) // If there is a new D3DFORMAT, just add it here and // our copy procedures can handle any format specific // as bit mask. -VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) +VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) { switch (format) { case D3DFMT_R8G8B8: @@ -257,7 +257,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) ddpf->dwBBitMask = 0x000000ff; ddpf->noAlpha = true; break; - case D3DFMT_A8R8G8B8: + case D3DFMT_A8R8G8B8: ddpf->dwRGBBitCount = 32; ddpf->dwRGBAlphaBitMask = 0xff000000; ddpf->dwRBitMask = 0x00ff0000; @@ -289,7 +289,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) ddpf->dwBBitMask = 0x001f; ddpf->noAlpha = true; break; - case D3DFMT_A1R5G5B5: + case D3DFMT_A1R5G5B5: ddpf->dwRGBBitCount = 16; ddpf->dwRGBAlphaBitMask = 0x8000; ddpf->dwRBitMask = 0x7c00; @@ -361,7 +361,7 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) ddpf->dwBBitMask = 0; ddpf->noAlpha = false; break; - default: + default: printf("Unsupport format %d\n ", format); ddpf->dwRGBBitCount = 8; ddpf->dwRGBAlphaBitMask = 0; @@ -376,12 +376,12 @@ VOID computePixelFormat(PIXELFORMAT *ddpf, D3DFORMAT format) /* - * Right now only format D3DFMT_D16_LOCKABLE + * Right now only format D3DFMT_D16_LOCKABLE * is lockable by application. So can't use * with stencil buffer (in DecalGroup) together */ -VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf, - D3DFORMAT format) +VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf, + D3DFORMAT format) { switch (format) { case D3DFMT_D16_LOCKABLE: @@ -392,17 +392,17 @@ VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf, case D3DFMT_D15S1: ddpf->dwZBufferBitDepth = 16; ddpf->dwZBitMask = 0xfffe; - break; + break; case D3DFMT_D32: ddpf->dwZBufferBitDepth = 32; ddpf->dwZBitMask = 0xffffffff; - break; + break; case D3DFMT_D24S8: case D3DFMT_D24X8: case D3DFMT_D24X4S4: ddpf->dwZBufferBitDepth = 32; ddpf->dwZBitMask = 0xffffff00; - break; + break; default: printf("Unknown depth buffer format %d\n", format); } @@ -412,13 +412,13 @@ VOID computeDepthPixelFormat(DEPTHPIXELFORMAT *ddpf, /* * Set the correct D3DTSS_TEXTURETRANSFORMFLAGS */ -void setTexTransformStageFlag(D3dCtx* d3dCtx, - LPDIRECT3DDEVICE8 device, - int tus, int ts, int genMode) +void setTexTransformStageFlag(D3dCtx* d3dCtx, + LPDIRECT3DDEVICE9 device, + int tus, int ts, int genMode) { /* * In case of automatic texture generation, disable - * texture unit transform stage will cause crash in + * texture unit transform stage will cause crash in * reference device mode. */ if ((!d3dCtx->texTransformSet[tus]) && @@ -428,7 +428,7 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx, D3DTTFF_DISABLE); } else { D3DXMATRIX *m; - + switch (ts) { case 2: // Adjust for 2D texture transform in D3D @@ -463,18 +463,18 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx, m = &d3dCtx->texTransform[tus]; (*m)._31 = (*m)._41; (*m)._32 = (*m)._42; - device->SetTransform((D3DTRANSFORMSTATETYPE) + device->SetTransform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0 + tus), m); d3dCtx->texTranslateSet[tus] = true; } device->SetTextureStageState(tus, - D3DTSS_TEXTURETRANSFORMFLAGS, + D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); break; case 3: device->SetTextureStageState(tus, - D3DTSS_TEXTURETRANSFORMFLAGS, + D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3); break; case 4: @@ -482,15 +482,15 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx, // The texture transform matrix is funky that only the // upper 3x3 matrix is used if we are not using // automatic texture generation. In case of Object - // Linear we are need to workaround by doing our + // Linear we are need to workaround by doing our // own texture transform when generate texture // coordinate. device->SetTextureStageState(tus, D3DTSS_TEXTURETRANSFORMFLAGS, - D3DTTFF_DISABLE); - } else { + D3DTTFF_DISABLE); + } else { device->SetTextureStageState(tus, - D3DTSS_TEXTURETRANSFORMFLAGS, + D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT4|D3DTTFF_PROJECTED); } break; @@ -503,18 +503,18 @@ void setTexTransformStageFlag(D3dCtx* d3dCtx, } /* - * Set the corresponding D3D texture coordinate + * Set the corresponding D3D texture coordinate * mapping mode. */ inline int setTextureStage(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, int mapTexStage, jint texStage) { DWORD mode = 0; int genMode = d3dCtx->texGenMode[mapTexStage]; - // printf("Set TexStage mapTexStage = %d, texStage = %d, genMode = %d\n", + // printf("Set TexStage mapTexStage = %d, texStage = %d, genMode = %d\n", // mapTexStage, texStage, genMode); switch (genMode) { @@ -523,10 +523,10 @@ inline int setTextureStage(D3dCtx *d3dCtx, case TEX_GEN_INVALID: // optimize for general case device->SetTextureStageState(mapTexStage, - D3DTSS_TEXCOORDINDEX, + D3DTSS_TEXCOORDINDEX, texStage); return genMode; - case TEX_EYE_LINEAR: + case TEX_EYE_LINEAR: mode = D3DTSS_TCI_CAMERASPACEPOSITION; break; case TEX_SPHERE_MAP: @@ -547,21 +547,21 @@ inline int setTextureStage(D3dCtx *d3dCtx, // there is no texture coordinate defined in that texStage in VB. // This also clear the texStage previously set. device->SetTextureStageState(mapTexStage, - D3DTSS_TEXCOORDINDEX, + D3DTSS_TEXCOORDINDEX, mode | texStage); return TEX_GEN_AUTO; } -void getTexWidthHeight(D3dDeviceInfo *deviceInfo, +void getTexWidthHeight(D3dDeviceInfo *deviceInfo, jint* width, jint *height) { int texWidth, texHeight; - + texWidth = *width; texHeight = *height; - + // Found a texture bigger than width/height if (deviceInfo->texturePow2Only) { @@ -620,7 +620,7 @@ D3DFORMAT getTexFormat(jint internalFormat) { default: printf("CreateTextureSurface: Unknown internal Format %d \n", internalFormat); return D3DFMT_UNKNOWN; - } + } } @@ -628,7 +628,7 @@ D3dCtx* findCtx(HWND hwnd) { D3dCtx *ctx = NULL; - for (D3dCtx **p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) { + for (ITER_D3dCtxVector p = d3dCtxList.begin(); p != d3dCtxList.end(); p++) { if ((*p)->hwnd == hwnd) { ctx = *p; break; @@ -638,7 +638,7 @@ D3dCtx* findCtx(HWND hwnd) } -inline VOID lock() +inline VOID lock() { if (hSema != NULL) { WaitForSingleObject(hSema, INFINITE); @@ -653,7 +653,7 @@ inline VOID unlock() } -inline VOID lockSurfaceList() +inline VOID lockSurfaceList() { if (surfaceListSema != NULL) { WaitForSingleObject(surfaceListSema, INFINITE); @@ -681,7 +681,7 @@ inline VOID unlockBackground() } } -inline VOID lockImage() +inline VOID lockImage() { if (imageSema != NULL) { WaitForSingleObject(imageSema, INFINITE); @@ -697,7 +697,7 @@ inline VOID unlockImage() -inline VOID lockGeometry() +inline VOID lockGeometry() { if (geometrySema != NULL) { WaitForSingleObject(geometrySema, INFINITE); @@ -711,28 +711,28 @@ inline VOID unlockGeometry() } } -VOID freePointer(void * ptr) +VOID freePointer(void * ptr) { if (ptr != NULL) { lockSurfaceList(); if (useFreePointerList0) { freePointerList0.push_back(ptr); } else { - freePointerList1.push_back(ptr); + freePointerList1.push_back(ptr); } unlockSurfaceList(); } } -char *getErrorMessage(int idx) +char *getErrorMessage(int idx) { return D3dErrorMessage[idx]; } -HWND getTopWindow(HWND hwnd) +HWND getTopWindow(HWND hwnd) { HWND desktop = GetDesktopWindow(); HWND parent = GetParent(hwnd); @@ -745,7 +745,7 @@ HWND getTopWindow(HWND hwnd) } -DWORD firstBit(DWORD mask) +DWORD firstBit(DWORD mask) { int i; @@ -760,23 +760,23 @@ DWORD firstBit(DWORD mask) } // create a DirectDraw Texture surface of specific width and height -LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx, +LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, - jint width, jint height) + jint width, jint height) { - LPDIRECT3DTEXTURE8 pTexture; + LPDIRECT3DTEXTURE9 pTexture; D3DFORMAT format; HRESULT hr; - LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice; D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo; if (!deviceInfo->supportMipmap) { numLevels = 1; - } + } - getTexWidthHeight(deviceInfo, &width, &height); + getTexWidthHeight(deviceInfo, &width, &height); format = getTexFormat(internalFormat); // If format not support, the utility function will adjust the @@ -787,29 +787,29 @@ LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx, if (FAILED(hr)) { printf("Fail to create texture surface %dx%d, format %d, level %d : %s\n", - width, height, format, numLevels, DXGetErrorString8(hr)); + width, height, format, numLevels, DXGetErrorString9(hr)); return NULL; } - + return pTexture; } // create a DirectDraw Texture surface of specific width and height -LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx, +LPDIRECT3DVOLUMETEXTURE9 createVolumeTexture(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, - jint width, + jint width, jint height, - jint depth) + jint depth) { - LPDIRECT3DVOLUMETEXTURE8 pTexture; + LPDIRECT3DVOLUMETEXTURE9 pTexture; int texWidth, texHeight, texDepth; D3DFORMAT format; HRESULT hr; - LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice; D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo; texWidth = width; @@ -819,7 +819,7 @@ LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx, if (!deviceInfo->supportMipmap) { numLevels = 1; - } + } // Found a texture bigger than width/height @@ -887,25 +887,25 @@ LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx, if (debug) { printf("Fail to create volume texture %dx%dx%d, format %d, level %d : %s\n", texWidth, texHeight, texDepth, format, numLevels, - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); } return NULL; } - + return pTexture; } // copy data from DirectDraw surface to memory // and reverse the Y axis -void copyDataFromSurface(jint internalFormat, +void copyDataFromSurface(jint internalFormat, jint xoffset, jint yoffset, jint subWidth, jint subHeight, - jbyte *data, - LPDIRECT3DSURFACE8 surf) + jbyte *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; @@ -929,7 +929,7 @@ void copyDataFromSurface(jint internalFormat, D3DLOCK_READONLY); if (FAILED(hr)) { - printf("Fail to lock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock surface: %s\n", DXGetErrorString9(hr)); return; } @@ -941,9 +941,9 @@ void copyDataFromSurface(jint internalFormat, unsigned char *destRow = (unsigned char *) data; unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) + - xoffset*((int) ceil((float) ddpf.dwRGBBitCount/8.0)) + + xoffset*((int) ceil((float) ddpf.dwRGBBitCount/8.0)) + (yoffset*lockedRect.Pitch); - + if ((internalFormat == FORMAT_BYTE_RGBA) || (internalFormat == FORMAT_BYTE_RGB)) { @@ -969,7 +969,7 @@ void copyDataFromSurface(jint internalFormat, *src++; *dst++ = (byte) 0xff; } - srcRow += lockedRect.Pitch; + srcRow += lockedRect.Pitch; destRow -= dstPitch; } } else { @@ -985,21 +985,21 @@ void copyDataFromSurface(jint internalFormat, *dst++ = b1; *dst++ = *src++; } - srcRow += lockedRect.Pitch; + srcRow += lockedRect.Pitch; destRow -= dstPitch; } } } else { // handle less common format int rshift = firstBit(ddpf.dwRBitMask) + - countBits(ddpf.dwRBitMask) - 8; - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; + ucountBits(ddpf.dwRBitMask) - 8; + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; int bshift = firstBit(ddpf.dwBBitMask) + - countBits(ddpf.dwBBitMask) - 8; + ucountBits(ddpf.dwBBitMask) - 8; int ashift = firstBit(ddpf.dwRGBAlphaBitMask) + - countBits(ddpf.dwRGBAlphaBitMask) - 8; + ucountBits(ddpf.dwRGBAlphaBitMask) - 8; - if ((ddpf.dwRGBBitCount <= 32) && + if ((ddpf.dwRGBBitCount <= 32) && (ddpf.dwRGBBitCount > 24)) { for (int i=yoffset; i < ylimit; i++) { @@ -1028,7 +1028,7 @@ void copyDataFromSurface(jint internalFormat, } if (bshift >= 0) { *dst++ = (byte) ((mask & ddpf.dwBBitMask) >> - bshift); + bshift); } else { t = (mask & ddpf.dwBBitMask) << -bshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); @@ -1048,7 +1048,7 @@ void copyDataFromSurface(jint internalFormat, srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 24) && + } else if ((ddpf.dwRGBBitCount <= 24) && (ddpf.dwRGBBitCount > 16)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -1094,7 +1094,7 @@ void copyDataFromSurface(jint internalFormat, srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 16) && + } else if ((ddpf.dwRGBBitCount <= 16) && (ddpf.dwRGBBitCount > 8)) { for (int i=yoffset; i < ylimit; i++) { @@ -1111,7 +1111,7 @@ void copyDataFromSurface(jint internalFormat, t = (mask & ddpf.dwRBitMask) << -rshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } - + if (gshift >= 0) { *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); @@ -1121,7 +1121,7 @@ void copyDataFromSurface(jint internalFormat, } if (bshift >= 0) { *dst++ = (byte) ((mask & ddpf.dwBBitMask) >> - bshift); + bshift); } else { t = (mask & ddpf.dwBBitMask) << -bshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); @@ -1155,7 +1155,7 @@ void copyDataFromSurface(jint internalFormat, t = (mask & ddpf.dwRBitMask) << -rshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } - + if (gshift >= 0) { *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); @@ -1165,7 +1165,7 @@ void copyDataFromSurface(jint internalFormat, } if (bshift >= 0) { *dst++ = (byte) ((mask & ddpf.dwBBitMask) >> - bshift); + bshift); } else { t = (mask & ddpf.dwBBitMask) << -bshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); @@ -1186,12 +1186,12 @@ void copyDataFromSurface(jint internalFormat, destRow -= dstPitch; } } - } + } } else if (internalFormat == FORMAT_BYTE_LA) { - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; int ashift = firstBit(ddpf.dwRGBAlphaBitMask) + - countBits(ddpf.dwRGBAlphaBitMask) - 8; + ucountBits(ddpf.dwRGBAlphaBitMask) - 8; dstPitch = subWidth << 1; destRow += (subHeight-1)*dstPitch; @@ -1215,13 +1215,13 @@ void copyDataFromSurface(jint internalFormat, *dst++ = *src++; } } - srcRow += lockedRect.Pitch; + srcRow += lockedRect.Pitch; destRow -= dstPitch; } } else { // handle less common format - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; - if ((ddpf.dwRGBBitCount <= 32) && + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; + if ((ddpf.dwRGBBitCount <= 32) && (ddpf.dwRGBBitCount > 24)) { for (int i=yoffset; i < ylimit; i++) { @@ -1237,7 +1237,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } if (ddpf.noAlpha) { @@ -1255,7 +1255,7 @@ void copyDataFromSurface(jint internalFormat, srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 24) && + } else if ((ddpf.dwRGBBitCount <= 24) && (ddpf.dwRGBBitCount > 16)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -1269,7 +1269,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } if (ddpf.noAlpha) { @@ -1287,7 +1287,7 @@ void copyDataFromSurface(jint internalFormat, srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 16) && + } else if ((ddpf.dwRGBBitCount <= 16) && (ddpf.dwRGBBitCount > 8)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -1300,7 +1300,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } if (ddpf.noAlpha) { @@ -1328,7 +1328,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } if (ddpf.noAlpha) { @@ -1347,11 +1347,11 @@ void copyDataFromSurface(jint internalFormat, destRow -= dstPitch; } } - } + } } else if (internalFormat == FORMAT_BYTE_GRAY) { - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; dstPitch = subWidth; destRow += (subHeight-1)*dstPitch; @@ -1370,13 +1370,13 @@ void copyDataFromSurface(jint internalFormat, *dst++ = b2; *src++; } - srcRow += lockedRect.Pitch; + srcRow += lockedRect.Pitch; destRow -= dstPitch; } } else { // handle less common format - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; - if ((ddpf.dwRGBBitCount <= 32) && + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; + if ((ddpf.dwRGBBitCount <= 32) && (ddpf.dwRGBBitCount > 24)) { for (int i=yoffset; i < ylimit; i++) { @@ -1392,14 +1392,14 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } } srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 24) && + } else if ((ddpf.dwRGBBitCount <= 24) && (ddpf.dwRGBBitCount > 16)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -1413,14 +1413,14 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } } srcRow += lockedRect.Pitch; destRow -= dstPitch; } - } else if ((ddpf.dwRGBBitCount <= 16) && + } else if ((ddpf.dwRGBBitCount <= 16) && (ddpf.dwRGBBitCount > 8)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -1433,7 +1433,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } } @@ -1450,7 +1450,7 @@ void copyDataFromSurface(jint internalFormat, *dst++ = (byte) ((mask & ddpf.dwGBitMask) >> gshift); } else { - t = (mask & ddpf.dwGBitMask) << -gshift; + t = (mask & ddpf.dwGBitMask) << -gshift; *dst++ = (t <= 0xff ? (byte) t : 0xff); } } @@ -1458,7 +1458,7 @@ void copyDataFromSurface(jint internalFormat, destRow -= dstPitch; } } - } + } } else { // FORMAT_USHORT_GRAY @@ -1468,21 +1468,21 @@ void copyDataFromSurface(jint internalFormat, hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr)); return; } } -void copyDataToSurfaceABGR(jint internalFormat, +void copyDataToSurfaceABGR(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -1510,7 +1510,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = a; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -1529,20 +1529,20 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (a << 4) | r; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -1569,7 +1569,7 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -1577,7 +1577,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -1606,14 +1606,14 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -1642,13 +1642,13 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -1676,31 +1676,31 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -1710,7 +1710,7 @@ void copyDataToSurfaceABGR(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -1730,7 +1730,7 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -1738,7 +1738,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -1750,7 +1750,7 @@ void copyDataToSurfaceABGR(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -1770,14 +1770,14 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -1789,7 +1789,7 @@ void copyDataToSurfaceABGR(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -1809,13 +1809,13 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -1826,7 +1826,7 @@ void copyDataToSurfaceABGR(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -1846,22 +1846,22 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -1881,7 +1881,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -1902,7 +1902,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -1922,7 +1922,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -1939,26 +1939,26 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -1987,7 +1987,7 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -1995,7 +1995,7 @@ void copyDataToSurfaceABGR(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2026,14 +2026,14 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2064,13 +2064,13 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -2100,16 +2100,16 @@ void copyDataToSurfaceABGR(jint internalFormat, } else { a = l << -aDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -2118,14 +2118,14 @@ void copyDataToSurfaceABGR(jint internalFormat, } -void copyDataToSurfaceBGR(jint internalFormat, +void copyDataToSurfaceBGR(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -2153,7 +2153,7 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = 0xff; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && @@ -2172,18 +2172,18 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = 0xf0 | r; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -2205,15 +2205,15 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2237,14 +2237,14 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2268,13 +2268,13 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -2297,29 +2297,29 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { r = (*src++) << -rDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask); + *dst++ = (byte) ((r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -2344,15 +2344,15 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2379,14 +2379,14 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2413,13 +2413,13 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -2445,23 +2445,23 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | - (b << bshift) |ddpf->dwRGBAlphaBitMask); + *dst++ = (byte) ((r << rshift) | (g << gshift) | + (b << bshift) |ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { + } else if (internalFormat == ALPHA) { byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff); byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff); byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff); byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff); - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -2475,7 +2475,7 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = m4; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2490,7 +2490,7 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = m3; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2504,7 +2504,7 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = m2; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -2516,23 +2516,23 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -2556,7 +2556,7 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -2564,7 +2564,7 @@ void copyDataToSurfaceBGR(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2590,14 +2590,14 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2623,13 +2623,13 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -2654,16 +2654,16 @@ void copyDataToSurfaceBGR(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | - ddpf->dwRGBAlphaBitMask); + ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -2676,14 +2676,14 @@ void copyDataToSurfaceBGR(jint internalFormat, * but the pixel is written in the destination buffer * from right to left. This is used for CubeMapping. */ -void copyDataToSurfaceRGBARev(jint internalFormat, +void copyDataToSurfaceRGBARev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -2716,7 +2716,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -2736,19 +2736,19 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -2775,7 +2775,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -2784,7 +2784,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2814,14 +2814,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -2850,13 +2850,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit-1); @@ -2884,31 +2884,31 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) -1); for (int i=yoffset; i < ylimit; i++) { @@ -2921,7 +2921,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -2938,7 +2938,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); @@ -2947,7 +2947,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -2962,7 +2962,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -2979,14 +2979,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3001,7 +3001,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -3018,13 +3018,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -3038,7 +3038,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -3055,22 +3055,22 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3090,7 +3090,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3111,7 +3111,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3131,7 +3131,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit-1); @@ -3148,25 +3148,25 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3195,7 +3195,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -3203,7 +3203,7 @@ void copyDataToSurfaceRGBARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3234,14 +3234,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3272,13 +3272,13 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit-1); @@ -3308,16 +3308,16 @@ void copyDataToSurfaceRGBARev(jint internalFormat, } else { a = l << -aDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -3327,14 +3327,14 @@ void copyDataToSurfaceRGBARev(jint internalFormat, -void copyDataToSurfaceABGRRev(jint internalFormat, +void copyDataToSurfaceABGRRev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -3365,7 +3365,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -3384,20 +3384,20 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (g << 4) | b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3424,7 +3424,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -3432,7 +3432,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3461,14 +3461,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3497,13 +3497,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit-1); @@ -3531,31 +3531,31 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3565,7 +3565,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -3585,7 +3585,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -3593,7 +3593,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3605,7 +3605,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -3625,14 +3625,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3644,7 +3644,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -3664,13 +3664,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -3681,7 +3681,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } src++; src++; @@ -3701,22 +3701,22 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3737,7 +3737,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3758,7 +3758,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3778,7 +3778,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xlimit; @@ -3795,26 +3795,26 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -3843,7 +3843,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -3851,7 +3851,7 @@ void copyDataToSurfaceABGRRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -3882,14 +3882,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -3920,13 +3920,13 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -3956,16 +3956,16 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } else { a = l << -aDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -3975,14 +3975,14 @@ void copyDataToSurfaceABGRRev(jint internalFormat, } -void copyDataToSurfaceBGRRev(jint internalFormat, +void copyDataToSurfaceBGRRev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -4013,7 +4013,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && @@ -4032,18 +4032,18 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = (g << 4) | b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4065,15 +4065,15 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4097,14 +4097,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4128,13 +4128,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4157,29 +4157,29 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { r = (*src++) << -rDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask); + *dst-- = (byte) ((r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4204,15 +4204,15 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4239,14 +4239,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4273,13 +4273,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4305,23 +4305,23 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | - (b << bshift) |ddpf->dwRGBAlphaBitMask); + *dst-- = (byte) ((r << rshift) | (g << gshift) | + (b << bshift) |ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { + } else if (internalFormat == ALPHA) { byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff); byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff); byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff); byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff); - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4335,7 +4335,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4350,7 +4350,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4364,7 +4364,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4376,23 +4376,23 @@ void copyDataToSurfaceBGRRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4416,7 +4416,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -4425,7 +4425,7 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4451,14 +4451,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4484,13 +4484,13 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4515,16 +4515,16 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | - ddpf->dwRGBAlphaBitMask); + ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -4533,14 +4533,14 @@ void copyDataToSurfaceBGRRev(jint internalFormat, } -void copyDataToSurfaceRGBRev(jint internalFormat, +void copyDataToSurfaceRGBRev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -4573,7 +4573,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -4591,18 +4591,18 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = (g << 4) | b; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4624,15 +4624,15 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4656,14 +4656,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4687,13 +4687,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4716,29 +4716,29 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4763,7 +4763,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -4771,7 +4771,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4798,14 +4798,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4832,13 +4832,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4864,23 +4864,23 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { + } else if (internalFormat == ALPHA) { byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff); byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff); byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff); byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff); - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4894,7 +4894,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -4909,7 +4909,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -4923,7 +4923,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -4935,23 +4935,23 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -4976,7 +4976,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -4984,7 +4984,7 @@ void copyDataToSurfaceRGBRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5011,14 +5011,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5045,13 +5045,13 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5077,16 +5077,16 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -5094,14 +5094,14 @@ void copyDataToSurfaceRGBRev(jint internalFormat, } } -void copyDataToSurfaceLARev(jint internalFormat, +void copyDataToSurfaceLARev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -5132,7 +5132,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -5149,20 +5149,20 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (l << 4) | l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5179,7 +5179,7 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -5187,7 +5187,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5206,14 +5206,14 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5232,13 +5232,13 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5256,32 +5256,32 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - *dst-- = (byte) ((l << rshift) | (l << gshift) | + *dst-- = (byte) ((l << rshift) | (l << gshift) | (l << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5292,7 +5292,7 @@ void copyDataToSurfaceLARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5309,7 +5309,7 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); @@ -5318,7 +5318,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5331,7 +5331,7 @@ void copyDataToSurfaceLARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5348,14 +5348,14 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5368,7 +5368,7 @@ void copyDataToSurfaceLARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5385,13 +5385,13 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5403,7 +5403,7 @@ void copyDataToSurfaceLARev(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5420,22 +5420,22 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5455,7 +5455,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5476,7 +5476,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5496,7 +5496,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5513,25 +5513,25 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5560,7 +5560,7 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -5568,7 +5568,7 @@ void copyDataToSurfaceLARev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5599,14 +5599,14 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5637,13 +5637,13 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5673,16 +5673,16 @@ void copyDataToSurfaceLARev(jint internalFormat, } else { a = l << -aDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -5690,14 +5690,14 @@ void copyDataToSurfaceLARev(jint internalFormat, } } -void copyDataToSurfaceGrayRev(jint internalFormat, +void copyDataToSurfaceGrayRev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -5728,7 +5728,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -5744,18 +5744,18 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (l << 4) | l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5767,7 +5767,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -5775,7 +5775,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5789,14 +5789,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5810,13 +5810,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5829,32 +5829,32 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { l = (*src++) << -rDiscard; } - *dst-- = (byte) ((l << rshift) | (l << gshift) | - (l << bshift) | ddpf->dwRGBAlphaBitMask); + *dst-- = (byte) ((l << rshift) | (l << gshift) | + (l << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -5865,7 +5865,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5882,7 +5882,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -5890,7 +5890,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -5903,7 +5903,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5920,14 +5920,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -5940,7 +5940,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5957,13 +5957,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -5975,7 +5975,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -5992,22 +5992,22 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { b = l << -bDiscard; } - *dst-- = (byte) ((r << rshift) | (g << gshift) | + *dst-- = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -6026,7 +6026,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6046,7 +6046,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6065,7 +6065,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -6081,25 +6081,25 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -6127,7 +6127,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -6135,7 +6135,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6165,14 +6165,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6202,13 +6202,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -6237,16 +6237,16 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -6255,14 +6255,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } -void copyDataToSurfaceGrayRev(jint internalFormat, +void copyDataToSurfaceGrayRev(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jshort *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -6272,12 +6272,12 @@ void copyDataToSurfaceGrayRev(jint internalFormat, unsigned char *destRow = pRect + rectPitch*yoffset; - if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -6297,7 +6297,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6318,7 +6318,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6338,7 +6338,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -6355,25 +6355,25 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += ((xlimit << 2) - 1); for (int i=yoffset; i < ylimit; i++) { @@ -6402,7 +6402,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 24) & 0xff); *dst-- = (byte) ((mask >> 16) & 0xff); @@ -6410,7 +6410,7 @@ void copyDataToSurfaceGrayRev(jint internalFormat, *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6441,14 +6441,14 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 16) & 0xff); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6479,13 +6479,13 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst-- = (byte) ((mask >> 8) & 0xff); *dst-- = (byte) (mask & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += (xlimit - 1); @@ -6515,47 +6515,47 @@ void copyDataToSurfaceGrayRev(jint internalFormat, } else { a = l << -aDiscard; } - *dst-- = (byte) ((r << rshift) | - (g << gshift) | + *dst-- = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { printf("Texture format %d not support.\n", internalFormat); - } + } } /* * Copy data to Texture memory surface *pRect - * with pitch = rectPitch + * with pitch = rectPitch * Note that rectPitch >= surface width since * D3D may allocate extra width in texture memory * for other purpose or for alignment. Addional - * offset = (xoffset, yoffset) is added to copy - * data in texture memory. + * offset = (xoffset, yoffset) is added to copy + * data in texture memory. * * The source image has width = subWidth and * pointer *data. - * + * * */ -void copyDataToSurfaceRGBA(jint internalFormat, +void copyDataToSurfaceRGBA(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -6588,7 +6588,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = *src++; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -6607,20 +6607,20 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (a << 4) | r; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -6647,7 +6647,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -6655,7 +6655,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6684,14 +6684,14 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6720,13 +6720,13 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -6754,32 +6754,32 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -6792,7 +6792,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -6809,7 +6809,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -6817,7 +6817,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6832,7 +6832,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -6849,14 +6849,14 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -6871,7 +6871,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -6888,13 +6888,13 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -6908,7 +6908,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -6925,22 +6925,22 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -6960,7 +6960,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -6981,7 +6981,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7001,7 +7001,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7018,25 +7018,25 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7065,7 +7065,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -7073,7 +7073,7 @@ void copyDataToSurfaceRGBA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7104,14 +7104,14 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7142,13 +7142,13 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7178,16 +7178,16 @@ void copyDataToSurfaceRGBA(jint internalFormat, } else { a = l << -aDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -7196,14 +7196,14 @@ void copyDataToSurfaceRGBA(jint internalFormat, } -void copyDataToSurfaceRGB(jint internalFormat, +void copyDataToSurfaceRGB(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -7237,7 +7237,7 @@ void copyDataToSurfaceRGB(jint internalFormat, } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -7255,18 +7255,18 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = 0xf0 | r; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); - int gshift = firstBit(ddpf->dwGBitMask); - int bshift = firstBit(ddpf->dwBBitMask); + int gshift = firstBit(ddpf->dwGBitMask); + int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7288,15 +7288,15 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7320,14 +7320,14 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | - (b << bshift) | ddpf->dwRGBAlphaBitMask; + mask = (r << rshift) | (g << gshift) | + (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7351,13 +7351,13 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7380,29 +7380,29 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = (*src++) >> -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7427,7 +7427,7 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -7435,7 +7435,7 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7462,14 +7462,14 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7496,13 +7496,13 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7528,23 +7528,23 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { + } else if (internalFormat == ALPHA) { byte m1 = (byte) (ddpf->dwRGBAlphaBitMask & 0xff); byte m2 = (byte) ((ddpf->dwRGBAlphaBitMask >> 8) & 0xff); byte m3 = (byte) ((ddpf->dwRGBAlphaBitMask >> 16) & 0xff); byte m4 = (byte) ((ddpf->dwRGBAlphaBitMask >> 24) & 0xff); - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7558,7 +7558,7 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = m4; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7573,7 +7573,7 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = m3; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7587,7 +7587,7 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = m2; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7599,23 +7599,23 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = m1; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7640,7 +7640,7 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -7648,7 +7648,7 @@ void copyDataToSurfaceRGB(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7675,14 +7675,14 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7709,13 +7709,13 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7741,16 +7741,16 @@ void copyDataToSurfaceRGB(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -7759,14 +7759,14 @@ void copyDataToSurfaceRGB(jint internalFormat, } -void copyDataToSurfaceLA(jint internalFormat, +void copyDataToSurfaceLA(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -7797,7 +7797,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = *src++; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -7814,20 +7814,20 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (a << 4) | l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7844,7 +7844,7 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -7852,7 +7852,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7871,14 +7871,14 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -7897,13 +7897,13 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -7921,32 +7921,32 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = (*src++) >> -aDiscard; } - *dst++ = (byte) ((l << rshift) | (l << gshift) | + *dst++ = (byte) ((l << rshift) | (l << gshift) | (l << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -7957,7 +7957,7 @@ void copyDataToSurfaceLA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -7974,7 +7974,7 @@ void copyDataToSurfaceLA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -7982,7 +7982,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -7995,7 +7995,7 @@ void copyDataToSurfaceLA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8012,14 +8012,14 @@ void copyDataToSurfaceLA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8032,7 +8032,7 @@ void copyDataToSurfaceLA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8049,13 +8049,13 @@ void copyDataToSurfaceLA(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8067,7 +8067,7 @@ void copyDataToSurfaceLA(jint internalFormat, if (aDiscard >= 0) { a = (*src++) >> aDiscard; } else { - a = (*src++) << -aDiscard; + a = (*src++) << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8084,22 +8084,22 @@ void copyDataToSurfaceLA(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8119,7 +8119,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8140,7 +8140,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8160,7 +8160,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8177,25 +8177,25 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8224,7 +8224,7 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -8232,7 +8232,7 @@ void copyDataToSurfaceLA(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8263,14 +8263,14 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8301,13 +8301,13 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8337,16 +8337,16 @@ void copyDataToSurfaceLA(jint internalFormat, } else { a = l << -aDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -8354,14 +8354,14 @@ void copyDataToSurfaceLA(jint internalFormat, } } -void copyDataToSurfaceGray(jint internalFormat, +void copyDataToSurfaceGray(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jbyte *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -8393,7 +8393,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = 0xff; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount == 16) && (ddpf->dwRBitMask == 0xf00) && @@ -8409,18 +8409,18 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = 0xf0 | l; } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { // handle less common (even weird) format - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8432,7 +8432,7 @@ void copyDataToSurfaceGray(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -8440,7 +8440,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8454,14 +8454,14 @@ void copyDataToSurfaceGray(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8475,13 +8475,13 @@ void copyDataToSurfaceGray(jint internalFormat, } else { l = (*src++) << -rDiscard; } - mask = (l << rshift) | (l << gshift) | + mask = (l << rshift) | (l << gshift) | (l << bshift) | ddpf->dwRGBAlphaBitMask; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8494,32 +8494,32 @@ void copyDataToSurfaceGray(jint internalFormat, } else { l = (*src++) << -rDiscard; } - *dst++ = (byte) ((l << rshift) | (l << gshift) | - (l << bshift) | ddpf->dwRGBAlphaBitMask); + *dst++ = (byte) ((l << rshift) | (l << gshift) | + (l << bshift) | ddpf->dwRGBAlphaBitMask); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } } else if (internalFormat == LUMINANCE_ALPHA) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8530,7 +8530,7 @@ void copyDataToSurfaceGray(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8547,7 +8547,7 @@ void copyDataToSurfaceGray(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -8555,7 +8555,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8568,7 +8568,7 @@ void copyDataToSurfaceGray(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8585,14 +8585,14 @@ void copyDataToSurfaceGray(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8605,7 +8605,7 @@ void copyDataToSurfaceGray(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8622,13 +8622,13 @@ void copyDataToSurfaceGray(jint internalFormat, } else { b = l << -bDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8640,7 +8640,7 @@ void copyDataToSurfaceGray(jint internalFormat, if (aDiscard >= 0) { a = l >> aDiscard; } else { - a = l << -aDiscard; + a = l << -aDiscard; } if (rDiscard >= 0) { r = l >> rDiscard; @@ -8657,22 +8657,22 @@ void copyDataToSurfaceGray(jint internalFormat, } else { b = l << -bDiscard; } - *dst++ = (byte) ((r << rshift) | (g << gshift) | + *dst++ = (byte) ((r << rshift) | (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } - } else if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + } else if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8691,7 +8691,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8711,7 +8711,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8730,7 +8730,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8746,25 +8746,25 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - - if ((ddpf->dwRGBBitCount <= 32) && + + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -8792,7 +8792,7 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -8800,7 +8800,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -8830,14 +8830,14 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -8867,13 +8867,13 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -8902,16 +8902,16 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { @@ -8925,28 +8925,28 @@ void copyDataToSurfaceGray(jint internalFormat, * Copy data from memory to DirectDraw surface * * Source image with WIDTH = tilew, the subimage with - * dimension (subWidth, subHeight) is copy with + * dimension (subWidth, subHeight) is copy with * offset = (imgXOffset, imgYOffset) from the start * pointer *data. * - * Destination frame buffer is copy with + * Destination frame buffer is copy with * offset = (xoffset, yoffset) * */ void copyDataToSurface(jint storedFormat, - jint internalFormat, + jint internalFormat, jint xoffset, jint yoffset, jint imgXOffset, jint imgYOffset, jint subWidth, jint subHeight, - jint tilew, jbyte *data, - LPDIRECT3DTEXTURE8 surf, - jint level) + jint tilew, jbyte *data, + LPDIRECT3DTEXTURE9 surf, + jint level) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; - + if (surf == NULL) { return; } @@ -8971,58 +8971,58 @@ void copyDataToSurface(jint storedFormat, if (FAILED(hr)) { - printf("Fail to lock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock surface: %s\n", DXGetErrorString9(hr)); return; } int offset = tilew*imgYOffset + imgXOffset; switch (storedFormat) { case FORMAT_BYTE_RGBA : // This is the one we use when byReference = false - copyDataToSurfaceRGBA(internalFormat, &ddpf, + copyDataToSurfaceRGBA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 2), - xoffset, yoffset, + data + (offset << 2), + xoffset, yoffset, xlimit, ylimit, tilew); break; case FORMAT_BYTE_RGB: - copyDataToSurfaceRGB(internalFormat, &ddpf, + copyDataToSurfaceRGB(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + 3*offset, - xoffset, yoffset, + data + 3*offset, + xoffset, yoffset, xlimit, ylimit, tilew); break; case FORMAT_BYTE_ABGR: - copyDataToSurfaceABGR(internalFormat, &ddpf, + copyDataToSurfaceABGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 2), - xoffset, yoffset, + data + (offset << 2), + xoffset, yoffset, xlimit, ylimit, tilew); break; case FORMAT_BYTE_BGR: - copyDataToSurfaceBGR(internalFormat, &ddpf, + copyDataToSurfaceBGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + 3*offset, - xoffset, yoffset, + data + 3*offset, + xoffset, yoffset, xlimit, ylimit, tilew); break; case FORMAT_BYTE_LA: - copyDataToSurfaceLA(internalFormat, &ddpf, + copyDataToSurfaceLA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 1), - xoffset, yoffset, + data + (offset << 1), + xoffset, yoffset, xlimit, ylimit, tilew); break; case FORMAT_BYTE_GRAY: copyDataToSurfaceGray(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + offset, - xoffset, yoffset, + data + offset, + xoffset, yoffset, xlimit, ylimit, tilew); break; default: // should not happen @@ -9032,21 +9032,21 @@ void copyDataToSurface(jint storedFormat, hr = surf->UnlockRect(level); if (FAILED(hr)) { - printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr)); return; } } -void copyDataToSurfaceGray(jint internalFormat, +void copyDataToSurfaceGray(jint internalFormat, PIXELFORMAT *ddpf, unsigned char* pRect, DWORD rectPitch, jshort *data, jint xoffset, jint yoffset, - DWORD xlimit, DWORD ylimit, - jint subWidth) + DWORD xlimit, DWORD ylimit, + jint subWidth) { unsigned char *src; unsigned char *dst; @@ -9056,12 +9056,12 @@ void copyDataToSurfaceGray(jint internalFormat, unsigned char *destRow = pRect + rectPitch*yoffset; - if (internalFormat == ALPHA) { - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + if (internalFormat == ALPHA) { + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -9081,7 +9081,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -9102,7 +9102,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -9122,7 +9122,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -9139,26 +9139,26 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) (a << ashift); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else if ((internalFormat == LUMINANCE) || (internalFormat == INTENSITY)) { - int rDiscard = 8-countBits(ddpf->dwRBitMask); - int gDiscard = 8-countBits(ddpf->dwGBitMask); - int bDiscard = 8-countBits(ddpf->dwBBitMask); - int aDiscard = 8-countBits(ddpf->dwRGBAlphaBitMask); + int rDiscard = 8-ucountBits(ddpf->dwRBitMask); + int gDiscard = 8-ucountBits(ddpf->dwGBitMask); + int bDiscard = 8-ucountBits(ddpf->dwBBitMask); + int aDiscard = 8-ucountBits(ddpf->dwRGBAlphaBitMask); int rshift = firstBit(ddpf->dwRBitMask); int gshift = firstBit(ddpf->dwGBitMask); int bshift = firstBit(ddpf->dwBBitMask); - int ashift = firstBit(ddpf->dwRGBAlphaBitMask); + int ashift = firstBit(ddpf->dwRGBAlphaBitMask); DWORD mask; - if ((ddpf->dwRGBBitCount <= 32) && + if ((ddpf->dwRGBBitCount <= 32) && (ddpf->dwRGBBitCount > 24)) { destRow += (xoffset << 2); for (int i=yoffset; i < ylimit; i++) { @@ -9187,7 +9187,7 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); @@ -9195,7 +9195,7 @@ void copyDataToSurfaceGray(jint internalFormat, *dst++ = (byte) ((mask >> 24) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 24) && (ddpf->dwRGBBitCount > 16)) { @@ -9226,14 +9226,14 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if ((ddpf->dwRGBBitCount <= 16) && (ddpf->dwRGBBitCount > 8)) { @@ -9264,13 +9264,13 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - mask = (r << rshift) | (g << gshift) | + mask = (r << rshift) | (g << gshift) | (b << bshift) | (a << ashift); *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else if (ddpf->dwRGBBitCount <= 8) { destRow += xoffset; @@ -9300,21 +9300,21 @@ void copyDataToSurfaceGray(jint internalFormat, } else { a = l << -aDiscard; } - *dst++ = (byte) ((r << rshift) | - (g << gshift) | + *dst++ = (byte) ((r << rshift) | + (g << gshift) | (b << bshift) | (a << ashift)); } srcRow += srcPitch; - destRow += rectPitch; + destRow += rectPitch; } } else { - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf->dwRGBBitCount); } } else { printf("Texture format %d not support.\n", internalFormat); - } + } } @@ -9325,14 +9325,14 @@ void copyDataToSurface(jint storedFormat, jint imgXOffset, jint imgYOffset, jint subWidth, jint subHeight, jint tilew, jshort *data, - LPDIRECT3DTEXTURE8 surf, + LPDIRECT3DTEXTURE9 surf, jint level) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; - + if (surf == NULL) { return; } @@ -9351,22 +9351,22 @@ void copyDataToSurface(jint storedFormat, hr = surf->LockRect(level, &lockedRect, NULL, 0); if (FAILED(hr)) { - printf("Fail to lock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock surface: %s\n", DXGetErrorString9(hr)); return; } int offset = tilew*imgYOffset + imgXOffset; - copyDataToSurfaceGray(internalFormat, &ddpf, + copyDataToSurfaceGray(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 1), - xoffset, yoffset, + data + (offset << 1), + xoffset, yoffset, xlimit, ylimit, tilew); - + hr = surf->UnlockRect(level); if (FAILED(hr)) { - printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr)); return; } } @@ -9376,14 +9376,14 @@ void copyDataToSurface(jint storedFormat, // and reverse the Y axis void copyDepthFromSurface(jint xoffset, jint yoffset, jint subWidth, jint subHeight, - jint *data, - LPDIRECT3DSURFACE8 surf) + jint *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -9403,7 +9403,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } @@ -9414,7 +9414,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, jint *dst; unsigned char *src; unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) + - xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) + + xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) + (yoffset*lockedRect.Pitch); int zshift = firstBit(ddpf.dwZBitMask); @@ -9432,7 +9432,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, b2 = *src++; b3 = *src++; b4 = *src++; - mask = (b4 << 24) | (b3 << 16) | + mask = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; *dst++ = (mask & ddpf.dwZBitMask) >> zshift; } @@ -9480,13 +9480,13 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, } } else { // This is not support by D3D 8 either - printf("[Java 3D] %d bit Z buffer not support !\n", + printf("[Java 3D] %d bit Z buffer not support !\n", ddpf.dwZBufferBitDepth); } hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } } @@ -9496,14 +9496,14 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, // and reverse the Y axis void copyDepthFromSurface(jint xoffset, jint yoffset, jint subWidth, jint subHeight, - jfloat *data, - LPDIRECT3DSURFACE8 surf) + jfloat *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -9524,7 +9524,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } @@ -9535,11 +9535,11 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, jfloat *dst; unsigned char *src; unsigned char *srcRow = ((unsigned char *) lockedRect.pBits) + - xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) + + xoffset*((int) ceil((float) ddpf.dwZBufferBitDepth/8.0)) + (yoffset*lockedRect.Pitch); int zshift = firstBit(ddpf.dwZBitMask); - float maxdepth = 1 << ddpf.dwZBufferBitDepth; + float maxdepth = float( 1 << ddpf.dwZBufferBitDepth); destRow += (subHeight-1)*subWidth; @@ -9554,7 +9554,7 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, b2 = *src++; b3 = *src++; b4 = *src++; - mask = (b4 << 24) | (b3 << 16) | + mask = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; *dst++ = (((mask & ddpf.dwZBitMask) >> zshift))/ maxdepth; @@ -9606,13 +9606,13 @@ void copyDepthFromSurface(jint xoffset, jint yoffset, } } else { // This is not support by D3D 8 either - printf("[Java 3D] %d bit Z buffer not support !\n", + printf("[Java 3D] %d bit Z buffer not support !\n", ddpf.dwZBufferBitDepth); } hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } } @@ -9624,14 +9624,14 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jint *data, - LPDIRECT3DSURFACE8 surf) + jint *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -9652,12 +9652,12 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } jint *src; - jint *srcRow = data + src_xoffset + + jint *srcRow = data + src_xoffset + (src_yoffset + subHeight-1)*src_width; unsigned char *dst; unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + @@ -9677,7 +9677,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { mask = *src++; if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9698,7 +9698,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { mask = *src++; if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9718,7 +9718,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { mask = *src++; if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9749,7 +9749,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } @@ -9762,14 +9762,14 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jfloat *data, - LPDIRECT3DSURFACE8 surf) + jfloat *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -9791,12 +9791,12 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } jfloat *src; - jfloat *srcRow = data + src_xoffset + + jfloat *srcRow = data + src_xoffset + (src_yoffset + subHeight-1)*src_width; unsigned char *dst; unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + @@ -9805,7 +9805,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, int zshift = firstBit(ddpf.dwZBitMask); DWORD mask; int maxValue = ddpf.dwZBitMask >> zshift; - float maxdepth = 1 << ddpf.dwZBufferBitDepth; + float maxdepth = float( 1 << ddpf.dwZBufferBitDepth); if ((ddpf.dwZBufferBitDepth <= 32) && (ddpf.dwZBufferBitDepth > 24)) { @@ -9814,9 +9814,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, src = srcRow; dst = destRow; for (int j=dst_xoffset; j < xlimit; j++) { - mask = (DWORD) (*src++)*maxdepth; + mask = DWORD((*src++)*maxdepth); if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9835,9 +9835,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, src = srcRow; dst = destRow; for (int j=dst_xoffset; j < xlimit; j++) { - mask = (DWORD) (*src++)*maxdepth; + mask = DWORD((*src++)*maxdepth); if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9855,9 +9855,9 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, src = srcRow; dst = destRow; for (int j=dst_xoffset; j < xlimit; j++) { - mask = (DWORD) (*src++)*maxdepth; + mask = DWORD((*src++)*maxdepth); if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9873,7 +9873,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, src = srcRow; dst = destRow; for (int j=dst_xoffset; j < xlimit; j++) { - mask = (DWORD) (*src++)*maxdepth; + mask = DWORD((*src++)*maxdepth); if (mask < maxValue) { *dst++ = (byte) ((mask << zshift) & 0xff); } else { @@ -9888,7 +9888,7 @@ void copyDepthToSurfaceAlways(jint dst_xoffset, jint dst_yoffset, hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } @@ -9900,14 +9900,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jint *data, - LPDIRECT3DSURFACE8 surf) + jint *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -9929,13 +9929,13 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } jint *src; - jint *srcRow = data + src_xoffset + + jint *srcRow = data + src_xoffset + (src_yoffset + subHeight-1)*src_width; unsigned char *dst; unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + @@ -9960,14 +9960,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, b2 = *dst++; b3 = *dst++; b4 = *dst++; - zmask = (b4 << 24) | (b3 << 16) | + zmask = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; mask = *src++; - if (mask < zmask) { + if (mask < zmask) { // z depth test pass if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -9976,7 +9976,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); *dst++ = (byte) ((mask >> 24) & 0xff); - } + } } srcRow -= src_width; destRow += lockedRect.Pitch; @@ -9991,16 +9991,16 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, b1 = *dst++; b2 = *dst++; b3 = *dst++; - zmask = (b3 << 16) | (b2 << 8) | b1; + zmask = (b3 << 16) | (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; mask = *src++; - if (mask < zmask) { + if (mask < zmask) { if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } - dst -= 3; + dst -= 3; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); @@ -10018,12 +10018,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { b1 = *dst++; b2 = *dst++; - zmask = (b2 << 8) | b1; + zmask = (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; mask = *src++; - if (mask < zmask) { + if (mask < zmask) { if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -10043,7 +10043,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { zmask = (*dst++ & ddpf.dwZBitMask) >> zshift; mask = *src++; - if (mask < zmask) { + if (mask < zmask) { dst--; if (mask < maxValue) { *dst++ = (byte) ((mask << zshift) & 0xff); @@ -10060,7 +10060,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } @@ -10073,14 +10073,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jfloat *data, - LPDIRECT3DSURFACE8 surf) + jfloat *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; DEPTHPIXELFORMAT ddpf; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; HRESULT hr; - + if (surf == NULL) { return; } @@ -10102,12 +10102,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, if (FAILED(hr)) { if (debug) { - printf("Fail to lock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock depth surface: %s\n", DXGetErrorString9(hr)); } return; } jfloat *src; - jfloat *srcRow = data + src_xoffset + + jfloat *srcRow = data + src_xoffset + (src_yoffset + subHeight-1)*src_width; unsigned char *dst; unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + @@ -10118,7 +10118,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, DWORD b1, b2, b3, b4; DWORD zmask; int maxValue = ddpf.dwZBitMask >> zshift; - float maxdepth = 1 << ddpf.dwZBufferBitDepth; + float maxdepth = float(1 << ddpf.dwZBufferBitDepth); if ((ddpf.dwZBufferBitDepth <= 32) && (ddpf.dwZBufferBitDepth > 24)) { @@ -10131,14 +10131,14 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, b2 = *dst++; b3 = *dst++; b4 = *dst++; - zmask = (b4 << 24) | (b3 << 16) | + zmask = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; - mask = (DWORD) (*src++)*maxdepth; - if (mask < zmask) { + mask = DWORD((*src++)*maxdepth); + if (mask < zmask) { // z depth test pass if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -10147,7 +10147,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); *dst++ = (byte) ((mask >> 24) & 0xff); - } + } } srcRow -= src_width; destRow += lockedRect.Pitch; @@ -10162,16 +10162,16 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, b1 = *dst++; b2 = *dst++; b3 = *dst++; - zmask = (b3 << 16) | (b2 << 8) | b1; + zmask = (b3 << 16) | (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; - mask = (DWORD) (*src++)*maxdepth; - if (mask < zmask) { + mask = DWORD((*src++)*maxdepth); + if (mask < zmask) { if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } - dst -= 3; + dst -= 3; *dst++ = (byte) (mask & 0xff); *dst++ = (byte) ((mask >> 8) & 0xff); *dst++ = (byte) ((mask >> 16) & 0xff); @@ -10189,12 +10189,12 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, for (int j=dst_xoffset; j < xlimit; j++) { b1 = *dst++; b2 = *dst++; - zmask = (b2 << 8) | b1; + zmask = (b2 << 8) | b1; zmask = (zmask & ddpf.dwZBitMask) >> zshift; - mask = (DWORD) (*src++)*maxdepth; - if (mask < zmask) { + mask = DWORD((*src++)*maxdepth); + if (mask < zmask) { if (mask < maxValue) { - mask = mask << zshift; + mask = mask << zshift; } else { mask = ddpf.dwZBitMask; } @@ -10213,8 +10213,8 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, dst = destRow; for (int j=dst_xoffset; j < xlimit; j++) { zmask = (*dst++ & ddpf.dwZBitMask) >> zshift; - mask = (DWORD) (*src++)*maxdepth; - if (mask < zmask) { + mask = DWORD((*src++)*maxdepth); + if (mask < zmask) { dst--; if (mask < maxValue) { *dst++ = (byte) ((mask << zshift) & 0xff); @@ -10231,7 +10231,7 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock depth surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock depth surface: %s\n", DXGetErrorString9(hr)); return; } @@ -10240,13 +10240,13 @@ void copyDepthToSurfaceCmp(jint dst_xoffset, jint dst_yoffset, // copy data to DirectDraw depth surface from memory // and reverse the Y axis void copyDepthToSurface(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jint *data, - LPDIRECT3DSURFACE8 surf) + jint *data, + LPDIRECT3DSURFACE9 surf) { if (!d3dCtx->zWriteEnable) { @@ -10260,7 +10260,7 @@ void copyDepthToSurface(D3dCtx *d3dCtx, src_width, src_height, data, surf); } else { - // Currently ZFUNC must be D3DCMP_LESS + // Currently ZFUNC must be D3DCMP_LESS copyDepthToSurfaceCmp(dst_xoffset, dst_yoffset, src_xoffset, src_yoffset, subWidth, subHeight, @@ -10273,13 +10273,13 @@ void copyDepthToSurface(D3dCtx *d3dCtx, // copy data to DirectDraw depth surface from memory // and reverse the Y axis void copyDepthToSurface(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, - jfloat *data, - LPDIRECT3DSURFACE8 surf) + jfloat *data, + LPDIRECT3DSURFACE9 surf) { if (!d3dCtx->zWriteEnable) { return; @@ -10292,7 +10292,7 @@ void copyDepthToSurface(D3dCtx *d3dCtx, src_width, src_height, data, surf); } else { - // Currently ZFUNC must be D3DCMP_LESS + // Currently ZFUNC must be D3DCMP_LESS copyDepthToSurfaceCmp(dst_xoffset, dst_yoffset, src_xoffset, src_yoffset, subWidth, subHeight, @@ -10305,12 +10305,12 @@ void copyDepthToSurface(D3dCtx *d3dCtx, void compositeDataToSurface(jint px, jint py, jint xoffset, jint yoffset, jint subWidth, jint subHeight, - jint dataWidth, - jbyte *data, - LPDIRECT3DSURFACE8 surf) + jint dataWidth, + jbyte *data, + LPDIRECT3DSURFACE9 surf) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; @@ -10334,7 +10334,7 @@ void compositeDataToSurface(jint px, jint py, hr = surf->LockRect(&lockedRect, NULL, 0); if (FAILED(hr)) { - printf("Fail to lock rendering surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock rendering surface: %s\n", DXGetErrorString9(hr)); return; } @@ -10344,8 +10344,8 @@ void compositeDataToSurface(jint px, jint py, DWORD srcPitch; int offset = (xoffset + yoffset*dataWidth) << 2; unsigned char *srcRow = (unsigned char *) data + offset; - unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + - ((px + xoffset) << 2) + (py + yoffset)*lockedRect.Pitch; + unsigned char *destRow = ((unsigned char *) lockedRect.pBits) + + ((px + xoffset) << 2) + (py + yoffset)*lockedRect.Pitch; unsigned char a2; float inv = 1.0f/255.0f; ddpf.noAlpha = true; @@ -10353,7 +10353,7 @@ void compositeDataToSurface(jint px, jint py, if (ddpf.dwRGBAlphaBitMask != 0) { ddpf.noAlpha = false; } - + srcPitch = dataWidth << 2; if ((ddpf.dwRGBBitCount == 32) && @@ -10378,13 +10378,13 @@ void compositeDataToSurface(jint px, jint py, *dst++ = 0xff; } else { a2 = 255-a; - *dst++ = (*dst * a2 + b * a)*inv; - *dst++ = (*dst * a2 + g * a)*inv; - *dst++ = (*dst * a2 + r * a)*inv; + *dst++ = (unsigned char)((*dst * a2 + b * a)*inv); + *dst++ = (unsigned char)((*dst * a2 + g * a)*inv); + *dst++ = (unsigned char)((*dst * a2 + r * a)*inv); if (ddpf.noAlpha) { *dst++ = a; } else { - *dst++ = (*dst * a2 + a * a)*inv; + *dst++ = (unsigned char)((*dst * a2 + a * a)*inv); } } } else { @@ -10392,22 +10392,22 @@ void compositeDataToSurface(jint px, jint py, } } srcRow += srcPitch; - destRow += lockedRect.Pitch; + destRow += lockedRect.Pitch; } } else { // handle less common (even weird) format int rshift = firstBit(ddpf.dwRBitMask) + - countBits(ddpf.dwRBitMask) - 8; - int gshift = firstBit(ddpf.dwGBitMask) + - countBits(ddpf.dwGBitMask) - 8; + ucountBits(ddpf.dwRBitMask) - 8; + int gshift = firstBit(ddpf.dwGBitMask) + + ucountBits(ddpf.dwGBitMask) - 8; int bshift = firstBit(ddpf.dwBBitMask) + - countBits(ddpf.dwBBitMask) - 8; + ucountBits(ddpf.dwBBitMask) - 8; int ashift = firstBit(ddpf.dwRGBAlphaBitMask) + - countBits(ddpf.dwRGBAlphaBitMask) - 8; + ucountBits(ddpf.dwRGBAlphaBitMask) - 8; DWORD mask, dmask; DWORD dr, dg, db, da; - if ((ddpf.dwRGBBitCount <= 32) && + if ((ddpf.dwRGBBitCount <= 32) && (ddpf.dwRGBBitCount > 24)) { for (int i=yoffset; i < ylimit; i++) { src = srcRow; @@ -10422,7 +10422,7 @@ void compositeDataToSurface(jint px, jint py, if (a != 0xff) { dmask = (*(dst+3) << 24) | (*(dst+2) << 16) | - (*(dst+1) << 8) | + (*(dst+1) << 8) | *dst; if (rshift >= 0) { dr = (byte) ((dmask & ddpf.dwRBitMask) >> @@ -10454,12 +10454,12 @@ void compositeDataToSurface(jint px, jint py, da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) << -ashift); } - a = (da * a2 + a * a)*inv; + a = DWORD((da * a2 + a * a)*inv); } - g = (dg * a2 + g * a)*inv; - b = (db * a2 + b * a)*inv; - r = (dr * a2 + r * a)*inv; + g = DWORD((dg * a2 + g * a)*inv); + b = DWORD((db * a2 + b * a)*inv); + r = DWORD((dr * a2 + r * a)*inv); } if (rshift >= 0) { mask = (r << rshift) & ddpf.dwRBitMask; @@ -10492,7 +10492,7 @@ void compositeDataToSurface(jint px, jint py, } } srcRow += srcPitch; - destRow += lockedRect.Pitch; + destRow += lockedRect.Pitch; } } else if ((ddpf.dwRGBBitCount <= 24) && (ddpf.dwRGBBitCount > 16)) { @@ -10539,11 +10539,11 @@ void compositeDataToSurface(jint px, jint py, da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) << -ashift); } - a = (da * a2 + a * a)*inv; + a = DWORD((da * a2 + a * a)*inv); } - g = (dg * a2 + g * a)*inv; - b = (db * a2 + b * a)*inv; - r = (dr * a2 + r * a)*inv; + g = DWORD((dg * a2 + g * a)*inv); + b = DWORD((db * a2 + b * a)*inv); + r = DWORD((dr * a2 + r * a)*inv); } if (rshift >= 0) { mask = (r << rshift) & ddpf.dwRBitMask; @@ -10575,7 +10575,7 @@ void compositeDataToSurface(jint px, jint py, } } srcRow += srcPitch; - destRow += lockedRect.Pitch; + destRow += lockedRect.Pitch; } } else if ((ddpf.dwRGBBitCount <= 16) && (ddpf.dwRGBBitCount > 8)) { @@ -10624,12 +10624,12 @@ void compositeDataToSurface(jint px, jint py, da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) << -ashift); } - a = (da * a2 + a * a)*inv; - } + a = DWORD( (da * a2 + a * a)*inv); + } - g = (dg * a2 + g * a)*inv; - b = (db * a2 + b * a)*inv; - r = (dr * a2 + r * a)*inv; + g = DWORD((dg * a2 + g * a)*inv); + b = DWORD((db * a2 + b * a)*inv); + r = DWORD((dr * a2 + r * a)*inv); } if (rshift >= 0) { @@ -10662,7 +10662,7 @@ void compositeDataToSurface(jint px, jint py, } } srcRow += srcPitch; - destRow += lockedRect.Pitch; + destRow += lockedRect.Pitch; } } else if (ddpf.dwRGBBitCount <= 8) { for (int i=yoffset; i < ylimit; i++) { @@ -10706,12 +10706,12 @@ void compositeDataToSurface(jint px, jint py, da = (byte) ((dmask & ddpf.dwRGBAlphaBitMask) << -ashift); } - a = (da * a2 + a * a)*inv; + a = DWORD((da * a2 + a * a)*inv); } - g = (dg * a2 + g * a)*inv; - b = (db * a2 + b * a)*inv; - r = (dr * a2 + r * a)*inv; + g = DWORD((dg * a2 + g * a)*inv); + b = DWORD((db * a2 + b * a)*inv); + r = DWORD((dr * a2 + r * a)*inv); } if (rshift >= 0) { mask = (r << rshift) & ddpf.dwRBitMask; @@ -10741,19 +10741,19 @@ void compositeDataToSurface(jint px, jint py, } } srcRow += srcPitch; - destRow += lockedRect.Pitch; + destRow += lockedRect.Pitch; } - } else { - // should not happen, RGBBitCount > 32. Even DirectX + } else { + // should not happen, RGBBitCount > 32. Even DirectX // RGB mask can't address it. - printf("Texture memory with RGBBitCount = %d not support. \n", + printf("Texture memory with RGBBitCount = %d not support. \n", ddpf.dwRGBBitCount); } } hr = surf->UnlockRect(); if (FAILED(hr)) { - printf("Fail to unlock rendering surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock rendering surface: %s\n", DXGetErrorString9(hr)); return; } } @@ -10767,13 +10767,13 @@ void copyDataToVolume(jint storedFormat, jint imgZOffset, jint subWidth, jint subHeight, jint subDepth, jint tilew, jint tileh, - jbyte* data, - LPDIRECT3DVOLUMETEXTURE8 surf, + jbyte* data, + LPDIRECT3DVOLUMETEXTURE9 surf, jint level) { D3DVOLUME_DESC ddsd; - D3DLOCKED_BOX lockedBox; + D3DLOCKED_BOX lockedBox; PIXELFORMAT ddpf; HRESULT hr; UINT i; @@ -10792,7 +10792,7 @@ void copyDataToVolume(jint storedFormat, // case the hardware memory buffer may smaller than the // texture pass in. - if ((xoffset >= width) || + if ((xoffset >= width) || (yoffset >= height) || (zoffset >= depth)) { return; @@ -10806,7 +10806,7 @@ void copyDataToVolume(jint storedFormat, if (FAILED(hr)) { - printf("Fail to lock volume: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock volume: %s\n", DXGetErrorString9(hr)); return; } @@ -10824,12 +10824,12 @@ void copyDataToVolume(jint storedFormat, srcSlicePitch <<= 2; for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceRGBA(internalFormat, &ddpf, + copyDataToSurfaceRGBA(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10841,12 +10841,12 @@ void copyDataToVolume(jint storedFormat, srcSlicePitch *= 3; for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceRGB(internalFormat, &ddpf, + copyDataToSurfaceRGB(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10857,12 +10857,12 @@ void copyDataToVolume(jint storedFormat, srcSlicePitch <<= 2; for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceABGR(internalFormat, &ddpf, + copyDataToSurfaceABGR(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10873,11 +10873,11 @@ void copyDataToVolume(jint storedFormat, srcSlicePitch *= 3; for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceBGR(internalFormat, &ddpf, + copyDataToSurfaceBGR(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, tilew); p += lockedBox.SlicePitch; @@ -10889,12 +10889,12 @@ void copyDataToVolume(jint storedFormat, srcSlicePitch <<= 1; for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceLA(internalFormat, &ddpf, + copyDataToSurfaceLA(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10908,8 +10908,8 @@ void copyDataToVolume(jint storedFormat, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10922,7 +10922,7 @@ void copyDataToVolume(jint storedFormat, hr = surf->UnlockBox(level); if (FAILED(hr)) { - printf("Fail to unlock volume: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock volume: %s\n", DXGetErrorString9(hr)); return; } } @@ -10936,12 +10936,12 @@ void copyDataToVolume(jint storedFormat, jint imgZOffset, jint subWidth, jint subHeight, jint subDepth, jint tilew, jint tileh, - jshort* data, - LPDIRECT3DVOLUMETEXTURE8 surf, + jshort* data, + LPDIRECT3DVOLUMETEXTURE9 surf, jint level) { D3DVOLUME_DESC ddsd; - D3DLOCKED_BOX lockedBox; + D3DLOCKED_BOX lockedBox; PIXELFORMAT ddpf; HRESULT hr; UINT i; @@ -10958,7 +10958,7 @@ void copyDataToVolume(jint storedFormat, computePixelFormat(&ddpf, ddsd.Format); - if ((xoffset >= width) || + if ((xoffset >= width) || (yoffset >= height) || (zoffset >= depth)) { return; @@ -10972,7 +10972,7 @@ void copyDataToVolume(jint storedFormat, hr = surf->LockBox(level, &lockedBox, NULL, 0); if (FAILED(hr)) { - printf("Fail to lock volume: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock volume: %s\n", DXGetErrorString9(hr)); return; } @@ -10984,12 +10984,12 @@ void copyDataToVolume(jint storedFormat, data += (imgOffset << 1); for (i = zoffset; i < zlimit; i++) { - copyDataToSurfaceGray(internalFormat, &ddpf, + copyDataToSurfaceGray(internalFormat, &ddpf, p, lockedBox.RowPitch, data, - xoffset, yoffset, - xlimit, ylimit, + xoffset, yoffset, + xlimit, ylimit, tilew); p += lockedBox.SlicePitch; data += srcSlicePitch; @@ -10997,13 +10997,13 @@ void copyDataToVolume(jint storedFormat, hr = surf->UnlockBox(level); if (FAILED(hr)) { - printf("Fail to unlock volume: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock volume: %s\n", DXGetErrorString9(hr)); return; } } -LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env, +LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env, jobject pa2d, jlong ctx, int width, @@ -11033,22 +11033,22 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env, internalFormat = LUMINANCE_ALPHA; break; case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: + case FORMAT_USHORT_GRAY: internalFormat = LUMINANCE; break; default: printf("Format %d not support for Image Component\n", internalFormat); return NULL; } - - LPDIRECT3DTEXTURE8 surf; - surf = createTextureSurface(d3dCtx, 1, internalFormat, + LPDIRECT3DTEXTURE9 surf; + + surf = createTextureSurface(d3dCtx, 1, internalFormat, width, height); if (surf == NULL) { - return NULL; + return NULL; } if (imageYdown != NULL) { @@ -11058,7 +11058,7 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env, copyDataToSurface(storedFormat, internalFormat, 0, 0, 0, 0, width, height, width, byteData, surf, 0); env->ReleasePrimitiveArrayCritical(imageYdown, byteData, 0); - + } else { jshort *shortData = (jshort *)(env->GetPrimitiveArrayCritical( imageYdown, NULL)); @@ -11070,23 +11070,24 @@ LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env, return surf; } -VOID createLineModeIndexBuffer(D3dCtx *d3dCtx) +VOID createLineModeIndexBuffer(D3dCtx *d3dCtx) { HRESULT hr; WORD *wptr; hr = d3dCtx->pDevice->CreateIndexBuffer(6*sizeof(WORD), D3DUSAGE_WRITEONLY, - D3DFMT_INDEX16, + D3DFMT_INDEX16, D3DPOOL_DEFAULT, - &d3dCtx->lineModeIndexBuffer); + &d3dCtx->lineModeIndexBuffer, + NULL); if (FAILED(hr)) { D3dCtx::d3dWarning(CREATEINDEXVBFAIL, hr); return; } - hr = d3dCtx->lineModeIndexBuffer->Lock(0, 0, (BYTE **) &wptr, 0); + hr = d3dCtx->lineModeIndexBuffer->Lock(0, 0, (VOID **) &wptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr); return; @@ -11101,12 +11102,12 @@ VOID createLineModeIndexBuffer(D3dCtx *d3dCtx) d3dCtx->lineModeIndexBuffer->Unlock(); } -// Return TRUE if index is adjust smaller -BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount) +// Return TRUE if index is adjust smaller +BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount) { - DWORD dwIndexCount = (vcount*3) >> 1; + DWORD dwIndexCount = (vcount*3) >> 1; WORD *q; - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; HRESULT hr; BOOL adjustIdx = FALSE; @@ -11119,31 +11120,33 @@ BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount) if (dwIndexCount > d3dCtx->quadIndexBufferSize) { d3dCtx->freeResource(d3dCtx->quadIndexBuffer); - hr = device->CreateIndexBuffer(dwIndexCount*sizeof(WORD), + hr = device->CreateIndexBuffer(dwIndexCount*sizeof(WORD), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, - &d3dCtx->quadIndexBuffer); + &d3dCtx->quadIndexBuffer, + NULL); if (FAILED(hr)) { + printf("[Java3D] Error CREATEINDEXVBFAIL \n"); D3dCtx::d3dWarning(CREATEINDEXVBFAIL, hr); - d3dCtx->quadIndexBufferSize = 0; + d3dCtx->quadIndexBufferSize = 0; d3dCtx->quadIndexBuffer = NULL; - if (d3dCtx->quadIndexBufferSize > 0) { + if (d3dCtx->quadIndexBufferSize > 0) { // indices has successfully set before, we prevent // setting this when indices did not set before. // It is becasue there is a bug in Nvidia driver which // will crash in this case. - device->SetIndices(NULL, 0); + device->SetIndices(NULL); } return adjustIdx; - } + } d3dCtx->quadIndexBufferSize = dwIndexCount; - hr = d3dCtx->quadIndexBuffer->Lock(0, 0, (BYTE **) &q, 0); + hr = d3dCtx->quadIndexBuffer->Lock(0, 0, (VOID **) &q, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr); - if (d3dCtx->quadIndexBufferSize > 0) { - device->SetIndices(NULL, 0); + if (d3dCtx->quadIndexBufferSize > 0) { + device->SetIndices(NULL); } return adjustIdx; } @@ -11153,10 +11156,10 @@ BOOL createQuadIndices(D3dCtx *d3dCtx, int vcount) while (j < dwIndexCount) { q[j++] = ++i; // q[0] = 0 q[j++] = i+1; // q[1] = 1 - q[j++] = i+2; // q[2] = 2 - q[j++] = i++; // q[3] = 0 - q[j++] = ++i; // q[4] = 2 - q[j++] = ++i; // q[5] = 3 + q[j++] = i+2; // q[2] = 2 + q[j++] = i++; // q[3] = 0 + q[j++] = ++i; // q[4] = 2 + q[j++] = ++i; // q[5] = 3 } d3dCtx->quadIndexBuffer->Unlock(); @@ -11189,27 +11192,27 @@ int getPrimitiveNum(int primitive, int vcount) /* - * Note that tThe condition width == height always holds + * Note that tThe condition width == height always holds * when this function is invoked. */ -LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx, +LPDIRECT3DCUBETEXTURE9 createCubeMapTexture(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, - jint width, + jint width, jint height) { - LPDIRECT3DCUBETEXTURE8 pTexture; + LPDIRECT3DCUBETEXTURE9 pTexture; D3DFORMAT format; HRESULT hr; - LPDIRECT3DDEVICE8 pDevice = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice; D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo; if (!deviceInfo->supportMipmap) { numLevels = 1; - } + } - getTexWidthHeight(deviceInfo, &width, &height); + getTexWidthHeight(deviceInfo, &width, &height); format = getTexFormat(internalFormat); // If format not support, the utility function will adjust the @@ -11221,30 +11224,30 @@ LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx, if (FAILED(hr)) { if (debug) { printf("Fail to create cube texture surface %dx%d, format %d, level %d : %s\n", - width, height, format, numLevels, DXGetErrorString8(hr)); + width, height, format, numLevels, DXGetErrorString9(hr)); } return NULL; } - + return pTexture; } -void copyDataToCubeMap(jint storedFormat, +void copyDataToCubeMap(jint storedFormat, jint internalFormat, jint xoffset, jint yoffset, jint imgXOffset, jint imgYOffset, jint subWidth, jint subHeight, - jint tilew, - jshort *data, LPDIRECT3DCUBETEXTURE8 surf, + jint tilew, + jshort *data, LPDIRECT3DCUBETEXTURE9 surf, jint level, jint face) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; - + if (surf == NULL) { return; } @@ -11260,11 +11263,11 @@ void copyDataToCubeMap(jint storedFormat, DWORD xlimit = min(xoffset + subWidth, width); DWORD ylimit = min(yoffset + subHeight, height); - hr = surf->LockRect(textureCubeMapFace[face], level, + hr = surf->LockRect(textureCubeMapFace[face], level, &lockedRect, NULL, 0); if (FAILED(hr)) { - printf("Fail to lock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock surface: %s\n", DXGetErrorString9(hr)); return; } @@ -11272,25 +11275,25 @@ void copyDataToCubeMap(jint storedFormat, if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - copyDataToSurfaceGray(internalFormat, &ddpf, + copyDataToSurfaceGray(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + - ((offset+tilew*(ylimit-yoffset)) << 1), - xoffset, yoffset, + data + + ((offset+tilew*(ylimit-yoffset)) << 1), + xoffset, yoffset, xlimit, ylimit, -tilew); } else { - copyDataToSurfaceGrayRev(internalFormat, &ddpf, + copyDataToSurfaceGrayRev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 1), - xoffset, yoffset, + data + (offset << 1), + xoffset, yoffset, xlimit, ylimit, tilew); } hr = surf->UnlockRect(textureCubeMapFace[face], level); if (FAILED(hr)) { - printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr)); return; } } @@ -11301,17 +11304,17 @@ void copyDataToCubeMap(jint storedFormat, jint xoffset, jint yoffset, jint imgXOffset, jint imgYOffset, jint subWidth, jint subHeight, - jint tilew, - jbyte* data, - LPDIRECT3DCUBETEXTURE8 surf, + jint tilew, + jbyte* data, + LPDIRECT3DCUBETEXTURE9 surf, jint level, jint face) { D3DSURFACE_DESC ddsd; - D3DLOCKED_RECT lockedRect; + D3DLOCKED_RECT lockedRect; PIXELFORMAT ddpf; HRESULT hr; - + if (surf == NULL) { return; } @@ -11337,7 +11340,7 @@ void copyDataToCubeMap(jint storedFormat, if (FAILED(hr)) { - printf("Fail to lock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to lock surface: %s\n", DXGetErrorString9(hr)); return; } int offset = tilew*imgYOffset + imgXOffset; @@ -11347,118 +11350,118 @@ void copyDataToCubeMap(jint storedFormat, // This is the one we use when byReference = false if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - // Copy the pixel from bottom to up and + // Copy the pixel from bottom to up and // left to right in this case to match OGL definition - copyDataToSurfaceRGBA(internalFormat, &ddpf, + copyDataToSurfaceRGBA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + + data + ((offset + tilew*(ylimit-yoffset-1)) << 2), - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, -tilew); } else { - // Copy the pixel from up to bottom and + // Copy the pixel from up to bottom and // right to left in this case to match OGL definition - copyDataToSurfaceRGBARev(internalFormat, &ddpf, + copyDataToSurfaceRGBARev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, data + (offset << 2), - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, tilew); } break; case FORMAT_BYTE_RGB: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - copyDataToSurfaceRGB(internalFormat, &ddpf, + copyDataToSurfaceRGB(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + + data + 3*(offset + tilew*(ylimit-yoffset-1)), - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, -tilew); } else { - copyDataToSurfaceRGBRev(internalFormat, &ddpf, + copyDataToSurfaceRGBRev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, data + 3*offset, - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, tilew); } break; case FORMAT_BYTE_ABGR: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - copyDataToSurfaceABGR(internalFormat, &ddpf, + copyDataToSurfaceABGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + - ((offset+tilew*(ylimit-yoffset-1)) << 2), - xoffset, yoffset, + data + + ((offset+tilew*(ylimit-yoffset-1)) << 2), + xoffset, yoffset, xlimit, ylimit, -tilew); } else { - copyDataToSurfaceABGRRev(internalFormat, &ddpf, + copyDataToSurfaceABGRRev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 2), - xoffset, yoffset, + data + (offset << 2), + xoffset, yoffset, xlimit, ylimit, tilew); } break; case FORMAT_BYTE_BGR: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - copyDataToSurfaceBGR(internalFormat, &ddpf, + copyDataToSurfaceBGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + + data + 3*(offset + tilew*(ylimit-yoffset-1)), - xoffset, yoffset, + xoffset, yoffset, xlimit, ylimit, -tilew); } else { - copyDataToSurfaceBGRRev(internalFormat, &ddpf, + copyDataToSurfaceBGRRev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + 3*offset, - xoffset, yoffset, + data + 3*offset, + xoffset, yoffset, xlimit, ylimit, tilew); } break; case FORMAT_BYTE_LA: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { - copyDataToSurfaceLA(internalFormat, &ddpf, + copyDataToSurfaceLA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + - ((offset+tilew*(ylimit-yoffset-1)) << 1), - xoffset, yoffset, - xlimit, ylimit, -tilew); + data + + ((offset+tilew*(ylimit-yoffset-1)) << 1), + xoffset, yoffset, + xlimit, ylimit, -tilew); } else { - copyDataToSurfaceLARev(internalFormat, &ddpf, + copyDataToSurfaceLARev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + (offset << 1), - xoffset, yoffset, + data + (offset << 1), + xoffset, yoffset, xlimit, ylimit, tilew); } break; case FORMAT_BYTE_GRAY: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || - (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { + (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceGray(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + - offset + tilew*(ylimit-yoffset-1), - xoffset, yoffset, + data + + offset + tilew*(ylimit-yoffset-1), + xoffset, yoffset, xlimit, ylimit, -tilew); } else { copyDataToSurfaceGrayRev(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, - data + offset, - xoffset, yoffset, + data + offset, + xoffset, yoffset, xlimit, ylimit, tilew); } break; @@ -11469,54 +11472,57 @@ void copyDataToCubeMap(jint storedFormat, hr = surf->UnlockRect(textureCubeMapFace[face], level); if (FAILED(hr)) { - printf("Fail to unlock surface: %s\n", DXGetErrorString8(hr)); + printf("Fail to unlock surface: %s\n", DXGetErrorString9(hr)); return; } } void drawTextureRect(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, - LPDIRECT3DTEXTURE8 surf, + LPDIRECT3DDEVICE9 device, + LPDIRECT3DTEXTURE9 surf, D3DTLVERTEX screenCoord, - int startx, int starty, + int startx, int starty, int endx, int endy, int scaleWidth, int scaleHeight, - boolean texModeRepeat) + boolean texModeRepeat) { - LPDIRECT3DTEXTURE8 texture = NULL; + LPDIRECT3DTEXTURE9 texture = NULL; DWORD transflag, minstate, magstate, texcoordstate; DWORD wrapU, wrapV; DWORD colorOp, colorArg, alphaOp, alphaArg; D3DMATRIX m; + magstate = 1; + minstate = 1; + int h = endy - starty; int w = endx - startx; device->SetRenderState(D3DRS_SPECULARENABLE, FALSE); - device->GetTexture(0, (LPDIRECT3DBASETEXTURE8 *) &texture); + device->GetTexture(0, (LPDIRECT3DBASETEXTURE9 *) &texture); device->GetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, &transflag); if (transflag != D3DTTFF_DISABLE) { device->GetTransform(D3DTS_TEXTURE0, &m); } - - device->GetTextureStageState(0, D3DTSS_MINFILTER, &minstate); - device->GetTextureStageState(0, D3DTSS_MAGFILTER, &magstate); + //alessandro + //device->GetTextureStageState(0, D3DTSS_MINFILTER, &minstate); + //device->GetTextureStageState(0, D3DTSS_MAGFILTER, &magstate); device->GetTextureStageState(0, D3DTSS_TEXCOORDINDEX, &texcoordstate); device->SetTexture(0, surf); device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); if ((w == scaleWidth) && (h == scaleHeight)) { - device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT); - device->SetTextureStageState(0, D3DTSS_MAGFILTER, - D3DTEXF_POINT); + // alessandro + // device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_POINT); + // device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_POINT); } else { - device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); - device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); + // device->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); + // device->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); @@ -11550,10 +11556,10 @@ void drawTextureRect(D3dCtx *d3dCtx, // no need to draw multiple time tumax = scaleWidth/(float) ddsd.Width; tvmax = scaleHeight/(float) ddsd.Height; - device->GetTextureStageState(0, D3DTSS_ADDRESSU, &wrapU); - device->GetTextureStageState(0, D3DTSS_ADDRESSV, &wrapV); - device->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); - device->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); + device->GetSamplerState (0, D3DSAMP_ADDRESSU, &wrapU); + device->GetSamplerState (0, D3DSAMP_ADDRESSV, &wrapV); + device->SetSamplerState (0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); + device->SetSamplerState (0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); multipleDraw = false; } else { tumax = endx/(float) ddsd.Width; @@ -11562,7 +11568,7 @@ void drawTextureRect(D3dCtx *d3dCtx, } } else { tumax = endx/(float) ddsd.Width; - tvmax = endy/(float) ddsd.Height; + tvmax = endy/(float) ddsd.Height; multipleDraw = false; } @@ -11571,11 +11577,11 @@ void drawTextureRect(D3dCtx *d3dCtx, d3dCtx->rasterRect[0].tv = tvmax; d3dCtx->rasterRect[1].tu = tumin; d3dCtx->rasterRect[1].tv = tvmin; - d3dCtx->rasterRect[2].tu = tumax; - d3dCtx->rasterRect[2].tv = tvmax; - d3dCtx->rasterRect[3].tu = tumax; + d3dCtx->rasterRect[2].tu = tumax; + d3dCtx->rasterRect[2].tv = tvmax; + d3dCtx->rasterRect[3].tu = tumax; d3dCtx->rasterRect[3].tv = tvmin; - + d3dCtx->rasterRect[0].sx = screenCoord.sx; d3dCtx->rasterRect[0].sz = screenCoord.sz; d3dCtx->rasterRect[0].rhw = screenCoord.rhw; @@ -11593,7 +11599,11 @@ void drawTextureRect(D3dCtx *d3dCtx, d3dCtx->rasterRect[3].rhw = screenCoord.rhw; if ((h > 0) && (w > 0)) { - device->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1); + //device->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1); + //device->SetVertexShader(vertexFormat); + device->SetVertexShader(NULL); + device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1); + if (!multipleDraw) { d3dCtx->rasterRect[0].sy = screenCoord.sy + scaleHeight; d3dCtx->rasterRect[2].sx = screenCoord.sx + scaleWidth; @@ -11601,7 +11611,7 @@ void drawTextureRect(D3dCtx *d3dCtx, d3dCtx->rasterRect[3].sx = screenCoord.sx + scaleWidth; device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, - d3dCtx->rasterRect, + d3dCtx->rasterRect, sizeof(D3DTLVERTEX)); } else { d3dCtx->rasterRect[0].sy = screenCoord.sy + h; @@ -11612,7 +11622,7 @@ void drawTextureRect(D3dCtx *d3dCtx, for (int j=0; j < ceil(scaleWidth/((double) w)); j++) { device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, - d3dCtx->rasterRect, + d3dCtx->rasterRect, sizeof(D3DTLVERTEX)); d3dCtx->rasterRect[0].sx += w; d3dCtx->rasterRect[1].sx += w; @@ -11648,8 +11658,8 @@ void drawTextureRect(D3dCtx *d3dCtx, if (d3dCtx->fillMode != D3DFILL_SOLID) { device->SetRenderState(D3DRS_FILLMODE, d3dCtx->fillMode); } - device->SetTextureStageState(0, D3DTSS_MINFILTER, minstate); - device->SetTextureStageState(0, D3DTSS_MAGFILTER, magstate); + //device->SetTextureStageState(0, D3DTSS_MINFILTER, minstate); + //device->SetTextureStageState(0, D3DTSS_MAGFILTER, magstate); device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, texcoordstate); device->SetTextureStageState(0, D3DTSS_COLOROP, colorOp); @@ -11658,9 +11668,23 @@ void drawTextureRect(D3dCtx *d3dCtx, device->SetTextureStageState(0, D3DTSS_ALPHAARG1, alphaArg); if (texModeRepeat && !multipleDraw) { - device->SetTextureStageState(0, D3DTSS_ADDRESSU, wrapU); - device->SetTextureStageState(0, D3DTSS_ADDRESSV, wrapV); + device->SetSamplerState (0, D3DSAMP_ADDRESSU, wrapU); + device->SetSamplerState (0, D3DSAMP_ADDRESSV, wrapV); } device->SetRenderState(D3DRS_CULLMODE, d3dCtx->cullMode); device->SetRenderState(D3DRS_SPECULARENABLE, TRUE); } + +DWORD ucountBits(DWORD mask) +{ + DWORD count = 0; + int i; + + for (i=sizeof(DWORD)*8-1; i >=0 ; i--) { + if ((mask & 0x01) > 0) { + count++; + } + mask >>= 1; + } + return count; +} diff --git a/src/native/d3d/D3dUtil.hpp b/src/native/d3d/D3dUtil.hpp index c91b26f..cb340d9 100644 --- a/src/native/d3d/D3dUtil.hpp +++ b/src/native/d3d/D3dUtil.hpp @@ -70,7 +70,7 @@ #define GetDevice() \ GetCtx() \ - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; \ + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; \ if (device == NULL) return; #define GetCtx2() \ @@ -80,7 +80,7 @@ #define GetDevice2() \ GetCtx2(); \ - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; \ + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; \ if (device == NULL) return 0; #define CopyColor(c, red, green, blue, alpha) \ @@ -118,6 +118,9 @@ extern vector<void *> freePointerList0; extern vector<void *> freePointerList1; extern BOOL useFreePointerList0; +//ISSUE 135 a iterator to void * +typedef vector<void *>::iterator ITER_VOID; + extern HANDLE hSema; // handle to semaphore extern BOOL firstError; extern BOOL debug; @@ -136,21 +139,21 @@ extern VOID lockGeometry(); extern VOID unlockGeometry(); extern VOID lockSurfaceList(); extern VOID unlockSurfaceList(); -extern VOID freeSurface(LPDIRECT3DBASETEXTURE8 surf); +extern VOID freeSurface(LPDIRECT3DBASETEXTURE9 surf); extern VOID freePointer(void* surf); extern VOID freePointerList(); extern VOID setWindowCallback(HWND topHwnd, HWND hwnd); extern char* getErrorMessage(int idx); extern HWND getTopWindow(HWND hwnd); -extern LPDIRECT3DTEXTURE8 createTextureSurface(D3dCtx *d3dCtx, +extern LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, jint width, jint height); -extern LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx, +extern LPDIRECT3DVOLUMETEXTURE9 createVolumeTexture(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, jint width, @@ -158,7 +161,7 @@ extern LPDIRECT3DVOLUMETEXTURE8 createVolumeTexture(D3dCtx *d3dCtx, jint depth); -extern LPDIRECT3DCUBETEXTURE8 createCubeMapTexture(D3dCtx *d3dCtx, +extern LPDIRECT3DCUBETEXTURE9 createCubeMapTexture(D3dCtx *d3dCtx, jint numLevels, jint internalFormat, jint width, @@ -170,7 +173,7 @@ extern void copyDataToSurface(jint format, jint xoffset, jint yoffset, jint imgXOffset, jint imgYOffset, jint width, jint height, jint tilew, - jshort *data, LPDIRECT3DTEXTURE8 surf, + jshort *data, LPDIRECT3DTEXTURE9 surf, jint level); extern void copyDataToSurface(jint format, @@ -179,7 +182,7 @@ extern void copyDataToSurface(jint format, jint imgXOffset, jint imgYOffset, jint width, jint height, jint tilew, jbyte* data, - LPDIRECT3DTEXTURE8 surf, + LPDIRECT3DTEXTURE9 surf, jint level); extern void copyDataToVolume(jint format, @@ -190,7 +193,7 @@ extern void copyDataToVolume(jint format, jint imgZOffset, jint width, jint height, jint depth, jint tilew, jint tileh, - jshort *data, LPDIRECT3DVOLUMETEXTURE8 surf, + jshort *data, LPDIRECT3DVOLUMETEXTURE9 surf, jint level); @@ -203,7 +206,7 @@ extern void copyDataToVolume(jint format, jint width, jint height, jint depth, jint tilew, jint tileh, jbyte* data, - LPDIRECT3DVOLUMETEXTURE8 surf, + LPDIRECT3DVOLUMETEXTURE9 surf, jint level); extern void copyDataToCubeMap(jint format, @@ -212,7 +215,7 @@ extern void copyDataToCubeMap(jint format, jint imgXOffset, jint imgYOffset, jint width, jint height, jint tilew, - jshort *data, LPDIRECT3DCUBETEXTURE8 surf, + jshort *data, LPDIRECT3DCUBETEXTURE9 surf, jint level, jint face); @@ -224,7 +227,7 @@ extern void copyDataToCubeMap(jint format, jint width, jint height, jint tilew, jbyte* data, - LPDIRECT3DCUBETEXTURE8 surf, + LPDIRECT3DCUBETEXTURE9 surf, jint level, jint face); @@ -232,50 +235,50 @@ extern void copyDataToCubeMap(jint format, extern void copyDepthFromSurface(jint xoffset, jint yoffset, jint subWidth, jint subHeight, jint *data, - LPDIRECT3DSURFACE8 surf); + LPDIRECT3DSURFACE9 surf); extern void copyDepthFromSurface(jint xoffset, jint yoffset, jint subWidth, jint subHeight, jfloat *data, - LPDIRECT3DSURFACE8 surf); + LPDIRECT3DSURFACE9 surf); extern void copyDepthToSurface(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, jint *data, - LPDIRECT3DSURFACE8 surf); + LPDIRECT3DSURFACE9 surf); extern void copyDepthToSurface(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jint dst_xoffset, jint dst_yoffset, jint src_xoffset, jint src_yoffset, jint subWidth, jint subHeight, jint src_width, jint src_height, jfloat *data, - LPDIRECT3DSURFACE8 surf); + LPDIRECT3DSURFACE9 surf); extern void copyDataFromSurface(jint internalFormat, jint xoffset, jint yoffset, jint width, jint height, - jbyte *data, LPDIRECT3DSURFACE8 surf); + jbyte *data, LPDIRECT3DSURFACE9 surf); void compositeDataToSurface(jint px, jint py, jint xoffset, jint yoffset, jint subWidth, jint subHeight, jint dataWidth, jbyte *data, - LPDIRECT3DSURFACE8 surf); + LPDIRECT3DSURFACE9 surf); // extern BOOL isIdentity(jdouble *matrix); -extern void CopyTextureStage(LPDIRECT3DDEVICE8 device, +extern void CopyTextureStage(LPDIRECT3DDEVICE9 device, int fromLevel, int toLevel); -extern LPDIRECT3DTEXTURE8 createSurfaceFromImage(JNIEnv *env, +extern LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env, jobject pa2d, jlong ctx, int width, @@ -292,19 +295,20 @@ extern char *getSwapEffectName(D3DSWAPEFFECT swapEffect); extern int getPrimitiveNum(int primitive, int vcount); extern int getMaxNumVertex(int primitive, int vcount); extern void drawTextureRect(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, - LPDIRECT3DTEXTURE8 tex, + LPDIRECT3DDEVICE9 device, + LPDIRECT3DTEXTURE9 tex, D3DTLVERTEX screenCoord, int startx, int starty, int endx, int endy, int scaleWidth, int scaleHeight, boolean texModeRepeat); extern int setTextureStage(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, int mapTexStage, jint texStage); extern void setTexTransformStageFlag(D3dCtx* d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, int tus, int ts, int genMode); +DWORD ucountBits(DWORD mask) ; #endif diff --git a/src/native/d3d/D3dVertexBuffer.cpp b/src/native/d3d/D3dVertexBuffer.cpp index a29cf09..45688ee 100644 --- a/src/native/d3d/D3dVertexBuffer.cpp +++ b/src/native/d3d/D3dVertexBuffer.cpp @@ -62,7 +62,7 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) if ((buffer != NULL) && (numVertices != NULL)) { // device is already check for NULL in callDisplayList - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; BOOL setAmbientLight = false; if (((vertexFormat & D3DFVF_DIFFUSE) == 0) && @@ -95,9 +95,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); if (d3dCtx->deviceInfo->maxPointSize < d3dCtx->pointSize) { // Use software vertex processing mode - device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, - TRUE); + //device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, TRUE); + device->SetSoftwareVertexProcessing(TRUE); } + oldPrimitiveType = primitiveType; // For Polygon D3DFill_POINT mode we need to // temporary switch primitive to point list @@ -106,9 +107,11 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) } } - device->SetStreamSource(0, buffer, stride); - device->SetVertexShader(vertexFormat); - + device->SetStreamSource(0, buffer,0, stride); + //device->SetVertexShader(vertexFormat); + device->SetVertexShader(NULL); + device->SetFVF(vertexFormat); + int startIdx=0; int vc, i; @@ -123,10 +126,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) } } else { if (indexBuffer != NULL) { - device->SetIndices(indexBuffer, 0); + device->SetIndices(indexBuffer); for (i = 0; i < stripLen; i++) { vc = numVertices[i]; - device->DrawIndexedPrimitive(primitiveType, + device->DrawIndexedPrimitive(primitiveType,0, 0, vcount, startIdx, @@ -136,9 +139,9 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) } else { if (d3dCtx->quadIndexBufferSize > 0) { // Index is successfully set - device->SetIndices(d3dCtx->quadIndexBuffer, 0); - device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, - 0, + device->SetIndices(d3dCtx->quadIndexBuffer); + device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0, + 0, numVertices[0], 0, numVertices[0] >> 1); @@ -156,8 +159,10 @@ VOID D3dVertexBuffer::render(D3dCtx *d3dCtx) if (renderPoint) { device->SetRenderState(D3DRS_CULLMODE, d3dCtx->cullMode); device->SetRenderState(D3DRS_FILLMODE, d3dCtx->fillMode); - device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, + /** device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, d3dCtx->softwareVertexProcessing); + **/ + device->SetSoftwareVertexProcessing(d3dCtx->softwareVertexProcessing); primitiveType = oldPrimitiveType; } else if (restorePointSize) { device->SetRenderState(D3DRS_POINTSIZE, diff --git a/src/native/d3d/D3dVertexBuffer.hpp b/src/native/d3d/D3dVertexBuffer.hpp index cef8f4a..4cb6b9e 100644 --- a/src/native/d3d/D3dVertexBuffer.hpp +++ b/src/native/d3d/D3dVertexBuffer.hpp @@ -22,15 +22,17 @@ class D3dVertexBuffer; typedef D3dVertexBuffer* LPD3DVERTEXBUFFER; typedef vector<LPD3DVERTEXBUFFER> D3dVertexBufferVector; +//ISSUE 135 iterator for D3dVertexBuffer +typedef vector<LPD3DVERTEXBUFFER>::iterator ITER_LPD3DVERTEXBUFFER; class D3dVertexBuffer { public: // Actual buffer memory to hold all the vertices - LPDIRECT3DVERTEXBUFFER8 buffer; + LPDIRECT3DVERTEXBUFFER9 buffer; // Indexed buffer for rendering IndexedGeometry - LPDIRECT3DINDEXBUFFER8 indexBuffer; + LPDIRECT3DINDEXBUFFER9 indexBuffer; // D3D type of this Vertex Buffer D3DPRIMITIVETYPE primitiveType; @@ -56,6 +58,11 @@ public: // compute from above vertexFormat UINT stride; + UINT numCoorTexSupported; + + + + // Number of strips used for StripGeometryArray // For each strip i the number of vertex is // numVertices[i] diff --git a/src/native/d3d/GeometryArrayRetained.cpp b/src/native/d3d/GeometryArrayRetained.cpp index 50c6507..681395c 100644 --- a/src/native/d3d/GeometryArrayRetained.cpp +++ b/src/native/d3d/GeometryArrayRetained.cpp @@ -22,6 +22,7 @@ /* * This correspond to the constant in d3dtypes.h * under D3D 7.0/8.0 header and may not portable : + * Still valid with D3D 9.0 (aces) * D3DFVF_TEXTUREFORMAT1 3 * D3DFVF_TEXTUREFORMAT2 0 * D3DFVF_TEXTUREFORMAT3 1 @@ -62,12 +63,12 @@ void copyIndexVertexToVB(D3dCtx *d3dCtx, if (cDirty & javax_media_j3d_GeometryArrayRetained_INDEX_CHANGED) { jint *src = strideData->indexPtr + strideData->initialIndexIndex; - LPDIRECT3DINDEXBUFFER8 indexBuffer = d3dCtx->pVB->indexBuffer; + LPDIRECT3DINDEXBUFFER9 indexBuffer = d3dCtx->pVB->indexBuffer; D3DINDEXBUFFER_DESC desc; BYTE *bptr; indexBuffer->GetDesc(&desc); - hr = indexBuffer->Lock(0, 0, &bptr, 0); + hr = indexBuffer->Lock(0, 0, (VOID**)&bptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr); return; @@ -359,7 +360,7 @@ void copyVertexToVB(D3dCtx *d3dCtx, // buildGA() & modeulateAlpha // Currently buildGA() will not use byte color // so this code should never execute. - jbyte alpha = (jbyte) 255*strideData->alpha; + jbyte alpha = (jbyte)(255*strideData->alpha); if (strideData->useAlpha) { srcStride = strideData->diffuseStride - 3; while (wdst < wendptr) { @@ -1066,7 +1067,7 @@ void copyOneVertexToVB(D3dCtx *d3dCtx, float* allocateVB(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, int vcount, int maxVertexLimit, jint *cdirty) @@ -1111,13 +1112,15 @@ float* allocateVB(D3dCtx *d3dCtx, D3DUSAGE_WRITEONLY, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } else { hr = device->CreateVertexBuffer(vb->stride*vcount, D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } if (FAILED(hr)) { vb->buffer = NULL; @@ -1129,7 +1132,7 @@ float* allocateVB(D3dCtx *d3dCtx, *cdirty = javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED; } - hr = vb->buffer->Lock(0, 0, (BYTE**) &ptr, 0); + hr = vb->buffer->Lock(0, 0,(VOID**) &ptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); @@ -1147,7 +1150,7 @@ float* allocateVB(D3dCtx *d3dCtx, BOOL createCopyVBVertex(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, int vcount, jint cDirty, jdouble* xform, @@ -1170,7 +1173,7 @@ BOOL createCopyVBVertex(D3dCtx *d3dCtx, } else { // use the same VB HRESULT hr; - hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0); + hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); @@ -1210,7 +1213,7 @@ void splitVertexToMultipleVB(D3dCtx *d3dCtx, float* oldTexCoords[D3DDP_MAXTEXCOORD]; int vc; int texSetUsed = d3dCtx->texSetUsed; - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; jfloat fr, fg, fb, fa; jbyte br, bg, bb, ba; boolean success; @@ -1508,7 +1511,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx, { LPD3DVERTEXBUFFER vb = d3dCtx->pVB; HRESULT hr; - LPDIRECT3DDEVICE8 device = d3dCtx->pDevice; + LPDIRECT3DDEVICE9 device = d3dCtx->pDevice; int vbSize; @@ -1558,13 +1561,15 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx, D3DUSAGE_WRITEONLY, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } else { hr = device->CreateVertexBuffer(vb->stride*vbSize, D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, vb->vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); vb->isPointFlagUsed = true; } @@ -1588,13 +1593,15 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, - &vb->indexBuffer); + &vb->indexBuffer, + NULL); } else { hr = device->CreateIndexBuffer(vbSize*sizeof(UINT), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, - &vb->indexBuffer); + &vb->indexBuffer, + NULL); } if (FAILED(hr)) { @@ -1610,7 +1617,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx, float *vbptr; // Note that DWORD (use for color) is of same size // as float (use for vertex/normal) - hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0); + hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); // recreate it next time @@ -1628,7 +1635,7 @@ BOOL reIndexifyIndexVertexToVBs(D3dCtx *d3dCtx, BYTE *bptr; vb->indexBuffer->GetDesc(&desc); - hr = vb->indexBuffer->Lock(0, 0, &bptr, 0); + hr = vb->indexBuffer->Lock(0, 0, (VOID**)&bptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKINDEXVBFAIL, hr); vb->buffer->Unlock(); @@ -1848,35 +1855,37 @@ void splitIndexVertexToMultipleVB(D3dCtx *d3dCtx, // This is used by quad polygon line mode void DrawPolygonLine(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, DWORD vertexFormat, D3DDRAWPRIMITIVESTRIDEDDATA *strideData) { HRESULT hr; float *vbptr; - hr = d3dCtx->pVB->buffer->Lock(0, 0, (BYTE**) &vbptr, 0 ); + hr = d3dCtx->pVB->buffer->Lock(0, 0, (VOID**) &vbptr, 0 ); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); return; } // DisplayList will not use in this case, so xform = nxform = NULL copyVertexToVB(d3dCtx, strideData, 4, &vbptr, - javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED, true, - NULL, NULL); + javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED, true, + NULL, NULL); d3dCtx->pVB->buffer->Unlock(); - device->SetStreamSource(0, d3dCtx->pVB->buffer, - d3dCtx->pVB->stride); - device->SetIndices(d3dCtx->lineModeIndexBuffer, 0); - device->SetVertexShader(vertexFormat); - - device->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 4, 0, 4); + device->SetStreamSource(0, d3dCtx->pVB->buffer, 0, + d3dCtx->pVB->stride); + device->SetIndices(d3dCtx->lineModeIndexBuffer); + //device->SetVertexShader(vertexFormat); + device->SetVertexShader(NULL); + device->SetFVF(vertexFormat); + + device->DrawIndexedPrimitive(D3DPT_LINESTRIP,0, 0, 4, 0, 4); } // This is used by indexed quad polygon line mode void DrawIndexPolygonLine(D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, DWORD vertexFormat, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, jint idx0, jint idx1, jint idx2, jint idx3) @@ -1884,7 +1893,7 @@ void DrawIndexPolygonLine(D3dCtx *d3dCtx, HRESULT hr; float *vbptr; - hr = d3dCtx->pVB->buffer->Lock(0, 0, (BYTE**) &vbptr, 0 ); + hr = d3dCtx->pVB->buffer->Lock(0, 0, (VOID**) &vbptr, 0 ); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); return; @@ -1904,18 +1913,21 @@ void DrawIndexPolygonLine(D3dCtx *d3dCtx, NULL, NULL); d3dCtx->pVB->buffer->Unlock(); - device->SetStreamSource(0, d3dCtx->pVB->buffer, - d3dCtx->pVB->stride); - device->SetVertexShader(vertexFormat); - device->SetIndices(d3dCtx->lineModeIndexBuffer, 0); + device->SetStreamSource(0, d3dCtx->pVB->buffer, 0, + d3dCtx->pVB->stride); + //device->SetVertexShader(vertexFormat); + device->SetVertexShader(NULL); + device->SetFVF(vertexFormat); + + device->SetIndices(d3dCtx->lineModeIndexBuffer); - device->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 4, 0, 4); + device->DrawIndexedPrimitive(D3DPT_LINESTRIP,0, 0, 4, 0, 4); } void renderGeometry(JNIEnv *env, D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jobject geo, jint geo_type, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, @@ -1998,9 +2010,9 @@ void renderGeometry(JNIEnv *env, } else { // Found the vb in the list of vbVector - for (LPD3DVERTEXBUFFER *s = vbVector->begin(); + for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin(); s != vbVector->end(); ++s) { - if ((*s)->ctx == d3dCtx) { + if ((*s)->ctx == d3dCtx) { vb = *s; break; } @@ -2061,13 +2073,15 @@ void renderGeometry(JNIEnv *env, D3DUSAGE_WRITEONLY, vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } else { hr = device->CreateVertexBuffer(vb->stride*vb->vcount, D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); vb->isPointFlagUsed = true; } @@ -2122,7 +2136,7 @@ void renderGeometry(JNIEnv *env, // Note that DWORD (use for color) is of same size // as float (use for vertex/normal) - hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0); + hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); // recreate it next time @@ -2573,7 +2587,7 @@ void renderGeometry(JNIEnv *env, void renderIndexGeometry(JNIEnv *env, D3dCtx *d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, jobject geo, jint geo_type, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, @@ -2638,8 +2652,8 @@ void renderIndexGeometry(JNIEnv *env, env->SetLongField(geo, fieldID, reinterpret_cast<long>(vbVector)); } else { // Found the vb in the list of vbVector - for (LPD3DVERTEXBUFFER *s = vbVector->begin(); - s != vbVector->end(); ++s) { + for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin(); + s != vbVector->end(); ++s) { if ((*s)->ctx == d3dCtx) { vb = *s; break; @@ -2704,13 +2718,15 @@ void renderIndexGeometry(JNIEnv *env, D3DUSAGE_WRITEONLY, vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); } else { hr = device->CreateVertexBuffer(vb->stride*vb->vcount, D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, vertexFormat, D3DPOOL_DEFAULT, - &vb->buffer); + &vb->buffer, + NULL); vb->isPointFlagUsed = true; } @@ -2745,13 +2761,15 @@ void renderIndexGeometry(JNIEnv *env, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, - &vb->indexBuffer); + &vb->indexBuffer, + NULL); } else { hr = device->CreateIndexBuffer(vb->indexCount*sizeof(UINT), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, - &vb->indexBuffer); + &vb->indexBuffer, + NULL); } if (FAILED(hr)) { @@ -2799,7 +2817,7 @@ void renderIndexGeometry(JNIEnv *env, // Note that DWORD (use for color) is of same size // as float (use for vertex/normal) - hr = vb->buffer->Lock(0, 0, (BYTE**)&vbptr, 0); + hr = vb->buffer->Lock(0, 0, (VOID**)&vbptr, 0); if (FAILED(hr)) { D3dCtx::d3dWarning(LOCKVBFAIL, hr); // recreate it next time @@ -2927,7 +2945,10 @@ void renderIndexGeometry(JNIEnv *env, renderTypeSet = true; expandQuadIndex = true; // fall through - } else { // polygon line mode + } + // start quad WireFrame + else { + // polygon line mode // we don't want to see extra line appear in the // diagonal of quads if it splits into two // triangles. This is REALLY SLOW !!! @@ -3037,6 +3058,9 @@ void renderIndexGeometry(JNIEnv *env, // Don't call vb->Renderer() at the end return; } + + //end Quad WireFrame + // fall through case GEO_TYPE_INDEXED_TRI_SET: if (renderTypeSet == false) { @@ -3151,7 +3175,7 @@ inline void setDefaultTextureCoordPointers(D3dCtx *d3dCtx, */ void setTextureCoordPointers(JNIEnv *env, D3dCtx* d3dCtx, - LPDIRECT3DDEVICE8 device, + LPDIRECT3DDEVICE9 device, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, jint pass, jint texoff, @@ -3647,9 +3671,9 @@ void executeGeometryArrayVA( /* execute geometry array with java array format */ extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( - JNIEnv *env, + JNIEnv *env, jobject obj, - jlong ctx, + jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, @@ -3666,6 +3690,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( jbyteArray cbdata, jint initialNormalIndex, jobject ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -3741,13 +3769,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( } } - executeGeometryArrayVA(env, obj, ctx, geo, geo_type, - isNonUniformScale, false, 0, - multiScreen, ignoreVertexColors, + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, + isNonUniformScale, false, 0, multiScreen, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, pass, texCoordMapLength, + norms, + pass, texCoordMapLength, tcoordsetmap,numActiveTexUnit, tunitstatemap, texindices,texStride,texCoordPointer, NULL, NULL, cdirty); @@ -3763,12 +3791,12 @@ extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( JNIEnv *env, jobject obj, - jlong ctx, + jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean multiScreen, - jboolean ignoreVertexColors, + jboolean ignoreVertexColors, jint vcount, jint vformat, jint vdefined, @@ -3780,7 +3808,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( jbyteArray cbdata, jint initialNormalIndex, jfloatArray ndata, - jint pass, // or texUnitIndex + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, + jint pass, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, @@ -3788,7 +3820,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( jintArray texindices, jint texStride, jobjectArray texCoords, - jint cDirty) + jint cdirty) { jfloat *fverts = NULL; @@ -3847,7 +3879,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( } } - executeGeometryArrayVA(env, obj, ctx, geo, geo_type, + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, false, 0, multiScreen, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, @@ -3856,7 +3888,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( norms, pass, texCoordMapLength, tcoordsetmap,numActiveTexUnit, tunitstatemap, texindices,texStride,texCoordPointer, - NULL, NULL, cDirty); + NULL, NULL, cdirty); if (floatCoordDefined) { env->ReleasePrimitiveArrayCritical( vfcoords, fverts, 0); @@ -3910,12 +3942,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha( extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( - JNIEnv *env, + JNIEnv *env, jobject obj, + jlong ctxInfo, jint vformat, jboolean useAlpha, - jboolean ignoreVertexColors, - jlong ctx) + jboolean ignoreVertexColors) { // not use in D3D } @@ -4100,17 +4132,24 @@ void executeGeometryArray(JNIEnv *env, } +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: buildGA + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[II[II[I[D[D[F)V + */ extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, - jobject obj, jlong ctx, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean updateAlpha, float alpha, + jobject obj, jlong ctx, jobject geo, + jint geo_type, + jboolean isNonUniformScale, jboolean updateAlpha, float alpha, jboolean ignoreVertexColors, jint startVIndex, - jint vcount, jint vformat, + jint vcount, jint vformat, jint texCoordSetCount, - jintArray texCoordSetMapArray, + jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, + jint vertexAttrCount, jintArray vertexAttrSizes, jdoubleArray xform, jdoubleArray nxform, jfloatArray varray) { @@ -4160,8 +4199,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, - jobject obj, jlong ctx, - jobject geo, jint geo_type, + jobject obj, jlong ctx,jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, jboolean multiScreen, jboolean ignoreVertexColors, @@ -4169,10 +4207,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, jint vcount, jint vformat, jint texCoordSetCount, jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray tunitstatemap, + jint numActiveTexUnit, + jintArray tunitstatemap, + jint vertexAttrCount, jintArray vertexAttrSizes, jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) + jint texUnitIndex, jint cDirty) { jfloat *verts = NULL; @@ -4260,13 +4299,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_freeD3DArray if (vbVector != NULL) { // clearLive() invoke this in Renderer thread - for (LPD3DVERTEXBUFFER *s = vbVector->begin(); + for (ITER_LPD3DVERTEXBUFFER s = vbVector->begin(); s != vbVector->end(); ++s) { // This notify vb that parent vector is already free // so there is no need to remove itself from vbVector (*s)->vbVector = NULL; (*s)->ctx->freeVB(*s); - } + } env->SetLongField(geo, fieldID, 0); vbVector->clear(); delete vbVector; @@ -4466,7 +4505,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jint initialIndexIndex, jint indexCount, jint vcount, - jint vformat, jint texCoordSetCount, + jint vformat, + jint vertexAttrCount, jintArray vertexAttrSizes, + jint texCoordSetCount, jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, @@ -4573,6 +4614,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome jint indexCount, jint vertexCount, jint vformat, + jint vertexAttrCount, + jintArray vertexAttrSizes, jint texCoordSetCount, jintArray texCoordSetMapArray, jint texCoordMapLength, @@ -4773,6 +4816,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jfloatArray cfdata, jbyteArray cbdata, jfloatArray ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -4917,6 +4963,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jfloatArray cfdata, jbyteArray cbdata, jobject ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -5124,6 +5173,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED); } +/* execute geometry array with java array format */ +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: buildGAForByRef + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[F[DI[F[BI[FI[I[I[[FI[I[II[Ljava/lang/Object;[D[D)V + */ extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( @@ -5147,7 +5202,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( jbyteArray cbdata, jint initialNormalIndex, jfloatArray ndata, - jint texCoordMapLength, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, + jint texCoordMapLength, jintArray tcoordsetmap, jintArray texindices, jint texStride, diff --git a/src/native/d3d/GraphicsContext3D.cpp b/src/native/d3d/GraphicsContext3D.cpp index e1fa7db..fc33970 100644 --- a/src/native/d3d/GraphicsContext3D.cpp +++ b/src/native/d3d/GraphicsContext3D.cpp @@ -49,9 +49,9 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( d3dCtx->createFrontBuffer())) { - HRESULT hr = device->GetFrontBuffer(d3dCtx->frontSurface); + HRESULT hr = device->GetFrontBufferData(0,d3dCtx->frontSurface);//iSwapChain as 0 if (FAILED(hr)) { - printf("GetFrontBuffer fail %s\n", DXGetErrorString8(hr)); + printf("GetFrontBuffer fail %s\n", DXGetErrorString9(hr)); return; } @@ -77,10 +77,10 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( } } else { if (d3dCtx->backSurface == NULL) { - HRESULT hr = device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, + HRESULT hr = device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO, //isSwapChain as 0 &d3dCtx->backSurface); if (FAILED(hr)) { - printf("GetBackBuffer fail %s\n", DXGetErrorString8(hr)); + printf("GetBackBuffer fail %s\n", DXGetErrorString9(hr)); return; } } @@ -114,7 +114,7 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( if (FAILED(hr)) { if (debug) { printf("[Java3D] Fail to get depth stencil surface %s\n", - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); } return; } diff --git a/src/native/d3d/Lights.cpp b/src/native/d3d/Lights.cpp index 322ccd1..9a790a8 100644 --- a/src/native/d3d/Lights.cpp +++ b/src/native/d3d/Lights.cpp @@ -27,7 +27,7 @@ void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight( jfloat diry, jfloat dirz) { - D3DLIGHT8 d3dLight; + D3DLIGHT9 d3dLight; GetDevice(); @@ -71,7 +71,7 @@ void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight( jfloat posy, jfloat posz) { - D3DLIGHT8 d3dLight; + D3DLIGHT9 d3dLight; GetDevice(); @@ -119,7 +119,7 @@ void JNICALL Java_javax_media_j3d_SpotLightRetained_updateLight( jfloat diry, jfloat dirz) { - D3DLIGHT8 d3dLight; + D3DLIGHT9 d3dLight; GetDevice(); diff --git a/src/native/d3d/NativeAPIInfo.c b/src/native/d3d/NativeAPIInfo.c index 8286a7b..ddca7af 100644 --- a/src/native/d3d/NativeAPIInfo.c +++ b/src/native/d3d/NativeAPIInfo.c @@ -13,11 +13,11 @@ #include <jni.h> #include "javax_media_j3d_MasterControl.h" - +#include "javax_media_j3d_NativeAPIInfo.h" JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI( JNIEnv *env, jobject obj) -{ +{ return (jint)javax_media_j3d_MasterControl_RENDER_DIRECT3D; } diff --git a/src/native/d3d/NativeConfigTemplate3D.cpp b/src/native/d3d/NativeConfigTemplate3D.cpp index d115c14..c18134b 100644 --- a/src/native/d3d/NativeConfigTemplate3D.cpp +++ b/src/native/d3d/NativeConfigTemplate3D.cpp @@ -131,3 +131,18 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( return retValue; } + + +/* + * Class: javax_media_j3d_NativeConfigTemplate3D + * Method: getStencilSize + * Signature: (JZ)I + * @TODO: FIX THIS !!!!! + */ +JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_getStencilSize + (JNIEnv *, jobject, jlong, jboolean) +{ + // dummy value + + return 8; +} diff --git a/src/native/d3d/RasterRetained.cpp b/src/native/d3d/RasterRetained.cpp index 7886868..a1606f3 100644 --- a/src/native/d3d/RasterRetained.cpp +++ b/src/native/d3d/RasterRetained.cpp @@ -102,7 +102,7 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, D3dImageComponent* d3dImage = D3dImageComponent::find(&RasterList, d3dCtx, hashCode); - LPDIRECT3DTEXTURE8 surf = NULL ; + LPDIRECT3DTEXTURE9 surf = NULL ; if ((d3dImage == NULL) || (d3dImage->surf == NULL)) { @@ -200,7 +200,7 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, if (FAILED(hr)) { if (debug) { printf("[Java3D] Fail to get depth stencil surface %s\n", - DXGetErrorString8(hr)); + DXGetErrorString9(hr)); } return; } @@ -213,8 +213,8 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, intData_array, NULL); copyDepthToSurface(d3dCtx, device, - screenCoord.sx, - screenCoord.sy, + (int)(screenCoord.sx), + (int)(screenCoord.sy), x_offset, y_offset, w, h,width, height, intData, d3dCtx->depthStencilSurface); @@ -230,8 +230,8 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, floatData_array, NULL); copyDepthToSurface(d3dCtx, device, - screenCoord.sx, - screenCoord.sy, + (jint)(screenCoord.sx), + (jint)(screenCoord.sy), x_offset, y_offset, w, h, width, height, floatData, d3dCtx->depthStencilSurface); diff --git a/src/native/d3d/StdAfx.h b/src/native/d3d/StdAfx.h index 020e69e..d653594 100644 --- a/src/native/d3d/StdAfx.h +++ b/src/native/d3d/StdAfx.h @@ -7,12 +7,20 @@ * * $Revision$ * $Date$ - * $State$ + * $State$_WIN32_WINNT */ #if !defined(AFX_STDAFX_H) #define AFX_STDAFX_H +#ifndef WINVER +#define WINVER 0x0501 +#endif + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -35,9 +43,9 @@ #include <jni.h> #include <math.h> #define D3D_OVERLOADS -#include <d3d8.h> -#include <dxerr8.h> -#include <d3dx8.h> +#include <d3d9.h> +#include <dxerr9.h> +#include <d3dx9.h> #include <vector> #include <algorithm> using namespace std ; @@ -52,3 +60,4 @@ using namespace std ; #include "D3dDisplayList.hpp" #include "D3dImageComponent.hpp" #endif + diff --git a/src/native/d3d/build-windows-i586-vc.xml b/src/native/d3d/build-windows-i586-vc.xml index 9f05f23..a73c4ca 100644 --- a/src/native/d3d/build-windows-i586-vc.xml +++ b/src/native/d3d/build-windows-i586-vc.xml @@ -36,12 +36,13 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="cl"> - <arg line="-I"${javaInclude}" -I"${javaWin32Include}" -I"${src}/native/ogl" -I"${javahCoreTarget}" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} -DD3D -DJ3D_BUILDVERTICES -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/MasterControl.c" "${d3dsrc}/D3dVertexBuffer.cpp" "${d3dsrc}/D3dDisplayList.cpp" "${d3dsrc}/D3dDriverInfo.cpp" "${d3dsrc}/D3dDeviceInfo.cpp" "${d3dsrc}/D3dCtx.cpp" "${d3dsrc}/D3dUtil.cpp" "${d3dsrc}/D3dImageComponent.cpp" "${d3dsrc}/GeometryArrayRetained.cpp" "${d3dsrc}/Canvas3D.cpp" "${d3dsrc}/GraphicsContext3D.cpp" "${d3dsrc}/CompressedGeometryRetained.cpp" "${d3dsrc}/Attributes.cpp" "${d3dsrc}/Lights.cpp" "${d3dsrc}/NativeConfigTemplate3D.cpp" "${d3dsrc}/NativeWSInfo.cpp" "${d3dsrc}/NativeAPIInfo.c" "${d3dsrc}/RasterRetained.cpp""/> + <arg line="-Ox -Og -O2 -Ob2 -Os -Oi -GT -GL /nologo -I"${javaInclude}" -I"${javaWin32Include}" -I"${src}/native/ogl" -I"${javahCoreTarget}" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "J3DDX90PORT_EXPORTS" /D "WIN32" /D "D3D" /D "J3D_BUILDVERTICES" /D "NVIDIA_DEBUG" /FD /EHsc /MT /Fp"J3dDX90Port.pch" /W2 /c /TP "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/MasterControl.c" "${d3dsrc}/D3dVertexBuffer.cpp" "${d3dsrc}/D3dDisplayList.cpp" "${d3dsrc}/D3dDriverInfo.cpp" "${d3dsrc}/D3dDeviceInfo.cpp" "${d3dsrc}/D3dCtx.cpp" "${d3dsrc}/D3dUtil.cpp" "${d3dsrc}/D3dImageComponent.cpp" "${d3dsrc}/GeometryArrayRetained.cpp" "${d3dsrc}/Canvas3D.cpp" "${d3dsrc}/GraphicsContext3D.cpp" "${d3dsrc}/Attributes.cpp" "${d3dsrc}/Lights.cpp" "${d3dsrc}/NativeConfigTemplate3D.cpp" "${d3dsrc}/NativeWSInfo.cpp" "${d3dsrc}/NativeAPIInfo.c" "${d3dsrc}/RasterRetained.cpp" "/> </exec> + <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="link"> - <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 /ignore:4089 -out:j3dcore-d3d.dll D3dVertexBuffer.obj D3dDisplayList.obj D3dDriverInfo.obj D3dDeviceInfo.obj D3dCtx.obj D3dUtil.obj D3dImageComponent.obj GeometryArrayRetained.obj Canvas3D.obj GraphicsContext3D.obj CompressedGeometryRetained.obj Attributes.obj Lights.obj NativeConfigTemplate3D.obj NativeWSInfo.obj NativeAPIInfo.obj RasterRetained.obj DrawingSurfaceObjectAWT.obj MasterControl.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ddraw.lib d3d8.lib d3dx8.lib dxerr8.lib dxguid.lib user32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + <arg line="/OUT:"j3dcore-d3d.dll" /nologo -DLL -DELAYLOAD:jawt.dll -IMPLIB:"j3dcore-d3d.lib" -MACHINE:X86 -LTCG /ignore:4089 ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib Attributes.obj Canvas3D.obj D3dCtx.obj D3dDeviceInfo.obj D3dDisplayList.obj D3dDriverInfo.obj D3dImageComponent.obj D3dUtil.obj D3dVertexBuffer.obj DrawingSurfaceObjectAWT.obj GeometryArrayRetained.obj GraphicsContext3D.obj Lights.obj MasterControl.obj NativeAPIInfo.obj NativeConfigTemplate3D.obj NativeWSInfo.obj RasterRetained.obj ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib -LIBPATH:"${java.home}\..\lib" jawt.lib"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/Attributes.c b/src/native/ogl/Attributes.c index efe4407..16a299e 100644 --- a/src/native/ogl/Attributes.c +++ b/src/native/ogl/Attributes.c @@ -554,8 +554,67 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetRenderingAttributes( glEnable(GL_DEPTH_TEST); } glAlphaFunc(GL_ALWAYS, 0.0f); + glDepthFunc(GL_LEQUAL); glEnable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_LOGIC_OP); + +} + +GLenum getFunctionValue(jint func) { + switch (func) { + case javax_media_j3d_RenderingAttributes_ALWAYS: + func = GL_ALWAYS; + break; + case javax_media_j3d_RenderingAttributes_NEVER: + func = GL_NEVER; + break; + case javax_media_j3d_RenderingAttributes_EQUAL: + func = GL_EQUAL; + break; + case javax_media_j3d_RenderingAttributes_NOT_EQUAL: + func = GL_NOTEQUAL; + break; + case javax_media_j3d_RenderingAttributes_LESS: + func = GL_LESS; + break; + case javax_media_j3d_RenderingAttributes_LESS_OR_EQUAL: + func = GL_LEQUAL; + break; + case javax_media_j3d_RenderingAttributes_GREATER: + func = GL_GREATER; + break; + case javax_media_j3d_RenderingAttributes_GREATER_OR_EQUAL: + func = GL_GEQUAL; + break; + } + + return func; +} + +GLenum getStencilOpValue(jint op) { + switch (op) { + case javax_media_j3d_RenderingAttributes_STENCIL_KEEP: + op = GL_KEEP; + break; + case javax_media_j3d_RenderingAttributes_STENCIL_ZERO: + op = GL_ZERO; + break; + case javax_media_j3d_RenderingAttributes_STENCIL_REPLACE: + op = GL_REPLACE; + break; + case javax_media_j3d_RenderingAttributes_STENCIL_INCR: + op = GL_INCR; + break; + case javax_media_j3d_RenderingAttributes_STENCIL_DECR: + op = GL_DECR; + break; + case javax_media_j3d_RenderingAttributes_STENCIL_INVERT: + op = GL_INVERT; + break; + } + + return op; + } JNIEXPORT @@ -567,16 +626,28 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( jboolean db_enable_override, jboolean db_enable, jboolean db_write_enable, + jint db_func, jfloat at_value, jint at_func, jboolean ignoreVertexColors, jboolean rasterOpEnable, - jint rasterOp) + jint rasterOp, + jboolean userStencilAvailable, + jboolean stencilEnable, + jint stencilFailOp, + jint stencilZFailOp, + jint stencilZPassOp, + jint stencilFunction, + jint stencilReferenceValue, + jint stencilCompareMask, + jint stencilWriteMask) { if (db_enable_override == JNI_FALSE) { if (db_enable == JNI_TRUE) { glEnable(GL_DEPTH_TEST); - } else { + glDepthFunc( getFunctionValue(db_func)); + + } else { glDisable(GL_DEPTH_TEST); } } @@ -593,6 +664,7 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( glDisable(GL_ALPHA_TEST); } else { glEnable(GL_ALPHA_TEST); + glAlphaFunc(getFunctionValue(at_func), at_value); } if (ignoreVertexColors == JNI_TRUE) { @@ -600,47 +672,81 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( } else { glEnable(GL_COLOR_MATERIAL); - } - - switch (at_func) { - case javax_media_j3d_RenderingAttributes_ALWAYS: - glAlphaFunc(GL_ALWAYS, at_value); - break; - case javax_media_j3d_RenderingAttributes_NEVER: - glAlphaFunc(GL_NEVER, at_value); - break; - case javax_media_j3d_RenderingAttributes_EQUAL: - glAlphaFunc(GL_EQUAL, at_value); - break; - case javax_media_j3d_RenderingAttributes_NOT_EQUAL: - glAlphaFunc(GL_NOTEQUAL, at_value); - break; - case javax_media_j3d_RenderingAttributes_LESS: - glAlphaFunc(GL_LESS, at_value); - break; - case javax_media_j3d_RenderingAttributes_LESS_OR_EQUAL: - glAlphaFunc(GL_LEQUAL, at_value); - break; - case javax_media_j3d_RenderingAttributes_GREATER: - glAlphaFunc(GL_GREATER, at_value); - break; - case javax_media_j3d_RenderingAttributes_GREATER_OR_EQUAL: - glAlphaFunc(GL_GEQUAL, at_value); - break; } - + if (rasterOpEnable == JNI_TRUE) { glEnable(GL_COLOR_LOGIC_OP); switch (rasterOp) { + case javax_media_j3d_RenderingAttributes_ROP_CLEAR: + glLogicOp(GL_CLEAR); + break; + case javax_media_j3d_RenderingAttributes_ROP_AND: + glLogicOp(GL_AND); + break; + case javax_media_j3d_RenderingAttributes_ROP_AND_REVERSE: + glLogicOp(GL_AND_REVERSE); + break; case javax_media_j3d_RenderingAttributes_ROP_COPY: glLogicOp(GL_COPY); break; + case javax_media_j3d_RenderingAttributes_ROP_AND_INVERTED: + glLogicOp(GL_AND_INVERTED); + break; + case javax_media_j3d_RenderingAttributes_ROP_NOOP: + glLogicOp(GL_NOOP); + break; case javax_media_j3d_RenderingAttributes_ROP_XOR: glLogicOp(GL_XOR); break; + case javax_media_j3d_RenderingAttributes_ROP_OR: + glLogicOp(GL_OR); + break; + case javax_media_j3d_RenderingAttributes_ROP_NOR: + glLogicOp(GL_NOR); + break; + case javax_media_j3d_RenderingAttributes_ROP_EQUIV: + glLogicOp(GL_EQUIV); + break; + case javax_media_j3d_RenderingAttributes_ROP_INVERT: + glLogicOp(GL_INVERT); + break; + case javax_media_j3d_RenderingAttributes_ROP_OR_REVERSE: + glLogicOp(GL_OR_REVERSE); + break; + case javax_media_j3d_RenderingAttributes_ROP_COPY_INVERTED: + glLogicOp(GL_COPY_INVERTED); + break; + case javax_media_j3d_RenderingAttributes_ROP_OR_INVERTED: + glLogicOp(GL_OR_INVERTED); + break; + case javax_media_j3d_RenderingAttributes_ROP_NAND: + glLogicOp(GL_NAND); + break; + case javax_media_j3d_RenderingAttributes_ROP_SET: + glLogicOp(GL_SET); + break; } - } else + } else { glDisable(GL_COLOR_LOGIC_OP); + } + + if (userStencilAvailable == JNI_TRUE) { + if (stencilEnable == JNI_TRUE) { + glEnable(GL_STENCIL_TEST); + + glStencilOp(getStencilOpValue(stencilFailOp), + getStencilOpValue(stencilZFailOp), + getStencilOpValue(stencilZPassOp)); + + glStencilFunc(getFunctionValue(stencilFunction), + stencilReferenceValue, stencilCompareMask); + + glStencilMask(stencilWriteMask); + + } else { + glDisable(GL_STENCIL_TEST); + } + } } JNIEXPORT @@ -741,7 +847,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( glLineWidth(1.0f); glDisable(GL_LINE_STIPPLE); - /* TODO: Polygon Mode check, blend enable */ + /* XXXX: Polygon Mode check, blend enable */ glDisable (GL_LINE_SMOOTH); } @@ -773,7 +879,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( glEnable(GL_LINE_STIPPLE); } - /* TODO: Polygon Mode check, blend enable */ + /* XXXX: Polygon Mode check, blend enable */ if (lineAntialiasing == JNI_TRUE) { glEnable (GL_LINE_SMOOTH); } else { @@ -789,7 +895,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPointAttributes( { glPointSize(1.0f); - /* TODO: Polygon Mode check, blend enable */ + /* XXXX: Polygon Mode check, blend enable */ glDisable (GL_POINT_SMOOTH); } @@ -803,7 +909,7 @@ void JNICALL Java_javax_media_j3d_PointAttributesRetained_updateNative( { glPointSize(pointSize); - /* TODO: Polygon Mode check, blend enable */ + /* XXXX: Polygon Mode check, blend enable */ if (pointAntialiasing == JNI_TRUE) { glEnable (GL_POINT_SMOOTH); } else { @@ -3409,18 +3515,6 @@ void JNICALL Java_javax_media_j3d_TextureUnitStateRetained_updateTextureUnitStat */ } -JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setDepthFunc( - JNIEnv * env, - jobject obj, - jlong ctxInfo, - jint func) -{ - if (func == javax_media_j3d_RenderingAttributesRetained_LESS) - glDepthFunc(GL_LESS); - else if (func == javax_media_j3d_RenderingAttributesRetained_LEQUAL) - glDepthFunc(GL_LEQUAL); -} JNIEXPORT void JNICALL Java_javax_media_j3d_Canvas3D_setBlendColor( @@ -3503,3 +3597,115 @@ void JNICALL Java_javax_media_j3d_Canvas3D_updateTexUnitStateMap( * texture unit state. */ } + + +/* + * strJavaToC + * + * Returns a copy of the specified Java String object as a new, + * null-terminated "C" string. The caller must free this string. + */ +char * +strJavaToC(JNIEnv *env, jstring str) +{ + JNIEnv table = *env; + jclass oom; + + const char *strUTFBytes; /* Array of UTF-8 bytes */ + char *cString = NULL; /* Null-terminated "C" string */ + + if (str == NULL) { + return NULL; + } + + strUTFBytes = table->GetStringUTFChars(env, str, NULL); + if (strUTFBytes == NULL) { + /* Just return, since GetStringUTFChars will throw OOM if it returns NULL */ + return NULL; + } + + cString = strdup(strUTFBytes); + table->ReleaseStringUTFChars(env, str, strUTFBytes); + if (cString == NULL) { + if ((oom = table->FindClass(env, "java/lang/OutOfMemoryError")) != NULL) { + table->ThrowNew(env, oom, "strdup"); + } + return NULL; + } + + return cString; +} + + +/* + * createShaderError + * + * Constructs a new ShaderError object from the given error code, + * error message, and detail message. + */ +jobject +createShaderError( + JNIEnv *env, + int errorCode, + const char *errorMsg, + const char *detailMsg) +{ + JNIEnv table = *env; + jclass shaderErrorClass; + jobject shaderError; + jmethodID methodID; + jstring errorMsgString = NULL; + jstring detailMsgString = NULL; + + if (errorMsg != NULL) { + if ((errorMsgString = table->NewStringUTF(env, errorMsg)) == NULL) { + return NULL; + } + } + + if (detailMsg != NULL) { + if ((detailMsgString = table->NewStringUTF(env, detailMsg)) == NULL) { + return NULL; + } + } + + shaderErrorClass = (*(table->FindClass))(env, "javax/media/j3d/ShaderError"); + if (shaderErrorClass == NULL) { + return NULL; + } + + methodID = table->GetMethodID(env, shaderErrorClass, + "<init>", + "(ILjava/lang/String;)V"); + if (methodID == NULL) { + return NULL; + } + + shaderError = table->NewObject(env, shaderErrorClass, methodID, + errorCode, errorMsgString); + if (shaderError == NULL) { + return NULL; + } + + methodID = table->GetMethodID(env, shaderErrorClass, + "setDetailMessage", + "(Ljava/lang/String;)V"); + if (methodID == NULL) { + return NULL; + } + + table->CallVoidMethod(env, shaderError, methodID, + detailMsgString); + + return shaderError; +} + + +void +throwAssert(JNIEnv *env, char *str) +{ + jclass rte; + if ((rte = (*env)->FindClass(env, "java/lang/AssertionError")) != NULL) { + (*env)->ThrowNew(env, rte, str); + } +} diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index 3a45b92..f653e84 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -16,7 +16,7 @@ * of the Java 3D API. */ -#if defined(__linux__) +#if defined(LINUX) #define _GNU_SOURCE 1 #endif @@ -28,7 +28,7 @@ #include "gldefs.h" -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #include <dlfcn.h> #endif @@ -38,6 +38,8 @@ #endif /* DEBUG */ +extern void throwAssert(JNIEnv *env, char *str); + static void initializeCtxInfo(JNIEnv *env, GraphicsContextPropertiesInfo* ctxInfo); static void cleanupCtxInfo(GraphicsContextPropertiesInfo* ctxInfo); static void disableAttribFor2D(GraphicsContextPropertiesInfo *ctxProperties); @@ -47,7 +49,7 @@ static void disableAttribFor2D(GraphicsContextPropertiesInfo *ctxProperties); * Method: getTextureColorTableSize * Signature: ()I */ -int getTextureColorTableSize( +extern int getTextureColorTableSize( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -55,6 +57,21 @@ int getTextureColorTableSize( int minorVersion); +extern void checkGLSLShaderExtensions( + JNIEnv *env, + jobject obj, + char *tmpExtensionStr, + GraphicsContextPropertiesInfo *ctxInfo, + jboolean glslLibraryAvailable); + +extern void checkCgShaderExtensions( + JNIEnv *env, + jobject obj, + char *tmpExtensionStr, + GraphicsContextPropertiesInfo *ctxInfo, + jboolean cgLibraryAvailable); + + #ifdef WIN32 extern void printErrorMessage(char *message); extern PIXELFORMATDESCRIPTOR getDummyPFD(); @@ -71,6 +88,7 @@ HWND createDummyWindow(const char* szAppName); void extractVersionInfo(char *versionStr, int* numbers){ char *majorNumStr; char *minorNumStr; + majorNumStr = strtok(versionStr, (char *)"."); minorNumStr = strtok(0, (char *)"."); if (majorNumStr != NULL) @@ -78,14 +96,14 @@ void extractVersionInfo(char *versionStr, int* numbers){ if (minorNumStr != NULL) numbers[1] = atoi(minorNumStr); - /* fprintf(stderr, "majorNumStr = %d, minNumStr = %d \n", numbers[0], numbers[1]); */ return; } /* * check if the extension is supported */ -int isExtensionSupported(const char *allExtensions, const char *extension) +int +isExtensionSupported(const char *allExtensions, const char *extension) { const char *start; const char *where, *terminator; @@ -114,18 +132,23 @@ int isExtensionSupported(const char *allExtensions, const char *extension) return 0; } -void checkTextureExtensions( + +static void +checkTextureExtensions( JNIEnv *env, jobject obj, char *tmpExtensionStr, int versionNumber, - GraphicsContextPropertiesInfo* ctxInfo) { - - if(isExtensionSupported(tmpExtensionStr, "GL_ARB_multitexture")) { - ctxInfo->arb_multitexture = JNI_TRUE ; + GraphicsContextPropertiesInfo* ctxInfo) +{ + if (isExtensionSupported(tmpExtensionStr, "GL_ARB_multitexture")) { + ctxInfo->arb_multitexture = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_MULTI_TEXTURE; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ctxInfo->textureUnitCount); - + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ctxInfo->maxTextureUnits); + ctxInfo->maxTexCoordSets = ctxInfo->maxTextureUnits; + if (isExtensionSupported(tmpExtensionStr, "GL_ARB_vertex_shader")) { + glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &ctxInfo->maxTexCoordSets); + } } if(isExtensionSupported(tmpExtensionStr,"GL_SGI_texture_color_table" )){ @@ -171,7 +194,7 @@ void checkTextureExtensions( if(isExtensionSupported(tmpExtensionStr,"GL_NV_register_combiners" )) { ctxInfo->textureRegisterCombinersAvailable = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_REGISTER_COMBINERS; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxInfo->glCombinerInputNV = (MYPFNGLCOMBINERINPUTNV) dlsym(RTLD_DEFAULT, "glCombinerInputNV"); ctxInfo->glFinalCombinerInputNV = @@ -282,7 +305,7 @@ void checkTextureExtensions( ctxInfo->linear_sharpen_rgb_enum = GL_LINEAR_SHARPEN_COLOR_SGIS; ctxInfo->linear_sharpen_alpha_enum = GL_LINEAR_SHARPEN_ALPHA_SGIS; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_SHARPEN; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxInfo->glSharpenTexFuncSGIS = (MYPFNGLSHARPENTEXFUNCSGI) dlsym(RTLD_DEFAULT, "glSharpenTexFuncSGIS"); #endif @@ -306,7 +329,7 @@ void checkTextureExtensions( ctxInfo->texture_detail_mode_enum = GL_DETAIL_TEXTURE_MODE_SGIS; ctxInfo->texture_detail_level_enum = GL_DETAIL_TEXTURE_LEVEL_SGIS; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_DETAIL; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxInfo->glDetailTexFuncSGIS = (MYPFNGLDETAILTEXFUNCSGI) dlsym(RTLD_DEFAULT, "glDetailTexFuncSGIS"); #endif @@ -325,7 +348,7 @@ void checkTextureExtensions( ctxInfo->textureFilter4Available = JNI_TRUE; ctxInfo->filter4_enum = GL_FILTER4_SGIS; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_FILTER4; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxInfo->glTexFilterFuncSGIS = (MYPFNGLTEXFILTERFUNCSGI) dlsym(RTLD_DEFAULT, "glTexFilterFuncSGIS"); #endif @@ -410,6 +433,38 @@ getJavaBoolEnv(JNIEnv *env, char* envStr) return (*(table->GetBooleanField))(env, obj, fieldID); } +/* + * Dummy functions for language-independent vertex attribute functions + */ +static void +dummyVertexAttrPointer( + GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer) +{ +#ifdef DEBUG + fprintf(stderr, "dummyVertexAttrPointer()\n"); +#endif /* DEBUG */ +} + +static void +dummyEnDisableVertexAttrArray( + GraphicsContextPropertiesInfo *ctxProperties, int index) +{ +#ifdef DEBUG + fprintf(stderr, "dummyEnDisableVertexAttrArray()\n"); +#endif /* DEBUG */ +} + +static void +dummyVertexAttr( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ +#ifdef DEBUG + fprintf(stderr, "dummyVertexAttr()\n"); +#endif /* DEBUG */ +} /* * get properties from current context @@ -421,9 +476,10 @@ getPropertiesFromCurrentContext( GraphicsContextPropertiesInfo *ctxInfo, jlong hdc, int pixelFormat, - int stencilSize, jlong fbConfigListPtr, - jboolean offScreen) + jboolean offScreen, + jboolean glslLibraryAvailable, + jboolean cgLibraryAvailable) { JNIEnv table = *env; @@ -436,10 +492,8 @@ getPropertiesFromCurrentContext( char *tmpExtensionStr; int versionNumbers[2]; char *cgHwStr = 0; - - + #ifdef WIN32 - PIXELFORMATDESCRIPTOR pfd; PixelFormatInfo *PixelFormatInfoPtr = (PixelFormatInfo *)fbConfigListPtr; #endif @@ -485,18 +539,24 @@ getPropertiesFromCurrentContext( /* *********************************************************/ /* setup the graphics context properties */ - /* check 1.2 core and above */ + /* NOTE : At some point we will want to require OpenGL 1.3 */ + /* Check for OpenGL 1.2 core or better */ if ((versionNumbers[0] > 1) || (versionNumbers[0] == 1 && versionNumbers[1] >= 2)) { - /* 1.2 core */ + if (versionNumbers[0] == 1 && versionNumbers[1] == 2) { + fprintf(stderr, + "Java 3D WARNING : OpenGL 1.3 will be required in the near future (GL_VERSION=%d.%d)\n", + versionNumbers[0], versionNumbers[1]); + } + ctxInfo->rescale_normal_ext = JNI_TRUE; ctxInfo->rescale_normal_ext_enum = GL_RESCALE_NORMAL; ctxInfo->bgr_ext = JNI_TRUE; ctxInfo->bgr_ext_enum = GL_BGR; ctxInfo->texture3DAvailable = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_3D; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexImage3D"); ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexSubImage3D"); #endif @@ -514,8 +574,9 @@ getPropertiesFromCurrentContext( if(isExtensionSupported(tmpExtensionStr, "GL_ARB_imaging")){ ctxInfo->blend_color_ext = JNI_TRUE; - ctxInfo->blendFunctionTable[7] = GL_CONSTANT_COLOR; -#if defined(SOLARIS) || defined(__linux__) + + ctxInfo->blendFunctionTable[BLEND_CONSTANT_COLOR] = GL_CONSTANT_COLOR; +#if defined(UNIX) ctxInfo->glBlendColor = (MYPFNGLBLENDCOLORPROC )dlsym(RTLD_DEFAULT, "glBlendColor"); #endif #ifdef WIN32 @@ -539,103 +600,24 @@ getPropertiesFromCurrentContext( ctxInfo->texture_max_level_enum = GL_TEXTURE_MAX_LEVEL; /* ... */ - - } else { /* check 1.1 extension */ - if(isExtensionSupported(tmpExtensionStr,"GL_EXT_rescale_normal")){ - ctxInfo->rescale_normal_ext = JNI_TRUE; - ctxInfo->rescale_normal_ext_enum = GL_RESCALE_NORMAL_EXT; - } - if(isExtensionSupported(tmpExtensionStr,"GL_BGR_EXT")) { - ctxInfo->bgr_ext = 1; - ctxInfo->bgr_ext_enum = GL_BGR_EXT; - } - - if(isExtensionSupported(tmpExtensionStr,"GL_EXT_texture3D" )){ - ctxInfo->texture3DAvailable = JNI_TRUE; - ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_3D; - ctxInfo->texture_3D_ext_enum = GL_TEXTURE_3D_EXT; - ctxInfo->texture_wrap_r_ext_enum = GL_TEXTURE_WRAP_R_EXT; -#if defined(SOLARIS) || defined(__linux__) - ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexImage3DEXT"); - ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexSubImage3DEXT"); - /* Fallback to non-EXT variants, needed for older - NVIDIA drivers which announce GL_EXT_texture3D but - don't have the EXT variants */ - if (ctxInfo->glTexImage3DEXT == NULL || - ctxInfo->glTexSubImage3DEXT == NULL) { - - ctxInfo->glTexImage3DEXT = - (MYPFNGLTEXIMAGE3DPROC) dlsym(RTLD_DEFAULT, "glTexImage3D"); - ctxInfo->glTexSubImage3DEXT = - (MYPFNGLTEXSUBIMAGE3DPROC) dlsym(RTLD_DEFAULT, "glTexSubImage3D"); - - if (ctxInfo->glTexImage3DEXT == NULL || - ctxInfo->glTexSubImage3DEXT == NULL) { - - ctxInfo->textureExtMask &= - ~javax_media_j3d_Canvas3D_TEXTURE_3D; - ctxInfo->texture3DAvailable = JNI_FALSE; - } - } - -#endif -#ifdef WIN32 - ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )wglGetProcAddress("glTexImage3DEXT"); - ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )wglGetProcAddress("glTexSubImage3DEXT"); - if ((ctxInfo->glTexImage3DEXT == NULL) || (ctxInfo->glTexSubImage3DEXT == NULL)) { - ctxInfo->textureExtMask &= ~javax_media_j3d_Canvas3D_TEXTURE_3D; - ctxInfo->texture3DAvailable = JNI_FALSE; - } -#endif - } - - - if(isExtensionSupported(tmpExtensionStr, "GL_EXT_texture_edge_clamp")) { - ctxInfo->texture_clamp_to_edge_enum = GL_CLAMP_TO_EDGE_EXT; - } else if(isExtensionSupported(tmpExtensionStr, "GL_SGIS_texture_edge_clamp")) { - ctxInfo->texture_clamp_to_edge_enum = GL_CLAMP_TO_EDGE_SGIS; - } else { - /* fallback to GL_CLAMP */ - ctxInfo->texture_clamp_to_edge_enum = GL_CLAMP; - } - - - if(isExtensionSupported(tmpExtensionStr, "GL_EXT_blend_color")){ - ctxInfo->blend_color_ext = JNI_TRUE; -#if defined(SOLARIS) || defined(__linux__) - ctxInfo->glBlendColor = (MYPFNGLBLENDCOLOREXTPROC )dlsym(RTLD_DEFAULT, "glBlendColorEXT"); -#endif -#ifdef WIN32 - ctxInfo->glBlendColor = (MYPFNGLBLENDCOLOREXTPROC )wglGetProcAddress("glBlendColorEXT"); - if (ctxInfo->glBlendColor == NULL) { - ctxInfo->blend_color_ext = JNI_FALSE; - } -#endif - ctxInfo->blendFunctionTable[7] = GL_CONSTANT_COLOR_EXT; - } - - if(isExtensionSupported(tmpExtensionStr,"GL_EXT_separate_specular_color" )){ - ctxInfo->seperate_specular_color = JNI_TRUE; - ctxInfo->light_model_color_control_enum = GL_LIGHT_MODEL_COLOR_CONTROL_EXT; - ctxInfo->single_color_enum = GL_SINGLE_COLOR_EXT; - ctxInfo->seperate_specular_color_enum = GL_SEPARATE_SPECULAR_COLOR_EXT ; - } + } + else { + jclass rte; - if (isExtensionSupported(tmpExtensionStr,"GL_SGIS_texture_lod")) { - ctxInfo->textureLodAvailable = JNI_TRUE; - ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_LOD_RANGE; - ctxInfo->texture_min_lod_enum = GL_TEXTURE_MIN_LOD_SGIS; - ctxInfo->texture_max_lod_enum = GL_TEXTURE_MAX_LOD_SGIS; - ctxInfo->texture_base_level_enum = GL_TEXTURE_BASE_LEVEL_SGIS; - ctxInfo->texture_max_level_enum = GL_TEXTURE_MAX_LEVEL_SGIS; + fprintf(stderr, + "Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=%d.%d)\n", + versionNumbers[0], versionNumbers[1]); + if ((rte = (*(table->FindClass))(env, "java/lang/IllegalStateException")) != NULL) { + (*(table->ThrowNew))(env, rte, "GL_VERSION"); } - - - /* ... */ + return JNI_FALSE; } + /* + * TODO: Remove extension checks for those features that are core + * in OpenGL 1.2 and just use the core feature. + */ - /* check extensions for remaining of 1.1 and 1.2 */ if(isExtensionSupported(tmpExtensionStr, "GL_EXT_multi_draw_arrays")){ ctxInfo->multi_draw_arrays_ext = JNI_TRUE; @@ -672,13 +654,7 @@ getPropertiesFromCurrentContext( ctxInfo->arb_transpose_matrix = JNI_TRUE; } -#ifdef OBSOLETE_HW_COMPRESSED_GEOM - if(isExtensionSupported(tmpExtensionStr, "GL_SUNX_geometry_compression")) { - ctxInfo->geometry_compression_sunx = JNI_TRUE ; - } -#endif /* OBSOLETE_HW_COMPRESSED_GEOM */ - -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* * setup ARB_multisample, under windows this is setup in * NativeConfigTemplate when pixel format is choose @@ -713,15 +689,17 @@ getPropertiesFromCurrentContext( * it by default if the surface is multisample capable. */ if (ctxInfo->arb_multisample && !ctxInfo->implicit_multisample) { - glDisable(MULTISAMPLE_ARB); + glDisable(GL_MULTISAMPLE_ARB); } - /* - * checking of the texture extensions is done in checkTextureExtensions(), - * so that the same function can be used for queryContext as well - */ + + /* Check texture extensions */ checkTextureExtensions(env, obj, tmpExtensionStr, versionNumbers[1], - ctxInfo); - + ctxInfo); + + /* Check shader extensions */ + checkGLSLShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, glslLibraryAvailable); + checkCgShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, cgLibraryAvailable); + /* ... */ /* *********************************************************/ @@ -766,33 +744,6 @@ getPropertiesFromCurrentContext( ctxInfo->extMask |= javax_media_j3d_Canvas3D_ARB_TRANSPOSE_MATRIX; } -#ifdef OBSOLETE_HW_COMPRESSED_GEOM - /* - * Check for compressed geometry extensions and see if hardware - * acceleration is supported in the runtime environment. - */ - if (ctxInfo->geometry_compression_sunx) { - cgHwStr = (char *)glGetString(GL_COMPRESSED_GEOM_ACCELERATED_SUNX) ; - } - - if (cgHwStr == 0 || strstr(cgHwStr, " ")) { - ctxInfo->geometry_compression_accelerated = 0 ; - - } else { - char *tmp = strdup(cgHwStr) ; - - ctxInfo->geometry_compression_accelerated_major_version = - atoi(strtok(tmp, ".")) ; - ctxInfo->geometry_compression_accelerated_minor_version = - atoi(strtok(0, ".")) ; - ctxInfo->geometry_compression_accelerated_subminor_version = - atoi(strtok(0, ".")) ; - - free(tmp) ; - ctxInfo->geometry_compression_accelerated = 1 ; - } -#endif /* OBSOLETE_HW_COMPRESSED_GEOM */ - /* Setup GL_EXT_separate_specular_color */ if(ctxInfo->seperate_specular_color) { ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_SEPARATE_SPECULAR_COLOR; @@ -893,13 +844,9 @@ getPropertiesFromCurrentContext( } } - - DescribePixelFormat((HDC) hdc, pixelFormat, sizeof(pfd), &pfd); - - stencilSize = pfd.cStencilBits; #endif -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) if(ctxInfo->multi_draw_arrays_ext) { ctxInfo->glMultiDrawArraysEXT = (MYPFNGLMULTIDRAWARRAYSEXTPROC)dlsym(RTLD_DEFAULT, "glMultiDrawArraysEXT"); @@ -977,14 +924,7 @@ getPropertiesFromCurrentContext( } } -#endif /* Solaris or Linux */ - - if (stencilSize > 1) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_STENCIL_BUFFER; - } - - - /* ... */ +#endif /* UNIX */ /* clearing up the memory */ free(tmpExtensionStr); @@ -1013,12 +953,20 @@ void setupCanvasProperties( (*(table->SetBooleanField))(env, obj, rsc_field, ctxInfo->arb_multitexture); if (ctxInfo->arb_multitexture) { - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "numTexUnitSupported", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->textureUnitCount); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "numTexCoordSupported", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->textureUnitCount); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTexCoordSets", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTexCoordSets); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxCombinedTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxCombinedTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexAttrs", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexAttrs); } - + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "extensionsSupported", "I"); (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->extMask); @@ -1067,6 +1015,13 @@ void setupCanvasProperties( rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "texture3DDepthMax", "I"); (*(table->SetIntField))(env, obj, rsc_field, param); + + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "shadingLanguageGLSL", "Z"); + (*(table->SetBooleanField))(env, obj, rsc_field, ctxInfo->shadingLanguageGLSL); + + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "shadingLanguageCg", "Z"); + (*(table->SetBooleanField))(env, obj, rsc_field, ctxInfo->shadingLanguageCg); + } JNIEXPORT @@ -1090,12 +1045,12 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyContext( wglDeleteContext((HGLRC)context); #endif /* WIN32 */ -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* glXMakeCurrent((Display *)display, None, NULL); */ glXDestroyContext((Display *)display, (GLXContext)context); -#endif /* SOLARIS */ +#endif /* UNIX */ /* cleanup CtxInfo and free its memory */ cleanupCtxInfo(s); @@ -1129,7 +1084,9 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( jlong fbConfigListPtr, jlong sharedCtxInfo, jboolean isSharedCtx, - jboolean offScreen) + jboolean offScreen, + jboolean glslLibraryAvailable, + jboolean cgLibraryAvailable) { jlong gctx; jlong sharedCtx; @@ -1142,7 +1099,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( GraphicsContextPropertiesInfo *sharedCtxStructure; int PixelFormatID=0; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* Fix for issue 20 */ @@ -1154,10 +1111,12 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( fbConfigList = (GLXFBConfig *)fbConfigListPtr; /* - fprintf(stderr, "Canvas3D_createNewContext: \n"); - fprintf(stderr, "fbConfigListPtr 0x%x\n", (int) fbConfigListPtr); - fprintf(stderr, "fbConfigList 0x%x, fbConfigList[0] 0x%x\n", - (int) fbConfigList, (int) fbConfigList[0]); + fprintf(stderr, "Canvas3D_createNewContext: \n"); + fprintf(stderr, " fbConfigListPtr 0x%x\n", (int) fbConfigListPtr); + fprintf(stderr, " fbConfigList 0x%x, fbConfigList[0] 0x%x\n", + (int) fbConfigList, (int) fbConfigList[0]); + fprintf(stderr, " glslLibraryAvailable = %d\n", glslLibraryAvailable); + fprintf(stderr, " cgLibraryAvailable = %d\n", cgLibraryAvailable); */ if(sharedCtxInfo == 0) @@ -1204,13 +1163,13 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( return 0; } - + /* Shouldn't this be moved to NativeConfig. ? */ glXGetFBConfigAttrib((Display *) display, fbConfigList[0], GLX_STENCIL_SIZE, &stencilSize); gctx = (jlong)ctx; -#endif /* SOLARIS */ +#endif /* UNIX */ #ifdef WIN32 HGLRC hrc; /* HW Rendering Context */ @@ -1245,7 +1204,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( * by wglChoosePixelFormat() or wglChoosePixelFormatARB. */ - if(!offScreen) { // Fix to issue 104 + if(!offScreen) { /* Fix to issue 104 */ if ((PixelFormatInfoPtr == NULL) || (PixelFormatInfoPtr->onScreenPFormat <= 0)) { printErrorMessage("Canvas3D_createNewContext: onScreen PixelFormat is invalid"); return 0; @@ -1266,11 +1225,11 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( SetPixelFormat(hdc, PixelFormatID, NULL); - // fprintf(stderr, "Before wglCreateContext\n"); + /* fprintf(stderr, "Before wglCreateContext\n"); */ hrc = wglCreateContext( hdc ); - // fprintf(stderr, "After wglCreateContext hrc = 0x%x\n", hrc); + /* fprintf(stderr, "After wglCreateContext hrc = 0x%x\n", hrc); */ if (!hrc) { err = GetLastError(); @@ -1286,9 +1245,9 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( wglShareLists( (HGLRC) sharedCtx, hrc ); } - // fprintf(stderr, "Before wglMakeCurrent\n"); + /* fprintf(stderr, "Before wglMakeCurrent\n"); */ result = wglMakeCurrent(hdc, hrc); - // fprintf(stderr, "After wglMakeCurrent result = %d\n", result); + /* fprintf(stderr, "After wglMakeCurrent result = %d\n", result); */ if (!result) { err = GetLastError(); @@ -1304,13 +1263,14 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( /* allocate the structure */ ctxInfo = (GraphicsContextPropertiesInfo *)malloc(sizeof(GraphicsContextPropertiesInfo)); - + /* initialize the structure */ initializeCtxInfo(env, ctxInfo); ctxInfo->context = gctx; - + if (!getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID, - stencilSize, fbConfigListPtr, offScreen)) { + fbConfigListPtr, offScreen, + glslLibraryAvailable, cgLibraryAvailable)) { return 0; } @@ -1358,7 +1318,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_useCtx( { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) glXMakeCurrent((Display *)display, (GLXDrawable)window, (GLXContext)ctx); #endif @@ -1409,7 +1369,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_composite( fprintf(stderr, "Canvas3D.composite()\n"); #endif /* Temporarily disable fragment and most 3D operations */ - /* TODO: the GL_TEXTURE_BIT may not be necessary here */ + /* XXXX: the GL_TEXTURE_BIT may not be necessary here */ glPushAttrib(GL_ENABLE_BIT|GL_TEXTURE_BIT|GL_DEPTH_BUFFER_BIT); disableAttribFor2D(ctxProperties); @@ -1708,7 +1668,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( pixels_obj, NULL); /* Temporarily disable fragment and most 3D operations */ - /* TODO: the GL_TEXTURE_BIT may not be necessary */ + /* XXXX: the GL_TEXTURE_BIT may not be necessary */ glPushAttrib(GL_ENABLE_BIT|GL_TEXTURE_BIT); disableAttribFor2D(ctxProperties); @@ -1743,7 +1703,8 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( break; case FORMAT_BYTE_GRAY: case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + default: + throwAssert(env, "illegal format"); break; } @@ -1988,9 +1949,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_textureclear(JNIEnv *env, case FORMAT_BYTE_LA: gltype = GL_LUMINANCE_ALPHA; break; + case FORMAT_BYTE_GRAY: case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + default: + throwAssert(env, "illegal format"); break; } @@ -2296,7 +2259,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( jint win) { -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) glXSwapBuffers((Display *)display, (Window)win); #endif @@ -2463,17 +2426,6 @@ void JNICALL Java_javax_media_j3d_Canvas3D_freeTexture( } - -JNIEXPORT jint JNICALL Java_javax_media_j3d_Canvas3D_getTextureUnitCount( - JNIEnv *env, - jobject obj, - jlong ctxInfo) -{ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - return ctxProperties->textureUnitCount; -} - /* * Method: getTextureColorTableSize */ @@ -2494,7 +2446,7 @@ int getTextureColorTableSize( ctxProperties->glGetColorTableParameteriv = (MYPFNGLGETCOLORTABLEPARAMETERIVPROC)wglGetProcAddress("glGetColorTableParameteriv"); #endif -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxProperties->glColorTable = (MYPFNGLCOLORTABLEPROC)dlsym(RTLD_DEFAULT, "glColorTable"); ctxProperties->glGetColorTableParameteriv = @@ -2507,7 +2459,7 @@ int getTextureColorTableSize( ctxProperties->glGetColorTableParameteriv = (MYPFNGLGETCOLORTABLEPARAMETERIVPROC)wglGetProcAddress("glGetColorTableParameterivSGI"); #endif -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) ctxProperties->glColorTable = (MYPFNGLCOLORTABLEPROC)dlsym(RTLD_DEFAULT, "glColorTableSGI"); ctxProperties->glGetColorTableParameteriv = @@ -2540,7 +2492,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_videoResize( jint win, jfloat dvrFactor) { -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; @@ -2560,7 +2512,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_videoResizeCompensation( jboolean enable) { -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; @@ -2591,7 +2543,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( jint height) { -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* Fix for issue 20 */ @@ -2699,7 +2651,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( } -#endif /* SOLARIS */ +#endif /* UNIX */ #ifdef WIN32 /* Fix for issue 76 */ @@ -2902,7 +2854,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( jfieldID offScreenBuffer_field; JNIEnv table = *env; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* Fix for Issue 20 */ GLXFBConfig *fbConfigList = (GLXFBConfig *)fbConfigListPtr; int val; @@ -2918,7 +2870,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( glXDestroyPixmap((Display *) display, (GLXPixmap)window); } -#endif /* SOLARIS */ +#endif /* UNIX */ #ifdef WIN32 /* Fix for issue 76 */ @@ -3023,9 +2975,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer( case FORMAT_BYTE_LA: type = GL_LUMINANCE_ALPHA; break; + case FORMAT_BYTE_GRAY: case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + default: + throwAssert(env, "illegal format"); break; } @@ -3057,15 +3011,16 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) /* 1.2 and GL_ARB_imaging */ ctxInfo->blend_color_ext = JNI_FALSE; - ctxInfo->color_table_ext = JNI_FALSE; - ctxInfo->blendFunctionTable[0] = GL_ZERO; - ctxInfo->blendFunctionTable[1] = GL_ONE; - ctxInfo->blendFunctionTable[2] = GL_SRC_ALPHA; - ctxInfo->blendFunctionTable[3] = GL_ONE_MINUS_SRC_ALPHA; - ctxInfo->blendFunctionTable[4] = GL_DST_COLOR; - ctxInfo->blendFunctionTable[5] = GL_SRC_COLOR; - ctxInfo->blendFunctionTable[6] = GL_ONE_MINUS_SRC_COLOR; - ctxInfo->blendFunctionTable[7] = GL_SRC_COLOR; + ctxInfo->color_table_ext = JNI_FALSE; + ctxInfo->blendFunctionTable[BLEND_ZERO] = GL_ZERO; + ctxInfo->blendFunctionTable[BLEND_ONE] = GL_ONE; + ctxInfo->blendFunctionTable[BLEND_SRC_ALPHA] = GL_SRC_ALPHA; + ctxInfo->blendFunctionTable[BLEND_ONE_MINUS_SRC_ALPHA] = GL_ONE_MINUS_SRC_ALPHA; + ctxInfo->blendFunctionTable[BLEND_DST_COLOR] = GL_DST_COLOR; + ctxInfo->blendFunctionTable[BLEND_ONE_MINUS_DST_COLOR] = GL_ONE_MINUS_DST_COLOR; + ctxInfo->blendFunctionTable[BLEND_SRC_COLOR] = GL_SRC_COLOR; + ctxInfo->blendFunctionTable[BLEND_ONE_MINUS_SRC_COLOR] = GL_ONE_MINUS_SRC_COLOR; + ctxInfo->blendFunctionTable[BLEND_CONSTANT_COLOR] = GL_CONSTANT_COLOR; /* 1.1 extensions or 1.2 extensions */ /* sun extensions */ @@ -3075,7 +3030,6 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->videoResizeAvailable = JNI_FALSE; ctxInfo->global_alpha_sun = JNI_FALSE; ctxInfo->constant_data_sun = JNI_FALSE; - ctxInfo->geometry_compression_sunx = JNI_FALSE; /* EXT extensions */ ctxInfo->abgr_ext = JNI_FALSE; @@ -3092,7 +3046,12 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->arb_multitexture = JNI_FALSE; ctxInfo->arb_multisample = JNI_FALSE; - ctxInfo->textureUnitCount = 1; + ctxInfo->maxTexCoordSets = 1; + ctxInfo->maxTextureUnits = 1; + ctxInfo->maxTextureImageUnits = 0; + ctxInfo->maxVertexTextureImageUnits = 0; + ctxInfo->maxCombinedTextureImageUnits = 0; + ctxInfo->textureEnvCombineAvailable = JNI_FALSE; ctxInfo->textureCombineDot3Available = JNI_FALSE; ctxInfo->textureCombineSubtractAvailable = JNI_FALSE; @@ -3111,15 +3070,13 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->textureLodAvailable = JNI_FALSE; ctxInfo->textureLodBiasAvailable = JNI_FALSE; - ctxInfo->geometry_compression_accelerated = JNI_FALSE; - ctxInfo->geometry_compression_accelerated_major_version = 0; - ctxInfo->geometry_compression_accelerated_minor_version = 0; - ctxInfo->geometry_compression_accelerated_subminor_version = 0; - /* extension mask */ ctxInfo->extMask = 0; ctxInfo->textureExtMask = 0; + ctxInfo->shadingLanguageGLSL = JNI_FALSE; + ctxInfo->shadingLanguageCg = JNI_FALSE; + ctxInfo->glBlendColor = NULL; ctxInfo->glBlendColorEXT = NULL; ctxInfo->glColorTable = NULL; @@ -3151,9 +3108,28 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->glDetailTexFuncSGIS = NULL; ctxInfo->glTexFilterFuncSGIS = NULL; -#if defined(SOLARIS) || defined(__linux__) + /* Initialize shader program Id */ + ctxInfo->shaderProgramId = 0; + + /* Initialize maximum number of vertex attrs */ + ctxInfo->maxVertexAttrs = 0; + + /* Initialize shader vertex attribute function pointers */ + ctxInfo->vertexAttrPointer = dummyVertexAttrPointer; + ctxInfo->enableVertexAttrArray = dummyEnDisableVertexAttrArray; + ctxInfo->disableVertexAttrArray = dummyEnDisableVertexAttrArray; + ctxInfo->vertexAttr1fv = dummyVertexAttr; + ctxInfo->vertexAttr2fv = dummyVertexAttr; + ctxInfo->vertexAttr3fv = dummyVertexAttr; + ctxInfo->vertexAttr4fv = dummyVertexAttr; + + /* Initialize shader info pointers */ + ctxInfo->glslCtxInfo = NULL; + ctxInfo->cgCtxInfo = NULL; + +#if defined(UNIX) ctxInfo->glXVideoResizeSUN = NULL; -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX */ } static void @@ -3242,7 +3218,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( jlong fbConfigListPtr, jboolean offScreen, jint width, - jint height) + jint height, + jboolean glslLibraryAvailable, + jboolean cgLibraryAvailable) { JNIEnv table = *env; jlong gctx; @@ -3251,7 +3229,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( int PixelFormatID=0; GraphicsContextPropertiesInfo* ctxInfo = (GraphicsContextPropertiesInfo *)malloc(sizeof(GraphicsContextPropertiesInfo)); -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* Fix for issue 20 */ @@ -3356,7 +3334,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( * by wglChoosePixelFormat() or wglChoosePixelFormatARB. */ - // Fix to issue 104 + /* Fix to issue 104 */ if(!offScreen) { if ((PixelFormatInfoPtr == NULL) || (PixelFormatInfoPtr->onScreenPFormat <= 0)) { printErrorMessage("Canvas3D_createNewContext: onScreen PixelFormat is invalid"); @@ -3431,7 +3409,8 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( /* get current context properties */ if (getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID, - stencilSize, fbConfigListPtr, offScreen)) { + fbConfigListPtr, offScreen, + glslLibraryAvailable, cgLibraryAvailable)) { /* put the properties to the Java side */ setupCanvasProperties(env, obj, ctxInfo); } @@ -3439,11 +3418,11 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( /* clear up the context , colormap and window if appropriate */ if(window == 0 && !offScreen){ -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) Java_javax_media_j3d_Canvas3D_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); XDestroyWindow((Display *)display, glWin); XFreeColormap((Display *)display, cmap); -#endif /* SOLARIS */ +#endif /* UNIX */ #ifdef WIN32 /* Release DC */ ReleaseDC(hDummyWnd, hdc); @@ -3495,10 +3474,10 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_Canvas3D_setFullSceneAntialiasing if (ctxProperties->arb_multisample && !ctxProperties->implicit_multisample) { if(enable == JNI_TRUE) { - glEnable(MULTISAMPLE_ARB); + glEnable(GL_MULTISAMPLE_ARB); } else { - glDisable(MULTISAMPLE_ARB); + glDisable(GL_MULTISAMPLE_ARB); } } @@ -3521,7 +3500,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_validGraphicsMode( return (devMode.dmBitsPerPel > 8); #endif -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) return JNI_TRUE; #endif } diff --git a/src/native/ogl/CgShaderProgram.c b/src/native/ogl/CgShaderProgram.c new file mode 100644 index 0000000..5e7654b --- /dev/null +++ b/src/native/ogl/CgShaderProgram.c @@ -0,0 +1,1815 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +#if defined(LINUX) +#define _GNU_SOURCE 1 +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <jni.h> + +#include "gldefs.h" +#include "CgWrapper.h" + +#if defined(UNIX) +#include <dlfcn.h> +#endif + + +extern char *strJavaToC(JNIEnv *env, jstring str); +extern void throwAssert(JNIEnv *env, char *str); +extern jobject createShaderError(JNIEnv *env, + int errorCode, + const char *errorMsg, + const char *detailMsg); + +static void cgVertexAttrPointer(GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer); +static void cgEnableVertexAttrArray(GraphicsContextPropertiesInfo *ctxProperties, + int index); +static void cgDisableVertexAttrArray(GraphicsContextPropertiesInfo *ctxProperties, + int index); +static void cgVertexAttr(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); + + +/* Global CG wrapper info struct, created by MasterControl during initialization */ +static CgWrapperInfo *globalCgWrapperInfo = NULL; + + +/* + * Class: javax_media_j3d_MasterControl + * Method: loadNativeCgLibrary + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL +Java_javax_media_j3d_MasterControl_loadNativeCgLibrary( + JNIEnv *env, + jclass clazz, + jobjectArray libpath) +{ + CgWrapperInfo *cgWrapperInfo; + int i, pathLen; + char *errName = NULL; + +#ifdef WIN32 + DWORD err; + LPTSTR errString; + UINT origErrorMode; +#endif /* WIN32 */ + + /* + * This method is called exactly once to load and initialize the + * CG wrapper library. + */ + + /* Assertion check that we don't get called more than once */ + if (globalCgWrapperInfo != NULL) { + throwAssert(env, "MasterControl.loadNativeCgLibrary called more than once"); + return JNI_FALSE; + } + + /* Allocate global Cg wrapper struct */ + cgWrapperInfo = (CgWrapperInfo*)malloc(sizeof(CgWrapperInfo)); + cgWrapperInfo->loaded = JNI_FALSE; + cgWrapperInfo->cgLibraryHandle = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* Remove the following print statement when the native Cg code is done */ + fprintf(stderr, "*** JAVA 3D : loading experimental native Cg library\n"); + + /* Get number of entries in libpath array */ + pathLen = (*env)->GetArrayLength(env, libpath); + /*fprintf(stderr, "pathLen = %d\n", pathLen);*/ + +#ifdef UNIX + + for (i = 0; i < pathLen; i++) { + jstring libname; + char *libnameStr; + + libname = (*env)->GetObjectArrayElement(env, libpath, i); + libnameStr = strJavaToC(env, libname); + /*fprintf(stderr, "dlopen(%s)\n", libnameStr);*/ + cgWrapperInfo->cgLibraryHandle = dlopen(libnameStr, RTLD_LAZY); + if ((cgWrapperInfo->cgLibraryHandle == NULL) && (i == pathLen-1)) { + errName = strdup(libnameStr); + } + free(libnameStr); + if (cgWrapperInfo->cgLibraryHandle != NULL) { + break; + } + } + + if (cgWrapperInfo->cgLibraryHandle == NULL) { + fprintf(stderr, "JAVA 3D ERROR : Unable to load library "); + perror(errName); + free(errName); + free(cgWrapperInfo); + return JNI_FALSE; + } + + /* Get pointer to library function to setup function pointers */ + cgWrapperInfo->j3dLoadCgFunctionPointers = + (PFNJ3DLOADCGFUNCTIONPOINTERS)dlsym(cgWrapperInfo->cgLibraryHandle, + "j3dLoadCgFunctionPointers"); + +#endif /* UNIX */ + +#ifdef WIN32 + + /* Load the library, suppressing any dialog boxes that may occur */ + origErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | + SEM_FAILCRITICALERRORS); + + for (i = 0; i < pathLen; i++) { + jstring libname; + char *libnameStr; + + libname = (*env)->GetObjectArrayElement(env, libpath, i); + libnameStr = strJavaToC(env, libname); + /*fprintf(stderr, "LoadLibrary(%s)\n", libnameStr);*/ + cgWrapperInfo->cgLibraryHandle = LoadLibrary(libnameStr); + if ((cgWrapperInfo->cgLibraryHandle == NULL) && (i == pathLen-1)) { + errName = strdup(libnameStr); + } + free(libnameStr); + if (cgWrapperInfo->cgLibraryHandle != NULL) { + break; + } + } + + SetErrorMode(origErrorMode); + + if (cgWrapperInfo->cgLibraryHandle == NULL) { + err = GetLastError(); + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, 0, (LPTSTR)&errString, 0, NULL); + + fprintf(stderr, + "JAVA 3D ERROR : Unable to load library %s: %s\n", + errName, errString); + free(errName); + return JNI_FALSE; + } + + cgWrapperInfo->j3dLoadCgFunctionPointers = + (PFNJ3DLOADCGFUNCTIONPOINTERS)GetProcAddress( + (HMODULE)cgWrapperInfo->cgLibraryHandle, + "j3dLoadCgFunctionPointers"); + + if (cgWrapperInfo->j3dLoadCgFunctionPointers == NULL) { + err = GetLastError(); + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, 0, (LPTSTR)&errString, 0, NULL); + + fprintf(stderr, + "JAVA 3D ERROR : Unable to find: j3dLoadCgFunctionPointers: %s\n", + errString); + return JNI_FALSE; + } + +#endif /* WIN32 */ + + if (cgWrapperInfo->j3dLoadCgFunctionPointers) { + cgWrapperInfo->j3dLoadCgFunctionPointers(cgWrapperInfo); + cgWrapperInfo->loaded = JNI_TRUE; + } + +#else /* COMPILE_CG_SHADERS */ + + fprintf(stderr, "Java 3D: CgShaderProgram code not compiled\n"); + +#endif /* COMPILE_CG_SHADERS */ + + /* Save pointer in global variable */ + globalCgWrapperInfo = cgWrapperInfo; + + return cgWrapperInfo->loaded; +} + + +#ifdef COMPILE_CG_SHADERS + +static char * +getErrorLog( + GraphicsContextPropertiesInfo* ctxProperties, + CGerror lastError) +{ + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + if (lastError != 0) { + const char *errString = cgWrapperInfo->cgGetErrorString(lastError); + const char *delimeter1 = "\n"; + const char *listing = cgWrapperInfo->cgGetLastListing(cgCtxInfo->cgCtx); + + char *errMsg = (char *) + malloc(strlen(errString) + strlen(delimeter1) + strlen(listing) + 1); + + if (errMsg == NULL) { + perror("malloc"); + return NULL; + } + + strcpy(errMsg, errString); + strcat(errMsg, delimeter1); + strcat(errMsg, listing); + + return errMsg; + } + + fprintf(stderr, "Assertion error: assert(lastError != 0) failed\n"); + return NULL; +} + + +static CgCtxInfo * +createCgShaderContext( + JNIEnv *env, + GraphicsContextPropertiesInfo *ctxInfo) +{ + jclass oom; + CGerror lastError; + CgCtxInfo *cgCtxInfo = NULL; + CgWrapperInfo *cgWrapperInfo; + + /* Assertion check that we don't get here unless the library is loaded */ + if (globalCgWrapperInfo == NULL) { + throwAssert(env, "createCgShaderContext: cgWrapperInfo is NULL"); + return NULL; + } + + if (!globalCgWrapperInfo->loaded) { + throwAssert(env, "createCgShaderContext: cgWrapper library not loaded"); + return NULL; + } + + cgCtxInfo = (CgCtxInfo*)malloc(sizeof(CgCtxInfo)); + if (cgCtxInfo == NULL) { + if ((oom = (*env)->FindClass(env, "java/lang/OutOfMemoryError")) != NULL) { + (*env)->ThrowNew(env, oom, "malloc"); + } + return NULL; + } + + /* Point to the global CG wrapper info */ + cgWrapperInfo = cgCtxInfo->cgWrapperInfo = globalCgWrapperInfo; + + /* Create CG context */ + cgCtxInfo->cgCtx = cgWrapperInfo->cgCreateContext(); + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + fprintf(stderr, "Fatal error in creating Cg context:\n"); + fprintf(stderr, "\t%s\n", cgWrapperInfo->cgGetErrorString(lastError)); + free(cgCtxInfo); + return NULL; + } + + if (cgCtxInfo->cgCtx == 0) { + fprintf(stderr, "Invalid NULL Cg context\n"); + free(cgCtxInfo); + return NULL; + } + + /* Use GL_ARB_vertex_program extension if supported by video card */ + if (cgWrapperInfo->cgGLIsProfileSupported(CG_PROFILE_ARBVP1)) { + fprintf(stderr, "Using CG_PROFILE_ARBVP1\n"); + cgCtxInfo->vProfile = CG_PROFILE_ARBVP1; + } + else if (cgWrapperInfo->cgGLIsProfileSupported(CG_PROFILE_VP20)) { + fprintf(stderr, "Using CG_PROFILE_VP20\n"); + cgCtxInfo->vProfile = CG_PROFILE_VP20; + } + else { + fprintf(stderr, + "ERROR: Vertex programming extensions (GL_ARB_vertex_program or\n" + "GL_NV_vertex_program) not supported, exiting...\n"); + free(cgCtxInfo); + return NULL; + } + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + fprintf(stderr, "FATAL ERROR IN CREATING VERTEX SHADER PROFILE:\n"); + fprintf(stderr, "\t%s\n", cgWrapperInfo->cgGetErrorString(lastError)); + free(cgCtxInfo); + return NULL; + } + + /* Use GL_ARB_fragment_program extension if supported by video card */ + if (cgWrapperInfo->cgGLIsProfileSupported(CG_PROFILE_ARBFP1)) { + fprintf(stderr, "Using CG_PROFILE_ARBFP1\n"); + cgCtxInfo->fProfile = CG_PROFILE_ARBFP1; + } + else if (cgWrapperInfo->cgGLIsProfileSupported(CG_PROFILE_FP20)) { + fprintf(stderr, "Using CG_PROFILE_FP20\n"); + cgCtxInfo->fProfile = CG_PROFILE_FP20; + } + else { + fprintf(stderr, + "Fragment programming extensions (GL_ARB_fragment_program or\n" + "GL_NV_fragment_program) not supported, exiting...\n"); + free(cgCtxInfo); + return NULL; + } + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + fprintf(stderr, "FATAL ERROR IN CREATING FRAGMENT SHADER PROFILE:\n"); + fprintf(stderr, "\t%s\n", cgWrapperInfo->cgGetErrorString(lastError)); + free(cgCtxInfo); + return NULL; + } + + /* + fprintf(stderr, "createCgShaderContext: SUCCESS\n"); + fprintf(stderr, " cgCtx = 0x%x\n", cgCtxInfo->cgCtx); + fprintf(stderr, " vProfile = 0x%x\n", cgCtxInfo->vProfile); + fprintf(stderr, " fProfile = 0x%x\n", cgCtxInfo->fProfile); + */ + + return cgCtxInfo; +} + +#endif /* COMPILE_CG_SHADERS */ + + +/* + * Called by getPropertiesFromCurrentContext to initialize the Cg + * shader function pointers and set the flag indicating whether Cg + * shaders are available. + */ +void +checkCgShaderExtensions( + JNIEnv *env, + jobject obj, + char *tmpExtensionStr, + GraphicsContextPropertiesInfo *ctxInfo, + jboolean cgLibraryAvailable) +{ + ctxInfo->shadingLanguageCg = JNI_FALSE; + ctxInfo->cgCtxInfo = NULL; + +#ifdef COMPILE_CG_SHADERS + if (cgLibraryAvailable) { + /* TODO: need to free ctxInfo->cgCtxInfo when ctxInfo is freed */ + ctxInfo->cgCtxInfo = createCgShaderContext(env, ctxInfo); + if (ctxInfo->cgCtxInfo != NULL) { + CgWrapperInfo *cgWrapperInfo = ctxInfo->cgCtxInfo->cgWrapperInfo; + + /* + fprintf(stderr, "Cg ctx is available\n"); + */ + ctxInfo->shadingLanguageCg = JNI_TRUE; + + /* TODO: Query Cg texture sampler limits */ + ctxInfo->maxTextureImageUnits = ctxInfo->maxTextureUnits; + ctxInfo->maxVertexTextureImageUnits = 0; + ctxInfo->maxCombinedTextureImageUnits = ctxInfo->maxTextureUnits; + + /* TODO: Query max vertex attrs */ + ctxInfo->maxVertexAttrs = 2; + + /* Initialize shader vertex attribute function pointers */ + ctxInfo->vertexAttrPointer = cgVertexAttrPointer; + ctxInfo->enableVertexAttrArray = cgEnableVertexAttrArray; + ctxInfo->disableVertexAttrArray = cgDisableVertexAttrArray; + ctxInfo->vertexAttr1fv = cgVertexAttr; + ctxInfo->vertexAttr2fv = cgVertexAttr; + ctxInfo->vertexAttr3fv = cgVertexAttr; + ctxInfo->vertexAttr4fv = cgVertexAttr; + } + /* + else { + fprintf(stderr, "ERROR: Cg ctx *not* available\n"); + } + */ + } +#endif /* COMPILE_CG_SHADERS */ + +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: createNativeShader + * Signature: (JI[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_createNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jint shaderType, + jlongArray shaderIdArray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + + jlong *shaderIdPtr; + CGprogram shaderId = 0; + jclass oom; + CgShaderInfo *cgShaderInfo; + + fprintf(stderr, "CgShaderProgramRetained.createNativeShader\n"); + + cgShaderInfo = (CgShaderInfo*)malloc(sizeof(CgShaderInfo)); + if (cgShaderInfo == NULL) { + if ((oom = (*env)->FindClass(env, "java/lang/OutOfMemoryError")) != NULL) { + (*env)->ThrowNew(env, oom, "malloc"); + } + return NULL; + } + cgShaderInfo->cgShader = 0; + cgShaderInfo->shaderType = shaderType; + if (shaderType == javax_media_j3d_Shader_SHADER_TYPE_VERTEX) { + cgShaderInfo->shaderProfile = cgCtxInfo->vProfile; + } + else if (shaderType == javax_media_j3d_Shader_SHADER_TYPE_FRAGMENT) { + cgShaderInfo->shaderProfile = cgCtxInfo->fProfile; + } + else { + cgShaderInfo->shaderProfile = 0; + fprintf(stderr, "shaderType = %d\n", shaderType); + throwAssert(env, "unrecognized shaderType"); + return NULL; + } + + shaderIdPtr = (*env)->GetLongArrayElements(env, shaderIdArray, NULL); + shaderIdPtr[0] = (jlong) cgShaderInfo; + (*env)->ReleaseLongArrayElements(env, shaderIdArray, shaderIdPtr, 0); + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: destroyNativeShader + * Signature: (JJ)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderId) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + CgShaderInfo *cgShaderInfo = (CgShaderInfo *)shaderId; + + fprintf(stderr, "CgShaderProgramRetained.destroyNativeShader\n"); + + if (cgShaderInfo != NULL) { + if (cgShaderInfo->cgShader != 0) { + cgWrapperInfo->cgDestroyProgram(cgShaderInfo->cgShader); + } + + free(cgShaderInfo); + } + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: compileNativeShader + * Signature: (JJLjava/lang/String;)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_compileNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderId, + jstring program) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + CgShaderInfo *cgShaderInfo = (CgShaderInfo *)shaderId; + CGerror lastError; + GLcharARB *shaderString = NULL; + + fprintf(stderr, "CgShaderProgramRetained.compileNativeShader\n"); + + /* Assertion check the cgShaderInfo pointer */ + if (cgShaderInfo == NULL) { + throwAssert(env, "cgShaderInfo is NULL"); + return NULL; + } + + /* Assertion check the program string */ + if (program == NULL) { + throwAssert(env, "shader program string is NULL"); + return NULL; + } + + shaderString = strJavaToC(env, program); + if (shaderString == NULL) { + /* Just return, since strJavaToC will throw OOM if it returns NULL */ + return NULL; + } + + /* create the shader */ + if (cgShaderInfo->shaderType == javax_media_j3d_Shader_SHADER_TYPE_VERTEX) { + fprintf(stderr, "Create vertex shader\n"); + } + else if (cgShaderInfo->shaderType == javax_media_j3d_Shader_SHADER_TYPE_FRAGMENT) { + fprintf(stderr, "Create fragment shader\n"); + } + fprintf(stderr, "cgCtx = 0x%x\n", cgCtxInfo->cgCtx); + fprintf(stderr, "shaderProfile = 0x%x\n", cgShaderInfo->shaderProfile); + cgShaderInfo->cgShader = cgWrapperInfo->cgCreateProgram(cgCtxInfo->cgCtx, + CG_SOURCE, shaderString, + cgShaderInfo->shaderProfile, NULL, NULL); + fprintf(stderr, " cgShader = 0x%x\n", cgShaderInfo->cgShader); + + free(shaderString); + +#ifdef OUT__XXX__OUT + cgShaderInfo->cgShader = 0; + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_COMPILE_ERROR, + "Cg shader compile error", + "NOT YET IMPLEMENTED..."); +#endif /* OUT__XXX__OUT */ + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + char *detailMsg = getErrorLog(ctxProperties, lastError); + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_COMPILE_ERROR, + "Cg shader compile error", + detailMsg); + if (detailMsg != NULL) { + free(detailMsg); + } + } + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: createNativeShaderProgram + * Signature: (J[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_createNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlongArray shaderProgramIdArray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + jlong *shaderProgramIdPtr; + + CgShaderProgramInfo *shaderProgramInfo = + (CgShaderProgramInfo*)malloc(sizeof(CgShaderProgramInfo)); + + fprintf(stderr, "CgShaderProgramRetained.createNativeShaderProgram\n"); + + shaderProgramInfo->vShader = NULL; + shaderProgramInfo->fShader = NULL; + shaderProgramInfo->numVtxAttrs = 0; + shaderProgramInfo->vtxAttrs = NULL; + + shaderProgramIdPtr = (*env)->GetLongArrayElements(env, shaderProgramIdArray, NULL); + shaderProgramIdPtr[0] = (jlong)shaderProgramInfo; + (*env)->ReleaseLongArrayElements(env, shaderProgramIdArray, shaderProgramIdPtr, 0); + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: destroyNativeShaderProgram + * Signature: (JJ)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + + fprintf(stderr, "CgShaderProgramRetained.destroyNativeShaderProgram\n"); + + if (shaderProgramInfo != NULL) { + if (shaderProgramInfo->vtxAttrs != NULL) { + free(shaderProgramInfo->vtxAttrs); + shaderProgramInfo->vtxAttrs = NULL; + } + free(shaderProgramInfo); + } + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: linkNativeShaderProgram + * Signature: (JJ[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_linkNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlongArray shaderIdArray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + jsize shaderIdArrayLength = (*env)->GetArrayLength(env, shaderIdArray); + jlong *shaderIdPtr = (*env)->GetLongArrayElements(env, shaderIdArray, NULL); + CGerror lastError; + + int i; + + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + + fprintf(stderr, "CgShaderProgramRetained.linkNativeShaderProgram\n"); + + /* + * NOTE: we assume that the caller has already verified that there + * is at most one vertex program and one fragment program + */ + shaderProgramInfo->vShader = NULL; + shaderProgramInfo->fShader = NULL; + for (i = 0; i < shaderIdArrayLength; i++) { + CgShaderInfo *shader = (CgShaderInfo*)shaderIdPtr[i]; + if (shader->shaderType == javax_media_j3d_Shader_SHADER_TYPE_VERTEX) { + shaderProgramInfo->vShader = shader; + } else { + shaderProgramInfo->fShader = shader; + } + + cgWrapperInfo->cgGLLoadProgram(shader->cgShader); + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + char *detailMsg = getErrorLog(ctxProperties, lastError); + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_LINK_ERROR, + "Cg shader link/load error", + detailMsg); + if (detailMsg != NULL) { + free(detailMsg); + } + } + + cgWrapperInfo->cgGLBindProgram(shader->cgShader); + + if ((lastError = cgWrapperInfo->cgGetError()) != 0) { + char *detailMsg = getErrorLog(ctxProperties, lastError); + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_LINK_ERROR, + "Cg shader link/bind error", + detailMsg); + if (detailMsg != NULL) { + free(detailMsg); + } + } + } + + (*env)->ReleaseLongArrayElements(env, shaderIdArray, shaderIdPtr, JNI_ABORT); + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: lookupNativeVertexAttrNames + * Signature: (JJI[Ljava/lang/String;[Z)V + */ +JNIEXPORT void JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeVertexAttrNames( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jint numAttrNames, + jobjectArray attrNames, + jbooleanArray errArr) +{ +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + + int i; + jstring attrName; + char *attrNameString; + jboolean *errPtr; + + errPtr = (*env)->GetBooleanArrayElements(env, errArr, NULL); + + if (shaderProgramInfo->vShader == NULL) { + /* If there if no vertex shader, no attributes can be looked up, so all fail */ + for (i = 0; i < numAttrNames; i++) { + errPtr[i] = JNI_TRUE; + } + (*env)->ReleaseBooleanArrayElements(env, errArr, errPtr, 0); + return; + } + + shaderProgramInfo->numVtxAttrs = numAttrNames; + shaderProgramInfo->vtxAttrs = (CGparameter *)malloc(numAttrNames * sizeof(CGparameter)); + + fprintf(stderr, "CgShaderProgramRetained.lookupNativeVertexAttrNames()\n"); + for (i = 0; i < numAttrNames; i++) { + attrName = (*env)->GetObjectArrayElement(env, attrNames, i); + attrNameString = strJavaToC(env, attrName); + + shaderProgramInfo->vtxAttrs[i] = + cgWrapperInfo->cgGetNamedParameter(shaderProgramInfo->vShader->cgShader, + attrNameString); + fprintf(stderr, " %s : 0x%x\n", attrNameString, shaderProgramInfo->vtxAttrs[i]); + if (shaderProgramInfo->vtxAttrs[i] == NULL) { + errPtr[i] = JNI_TRUE; + } + + free(attrNameString); + } + + (*env)->ReleaseBooleanArrayElements(env, errArr, errPtr, 0); + +#endif /* COMPILE_CG_SHADERS */ +} + + +#ifdef COMPILE_CG_SHADERS + +static jint +cgToJ3dType(CGtype type) +{ + switch (type) { + case CG_BOOL: + case CG_BOOL1: + case CG_FIXED: + case CG_FIXED1: + case CG_HALF: + case CG_HALF1: + case CG_INT: + case CG_INT1: + return TYPE_INTEGER; + + /* + * TODO: add ShaderAttribute support for setting samplers. In the + * mean time, the binding between sampler and texture unit will + * need to be specified in the shader itself (which it already is + * in most example shaders). + * + * case CG_SAMPLER2D: + * case CG_SAMPLER3D: + * case CG_SAMPLERCUBE: + * + */ + + case CG_BOOL2: + case CG_FIXED2: + case CG_HALF2: + case CG_INT2: + /* TODO: return TYPE_TUPLE2I; */ + return -1; + + case CG_BOOL3: + case CG_FIXED3: + case CG_HALF3: + case CG_INT3: + /*TODO: return TYPE_TUPLE3I; */ + return -1; + + case CG_BOOL4: + case CG_FIXED4: + case CG_HALF4: + case CG_INT4: + /*TODO: return TYPE_TUPLE4I; */ + return -1; + + case CG_FLOAT: + case CG_FLOAT1: + return TYPE_FLOAT; + + case CG_FLOAT2: + /*TODO: return TYPE_TUPLE2F; */ + return -1; + + case CG_FLOAT3: + /*TODO: return TYPE_TUPLE3F; */ + return -1; + + case CG_FLOAT4: + /*TODO: return TYPE_TUPLE4F; */ + return -1; + + case CG_FLOAT3x3: + /*TODO: return TYPE_MATRIX3F; */ + return -1; + + case CG_FLOAT4x4: + /*TODO: return TYPE_MATRIX4F; */ + return -1; + + /* + * Java 3D does not support the following sampler types: + * + * case CG_SAMPLER1D: + * case CG_SAMPLERRECT: + */ + } + + return -1; +} + +static CGparameter +lookupParams( + CgWrapperInfo *cgWrapperInfo, + CgShaderInfo *shader, + char *attrNameString, + CGtype *type, + int *size, + jboolean *isArray) +{ + CGparameter loc; + CGparameter firstElem; + + loc = cgWrapperInfo->cgGetNamedParameter(shader->cgShader, + attrNameString); + if (loc != NULL) { + *type = cgWrapperInfo->cgGetParameterType(loc); + if (*type == CG_ARRAY) { + *isArray = JNI_TRUE; + *size = cgWrapperInfo->cgGetArraySize(loc, 0); + /**type = cgWrapperInfo->cgGetArrayType(loc);*/ + firstElem = cgWrapperInfo->cgGetArrayParameter(loc, 0); + *type = cgWrapperInfo->cgGetParameterType(firstElem); + /* + fprintf(stderr, + "firstElem = %d, *type = %d\n", + firstElem, *type); + */ + } + else { + *isArray = JNI_FALSE; + *size = 1; + } + } + + return loc; +} + +#endif /* COMPILE_CG_SHADERS */ + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: lookupNativeShaderAttrNames + * Signature: (JJI[Ljava/lang/String;[J[I[I[Z)V + */ +JNIEXPORT void JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeShaderAttrNames( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jint numAttrNames, + jobjectArray attrNames, + jlongArray locArr, + jintArray typeArr, + jintArray sizeArr, + jbooleanArray isArrayArr) +{ + +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + + jstring attrName; + char *attrNameString; + jlong *locPtr; + jint *typePtr; + jint *sizePtr; + jboolean *isArrayPtr; + CGparameter vLoc, fLoc; + CGtype vType, fType; + int vSize, fSize; + jboolean vIsArray, fIsArray; + int i; + + locPtr = (*env)->GetLongArrayElements(env, locArr, NULL); + typePtr = (*env)->GetIntArrayElements(env, typeArr, NULL); + sizePtr = (*env)->GetIntArrayElements(env, sizeArr, NULL); + isArrayPtr = (*env)->GetBooleanArrayElements(env, isArrayArr, NULL); + + /* + * Set the loc, type, and size arrays to out-of-band values + */ + for (i = 0; i < numAttrNames; i++) { + locPtr[i] = -1; + typePtr[i] = -1; + sizePtr[i] = -1; + } + + /* Now lookup the location of each name in the attrNames array */ + for (i = 0; i < numAttrNames; i++) { + jboolean err; + CgParameterInfo *cgParamInfo; + + attrName = (*env)->GetObjectArrayElement(env, attrNames, i); + attrNameString = (GLcharARB *)strJavaToC(env, attrName); + + fprintf(stderr, "lookup %s\n", attrNameString); + + /* + * Get uniform attribute location -- note that we need to + * lookup the name in both the vertex and fragment shader + * (although we will generalize it to look at the list of "N" + * shaders). If all parameter locations are NULL, then no + * struct will be allocated and -1 will be stored for this + * attribute. If there is more than one non-NULL parameter, + * then all must be of the same type and dimensionality, + * otherwise an error will be generated and -1 will be stored + * for this attribute. If all non-NULL parameters are of the + * same type and dimensionality, then a struct is allocated + * containing the list of parameters. + * + * When any of the setUniform methods are called, the attribute + * will be set for each parameter in the list. + */ + cgParamInfo = (CgParameterInfo *)malloc(sizeof(CgParameterInfo)); + cgParamInfo->vParam = NULL; + cgParamInfo->fParam = NULL; + err = JNI_FALSE; + + vLoc = NULL; + if (shaderProgramInfo->vShader != NULL) { + vLoc = lookupParams(cgWrapperInfo, shaderProgramInfo->vShader, + attrNameString, &vType, &vSize, &vIsArray); + cgParamInfo->vParam = vLoc; + if (vLoc != NULL) { + sizePtr[i] = (jint)vSize; + isArrayPtr[i] = vIsArray; + typePtr[i] = cgToJ3dType(vType); + + fprintf(stderr, " vLoc = %d, vType = %d, vSize = %d, vIsArray = %d\n", + vLoc, vType, vSize, vIsArray); + } + } + + fLoc = NULL; + if (shaderProgramInfo->fShader != NULL) { + fLoc = lookupParams(cgWrapperInfo, shaderProgramInfo->fShader, + attrNameString, &fType, &fSize, &fIsArray); + cgParamInfo->fParam = fLoc; + if (fLoc != NULL) { + sizePtr[i] = (jint)fSize; + isArrayPtr[i] = fIsArray; + typePtr[i] = cgToJ3dType(fType); + + fprintf(stderr, " fLoc = %d, fType = %d, fSize = %d, fIsArray = %d\n", + fLoc, fType, fSize, fIsArray); + } + } + + /* + * If the name lookup found an entry in both vertex and + * fragment program, verify that the type and size are the + * same. + */ + if (cgParamInfo->vParam != NULL && cgParamInfo->fParam != NULL) { + if (vType != fType || vSize != fSize || vIsArray != fIsArray) { + /* TODO: the following needs to be propagated to ShaderError */ + fprintf(stderr, + "JAVA 3D : error shader attribute type mismatch: %s\n", + attrNameString); + fprintf(stderr, + " 1 : type = %d, size = %d, isArray = %d\n", + vType, vSize, vIsArray); + fprintf(stderr, + " 0 : type = %d, size = %d, isArray = %d\n", + fType, fSize, fIsArray); + err = JNI_TRUE; + } + } + + /* + * Report an error if we got a mismatch or if the attribute + * was not found in either the vertex or the fragment program + */ + if (err || (cgParamInfo->vParam == NULL && cgParamInfo->fParam == NULL)) { + /* TODO: distinguish between (err) and (vParam and fParam both NULL) */ + free(cgParamInfo); + locPtr[i] = (jlong)-1; + } + else { + /* + * TODO: need to store the cgParamInfo pointers in the + * shader program so we can free them later. + * + * NOTE: WE CURRENTLY HAVE A MEMORY LEAK. + */ + locPtr[i] = (jlong)cgParamInfo; + } + + free(attrNameString); + } + + /* Release JNI arrays */ + (*env)->ReleaseLongArrayElements(env, locArr, locPtr, 0); + (*env)->ReleaseIntArrayElements(env, typeArr, typePtr, 0); + (*env)->ReleaseIntArrayElements(env, sizeArr, sizePtr, 0); + (*env)->ReleaseBooleanArrayElements(env, isArrayArr, isArrayPtr, 0); + +#endif /* COMPILE_CG_SHADERS */ + +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: useShaderProgram + * Signature: (JJ)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_useShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId) +{ +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + + cgWrapperInfo->cgGLDisableProfile(cgCtxInfo->vProfile); + cgWrapperInfo->cgGLDisableProfile(cgCtxInfo->fProfile); + + if (shaderProgramId != 0) { + if (shaderProgramInfo->vShader != NULL) { + cgWrapperInfo->cgGLBindProgram(shaderProgramInfo->vShader->cgShader); + cgWrapperInfo->cgGLEnableProfile(shaderProgramInfo->vShader->shaderProfile); + } + + if (shaderProgramInfo->fShader != NULL) { + cgWrapperInfo->cgGLBindProgram(shaderProgramInfo->fShader->cgShader); + cgWrapperInfo->cgGLEnableProfile(shaderProgramInfo->fShader->shaderProfile); + } + } + else { + /* TODO: Unbind old shader program */ + } + + ctxProperties->shaderProgramId = shaderProgramId; + +#endif /* COMPILE_CG_SHADERS */ + + return NULL; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform1i + * Signature: (JJJI)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform1i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint value) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform1f + * Signature: (JJJF)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform1f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloat value) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + CgCtxInfo *cgCtxInfo = ctxProperties->cgCtxInfo; + CgWrapperInfo *cgWrapperInfo = cgCtxInfo->cgWrapperInfo; + CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; + CgParameterInfo *cgParamInfo = (CgParameterInfo *)location; + + if (cgParamInfo->vParam != NULL) { + cgWrapperInfo->cgSetParameter1f(cgParamInfo->vParam, value); + } + + if (cgParamInfo->fParam != NULL) { + cgWrapperInfo->cgSetParameter1f(cgParamInfo->fParam, value); + } + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform2i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform2i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform2f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform2f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform3i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform3i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform3f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform3f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform4i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform4i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform4f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniform4f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniformMatrix3f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniformMatrix4f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix4f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + jobject shaderError = NULL; + +#ifdef COMPILE_CG_SHADERS + + /* TODO: implement this */ + +#else /* COMPILE_CG_SHADERS */ + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_UNSUPPORTED_LANGUAGE_ERROR, + "CgShaderProgram support not compiled", + NULL); + +#endif /* !COMPILE_CG_SHADERS */ + + return shaderError; +} + + +/* + * Cg vertex attribute functions + */ + +static void +cgVertexAttrPointer( + GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer) +{ + /* TODO: implement this */ + fprintf(stderr, "cgVertexAttrPointer: not implemented\n"); +} + +static void +cgEnableVertexAttrArray( + GraphicsContextPropertiesInfo *ctxProperties, + int index) +{ + /* TODO: implement this */ + fprintf(stderr, "cgEnableVertexAttrArray: not implemented\n"); +} + +static void +cgDisableVertexAttrArray( + GraphicsContextPropertiesInfo *ctxProperties, + int index) +{ + /* TODO: implement this */ + fprintf(stderr, "cgDisableVertexAttrArray: not implemented\n"); +} + +static void +cgVertexAttr( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ + /* + * NOTE: we should never get here. This function is only called + * when building display lists for geometry arrays with vertex + * attributes, and such display lists are disabled in Cg mode. + */ + fprintf(stderr, + "Java 3D ERROR : Assertion failed: invalid call to cgVertexAttr*f\n"); +} + + +#if 0 + + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform1iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform1iArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jintArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform1fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform1fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform2iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform2iArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jintArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform2fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform2fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform3iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform3iArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jintArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform3fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform3fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform4iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform4iArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jintArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniform4fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniform4fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniformMatrix3fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + +/* + * Class: javax_media_j3d_CgShaderProgramRetained + * Method: setUniformMatrix4fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix4fArray + (JNIEnv *, jobject, jlong, jlong, jlong, jint, jfloatArray); + + + +#endif + + + + + +#if 0 +/* + * Class: javax_media_j3d_CgShaderProgram + * Method: updateNative + * Signature: (JLjava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_javax_media_j3d_CgShaderProgram_updateNative( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jstring vertexShader, + jstring fragmentShader) +{ +#ifndef COMPILE_CG_SHADERS + static GLboolean firstTime = GL_TRUE; + + if (firstTime) { + fprintf(stderr, "Java 3D ERROR : CgShader code not compiled\n"); + firstTime = GL_FALSE; + } + return; +#endif /* !COMPILE_CG_SHADERS */ + +#ifdef COMPILE_CG_SHADERS + /* Null-terminated "C" strings */ + char *vertexShaderString = NULL; + char *fragmentShaderString = NULL; + + /* Process vertex shader */ + /* + fprintf(stderr, " vertexShader == 0x%x\n", vertexShader); + */ + if (vertexShader != 0) { + vertexShaderString = strJavaToC(env, vertexShader); + if (vertexShaderString == NULL) { + return; + } + + /* + * TODO: need to check whether the shader has changed and free up the + * old shader before allocating a new one (like we do for texture) + */ + if (vContext == 0) { + /* Use GL_ARB_vertex_program extension if supported by video card */ + if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1)) { + fprintf(stderr, "Using CG_PROFILE_ARBVP1\n"); + vProfile = CG_PROFILE_ARBVP1; + } + else if (cgGLIsProfileSupported(CG_PROFILE_VP20)) { + fprintf(stderr, "Using CG_PROFILE_VP20\n"); + vProfile = CG_PROFILE_VP20; + } + else { + fprintf(stderr, + "ERROR: Vertex programming extensions (GL_ARB_vertex_program or\n" + "GL_NV_vertex_program) not supported, exiting...\n"); + return; + } + + cgSetErrorCallback(cgErrorCallback); + + vContext = cgCreateContext(); + + /* create the vertex shader */ + fprintf(stderr, + "CgShaderProgram_updateNative: create vertex shader program\n"); + vShader = cgCreateProgram(vContext, + CG_SOURCE, vertexShaderString, + vProfile, NULL, NULL); + } + free(vertexShaderString); + + /* + fprintf(stderr, + "CgShaderProgram_updateNative: load/bind/enable vertex shader program\n"); + */ + cgGLLoadProgram(vShader); + cgGLBindProgram(vShader); + cgGLEnableProfile(vProfile); + } + else { + if (vProfile != 0) { + cgGLDisableProfile(vProfile); + } + } + + /* Process fragment shader */ + /* + fprintf(stderr, " fragmentShader == 0x%x\n", fragmentShader); + */ + if (fragmentShader != 0) { + fragmentShaderString = strJavaToC(env, fragmentShader); + if (fragmentShaderString == NULL) { + return; + } + + /* + * TODO: need to check whether the shader has changed and free up the + * old shader before allocating a new one (like we do for texture) + */ + if (fContext == 0) { + /* Use GL_ARB_fragment_program extension if supported by video card */ + if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1)) { + fprintf(stderr, "Using CG_PROFILE_ARBFP1\n"); + fProfile = CG_PROFILE_ARBFP1; + } + else if (cgGLIsProfileSupported(CG_PROFILE_FP20)) { + fprintf(stderr, "Using CG_PROFILE_FP20\n"); + fProfile = CG_PROFILE_FP20; + } + else { + fprintf(stderr, + "Fragment programming extensions (GL_ARB_fragment_program or\n" + "GL_NV_fragment_program) not supported, exiting...\n"); + return; + } + + cgSetErrorCallback(cgErrorCallback); + + fContext = cgCreateContext(); + + /* create the fragment shader */ + fprintf(stderr, + "CgShaderProgram_updateNative: create fragment shader program\n"); + fShader = cgCreateProgram(fContext, + CG_SOURCE, fragmentShaderString, + fProfile, NULL, NULL); + } + free(fragmentShaderString); + + cgGLLoadProgram(fShader); + cgGLBindProgram(fShader); + /* + fprintf(stderr, + "CgShaderProgram_updateNative: load/bind/enable fragment shader program\n"); + */ + cgGLEnableProfile(fProfile); + } + else { + if (fProfile != 0) { + cgGLDisableProfile(fProfile); + } + } +#endif /* COMPILE_CG_SHADERS */ + +} +/* KCR: END CG SHADER HACK */ + +#endif /* 0 */ diff --git a/src/native/ogl/CgWrapper.c b/src/native/ogl/CgWrapper.c new file mode 100644 index 0000000..55c2c64 --- /dev/null +++ b/src/native/ogl/CgWrapper.c @@ -0,0 +1,56 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +/* + * Note: since this is just a wrapper around the CG functions, it + * won't be compiled or linked unless the CG library is + * available. This means we don't need to use "#ifdef COMPILE_CG". + */ + +#if defined(LINUX) +#define _GNU_SOURCE 1 +#endif + +#include <stdio.h> +#include <stdlib.h> + +#include "gldefs.h" +#include "CgWrapper.h" + +/* + * Setup the function pointers + */ +JNIEXPORT void +j3dLoadCgFunctionPointers(CgWrapperInfo *cgWrapperInfo) +{ + cgWrapperInfo->cgCreateContext = &cgCreateContext; + cgWrapperInfo->cgGLIsProfileSupported = &cgGLIsProfileSupported; + cgWrapperInfo->cgGetError = &cgGetError; + cgWrapperInfo->cgGetErrorString = &cgGetErrorString; + cgWrapperInfo->cgGetLastListing = &cgGetLastListing; + cgWrapperInfo->cgCreateProgram = &cgCreateProgram; + cgWrapperInfo->cgDestroyProgram = &cgDestroyProgram; + cgWrapperInfo->cgGLLoadProgram = &cgGLLoadProgram; + cgWrapperInfo->cgGLBindProgram = &cgGLBindProgram; + cgWrapperInfo->cgGLUnbindProgram = &cgGLUnbindProgram; + cgWrapperInfo->cgGLEnableProfile = &cgGLEnableProfile; + cgWrapperInfo->cgGLDisableProfile = &cgGLDisableProfile; + cgWrapperInfo->cgGetNamedParameter = &cgGetNamedParameter; + cgWrapperInfo->cgGetParameterType = &cgGetParameterType; + cgWrapperInfo->cgGetArrayDimension = &cgGetArrayDimension; + cgWrapperInfo->cgGetArrayType = &cgGetArrayType; + cgWrapperInfo->cgGetArraySize = &cgGetArraySize; + cgWrapperInfo->cgGetArrayParameter = &cgGetArrayParameter; + cgWrapperInfo->cgSetParameter1f = &cgSetParameter1f; + + return; +} diff --git a/src/native/ogl/CgWrapper.h b/src/native/ogl/CgWrapper.h new file mode 100644 index 0000000..feed5ad --- /dev/null +++ b/src/native/ogl/CgWrapper.h @@ -0,0 +1,167 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +#ifndef _Java3D_CgWrapper_h_ +#define _Java3D_CgWrapper_h_ + +#include "gldefs.h" + +#ifdef COMPILE_CG_SHADERS +#include <Cg/cgGL.h> +#endif /* COMPILE_CG_SHADERS */ + + +/* Forward references for structure typedefs */ +typedef struct CgWrapperInfoRec CgWrapperInfo; +typedef struct CgShaderInfoRec CgShaderInfo; +typedef struct CgShaderProgramInfoRec CgShaderProgramInfo; +typedef struct CgParameterInfoRec CgParameterInfo; + + +/* Typedef for function pointer to entry point in CgWrapper library */ +typedef void (*PFNJ3DLOADCGFUNCTIONPOINTERS)(CgWrapperInfo *); + + +#ifdef COMPILE_CG_SHADERS +typedef CGcontext (*PFNCGCREATECONTEXT)(void); +typedef CGbool (*PFNCGGLISPROFILESUPPORTED)(CGprofile); +typedef CGerror (*PFNCGGETERROR)(void); +typedef const char * (*PFNCGGETERRORSTRING)(CGerror); +typedef const char * (*PFNCGGETLASTLISTING)(CGcontext); +typedef CGprogram (*PFNCGCREATEPROGRAM)(CGcontext, CGenum, const char *, + CGprofile, const char *, const char **); +typedef void (*PFNCGDESTROYPROGRAM)(CGprogram program); +typedef void (*PFNCGGLLOADPROGRAM)(CGprogram); +typedef void (*PFNCGGLBINDPROGRAM)(CGprogram); +typedef void (*PFNCGGLUNBINDPROGRAM)(CGprofile); +typedef void (*PFNCGGLENABLEPROFILE)(CGprofile); +typedef void (*PFNCGGLDISABLEPROFILE)(CGprofile); +typedef CGparameter (*PFNCGGETNAMEDPARAMETER)(CGprogram, const char *); +typedef CGtype (*PFNCGGETPARAMETERTYPE)(CGparameter); +typedef int (*PFNCGGETARRAYDIMENSION)(CGparameter); +typedef CGtype (*PFNCGGETARRAYTYPE)(CGparameter); +typedef int (*PFNCGGETARRAYSIZE)(CGparameter, int); +typedef CGparameter (*PFNCGGETARRAYPARAMETER)(CGparameter, int); +typedef void (*PFNCGSETPARAMETER1F)(CGparameter, float); + +#endif /* COMPILE_CG_SHADERS */ + + +/* + * Global struct that contains the reference to the CG wrapper library + * and the function pointers to each wrapper function. This is a + * singleton (only one instance exists), and is initialized by a + * static MasterControl method. For performance, we will cache the + * pointer to this global struct in each context. + */ +struct CgWrapperInfoRec { + /* + * Flag indicating whether the library and all function pointers + * were successfully loaded. + */ + jboolean loaded; + + /* + * Pointer to library, returned by dlopen (UNIX) or LoadLibrary (Windows) + */ + void *cgLibraryHandle; + + /* Function pointer to entry point in CgWrapper library */ + PFNJ3DLOADCGFUNCTIONPOINTERS j3dLoadCgFunctionPointers; + + /* Function pointers for warapper functions */ +#ifdef COMPILE_CG_SHADERS + + /* CG function pointers */ + PFNCGCREATECONTEXT cgCreateContext; + PFNCGGLISPROFILESUPPORTED cgGLIsProfileSupported; + PFNCGGETERROR cgGetError; + PFNCGGETERRORSTRING cgGetErrorString; + PFNCGGETLASTLISTING cgGetLastListing; + PFNCGCREATEPROGRAM cgCreateProgram; + PFNCGDESTROYPROGRAM cgDestroyProgram; + PFNCGGLLOADPROGRAM cgGLLoadProgram; + PFNCGGLBINDPROGRAM cgGLBindProgram; + PFNCGGLUNBINDPROGRAM cgGLUnbindProgram; + PFNCGGLENABLEPROFILE cgGLEnableProfile; + PFNCGGLDISABLEPROFILE cgGLDisableProfile; + PFNCGGETNAMEDPARAMETER cgGetNamedParameter; + PFNCGGETPARAMETERTYPE cgGetParameterType; + PFNCGGETARRAYDIMENSION cgGetArrayDimension; + PFNCGGETARRAYTYPE cgGetArrayType; + PFNCGGETARRAYSIZE cgGetArraySize; + PFNCGGETARRAYPARAMETER cgGetArrayParameter; + PFNCGSETPARAMETER1F cgSetParameter1f; + +#endif /* COMPILE_CG_SHADERS */ +}; + + +/* Structure used to hold CG context information; stored in ctxInfo */ +struct CgCtxInfoRec { + CgWrapperInfo *cgWrapperInfo; /* Pointer to static wrapper info */ + +#ifdef COMPILE_CG_SHADERS + CGcontext cgCtx; + CGprofile vProfile; + CGprofile fProfile; +#endif /* COMPILE_CG_SHADERS */ +}; + + +/* Structure used to hold CG shader information; passed back to Java as cgShaderId */ +struct CgShaderInfoRec { +#ifdef COMPILE_CG_SHADERS + CGprogram cgShader; + jint shaderType; + CGprofile shaderProfile; +#else /* COMPILE_CG_SHADERS */ + int dummy; +#endif /* COMPILE_CG_SHADERS */ +}; + +/* + * Structure used to hold CG shader program information; passed back + * to Java as cgShaderProgramId + */ +struct CgShaderProgramInfoRec { +#ifdef COMPILE_CG_SHADERS + /* + * Vertex and fragment shader -- may be null to indicate that one + * or the other is not present + */ + CgShaderInfo *vShader; /* Vertex shader */ + CgShaderInfo *fShader; /* Fragment shader */ + + /* Array of parameters for (varying) vertex attributes */ + int numVtxAttrs; + CGparameter *vtxAttrs; +#else /* COMPILE_CG_SHADERS */ + int dummy; +#endif /* COMPILE_CG_SHADERS */ +}; + +/* + * Structure used to hold CG shader parameter information for uniform + * shader attributes; passed back to Java in the locArr array + */ +struct CgParameterInfoRec { +#ifdef COMPILE_CG_SHADERS + CGparameter vParam; /* Parameter handle for vertex shader */ + CGparameter fParam; /* Parameter handle for fragment shader */ +#else /* COMPILE_CG_SHADERS */ + int dummy; +#endif /* COMPILE_CG_SHADERS */ +}; + + +#endif /* _Java3D_CgWrapper_h_ */ diff --git a/src/native/ogl/CompressedGeometryRetained.c b/src/native/ogl/CompressedGeometryRetained.c deleted file mode 100644 index 4455ee4..0000000 --- a/src/native/ogl/CompressedGeometryRetained.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include <stdio.h> -#include <jni.h> -#include "gldefs.h" - -#ifdef OBSOLETE_HW_COMPRESSED_GEOM -/* #if defined(SOLARIS) && defined(__sparc) */ -/* Solaris/Sparc only, all others define this as a noop */ -#pragma weak glDrawCompressedGeomSUNX -#endif /* OBSOLETE_HW_COMPRESSED_GEOM */ - - -JNIEXPORT -void JNICALL Java_javax_media_j3d_CompressedGeometryRetained_execute - (JNIEnv *env, jobject obj, jlong ctxInfo, jint version, jint bufferType, - jint bufferContents, jint renderFlags, jint offset, jint size, - jbyteArray geometry) -{ - fprintf(stderr, - "JAVA 3D ERROR: call to obsolete CompressedGeometryRetained.execute method\n"); - - -#ifdef OBSOLETE_HW_COMPRESSED_GEOM - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - jbyte *cg = (*env)->GetPrimitiveArrayCritical(env, geometry, 0) ; - - /* ignore offset and pass header at 0 along with cg data */ - if(ctxProperties->geometry_compression_sunx) - glDrawCompressedGeomSUNX((GLint)(size + 48), (GLubyte *)cg) ; - - (*env)->ReleasePrimitiveArrayCritical(env, geometry, cg, 0) ; -#endif /* OBSOLETE_HW_COMPRESSED_GEOM */ -} - - -JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressByRef - (JNIEnv *env, jobject obj, jlong ctxInfo) -{ - return JNI_FALSE; -} - -JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressHW - (JNIEnv *env, jobject obj, jlong ctxInfo, jint majorVersion, jint minorVersion) -{ - return JNI_FALSE; - - -#ifdef OBSOLETE_HW_COMPRESSED_GEOM - /* - * Return true if hardware decompression is supported for the given - * version number of the compressed geometry. - */ - - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - return - (ctxProperties->geometry_compression_accelerated == 1) && - ((majorVersion < ctxProperties->geometry_compression_accelerated_major_version) || - ((majorVersion == ctxProperties->geometry_compression_accelerated_major_version) && - (minorVersion <= ctxProperties->geometry_compression_accelerated_minor_version))) ; -#endif /* OBSOLETE_HW_COMPRESSED_GEOM */ -} diff --git a/src/native/ogl/DrawingSurfaceObjectAWT.c b/src/native/ogl/DrawingSurfaceObjectAWT.c index b728201..84f86bb 100644 --- a/src/native/ogl/DrawingSurfaceObjectAWT.c +++ b/src/native/ogl/DrawingSurfaceObjectAWT.c @@ -16,12 +16,16 @@ * of the Java 3D API. */ +#include <jni.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <jawt_md.h> +#include "javax_media_j3d_MasterControl.h" +#include "javax_media_j3d_DrawingSurfaceObjectAWT.h" + #ifdef DEBUG /* Uncomment the following for VERBOSE debug messages */ /* #define VERBOSE */ @@ -144,11 +148,11 @@ Java_javax_media_j3d_DrawingSurfaceObjectAWT_getDrawingSurfaceWindowIdAWT( #endif /* __sparc */ #endif /* SOLARIS */ -#ifdef __linux__ +#ifdef LINUX JAWT_X11DrawingSurfaceInfo *xds = (JAWT_X11DrawingSurfaceInfo*) dsi->platformInfo; window = (jint)xds->drawable; -#endif /* __linux__ */ +#endif /* LINUX */ /* * Don't free DrawingSurfaceInfo here, otherwise diff --git a/src/native/ogl/GLSLInfo.h b/src/native/ogl/GLSLInfo.h new file mode 100644 index 0000000..c5be2ca --- /dev/null +++ b/src/native/ogl/GLSLInfo.h @@ -0,0 +1,61 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +#ifndef _Java3D_GLSLInfo_h_ +#define _Java3D_GLSLInfo_h_ + +#include "gldefs.h" + +/* Structure used to hold GLSL context information; stored in ctxInfo */ +struct GLSLCtxInfoRec { + PFNGLATTACHOBJECTARBPROC pfnglAttachObjectARB; + PFNGLCOMPILESHADERARBPROC pfnglCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC pfnglCreateProgramObjectARB; + PFNGLCREATESHADEROBJECTARBPROC pfnglCreateShaderObjectARB; + PFNGLDELETEOBJECTARBPROC pfnglglDeleteObjectARB; + PFNGLGETINFOLOGARBPROC pfnglGetInfoLogARB; + PFNGLGETOBJECTPARAMETERIVARBPROC pfnglGetObjectParameterivARB; + PFNGLLINKPROGRAMARBPROC pfnglLinkProgramARB; + PFNGLSHADERSOURCEARBPROC pfnglShaderSourceARB; + PFNGLUSEPROGRAMOBJECTARBPROC pfnglUseProgramObjectARB; + PFNGLGETUNIFORMLOCATIONARBPROC pfnglGetUniformLocationARB; + PFNGLGETATTRIBLOCATIONARBPROC pfnglGetAttribLocationARB; + PFNGLBINDATTRIBLOCATIONARBPROC pfnglBindAttribLocationARB; + PFNGLVERTEXATTRIB1FVARBPROC pfnglVertexAttrib1fvARB; + PFNGLVERTEXATTRIB2FVARBPROC pfnglVertexAttrib2fvARB; + PFNGLVERTEXATTRIB3FVARBPROC pfnglVertexAttrib3fvARB; + PFNGLVERTEXATTRIB4FVARBPROC pfnglVertexAttrib4fvARB; + PFNGLVERTEXATTRIBPOINTERARBPROC pfnglVertexAttribPointerARB; + PFNGLENABLEVERTEXATTRIBARRAYARBPROC pfnglEnableVertexAttribArrayARB; + PFNGLDISABLEVERTEXATTRIBARRAYARBPROC pfnglDisableVertexAttribArrayARB; + PFNGLGETACTIVEUNIFORMARBPROC pfnglGetActiveUniformARB; + PFNGLUNIFORM1IARBPROC pfnglUniform1iARB; + PFNGLUNIFORM1FARBPROC pfnglUniform1fARB; + PFNGLUNIFORM2IARBPROC pfnglUniform2iARB; + PFNGLUNIFORM2FARBPROC pfnglUniform2fARB; + PFNGLUNIFORM3IARBPROC pfnglUniform3iARB; + PFNGLUNIFORM3FARBPROC pfnglUniform3fARB; + PFNGLUNIFORM4IARBPROC pfnglUniform4iARB; + PFNGLUNIFORM4FARBPROC pfnglUniform4fARB; + PFNGLUNIFORM1IVARBPROC pfnglUniform1ivARB; + PFNGLUNIFORM1FVARBPROC pfnglUniform1fvARB; + PFNGLUNIFORM2IVARBPROC pfnglUniform2ivARB; + PFNGLUNIFORM2FVARBPROC pfnglUniform2fvARB; + PFNGLUNIFORM3IVARBPROC pfnglUniform3ivARB; + PFNGLUNIFORM3FVARBPROC pfnglUniform3fvARB; + PFNGLUNIFORM4IVARBPROC pfnglUniform4ivARB; + PFNGLUNIFORM4FVARBPROC pfnglUniform4fvARB; + PFNGLUNIFORMMATRIX3FVARBPROC pfnglUniformMatrix3fvARB; + PFNGLUNIFORMMATRIX4FVARBPROC pfnglUniformMatrix4fvARB; +}; + +#endif /* _Java3D_GLSLInfo_h_ */ diff --git a/src/native/ogl/GLSLShaderProgram.c b/src/native/ogl/GLSLShaderProgram.c new file mode 100644 index 0000000..3c29cb6 --- /dev/null +++ b/src/native/ogl/GLSLShaderProgram.c @@ -0,0 +1,1630 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +#if defined(LINUX) +#define _GNU_SOURCE 1 +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <jni.h> + +#include "gldefs.h" +#include "GLSLInfo.h" + +#if defined(UNIX) +#include <dlfcn.h> +#endif + +#ifdef DEBUG +/* Uncomment the following for VERBOSE debug messages */ +/* #define VERBOSE */ +#endif /* DEBUG */ + + +extern char *strJavaToC(JNIEnv *env, jstring str); +extern void throwAssert(JNIEnv *env, char *str); +extern jobject createShaderError(JNIEnv *env, + int errorCode, + const char *errorMsg, + const char *detailMsg); + +extern int isExtensionSupported(const char *allExtensions, const char *extension); + + +static void glslVertexAttrPointer(GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer); +static void glslEnableVertexAttrArray(GraphicsContextPropertiesInfo *ctxProperties, + int index); +static void glslDisableVertexAttrArray(GraphicsContextPropertiesInfo *ctxProperties, + int index); +static void glslVertexAttr1fv(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +static void glslVertexAttr2fv(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +static void glslVertexAttr3fv(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +static void glslVertexAttr4fv(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); + + +/* + * Called by getPropertiesFromCurrentContext to initialize the GLSL + * shader function pointers and set the flag indicating whether GLSL + * shaders are available. + */ +void +checkGLSLShaderExtensions( + JNIEnv *env, + jobject obj, + char *tmpExtensionStr, + GraphicsContextPropertiesInfo *ctxInfo, + jboolean glslLibraryAvailable) +{ + ctxInfo->shadingLanguageGLSL = JNI_FALSE; + ctxInfo->glslCtxInfo = NULL; + + if (glslLibraryAvailable && + isExtensionSupported(tmpExtensionStr, "GL_ARB_shader_objects") && + isExtensionSupported(tmpExtensionStr, "GL_ARB_shading_language_100")) { + + GLSLCtxInfo *glslCtxInfo = (GLSLCtxInfo *)malloc(sizeof(GLSLCtxInfo)); + memset(glslCtxInfo, 0, sizeof(GLSLCtxInfo)); + +#if defined(UNIX) + glslCtxInfo->pfnglAttachObjectARB = + (PFNGLATTACHOBJECTARBPROC)dlsym(RTLD_DEFAULT, "glAttachObjectARB"); + glslCtxInfo->pfnglCompileShaderARB = + (PFNGLCOMPILESHADERARBPROC)dlsym(RTLD_DEFAULT, "glCompileShaderARB"); + glslCtxInfo->pfnglCreateProgramObjectARB = + (PFNGLCREATEPROGRAMOBJECTARBPROC)dlsym(RTLD_DEFAULT, "glCreateProgramObjectARB"); + glslCtxInfo->pfnglCreateShaderObjectARB = + (PFNGLCREATESHADEROBJECTARBPROC)dlsym(RTLD_DEFAULT, "glCreateShaderObjectARB"); + glslCtxInfo->pfnglglDeleteObjectARB = + (PFNGLDELETEOBJECTARBPROC)dlsym(RTLD_DEFAULT, "glDeleteObjectARB"); + glslCtxInfo->pfnglGetInfoLogARB = + (PFNGLGETINFOLOGARBPROC)dlsym(RTLD_DEFAULT, "glGetInfoLogARB"); + glslCtxInfo->pfnglGetObjectParameterivARB = + (PFNGLGETOBJECTPARAMETERIVARBPROC)dlsym(RTLD_DEFAULT, "glGetObjectParameterivARB"); + glslCtxInfo->pfnglLinkProgramARB = + (PFNGLLINKPROGRAMARBPROC)dlsym(RTLD_DEFAULT, "glLinkProgramARB"); + glslCtxInfo->pfnglShaderSourceARB = + (PFNGLSHADERSOURCEARBPROC)dlsym(RTLD_DEFAULT, "glShaderSourceARB"); + glslCtxInfo->pfnglUseProgramObjectARB = + (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym(RTLD_DEFAULT, "glUseProgramObjectARB"); + glslCtxInfo->pfnglGetUniformLocationARB = + (PFNGLGETUNIFORMLOCATIONARBPROC)dlsym(RTLD_DEFAULT, "glGetUniformLocationARB"); + glslCtxInfo->pfnglGetAttribLocationARB = + (PFNGLGETATTRIBLOCATIONARBPROC)dlsym(RTLD_DEFAULT, "glGetAttribLocationARB"); + glslCtxInfo->pfnglBindAttribLocationARB = + (PFNGLBINDATTRIBLOCATIONARBPROC)dlsym(RTLD_DEFAULT, "glBindAttribLocationARB"); + glslCtxInfo->pfnglVertexAttrib1fvARB = + (PFNGLVERTEXATTRIB1FVARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttrib1fvARB"); + glslCtxInfo->pfnglVertexAttrib2fvARB = + (PFNGLVERTEXATTRIB2FVARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttrib2fvARB"); + glslCtxInfo->pfnglVertexAttrib3fvARB = + (PFNGLVERTEXATTRIB3FVARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttrib3fvARB"); + glslCtxInfo->pfnglVertexAttrib4fvARB = + (PFNGLVERTEXATTRIB4FVARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttrib4fvARB"); + glslCtxInfo->pfnglVertexAttribPointerARB = + (PFNGLVERTEXATTRIBPOINTERARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttribPointerARB"); + glslCtxInfo->pfnglEnableVertexAttribArrayARB = + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)dlsym(RTLD_DEFAULT, "glEnableVertexAttribArrayARB"); + glslCtxInfo->pfnglDisableVertexAttribArrayARB = + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)dlsym(RTLD_DEFAULT, "glDisableVertexAttribArrayARB"); + glslCtxInfo->pfnglVertexAttribPointerARB = + (PFNGLVERTEXATTRIBPOINTERARBPROC)dlsym(RTLD_DEFAULT, "glVertexAttribPointerARB"); + glslCtxInfo->pfnglGetActiveUniformARB = + (PFNGLGETACTIVEUNIFORMARBPROC)dlsym(RTLD_DEFAULT, "glGetActiveUniformARB"); + glslCtxInfo->pfnglUniform1iARB = + (PFNGLUNIFORM1IARBPROC)dlsym(RTLD_DEFAULT, "glUniform1iARB"); + glslCtxInfo->pfnglUniform1fARB = + (PFNGLUNIFORM1FARBPROC)dlsym(RTLD_DEFAULT, "glUniform1fARB"); + glslCtxInfo->pfnglUniform2iARB = + (PFNGLUNIFORM2IARBPROC)dlsym(RTLD_DEFAULT, "glUniform2iARB"); + glslCtxInfo->pfnglUniform2fARB = + (PFNGLUNIFORM2FARBPROC)dlsym(RTLD_DEFAULT, "glUniform2fARB"); + glslCtxInfo->pfnglUniform3iARB = + (PFNGLUNIFORM3IARBPROC)dlsym(RTLD_DEFAULT, "glUniform3iARB"); + glslCtxInfo->pfnglUniform3fARB = + (PFNGLUNIFORM3FARBPROC)dlsym(RTLD_DEFAULT, "glUniform3fARB"); + glslCtxInfo->pfnglUniform4iARB = + (PFNGLUNIFORM4IARBPROC)dlsym(RTLD_DEFAULT, "glUniform4iARB"); + glslCtxInfo->pfnglUniform4fARB = + (PFNGLUNIFORM4FARBPROC)dlsym(RTLD_DEFAULT, "glUniform4fARB"); + glslCtxInfo->pfnglUniform1ivARB = + (PFNGLUNIFORM1IVARBPROC)dlsym(RTLD_DEFAULT, "glUniform1ivARB"); + glslCtxInfo->pfnglUniform1fvARB = + (PFNGLUNIFORM1FVARBPROC)dlsym(RTLD_DEFAULT, "glUniform1fvARB"); + glslCtxInfo->pfnglUniform2ivARB = + (PFNGLUNIFORM2IVARBPROC)dlsym(RTLD_DEFAULT, "glUniform2ivARB"); + glslCtxInfo->pfnglUniform2fvARB = + (PFNGLUNIFORM2FVARBPROC)dlsym(RTLD_DEFAULT, "glUniform2fvARB"); + glslCtxInfo->pfnglUniform3ivARB = + (PFNGLUNIFORM3IVARBPROC)dlsym(RTLD_DEFAULT, "glUniform3ivARB"); + glslCtxInfo->pfnglUniform3fvARB = + (PFNGLUNIFORM3FVARBPROC)dlsym(RTLD_DEFAULT, "glUniform3fvARB"); + glslCtxInfo->pfnglUniform4ivARB = + (PFNGLUNIFORM4IVARBPROC)dlsym(RTLD_DEFAULT, "glUniform4ivARB"); + glslCtxInfo->pfnglUniform4fvARB = + (PFNGLUNIFORM4FVARBPROC)dlsym(RTLD_DEFAULT, "glUniform4fvARB"); + glslCtxInfo->pfnglUniformMatrix3fvARB = + (PFNGLUNIFORMMATRIX3FVARBPROC)dlsym(RTLD_DEFAULT, "glUniformMatrix3fvARB"); + glslCtxInfo->pfnglUniformMatrix4fvARB = + (PFNGLUNIFORMMATRIX4FVARBPROC)dlsym(RTLD_DEFAULT, "glUniformMatrix4fvARB"); +#endif +#ifdef WIN32 + glslCtxInfo->pfnglAttachObjectARB = + (PFNGLATTACHOBJECTARBPROC)wglGetProcAddress("glAttachObjectARB"); + glslCtxInfo->pfnglCompileShaderARB = + (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB"); + glslCtxInfo->pfnglCreateProgramObjectARB = + (PFNGLCREATEPROGRAMOBJECTARBPROC)wglGetProcAddress("glCreateProgramObjectARB"); + glslCtxInfo->pfnglCreateShaderObjectARB = + (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB"); + glslCtxInfo->pfnglglDeleteObjectARB = + (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB"); + glslCtxInfo->pfnglGetInfoLogARB = + (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB"); + glslCtxInfo->pfnglGetObjectParameterivARB = + (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + glslCtxInfo->pfnglLinkProgramARB = + (PFNGLLINKPROGRAMARBPROC)wglGetProcAddress("glLinkProgramARB"); + glslCtxInfo->pfnglShaderSourceARB = + (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB"); + glslCtxInfo->pfnglUseProgramObjectARB = + (PFNGLUSEPROGRAMOBJECTARBPROC)wglGetProcAddress("glUseProgramObjectARB"); + glslCtxInfo->pfnglGetUniformLocationARB = + (PFNGLGETUNIFORMLOCATIONARBPROC)wglGetProcAddress("glGetUniformLocationARB"); + glslCtxInfo->pfnglGetAttribLocationARB = + (PFNGLGETATTRIBLOCATIONARBPROC)wglGetProcAddress("glGetAttribLocationARB"); + glslCtxInfo->pfnglBindAttribLocationARB = + (PFNGLBINDATTRIBLOCATIONARBPROC)wglGetProcAddress("glBindAttribLocationARB"); + glslCtxInfo->pfnglVertexAttrib1fvARB = + (PFNGLVERTEXATTRIB1FVARBPROC)wglGetProcAddress("glVertexAttrib1fvARB"); + glslCtxInfo->pfnglVertexAttrib2fvARB = + (PFNGLVERTEXATTRIB2FVARBPROC)wglGetProcAddress("glVertexAttrib2fvARB"); + glslCtxInfo->pfnglVertexAttrib3fvARB = + (PFNGLVERTEXATTRIB3FVARBPROC)wglGetProcAddress("glVertexAttrib3fvARB"); + glslCtxInfo->pfnglVertexAttrib4fvARB = + (PFNGLVERTEXATTRIB4FVARBPROC)wglGetProcAddress("glVertexAttrib4fvARB"); + glslCtxInfo->pfnglVertexAttribPointerARB = + (PFNGLVERTEXATTRIBPOINTERARBPROC)wglGetProcAddress("glVertexAttribPointerARB"); + glslCtxInfo->pfnglEnableVertexAttribArrayARB = + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress("glEnableVertexAttribArrayARB"); + glslCtxInfo->pfnglDisableVertexAttribArrayARB = + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)wglGetProcAddress("glDisableVertexAttribArrayARB"); + glslCtxInfo->pfnglVertexAttribPointerARB = + (PFNGLVERTEXATTRIBPOINTERARBPROC)wglGetProcAddress("glVertexAttribPointerARB"); + glslCtxInfo->pfnglGetActiveUniformARB = + (PFNGLGETACTIVEUNIFORMARBPROC)wglGetProcAddress("glGetActiveUniformARB"); + glslCtxInfo->pfnglUniform1iARB = + (PFNGLUNIFORM1IARBPROC)wglGetProcAddress("glUniform1iARB"); + glslCtxInfo->pfnglUniform1fARB = + (PFNGLUNIFORM1FARBPROC)wglGetProcAddress("glUniform1fARB"); + glslCtxInfo->pfnglUniform2iARB = + (PFNGLUNIFORM2IARBPROC)wglGetProcAddress("glUniform2iARB"); + glslCtxInfo->pfnglUniform2fARB = + (PFNGLUNIFORM2FARBPROC)wglGetProcAddress("glUniform2fARB"); + glslCtxInfo->pfnglUniform3iARB = + (PFNGLUNIFORM3IARBPROC)wglGetProcAddress("glUniform3iARB"); + glslCtxInfo->pfnglUniform3fARB = + (PFNGLUNIFORM3FARBPROC)wglGetProcAddress("glUniform3fARB"); + glslCtxInfo->pfnglUniform4iARB = + (PFNGLUNIFORM4IARBPROC)wglGetProcAddress("glUniform4iARB"); + glslCtxInfo->pfnglUniform4fARB = + (PFNGLUNIFORM4FARBPROC)wglGetProcAddress("glUniform4fARB"); + glslCtxInfo->pfnglUniform1ivARB = + (PFNGLUNIFORM1IVARBPROC)wglGetProcAddress("glUniform1ivARB"); + glslCtxInfo->pfnglUniform1fvARB = + (PFNGLUNIFORM1FVARBPROC)wglGetProcAddress("glUniform1fvARB"); + glslCtxInfo->pfnglUniform2ivARB = + (PFNGLUNIFORM2IVARBPROC)wglGetProcAddress("glUniform2ivARB"); + glslCtxInfo->pfnglUniform2fvARB = + (PFNGLUNIFORM2FVARBPROC)wglGetProcAddress("glUniform2fvARB"); + glslCtxInfo->pfnglUniform3ivARB = + (PFNGLUNIFORM3IVARBPROC)wglGetProcAddress("glUniform3ivARB"); + glslCtxInfo->pfnglUniform3fvARB = + (PFNGLUNIFORM3FVARBPROC)wglGetProcAddress("glUniform3fvARB"); + glslCtxInfo->pfnglUniform4ivARB = + (PFNGLUNIFORM4IVARBPROC)wglGetProcAddress("glUniform4ivARB"); + glslCtxInfo->pfnglUniform4fvARB = + (PFNGLUNIFORM4FVARBPROC)wglGetProcAddress("glUniform4fvARB"); + glslCtxInfo->pfnglUniformMatrix3fvARB = + (PFNGLUNIFORMMATRIX3FVARBPROC)wglGetProcAddress("glUniformMatrix3fvARB"); + glslCtxInfo->pfnglUniformMatrix4fvARB = + (PFNGLUNIFORMMATRIX4FVARBPROC)wglGetProcAddress("glUniformMatrix4fvARB"); +#endif + + /* Initialize shader vertex attribute function pointers */ + ctxInfo->vertexAttrPointer = glslVertexAttrPointer; + ctxInfo->enableVertexAttrArray = glslEnableVertexAttrArray; + ctxInfo->disableVertexAttrArray = glslDisableVertexAttrArray; + ctxInfo->vertexAttr1fv = glslVertexAttr1fv; + ctxInfo->vertexAttr2fv = glslVertexAttr2fv; + ctxInfo->vertexAttr3fv = glslVertexAttr3fv; + ctxInfo->vertexAttr4fv = glslVertexAttr4fv; + + ctxInfo->maxTextureImageUnits = 0; + ctxInfo->maxVertexTextureImageUnits = 0; + ctxInfo->maxCombinedTextureImageUnits = 0; + + /* Initialize GLSL texture sampler limits */ + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxTextureImageUnits); + glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxVertexTextureImageUnits); + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxCombinedTextureImageUnits); + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &ctxInfo->maxVertexAttrs); + if (ctxInfo->maxVertexAttrs > 0) { + /* decr count, since vertexAttr[0] is reserved for position */ + ctxInfo->maxVertexAttrs -= 1; + } + + if (glslCtxInfo->pfnglCreateShaderObjectARB != NULL) { + /*fprintf(stderr, "Java 3D : GLSLShader extension is available\n");*/ + ctxInfo->shadingLanguageGLSL = JNI_TRUE; + /* TODO: need to free ctxInfo->glslCtxInfo when ctxInfo is freed */ + ctxInfo->glslCtxInfo = glslCtxInfo; + } + else { + free(glslCtxInfo); + } + } +} + + +/* + * Return the info log as a string. This is used as the detail message + * for a ShaderError. + */ +static const char * +getInfoLog( + GraphicsContextPropertiesInfo* ctxProperties, + GLhandleARB obj) +{ + int infoLogLength = 0; + int len = 0; + GLcharARB *infoLog = NULL; + + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + static const char *allocMsg = + "Java 3D ERROR: could not allocate infoLog buffer\n"; + + glslCtxInfo->pfnglGetObjectParameterivARB(obj, + GL_OBJECT_INFO_LOG_LENGTH_ARB, + &infoLogLength); + if (infoLogLength > 0) { + infoLog = (GLcharARB *)malloc(infoLogLength); + if (infoLog == NULL) { + return allocMsg; + } + + glslCtxInfo->pfnglGetInfoLogARB(obj, infoLogLength, &len, infoLog); + } + + return infoLog; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: createNativeShader + * Signature: (JI[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jint shaderType, + jlongArray shaderIdArray) +{ + + jlong *shaderIdPtr; + GLhandleARB shaderHandle = 0; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + jobject shaderError = NULL; + + shaderIdPtr = (*env)->GetLongArrayElements(env, shaderIdArray, NULL); + + /* Process shader */ + /* + fprintf(stderr, " shaderType == %d\n", shaderType); + */ + if (shaderType == javax_media_j3d_Shader_SHADER_TYPE_VERTEX) { + /* create the vertex shader */ + shaderHandle = glslCtxInfo->pfnglCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + } + else if (shaderType == javax_media_j3d_Shader_SHADER_TYPE_FRAGMENT) { + /* create the fragment shader */ + shaderHandle = glslCtxInfo->pfnglCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + } + + if (shaderHandle == 0) { + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_COMPILE_ERROR, + "Unable to create native shader object", + NULL); + } + + shaderIdPtr[0] = (jlong) shaderHandle; + (*env)->ReleaseLongArrayElements(env, shaderIdArray, shaderIdPtr, 0); + + return shaderError; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: destroyNativeShader + * Signature: (JJ)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderId) +{ + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglglDeleteObjectARB( (GLhandleARB) shaderId); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: compileNativeShader + * Signature: (JJLjava/lang/String;)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_compileNativeShader( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderId, + jstring program) +{ + GLint status; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + jobject shaderError = NULL; + + /* Null-terminated "C" strings */ + GLcharARB *shaderString = NULL; + const GLcharARB *shaderStringArr[1]; + + + /* Assertion check the shaderId */ + if (shaderId == 0) { + throwAssert(env, "shaderId == 0"); + return NULL; + } + + /* Assertion check the program string */ + if (program == NULL) { + throwAssert(env, "shader program string is NULL"); + return NULL; + } + + shaderString = (GLcharARB *)strJavaToC(env, program); + if (shaderString == NULL) { + /* Just return, since strJavaToC will throw OOM if it returns NULL */ + return NULL; + } + + shaderStringArr[0] = shaderString; + glslCtxInfo->pfnglShaderSourceARB((GLhandleARB)shaderId, 1, shaderStringArr, NULL); + glslCtxInfo->pfnglCompileShaderARB((GLhandleARB)shaderId); + glslCtxInfo->pfnglGetObjectParameterivARB((GLhandleARB)shaderId, + GL_OBJECT_COMPILE_STATUS_ARB, + &status); + if (!status) { + const char *detailMsg = getInfoLog(ctxProperties, (GLhandleARB)shaderId); + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_COMPILE_ERROR, + "GLSL shader compile error", + detailMsg); + } + + free(shaderString); + return shaderError; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: createNativeShaderProgram + * Signature: (J[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlongArray shaderProgramIdArray) +{ + + jlong *shaderProgramIdPtr; + GLhandleARB shaderProgramHandle; + jobject shaderError = NULL; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + shaderProgramIdPtr = (*env)->GetLongArrayElements(env, shaderProgramIdArray, NULL); + + shaderProgramHandle = glslCtxInfo->pfnglCreateProgramObjectARB(); + + if (shaderProgramHandle == 0) { + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_LINK_ERROR, + "Unable to create native shader program object", + NULL); + } + + shaderProgramIdPtr[0] = (jlong) shaderProgramHandle; + (*env)->ReleaseLongArrayElements(env, shaderProgramIdArray, shaderProgramIdPtr, 0); + + return shaderError; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: destroyNativeShaderProgram + * Signature: (JJ)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId) +{ + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglglDeleteObjectARB((GLhandleARB)shaderProgramId); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: linkNativeShaderProgram + * Signature: (JJ[J)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_linkNativeShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlongArray shaderIdArray) +{ + GLint status; + int i; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + jlong *shaderIdPtr = (*env)->GetLongArrayElements(env, shaderIdArray, NULL); + jsize shaderIdArrayLength = (*env)->GetArrayLength(env, shaderIdArray); + jobject shaderError = NULL; + + /* + fprintf(stderr, "linkShaderProgram: shaderIdArrayLength %d\n", shaderIdArrayLength); + */ + + for(i=0; i<shaderIdArrayLength; i++) { + glslCtxInfo->pfnglAttachObjectARB((GLhandleARB)shaderProgramId, + (GLhandleARB)shaderIdPtr[i]); + } + + glslCtxInfo->pfnglLinkProgramARB((GLhandleARB)shaderProgramId); + glslCtxInfo->pfnglGetObjectParameterivARB((GLhandleARB)shaderProgramId, + GL_OBJECT_LINK_STATUS_ARB, + &status); + + if (!status) { + const char *detailMsg = getInfoLog(ctxProperties, (GLhandleARB)shaderProgramId); + + shaderError = createShaderError(env, + javax_media_j3d_ShaderError_LINK_ERROR, + "GLSL shader program link error", + detailMsg); + } + + (*env)->ReleaseLongArrayElements(env, shaderIdArray, shaderIdPtr, JNI_ABORT); + + return shaderError; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: bindNativeVertexAttrName + * Signature: (JJLjava/lang/String;I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_bindNativeVertexAttrName( + JNIEnv * env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jstring attrName, + jint attrIndex) +{ + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + jobject shaderError = NULL; + GLcharARB *attrNameString = (GLcharARB *)strJavaToC(env, attrName); + + /* + fprintf(stderr, + "GLSLShaderProgramRetained.bindNativeVertexAttrName: %s\n", + attrNameString); + */ + + glslCtxInfo->pfnglBindAttribLocationARB((GLhandleARB)shaderProgramId, + attrIndex + 1, + attrNameString); + + /* No error checking needed, so just return */ + + return shaderError; +} + + +static jint +glslToJ3dType(GLint type) +{ + switch (type) { + case GL_BOOL_ARB: + case GL_INT: + case GL_SAMPLER_2D_ARB: + case GL_SAMPLER_3D_ARB: + case GL_SAMPLER_CUBE_ARB: + return TYPE_INTEGER; + + case GL_FLOAT: + return TYPE_FLOAT; + + case GL_INT_VEC2_ARB: + case GL_BOOL_VEC2_ARB: + return TYPE_TUPLE2I; + + case GL_FLOAT_VEC2_ARB: + return TYPE_TUPLE2F; + + case GL_INT_VEC3_ARB: + case GL_BOOL_VEC3_ARB: + return TYPE_TUPLE3I; + + case GL_FLOAT_VEC3_ARB: + return TYPE_TUPLE3F; + + case GL_INT_VEC4_ARB: + case GL_BOOL_VEC4_ARB: + return TYPE_TUPLE4I; + + case GL_FLOAT_VEC4_ARB: + return TYPE_TUPLE4F; + + /* case GL_FLOAT_MAT2_ARB: */ + + case GL_FLOAT_MAT3_ARB: + return TYPE_MATRIX3F; + + case GL_FLOAT_MAT4_ARB: + return TYPE_MATRIX4F; + + /* + * Java 3D does not support the following sampler types: + * + * case GL_SAMPLER_1D_ARB: + * case GL_SAMPLER_1D_SHADOW_ARB: + * case GL_SAMPLER_2D_SHADOW_ARB: + * case GL_SAMPLER_2D_RECT_ARB: + * case GL_SAMPLER_2D_RECT_SHADOW_ARB: + */ + } + + return -1; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: lookupNativeShaderAttrNames + * Signature: (JJI[Ljava/lang/String;[J[I[I[Z)V + */ +JNIEXPORT void JNICALL +Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jint numAttrNames, + jobjectArray attrNames, + jlongArray locArr, + jintArray typeArr, + jintArray sizeArr, + jbooleanArray isArrayArr) +{ + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + GLcharARB **attrNamesString; + jlong *locPtr; + jint *typePtr; + jint *sizePtr; + jboolean *isArrayPtr; + GLint loc; + GLenum type; + GLint size; + GLcharARB *name; + GLint maxStrLen; + int numActiveUniforms; + int i, j; + + JNIEnv table = *env; + + locPtr = (*env)->GetLongArrayElements(env, locArr, NULL); + typePtr = (*env)->GetIntArrayElements(env, typeArr, NULL); + sizePtr = (*env)->GetIntArrayElements(env, sizeArr, NULL); + isArrayPtr = (*env)->GetBooleanArrayElements(env, isArrayArr, NULL); + + /* + * Initialize the name array, also set the loc, type, and size + * arrays to out-of-band values + */ + attrNamesString = (GLcharARB **)malloc(numAttrNames * sizeof(GLcharARB *)); + for (i = 0; i < numAttrNames; i++) { + jstring attrName; + + attrName = (*env)->GetObjectArrayElement(env, attrNames, i); + attrNamesString[i] = (GLcharARB *)strJavaToC(env, attrName); + + locPtr[i] = -1; + typePtr[i] = -1; + sizePtr[i] = -1; + } + + /* + * Loop through the list of active uniform variables, one at a + * time, searching for a match in the attrNames array. + * + * NOTE: Since attrNames isn't sorted, and we don't have a + * hashtable of names to index locations, we will do a + * brute-force, linear search of the array. This leads to an + * O(n^2) algorithm (actually O(n*m) where n is attrNames.length + * and m is the number of uniform variables), but since we expect + * N to be small, we will not optimize this at this time. + */ + glslCtxInfo->pfnglGetObjectParameterivARB((GLhandleARB) shaderProgramId, + GL_OBJECT_ACTIVE_UNIFORMS_ARB, + &numActiveUniforms); + glslCtxInfo->pfnglGetObjectParameterivARB((GLhandleARB) shaderProgramId, + GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, + &maxStrLen); + name = malloc(maxStrLen + 1); + + /* + fprintf(stderr, + "numActiveUniforms = %d, maxStrLen = %d\n", + numActiveUniforms, maxStrLen); + */ + + for (i = 0; i < numActiveUniforms; i++) { + glslCtxInfo->pfnglGetActiveUniformARB((GLhandleARB) shaderProgramId, + i, + maxStrLen, + NULL, + &size, + &type, + name); + /* + fprintf(stderr, + "Uniform[%d] : name = %s, type = %d, size = %d\n", + i, name, type, size); + */ + + /* Now try to find the name */ + for (j = 0; j < numAttrNames; j++) { + if (strcmp(attrNamesString[j], name) == 0) { + sizePtr[j] = (jint)size; + isArrayPtr[j] = (size > 1); + typePtr[j] = glslToJ3dType(type); + break; + } + } + } + + free(name); + + /* Now lookup the location of each name in the attrNames array */ + for (i = 0; i < numAttrNames; i++) { + /* + * Get uniform attribute location + */ + loc = glslCtxInfo->pfnglGetUniformLocationARB((GLhandleARB)shaderProgramId, + attrNamesString[i]); + + /* + fprintf(stderr, + "str = %s, loc = %d\n", + attrNamesString[i], loc); + */ + + locPtr[i] = (jlong)loc; + } + + /* Free the array of strings */ + for (i = 0; i < numAttrNames; i++) { + free(attrNamesString[i]); + } + free(attrNamesString); + + /* Release JNI arrays */ + (*env)->ReleaseLongArrayElements(env, locArr, locPtr, 0); + (*env)->ReleaseIntArrayElements(env, typeArr, typePtr, 0); + (*env)->ReleaseIntArrayElements(env, sizeArr, sizePtr, 0); + (*env)->ReleaseBooleanArrayElements(env, isArrayArr, isArrayPtr, 0); +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: useShaderProgram + * Signature: (JI)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_useShaderProgram( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId) +{ + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglUseProgramObjectARB((GLhandleARB)shaderProgramId); + + ctxProperties->shaderProgramId = shaderProgramId; + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform1i + * Signature: (JJJI)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint value) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Load attribute */ + glslCtxInfo->pfnglUniform1iARB((GLint)location, value); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform1f + * Signature: (JJJF)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloat value) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Load attribute */ + glslCtxInfo->pfnglUniform1fARB((GLint)location, value); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform2i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jint *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetIntArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform2iARB((GLint)location, values[0], values[1]); + + /* Release array values */ + (*env)->ReleaseIntArrayElements(env, varray, values, JNI_ABORT); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform2f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jfloat *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Why shaderProgramId is not needed ? */ + + /* Get array values */ + values = (*env)->GetFloatArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform2fARB((GLint)location, values[0], values[1]); + + /* Release array values */ + (*env)->ReleaseFloatArrayElements(env, varray, values, JNI_ABORT); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform3i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jint *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetIntArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform3iARB((GLint)location, values[0], values[1], values[2]); + + /* Release array values */ + (*env)->ReleaseIntArrayElements(env, varray, values, JNI_ABORT); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform3f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jfloat *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetFloatArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform3fARB((GLint)location, values[0], values[1], values[2]); + + /* Release array values */ + (*env)->ReleaseFloatArrayElements(env, varray, values, JNI_ABORT); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform4i + * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4i( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jintArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jint *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + /* Get array values */ + values = (*env)->GetIntArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform4iARB((GLint)location, values[0], values[1], values[2], values[3]); + + /* Release array values */ + (*env)->ReleaseIntArrayElements(env, varray, values, JNI_ABORT); + + return NULL; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform4f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jfloat *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetFloatArrayElements(env, varray, NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform4fARB((GLint)location, values[0], values[1], values[2], values[3]); + + /* Release array values */ + (*env)->ReleaseFloatArrayElements(env, varray, values, JNI_ABORT); + + return NULL; + +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniformMatrix3f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix3f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jfloat *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetFloatArrayElements(env, varray, NULL); + + /* Load attribute */ + /* transpose is GL_TRUE : each matrix is supplied in row major order */ + glslCtxInfo->pfnglUniformMatrix3fvARB((GLint)location, 1, GL_TRUE, (GLfloat *)values); + + /* Release array values */ + (*env)->ReleaseFloatArrayElements(env, varray, values, JNI_ABORT); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniformMatrix4f + * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix4f( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jfloatArray varray) +{ + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + jfloat *values; + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (*env)->GetFloatArrayElements(env, varray, NULL); + + /* Load attribute */ + /* transpose is GL_TRUE : each matrix is supplied in row major order */ + glslCtxInfo->pfnglUniformMatrix4fvARB((GLint)location, 1, GL_TRUE, (GLfloat *)values); + + /* Release array values */ + (*env)->ReleaseFloatArrayElements(env, varray, values, JNI_ABORT); + + return NULL; +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform1iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1iArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jintArray vArray) +{ + + JNIEnv table = *env; + jint *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jint *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform1ivARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform1fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1fArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform1fvARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform2iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2iArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jintArray vArray) +{ + + JNIEnv table = *env; + jint *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jint *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform2ivARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform2fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2fArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform2fvARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform3iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3iArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jintArray vArray) +{ + + JNIEnv table = *env; + jint *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jint *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform3ivARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform3fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3fArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform3fvARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform4iArray + * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4iArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jintArray vArray) +{ + + JNIEnv table = *env; + jint *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jint *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform4ivARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniform4fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4fArray( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + glslCtxInfo->pfnglUniform4fvARB((GLint)location, length, values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; + +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniformMatrix3fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix3fArray +( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + /* transpose is GL_TRUE : each matrix is supplied in row major order */ + glslCtxInfo->pfnglUniformMatrix3fvARB((GLint)location, length, + GL_TRUE, (GLfloat *)values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; +} + + +/* + * Class: javax_media_j3d_GLSLShaderProgramRetained + * Method: setUniformMatrix4fArray + * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; + */ +JNIEXPORT jobject +JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix4fArray +( + JNIEnv *env, + jobject obj, + jlong ctxInfo, + jlong shaderProgramId, + jlong location, + jint length, + jfloatArray vArray) +{ + + JNIEnv table = *env; + jfloat *values; + + /* We do not need to use shaderProgramId because caller has already called + useShaderProgram(). */ + + GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + /* Get array values */ + values = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, vArray , NULL); + + /* Load attribute */ + /* transpose is GL_TRUE : each matrix is supplied in row major order */ + glslCtxInfo->pfnglUniformMatrix4fvARB((GLint)location, length, + GL_TRUE, (GLfloat *)values); + + /* Release array values */ + (*(table->ReleasePrimitiveArrayCritical))(env, vArray, values, 0); + + return NULL; +} + + +/* + * GLSL vertex attribute functions + */ + +static void +glslVertexAttrPointer( + GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglVertexAttribPointerARB(index+1, size, type, + GL_FALSE, stride, pointer); +} + +static void +glslEnableVertexAttrArray( + GraphicsContextPropertiesInfo *ctxProperties, + int index) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglEnableVertexAttribArrayARB(index+1); +} + +static void +glslDisableVertexAttrArray( + GraphicsContextPropertiesInfo *ctxProperties, + int index) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + + glslCtxInfo->pfnglDisableVertexAttribArrayARB(index+1); +} + +static void +glslVertexAttr1fv( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + +#ifdef VERBOSE + fprintf(stderr, "glslVertexAttr1fv()\n"); +#endif + glslCtxInfo->pfnglVertexAttrib1fvARB(index+1, v); +} + +static void +glslVertexAttr2fv( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + +#ifdef VERBOSE + fprintf(stderr, "glslVertexAttr2fv()\n"); +#endif + glslCtxInfo->pfnglVertexAttrib2fvARB(index+1, v); +} + +static void +glslVertexAttr3fv( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + +#ifdef VERBOSE + fprintf(stderr, "glslVertexAttr3fv()\n"); +#endif + glslCtxInfo->pfnglVertexAttrib3fvARB(index+1, v); +} + +static void +glslVertexAttr4fv( + GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v) +{ + GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; + +#ifdef VERBOSE + fprintf(stderr, "glslVertexAttr4fv()\n"); +#endif + glslCtxInfo->pfnglVertexAttrib4fvARB(index+1, v); +} + diff --git a/src/native/ogl/GeometryArrayRetained.c b/src/native/ogl/GeometryArrayRetained.c index b69324b..9834eae 100644 --- a/src/native/ogl/GeometryArrayRetained.c +++ b/src/native/ogl/GeometryArrayRetained.c @@ -47,24 +47,20 @@ static float EPS = 0.0001f; iaFormat = GL_T2F_C4F_N3F_V3F; break;\ default: \ useInterleavedArrays = 0; break; \ - } - - - -/* This hardcoded value should be fixed for 1.3 */ -#define NUM_TEXTURE_UNITS 64 + } -extern void enableTexCoordPointer(GraphicsContextPropertiesInfo *, int, int, - int, int, void *); -extern void disableTexCoordPointer(GraphicsContextPropertiesInfo *, int); +static void enableTexCoordPointer(GraphicsContextPropertiesInfo *, int, int, + int, int, void *); +static void disableTexCoordPointer(GraphicsContextPropertiesInfo *, int); +static void clientActiveTextureUnit(GraphicsContextPropertiesInfo *, int); /* * texUnitIndex < 0 implies send all texture unit state info in one pass * texUnitIndex >= 0 implies one texture unit state info in one pass using * the underlying texture unit 0 */ -void +static void executeTexture(int texUnitIndex, int texCoordSetMapLen, int texSize, int bstride, int texCoordoff, jint texCoordSetMapOffset[], @@ -143,6 +139,39 @@ executeTexture(int texUnitIndex, int texCoordSetMapLen, } } +static void +resetTexture(jlong ctxInfo) +{ + int i; + + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; + + if(ctxProperties->arb_multitexture) { + /* Disable texture coordinate arrays for all texture units */ + for (i = 0; i < ctxProperties->maxTexCoordSets; i++) { + disableTexCoordPointer(ctxProperties, i); + } + /* Reset client active texture unit to 0 */ + clientActiveTextureUnit(ctxProperties, 0); + } else { + disableTexCoordPointer(ctxProperties, 0); + } +} + + +static void +resetVertexAttrs(jlong ctxInfo, int vertexAttrCount) +{ + int i; + + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; + + /* Disable specified vertex attr arrays */ + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->disableVertexAttrArray(ctxProperties, i); + } +} + /* * glLockArrays() is invoked only for indexed geometry, and the @@ -166,21 +195,23 @@ unlockArray(GraphicsContextPropertiesInfo *ctxProperties) } -void -executeGeometryArray(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint startVIndex, - jint vcount, jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jfloatArray varray, jobject varrayBuffer, jfloatArray carray, - jint texUnitIndex, jint cDirty) +static void +executeGeometryArray( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint startVIndex, + jint vcount, jint vformat, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jint vertexAttrCount, jintArray vertexAttrSizes, + jfloatArray varray, jobject varrayBuffer, jfloatArray carray, + jint texUnitIndex, jint cDirty) { jclass geo_class; JNIEnv table; @@ -210,13 +241,16 @@ executeGeometryArray(JNIEnv *env, jfieldID start_field; GLint *start; int cstride = 0; + int vAttrStride = 0; + int vAttrOff; + jint *vAttrSizesPtr = NULL; table = *env; geo_class = (jclass) (*(table->GetObjectClass))(env, geo); - /* This matches the code in GeometryArrayRetained.java */ stride = coordoff = normoff = coloroff = texCoordoff = 0; + vAttrOff = 0; if ((vformat & GA_COORDINATES) != 0) { stride += 3; } @@ -253,6 +287,20 @@ executeGeometryArray(JNIEnv *env, coordoff += texStride; } + if ((vformat & GA_VERTEX_ATTRIBUTES) != 0) { + if (vertexAttrSizes != NULL) { + vAttrSizesPtr = table->GetIntArrayElements(env, vertexAttrSizes, NULL); + } + for (i = 0; i < vertexAttrCount; i++) { + vAttrStride += vAttrSizesPtr[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + bstride = stride*sizeof(float); /* @@ -277,17 +325,22 @@ executeGeometryArray(JNIEnv *env, } /* begin critical region */ + verts = NULL; if(varray != NULL) { verts = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env, varray, NULL); - if(verts == NULL) - return; } else if(varrayBuffer != NULL) { verts = (jfloat *) (*(table->GetDirectBufferAddress))(env, varrayBuffer ); - if(verts == NULL) - return; } - + if (verts == NULL) { + /* This should never happen */ + fprintf(stderr, "JAVA 3D ERROR : unable to get vertex pointer\n"); + if (vAttrSizesPtr != NULL) { + table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); + } + return; + } + /* using byRef interleaved array and has a separate pointer, then .. */ cstride = stride; if (carray != NULL) { @@ -369,6 +422,17 @@ executeGeometryArray(JNIEnv *env, numActiveTexUnit, texUnitStateMap, startVertex, ctxInfo); } + + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &startVertex[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } } switch (geo_type) { @@ -451,6 +515,17 @@ executeGeometryArray(JNIEnv *env, numActiveTexUnit, texUnitStateMap, startVertex, ctxInfo); } + + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &startVertex[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } } switch (geo_type){ case GEO_TYPE_QUAD_SET : glDrawArrays(GL_QUADS, 0, vcount);break; @@ -465,6 +540,14 @@ executeGeometryArray(JNIEnv *env, glDisable(GL_NORMALIZE); } + if (vformat & GA_VERTEX_ATTRIBUTES) { + resetVertexAttrs(ctxInfo, vertexAttrCount); + } + + if (vformat & GA_TEXTURE_COORDINATE) { + resetTexture(ctxInfo); + } + if (carray != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, carray, clrs, 0); @@ -477,74 +560,104 @@ executeGeometryArray(JNIEnv *env, texUnitStateMap, 0); if(varray != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, varray, verts, 0); + + if (vAttrSizesPtr != NULL) { + table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); + } } -JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint startVIndex, - jint vcount, jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) { - - + +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: execute + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZZIIII[II[II[II[I[F[FII)V + */ +JNIEXPORT void JNICALL +Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint startVIndex, + jint vcount, jint vformat, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jint vertexAttrCount, jintArray vertexAttrSizes, + jfloatArray varray, jfloatArray carray, + jint texUnitIndex, jint cDirty) +{ + +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.execute() -- calling executeGeometryArray\n"); +#endif /* VERBOSE */ + /* call executeGeometryArray */ - executeGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, + executeGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, multiScreen, ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, texUnitStateMapArray, + vertexAttrCount, vertexAttrSizes, varray, NULL, carray, texUnitIndex, cDirty); - + } /* interleaved data with nio buffer as data format */ -JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint startVIndex, - jint vcount, jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) { - +JNIEXPORT void JNICALL +Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint startVIndex, + jint vcount, jint vformat, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jobject varray, jfloatArray carray, + jint texUnitIndex, jint cDirty) +{ + +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.executeInterleavedBuffer() -- calling executeGeometryArray\n"); +#endif /* VERBOSE */ + /* call executeGeometryArray */ executeGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, multiScreen, ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, texUnitStateMapArray, + 0, NULL, NULL, varray, carray, texUnitIndex, cDirty); } + +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: buildGA + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[II[II[I[D[D[F)V + */ JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, - jint geo_type, - jboolean isNonUniformScale, jboolean updateAlpha, float alpha, - jboolean ignoreVertexColors, - jint startVIndex, - jint vcount, jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMapArray, - jint texCoordSetMapLen, - jintArray texUnitOffset, - jdoubleArray xform, jdoubleArray nxform, - jfloatArray varray) + void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, + jint geo_type, + jboolean isNonUniformScale, jboolean updateAlpha, float alpha, + jboolean ignoreVertexColors, + jint startVIndex, + jint vcount, jint vformat, + jint texCoordSetCount, + jintArray texCoordSetMapArray, + jint texCoordSetMapLen, + jintArray texUnitOffset, + jint vertexAttrCount, jintArray vertexAttrSizes, + jdoubleArray xform, jdoubleArray nxform, + jfloatArray varray) { jclass geo_class; JNIEnv table; @@ -554,6 +667,9 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, jint i, j; size_t bstride; jint texStride, *texCoordSetMapOffset; + int vAttrStride = 0; + int vAttrOff; + jint *vAttrSizesPtr = NULL; GLsizei *strips; jfloat vertex[3]; jfloat normal[3]; @@ -569,18 +685,22 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, float color[4]; jdouble *xform_ptr = NULL; jdouble *nxform_ptr = NULL; - jint k; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.buildGA()\n"); +#endif /* VERBOSE */ + table = *env; geo_class = (jclass) (*(table->GetObjectClass))(env, geo); /* This matches the code in GeometryArrayRetained.java */ stride = coordoff = normoff = coloroff = texCoordoff = 0; + vAttrOff = 0; if ((vformat & GA_COORDINATES) != 0) { stride += 3; } @@ -623,6 +743,20 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, coordoff += texStride; } + if ((vformat & GA_VERTEX_ATTRIBUTES) != 0) { + if (vertexAttrSizes != NULL) { + vAttrSizesPtr = table->GetIntArrayElements(env, vertexAttrSizes, NULL); + } + for (i = 0; i < vertexAttrCount; i++) { + vAttrStride += vAttrSizesPtr[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + bstride = stride*sizeof(float); /* Start send down from the startVIndex */ initialOffset = startVIndex * stride; @@ -630,6 +764,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, coloroff += initialOffset; coordoff += initialOffset; texCoordoff += initialOffset; + vAttrOff += initialOffset; /* * process alpha for geometryArray without alpha @@ -740,6 +875,38 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } } + if (vformat & GA_VERTEX_ATTRIBUTES) { + int vaIdx, vaOff; + + vaOff = vAttrOff; + for (vaIdx = 0; vaIdx < vertexAttrCount; vaIdx++) { +#ifdef VERBOSE + fprintf(stderr, "vertexAttrs[%d] = (", vaIdx); + for (k = 0; k < vAttrSizesPtr[vaIdx]; k++) { + fprintf(stderr, "%g, ", + verts[vaOff+k]); + } + fprintf(stderr, ")\n"); +#endif /* VERBOSE */ + switch (vAttrSizesPtr[vaIdx]) { + case 1: + ctxProperties->vertexAttr1fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 2: + ctxProperties->vertexAttr2fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 3: + ctxProperties->vertexAttr3fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 4: + ctxProperties->vertexAttr4fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + } + + vaOff += vAttrSizesPtr[vaIdx]; + } + } + if (vformat & GA_TEXTURE_COORDINATE) { if (texCoordSetMapLen > 0) { @@ -833,6 +1000,7 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", coloroff += stride; coordoff += stride; texCoordoff += stride; + vAttrOff += stride; } glEnd(); } @@ -917,6 +1085,38 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } } + if (vformat & GA_VERTEX_ATTRIBUTES) { + int vaIdx, vaOff; + + vaOff = vAttrOff; + for (vaIdx = 0; vaIdx < vertexAttrCount; vaIdx++) { +#ifdef VERBOSE + fprintf(stderr, "vertexAttrs[%d] = (", vaIdx); + for (k = 0; k < vAttrSizesPtr[vaIdx]; k++) { + fprintf(stderr, "%g, ", + verts[vaOff+k]); + } + fprintf(stderr, ")\n"); +#endif /* VERBOSE */ + switch (vAttrSizesPtr[vaIdx]) { + case 1: + ctxProperties->vertexAttr1fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 2: + ctxProperties->vertexAttr2fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 3: + ctxProperties->vertexAttr3fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + case 4: + ctxProperties->vertexAttr4fv(ctxProperties, vaIdx, &verts[vaOff]); + break; + } + + vaOff += vAttrSizesPtr[vaIdx]; + } + } + if (vformat & GA_TEXTURE_COORDINATE) { if (texCoordSetMapLen > 0) { @@ -1012,13 +1212,14 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", coloroff += stride; coordoff += stride; texCoordoff += stride; + vAttrOff += stride; } glEnd(); } /* Restore the vertex format */ vformat = saveVformat; - + (*(table->ReleasePrimitiveArrayCritical))(env, varray, verts, 0); if (texCoordSetMapLen > 0) @@ -1030,35 +1231,48 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", if (nxform_ptr != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, nxform, nxform_ptr, 0); + + if (vAttrSizesPtr != NULL) { + table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); + } } -void enableTexCoordPointer( +static void +enableTexCoordPointer( GraphicsContextPropertiesInfo *ctxProperties, int texUnit, int texSize, int texDataType, int stride, - void *pointer) { - - if (ctxProperties->arb_multitexture) { - ctxProperties->glClientActiveTextureARB(texUnit + GL_TEXTURE0_ARB); - } + void *pointer) +{ + clientActiveTextureUnit(ctxProperties, texUnit); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(texSize, texDataType, stride, pointer); } - -void disableTexCoordPointer( +static void +disableTexCoordPointer( GraphicsContextPropertiesInfo *ctxProperties, - int texUnit) { + int texUnit) +{ + clientActiveTextureUnit(ctxProperties, texUnit); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} - if (ctxProperties->glClientActiveTextureARB != NULL) { +static void +clientActiveTextureUnit( + GraphicsContextPropertiesInfo *ctxProperties, + int texUnit) +{ + if (ctxProperties->arb_multitexture) { ctxProperties->glClientActiveTextureARB(texUnit + GL_TEXTURE0_ARB); } - glDisableClientState(GL_TEXTURE_COORD_ARRAY); } -void executeGeometryArrayVA( + +static void +executeGeometryArrayVA( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1078,6 +1292,10 @@ void executeGeometryArrayVA( jbyte* bclrs, jint initialNormalIndex, jfloat* norms, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jfloat ** vertexAttrPointer, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -1102,6 +1320,8 @@ void executeGeometryArrayVA( GLint *start; jint coordoff, coloroff, normoff; + jint* initialVAttrIndices; + jint* vAttrSizes; int texSet; jint *texCoordSetMap; jint* initialTexIndices; @@ -1111,10 +1331,15 @@ void executeGeometryArrayVA( jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); table = *env; - + +#ifdef VERBOSE + fprintf(stderr, "executeGeometryArrayVA()\n"); +#endif /* VERBOSE */ + /* Enable normalize for non-uniform scale (which rescale can't handle) */ if (ctxProperties->rescale_normal_ext && isNonUniformScale) { glEnable(GL_NORMALIZE); @@ -1150,9 +1375,31 @@ void executeGeometryArrayVA( glNormalPointer(GL_FLOAT, 0, &(norms[normoff])); } + if (vattrDefined) { + float *pVertexAttrs; + int sz, initIdx; + + vAttrSizes = (jint *) (*(table->GetPrimitiveArrayCritical))(env, vertexAttrSizes, NULL); + initialVAttrIndices = (jint *) (*(table->GetPrimitiveArrayCritical))(env, vertexAttrIndices, NULL); + + for (i = 0; i < vertexAttrCount; i++) { + pVertexAttrs = vertexAttrPointer[i]; + sz = vAttrSizes[i]; + initIdx = initialVAttrIndices[i]; + + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, sz, + GL_FLOAT, 0, + &pVertexAttrs[initIdx * sz]); + } + + (*(table->ReleasePrimitiveArrayCritical))(env, vertexAttrSizes, vAttrSizes, 0); + (*(table->ReleasePrimitiveArrayCritical))(env, vertexAttrIndices, initialVAttrIndices, 0); + } + if (textureDefined) { - int j = 0, tus = 0; + int tus = 0; float *ptexCoords; initialTexIndices = (jint *) (*(table->GetPrimitiveArrayCritical))(env,texindices, NULL); @@ -1194,6 +1441,8 @@ void executeGeometryArrayVA( disableTexCoordPointer(ctxProperties, 0); } } + /* Reset client active texture unit to 0 */ + clientActiveTextureUnit(ctxProperties, 0); } if (geo_type == GEO_TYPE_TRI_STRIP_SET || @@ -1250,15 +1499,26 @@ void executeGeometryArrayVA( } + if (vattrDefined) { + resetVertexAttrs(ctxInfo, vertexAttrCount); + } + if (textureDefined) { + resetTexture(ctxInfo); + (*(table->ReleasePrimitiveArrayCritical))(env, tcoordsetmap, texCoordSetMap, 0); (*(table->ReleasePrimitiveArrayCritical))(env, texindices, initialTexIndices, 0); } } /* execute geometry array with java array format */ -JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: executeVA + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZIIII[F[DI[F[BI[FI[I[I[[FII[II[I[II[Ljava/lang/Object;I)V + */ +JNIEXPORT void JNICALL +Java_javax_media_j3d_GeometryArrayRetained_executeVA( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1278,6 +1538,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( jbyteArray cbdata, jint initialNormalIndex, jfloatArray ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -1302,26 +1566,41 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( jdouble *dverts = NULL; jbyte *bclrs = NULL; jfloat *fclrs = NULL, *norms = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jarray *vaobjs = NULL; + jfloat **vertexAttrPointer = NULL; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jint* texUnitStateMap = NULL; int i; - jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); + if (vattrDefined) { + vaobjs = (jarray *)malloc(vertexAttrCount * sizeof(jarray)); + vertexAttrPointer = (jfloat **)malloc(vertexAttrCount * sizeof(jfloat *)); + + for (i = 0; i < vertexAttrCount; i++) { + vaobjs[i] = (*(table->GetObjectArrayElement))(env, vertexAttrData, i); + } + } + if (textureDefined) { + texobjs = (jarray*)malloc(texCoordMapLength * sizeof(jarray)); + texCoordPointer = (jfloat**)malloc(texCoordMapLength * sizeof(jfloat*)); + for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (*(table->GetObjectArrayElement))(env, texCoords, i); } } + geo_class = (jclass) (*(table->GetObjectClass))(env, geo); - + if (geo_type == GEO_TYPE_TRI_STRIP_SET || geo_type == GEO_TYPE_TRI_FAN_SET || geo_type == GEO_TYPE_LINE_STRIP_SET) { @@ -1337,6 +1616,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( start_field); } + /* Get vertex attribute arrays */ + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + vertexAttrPointer[i] = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env, vaobjs[i], NULL); + } + } + /* get texture arrays */ if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { @@ -1369,16 +1655,36 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( norms = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env,ndata, NULL); } +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.executeVA() -- calling executeGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, multiScreen, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, pass, texCoordMapLength, + norms, + vertexAttrCount, vertexAttrSizes, + vertexAttrIndices, vertexAttrPointer, + pass, texCoordMapLength, tcoordsetmap,numActiveTexUnit, texUnitStateMap, texindices,texStride,texCoordPointer,cdirty, sarray, strip_len, start_array); + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + (*(table->ReleasePrimitiveArrayCritical))(env, vaobjs[i], vertexAttrPointer[i], 0); + } + } + + if (vaobjs != NULL) { + free(vaobjs); + } + if (vertexAttrPointer != NULL) { + free(vertexAttrPointer); + } + if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { if (texCoordPointer[i] != NULL) { @@ -1389,6 +1695,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); } } + + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } if (normalsDefined) { (*env)->ReleasePrimitiveArrayCritical(env, ndata, norms, 0); @@ -1409,12 +1722,15 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( else if (doubleCoordDefined) { (*env)->ReleasePrimitiveArrayCritical(env, vdcoords, dverts, 0); } - } /* execute geometry array with java array format */ -JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: executeVABuffer + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZIIIILjava/lang/Object;ILjava/lang/Object;[F[BILjava/lang/Object;I[I[I[Ljava/lang/Object;II[II[I[II[Ljava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1434,6 +1750,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( jbyteArray cbdata, jint initialNormalIndex, jobject ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -1457,8 +1777,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( jdouble *dverts = NULL ; jbyte *bclrs = NULL; jfloat *fclrs = NULL, *norms = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jarray *vaobjs = NULL; + jfloat **vertexAttrPointer = NULL; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jint* texUnitStateMap = NULL; int i; @@ -1467,10 +1789,22 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); - + if (vattrDefined) { + vaobjs = (jarray *)malloc(vertexAttrCount * sizeof(jarray)); + vertexAttrPointer = (jfloat **)malloc(vertexAttrCount * sizeof(jfloat *)); + + for (i = 0; i < vertexAttrCount; i++) { + vaobjs[i] = (*(table->GetObjectArrayElement))(env, vertexAttrData, i); + } + } + if (textureDefined) { + texobjs = (jarray*)malloc(texCoordMapLength * sizeof(jarray)); + texCoordPointer = (jfloat**)malloc(texCoordMapLength * sizeof(jfloat*)); + for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (*(table->GetObjectArrayElement))(env, texCoords, i); } @@ -1523,6 +1857,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( norms = (jfloat *)(*(table->GetDirectBufferAddress))(env, ndata); } + /* get vertex attr arrays */ + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + vertexAttrPointer[i] = (jfloat *) (*(table->GetDirectBufferAddress))(env, vaobjs[i]); + } + } + /* get texture arrays */ if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { @@ -1537,21 +1878,42 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( } +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.executeVABuffer() -- calling executeGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, multiScreen, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, pass, texCoordMapLength, + norms, + vertexAttrCount, vertexAttrSizes, + vertexAttrIndices, vertexAttrPointer, + pass, texCoordMapLength, tcoordsetmap,numActiveTexUnit, texUnitStateMap, texindices,texStride,texCoordPointer,cdirty, sarray, strip_len, start_array); + if (vaobjs != NULL) { + free(vaobjs); + } + if (vertexAttrPointer != NULL) { + free(vertexAttrPointer); + } + if (textureDefined) { if (texUnitStateMap != NULL) { (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); } } + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } + if(floatColorsDefined && cfdata != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, cfdata, fclrs, 0); else if(byteColorsDefined && cbdata != NULL) @@ -1581,18 +1943,30 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha( } } + +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: setVertexFormat + * Signature: (JIZZI[I)V + */ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( JNIEnv *env, jobject obj, + jlong ctxInfo, jint vformat, jboolean useAlpha, - jboolean ignoreVertexColors, - jlong ctxInfo) { - + jboolean ignoreVertexColors) +{ GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; - + +#ifdef VERBOSE + fprintf(stderr, + "GeometryArrayRetained.setVertexFormat() : vformat = %d\n", + vformat); +#endif /* VERBOSE */ + /* Enable and disable the appropriate pointers */ if (vformat & GA_NORMALS) { glEnableClientState(GL_NORMAL_ARRAY); @@ -1616,7 +1990,6 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( glDisable(GL_GLOBAL_ALPHA_SUN); } } - if (vformat & GA_COORDINATES) { glEnableClientState(GL_VERTEX_ARRAY); @@ -1626,9 +1999,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( } } -JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_GeometryArrayRetained_globalAlphaSUN - (JNIEnv *env, jobject obj, jlong ctxInfo) +JNIEXPORT jboolean JNICALL +Java_javax_media_j3d_GeometryArrayRetained_globalAlphaSUN( + JNIEnv *env, + jobject obj, + jlong ctxInfo) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; @@ -1640,24 +2015,26 @@ jboolean JNICALL Java_javax_media_j3d_GeometryArrayRetained_globalAlphaSUN } - -void executeIndexedGeometryArray(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint initialIndexIndex, - jint indexCount, - jint vertexCount, - jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jfloatArray varray, jobject varrayBuffer, jfloatArray carray, - jint texUnitIndex, jint cDirty, - jintArray indexCoord) +static void +executeIndexedGeometryArray( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint initialIndexIndex, + jint indexCount, + jint vertexCount, + jint vformat, + jint vertexAttrCount, jintArray vertexAttrSizes, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jfloatArray varray, jobject varrayBuffer, jfloatArray carray, + jint texUnitIndex, jint cDirty, + jintArray indexCoord) { jclass geo_class; JNIEnv table; @@ -1685,18 +2062,28 @@ void executeIndexedGeometryArray(JNIEnv *env, jint texSize, texStride, *texCoordSetMapOffset = NULL, *texUnitStateMap = NULL; - + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; int cstride = 0; + int vAttrStride = 0; + int vAttrOff; + jint *vAttrSizesPtr = NULL; + table = *env; - /* fprintf(stderr, "Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry \n");*/ +#ifdef VERBOSE + fprintf(stderr, + "executeIndexedGeometryArray: vertexAttrCount = %d\n", + vertexAttrCount); +#endif /* VERBOSE */ + geo_class = (jclass) (*(table->GetObjectClass))(env, geo); /* This matches the code in GeometryArrayRetained.java */ stride = coordoff = normoff = coloroff = texCoordoff = 0; + vAttrOff = 0; if ((vformat & GA_COORDINATES) != 0) { stride += 3; } @@ -1733,6 +2120,20 @@ void executeIndexedGeometryArray(JNIEnv *env, coordoff += texStride; } + if ((vformat & GA_VERTEX_ATTRIBUTES) != 0) { + if (vertexAttrSizes != NULL) { + vAttrSizesPtr = table->GetIntArrayElements(env, vertexAttrSizes, NULL); + } + for (i = 0; i < vertexAttrCount; i++) { + vAttrStride += vAttrSizesPtr[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + bstride = stride*sizeof(float); /* @@ -1831,13 +2232,24 @@ void executeIndexedGeometryArray(JNIEnv *env, if (vformat & GA_TEXTURE_COORDINATE) { -/* TODO: texCoordoff == 0 ???*/ + /* XXXX: texCoordoff == 0 ???*/ executeTexture(texUnitIndex, texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, numActiveTexUnit, texUnitStateMap, verts, ctxInfo); } + + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &verts[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } } switch (geo_type) { @@ -1923,15 +2335,25 @@ void executeIndexedGeometryArray(JNIEnv *env, if (vformat & GA_TEXTURE_COORDINATE) { -/* TODO: texCoordoff == 0 ???*/ + /* XXXX: texCoordoff == 0 ???*/ executeTexture(texUnitIndex, texCoordSetMapLen, - texSize, bstride, texCoordoff, - texCoordSetMapOffset, - numActiveTexUnit, texUnitStateMap, - verts, ctxInfo); - } - } + texSize, bstride, texCoordoff, + texCoordSetMapOffset, + numActiveTexUnit, texUnitStateMap, + verts, ctxInfo); + } + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &verts[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } + } lockArray(ctxProperties, vertexCount); @@ -1944,7 +2366,15 @@ void executeIndexedGeometryArray(JNIEnv *env, } unlockArray(ctxProperties); - + + if (vformat & GA_VERTEX_ATTRIBUTES) { + resetVertexAttrs(ctxInfo, vertexAttrCount); + } + + if (vformat & GA_TEXTURE_COORDINATE) { + resetTexture(ctxInfo); + } + /* clean up if we turned on normalize */ if (ctxProperties->rescale_normal_ext && isNonUniformScale) { @@ -1965,69 +2395,88 @@ void executeIndexedGeometryArray(JNIEnv *env, if (texUnitStateMap != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, texUnitStateMapArray, texUnitStateMap, 0); + if (vAttrSizesPtr != NULL) { + table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); + } } -JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint initialIndexIndex, - jint indexCount, - jint vertexCount, - jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, - jintArray indexCoord) + +JNIEXPORT void JNICALL +Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint initialIndexIndex, + jint indexCount, + jint vertexCount, + jint vformat, + jint vertexAttrCount, jintArray vertexAttrSizes, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jfloatArray varray, jfloatArray carray, + jint texUnitIndex, jint cDirty, + jintArray indexCoord) { + +#ifdef VERBOSE + fprintf(stderr, "IndexedGeometryArrayRetained.executeIndexedGeometry() -- calling executeIndexedGeometryArray\n"); +#endif /* VERBOSE */ + executeIndexedGeometryArray(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, useAlpha, multiScreen, - ignoreVertexColors, - initialIndexIndex, - indexCount, - vertexCount, - vformat, - texCoordSetCount, - texCoordSetMap, texCoordSetMapLen, - texUnitOffset, - numActiveTexUnit, - texUnitStateMapArray, - varray, NULL, carray, - texUnitIndex, cDirty, - indexCoord); + isNonUniformScale, useAlpha, multiScreen, + ignoreVertexColors, + initialIndexIndex, + indexCount, + vertexCount, + vformat, + vertexAttrCount, vertexAttrSizes, + texCoordSetCount, + texCoordSetMap, texCoordSetMapLen, + texUnitOffset, + numActiveTexUnit, + texUnitStateMapArray, + varray, NULL, carray, + texUnitIndex, cDirty, + indexCoord); } -JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, - jboolean ignoreVertexColors, - jint initialIndexIndex, - jint indexCount, - jint vertexCount, - jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMap, jint texCoordSetMapLen, - jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray texUnitStateMapArray, - jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, - jintArray indexCoord) +JNIEXPORT void JNICALL +Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, jint geo_type, + jboolean isNonUniformScale, jboolean useAlpha, + jboolean multiScreen, + jboolean ignoreVertexColors, + jint initialIndexIndex, + jint indexCount, + jint vertexCount, + jint vformat, + jint texCoordSetCount, + jintArray texCoordSetMap, jint texCoordSetMapLen, + jintArray texUnitOffset, + jint numActiveTexUnit, + jintArray texUnitStateMapArray, + jobject varray, jfloatArray carray, + jint texUnitIndex, jint cDirty, + jintArray indexCoord) { + +#ifdef VERBOSE + fprintf(stderr, "IndexedGeometryArrayRetained.executeIndexedGeometryBuffer() -- calling executeIndexedGeometryArray\n"); +#endif /* VERBOSE */ + executeIndexedGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, multiScreen, ignoreVertexColors, initialIndexIndex, indexCount, vertexCount, - vformat, + vformat, + 0, NULL, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, @@ -2039,7 +2488,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } -void executeIndexedGeometryArrayVA( +static void +executeIndexedGeometryArrayVA( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2058,6 +2508,9 @@ void executeIndexedGeometryArrayVA( jfloat* fclrs, jbyte* bclrs, jfloat* norms, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jfloat ** vertexAttrPointer, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -2069,7 +2522,7 @@ void executeIndexedGeometryArrayVA( jintArray indexCoord, jarray sarray, jsize strip_len) - { +{ int primType; JNIEnv table; jint i; @@ -2083,6 +2536,7 @@ void executeIndexedGeometryArrayVA( jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; @@ -2091,9 +2545,17 @@ void executeIndexedGeometryArrayVA( int texSet; jint *texCoordSetMap, *texUnitStateMap; GLsizei *countArray; + jint* vAttrSizes; jint offset = 0; + table = *env; +#ifdef VERBOSE + fprintf(stderr, + "executeIndexedGeometryArrayVA: vertexAttrCount = %d\n", + vertexAttrCount); +#endif /* VERBOSE */ + /* Enable normalize for non-uniform scale (which rescale can't handle) */ if (ctxProperties->rescale_normal_ext && isNonUniformScale) { glEnable(GL_NORMALIZE); @@ -2122,9 +2584,28 @@ void executeIndexedGeometryArrayVA( glNormalPointer(GL_FLOAT, 0, norms); } + if (vattrDefined) { + float *pVertexAttrs; + int sz; + + vAttrSizes = (jint *) (*(table->GetPrimitiveArrayCritical))(env, vertexAttrSizes, NULL); + + for (i = 0; i < vertexAttrCount; i++) { + pVertexAttrs = vertexAttrPointer[i]; + sz = vAttrSizes[i]; + + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, sz, + GL_FLOAT, 0, + pVertexAttrs); + } + + (*(table->ReleasePrimitiveArrayCritical))(env, vertexAttrSizes, vAttrSizes, 0); + } + if (textureDefined) { - int j = 0, tus = 0; + int tus = 0; float *ptexCoords; texCoordSetMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tcoordsetmap, NULL); @@ -2164,6 +2645,8 @@ void executeIndexedGeometryArrayVA( */ } } + /* Reset client active texture unit to 0 */ + clientActiveTextureUnit(ctxProperties, 0); } indices = (jint *) (*(table->GetPrimitiveArrayCritical))(env, indexCoord, NULL); @@ -2237,7 +2720,13 @@ void executeIndexedGeometryArrayVA( (*(table->ReleasePrimitiveArrayCritical))(env, indexCoord, indices, 0); + if (vattrDefined) { + resetVertexAttrs(ctxInfo, vertexAttrCount); + } + if (textureDefined) { + resetTexture(ctxInfo); + (*(table->ReleasePrimitiveArrayCritical))(env, tcoordsetmap, texCoordSetMap, 0); if (texUnitStateMap != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); @@ -2265,6 +2754,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jfloatArray cfdata, jbyteArray cbdata, jfloatArray ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -2286,23 +2778,41 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jdouble *dverts = NULL; jbyte *bclrs = NULL; jfloat *fclrs = NULL, *norms = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jarray *vaobjs = NULL; + jfloat **vertexAttrPointer = NULL; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); + table = *env; - geo_class = (jclass) (*(table->GetObjectClass))(env, geo); + + if (vattrDefined) { + vaobjs = (jarray *)malloc(vertexAttrCount * sizeof(jarray)); + vertexAttrPointer = (jfloat **)malloc(vertexAttrCount * sizeof(jfloat *)); + + for (i = 0; i < vertexAttrCount; i++) { + vaobjs[i] = (*(table->GetObjectArrayElement))(env, vertexAttrData, i); + } + } if (textureDefined) { + texobjs = (jarray*)malloc(texCoordMapLength * sizeof(jarray)); + texCoordPointer = (jfloat**)malloc(texCoordMapLength * sizeof(jfloat*)); + for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (jarray)(*(table->GetObjectArrayElement))(env, texCoords, i); } } + + geo_class = (jclass) (*(table->GetObjectClass))(env, geo); + if (geo_type == GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GEO_TYPE_INDEXED_TRI_FAN_SET || geo_type == GEO_TYPE_INDEXED_LINE_STRIP_SET) { @@ -2313,7 +2823,15 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo strip_len = (jsize)(*(table->GetArrayLength))(env, sarray); } - /* get texture arrays */ + + /* Get vertex attribute arrays */ + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + vertexAttrPointer[i] = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env, vaobjs[i], NULL); + } + } + + /* get texture arrays */ if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { if (texobjs[i] != NULL) @@ -2343,6 +2861,10 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo norms = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env,ndata, NULL); } +#ifdef VERBOSE + fprintf(stderr, "IndexedGeometryArrayRetained.executeIndexedGeometryVA() -- calling executeIndexedGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeIndexedGeometryArrayVA(env, obj, ctxInfo, @@ -2361,6 +2883,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo fclrs, bclrs, norms, + vertexAttrCount, + vertexAttrSizes, + vertexAttrPointer, pass, texCoordMapLength, tcoordsetmap, @@ -2391,6 +2916,19 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo (*(table->ReleasePrimitiveArrayCritical))(env, ndata, norms, 0); } + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + (*(table->ReleasePrimitiveArrayCritical))(env, vaobjs[i], vertexAttrPointer[i], 0); + } + } + + if (vaobjs != NULL) { + free(vaobjs); + } + if (vertexAttrPointer != NULL) { + free(vertexAttrPointer); + } + if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { if (texCoordPointer[i] != NULL) { @@ -2398,6 +2936,13 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } } } + + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } } JNIEXPORT @@ -2420,6 +2965,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jfloatArray cfdata, jbyteArray cbdata, jobject ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jobjectArray vertexAttrData, jint pass, jint texCoordMapLength, jintArray tcoordsetmap, @@ -2441,23 +2989,38 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jdouble *dverts = NULL; jbyte *bclrs = NULL; jfloat *fclrs = NULL, *norms = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jarray *vaobjs = NULL; + jfloat **vertexAttrPointer = NULL; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); - table = *env; - geo_class = (jclass) (*(table->GetObjectClass))(env, geo); - + + table = *env; + + if (vattrDefined) { + vaobjs = (jarray *)malloc(vertexAttrCount * sizeof(jarray)); + vertexAttrPointer = (jfloat **)malloc(vertexAttrCount * sizeof(jfloat *)); + + for (i = 0; i < vertexAttrCount; i++) { + vaobjs[i] = (*(table->GetObjectArrayElement))(env, vertexAttrData, i); + } + } + if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (jarray)(*(table->GetObjectArrayElement))(env, texCoords, i); } } + + geo_class = (jclass) (*(table->GetObjectClass))(env, geo); + if (geo_type == GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GEO_TYPE_INDEXED_TRI_FAN_SET || geo_type == GEO_TYPE_INDEXED_LINE_STRIP_SET) { @@ -2468,6 +3031,14 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo strip_len = (jsize)(*(table->GetArrayLength))(env, sarray); } + + /* Get vertex attribute arrays */ + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + vertexAttrPointer[i] = (jfloat *) (*(table->GetDirectBufferAddress))(env, vaobjs[i]); + } + } + /* get texture arrays */ if (textureDefined) { for (i = 0; i < texCoordMapLength; i++) { @@ -2478,14 +3049,14 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } } - + /* get coordinate array */ if (floatCoordDefined) { fverts= (jfloat *)(*(table->GetDirectBufferAddress))(env, vcoords ); } else if (doubleCoordDefined) { dverts= (jdouble *)(*(table->GetDirectBufferAddress))(env, vcoords ); } - + /* get color array */ if (floatColorsDefined) { if(cfdata != NULL) @@ -2499,12 +3070,16 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo else bclrs = (jbyte *)(*(table->GetDirectBufferAddress))(env, cdataBuffer); } - + /* get normal array */ if (normalsDefined) { norms = (jfloat *)(*(table->GetDirectBufferAddress))(env, ndata); } +#ifdef VERBOSE + fprintf(stderr, "IndexedGeometryArrayRetained.executeIndexedGeometryVABuffer() -- calling executeIndexedGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeIndexedGeometryArrayVA(env, obj, ctxInfo, @@ -2523,6 +3098,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo fclrs, bclrs, norms, + vertexAttrCount, + vertexAttrSizes, + vertexAttrPointer, pass, texCoordMapLength, tcoordsetmap, @@ -2539,26 +3117,42 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo (*(table->ReleasePrimitiveArrayCritical))(env, cfdata, fclrs, 0); else if(byteColorsDefined && cbdata != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, cbdata, bclrs, 0); + + if (vaobjs != NULL) { + free(vaobjs); + } + if (vertexAttrPointer != NULL) { + free(vertexAttrPointer); + } + + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } } -JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, - jint geo_type, - jboolean isNonUniformScale, jboolean updateAlpha, float alpha, - jboolean ignoreVertexColors, - jint initialIndexIndex, - jint validIndexCount, - jint vertexCount, - jint vformat, - jint texCoordSetCount, - jintArray texCoordSetMapArray, - jint texCoordSetMapLen, - jintArray texUnitOffset, - jdoubleArray xform, jdoubleArray nxform, - jfloatArray varray, jintArray indexCoord) +JNIEXPORT void JNICALL +Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( + JNIEnv *env, + jobject obj, jlong ctxInfo, jobject geo, + jint geo_type, + jboolean isNonUniformScale, jboolean updateAlpha, float alpha, + jboolean ignoreVertexColors, + jint initialIndexIndex, + jint validIndexCount, + jint vertexCount, + jint vformat, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jint texCoordSetCount, + jintArray texCoordSetMapArray, + jint texCoordSetMapLen, + jintArray texUnitOffset, + jdoubleArray xform, jdoubleArray nxform, + jfloatArray varray, jintArray indexCoord) { - jclass geo_class; JNIEnv table; jboolean useAlpha = JNI_FALSE; @@ -2566,7 +3160,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome jfloat *verts; jint *indices; jint i; - size_t bstride; + size_t bstride; jint texStride, *texCoordSetMapOffset, texSize; GLsizei *countArray; GLenum iaFormat; @@ -2584,15 +3178,23 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome jint** multiDrawElementsIndices = NULL; jint allocated = 0; int offset = 0; + int vAttrStride = 0; + int vAttrOff; + jint *vAttrSizesPtr = NULL; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; - + +#ifdef VERBOSE + fprintf(stderr, "IndexedGeometryArrayRetained.buildIndexedGeometry()\n"); +#endif /* VERBOSE */ + table = *env; geo_class = (jclass) (*(table->GetObjectClass))(env, geo); /* This matches the code in GeometryArrayRetained.java */ stride = coordoff = normoff = coloroff = texCoordoff = 0; + vAttrOff = 0; if ((vformat & GA_COORDINATES) != 0) { glEnableClientState(GL_VERTEX_ARRAY); stride += 3; @@ -2600,6 +3202,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome else { glDisableClientState(GL_VERTEX_ARRAY); } + if ((vformat & GA_NORMALS) != 0) { glEnableClientState(GL_NORMAL_ARRAY); stride += 3; @@ -2618,6 +3221,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome else { glDisableClientState(GL_COLOR_ARRAY); } + if ((vformat & GA_TEXTURE_COORDINATE) != 0) { if ((vformat & GA_TEXTURE_COORDINATE_2) != 0) { texSize = 2; @@ -2635,6 +3239,20 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome coordoff += texStride; } + if ((vformat & GA_VERTEX_ATTRIBUTES) != 0) { + if (vertexAttrSizes != NULL) { + vAttrSizesPtr = table->GetIntArrayElements(env, vertexAttrSizes, NULL); + } + for (i = 0; i < vertexAttrCount; i++) { + vAttrStride += vAttrSizesPtr[i]; + } + stride += vAttrStride; + normoff += vAttrStride; + coloroff += vAttrStride; + coordoff += vAttrStride; + texCoordoff += vAttrStride; + } + bstride = stride*sizeof(float); /* @@ -2798,7 +3416,18 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome texCoordSetMapOffset, texCoordSetMapLen, NULL, verts, ctxInfo); - } + } + + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &verts[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } } switch (geo_type) { @@ -2910,6 +3539,17 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome texCoordSetMapLen, NULL, verts, ctxInfo); } + + if (vformat & GA_VERTEX_ATTRIBUTES) { + jfloat *vAttrPtr = &verts[vAttrOff]; + + for (i = 0; i < vertexAttrCount; i++) { + ctxProperties->enableVertexAttrArray(ctxProperties, i); + ctxProperties->vertexAttrPointer(ctxProperties, i, vAttrSizesPtr[i], + GL_FLOAT, bstride, vAttrPtr); + vAttrPtr += vAttrSizesPtr[i]; + } + } } lockArray(ctxProperties, vertexCount); switch (geo_type){ @@ -2922,6 +3562,14 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome unlockArray(ctxProperties); + if (vformat & GA_VERTEX_ATTRIBUTES) { + resetVertexAttrs(ctxInfo, vertexAttrCount); + } + + if (vformat & GA_TEXTURE_COORDINATE) { + resetTexture(ctxInfo); + } + if (tmpNormalArray != NULL) { free(tmpNormalArray); } @@ -2943,12 +3591,20 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome if (nxform_ptr != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, nxform, nxform_ptr, 0); + + if (vAttrSizesPtr != NULL) { + table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); + } } /* execute geometry array with java array format */ -JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( +/* + * Class: javax_media_j3d_GeometryArrayRetained + * Method: buildGAForByRef + * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[F[DI[F[BI[FI[I[I[[FI[I[II[Ljava/lang/Object;[D[D)V + */ +JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2969,6 +3625,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( jbyteArray cbdata, jint initialNormalIndex, jfloatArray ndata, + jint vertexAttrCount, + jintArray vertexAttrSizes, + jintArray vertexAttrIndices, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jintArray texindices, @@ -2998,22 +3658,39 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( jfloat* fvptr = NULL, *nptr = NULL, *fcptr = NULL; jdouble* dvptr = NULL; jbyte* bcptr = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jarray *vaobjs = NULL; + jfloat **vertexAttrPointer = NULL; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jint *tunitstatemap = NULL; + int offset = 0; + jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); jboolean byteColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_BYTE) != 0); jboolean normalsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_NORMAL_FLOAT) != 0); + jboolean vattrDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_VATTR_FLOAT) != 0); jboolean textureDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_TEXCOORD_FLOAT) != 0); - int offset = 0; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; table = *env; + + if (vattrDefined) { + vaobjs = (jarray *)malloc(vertexAttrCount * sizeof(jarray)); + vertexAttrPointer = (jfloat **)malloc(vertexAttrCount * sizeof(jfloat *)); + + for (i = 0; i < vertexAttrCount; i++) { + vaobjs[i] = (*(table->GetObjectArrayElement))(env, vertexAttrData, i); + } + } + if (textureDefined) { + texobjs = (jarray*)malloc(texCoordMapLength * sizeof(jarray)); + texCoordPointer = (jfloat**)malloc(texCoordMapLength * sizeof(jfloat*)); + for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (*(table->GetObjectArrayElement))(env, texCoords, i); } @@ -3051,6 +3728,14 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( floatColorsDefined = JNI_FALSE; byteColorsDefined = JNI_FALSE; } + + /* get vertex attr arrays */ + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + vertexAttrPointer[i] = (jfloat *) (*(table->GetPrimitiveArrayCritical))(env, vaobjs[i], NULL); + } + } + /* get texture arrays */ if (textureDefined) { tunitstatemap = (int *)malloc(texCoordMapLength * sizeof(int)); @@ -3078,7 +3763,6 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( glDisableClientState(GL_VERTEX_ARRAY); } - /* get color array */ if (floatColorsDefined) { glEnableClientState(GL_COLOR_ARRAY); @@ -3225,15 +3909,37 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( vformat |= GA_WITH_ALPHA; } + +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.buildGAForByRef() -- calling executeGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, JNI_FALSE, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fvptr, dvptr, initialColorIndex, fcptr, bcptr, initialNormalIndex, - nptr, -1, texCoordMapLength, + nptr, + vertexAttrCount, vertexAttrSizes, + vertexAttrIndices, vertexAttrPointer, + -1, texCoordMapLength, tcoordsetmap, texCoordMapLength, tunitstatemap, texindices,texStride,texCoordPointer,0, sarray, strip_len, start_array); + + if (vattrDefined) { + for (i = 0; i < vertexAttrCount; i++) { + (*(table->ReleasePrimitiveArrayCritical))(env, vaobjs[i], vertexAttrPointer[i], 0); + } + } + + if (vaobjs != NULL) { + free(vaobjs); + } + if (vertexAttrPointer != NULL) { + free(vertexAttrPointer); + } + if (textureDefined) { if (tunitstatemap != NULL) { free(tunitstatemap); @@ -3245,6 +3951,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( } } + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } + if (normalsDefined) { (*env)->ReleasePrimitiveArrayCritical(env, ndata, norms, 0); if (tmpNormalArray != NULL) { @@ -3282,6 +3995,8 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( } +/* NOTE: NIO buffers are no longer supported in display lists. */ +#if 0 /* execute geometry array with java array format */ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( @@ -3332,8 +4047,8 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( jfloat* fvptr = NULL, *nptr = NULL, *fcptr = NULL; jdouble* dvptr = NULL; jbyte* bcptr = NULL; - jfloat* texCoordPointer[NUM_TEXTURE_UNITS]; - jarray texobjs[NUM_TEXTURE_UNITS]; + jfloat **texCoordPointer = NULL; + jarray *texobjs = NULL; jint *tunitstatemap = NULL; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); @@ -3347,7 +4062,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( jlong ctx = ctxProperties->context; table = *env; + if (textureDefined) { + texobjs = (jarray*)malloc(texCoordMapLength * sizeof(jarray)); + texCoordPointer = (jfloat**)malloc(texCoordMapLength * sizeof(jfloat*)); + for (i = 0; i < texCoordMapLength; i++) { texobjs[i] = (*(table->GetObjectArrayElement))(env, texCoords, i); } @@ -3416,6 +4135,9 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( if(fverts == NULL && dverts == NULL) { return; } + + /* TODO KCR : get vertex attr arrays */ + /* get color array */ if (floatColorsDefined) { glEnableClientState(GL_COLOR_ARRAY); @@ -3556,12 +4278,20 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( vformat |= GA_WITH_ALPHA; } + +#ifdef VERBOSE + fprintf(stderr, "GeometryArrayRetained.buildGAForBuffer() -- calling executeGeometryArrayVA\n"); +#endif /* VERBOSE */ + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, JNI_FALSE, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fvptr, dvptr, initialColorIndex, fcptr, bcptr, initialNormalIndex, - nptr, -1, texCoordMapLength, + nptr, + /* TODO: vertexAttrCount, vertexAttrSizes, */ + /* TODO: vertexAttrIndices, vertexAttrPointer, */ + -1, texCoordMapLength, tcoordsetmap, texCoordMapLength, tunitstatemap, texindices,texStride,texCoordPointer,0, sarray, strip_len, start_array); if (textureDefined) { @@ -3575,6 +4305,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( } } + if (texobjs != NULL) { + free(texobjs); + } + if (texCoordPointer != NULL) { + free(texCoordPointer); + } + if (tmpNormalArray != NULL) { free(tmpNormalArray); } @@ -3596,4 +4333,5 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( } } +#endif /* 0 */ diff --git a/src/native/ogl/GraphicsContext3D.c b/src/native/ogl/GraphicsContext3D.c index bdff363..b3772dd 100644 --- a/src/native/ogl/GraphicsContext3D.c +++ b/src/native/ogl/GraphicsContext3D.c @@ -15,6 +15,9 @@ #include "gldefs.h" +extern void throwAssert(JNIEnv *env, char *str); + + JNIEXPORT void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -79,9 +82,11 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( case FORMAT_BYTE_LA: gltype = GL_LUMINANCE_ALPHA; break; + case FORMAT_BYTE_GRAY: case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + default: + throwAssert(env, "illegal format"); break; } byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, diff --git a/src/native/ogl/MasterControl.c b/src/native/ogl/MasterControl.c index 03cb380..a7ce163 100644 --- a/src/native/ogl/MasterControl.c +++ b/src/native/ogl/MasterControl.c @@ -32,7 +32,7 @@ #include <winbase.h> #endif /* WIN32 */ -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #include <unistd.h> #ifdef SOLARIS #include <thread.h> @@ -65,7 +65,7 @@ extern Bool XPanoramiXQueryExtension(Display *dpy, int *event_base, int *error_base); #endif /* SOLARIS && __sparc */ -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ /* defined in Canvas3D.c */ extern int isExtensionSupported(const char *allExtensions, @@ -174,9 +174,9 @@ DWORD countBits(DWORD mask) JNIEXPORT jint JNICALL Java_javax_media_j3d_MasterControl_getNumberOfProcessor (JNIEnv *env, jobject obj) { -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) return sysconf(_SC_NPROCESSORS_ONLN); -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ #ifdef WIN32 SYSTEM_INFO sysInfo; @@ -205,9 +205,9 @@ Java_javax_media_j3d_MasterControl_getThreadConcurrency(JNIEnv *env, return (jint) thr_getconcurrency(); #endif /* SOLARIS */ -#ifdef __linux__ +#ifdef LINUX return -1; -#endif /* __linux__ */ +#endif /* LINUX */ #ifdef WIN32 return -1; @@ -233,9 +233,9 @@ Java_javax_media_j3d_MasterControl_setThreadConcurrency(JNIEnv *env, /* No-op on windows */ #endif /* WIN32 */ -#ifdef __linux__ +#ifdef LINUX /* No-op on linux */ -#endif /* __linux__ */ +#endif /* LINUX */ } @@ -254,7 +254,7 @@ jint JNICALL Java_javax_media_j3d_MasterControl_getMaximumLights( return 8; #endif /* WIN32 */ -#ifdef __linux__ +#ifdef LINUX return 8; -#endif /* __linux__ */ +#endif /* LINUX */ } diff --git a/src/native/ogl/NativeAPIInfo.c b/src/native/ogl/NativeAPIInfo.c index e0559ed..5554dec 100644 --- a/src/native/ogl/NativeAPIInfo.c +++ b/src/native/ogl/NativeAPIInfo.c @@ -19,6 +19,7 @@ #include <jni.h> #include "javax_media_j3d_MasterControl.h" +#include "javax_media_j3d_NativeAPIInfo.h" JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI( @@ -32,7 +33,7 @@ jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI( return (jint)javax_media_j3d_MasterControl_RENDER_OPENGL_SOLARIS; #endif /* SOLARIS */ -#ifdef __linux__ +#ifdef LINUX return (jint)javax_media_j3d_MasterControl_RENDER_OPENGL_LINUX; -#endif /* __linux__ */ +#endif /* LINUX */ } diff --git a/src/native/ogl/NativeConfigTemplate3D.c b/src/native/ogl/NativeConfigTemplate3D.c index db14ba1..dd621ac 100644 --- a/src/native/ogl/NativeConfigTemplate3D.c +++ b/src/native/ogl/NativeConfigTemplate3D.c @@ -16,7 +16,7 @@ * of the Java 3D API. */ -#if defined(__linux__) +#if defined(LINUX) #define _GNU_SOURCE 1 #endif @@ -26,7 +26,7 @@ #include "gldefs.h" -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -43,41 +43,105 @@ extern int isExtensionSupported(const char *allExtensions, const char *extension /* by MIK OF CLASSX */ extern jboolean getJavaBoolEnv(JNIEnv *env, char* envStr); -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* Fix for issue 20 */ #define MAX_GLX_ATTRS_LENGTH 100 + GLXFBConfig *find_S_FBConfigs(jlong display, jint screen, int* glxAttrs, - int sVal, int sIndex) { + int stencilVal, + int sIndex) { + GLXFBConfig *fbConfigList = NULL; int numFBConfigs, index; MYPFNGLXCHOOSEFBCONFIG pGLXChooseFbConfig = NULL; + GLboolean userReq = GL_TRUE; pGLXChooseFbConfig = (MYPFNGLXCHOOSEFBCONFIG) dlsym(RTLD_DEFAULT, "glXChooseFBConfig"); J3D_ASSERT((sIndex+3) < MAX_GLX_ATTRS_LENGTH); + + /* if user not use stencil we will request one of internal use. */ + if (stencilVal < 1) { + userReq = GL_FALSE; + stencilVal = 1; + } + + index = sIndex; + glxAttrs[index++] = GLX_STENCIL_SIZE; + glxAttrs[index++] = stencilVal; + glxAttrs[index] = None; + + fbConfigList = pGLXChooseFbConfig((Display*)display, screen, + glxAttrs, &numFBConfigs); + + + if(fbConfigList != NULL) { + return fbConfigList; + } + + /* + fprintf(stderr, "Stencil : find_S_FBConfigs (TRY 1): FAIL -- stencilVal = %d\n", + stencilVal); + */ + + if (userReq == GL_TRUE) { + /* fprintf(stderr, " userReq : *** FAILED ***\n"); */ + return NULL; + } + + index = sIndex; + glxAttrs[index] = None; + + fbConfigList = pGLXChooseFbConfig((Display*)display, screen, + glxAttrs, &numFBConfigs); + + + if(fbConfigList != NULL) { + return fbConfigList; + } + + /* + fprintf(stderr, "Stencil : find_S_FBConfigs (TRY 2): FAIL -- stencilVal = %d\n", + stencilVal); + */ + + return NULL; + +} + +GLXFBConfig *find_S_S_FBConfigs(jlong display, + jint screen, + int* glxAttrs, + int stereoVal, + int stencilVal, + int sIndex) { + + GLXFBConfig *fbConfigList = NULL; + int numFBConfigs, index; + + J3D_ASSERT((sIndex+3) < MAX_GLX_ATTRS_LENGTH); - if (sVal == REQUIRED || sVal== PREFERRED) { + if (stereoVal == REQUIRED || stereoVal== PREFERRED) { index = sIndex; glxAttrs[index++] = GLX_STEREO; glxAttrs[index++] = True; glxAttrs[index] = None; + + fbConfigList = find_S_FBConfigs(display, screen, glxAttrs, stencilVal, index); - fbConfigList = pGLXChooseFbConfig((Display*)display, screen, - glxAttrs, &numFBConfigs); - if(fbConfigList != NULL) { return fbConfigList; } } - if (sVal == UNNECESSARY || sVal== PREFERRED) { + if (stereoVal == UNNECESSARY || stereoVal== PREFERRED) { /* This is a workaround to BugId : 5106472 in Solaris OGL. We can't set glxAttrs with GLX_STEREO follow by a boolean */ @@ -87,7 +151,7 @@ GLXFBConfig *find_S_FBConfigs(jlong display, /* For debug only { int i=0; - fprintf(stderr, "find_S_FBConfigs sVal = %d\n", sVal); + fprintf(stderr, "find_S_S_FBConfigs stereoVal = %d\n", stereoVal); while(glxAttrs[i] != None) { fprintf(stderr, "glxAttrs[%d] = %x", i, glxAttrs[i]); @@ -97,22 +161,25 @@ GLXFBConfig *find_S_FBConfigs(jlong display, } } */ - fbConfigList = pGLXChooseFbConfig((Display*)display, screen, - glxAttrs, &numFBConfigs); - + + fbConfigList = find_S_FBConfigs(display, screen, glxAttrs, stencilVal, index); + if(fbConfigList != NULL) { return fbConfigList; } } - if (sVal == UNNECESSARY) { + if (stereoVal == UNNECESSARY) { index = sIndex; glxAttrs[index++] = GLX_STEREO; glxAttrs[index++] = True; glxAttrs[index] = None; - fbConfigList = pGLXChooseFbConfig((Display*)display, screen, - glxAttrs, &numFBConfigs); + /* + fbConfigList = pGLXChooseFbConfig((Display*)display, screen, + glxAttrs, &numFBConfigs); + */ + fbConfigList = find_S_FBConfigs(display, screen, glxAttrs, stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; @@ -122,11 +189,13 @@ GLXFBConfig *find_S_FBConfigs(jlong display, return NULL; } -GLXFBConfig *find_AA_S_FBConfigs(jlong display, - jint screen, - int* glxAttrs, - int sVal, - int antialiasVal, int antialiasIndex) { +GLXFBConfig *find_AA_S_S_FBConfigs(jlong display, + jint screen, + int* glxAttrs, + int stereoVal, + int antialiasVal, + int stencilVal, + int antialiasIndex) { const char *glxExtensions = NULL; GLXFBConfig *fbConfigList = NULL; @@ -151,10 +220,10 @@ GLXFBConfig *find_AA_S_FBConfigs(jlong display, glxAttrs[index] = None; for(i=0; i < SAMPLE_LENGTH; i++) { - /* fprintf(stderr, "find_AA_S_FBConfigs samples = %d\n", samples[i]); */ + /* fprintf(stderr, "find_AA_S_S_FBConfigs samples = %d\n", samples[i]); */ glxAttrs[samplesIndex] = samples[i]; - fbConfigList = find_S_FBConfigs(display, screen, - glxAttrs, sVal, index); + fbConfigList = find_S_S_FBConfigs(display, screen, glxAttrs, stereoVal, + stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; @@ -173,8 +242,8 @@ GLXFBConfig *find_AA_S_FBConfigs(jlong display, glxAttrs[index++] = 8; glxAttrs[index] = None; - fbConfigList = find_S_FBConfigs(display, screen, - glxAttrs, sVal, index); + fbConfigList = find_S_S_FBConfigs(display, screen, glxAttrs, + stereoVal, stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; @@ -184,8 +253,8 @@ GLXFBConfig *find_AA_S_FBConfigs(jlong display, glxAttrs[antialiasIndex] = None; if (antialiasVal == UNNECESSARY || antialiasVal == PREFERRED) { - fbConfigList = find_S_FBConfigs(display, screen, - glxAttrs, sVal, index); + fbConfigList = find_S_S_FBConfigs(display, screen, glxAttrs, + stereoVal, stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; @@ -198,11 +267,13 @@ GLXFBConfig *find_AA_S_FBConfigs(jlong display, } -GLXFBConfig *find_DB_AA_S_FBConfigs(jlong display, +GLXFBConfig *find_DB_AA_S_S_FBConfigs(jlong display, jint screen, int* glxAttrs, - int sVal, int dbVal, - int antialiasVal, int dbIndex) { + int stereoVal, int dbVal, + int antialiasVal, + int stencilVal, + int dbIndex) { GLXFBConfig *fbConfigList = NULL; int index = dbIndex; @@ -216,9 +287,9 @@ GLXFBConfig *find_DB_AA_S_FBConfigs(jlong display, glxAttrs[index++] = True; glxAttrs[index] = None; - fbConfigList = find_AA_S_FBConfigs(display, screen, - glxAttrs, sVal, - antialiasVal, index); + fbConfigList = find_AA_S_S_FBConfigs(display, screen, glxAttrs, + stereoVal, antialiasVal, + stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; @@ -230,31 +301,31 @@ GLXFBConfig *find_DB_AA_S_FBConfigs(jlong display, glxAttrs[index++] = GLX_DOUBLEBUFFER; glxAttrs[index++] = False; glxAttrs[index] = None; - - fbConfigList = find_AA_S_FBConfigs(display, screen, - glxAttrs, sVal, - antialiasVal, index); + + fbConfigList = find_AA_S_S_FBConfigs(display, screen, glxAttrs, + stereoVal, antialiasVal, + stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; } } - + if (dbVal == UNNECESSARY) { index = dbIndex; glxAttrs[index++] = GLX_DOUBLEBUFFER; glxAttrs[index++] = True; glxAttrs[index] = None; - - fbConfigList = find_AA_S_FBConfigs(display, screen, - glxAttrs, sVal, - antialiasVal, index); + + fbConfigList = find_AA_S_S_FBConfigs(display, screen, glxAttrs, + stereoVal, antialiasVal, + stencilVal, index); if(fbConfigList != NULL) { return fbConfigList; } } - + return NULL; } @@ -279,9 +350,10 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual( GLXFBConfig *fbConfigList = NULL; /* use to cycle through when attr is not REQUIRED */ - int sVal; - int dbVal; - int antialiasVal; + int dbVal; /* value for double buffering */ + int stereoVal; /* value for stereo */ + int antialiasVal; /* value for antialias */ + int stencilVal; /* value for stencil size */ int drawableIndex; @@ -330,32 +402,28 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual( glxAttrs[index] = None; dbVal = mx_ptr[DOUBLEBUFFER]; - sVal = mx_ptr[STEREO]; + stereoVal = mx_ptr[STEREO]; antialiasVal = mx_ptr[ANTIALIASING]; + stencilVal = mx_ptr[STENCIL_SIZE]; (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT); - /* Get Pbuffer-capabale visual unless j3d.usePbuffer property is FALSE */ + /* Get Pbuffer-capable visual unless j3d.usePbuffer property is FALSE */ if (getJavaBoolEnv(env,"usePbuffer")) { - fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, - dbVal, antialiasVal, index); + fbConfigList = find_DB_AA_S_S_FBConfigs(display, screen, glxAttrs, stereoVal, + dbVal, antialiasVal, stencilVal, index); } if(fbConfigList == NULL) { /* Try with Pixmap, if Pbuffer fail. */ - glxAttrs[drawableIndex] = (GLX_PIXMAP_BIT | GLX_WINDOW_BIT); - - fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, - dbVal, antialiasVal, index); - + fbConfigList = find_DB_AA_S_S_FBConfigs(display, screen, glxAttrs, stereoVal, + dbVal, antialiasVal, stencilVal, index); } if(fbConfigList == NULL) { /* Try with Window only, if Pixmap fail. */ - glxAttrs[drawableIndex] = GLX_WINDOW_BIT; - - fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal, - dbVal, antialiasVal, index); - + glxAttrs[drawableIndex] = GLX_WINDOW_BIT; + fbConfigList = find_DB_AA_S_S_FBConfigs(display, screen, glxAttrs, stereoVal, + dbVal, antialiasVal, stencilVal, index); } fbConfigListPtr[0] = (jlong)fbConfigList; @@ -444,6 +512,29 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isStereoAvailable( return (stereoFlag ? JNI_TRUE : JNI_FALSE); } +JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_getStencilSize( + JNIEnv *env, + jobject obj, + jlong display, + jint screen, + jint vid) +{ + Display *dpy = (Display*) display; + XVisualInfo *vinfo, template; + int nitems; + int stencilVal = 0; + + template.visualid = vid; + vinfo = XGetVisualInfo(dpy, VisualIDMask, &template, &nitems); + if (nitems != 1) { + fprintf(stderr, "Warning Canvas3D_getStencilSize got unexpected number of matching visuals %d\n", nitems); + } + + glXGetConfig(dpy, vinfo, GLX_STENCIL_SIZE, &stencilVal); + + return stencilVal; +} + JNIEXPORT jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isDoubleBufferAvailable( JNIEnv *env, @@ -543,7 +634,7 @@ jboolean JNICALL Java_javax_media_j3d_J3dGraphicsConfig_isValidVisualID( return (nitems == 1); } -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ #ifdef WIN32 @@ -652,10 +743,12 @@ HDC getMonitorDC(int screen) return CreateDC("DISPLAY", NULL, NULL, NULL); } +/* NOTE : Since OpenGL 1.2 or greater is required. This is method will not be + * called. Need to remove in Java 3D 1.5 + */ int find_DB_S_STDPixelFormat(PIXELFORMATDESCRIPTOR* pfd, HDC hdc, - int *mx_ptr, GLboolean offScreen) -{ - + int *mx_ptr, GLboolean offScreen, int stencilVal) +{ int pf; PIXELFORMATDESCRIPTOR newpfd; @@ -669,6 +762,7 @@ int find_DB_S_STDPixelFormat(PIXELFORMATDESCRIPTOR* pfd, HDC hdc, (newpfd.cGreenBits < (unsigned char) mx_ptr[GREEN_SIZE]) || (newpfd.cBlueBits < (unsigned char) mx_ptr[BLUE_SIZE]) || (newpfd.cDepthBits < (unsigned char) mx_ptr[DEPTH_SIZE]) || + (newpfd.cStencilBits < (unsigned char) mx_ptr[STENCIL_SIZE]) || ((mx_ptr[DOUBLEBUFFER] == REQUIRED) && ((newpfd.dwFlags & PFD_DOUBLEBUFFER) == 0)) || ((mx_ptr[STEREO] == REQUIRED) && ((newpfd.dwFlags & PFD_STEREO) == 0))) @@ -706,17 +800,22 @@ void printErrorMessage(char *message) #define MAX_WGL_ATTRS_LENGTH 100 -int find_Stencil_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, - int* wglAttrs, int sIndex) { +int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, + int* wglAttrs, int stencilVal, int sIndex) { int pFormat, availableFormats, index; - + GLboolean userReq = GL_TRUE; + J3D_ASSERT((sIndex+4) < MAX_WGL_ATTRS_LENGTH); + /* if user not use stencil we will request one of internal use. */ + if (stencilVal < 1) { + userReq = GL_FALSE; + stencilVal = 1; + } - index = sIndex; wglAttrs[index++] = WGL_STENCIL_BITS_ARB; - wglAttrs[index++] = 1; + wglAttrs[index++] = stencilVal; /* * Terminate by 2 zeros to avoid driver bugs * that assume attributes always come in pairs. @@ -729,14 +828,25 @@ int find_Stencil_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, if ((pFormatInfo->wglChoosePixelFormatARB(hdc, wglAttrs, NULL, 1, &pFormat, &availableFormats)) && (availableFormats > 0)) { - /* fprintf(stderr, "wglChoosePixelFormatARB : pFormat %d availableFormats %d\n", - pFormat, availableFormats); */ + /* + fprintf(stderr, "Stencil : wglChoosePixelFormatARB : pFormat %d availableFormats %d\n", + pFormat, availableFormats); + */ return pFormat; } + + /* + fprintf(stderr, "Stencil : wglChoosePixelFormatARB (TRY 1): FAIL -- stencilVal = %d\n", + stencilVal); + */ - /* fprintf(stderr, "wglChoosePixelFormatARB (TRY 1): FAIL\n"); */ - + if (userReq == GL_TRUE) { + /* fprintf(stderr, " userReq : *** FAILED ***\n"); */ + return -1; + } + index = sIndex; + /* * Terminate by 2 zeros to avoid driver bugs * that assume attributes always come in pairs. @@ -745,28 +855,28 @@ int find_Stencil_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index+1] = 0; pFormat = -1; - + if ((pFormatInfo->wglChoosePixelFormatARB(hdc, wglAttrs, NULL, 1, &pFormat, &availableFormats)) && (availableFormats > 0)) { - + /* fprintf(stderr, "wglChoosePixelFormatARB : pFormat %d availableFormats %d\n", pFormat, availableFormats); */ - - return pFormat; + + return pFormat; } /* fprintf(stderr, "wglChoosePixelFormatARB (TRY 2): FAIL\n"); */ return -1; } -int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, - int* wglAttrs, int sVal, int sIndex) { +int find_S_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, int* wglAttrs, + int stereoVal, int stencilVal, int sIndex) { int pFormat, index; J3D_ASSERT((sIndex+4) < MAX_WGL_ATTRS_LENGTH); - if (sVal == REQUIRED || sVal== PREFERRED) { + if (stereoVal == REQUIRED || stereoVal== PREFERRED) { index = sIndex; wglAttrs[index++] = WGL_STEREO_ARB; @@ -778,8 +888,8 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo, - wglAttrs, index); + pFormat = find_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stencilVal, index); /* fprintf(stderr,"STEREO REQUIRED or PREFERRED ***pFormat %d\n", pFormat); */ if(pFormat >= 0) { @@ -787,7 +897,7 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, } } - if (sVal == UNNECESSARY || sVal== PREFERRED) { + if (stereoVal == UNNECESSARY || stereoVal== PREFERRED) { index = sIndex; wglAttrs[index++] = WGL_STEREO_ARB; @@ -799,8 +909,8 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo, - wglAttrs, index); + pFormat = find_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stencilVal, index); /* fprintf(stderr,"STEREO UNNECC. or PREFERRED ***pFormat %d\n", pFormat); */ @@ -809,7 +919,7 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, } } - if (sVal == UNNECESSARY) { + if (stereoVal == UNNECESSARY) { index = sIndex; wglAttrs[index++] = WGL_STEREO_ARB; wglAttrs[index++] = TRUE; @@ -820,8 +930,8 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo, - wglAttrs, index); + pFormat = find_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stencilVal, index); /* fprintf(stderr,"STEREO UNNECC. ***pFormat %d\n", pFormat); */ @@ -834,9 +944,9 @@ int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo, } -int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, - int* wglAttrs, int sVal, - int antialiasVal, int antialiasIndex) { +int find_AA_S_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, + int* wglAttrs, int stereoVal, int antialiasVal, + int stencilVal, int antialiasIndex) { int index; int pFormat; @@ -879,11 +989,11 @@ int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, for(i=0; i < SAMPLE_LENGTH; i++) { - /* fprintf(stderr, "find_AA_S_PixelFormat samples = %d\n", samples[i]); */ + /* fprintf(stderr, "find_AA_S_S_PixelFormat samples = %d\n", samples[i]); */ wglAttrs[samplesIndex] = samples[i]; - pFormat = find_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, index); + pFormat = find_S_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stereoVal, stencilVal, index); if(pFormat >= 0) { return pFormat; } @@ -907,8 +1017,8 @@ int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, index); + pFormat = find_S_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stereoVal, stencilVal, index); if(pFormat >= 0) { return pFormat; @@ -925,8 +1035,8 @@ int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, if (antialiasVal == UNNECESSARY || antialiasVal == PREFERRED) { - pFormat = find_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, index); + pFormat = find_S_S_PixelFormat(hdc, pFormatInfo, wglAttrs, + stereoVal, stencilVal, index); if(pFormat >= 0) { return pFormat; @@ -939,9 +1049,9 @@ int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, } -int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, - int* wglAttrs, int sVal, int dbVal, - int antialiasVal, int dbIndex) { +int find_DB_AA_S_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, + int* wglAttrs, int stereoVal, int dbVal, + int antialiasVal, int stencilVal, int dbIndex) { int index = dbIndex; int pFormat; @@ -960,9 +1070,9 @@ int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, - antialiasVal, index); + pFormat = find_AA_S_S_PixelFormat(hdc, pFormatInfo, + wglAttrs, stereoVal, + antialiasVal, stencilVal, index); if(pFormat >= 0) { return pFormat; @@ -972,7 +1082,7 @@ int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, if (dbVal == UNNECESSARY || dbVal== PREFERRED) { index = dbIndex; wglAttrs[index++] = WGL_DOUBLE_BUFFER_ARB; - wglAttrs[index++] = FALSE; // Partial fix to issue 100. + wglAttrs[index++] = FALSE; /* Partial fix to issue 100. */ /* * Terminate by 2 zeros to avoid driver bugs * that assume attributes always come in pairs. @@ -980,9 +1090,9 @@ int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, - antialiasVal, index); + pFormat = find_AA_S_S_PixelFormat(hdc, pFormatInfo, + wglAttrs, stereoVal, + antialiasVal, stencilVal, index); if(pFormat >= 0) { return pFormat; @@ -1000,9 +1110,9 @@ int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo, wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo, - wglAttrs, sVal, - antialiasVal, index); + pFormat = find_AA_S_S_PixelFormat(hdc, pFormatInfo, + wglAttrs, stereoVal, + antialiasVal, stencilVal, index); if(pFormat >= 0) { return pFormat; @@ -1024,7 +1134,9 @@ void checkPixelFormat(HDC hdc, GLboolean hasMultisample = GL_FALSE; GLboolean hasStereo = GL_FALSE; GLboolean hasDoubleBuffer = GL_FALSE; - GLboolean hasAccum = GL_FALSE; + GLboolean hasAccum + = GL_FALSE; + int stencilSize = 0; PIXELFORMATDESCRIPTOR pfd; /* fprintf(stderr, "*** checkPixelFormat : offScreen = %d\n", offScreen); */ @@ -1069,10 +1181,12 @@ void checkPixelFormat(HDC hdc, if (pfd.cAccumRedBits > 0) { hasAccum = GL_TRUE; } - + + stencilSize = pfd.cStencilBits; + /* - fprintf(stderr, "hasStereo = %d, hasDoubleBuffer %d, hasAccum %d\n", - hasStereo, hasDoubleBuffer, hasAccum); + fprintf(stderr, "hasStereo = %d, hasDoubleBuffer %d, hasAccum %d stencilSize %d\n", + hasStereo, hasDoubleBuffer, hasAccum, pfd.cStencilBits); */ if(pFormatInfo->onScreenPFormat == pFormatInfo->offScreenPFormat) { @@ -1080,23 +1194,27 @@ void checkPixelFormat(HDC hdc, pFormatInfo->onScreenHasStereo = hasStereo; pFormatInfo->onScreenHasDoubleBuffer = hasDoubleBuffer; pFormatInfo->onScreenHasAccum = hasAccum; + pFormatInfo->onScreenStencilSize = stencilSize; pFormatInfo->offScreenHasMultisample = hasMultisample; pFormatInfo->offScreenHasStereo = hasStereo; pFormatInfo->offScreenHasDoubleBuffer = hasDoubleBuffer; pFormatInfo->offScreenHasAccum = hasAccum; + pFormatInfo->offScreenStencilSize = stencilSize; } else if(!offScreen) { pFormatInfo->onScreenHasMultisample = hasMultisample; pFormatInfo->onScreenHasStereo = hasStereo; pFormatInfo->onScreenHasDoubleBuffer = hasDoubleBuffer; pFormatInfo->onScreenHasAccum = hasAccum; + pFormatInfo->onScreenStencilSize = stencilSize; } else { pFormatInfo->offScreenHasMultisample = hasMultisample; pFormatInfo->offScreenHasStereo = hasStereo; pFormatInfo->offScreenHasDoubleBuffer = hasDoubleBuffer; pFormatInfo->offScreenHasAccum = hasAccum; + pFormatInfo->offScreenStencilSize = stencilSize; } } @@ -1111,16 +1229,18 @@ int chooseSTDPixelFormat( { int *mx_ptr; int dbVal; /* value for double buffering */ - int sVal; /* value for stereo */ + int stereoVal; /* value for stereo */ int pFormat = -1; /* PixelFormat */ PIXELFORMATDESCRIPTOR pfd; + int stencilVal = 0; /* value for stencil size */ + GLboolean userReq = GL_TRUE; /* fprintf(stderr, "chooseSTDPixelFormat : screen 0x%x, offScreen %d hdc 0x%x\n", screen, offScreen, hdc); */ ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; /*TODO: when would this change? */ + pfd.nVersion = 1; /* When would this change? */ pfd.iPixelType = PFD_TYPE_RGBA; /* @@ -1140,16 +1260,23 @@ int chooseSTDPixelFormat( else dbVal = PFD_DOUBLEBUFFER_DONTCARE; - sVal = 0; + stereoVal = 0; if (mx_ptr[STEREO] == REQUIRED || mx_ptr[STEREO] == PREFERRED) { - sVal = PFD_STEREO; + stereoVal = PFD_STEREO; } else { - sVal = PFD_STEREO_DONTCARE; + stereoVal = PFD_STEREO_DONTCARE; } - pfd.dwFlags = dbVal | sVal | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; + pfd.dwFlags = dbVal | stereoVal | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; - pfd.cStencilBits = 1; + /* if user not use stencil we will request one of internal use. */ + stencilVal = mx_ptr[STENCIL_SIZE]; + if (stencilVal < 1) { + userReq = GL_FALSE; + stencilVal = 1; + } + + pfd.cStencilBits = stencilVal; if (mx_ptr[ANTIALIASING] == REQUIRED) { pfd.cAccumRedBits = 8; @@ -1161,6 +1288,8 @@ int chooseSTDPixelFormat( else { /* Offscreen setting. */ /* We are here b/c there is no support for Pbuffer on the HW. This is a fallback path, we will hardcore the value. */ + + /* NOTE : Stencil size isn't handle for Offscreen */ /* by MIK OF CLASSX */ pfd.iPixelType = PFD_TYPE_RGBA; @@ -1184,12 +1313,13 @@ int chooseSTDPixelFormat( } - pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen); + pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen, stencilVal); - if (pFormat == -1) { + if ((pFormat == -1) && (userReq == GL_FALSE)) { /* try disable stencil buffer */ pfd.cStencilBits = 0; - pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen); + stencilVal = 0; + pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen, stencilVal); } (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT); @@ -1208,12 +1338,14 @@ PixelFormatInfo * newPixelFormatInfo(HDC hdc, jboolean usePbuffer) pFormatInfo->onScreenHasStereo = GL_FALSE; pFormatInfo->onScreenHasDoubleBuffer = GL_FALSE; pFormatInfo->onScreenHasAccum = GL_FALSE; + pFormatInfo->onScreenStencilSize = 0; pFormatInfo->offScreenPFormat = -1; pFormatInfo->offScreenHasMultisample = GL_FALSE; pFormatInfo->offScreenHasStereo = GL_FALSE; pFormatInfo->offScreenHasDoubleBuffer = GL_FALSE; pFormatInfo->offScreenHasAccum = GL_FALSE; + pFormatInfo->offScreenStencilSize = 0; pFormatInfo->drawToPbuffer = GL_FALSE; pFormatInfo->supportARB = GL_FALSE; @@ -1307,9 +1439,10 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( int *mx_ptr; int dbVal; /* value for double buffering */ - int sVal; /* value for stereo */ + int stereoVal; /* value for stereo */ int antialiasVal; /* value for antialias */ - + int stencilVal; /* value for stencil size */ + HWND hwnd; HGLRC hrc; HDC hdc; @@ -1366,6 +1499,8 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( offScreenPFListPtr = (*env)->GetLongArrayElements(env, offScreenPFArray, NULL); if (pFormatInfo->supportARB) { + + /* fprintf(stderr, "Using non standard ChoosePixelFormat.\n"); */ mx_ptr = (*env)->GetIntArrayElements(env, attrList, NULL); @@ -1399,8 +1534,9 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( lastIndex = index; dbVal = mx_ptr[DOUBLEBUFFER]; - sVal = mx_ptr[STEREO]; + stereoVal = mx_ptr[STEREO]; antialiasVal = mx_ptr[ANTIALIASING]; + stencilVal = mx_ptr[STENCIL_SIZE]; (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT); @@ -1416,9 +1552,10 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormatInfo->onScreenPFormat = find_DB_AA_S_PixelFormat( hdc, pFormatInfo, - wglAttrs, sVal, dbVal, - antialiasVal, index); + pFormatInfo->onScreenPFormat = find_DB_AA_S_S_PixelFormat( hdc, pFormatInfo, + wglAttrs, stereoVal, + dbVal, antialiasVal, + stencilVal, index); if(pFormatInfo->onScreenPFormat >= 0) { /* Since the return pixel format support pbuffer, @@ -1453,12 +1590,13 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat( wglAttrs[index] = 0; wglAttrs[index+1] = 0; - pFormatInfo->onScreenPFormat = find_DB_AA_S_PixelFormat( hdc, pFormatInfo, - wglAttrs, sVal, dbVal, - antialiasVal, index); + pFormatInfo->onScreenPFormat = find_DB_AA_S_S_PixelFormat( hdc, pFormatInfo, + wglAttrs, stereoVal, + dbVal, antialiasVal, + stencilVal, index); } else { - /* fprintf(stderr, "Fallback to use standard ChoosePixelFormat.\n"); */ + fprintf(stderr, "Fallback to use standard ChoosePixelFormat.\n"); pFormatInfo->onScreenPFormat = (jint) chooseSTDPixelFormat( env, screen, attrList, hdc, GL_FALSE); @@ -1567,6 +1705,29 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isStereoAvailable( } +JNIEXPORT jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_getStencilSize( + JNIEnv *env, + jobject obj, + jlong pFormatInfo, + jboolean offScreen) +{ + + PixelFormatInfo *pfInfo = (PixelFormatInfo *) pFormatInfo; + if(offScreen) { + /* fprintf(stderr, "offScreen getStencilSize %d\n", + pfInfo->offScreenStencilSize); */ + + return pfInfo->offScreenStencilSize; + } + else { + /* fprintf(stderr, "onScreen getStencilSize %d\n", + pfInfo->onScreenStencilSize); */ + + return pfInfo->onScreenStencilSize; + } + +} + JNIEXPORT jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isDoubleBufferAvailable( diff --git a/src/native/ogl/NativeScreenInfo.c b/src/native/ogl/NativeScreenInfo.c index 1082770..ec14649 100644 --- a/src/native/ogl/NativeScreenInfo.c +++ b/src/native/ogl/NativeScreenInfo.c @@ -16,7 +16,7 @@ * of the Java 3D API. */ -#if defined(__linux__) +#if defined(LINUX) #define _GNU_SOURCE 1 #endif @@ -26,7 +26,7 @@ #include "gldefs.h" -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -37,7 +37,7 @@ #include <windows.h> #endif -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) /* @@ -94,38 +94,40 @@ Java_javax_media_j3d_NativeScreenInfo_queryGLX13( return JNI_FALSE; } -#if 0 /* Temporary disable this code segment because the ATI driver incorrectly - return 1.2 */ - - /* Check for glX 1.3 and higher */ - if (glXQueryVersion(dpy, &major, &minor)) { - /* fprintf(stderr, "Checking glX version : %d.%d\n",major, minor); */ - if (!(major == 1 && minor >= 3)) { - fprintf(stderr, "Java 3D ERROR : GLX version = %d.%d\n", major, minor); - fprintf(stderr, " GLX version 1.3 or higher is required\n"); - return JNI_FALSE; - } - } - else { + /* Query the GLX version number */ + if (!glXQueryVersion(dpy, &major, &minor)) { fprintf(stderr, "Java 3D ERROR : Unable to query GLX version\n"); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } - -#elseif - + /*fprintf(stderr, "Checking GLX version : %d.%d\n", major, minor);*/ + tmpfp = (MYPFNGLXCHOOSEFBCONFIG)dlsym(RTLD_DEFAULT, "glXChooseFBConfig"); if (tmpfp == NULL) { - glXQueryVersion(dpy, &major, &minor); fprintf(stderr, "Java 3D ERROR : glXChooseFBConfig not found\n"); fprintf(stderr, " GLX version = %d.%d\n", major, minor); fprintf(stderr, " GLX version 1.3 or higher is required\n"); return JNI_FALSE; } -#endif - + /* Check for GLX 1.3 and higher */ + if (!(major == 1 && minor >= 3)) { + fprintf(stderr, "Java 3D WARNING : reported GLX version = %d.%d\n", major, minor); + fprintf(stderr, " GLX version 1.3 or higher is required\n"); + + fprintf(stderr, + " The reported version number may be incorrect. There is a known\n"); + fprintf(stderr, + " ATI driver bug in glXQueryVersion that incorrectly reports the GLX\n"); + fprintf(stderr, + " version as 1.2 when it really is 1.3, so Java 3D will attempt to\n"); + fprintf(stderr, + " run anyway.\n"); + + /*return JNI_FALSE;*/ + } + return JNI_TRUE; } diff --git a/src/native/ogl/NativeWSInfo.c b/src/native/ogl/NativeWSInfo.c index 46f1f56..de971d0 100644 --- a/src/native/ogl/NativeWSInfo.c +++ b/src/native/ogl/NativeWSInfo.c @@ -21,7 +21,7 @@ #include "gldefs.h" -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> diff --git a/src/native/ogl/RasterRetained.c b/src/native/ogl/RasterRetained.c index 2de7831..09d4e6d 100644 --- a/src/native/ogl/RasterRetained.c +++ b/src/native/ogl/RasterRetained.c @@ -21,6 +21,9 @@ #endif /* DEBUG */ +extern void throwAssert(JNIEnv *env, char *str); + + JNIEXPORT void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, @@ -149,9 +152,11 @@ void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, case FORMAT_BYTE_LA: glformat = GL_LUMINANCE_ALPHA; break; + case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + case FORMAT_USHORT_GRAY: + default: + throwAssert(env, "illegal format"); break; } glDrawPixels(w_raster, h_raster, glformat, GL_UNSIGNED_BYTE, @@ -374,7 +379,8 @@ void JNICALL Java_javax_media_j3d_RasterRetained_executeTiled(JNIEnv *env, break; case FORMAT_BYTE_GRAY: case FORMAT_USHORT_GRAY: - /* TODO: throw exception */ + default: + throwAssert(env, "illegal format"); break; } fprintf(stderr, "w_raster = %d, h_raster = %d, glformat = %d\n",w_raster, h_raster, glformat); diff --git a/src/native/ogl/build-linux-amd64.xml b/src/native/ogl/build-linux-amd64.xml index 55adffd..f2df165 100644 --- a/src/native/ogl/build-linux-amd64.xml +++ b/src/native/ogl/build-linux-amd64.xml @@ -18,6 +18,13 @@ <target name="compile"> + <!-- + /* + * TODO: To compile CG, add the following the the "link" command: + * -lCg -lCgGL -lGLU -lpthread + */ + --> + <echo message="Executing 64 bit native renderer build [${bldType}]"/> <!-- Create the build directories for linux --> @@ -29,12 +36,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-m64 -march=k8 -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} -${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-m64 -march=k8 -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib64 -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/amd64 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib64 -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/amd64 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-linux-i586.xml b/src/native/ogl/build-linux-i586.xml index a9524cf..f70e067 100644 --- a/src/native/ogl/build-linux-i586.xml +++ b/src/native/ogl/build-linux-i586.xml @@ -16,30 +16,59 @@ <!-- Ant file for building native ogl renderer files for Solaris --> <project name="Java 3D" default="compile"> - <target name="compile"> - - <echo message="Executing 32 bit native renderer build [${bldType}]"/> - + <target name="init" depends="init-cg,init-nocg"> <!-- Create the build directories for linux --> <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> <property name="oglsrc" location="${src}/native/ogl"/> + </target> + + <target name="init-cg" if="build.cg"> + <property name="cflags.cg" value="-DCOMPILE_CG_SHADERS=1"/> + </target> + + <target name="init-nocg" unless="build.cg"> + <property name="cflags.cg" value=""/> + </target> + + <target name="compile-ogl"> + <echo message="Executing 32 bit native renderer build [${bldType}]"/> <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -m32 -mcpu=i386 -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahCoreTarget} -${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -m32 -mcpu=i386 -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> </exec> - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/ogl/objs/libj3dcore-ogl.so" - todir="${build}/${platform}/${bldType}/lib/i386"/> + </target> + + <target name="compile-ogl-cg" if="build.cg"> + <!-- Compile the wrapper --> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> + <arg line="-w -m32 -mcpu=i386 -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/CgWrapper.c"/> + </exec> + + <!-- Create the wrapper library --> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> + <arg line="CgWrapper.o -G -z defs -L/usr/X11R6/lib -ldl -lCg -lCgGL -lpthread -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl-cg.so"/> + </exec> + + </target> + + <target name="compile" depends="init,compile-ogl,compile-ogl-cg"> + + <!-- Copy the library file --> + <copy todir="${build}/${platform}/${bldType}/lib/i386"> + <fileset dir="${build}/${platform}/${bldType}/native/ogl/objs" + includes="libj3dcore-ogl*.so" + /> + </copy> </target> @@ -48,8 +77,11 @@ <mkdir dir="${dist}/${platform}/lib/i386"/> <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/i386/libj3dcore-ogl.so" - todir="${dist}/${platform}/lib/i386"/> + <copy todir="${dist}/${platform}/lib/i386"> + <fileset dir="${build}/${platform}/opt/lib/i386" + includes="libj3dcore-ogl*.so" + /> + </copy> </target> diff --git a/src/native/ogl/build-linux-ia64.xml b/src/native/ogl/build-linux-ia64.xml index ff24611..20d7f4d 100644 --- a/src/native/ogl/build-linux-ia64.xml +++ b/src/native/ogl/build-linux-ia64.xml @@ -18,6 +18,13 @@ <target name="compile"> + <!-- + /* + * TODO: To compile CG, add the following the the "link" command: + * -lCg -lCgGL -lGLU -lpthread + */ + --> + <echo message="Executing 64 bit native renderer build [${bldType}]"/> <!-- Create the build directories for linux --> @@ -28,14 +35,14 @@ <!-- Compile the c source files; based on build-linux-amd64.xml--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} -${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file; based on build-linux-amd64.xml--> <!-- Must use gcc to link, not ld, hence also need -shared; refer to http://www.gelato.unsw.edu.au/linux-ia64/0006/0212.html --> <!-- Removed -R/usr/openwin/lib - an ld specific option (should be a filename, not a dir?!?) --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -shared -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/ia64 -ljawt -L${java.home}/lib/ia64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -shared -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/ia64 -ljawt -L${java.home}/lib/ia64/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-linux-ppc.xml b/src/native/ogl/build-linux-ppc.xml new file mode 100644 index 0000000..1149d05 --- /dev/null +++ b/src/native/ogl/build-linux-ppc.xml @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native ogl renderer files for Solaris --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <!-- + /* + * TODO: To compile CG, add the following the the "link" command: + * -lCg -lCgGL -lGLU -lpthread + */ + --> + + <echo message="Executing 32 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for linux --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/bin"/> + + <property name="oglsrc" location="${src}/native/ogl"/> + + <!-- Compile the c source files--> + <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> + <arg line="-w -I${java.home}/../include -I${java.home}/../include/linux -I/usr/X11R6/include -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/bin -ljawt -L${java.home}/bin/classic -ljvm -o libj3dcore-ogl.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/ogl/objs/libj3dcore-ogl.so" + todir="${build}/${platform}/${bldType}/bin"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/bin"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/bin/libj3dcore-ogl.so" + todir="${dist}/${platform}/bin"/> + + </target> + +</project> diff --git a/src/native/ogl/build-solaris-sparc-forte.xml b/src/native/ogl/build-solaris-sparc-forte.xml index 6eb2d53..453d493 100644 --- a/src/native/ogl/build-solaris-sparc-forte.xml +++ b/src/native/ogl/build-solaris-sparc-forte.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} -${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -51,12 +51,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} -${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-sparc-gcc.xml b/src/native/ogl/build-solaris-sparc-gcc.xml index 1bd4575..fdf7a97 100644 --- a/src/native/ogl/build-solaris-sparc-gcc.xml +++ b/src/native/ogl/build-solaris-sparc-gcc.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -m32 -mcpu=v9 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} -${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -m32 -mcpu=v9 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -51,12 +51,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="gcc"> - <arg line="-m64 -mcpu=v9 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} -${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-m64 -mcpu=v9 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-x86-forte.xml b/src/native/ogl/build-solaris-x86-forte.xml new file mode 100644 index 0000000..942319a --- /dev/null +++ b/src/native/ogl/build-solaris-x86-forte.xml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native ogl renderer files for Solaris --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 32 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for i386 --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> + + <property name="oglsrc" location="${src}/native/ogl"/> + + <!-- Compile the c source files--> + <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cc"> + <arg line="-v -xCC -xchip=pentium3 -xarch=generic -KPIC -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/ogl/objs/libj3dcore-ogl.so" + todir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- + /* + * TODO: only do the 64-bit build if isSolarisOnX86_64 property is + * set, indicating that a 64-bit JVM is available + */ + --> + +<!-- ********************************************************************** --> + <echo message="Executing 64 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for amd64 --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="cc"> + <arg line="-v -xCC -xchip=opteron -xarch=generic64 -KPIC -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="ld"> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/ogl/objs/amd64/libj3dcore-ogl.so" + todir="${build}/${platform}/${bldType}/lib/amd64"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/lib/i386"/> + <mkdir dir="${dist}/${platform}/lib/amd64"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/lib/i386/libj3dcore-ogl.so" + todir="${dist}/${platform}/lib/i386"/> + + <copy file="${build}/${platform}/opt/lib/amd64/libj3dcore-ogl.so" + todir="${dist}/${platform}/lib/amd64"/> + </target> + +</project> diff --git a/src/native/ogl/build-solaris-x86-gcc.xml b/src/native/ogl/build-solaris-x86-gcc.xml new file mode 100644 index 0000000..7131d06 --- /dev/null +++ b/src/native/ogl/build-solaris-x86-gcc.xml @@ -0,0 +1,88 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native ogl renderer files for Solaris --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 32 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for i386 --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> + + <property name="oglsrc" location="${src}/native/ogl"/> + + <!-- Compile the c source files--> + <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> + <arg line="-w -m32 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/ogl/objs/libj3dcore-ogl.so" + todir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- + /* + * TODO: only do the 64-bit build if isSolarisOnX86_64 property is + * set, indicating that a 64-bit JVM is available + */ + --> + +<!-- ********************************************************************** --> + <echo message="Executing 64 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for amd64 --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="gcc"> + <arg line="-m64 -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="ld"> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/ogl/objs/amd64/libj3dcore-ogl.so" + todir="${build}/${platform}/${bldType}/lib/amd64"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/lib/i386"/> + <mkdir dir="${dist}/${platform}/lib/amd64"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/lib/i386/libj3dcore-ogl.so" + todir="${dist}/${platform}/lib/i386"/> + + <copy file="${build}/${platform}/opt/lib/amd64/libj3dcore-ogl.so" + todir="${dist}/${platform}/lib/amd64"/> + </target> + +</project> diff --git a/src/native/ogl/build-windows-i586-gcc.xml b/src/native/ogl/build-windows-i586-gcc.xml index 74de03e..08c07db 100644 --- a/src/native/ogl/build-windows-i586-gcc.xml +++ b/src/native/ogl/build-windows-i586-gcc.xml @@ -19,6 +19,21 @@ <target name="compile"> + <!-- + /* + * TODO: To compile CG, do the following steps: + * + * 1. define the following property: + * <property name="cg_home" location="c:/Program Files/NVIDIA Corporation/Cg"/> + * + * 2. Add the following to the "compile" command: + * -I"${cg_home}\include" + * + * 3. Add the following the the "link" command: + * -L"${cg_home}\lib" -lcg -lcgGL + */ + --> + <echo message="Executing 32 bit native renderer build [${bldType}]"/> <!-- Create the build directories for sparc --> @@ -37,12 +52,12 @@ <!-- Inhibit all warning for native build. Remove -w to switch warning on --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -D_WINGDI_ -D_JNI_IMPLEMENTATION_ -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" ${bldFlag} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/CompressedGeometryRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> + <arg line="-w -D_WINGDI_ -D_JNI_IMPLEMENTATION_ -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" ${bldFlag} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-shared -o j3dcore-ogl.dll DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o Lights.o NativeAPIInfo.o -Wl,--kill-at -L"${java.home}\..\lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32 -ljawt"/> + <arg line="-shared -o j3dcore-ogl.dll DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -Wl,--kill-at -L"${java.home}\..\lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32 -ljawt"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-windows-i586-vc.xml b/src/native/ogl/build-windows-i586-vc.xml index 55b65ee..284362e 100644 --- a/src/native/ogl/build-windows-i586-vc.xml +++ b/src/native/ogl/build-windows-i586-vc.xml @@ -14,17 +14,25 @@ */ --> +<!-- +/* 1. define the following property to change the location of the CG library: + * + * ant -Dcg.home="path-to-cg-installation" + */ + --> + <!-- Ant file for building native ogl renderer files for Windows-i586 --> <project name="Java 3D" default="compile"> - <target name="compile"> - <echo message="Executing 32 bit native renderer build [${bldType}]"/> - <!-- Create the build directories for sparc --> + <target name="init" depends="init-cg,init-nocg"> + <!-- Create the build directories for win32 --> <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> <mkdir dir="${build}/${platform}/${bldType}/bin"/> + <echo message="Executing 32 bit native renderer build [${bldType}]"/> + <property name="javaInclude" location="${java.home}/../include"/> @@ -32,20 +40,55 @@ location="${java.home}/../include/win32"/> <property name="oglsrc" location="${src}/native/ogl"/> + </target> + + <target name="init-cg" if="build.cg"> + <property name="cflags.cg" value="-DCOMPILE_CG_SHADERS=1"/> + <property name="cg.home" location="c:/Program Files/NVIDIA Corporation/Cg"/> + </target> + <target name="init-nocg" unless="build.cg"> + <property name="cflags.cg" value=""/> + <property name="cg.home" value=""/> + </target> + + <target name="compile-ogl"> <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cl"> - <arg line="-I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/CompressedGeometryRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> + <arg line="-I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="link"> - <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl.dll DrawingSurfaceObjectAWT.obj Canvas3D.obj GraphicsContext3D.obj NativeWSInfo.obj NativeScreenInfo.obj NativeConfigTemplate3D.obj MasterControl.obj RasterRetained.obj CompressedGeometryRetained.obj GeometryArrayRetained.obj Attributes.obj Lights.obj NativeAPIInfo.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl.dll DrawingSurfaceObjectAWT.obj Canvas3D.obj GraphicsContext3D.obj NativeWSInfo.obj NativeScreenInfo.obj NativeConfigTemplate3D.obj MasterControl.obj RasterRetained.obj GeometryArrayRetained.obj Attributes.obj CgShaderProgram.obj GLSLShaderProgram.obj Lights.obj NativeAPIInfo.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> </exec> - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/ogl/objs/j3dcore-ogl.dll" - todir="${build}/${platform}/${bldType}/bin"/> + </target> + + + <target name="compile-ogl-cg" if="build.cg"> + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cl"> + <arg line="-I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/CgWrapper.c""/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="link"> + <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl-cg.dll CgWrapper.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib -LIBPATH:"${cg.home}\lib" cg.lib cgGL.lib"/> + </exec> + + </target> + + + + <target name="compile" depends="init,compile-ogl,compile-ogl-cg"> + + <!-- Copy the library file --> + <copy todir="${build}/${platform}/${bldType}/bin"> + <fileset dir="${build}/${platform}/${bldType}/native/ogl/objs" + includes="j3dcore-ogl*.dll" + /> + </copy> </target> @@ -54,8 +97,11 @@ <mkdir dir="${dist}/${platform}/bin"/> <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/bin/j3dcore-ogl.dll" - todir="${dist}/${platform}/bin"/> + <copy todir="${dist}/${platform}/bin"> + <fileset dir="${build}/${platform}/opt/bin" + includes="j3dcore-ogl*.dll" + /> + </copy> </target> diff --git a/src/native/ogl/gl_1_2.h b/src/native/ogl/gl_1_2.h deleted file mode 100644 index a251c15..0000000 --- a/src/native/ogl/gl_1_2.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#ifndef __gl_1_2_h_ -#define __gl_1_2_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Portions of this code were derived from work done by the Blackdown - * group (www.blackdown.org), who did the initial Linux implementation - * of the Java 3D API. - */ - -#ifndef GL_VERSION_1_2 - -#ifndef GL_BGR -#define GL_BGR 0x80E0 -#endif - -#ifndef GL_BGRA -#define GL_BGRA 0x80E1 -#endif - - -#ifndef GL_LIGHT_MODEL_COLOR_CONTROL -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#endif - -#ifndef GL_SEPARATE_SPECULAR_COLOR -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#endif - -#ifndef GL_SINGLE_COLOR -#define GL_SINGLE_COLOR 0x81F9 -#endif - -#endif /* GL_VERSION_1_2 */ - - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#endif /* GL_ARB_texture_env_combine */ - - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif /* GL_ARB_texture_env_dot3 */ - - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif /* GL_EXT_texture_env_dot3 */ - -#ifndef GL_EXT_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_EXT 0x812F -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#if defined(SOLARIS) || defined(__linux__) -#ifndef GL_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 - -#define MULTISAMPLE_ARB 0x809D -#define SAMPLE_ALPHA_TO_COVERATE_ARB 0x809E -#define SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define SAMPLE_COVERAGE_ARB 0x80A0 -#define MULTISAMPLE_BIT_ARB 0x20000000 -#define SAMPLE_BUFFERS_ARB 0x80A8 -#define SAMPLES_ARB 0x80A9 -#define SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#endif /* GL_ARB_multisample */ -#endif /* SOLARIS */ - -#ifndef MULTISAMPLE_ARB -#define MULTISAMPLE_ARB 0x809D -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/native/ogl/gldefs.h b/src/native/ogl/gldefs.h index 2411f4f..2e5246f 100644 --- a/src/native/ogl/gldefs.h +++ b/src/native/ogl/gldefs.h @@ -23,15 +23,16 @@ #include <stdlib.h> #include <string.h> -#if defined(SOLARIS) || defined(__linux__) +#if defined(SOLARIS) || defined(LINUX) #define GLX_GLEXT_PROTOTYPES #define GLX_GLXEXT_PROTOTYPES +#define UNIX + #include <limits.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <GL/gl.h> #include <GL/glx.h> -#include "gl_1_2.h" #include "glext.h" #endif @@ -73,7 +74,6 @@ #ifndef D3D #include <GL/gl.h> #include "wglext.h" -#include "gl_1_2.h" #include "glext.h" #endif @@ -84,7 +84,6 @@ #include "javax_media_j3d_Canvas3D.h" #include "javax_media_j3d_ColoringAttributes.h" #include "javax_media_j3d_ColoringAttributesRetained.h" -#include "javax_media_j3d_CompressedGeometryRetained.h" #include "javax_media_j3d_DepthComponentRetained.h" #include "javax_media_j3d_DetailTextureImage.h" #include "javax_media_j3d_DirectionalLightRetained.h" @@ -106,6 +105,7 @@ #include "javax_media_j3d_Material.h" #include "javax_media_j3d_MaterialRetained.h" #include "javax_media_j3d_ModelClipRetained.h" +#include "javax_media_j3d_NativeAPIInfo.h" #include "javax_media_j3d_NativeConfigTemplate3D.h" #include "javax_media_j3d_NodeRetained.h" #include "javax_media_j3d_PointAttributesRetained.h" @@ -132,10 +132,11 @@ #include "javax_media_j3d_TextureUnitStateRetained.h" #include "javax_media_j3d_TransparencyAttributes.h" #include "javax_media_j3d_TransparencyAttributesRetained.h" - -#ifndef GL_SUNX_geometry_compression -#define GL_COMPRESSED_GEOM_ACCELERATED_SUNX 0x81D0 -#endif /* GL_SUNX_geometry_compression */ +#include "javax_media_j3d_GLSLShaderProgramRetained.h" +#include "javax_media_j3d_CgShaderProgramRetained.h" +#include "javax_media_j3d_Shader.h" +#include "javax_media_j3d_ShaderAttributeObjectRetained.h" +#include "javax_media_j3d_ShaderError.h" /* * Define these constants here as a workaround for conflicting @@ -259,9 +260,25 @@ #define GA_TEXTURE_COORDINATE_3 javax_media_j3d_GeometryArray_TEXTURE_COORDINATE_3 #define GA_TEXTURE_COORDINATE_4 javax_media_j3d_GeometryArray_TEXTURE_COORDINATE_4 #define GA_TEXTURE_COORDINATE javax_media_j3d_GeometryArray_TEXTURE_COORDINATE +#define GA_VERTEX_ATTRIBUTES javax_media_j3d_GeometryArray_VERTEX_ATTRIBUTES #define GA_BY_REFERENCE javax_media_j3d_GeometryArray_BY_REFERENCE +/* + * These match the constants in ShaderAttributeObjectRetained + */ + +#define TYPE_INTEGER javax_media_j3d_ShaderAttributeObjectRetained_TYPE_INTEGER +#define TYPE_FLOAT javax_media_j3d_ShaderAttributeObjectRetained_TYPE_FLOAT +#define TYPE_TUPLE2I javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE2I +#define TYPE_TUPLE2F javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE2F +#define TYPE_TUPLE3I javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE3I +#define TYPE_TUPLE3F javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE3F +#define TYPE_TUPLE4I javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE4I +#define TYPE_TUPLE4F javax_media_j3d_ShaderAttributeObjectRetained_TYPE_TUPLE4F +#define TYPE_MATRIX3F javax_media_j3d_ShaderAttributeObjectRetained_TYPE_MATRIX3F +#define TYPE_MATRIX4F javax_media_j3d_ShaderAttributeObjectRetained_TYPE_MATRIX4F + /* * These match the constants in NativeConfigTemplate3D @@ -281,7 +298,7 @@ #define DOUBLEBUFFER javax_media_j3d_NativeConfigTemplate3D_DOUBLEBUFFER #define STEREO javax_media_j3d_NativeConfigTemplate3D_STEREO #define ANTIALIASING javax_media_j3d_NativeConfigTemplate3D_ANTIALIASING - +#define STENCIL_SIZE javax_media_j3d_NativeConfigTemplate3D_STENCIL_SIZE /* set this to the number of indices (from above) */ #define NUM_ITEMS (javax_media_j3d_NativeConfigTemplate3D_NUM_ITEMS + 2) @@ -302,8 +319,26 @@ #define J3D_RGB javax_media_j3d_Texture_RGB #define J3D_RGBA javax_media_j3d_Texture_RGBA + +/* + * These match the constants in TransparencyAttributes.java + */ +#define BLEND_ZERO javax_media_j3d_TransparencyAttributes_BLEND_ZERO +#define BLEND_ONE javax_media_j3d_TransparencyAttributes_BLEND_ONE +#define BLEND_SRC_ALPHA javax_media_j3d_TransparencyAttributes_BLEND_SRC_ALPHA +#define BLEND_ONE_MINUS_SRC_ALPHA javax_media_j3d_TransparencyAttributes_BLEND_ONE_MINUS_SRC_ALPHA +#define BLEND_DST_COLOR javax_media_j3d_TransparencyAttributes_BLEND_DST_COLOR +#define BLEND_ONE_MINUS_DST_COLOR javax_media_j3d_TransparencyAttributes_BLEND_ONE_MINUS_DST_COLOR +#define BLEND_SRC_COLOR javax_media_j3d_TransparencyAttributes_BLEND_SRC_COLOR +#define BLEND_ONE_MINUS_SRC_COLOR javax_media_j3d_TransparencyAttributes_BLEND_ONE_MINUS_SRC_COLOR +#define BLEND_CONSTANT_COLOR javax_media_j3d_TransparencyAttributes_BLEND_CONSTANT_COLOR +#define MAX_BLEND_FUNC_TABLE_SIZE javax_media_j3d_TransparencyAttributes_MAX_BLEND_FUNC_TABLE_SIZE + + + + #ifndef D3D -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) extern void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); extern void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); extern void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); @@ -347,7 +382,7 @@ extern void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLs extern int glXVideoResizeSUN( Display *, GLXDrawable, float); #endif -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ #ifndef APIENTRY #define APIENTRY @@ -389,14 +424,41 @@ typedef void (APIENTRY * MYPFNGLSHARPENTEXFUNCSGI) (GLenum target, GLsizei n, co typedef void (APIENTRY * MYPFNGLDETAILTEXFUNCSGI) (GLenum target, GLsizei n, const GLfloat *points); typedef void (APIENTRY * MYPFNGLTEXFILTERFUNCSGI) (GLenum target, GLenum filter, GLsizei n, const GLfloat *points); -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) typedef GLXFBConfig * (APIENTRY * MYPFNGLXCHOOSEFBCONFIG) (Display *dpy, int screen, const int *attrib_list, int *nelements); typedef int (APIENTRY * MYPFNGLXVIDEORESIZESUN) (Display * dpy, GLXDrawable draw, float factor); -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ + + +/* Typedef for context properties struct */ +typedef struct GraphicsContextPropertiesInfoRec GraphicsContextPropertiesInfo; + +/* Typedefs for language-independent vertex attribute functions */ +typedef void (*MYPFNVERTEXATTRPOINTER)(GraphicsContextPropertiesInfo *ctxProperties, + int index, int size, int type, int stride, + const void *pointer); +typedef void (*MYPFNENABLEVERTEXATTRARRAY)(GraphicsContextPropertiesInfo *ctxProperties, + int index); +typedef void (*MYPFNDISABLEVERTEXATTRARRAY)(GraphicsContextPropertiesInfo *ctxProperties, + int index); +typedef void (*MYPFNVERTEXATTR1FV)(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +typedef void (*MYPFNVERTEXATTR2FV)(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +typedef void (*MYPFNVERTEXATTR3FV)(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +typedef void (*MYPFNVERTEXATTR4FV)(GraphicsContextPropertiesInfo *ctxProperties, + int index, const float *v); +/* Typedefs for (opaque) GLSL context info */ +typedef struct GLSLCtxInfoRec GLSLCtxInfo; + +/* Typedefs for (opaque) Cg context info */ +typedef struct CgCtxInfoRec CgCtxInfo; + /* define the structure to hold the properties of graphics context */ -typedef struct { +struct GraphicsContextPropertiesInfoRec { jlong context; /* version and extension info */ @@ -423,7 +485,8 @@ typedef struct { /* GL_ARB_imaging subset */ /* GL_EXT_blend_color or GL_BLEND_COLOR */ jboolean blend_color_ext; - GLenum blendFunctionTable[8]; + GLenum blendFunctionTable[MAX_BLEND_FUNC_TABLE_SIZE]; + /* GL_SGI_color_table or GL_COLOR_TABLE */ jboolean color_table_ext; @@ -461,8 +524,6 @@ typedef struct { jboolean global_alpha_sun; /* GL_SUNX_constant_data */ jboolean constant_data_sun; - /* GL_SUNX_geometry_compression */ - jboolean geometry_compression_sunx; /* GL_EXT_abgr */ jboolean abgr_ext; @@ -477,7 +538,11 @@ typedef struct { /* GL_ARB_multitexture */ jboolean arb_multitexture; - int textureUnitCount; + int maxTexCoordSets; /* maximum number of texture coordinate sets */ + int maxTextureUnits; /* number of fixed-function texture units */ + int maxTextureImageUnits; /* number of fragment shader texture units */ + int maxVertexTextureImageUnits; /* number of vertex shader texture units */ + int maxCombinedTextureImageUnits; /* total number of shader texture units */ /* GL_SGI_texture_color_table */ jboolean textureColorTableAvailable; @@ -557,16 +622,11 @@ typedef struct { /* GL_SGIX_texture_lod_bias */ jboolean textureLodBiasAvailable; - - jboolean geometry_compression_accelerated; - int geometry_compression_accelerated_major_version; - int geometry_compression_accelerated_minor_version; - int geometry_compression_accelerated_subminor_version; - + /* extension mask */ jint extMask; jint textureExtMask; - + /* function pointers */ MYPFNGLBLENDCOLORPROC glBlendColor; MYPFNGLBLENDCOLOREXTPROC glBlendColorEXT; @@ -599,11 +659,36 @@ typedef struct { MYPFNGLDETAILTEXFUNCSGI glDetailTexFuncSGIS; MYPFNGLTEXFILTERFUNCSGI glTexFilterFuncSGIS; -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) MYPFNGLXVIDEORESIZESUN glXVideoResizeSUN; -#endif /* SOLARIS || __linux__ */ +#endif /* UNIX_ */ + + /* Shading language support */ + jboolean shadingLanguageGLSL; + jboolean shadingLanguageCg; -} GraphicsContextPropertiesInfo; + /* Function pointers for language-independent vertex attribute functions */ + MYPFNVERTEXATTRPOINTER vertexAttrPointer; + MYPFNENABLEVERTEXATTRARRAY enableVertexAttrArray; + MYPFNDISABLEVERTEXATTRARRAY disableVertexAttrArray; + MYPFNVERTEXATTR1FV vertexAttr1fv; + MYPFNVERTEXATTR2FV vertexAttr2fv; + MYPFNVERTEXATTR3FV vertexAttr3fv; + MYPFNVERTEXATTR4FV vertexAttr4fv; + + /* Pointer to currently bound shader program */ + jlong shaderProgramId; + + /* Implementation-dependent maximum number of vertex attributes */ + int maxVertexAttrs; + + /* GLSL shader context information */ + GLSLCtxInfo *glslCtxInfo; + + /* Cg shader context information */ + CgCtxInfo *cgCtxInfo; + +}; #ifdef WIN32 @@ -619,6 +704,8 @@ struct PixelFormatInfoRec { GLboolean onScreenHasStereo; GLboolean onScreenHasDoubleBuffer; GLboolean onScreenHasAccum; + int onScreenStencilSize; + /* Information about onScreen pixel format */ int offScreenPFormat; /* PixelFormat for offScreen */ GLboolean offScreenHasMultisample; /* TRUE if WGL_SAMPLE_BUFFERS_ARB is TRUE and @@ -626,6 +713,8 @@ struct PixelFormatInfoRec { GLboolean offScreenHasStereo; GLboolean offScreenHasDoubleBuffer; GLboolean offScreenHasAccum; + int offScreenStencilSize; + GLboolean drawToPbuffer; /* value of DRAW_TO_PBUFFER attr for offScreenPFormat */ /* Information about extension support */ @@ -652,7 +741,7 @@ typedef struct OffScreenBufferInfoRec OffScreenBufferInfo; struct OffScreenBufferInfoRec { GLboolean isPbuffer; /* GL_TRUE if Pbuffer is used. */ -#if defined(SOLARIS) || defined(__linux__) +#if defined(UNIX) #endif #ifdef WIN32 diff --git a/src/native/ogl/glext.h b/src/native/ogl/glext.h index 9549427..9e88dd9 100644 --- a/src/native/ogl/glext.h +++ b/src/native/ogl/glext.h @@ -1,15 +1,3 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - #ifndef __glext_h_ #define __glext_h_ @@ -18,12 +6,6 @@ extern "C" { #endif /* - * Portions of this code were derived from work done by the Blackdown - * group (www.blackdown.org), who did the initial Linux implementation - * of the Java 3D API. - */ - -/* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free ** Software License B, Version 1.1 (the "License"), the contents of this @@ -42,7 +24,7 @@ extern "C" { ** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. ** @@ -52,7 +34,7 @@ extern "C" { ** version 1.2.1 Specification. */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif @@ -60,13 +42,65 @@ extern "C" { #ifndef APIENTRY #define APIENTRY #endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif /*************************************************************/ /* Header file version number, required by OpenGL ABI for Linux */ -#define GL_GLEXT_VERSION 7 +/* glext.h last updated 2005/01/07 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 25 #ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 @@ -112,19 +146,6 @@ extern "C" { #define GL_MINMAX_FORMAT 0x802F #define GL_MINMAX_SINK 0x8030 #define GL_TABLE_TOO_LARGE 0x8031 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_COLOR_MATRIX 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 @@ -135,6 +156,7 @@ extern "C" { #define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB #define GL_COLOR_TABLE 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 @@ -151,11 +173,290 @@ extern "C" { #define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #endif #ifndef GL_ARB_multitexture @@ -215,6 +516,9 @@ extern "C" { #define GL_MULTISAMPLE_BIT_ARB 0x20000000 #endif +#ifndef GL_ARB_texture_env_add +#endif + #ifndef GL_ARB_texture_cube_map #define GL_NORMAL_MAP_ARB 0x8511 #define GL_REFLECTION_MAP_ARB 0x8512 @@ -238,12 +542,23 @@ extern "C" { #define GL_COMPRESSED_RGB_ARB 0x84ED #define GL_COMPRESSED_RGBA_ARB 0x84EE #define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 #define GL_TEXTURE_COMPRESSED_ARB 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 #endif +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + #ifndef GL_ARB_vertex_blend #define GL_MAX_VERTEX_UNITS_ARB 0x86A4 #define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 @@ -289,6 +604,356 @@ extern "C" { #define GL_MODELVIEW31_ARB 0x873F #endif +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891A +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -354,23 +1019,14 @@ extern "C" { #endif #ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D 0x806F #define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 #define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 #define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 #define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 #endif @@ -701,14 +1357,17 @@ extern "C" { #define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E #endif -#ifndef GL_SGIS_point_parameters +#ifndef GL_EXT_point_parameters #define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MIN_SGIS 0x8126 #define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 #define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 #define GL_DISTANCE_ATTENUATION_SGIS 0x8129 #endif @@ -996,6 +1655,16 @@ extern "C" { #define GL_ALPHA_MAX_SGIX 0x8321 #endif +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + #ifndef GL_EXT_bgra #define GL_BGR_EXT 0x80E0 #define GL_BGRA_EXT 0x80E1 @@ -1124,35 +1793,15 @@ extern "C" { #define GL_SOURCE0_RGB_EXT 0x8580 #define GL_SOURCE1_RGB_EXT 0x8581 #define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE3_RGB_EXT 0x8583 -#define GL_SOURCE4_RGB_EXT 0x8584 -#define GL_SOURCE5_RGB_EXT 0x8585 -#define GL_SOURCE6_RGB_EXT 0x8586 -#define GL_SOURCE7_RGB_EXT 0x8587 #define GL_SOURCE0_ALPHA_EXT 0x8588 #define GL_SOURCE1_ALPHA_EXT 0x8589 #define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_SOURCE3_ALPHA_EXT 0x858B -#define GL_SOURCE4_ALPHA_EXT 0x858C -#define GL_SOURCE5_ALPHA_EXT 0x858D -#define GL_SOURCE6_ALPHA_EXT 0x858E -#define GL_SOURCE7_ALPHA_EXT 0x858F #define GL_OPERAND0_RGB_EXT 0x8590 #define GL_OPERAND1_RGB_EXT 0x8591 #define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND3_RGB_EXT 0x8593 -#define GL_OPERAND4_RGB_EXT 0x8594 -#define GL_OPERAND5_RGB_EXT 0x8595 -#define GL_OPERAND6_RGB_EXT 0x8596 -#define GL_OPERAND7_RGB_EXT 0x8597 #define GL_OPERAND0_ALPHA_EXT 0x8598 #define GL_OPERAND1_ALPHA_EXT 0x8599 #define GL_OPERAND2_ALPHA_EXT 0x859A -#define GL_OPERAND3_ALPHA_EXT 0x859B -#define GL_OPERAND4_ALPHA_EXT 0x859C -#define GL_OPERAND5_ALPHA_EXT 0x859D -#define GL_OPERAND6_ALPHA_EXT 0x859E -#define GL_OPERAND7_ALPHA_EXT 0x859F #endif #ifndef GL_APPLE_specular_vector @@ -1179,9 +1828,9 @@ extern "C" { #endif #ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x01 -#define GL_REPLACE_MIDDLE_SUN 0x02 -#define GL_REPLACE_OLDEST_SUN 0x03 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 #define GL_TRIANGLE_LIST_SUN 0x81D7 #define GL_REPLACEMENT_CODE_SUN 0x81D8 #define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 @@ -1198,13 +1847,6 @@ extern "C" { #define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB #endif - /* DVR support --This is a temporary solution. Hopefully the new - glext.h from ARB will have GL_SUN_video_resize_compensation - defined. */ -#ifndef GL_SUN_video_resize_compensation -#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD -#endif - #ifndef GL_SUN_vertex #endif @@ -1284,7 +1926,7 @@ extern "C" { #define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 #define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW_MATRIX1_EXT 0x8506 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 #define GL_VERTEX_WEIGHTING_EXT 0x8509 #define GL_MODELVIEW0_EXT GL_MODELVIEW #define GL_MODELVIEW1_EXT 0x850A @@ -1485,6 +2127,7 @@ extern "C" { #define GL_SAMPLE_MASK_VALUE_EXT 0x80AA #define GL_SAMPLE_MASK_INVERT_EXT 0x80AB #define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 #endif #ifndef GL_SGIX_vertex_preclip @@ -1519,188 +2162,1457 @@ extern "C" { #define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF #endif +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + /*************************************************************/ +#include <stddef.h> +#ifndef GL_VERSION_2_0 +/* GL types for andling program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and characters */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +#ifndef GL_NV_half_float +/* GL type for representing NVIDIA "half" floating point type in host memory */ +typedef unsigned short GLhalfNV; +#endif + #ifndef GL_VERSION_1_2 - /* #define GL_VERSION_1_2 1, I am not sure about this one */ - -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -extern void APIENTRY glBlendEquation (GLenum); -extern void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -extern void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -extern void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -extern void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -extern void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -extern void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -extern void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -extern void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -extern void APIENTRY glResetHistogram (GLenum); -extern void APIENTRY glResetMinmax (GLenum); -extern void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glActiveTextureARB (GLenum); -extern void APIENTRY glClientActiveTextureARB (GLenum); -extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #endif #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -extern void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -extern void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -extern void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #endif #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -extern void APIENTRY glSamplePassARB (GLenum); +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRY * PFNGLSAMPLEPASSARBPROC) (GLenum pass); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); #endif #ifndef GL_ARB_texture_env_add @@ -1714,21 +3626,476 @@ typedef void (APIENTRY * PFNGLSAMPLEPASSARBPROC) (GLenum pass); #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, void *); +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 #endif #ifndef GL_EXT_abgr @@ -1738,17 +4105,17 @@ typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLin #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); #endif #ifndef GL_EXT_polygon_offset #define GL_EXT_polygon_offset 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); #endif #ifndef GL_EXT_texture @@ -1758,105 +4125,105 @@ typedef void (APIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bia #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); #endif #ifndef GL_SGIS_texture_filter4 #define GL_SGIS_texture_filter4 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -extern void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif #ifndef GL_EXT_subtexture #define GL_EXT_subtexture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); #endif #ifndef GL_EXT_copy_texture #define GL_EXT_copy_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -extern void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -extern void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -extern void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif #ifndef GL_EXT_histogram #define GL_EXT_histogram 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -extern void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -extern void APIENTRY glResetHistogramEXT (GLenum); -extern void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); #endif #ifndef GL_EXT_convolution #define GL_EXT_convolution 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -extern void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -extern void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -extern void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #endif #ifndef GL_EXT_color_matrix @@ -1866,57 +4233,57 @@ typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum i #ifndef GL_SGI_color_table #define GL_SGI_color_table 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); #endif #ifndef GL_SGIX_pixel_texture #define GL_SGIX_pixel_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTexGenSGIX (GLenum); +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #endif #ifndef GL_SGIS_pixel_texture #define GL_SGIS_pixel_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -extern void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -extern void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -extern void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -extern void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -extern void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); #endif #ifndef GL_SGIS_texture4D #define GL_SGIS_texture4D 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); #endif #ifndef GL_SGI_texture_color_table @@ -1930,39 +4297,39 @@ typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level #ifndef GL_EXT_texture_object #define GL_EXT_texture_object 1 #ifdef GL_GLEXT_PROTOTYPES -extern GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -extern void APIENTRY glBindTextureEXT (GLenum, GLuint); -extern void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -extern void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -extern GLboolean APIENTRY glIsTextureEXT (GLuint); -extern void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); #endif #ifndef GL_SGIS_detail_texture #define GL_SGIS_detail_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #endif #ifndef GL_SGIS_sharpen_texture #define GL_SGIS_sharpen_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #endif #ifndef GL_EXT_packed_pixels @@ -1976,11 +4343,11 @@ typedef void (APIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat #ifndef GL_SGIS_multisample #define GL_SGIS_multisample 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -extern void APIENTRY glSamplePatternSGIS (GLenum); +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #endif #ifndef GL_EXT_rescale_normal @@ -1990,25 +4357,25 @@ typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #ifndef GL_EXT_vertex_array #define GL_EXT_vertex_array 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glArrayElementEXT (GLint); -extern void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -extern void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -extern void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -extern void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); #endif #ifndef GL_EXT_misc_attribute @@ -2038,9 +4405,9 @@ typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GL #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendEquationEXT (GLenum); +GLAPI void APIENTRY glBlendEquationEXT (GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #endif #ifndef GL_EXT_blend_subtract @@ -2066,15 +4433,15 @@ typedef void (APIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #ifndef GL_SGIX_sprite #define GL_SGIX_sprite 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -extern void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -extern void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -extern void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #endif #ifndef GL_SGIX_texture_multi_buffer @@ -2084,33 +4451,39 @@ typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GL #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -extern void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -extern void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -extern void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #endif #ifndef GL_SGIX_instruments #define GL_SGIX_instruments 1 #ifdef GL_GLEXT_PROTOTYPES -extern GLint APIENTRY glGetInstrumentsSGIX (void); -extern void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -extern GLint APIENTRY glPollInstrumentsSGIX (GLint *); -extern void APIENTRY glReadInstrumentsSGIX (GLint); -extern void APIENTRY glStartInstrumentsSGIX (void); -extern void APIENTRY glStopInstrumentsSGIX (GLint); +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRY * PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRY * PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRY * PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRY * PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRY * PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRY * PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #endif #ifndef GL_SGIX_texture_scale_bias @@ -2120,47 +4493,47 @@ typedef void (APIENTRY * PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #ifndef GL_SGIX_framezoom #define GL_SGIX_framezoom 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFrameZoomSGIX (GLint); +GLAPI void APIENTRY glFrameZoomSGIX (GLint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); #endif #ifndef GL_SGIX_tag_sample_buffer #define GL_SGIX_tag_sample_buffer 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTagSampleBufferSGIX (void); +GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #endif #ifndef GL_SGIX_polynomial_ffd #define GL_SGIX_polynomial_ffd 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -extern void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -extern void APIENTRY glDeformSGIX (GLbitfield); -extern void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRY * PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRY * PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRY * PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); #endif #ifndef GL_SGIX_reference_plane #define GL_SGIX_reference_plane 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glReferencePlaneSGIX (const GLdouble *); +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); #endif #ifndef GL_SGIX_flush_raster #define GL_SGIX_flush_raster 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFlushRasterSGIX (void); +GLAPI void APIENTRY glFlushRasterSGIX (void); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); #endif #ifndef GL_SGIX_depth_texture @@ -2170,11 +4543,11 @@ typedef void (APIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); #ifndef GL_SGIS_fog_function #define GL_SGIS_fog_function 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -extern void APIENTRY glGetFogFuncSGIS (const GLfloat *); +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRY * PFNGLGETFOGFUNCSGISPROC) (const GLfloat *points); +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #endif #ifndef GL_SGIX_fog_offset @@ -2184,19 +4557,19 @@ typedef void (APIENTRY * PFNGLGETFOGFUNCSGISPROC) (const GLfloat *points); #ifndef GL_HP_image_transform #define GL_HP_image_transform 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -extern void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -extern void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -extern void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -extern void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); #endif #ifndef GL_HP_convolution_border_modes @@ -2210,11 +4583,11 @@ typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target #ifndef GL_EXT_color_subtable #define GL_EXT_color_subtable 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif #ifndef GL_PGI_vertex_hints @@ -2224,23 +4597,23 @@ typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei #ifndef GL_PGI_misc_hints #define GL_PGI_misc_hints 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glHintPGI (GLenum, GLint); +GLAPI void APIENTRY glHintPGI (GLenum, GLint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLHINTPGIPROC) (GLenum target, GLint mode); +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #endif #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); #endif #ifndef GL_EXT_clip_volume_hint @@ -2250,19 +4623,19 @@ typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, G #ifndef GL_SGIX_list_priority #define GL_SGIX_list_priority 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -extern void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -extern void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -extern void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -extern void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #endif #ifndef GL_SGIX_ir_instrument1 @@ -2288,17 +4661,17 @@ typedef void (APIENTRY * PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pnam #ifndef GL_EXT_index_material #define GL_EXT_index_material 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #endif #ifndef GL_EXT_index_func #define GL_EXT_index_func 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); #endif #ifndef GL_EXT_index_array_formats @@ -2308,21 +4681,21 @@ typedef void (APIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); #ifndef GL_EXT_compiled_vertex_array #define GL_EXT_compiled_vertex_array 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glLockArraysEXT (GLint, GLsizei); -extern void APIENTRY glUnlockArraysEXT (void); +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #endif #ifndef GL_EXT_cull_vertex #define GL_EXT_cull_vertex 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -extern void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); #endif #ifndef GL_SGIX_ycrcb @@ -2332,43 +4705,43 @@ typedef void (APIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *pa #ifndef GL_SGIX_fragment_lighting #define GL_SGIX_fragment_lighting 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -extern void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -extern void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -extern void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -extern void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -extern void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -extern void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -extern void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -extern void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -extern void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -extern void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -extern void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -extern void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -extern void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #endif #ifndef GL_IBM_rasterpos_clip @@ -2382,9 +4755,9 @@ typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #ifndef GL_EXT_draw_range_elements #define GL_EXT_draw_range_elements 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); #endif #ifndef GL_WIN_phong_shading @@ -2398,13 +4771,13 @@ typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint sta #ifndef GL_EXT_light_texture #define GL_EXT_light_texture 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glApplyTextureEXT (GLenum); -extern void APIENTRY glTextureLightEXT (GLenum); -extern void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); #endif #ifndef GL_SGIX_blend_alpha_minmax @@ -2418,19 +4791,19 @@ typedef void (APIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode) #ifndef GL_SGIX_async #define GL_SGIX_async 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glAsyncMarkerSGIX (GLuint); -extern GLint APIENTRY glFinishAsyncSGIX (GLuint *); -extern GLint APIENTRY glPollAsyncSGIX (GLuint *); -extern GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -extern void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -extern GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #endif #ifndef GL_SGIX_async_pixel @@ -2444,15 +4817,15 @@ typedef GLboolean (APIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifndef GL_INTEL_parallel_arrays #define GL_INTEL_parallel_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -extern void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -extern void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -extern void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); #endif #ifndef GL_HP_occlusion_test @@ -2462,15 +4835,15 @@ typedef void (APIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum typ #ifndef GL_EXT_pixel_transform #define GL_EXT_pixel_transform 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -extern void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -extern void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -extern void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); #endif #ifndef GL_EXT_pixel_transform_color_table @@ -2488,75 +4861,75 @@ typedef void (APIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, #ifndef GL_EXT_secondary_color #define GL_EXT_secondary_color 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -extern void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -extern void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -extern void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -extern void APIENTRY glSecondaryColor3ivEXT (const GLint *); -extern void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glSecondaryColor3svEXT (const GLshort *); -extern void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -extern void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -extern void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -extern void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -extern void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -extern void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -extern void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_EXT_texture_perturb_normal #define GL_EXT_texture_perturb_normal 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTextureNormalEXT (GLenum); +GLAPI void APIENTRY glTextureNormalEXT (GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); #endif #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFogCoordfEXT (GLfloat); -extern void APIENTRY glFogCoordfvEXT (const GLfloat *); -extern void APIENTRY glFogCoorddEXT (GLdouble); -extern void APIENTRY glFogCoorddvEXT (const GLdouble *); -extern void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_REND_screen_coordinates @@ -2566,51 +4939,51 @@ typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stri #ifndef GL_EXT_coordinate_frame #define GL_EXT_coordinate_frame 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glTangent3bvEXT (const GLbyte *); -extern void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glTangent3dvEXT (const GLdouble *); -extern void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTangent3fvEXT (const GLfloat *); -extern void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -extern void APIENTRY glTangent3ivEXT (const GLint *); -extern void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glTangent3svEXT (const GLshort *); -extern void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glBinormal3bvEXT (const GLbyte *); -extern void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glBinormal3dvEXT (const GLdouble *); -extern void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glBinormal3fvEXT (const GLfloat *); -extern void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -extern void APIENTRY glBinormal3ivEXT (const GLint *); -extern void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glBinormal3svEXT (const GLshort *); -extern void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRY * PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRY * PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRY * PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRY * PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRY * PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRY * PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRY * PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRY * PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRY * PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRY * PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRY * PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRY * PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRY * PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_EXT_texture_env_combine @@ -2632,145 +5005,153 @@ typedef void (APIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stri #ifndef GL_SUNX_constant_data #define GL_SUNX_constant_data 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFinishTextureSUNX (void); +GLAPI void APIENTRY glFinishTextureSUNX (void); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); #endif #ifndef GL_SUN_global_alpha #define GL_SUN_global_alpha 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -extern void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -extern void APIENTRY glGlobalAlphaFactoriSUN (GLint); -extern void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -extern void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -extern void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -extern void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -extern void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); #endif #ifndef GL_SUN_triangle_list #define GL_SUN_triangle_list 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glReplacementCodeuiSUN (GLuint); -extern void APIENTRY glReplacementCodeusSUN (GLushort); -extern void APIENTRY glReplacementCodeubSUN (GLubyte); -extern void APIENTRY glReplacementCodeuivSUN (const GLuint *); -extern void APIENTRY glReplacementCodeusvSUN (const GLushort *); -extern void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -extern void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); #endif #ifndef GL_SUN_vertex #define GL_SUN_vertex 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -extern void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -extern void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -extern void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLenum *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLenum, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLenum *, const GLubyte *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLenum, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLenum *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLenum rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLenum rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLenum *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLenum rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLenum rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLenum *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #endif #ifndef GL_EXT_blend_func_separate #define GL_EXT_blend_func_separate 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif #ifndef GL_INGR_color_clamp @@ -2812,13 +5193,13 @@ typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLen #ifndef GL_EXT_vertex_weighting #define GL_EXT_vertex_weighting 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexWeightfEXT (GLfloat); -extern void APIENTRY glVertexWeightfvEXT (const GLfloat *); -extern void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif #ifndef GL_NV_light_max_exponent @@ -2828,43 +5209,43 @@ typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFlushVertexArrayRangeNV (void); -extern void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei size, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); #endif #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -extern void APIENTRY glCombinerParameteriNV (GLenum, GLint); -extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); #endif #ifndef GL_NV_fog_distance @@ -2886,63 +5267,63 @@ typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum va #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glResizeBuffersMESA (void); +GLAPI void APIENTRY glResizeBuffersMESA (void); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); #endif #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -extern void APIENTRY glWindowPos2dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -extern void APIENTRY glWindowPos2fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos2iMESA (GLint, GLint); -extern void APIENTRY glWindowPos2ivMESA (const GLint *); -extern void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -extern void APIENTRY glWindowPos2svMESA (const GLshort *); -extern void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos3dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos3fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -extern void APIENTRY glWindowPos3ivMESA (const GLint *); -extern void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos3svMESA (const GLshort *); -extern void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos4dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos4fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -extern void APIENTRY glWindowPos4ivMESA (const GLint *); -extern void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); #endif #ifndef GL_IBM_cull_vertex @@ -2952,33 +5333,33 @@ typedef void (APIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); #ifndef GL_IBM_multimode_draw_arrays #define GL_IBM_multimode_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glMultiModeDrawArraysIBM (GLenum, const GLint *, const GLsizei *, GLsizei, GLint); -extern void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); #endif #ifndef GL_IBM_vertex_array_lists #define GL_IBM_vertex_array_lists 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -extern void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); #endif #ifndef GL_SGIX_subsample @@ -3008,23 +5389,23 @@ typedef void (APIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type #ifndef GL_3DFX_tbuffer #define GL_3DFX_tbuffer 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTbufferMask3DFX (GLuint); +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #endif #ifndef GL_EXT_multisample #define GL_EXT_multisample 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -extern void APIENTRY glSamplePatternEXT (GLenum); +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); #endif -#ifndef GL_SGI_vertex_preclip -#define GL_SGI_vertex_preclip 1 +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 #endif #ifndef GL_SGIX_convolution_accuracy @@ -3042,17 +5423,949 @@ typedef void (APIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); #ifndef GL_SGIS_texture_color_mask #define GL_SGIS_texture_color_mask 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif #ifndef GL_SGIX_igloo_interface #define GL_SGIX_igloo_interface 1 #ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRY * PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 #endif diff --git a/src/native/ogl/wglext.h b/src/native/ogl/wglext.h index d1ab334..9dcee14 100644 --- a/src/native/ogl/wglext.h +++ b/src/native/ogl/wglext.h @@ -52,9 +52,9 @@ extern "C" { /*************************************************************/ /* Header file version number */ -/* wglext.h last updated 2004/07/26 */ +/* wglext.h last updated 2005/01/07 */ /* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define WGL_WGLEXT_VERSION 5 +#define WGL_WGLEXT_VERSION 6 #ifndef WGL_ARB_buffer_region #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 @@ -175,6 +175,10 @@ extern "C" { #define WGL_AUX9_ARB 0x2090 #endif +#ifndef WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + #ifndef WGL_EXT_make_current_read #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 #endif @@ -401,6 +405,10 @@ typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); #endif +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#endif + #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 #ifdef WGL_WGLEXT_PROTOTYPES @@ -611,6 +619,10 @@ typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWO #define WGL_ATI_pixel_format_float 1 #endif +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#endif + #ifdef __cplusplus } diff --git a/src/native/share/build-linux-amd64.xml b/src/native/share/build-linux-amd64.xml index d3ff24b..5f49d61 100644 --- a/src/native/share/build-linux-amd64.xml +++ b/src/native/share/build-linux-amd64.xml @@ -27,7 +27,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m64 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-m64 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> diff --git a/src/native/share/build-linux-i586.xml b/src/native/share/build-linux-i586.xml index 61d4434..29ee376 100644 --- a/src/native/share/build-linux-i586.xml +++ b/src/native/share/build-linux-i586.xml @@ -27,7 +27,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m32 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-m32 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> diff --git a/src/native/share/build-linux-ia64.xml b/src/native/share/build-linux-ia64.xml index 8188048..2457b35 100644 --- a/src/native/share/build-linux-ia64.xml +++ b/src/native/share/build-linux-ia64.xml @@ -27,7 +27,7 @@ <!-- Compile the c source files; based on build-linux-amd64.xml--> <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line=" -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line=" -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file; based on build-linux-amd64.xml--> diff --git a/src/native/share/build-linux-ppc.xml b/src/native/share/build-linux-ppc.xml new file mode 100644 index 0000000..50154d6 --- /dev/null +++ b/src/native/share/build-linux-ppc.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native utilities files for Linux --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 64 bit native utilities build [${bldType}]"/> + + <!-- Create the build directories linux --> + <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/bin"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> + <arg line="-I/include -I${java.home}/../include -I${java.home}/../include/linux -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> + <arg line="J3DTimer.o -G -z lazyload -lc -o libj3dutils.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" + todir="${build}/${platform}/${bldType}/bin"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/bin"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/bin/libj3dutils.so" + todir="${dist}/${platform}/bin"/> + </target> + + +</project> diff --git a/src/native/share/build-solaris-sparc-forte.xml b/src/native/share/build-solaris-sparc-forte.xml index 3ffe83f..43b2ee1 100644 --- a/src/native/share/build-solaris-sparc-forte.xml +++ b/src/native/share/build-solaris-sparc-forte.xml @@ -27,7 +27,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> @@ -48,7 +48,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> diff --git a/src/native/share/build-solaris-sparc-gcc.xml b/src/native/share/build-solaris-sparc-gcc.xml index f179591..afe17b4 100644 --- a/src/native/share/build-solaris-sparc-gcc.xml +++ b/src/native/share/build-solaris-sparc-gcc.xml @@ -27,7 +27,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m32 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-m32 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> @@ -48,7 +48,7 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="gcc"> - <arg line="-m64 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} -${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + <arg line="-m64 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> </exec> <!-- Create the library file--> diff --git a/src/native/share/build-solaris-x86-forte.xml b/src/native/share/build-solaris-x86-forte.xml new file mode 100644 index 0000000..8f72eb7 --- /dev/null +++ b/src/native/share/build-solaris-x86-forte.xml @@ -0,0 +1,86 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native utilities files for Solaris --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 32 bit native utilities build [${bldType}]"/> + + <!-- Create the build directories i386 --> + <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="cc"> + <arg line="-v -xCC -xchip=pentium3 -xarch=generic -KPIC -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> + <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" + todir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- + /* + * TODO: only do the 64-bit build if isSolarisOnX86_64 property is + * set, indicating that a 64-bit JVM is available + */ + --> + +<!-- ********************************************************************** --> + <echo message="Executing 64 bit native utilities build [${bldType}]"/> + + <!-- Create the build directories amd64 --> + <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/amd64"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="cc"> + <arg line="-v -xCC -xchip=opteron -xarch=amd64 -KPIC -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="ld"> + <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/share/objs/amd64/libj3dutils.so" + todir="${build}/${platform}/${bldType}/lib/amd64"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/lib/i386"/> + <mkdir dir="${dist}/${platform}/lib/amd64"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/lib/i386/libj3dutils.so" + todir="${dist}/${platform}/lib/i386"/> + + <copy file="${build}/${platform}/opt/lib/amd64/libj3dutils.so" + todir="${dist}/${platform}/lib/amd64"/> + </target> + + +</project> diff --git a/src/native/share/build-solaris-x86-gcc.xml b/src/native/share/build-solaris-x86-gcc.xml new file mode 100644 index 0000000..01ffdc4 --- /dev/null +++ b/src/native/share/build-solaris-x86-gcc.xml @@ -0,0 +1,86 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Ant file for building native utilities files for Solaris --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 32 bit native utilities build [${bldType}]"/> + + <!-- Create the build directories i386 --> + <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> + <arg line="-m32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> + <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" + todir="${build}/${platform}/${bldType}/lib/i386"/> + + <!-- + /* + * TODO: only do the 64-bit build if isSolarisOnX86_64 property is + * set, indicating that a 64-bit JVM is available + */ + --> + +<!-- ********************************************************************** --> + <echo message="Executing 64 bit native utilities build [${bldType}]"/> + + <!-- Create the build directories amd64 --> + <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/amd64"/> + <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="gcc"> + <arg line="-m64 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="ld"> + <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/share/objs/amd64/libj3dutils.so" + todir="${build}/${platform}/${bldType}/lib/amd64"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/lib/i386"/> + <mkdir dir="${dist}/${platform}/lib/amd64"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/lib/i386/libj3dutils.so" + todir="${dist}/${platform}/lib/i386"/> + + <copy file="${build}/${platform}/opt/lib/amd64/libj3dutils.so" + todir="${dist}/${platform}/lib/amd64"/> + </target> + + +</project> |