/*
* VertexProgram.java
*
* Created on January 24, 2004, 12:44 AM
*/
package com.xith3d.scenegraph;
/**
*
* @author Abdul
*/
/**
* Copyright (c) 2003, Xith3D Project Group
* All rights reserved.
*
* Portions based on the Java3D interface, Copyright by Sun Microsystems.
* Many thanks to the developers of Java3D and Sun Microsystems for their
* innovation and design.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the 'Xith3D Project Group' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) A
* RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE
*
*/
import javax.vecmath.Vector4f;
public class VertexProgram extends ShaderProgram {
public VertexProgram() {
super("!!ARBvp1.0 \n END");
}
public VertexProgram(String vertexProgram) {
super(vertexProgram);
}
public VertexProgram(String vertexProgram,
Vector4f parameters[]) {
super(vertexProgram, parameters);
}
public VertexProgram(String vertexProgram,
Vector4f parameters[],
boolean enabled) {
super(vertexProgram, parameters, enabled);
}
/**
* @see com.xith3d.scenegraph.NodeComponent#duplicateNodeComponent(com.xith3d.scenegraph.NodeComponent, boolean)
*/
public void duplicateNodeComponent(NodeComponent original, boolean forceDuplicate) {
super.duplicateNodeComponent(original,forceDuplicate);
}
/**
* @see com.xith3d.scenegraph.NodeComponent#cloneNodeComponent(boolean)
*/
public NodeComponent cloneNodeComponent(boolean forceDuplicate) {
VertexProgram vp = new VertexProgram();
vp.duplicateNodeComponent(this, forceDuplicate);
return vp;
}
}
/**
* Copyright (c) 2003, Xith3D Project Group
* All rights reserved.
*
* Portions based on the Java3D interface, Copyright by Sun Microsystems.
* Many thanks to the developers of Java3D and Sun Microsystems for their
* innovation and design.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the 'Xith3D Project Group' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) A
* RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE
*
*/
package com.xith3d.scenegraph;
import java.nio.*;
import javax.vecmath.Vector4f;
abstract public class ShaderProgram extends NodeComponent {
static long SH_PRO_STATE_ID_SEQ = 0;
// Create an IntBuffer for the shaderProgram name
private IntBuffer shaderProgramNames = null;
// Get vertexProgram name address
private int shaderProgramNameAddr = 0;
private String shaderProgram = "";
private boolean enabled = true;
private Vector4f shaderProgramParameters[] = null;
private Object shaderProgramHandleCanvasID = null;
private int shaderProgramHandle = -1;
private long shProStateId;
private boolean dirty = false;
public ShaderProgram() {
super();
shProStateId = SH_PRO_STATE_ID_SEQ++;
}
public ShaderProgram(String shaderProgram){
this();
this.shaderProgram = shaderProgram;
}
public ShaderProgram(String shaderProgram,
Vector4f[] parameters){
this();
this.shaderProgram = shaderProgram;
shaderProgramParameters = new Vector4f[parameters.length];
for(int i = 0; i < parameters.length; i++)
shaderProgramParameters[i] = new Vector4f(parameters[i]);
}
public ShaderProgram(String shaderProgram,
Vector4f[] parameters,
boolean shaderState){
this();
shaderProgramParameters = new Vector4f[parameters.length];
for(int i = 0; i < parameters.length; i++)
shaderProgramParameters[i] = new Vector4f(parameters[i]);
enabled = shaderState;
}
public final void setShaderProgram(String shaderProgram){
this.shaderProgram = shaderProgram;
dirty = true;
}
public final void setEnabled(boolean programState){
enabled = programState;
}
public final void setParameters(Vector4f[] parameters){
shaderProgramParameters = new Vector4f[parameters.length];
for(int i = 0; i < parameters.length; i++)
shaderProgramParameters[i] = new Vector4f(parameters[i]);
dirty = true;
}
public String getShaderProgram(){
return shaderProgram;
}
public boolean isEnabled(){
return enabled;
}
public Vector4f[] getParameters(){
Vector4f parameters[] = new Vector4f[shaderProgramParameters.length];
for(int i = 0; i < parameters.length; i++)
parameters[i] = new Vector4f(shaderProgramParameters[i]);
return parameters;
}
public boolean isDirty() {
return dirty;
}
public void setDirty( boolean dirty ) {
this.dirty = dirty;
}
public int getShaderProgramHandle(Object shaderProgramHandleCanvasID) {
if (this.shaderProgramHandleCanvasID == shaderProgramHandleCanvasID)
return shaderProgramHandle;
else
return -1;
}
/**
* @see com.xith3d.scenegraph.NodeComponent#duplicateNodeComponent(com.xith3d.scenegraph.NodeComponent, boolean)
*/
public void duplicateNodeComponent(NodeComponent original, boolean forceDuplicate) {
super.duplicateNodeComponent(original,forceDuplicate);
throw new UnsupportedOperationException("Not implemented yet");
}
/**
* returns the state ID used to sort the item
* @return
*/
public long getStateId() {
return shProStateId;
}
}
PS: Could someone with Xith3D source installed on his pc try and compile the two previous classes in the mentioned directory.
Thanks