001: /*
002: * $RCSfile: SourceCodeShaderRetained.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.7 $
028: * $Date: 2008/02/28 20:17:31 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The SourceCodeShaderRetained object is a shader that is defined using
036: * text-based source code. It is used to define the source code for
037: * both vertex and fragment shaders. The currently supported shading
038: * languages are Cg and GLSL.
039: */
040:
041: class SourceCodeShaderRetained extends ShaderRetained {
042:
043: private String shaderSource = null;
044:
045: /**
046: * Constructs a new shader retained object of the specified shading
047: * language and shader type from the specified source string.
048: */
049:
050: SourceCodeShaderRetained() {
051: }
052:
053: // This method is similar to setShaderSource().
054: // To conform to j3d frame in retained creation, we will stick with method
055: // with init name.
056: final void initShaderSource(String shaderSource) {
057: this .shaderSource = shaderSource;
058: }
059:
060: final void set(int shadingLanguage, int shaderType,
061: String shaderSource) {
062: this .shadingLanguage = shadingLanguage;
063: this .shaderType = shaderType;
064: this .shaderSource = shaderSource;
065: }
066:
067: /**
068: * Retrieves the shader source string from this shader object.
069: *
070: * @return the shader source string.
071: */
072: final String getShaderSource() {
073: return shaderSource;
074: }
075:
076: final void setShaderSource(String shaderSource) {
077: this .shaderSource = shaderSource;
078: }
079:
080: synchronized void createMirrorObject() {
081: // System.err.println("SourceCodeShaderRetained : createMirrorObject");
082:
083: if (mirror == null) {
084: SourceCodeShaderRetained mirrorSCS = new SourceCodeShaderRetained();
085: mirror = mirrorSCS;
086: }
087:
088: initMirrorObject();
089: }
090:
091: /**
092: * Initializes a mirror object.
093: */
094: synchronized void initMirrorObject() {
095: mirror.source = source;
096:
097: ((SourceCodeShaderRetained) mirror).set(shadingLanguage,
098: shaderType, shaderSource);
099: ((SourceCodeShaderRetained) mirror).shaderData = null;
100: }
101:
102: synchronized void updateMirrorObject(int component, Object value) {
103: System.err
104: .println("SourceCodeShader.updateMirrorObject not implemented yet!");
105: }
106:
107: }
|