diff options
author | Kenneth Russel <[email protected]> | 2007-03-18 11:58:01 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2007-03-18 11:58:01 +0000 |
commit | e1f4a731f55ab29e3f23f87102af1b11c67cb0da (patch) | |
tree | 244171ec6562416e3c44341c13f903a29ad44c69 /src/net/java/joglutils/msg/elements | |
parent | 208b84ae11288b4edd190364528289240303cb5d (diff) |
Initial checkin of the Minimal Scene Graph (MSG) library, intentended
for experimentation with both 3D and 2D/3D interaction.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@44 83d24430-9974-4f80-8418-2cc3294053b9
Diffstat (limited to 'src/net/java/joglutils/msg/elements')
18 files changed, 1713 insertions, 0 deletions
diff --git a/src/net/java/joglutils/msg/elements/BlendElement.java b/src/net/java/joglutils/msg/elements/BlendElement.java new file mode 100644 index 0000000..2a0d488 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/BlendElement.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; +import net.java.joglutils.msg.nodes.*; + +/** Represents the blending state of the OpenGL fixed-function pipeline. */ + +public class BlendElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new BlendElement(); + } + /** Returns the instance of this element in the passed State. */ + public static BlendElement getInstance(State state) { + return (BlendElement) state.getElement(index); + } + /** Enables this element in the passed state, which should be the + default for a given action. */ + public static void enable(State defaultState) { + BlendElement tmp = new BlendElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // These defaults match those in the Blend node -- is there a better way of factoring them out? + + // Whether blending is enabled + protected boolean enabled; + protected Vec4f blendColor = new Vec4f(); + protected int srcFunc = Blend.ONE; + protected int destFunc = Blend.ZERO; + protected int blendEquation = Blend.FUNC_ADD; + + /** Sets all of the portions of the blending state in the passed State object. */ + public static void set(State state, + boolean enabled, + Vec4f blendColor, + int srcFunc, + int destFunc, + int blendEquation) { + getInstance(state).setElt(enabled, + blendColor, + srcFunc, + destFunc, + blendEquation); + } + + /** Returns whether blending is enabled. */ + public static boolean getEnabled(State state) { + return getInstance(state).enabled; + } + + /** Returns the blending color. */ + public static Vec4f getBlendColor(State state) { + return getInstance(state).blendColor; + } + + /** Returns the source function for blending. */ + public static int getSourceFunc(State state) { + return getInstance(state).srcFunc; + } + + /** Returns the destination function for blending. */ + public static int getDestFunc(State state) { + return getInstance(state).destFunc; + } + + /** Returns the blending equation. */ + public static int getBlendEquation(State state) { + return getInstance(state).blendEquation; + } + + public void push(State state) { + BlendElement prev = (BlendElement) getNextInStack(); + if (prev != null) { + // Pull down the data from the previous element + enabled = prev.enabled; + blendColor.set(prev.blendColor); + srcFunc = prev.srcFunc; + destFunc = prev.destFunc; + blendEquation = prev.blendEquation; + } + } + + /** Sets all of the portions of the blending state in this element. */ + public void setElt(boolean enabled, + Vec4f blendColor, + int srcFunc, + int destFunc, + int blendEquation) { + this.enabled = enabled; + this.blendColor.set(blendColor); + this.srcFunc = srcFunc; + this.destFunc = destFunc; + this.blendEquation = blendEquation; + } +} diff --git a/src/net/java/joglutils/msg/elements/ColorElement.java b/src/net/java/joglutils/msg/elements/ColorElement.java new file mode 100644 index 0000000..a725d61 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/ColorElement.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of colors, which are applied on a + per-vertex basis to any drawn geometry. */ + +public class ColorElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new ColorElement(); + } + /** Returns the instance of this element in the passed State. */ + public static ColorElement getInstance(State state) { + return (ColorElement) state.getElement(index); + } + /** Enables this element in the passed state, which should be the + default for a given action. */ + public static void enable(State defaultState) { + ColorElement tmp = new ColorElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The actual color data + protected FloatBuffer colors; + // The color binding to material parameter (not yet implemented) + protected int colorBinding; + + /** Sets the color data in the passed state. */ + public static void set(State state, FloatBuffer colors) { + getInstance(state).setElt(colors); + } + + /** Returns the color data in the passed state. */ + public static FloatBuffer get(State state) { + return getInstance(state).colors; + } + + public void push(State state) { + ColorElement prev = (ColorElement) getNextInStack(); + if (prev != null) { + // Pull down the data from the previous element + colors = prev.colors; + } + } + + /** Sets the color data in this element. */ + public void setElt(FloatBuffer colors) { + this.colors = colors; + } +} diff --git a/src/net/java/joglutils/msg/elements/CoordinateElement.java b/src/net/java/joglutils/msg/elements/CoordinateElement.java new file mode 100644 index 0000000..34b16bc --- /dev/null +++ b/src/net/java/joglutils/msg/elements/CoordinateElement.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of coordinates, which are assembled to + draw geometry. */ + +public class CoordinateElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new CoordinateElement(); + } + public static CoordinateElement getInstance(State state) { + return (CoordinateElement) state.getElement(index); + } + public static void enable(State defaultState) { + CoordinateElement tmp = new CoordinateElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The actual coordinate data + protected FloatBuffer coords; + + /** Sets the coordinate data in the passed state. */ + public static void set(State state, FloatBuffer coords) { + getInstance(state).setElt(coords); + } + + /** Returns the coordinate data in the passed state. */ + public static FloatBuffer get(State state) { + return getInstance(state).coords; + } + + public void push(State state) { + CoordinateElement prev = (CoordinateElement) getNextInStack(); + if (prev != null) { + // Pull down the data from the previous element + coords = prev.coords; + } + } + + /** Sets the coordinate data in this element. */ + public void setElt(FloatBuffer coords) { + this.coords = coords; + } +} diff --git a/src/net/java/joglutils/msg/elements/Element.java b/src/net/java/joglutils/msg/elements/Element.java new file mode 100644 index 0000000..5937b65 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/Element.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import net.java.joglutils.msg.misc.*; + +/** Represents an element in the global {@link + net.java.joglutils.msg.misc.State state}, such as the current 3D + coordinates or texture to be applied. The organization of the + global state into elements is one of the key mechanisms for + extendability of the library which was pioneered by Open Inventor. +*/ + +public abstract class Element { + // Elements are organized into stacks. When we descend past (for + // example) a Separator node, we need to push all of the state + // elements, traverse the children, and then pop the state elements + // so afterward we restore the original state. This is implemented + // in the State class using a linked list of Elements, where the + // State keeps track of the top of each element stack. + private Element nextInStack; + + // Additionally we maintain a linked list through all Element + // instances pushed and popped in the State, so that we don't have + // to traverse all Element slots when performing a state pop. + private Element next; + + // Elements need to keep track of their depth in the stack in order + // for the State to maintain itself + private int depth; + + protected Element() {} + + /** Creates a new instance initialized to the default values for the + state element. All concrete Element subclasses must implement + this operation. */ + public abstract Element newInstance(); + + /** Returns the next element in the stack. */ + public Element getNextInStack() { return nextInStack; } + /** Sets the next element in the stack. */ + public void setNextInStack(Element nextInStack) { this.nextInStack = nextInStack; } + + /** Returns the next element in the linked list of elements which + were modified since the last state push. */ + public Element getNext() { return next; } + /** Sets the next element in the linked list of elements which were + modified since the last state push. */ + public void setNext(Element next) { this.next = next; } + + /** Returns the depth of this element in its stack, used to implement lazy state pushing. */ + public int getDepth() { return depth; } + /** Sets the depth of this element in its stack, used to implement lazy state pushing. */ + public void setDepth(int depth) { this.depth = depth; } + + /** Pushes the element, allowing for side effects to occur. Default method does nothing. */ + public void push(State state) {} + /** Pops the element, allowing for side effects to occur. Default + method does nothing. NOTE that it is not legal to call + State.getElement() in the implementation of this method, which + is why the previous top element is provided as an argument. */ + public void pop (State state, Element previousTopElement) {} + + /** All concrete element subclasses must register themselves with + the State in order to reserve a slot, or index, in the + state. This method must be overridden to return this slot. */ + public abstract StateIndex getStateIndex(); +} diff --git a/src/net/java/joglutils/msg/elements/GLBlendElement.java b/src/net/java/joglutils/msg/elements/GLBlendElement.java new file mode 100644 index 0000000..7955533 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLBlendElement.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; +import net.java.joglutils.msg.nodes.*; + +/** Represents the blending state of the OpenGL fixed-function + pipeline and causes side-effects in OpenGL for rendering. */ + +public class GLBlendElement extends BlendElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLBlendElement(); + } + public static GLBlendElement getInstance(State state) { + return (GLBlendElement) BlendElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLBlendElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + public void pop(State state, Element previousTopElement) { + send(); + } + + public void setElt(boolean enabled, + Vec4f blendColor, + int srcFunc, + int destFunc, + int blendEquation) { + super.setElt(enabled, blendColor, srcFunc, destFunc, blendEquation); + send(); + } + + private static int oglBlendFunc(int func) { + switch (func) { + case Blend.ZERO: return GL.GL_ZERO; + case Blend.ONE: return GL.GL_ONE; + case Blend.SRC_COLOR: return GL.GL_SRC_COLOR; + case Blend.ONE_MINUS_SRC_COLOR: return GL.GL_ONE_MINUS_SRC_COLOR; + case Blend.DST_COLOR: return GL.GL_DST_COLOR; + case Blend.ONE_MINUS_DST_COLOR: return GL.GL_ONE_MINUS_DST_COLOR; + case Blend.SRC_ALPHA: return GL.GL_SRC_ALPHA; + case Blend.ONE_MINUS_SRC_ALPHA: return GL.GL_ONE_MINUS_SRC_ALPHA; + case Blend.DST_ALPHA: return GL.GL_DST_ALPHA; + case Blend.ONE_MINUS_DST_ALPHA: return GL.GL_ONE_MINUS_DST_ALPHA; + case Blend.SRC_ALPHA_SATURATE: return GL.GL_SRC_ALPHA_SATURATE; + case Blend.CONSTANT_COLOR: return GL.GL_CONSTANT_COLOR; + case Blend.ONE_MINUS_CONSTANT_COLOR: return GL.GL_ONE_MINUS_CONSTANT_COLOR; + case Blend.CONSTANT_ALPHA: return GL.GL_CONSTANT_ALPHA; + case Blend.ONE_MINUS_CONSTANT_ALPHA: return GL.GL_ONE_MINUS_CONSTANT_ALPHA; + } + throw new InternalError("Illegal blend function " + func); + } + + private int oglBlendEquation(int equation) { + switch (equation) { + case Blend.FUNC_ADD: return GL.GL_FUNC_ADD; + case Blend.FUNC_SUBTRACT: return GL.GL_FUNC_SUBTRACT; + case Blend.FUNC_REVERSE_SUBTRACT: return GL.GL_FUNC_REVERSE_SUBTRACT; + case Blend.MIN: return GL.GL_MIN; + case Blend.MAX: return GL.GL_MAX; + } + throw new InternalError("Illegal blend equation " + equation); + } + + private static void validateFunc(GL gl, int func) { + if (func == GL.GL_CONSTANT_COLOR || + func == GL.GL_ONE_MINUS_CONSTANT_COLOR || + func == GL.GL_CONSTANT_ALPHA || + func == GL.GL_ONE_MINUS_CONSTANT_ALPHA) { + if (!gl.isExtensionAvailable("GL_ARB_imaging")) { + throw new RuntimeException("Blend function requires GL_ARB_imaging extension"); + } + } + } + + private void send() { + GL gl = GLU.getCurrentGL(); + // Don't try to optimize what we send to OpenGL at this point -- too complicated + if (enabled) { + gl.glEnable(GL.GL_BLEND); + int oglSrcFunc = oglBlendFunc(srcFunc); + int oglDestFunc = oglBlendFunc(destFunc); + validateFunc(gl, oglSrcFunc); + validateFunc(gl, oglDestFunc); + gl.glBlendFunc(oglSrcFunc, oglDestFunc); + if (gl.isExtensionAvailable("GL_ARB_imaging")) { + gl.glBlendEquation(oglBlendEquation(blendEquation)); + gl.glBlendColor(blendColor.x(), blendColor.y(), blendColor.z(), blendColor.w()); + } + } else { + gl.glDisable(GL.GL_BLEND); + } + } +} diff --git a/src/net/java/joglutils/msg/elements/GLColorElement.java b/src/net/java/joglutils/msg/elements/GLColorElement.java new file mode 100644 index 0000000..732ee98 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLColorElement.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of colors, which are applied on a + per-vertex basis to any drawn geometry, and causes side-effects in + OpenGL for rendering. */ + +public class GLColorElement extends ColorElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLColorElement(); + } + public static GLColorElement getInstance(State state) { + return (GLColorElement) ColorElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLColorElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // Whether the OpenGL state is currently enabled + private boolean enabled; + + public void push(State state) { + super.push(state); + // Copy enabled state from previous element if any + GLColorElement prev = (GLColorElement) getNextInStack(); + if (prev != null) { + enabled = prev.enabled; + } + } + + public void pop(State state, Element previousTopElement) { + GLColorElement prev = (GLColorElement) previousTopElement; + boolean shouldBeEnabled = enabled; + enabled = prev.enabled; + // Put things back the way they were + setEnabled(shouldBeEnabled); + } + + public void setElt(FloatBuffer colors) { + super.setElt(colors); + setEnabled(colors != null); + } + + private void setEnabled(boolean enabled) { + if (this.enabled == enabled) + return; // No OpenGL work to do + this.enabled = enabled; + GL gl = GLU.getCurrentGL(); + if (enabled) { + gl.glColorPointer(4, GL.GL_FLOAT, 0, colors); + gl.glEnableClientState(GL.GL_COLOR_ARRAY); + } else { + gl.glDisableClientState(GL.GL_COLOR_ARRAY); + // Assume we have to reset the current color to the default + gl.glColor4f(1, 1, 1, 1); + } + } +} diff --git a/src/net/java/joglutils/msg/elements/GLCoordinateElement.java b/src/net/java/joglutils/msg/elements/GLCoordinateElement.java new file mode 100644 index 0000000..d33e4ec --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLCoordinateElement.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of coordinates, which are assembled to + draw geometry, and causes side-effects in OpenGL. */ + +public class GLCoordinateElement extends CoordinateElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLCoordinateElement(); + } + public static GLCoordinateElement getInstance(State state) { + return (GLCoordinateElement) CoordinateElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLCoordinateElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // Whether the OpenGL state is currently enabled + private boolean enabled; + + public void push(State state) { + super.push(state); + // Copy enabled state from previous element if any + GLCoordinateElement prev = (GLCoordinateElement) getNextInStack(); + if (prev != null) { + enabled = prev.enabled; + } + } + + public void pop(State state, Element previousTopElement) { + GLCoordinateElement prev = (GLCoordinateElement) previousTopElement; + boolean shouldBeEnabled = enabled; + enabled = prev.enabled; + // Put things back the way they were + setEnabled(shouldBeEnabled); + } + + public void setElt(FloatBuffer coords) { + super.setElt(coords); + setEnabled(coords != null); + } + + private void setEnabled(boolean enabled) { + if (this.enabled == enabled) + return; // No OpenGL work to do + this.enabled = enabled; + GL gl = GLU.getCurrentGL(); + if (enabled) { + gl.glVertexPointer(3, GL.GL_FLOAT, 0, coords); + gl.glEnableClientState(GL.GL_VERTEX_ARRAY); + } else { + gl.glDisableClientState(GL.GL_VERTEX_ARRAY); + } + } +} diff --git a/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java b/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java new file mode 100644 index 0000000..24097bc --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the model matrix, which is the transformation applied + to objects in the scene, and causes side-effects in OpenGL. */ + +public class GLModelMatrixElement extends ModelMatrixElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLModelMatrixElement(); + } + public static GLModelMatrixElement getInstance(State state) { + return (GLModelMatrixElement) ModelMatrixElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLModelMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // State which we need in order to reset the modelview matrix + private State state; + + public void push(State state) { + super.push(state); + this.state = state; + + // Cause side-effects in OpenGL + GL gl = GLU.getCurrentGL(); + gl.glPushMatrix(); + } + + public void pop(State state, Element previousTopElement) { + super.pop(state, previousTopElement); + + // Cause side-effects in OpenGL + GL gl = GLU.getCurrentGL(); + gl.glPopMatrix(); + } + + public void makeEltIdent() { + super.makeEltIdent(); + // Cause side-effects in OpenGL + // Recompute the complete modelview matrix + Mat4f mat = ViewingMatrixElement.getInstance(state).getMatrix(); + GL gl = GLU.getCurrentGL(); + gl.glLoadTransposeMatrixf(mat.getRowMajorData(), 0); + } + + public void multElt(Mat4f matrix) { + super.multElt(matrix); + GL gl = GLU.getCurrentGL(); + gl.glMultTransposeMatrixf(matrix.getRowMajorData(), 0); + } +} diff --git a/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java b/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java new file mode 100644 index 0000000..6c8d7d2 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the projection matrix, which transforms view-space + coordinates into screen-space coordinates, and performs + side-effects in OpenGL. */ + +public class GLProjectionMatrixElement extends ProjectionMatrixElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLProjectionMatrixElement(); + } + public static GLProjectionMatrixElement getInstance(State state) { + return (GLProjectionMatrixElement) ProjectionMatrixElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLProjectionMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + public void push(State state) { + super.push(state); + } + + public void setElt(Mat4f matrix) { + super.setElt(matrix); + GL gl = GLU.getCurrentGL(); + gl.glMatrixMode(GL.GL_PROJECTION); + gl.glLoadTransposeMatrixf(matrix.getRowMajorData(), 0); + gl.glMatrixMode(GL.GL_MODELVIEW); + } +} diff --git a/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java b/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java new file mode 100644 index 0000000..111d0a9 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of texture coordinates, which are + applied on a per-vertex basis to any drawn geometry, and performs + side-effects in OpenGL. */ + +public class GLTextureCoordinateElement extends TextureCoordinateElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLTextureCoordinateElement(); + } + public static GLTextureCoordinateElement getInstance(State state) { + return (GLTextureCoordinateElement) TextureCoordinateElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLTextureCoordinateElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // Whether the OpenGL state is currently enabled + private boolean enabled; + + public void push(State state) { + super.push(state); + // Copy enabled state from previous element if any + GLTextureCoordinateElement prev = (GLTextureCoordinateElement) getNextInStack(); + if (prev != null) { + enabled = prev.enabled; + } + } + + public void pop(State state, Element previousTopElement) { + GLTextureCoordinateElement prev = (GLTextureCoordinateElement) previousTopElement; + boolean shouldBeEnabled = enabled; + enabled = prev.enabled; + // Put things back the way they were + setEnabled(shouldBeEnabled); + } + + public void setElt(FloatBuffer coords) { + super.setElt(coords); + setEnabled(coords != null); + } + + private void setEnabled(boolean enabled) { + if (this.enabled == enabled) + return; // No OpenGL work to do + this.enabled = enabled; + GL gl = GLU.getCurrentGL(); + if (enabled) { + // FIXME: may want to link this up with the GLTextureElement so + // that we only enable the texture coordinate array if we both + // have a TextureCoordinateElement and a TextureElement active + // (a little error checking for the application) + gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, coords); + gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); + } else { + gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY); + } + } +} diff --git a/src/net/java/joglutils/msg/elements/GLTextureElement.java b/src/net/java/joglutils/msg/elements/GLTextureElement.java new file mode 100644 index 0000000..5241b09 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLTextureElement.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.util.texture.*; + +import net.java.joglutils.msg.misc.*; +import net.java.joglutils.msg.nodes.*; + +/** Represents the current texture, which is applied to any drawn + geometry if texture coordinates are also supplied, and performs + side-effects in OpenGL. */ + +public class GLTextureElement extends TextureElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLTextureElement(); + } + public static GLTextureElement getInstance(State state) { + return (GLTextureElement) TextureElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLTextureElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + public void pop(State state, Element previousTopElement) { + // Put things back the way they were + switchTextures(((GLTextureElement) previousTopElement).texture, texture, texEnvMode); + } + + public void setElt(Texture texture, int texEnvMode) { + Texture prev = this.texture; + super.setElt(texture, texEnvMode); + switchTextures(prev, texture, texEnvMode); + } + + private void switchTextures(Texture prev, Texture texture, int texEnvMode) { + GL gl = GLU.getCurrentGL(); + // FIXME: should be smarter about this; if the target is the same + // for the previous and current textures, just bind the new one + if (prev != null) { + prev.disable(); + } + if (texture != null) { + texture.enable(); + texture.bind(); + int glEnvMode = 0; + switch (texEnvMode) { + case Texture2.MODULATE: glEnvMode = GL.GL_MODULATE; break; + case Texture2.DECAL: glEnvMode = GL.GL_DECAL; break; + case Texture2.BLEND: glEnvMode = GL.GL_BLEND; break; + case Texture2.REPLACE: glEnvMode = GL.GL_REPLACE; break; + } + gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, glEnvMode); + } + } +} diff --git a/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java b/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java new file mode 100644 index 0000000..5848413 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the viewing matrix, which contains the transformation + between the camera and the model, and performs side-effects in + OpenGL. */ + +public class GLViewingMatrixElement extends ViewingMatrixElement { + // Boilerplate for concrete element subclasses + public Element newInstance() { + return new GLViewingMatrixElement(); + } + public static GLViewingMatrixElement getInstance(State state) { + return (GLViewingMatrixElement) ViewingMatrixElement.getInstance(state); + } + public static void enable(State defaultState) { + Element tmp = new GLViewingMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // State which we need in order to reset the modelview matrix + private State state; + protected Mat4f temp = new Mat4f(); + + public void push(State state) { + super.push(state); + this.state = state; + } + + public void setElt(Mat4f matrix) { + super.setElt(matrix); + // Must push the combined viewing and modelview matrices down to OpenGL + Mat4f mdl = ModelMatrixElement.getInstance(state).getMatrix(); + temp.mul(matrix, mdl); + GL gl = GLU.getCurrentGL(); + gl.glLoadTransposeMatrixf(temp.getRowMajorData(), 0); + } +} diff --git a/src/net/java/joglutils/msg/elements/ModelMatrixElement.java b/src/net/java/joglutils/msg/elements/ModelMatrixElement.java new file mode 100644 index 0000000..cfe726e --- /dev/null +++ b/src/net/java/joglutils/msg/elements/ModelMatrixElement.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the model matrix, which is the transformation applied + to objects in the scene. */ + +public class ModelMatrixElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new ModelMatrixElement(); + } + public static ModelMatrixElement getInstance(State state) { + return (ModelMatrixElement) state.getElement(index); + } + public static void enable(State defaultState) { + Element tmp = new ModelMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The matrix data + protected Mat4f matrix; + protected Mat4f temp = new Mat4f(); + + public ModelMatrixElement() { + matrix = new Mat4f(); + matrix.makeIdent(); + } + + public void push(State state) { + ModelMatrixElement prev = (ModelMatrixElement) getNextInStack(); + if (prev != null) { + matrix.set(prev.matrix); + } + } + + /** Returns the current model matrix; callers should not mutate this + directly but instead use the accessor methods to change it. */ + public Mat4f getMatrix() { + return matrix; + } + + /** Sets the current element to the identity matrix. */ + public static void makeIdent(State state) { + ModelMatrixElement elt = getInstance(state); + elt.makeEltIdent(); + } + + /** Sets this element to the identity matrix. */ + public void makeEltIdent() { + matrix.makeIdent(); + } + + /** Multiplies the current element by the given matrix. */ + public static void mult(State state, Mat4f matrix) { + ModelMatrixElement elt = getInstance(state); + elt.multElt(matrix); + } + + /** Multiplies this element by the given matrix. */ + public void multElt(Mat4f matrix) { + temp.set(this.matrix); + this.matrix.mul(temp, matrix); + } +} diff --git a/src/net/java/joglutils/msg/elements/ProjectionMatrixElement.java b/src/net/java/joglutils/msg/elements/ProjectionMatrixElement.java new file mode 100644 index 0000000..dd70ca3 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/ProjectionMatrixElement.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the projection matrix, which transforms view-space + coordinates into screen-space coordinates. */ + +public class ProjectionMatrixElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new ProjectionMatrixElement(); + } + public static ProjectionMatrixElement getInstance(State state) { + return (ProjectionMatrixElement) state.getElement(index); + } + public static void enable(State defaultState) { + Element tmp = new ProjectionMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The matrix data + protected Mat4f matrix; + + public ProjectionMatrixElement() { + matrix = new Mat4f(); + matrix.makeIdent(); + } + + /** Returns the current projection matrix; callers should not mutate + this directly but instead use the accessor methods to change + it. */ + public Mat4f getMatrix() { + return matrix; + } + + public void push(State state) { + ProjectionMatrixElement prev = (ProjectionMatrixElement) getNextInStack(); + if (prev != null) { + matrix.set(prev.matrix); + } + } + + /** Sets the projection matrix in the given state to the given one. */ + public static void set(State state, Mat4f matrix) { + ProjectionMatrixElement elt = getInstance(state); + elt.setElt(matrix); + } + + /** Sets the projection matrix in this element to the given one. */ + public void setElt(Mat4f matrix) { + this.matrix.set(matrix); + } +} diff --git a/src/net/java/joglutils/msg/elements/TextureCoordinateElement.java b/src/net/java/joglutils/msg/elements/TextureCoordinateElement.java new file mode 100644 index 0000000..6d36c6c --- /dev/null +++ b/src/net/java/joglutils/msg/elements/TextureCoordinateElement.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; + +import net.java.joglutils.msg.misc.*; + +/** Represents the current set of texture coordinates, which are + applied on a per-vertex basis to any drawn geometry. */ + +public class TextureCoordinateElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new TextureCoordinateElement(); + } + public static TextureCoordinateElement getInstance(State state) { + return (TextureCoordinateElement) state.getElement(index); + } + public static void enable(State defaultState) { + TextureCoordinateElement tmp = new TextureCoordinateElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The actual coordinate data + protected FloatBuffer coords; + + /** Sets the texture coordinate data in the passed state. */ + public static void set(State state, FloatBuffer coords) { + getInstance(state).setElt(coords); + } + + /** Returns the texture coordinate data in the passed state. */ + public static FloatBuffer get(State state) { + return getInstance(state).coords; + } + + public void push(State state) { + TextureCoordinateElement prev = (TextureCoordinateElement) getNextInStack(); + if (prev != null) { + // Pull down the data from the previous element + coords = prev.coords; + } + } + + /** Sets the texture coordinate data in this element. */ + public void setElt(FloatBuffer coords) { + this.coords = coords; + } +} diff --git a/src/net/java/joglutils/msg/elements/TextureElement.java b/src/net/java/joglutils/msg/elements/TextureElement.java new file mode 100644 index 0000000..90a9ebc --- /dev/null +++ b/src/net/java/joglutils/msg/elements/TextureElement.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import java.nio.*; +import javax.media.opengl.*; +import com.sun.opengl.util.texture.*; + +import net.java.joglutils.msg.misc.*; + +// FIXME: the TextureElement / GLTextureElement distinction doesn't +// make much sense here, because the Texture object the TextureElement +// contains already implicitly relies on OpenGL + +/** Represents the current texture, which is applied to any drawn + geometry if texture coordinates are also supplied. */ + +public class TextureElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new TextureElement(); + } + public static TextureElement getInstance(State state) { + return (TextureElement) state.getElement(index); + } + public static void enable(State defaultState) { + TextureElement tmp = new TextureElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The actual Texture object + protected Texture texture; + // The texture environment mode + protected int texEnvMode; + + /** Sets the texture and environment mode in the given state. */ + public static void set(State state, Texture texture, int texEnvMode) { + getInstance(state).setElt(texture, texEnvMode); + } + + /** Returns the current texture in the state. */ + public static Texture get(State state) { + return getInstance(state).texture; + } + + /** Returns the texture environment mode in the state. */ + public static int getEnvMode(State state) { + return getInstance(state).texEnvMode; + } + + public void push(State state) { + TextureElement prev = (TextureElement) getNextInStack(); + if (prev != null) { + // Pull down the texture from the previous element + texture = prev.texture; + } + } + + /** Sets the texture and environment mode in this element. */ + public void setElt(Texture texture, int texEnvMode) { + this.texture = texture; + this.texEnvMode = texEnvMode; + } +} diff --git a/src/net/java/joglutils/msg/elements/ViewingMatrixElement.java b/src/net/java/joglutils/msg/elements/ViewingMatrixElement.java new file mode 100644 index 0000000..5142678 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/ViewingMatrixElement.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution 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 Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + */ + +package net.java.joglutils.msg.elements; + +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.misc.*; + +/** Represents the viewing matrix, which contains the transformation + between the camera and the model. */ + +public class ViewingMatrixElement extends Element { + // Boilerplate + private static StateIndex index = State.registerElementType(); + public StateIndex getStateIndex() { return index; } + public Element newInstance() { + return new ViewingMatrixElement(); + } + public static ViewingMatrixElement getInstance(State state) { + return (ViewingMatrixElement) state.getElement(index); + } + public static void enable(State defaultState) { + Element tmp = new ViewingMatrixElement(); + defaultState.setElement(tmp.getStateIndex(), tmp); + } + + // The matrix data + protected Mat4f matrix; + + public ViewingMatrixElement() { + matrix = new Mat4f(); + matrix.makeIdent(); + } + + /** Returns the current viewing matrix; callers should not mutate + this directly but instead use the accessor methods to change + it. */ + public Mat4f getMatrix() { + return matrix; + } + + public void push(State state) { + ViewingMatrixElement prev = (ViewingMatrixElement) getNextInStack(); + if (prev != null) { + matrix.set(prev.matrix); + } + } + + /** Sets the viewing matrix in the given state to the given one. */ + public static void set(State state, Mat4f matrix) { + ViewingMatrixElement elt = getInstance(state); + elt.setElt(matrix); + } + + /** Sets the viewing matrix in this element to the given one. */ + public void setElt(Mat4f matrix) { + this.matrix.set(matrix); + } +} diff --git a/src/net/java/joglutils/msg/elements/package.html b/src/net/java/joglutils/msg/elements/package.html new file mode 100644 index 0000000..870e605 --- /dev/null +++ b/src/net/java/joglutils/msg/elements/package.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<body> + +Elements of the global state affected by actions' traversal of +nodes. Only developers of the library will typically have to interact +with the classes in this package. + +<P> + +In similar fashion to Open Inventor, each element in this package is +typically partitioned into two classes, one which holds the storage +for the element and one which implements the OpenGL side-effects. This +organization allows certain actions to traverse the scene graph +without requiring an OpenGL context to be current. + +</body> +</html> |