001: /*
002: * $RCSfile: ShaderAttributeBinding.java,v $
003: *
004: * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.5 $
028: * $Date: 2008/02/28 20:17:29 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035:
036: /**
037: * The ShaderAttributeBinding object encapsulates a uniform attribute
038: * whose value is bound to a Java 3D system attribute. The
039: * shader variable <code>attrName</code> is implicitly set to the
040: * value of the corresponding Java 3D system attribute
041: * <code>j3dAttrName</code> during rendering. <code>attrName</code>
042: * must be the name of a valid uniform attribute in the shader in
043: * which it is used. Otherwise, the attribute name will be ignored and
044: * a runtime error may be generated. <code>j3dAttrName</code> must be
045: * the name of a predefined Java 3D system attribute. An
046: * IllegalArgumentException will be thrown if the specified
047: * <code>j3dAttrName</code> is not one of the predefined system
048: * attributes. Further, the type of the <code>j3dAttrName</code>
049: * attribute must match the type of the corresponding
050: * <code>attrName</code> variable in the shader in which it is
051: * used. Otherwise, the shader will not be able to use the attribute
052: * and a runtime error may be generated.
053: *
054: * <p>
055: * Following is the list of predefined Java 3D system attributes:<br>
056: *
057: * <ul>
058: * <font color="#ff0000"><i>TODO: replace the following with
059: * the real system attributes table</i></font><br>
060: * <table BORDER=1 CELLSPACING=2 CELLPADDING=2>
061: * <tr>
062: * <td><b>Name</b></td>
063: * <td><b>Type</b></td>
064: * <td><b>Description</b></td>
065: * </tr>
066: * <tr>
067: * <td><code>something</code></td>
068: * <td>Float</td>
069: * <td>This is something (of course)</td>
070: * </tr>
071: * <tr>
072: * <td><code>somethingElse</code></td>
073: * <td>Tuple3f</td>
074: * <td>This is something else</td>
075: * </tr>
076: * </table>
077: * </ul>
078: *
079: * <p>
080: * Depending on the shading language (and profile) being used, several
081: * Java 3D state attributes are automatically made available to the
082: * shader program as pre-defined uniform attributes. The application
083: * doesn't need to do anything to pass these attributes in to the
084: * shader program. The implementation of each shader language (e.g.,
085: * Cg, GLSL) defines its own mapping from Java 3D attribute to uniform
086: * variable name.
087: *
088: * <p>
089: * A list of these attributes for each shader language can be found in
090: * the concrete subclass of ShaderProgram for that shader language.
091: *
092: * <p>
093: * <font color="#ff0000"><i>NOTE: This class is not yet
094: * implemented.</i></font><br>
095: *
096: * @see ShaderAttributeSet
097: * @see ShaderProgram
098: *
099: * @since Java 3D 1.4
100: */
101:
102: public class ShaderAttributeBinding extends ShaderAttribute {
103:
104: /**
105: * Constructs a new ShaderAttributeBinding from the specified
106: * <code>(attrName, j3dAttrName)</code> pair.
107: *
108: * @param attrName the name of the shader attribute to be added
109: * @param j3dAttrName the name of the Java 3D attribute
110: * to bind to the shader attribute
111: *
112: * @exception UnsupportedOperationException this class is not
113: * yet implemented
114: *
115: * @exception NullPointerException if attrName or j3dAttrName is null
116: *
117: * @exception IllegalArgumentException if j3dAttrName is not the name
118: * of a valid predefined Java 3D system attribute
119: */
120: public ShaderAttributeBinding(String attrName, String j3dAttrName) {
121: super (attrName);
122: ((ShaderAttributeBindingRetained) this .retained)
123: .initJ3dAttrName(j3dAttrName);
124: // TODO: implement this class
125: throw new UnsupportedOperationException(J3dI18N
126: .getString("ShaderAttributeBinding0"));
127: }
128:
129: /**
130: * Retrieves the name of the Java 3D system attribute that is bound to this
131: * shader attribute.
132: *
133: * @return the name of the Java 3D system attribute that is bound to this
134: * shader attribute
135: */
136: public String getJ3DAttributeName() {
137: return ((ShaderAttributeBindingRetained) this .retained)
138: .getJ3DAttributeName();
139: }
140:
141: /**
142: * Creates a retained mode ShaderAttributeBindingRetained object that this
143: * ShaderAttributeBinding component object will point to.
144: */
145: void createRetained() {
146: this .retained = new ShaderAttributeBindingRetained();
147: this.retained.setSource(this);
148: }
149:
150: }
|