aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-10-24 19:21:03 +0000
committerKenneth Russel <[email protected]>2005-10-24 19:21:03 +0000
commitd6f9dbc493df725d3d574403549de142c5e1222a (patch)
tree8eb152b0627f8d1897a27c5204d6ce2efb4963e4 /src/net/java/games/jogl/impl
parent42843c3290d64c41c9c8a18b93f5ad3c00d35ddc (diff)
Merged JSR-231 branch on to the main JOGL trunk. The main trunk now
contains the evolving JSR-231 Reference Implementation and the JSR-231 branch is permanently closed. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@401 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl')
-rwxr-xr-xsrc/net/java/games/jogl/impl/Debug.java91
-rw-r--r--src/net/java/games/jogl/impl/FunctionAvailabilityCache.java315
-rw-r--r--src/net/java/games/jogl/impl/GLContext.java764
-rw-r--r--src/net/java/games/jogl/impl/GLContextFactory.java105
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLContextInitActionPair.java58
-rw-r--r--src/net/java/games/jogl/impl/GLContextShareSet.java153
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLContextStack.java127
-rw-r--r--src/net/java/games/jogl/impl/GLDrawableHelper.java84
-rw-r--r--src/net/java/games/jogl/impl/GLPbufferImpl.java286
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLUquadricImpl.java1049
-rw-r--r--src/net/java/games/jogl/impl/InternalBufferUtils.java55
-rw-r--r--src/net/java/games/jogl/impl/JAWT_PlatformInfo.java45
-rw-r--r--src/net/java/games/jogl/impl/NativeLibLoader.java86
-rwxr-xr-xsrc/net/java/games/jogl/impl/Project.java592
-rwxr-xr-xsrc/net/java/games/jogl/impl/SingleThreadedWorkaround.java115
-rwxr-xr-xsrc/net/java/games/jogl/impl/Util.java242
-rw-r--r--src/net/java/games/jogl/impl/error/Error.java89
-rw-r--r--src/net/java/games/jogl/impl/glue/Glue.java104
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java116
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java278
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java65
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java101
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java248
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java203
-rw-r--r--src/net/java/games/jogl/impl/mipmap/BuildMipmap.java1576
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract.java46
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract1010102.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract1555rev.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract2101010rev.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract233rev.java75
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract332.java74
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract4444.java86
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract4444rev.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract5551.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract565.java82
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract565rev.java82
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract8888.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Extract8888rev.java87
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractFloat.java64
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractPrimitive.java46
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractSByte.java59
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractSInt.java66
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractSShort.java66
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractUByte.java60
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractUInt.java66
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ExtractUShort.java66
-rw-r--r--src/net/java/games/jogl/impl/mipmap/HalveImage.java1523
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Image.java1402
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Mipmap.java799
-rw-r--r--src/net/java/games/jogl/impl/mipmap/PixelStorageModes.java416
-rw-r--r--src/net/java/games/jogl/impl/mipmap/ScaleInternal.java2381
-rw-r--r--src/net/java/games/jogl/impl/mipmap/Type_Widget.java214
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/README-PORTING.txt40
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/Arc.java274
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/ArcTesselator.java449
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/Backend.java377
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/BasicCurveEvaluator.java50
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/BasicSurfaceEvaluator.java76
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/BezierArc.java42
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/Bin.java147
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/CachingEvaluator.java56
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/Defines.java46
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/NurbsConsts.java117
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/NurbsException.java30
-rwxr-xr-xsrc/net/java/games/jogl/impl/nurbs/internals/Subdivider.java1781
-rw-r--r--src/net/java/games/jogl/impl/registry/Registry.java65
-rw-r--r--src/net/java/games/jogl/impl/tesselator/ActiveRegion.java58
-rw-r--r--src/net/java/games/jogl/impl/tesselator/CachedVertex.java48
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Dict.java130
-rw-r--r--src/net/java/games/jogl/impl/tesselator/DictNode.java49
-rw-r--r--src/net/java/games/jogl/impl/tesselator/GLUface.java55
-rw-r--r--src/net/java/games/jogl/impl/tesselator/GLUhalfEdge.java63
-rw-r--r--src/net/java/games/jogl/impl/tesselator/GLUmesh.java52
-rw-r--r--src/net/java/games/jogl/impl/tesselator/GLUtesselatorImpl.java624
-rw-r--r--src/net/java/games/jogl/impl/tesselator/GLUvertex.java55
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Geom.java308
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Mesh.java724
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Normal.java277
-rw-r--r--src/net/java/games/jogl/impl/tesselator/PriorityQ.java90
-rw-r--r--src/net/java/games/jogl/impl/tesselator/PriorityQHeap.java254
-rw-r--r--src/net/java/games/jogl/impl/tesselator/PriorityQSort.java270
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Render.java546
-rw-r--r--src/net/java/games/jogl/impl/tesselator/Sweep.java1342
-rw-r--r--src/net/java/games/jogl/impl/tesselator/TessMono.java199
-rw-r--r--src/net/java/games/jogl/impl/tesselator/TessState.java50
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java717
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java361
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java176
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java228
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java529
-rw-r--r--src/net/java/games/jogl/impl/x11/X11GLContext.java410
-rw-r--r--src/net/java/games/jogl/impl/x11/X11GLContextFactory.java288
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java175
-rw-r--r--src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java217
-rw-r--r--src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java343
-rwxr-xr-xsrc/net/java/games/jogl/impl/x11/X11SunJDKReflection.java101
96 files changed, 0 insertions, 27518 deletions
diff --git a/src/net/java/games/jogl/impl/Debug.java b/src/net/java/games/jogl/impl/Debug.java
deleted file mode 100755
index 164c5afbd..000000000
--- a/src/net/java/games/jogl/impl/Debug.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2003-2005 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.security.*;
-import net.java.games.jogl.Version;
-
-/** Helper routines for logging and debugging. */
-
-public class Debug {
- // Some common properties
- private static boolean verbose;
- private static boolean debugAll;
-
- static {
- verbose = isPropertyDefined("jogl.verbose");
- debugAll = isPropertyDefined("jogl.debug");
- if (verbose) {
- System.err.println("JOGL version " + Version.getVersion());
- }
- }
-
- public static boolean getBooleanProperty(final String property) {
- Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- boolean val = Boolean.getBoolean(property);
- return (val ? Boolean.TRUE : Boolean.FALSE);
- }
- });
- return b.booleanValue();
- }
-
- public static boolean isPropertyDefined(final String property) {
- Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String val = System.getProperty(property);
- return (val != null ? Boolean.TRUE : Boolean.FALSE);
- }
- });
- return b.booleanValue();
- }
-
- public static boolean verbose() {
- return verbose;
- }
-
- public static boolean debugAll() {
- return debugAll;
- }
-
- public static boolean debug(String subcomponent) {
- return debugAll() || isPropertyDefined("jogl.debug." + subcomponent);
- }
-}
diff --git a/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java b/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java
deleted file mode 100644
index be5e26067..000000000
--- a/src/net/java/games/jogl/impl/FunctionAvailabilityCache.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import net.java.games.jogl.*;
-import java.util.*;
-import java.awt.Canvas;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.lang.reflect.*;
-
-/**
- * A utility object intended to be used by implementations to act as a cache
- * of which OpenGL functions are currently available on both the host machine
- * and display.
- */
-public final class FunctionAvailabilityCache {
- private static final boolean DEBUG = Debug.debug("FunctionAvailabilityCache");
-
- FunctionAvailabilityCache(GLContext context)
- {
- this.context = context;
- }
-
- /**
- * Flush the cache. The cache will be rebuilt lazily as calls to {@link
- * #isFunctionAvailable(String)} are received.
- */
- public void flush()
- {
- availabilityCache.clear();
- availableExtensionCache.clear();
- }
-
- public boolean isFunctionAvailable(String glFunctionName)
- {
- if (DEBUG) {
- System.err.println("!!! CHECKING FOR AVAILABILITY OF: "+ glFunctionName);
- }
-
- Boolean available = (Boolean)availabilityCache.get(glFunctionName);
-
- if (available == null) // not in availabilityCache
- {
- if (isPartOfAvailableExtensions(glFunctionName) ||
- isPartOfGLCore(context.getGL().glGetString(GL.GL_VERSION), glFunctionName))
- {
- available = Boolean.TRUE;
- }
- else
- {
- available = Boolean.FALSE;
- }
-
- availabilityCache.put(glFunctionName, available);
- }
-
- if (DEBUG) {
- System.err.println("!!! AVAILABILITY OF "+ glFunctionName + ": " + available.booleanValue());
- }
-
- return available.booleanValue();
- }
-
- public boolean isExtensionAvailable(String glExtensionName) {
- initAvailableExtensions();
- return availableExtensionCache.contains(glExtensionName);
- }
-
- protected void initAvailableExtensions() {
- // if hash is empty (meaning it was flushed), pre-cache it with the list
- // of extensions that are in the GL_EXTENSIONS string
- if (availableExtensionCache.isEmpty()) {
- GL gl = context.getGL();
- if (DEBUG) {
- System.err.println("!!! Pre-caching extension availability");
- }
- String allAvailableExtensions =
- gl.glGetString(GL.GL_EXTENSIONS) + " " + context.getPlatformExtensionsString();
- if (DEBUG) {
- System.err.println("!!! Available extensions: " + allAvailableExtensions);
- System.err.println("!!! GL vendor: " + gl.glGetString(GL.GL_VENDOR));
- }
- StringTokenizer tok = new StringTokenizer(allAvailableExtensions);
- while (tok.hasMoreTokens()) {
- String availableExt = tok.nextToken().trim();
- availableExt = availableExt.intern();
- availableExtensionCache.add(availableExt);
- if (DEBUG) {
- System.err.println("!!! Available: " + availableExt);
- }
- }
-
- // put a dummy var in here so that the cache is no longer empty even if
- // no extensions are in the GL_EXTENSIONS string
- availableExtensionCache.add("<INTERNAL_DUMMY_PLACEHOLDER>");
- }
- }
-
- protected boolean isPartOfAvailableExtensions(String glFunctionName)
- {
- initAvailableExtensions();
-
- // First, find the extension to which the function corresponds
- String extensionName = getExtensionCorrespondingToFunction(glFunctionName);
-
- // Now see if that extension is available
- boolean extensionAvailable = availableExtensionCache.contains(extensionName);
-
- return extensionAvailable;
- }
-
- /**
- * Returns true if the given OpenGL function is part of the OpenGL core
- * that corresponds to the give OpenGL version string.
- *
- * @param glVersionString must be of the form "X" or "X.Y" or "X.Y.Z", where
- * X, Y, and Z are integers
- * @exception GLException if the glFunctionName passed in is
- * not the name of any known OpenGL extension function.
- */
- public static boolean isPartOfGLCore(String glVersionString, String glFunctionName)
- {
- String funcCoreVersionString =
- StaticGLInfo.getFunctionAssociation(glFunctionName);
-
- if (funcCoreVersionString == null) {
- // No extension string was found in the glext.h/wglext.h/glxext.h
- // headers when building the StaticGLInfo class. So either it's a new
- // extension that's not in those headers, or it's not an opengl
- // extension. Either way it's an illegal argument.
- throw new GLException(
- "Function \"" + glFunctionName + "\" does not " +
- "correspond to any known OpenGL extension or core version.");
- }
-
- Version actualVersion;
- try
- {
- actualVersion = new Version(funcCoreVersionString);
- }
- catch (IllegalArgumentException e)
- {
- // funcCoreVersionString is not an OpenGL version identifier (i.e., not
- // of the form GL_VERSION_XXX or X.Y).
- //
- // Since the association string returned from
- // StaticGLInfo.getFunctionAssociation() was not null, this function
- // must be an OpenGL extension function.
- //
- // Therefore this function can't be part of any OpenGL core.
- return false;
- }
-
- Version versionToCheck;
- try
- {
- versionToCheck = new Version(glVersionString);
- }
- catch (IllegalArgumentException e)
- {
- // user did not supply a valid OpenGL version identifier
- throw new IllegalArgumentException(
- "Illegally formatted OpenGL version identifier: \"" + glVersionString + "\"");
- }
-
- // See if the version number of glVersionString is less than or equal to
- // the OpenGL specification number to which the given function actually
- // belongs.
- if (actualVersion.compareTo(versionToCheck) <= 0)
- {
- if (DEBUG) {
- System.err.println(
- glFunctionName + " is in core OpenGL " + glVersionString +
- " because it is in OpenGL " + funcCoreVersionString);
- }
- return true;
- }
-
- if (DEBUG) {
- System.err.println(
- glFunctionName + " is NOT a part of the OpenGL " + glVersionString + " core" +
- "; it is part of OpenGL " + funcCoreVersionString);
- }
-
- return false;
- }
-
- /** Returns the extension name that corresponds to the given extension
- * function. For example, it will return "GL_EXT_vertex_array" when the
- * argument is "glNormalPointerEXT".
- *
- * Please see http://oss.sgi.com/projects/ogl-sample/registry/index.html for
- * a list of extension names and the functions they expose.
- */
- protected static String getExtensionCorrespondingToFunction(String glFunctionName)
- {
- // HACK: FIXME!!! return something I know is supported so I can test other
- // functions.
- return StaticGLInfo.getFunctionAssociation(glFunctionName);
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private HashMap availabilityCache = new HashMap(50);
- private HashSet availableExtensionCache = new HashSet(50);
- private GLContext context;
-
- /**
- * A class for storing and comparing revision version numbers.
- */
- private static class Version implements Comparable
- {
- private int major, minor, sub;
- public Version(int majorRev, int minorRev, int subMinorRev)
- {
- major = majorRev;
- minor = minorRev;
- sub = subMinorRev;
- }
-
- /**
- * @param versionString must be of the form "GL_VERSION_X" or
- * "GL_VERSION_X_Y" or "GL_VERSION_X_Y_Z" or "X.Y", where X, Y,
- * and Z are integers.
- *
- * @exception IllegalArgumentException if the argument is not a valid
- * OpenGL version identifier
- */
- public Version(String versionString)
- {
- try
- {
- if (versionString.startsWith("GL_VERSION_"))
- {
- StringTokenizer tok = new StringTokenizer(versionString, "_");
-
- tok.nextToken(); // GL_
- tok.nextToken(); // VERSION_
- if (!tok.hasMoreTokens()) { major = 0; return; }
- major = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) { minor = 0; return; }
- minor = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) { sub = 0; return; }
- sub = Integer.valueOf(tok.nextToken()).intValue();
- }
- else
- {
- StringTokenizer tok = new StringTokenizer(versionString, ". ");
- major = Integer.valueOf(tok.nextToken()).intValue();
- minor = Integer.valueOf(tok.nextToken()).intValue();
- }
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(
- "Illegally formatted version identifier: \"" + versionString + "\"");
- }
- }
-
- public int compareTo(Object o)
- {
- Version vo = (Version)o;
- if (major > vo.major) return 1;
- else if (major < vo.major) return -1;
- else if (minor > vo.minor) return 1;
- else if (minor < vo.minor) return -1;
- else if (sub > vo.sub) return 1;
- else if (sub < vo.sub) return -1;
-
- return 0; // they are equal
- }
-
- } // end class Version
-}
-
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
deleted file mode 100644
index 41fa98c4b..000000000
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.awt.Component;
-import net.java.games.jogl.*;
-import net.java.games.gluegen.runtime.*;
-
-public abstract class GLContext {
- protected static final boolean DEBUG = Debug.debug("GLContext");
- protected static final boolean VERBOSE = Debug.verbose();
- protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree");
-
- static {
- NativeLibLoader.load();
- }
-
- protected Component component;
-
- // Indicates whether the component (if an onscreen context) has been
- // realized. Plausibly, before the component is realized the JAWT
- // should return an error or NULL object from some of its
- // operations; this appears to be the case on Win32 but is not true
- // at least with Sun's current X11 implementation (1.4.x), which
- // crashes with no other error reported if the DrawingSurfaceInfo is
- // fetched from a locked DrawingSurface during the validation as a
- // result of calling show() on the main thread. To work around this
- // we prevent any JAWT or OpenGL operations from being done until
- // addNotify() is called on the component.
- protected boolean realized;
-
- protected GLCapabilities capabilities;
- protected GLCapabilitiesChooser chooser;
- protected GL gl;
- protected static final GLUProcAddressTable gluProcAddressTable = new GLUProcAddressTable();
- protected static boolean haveResetGLUProcAddressTable;
- protected GLU glu = new GLUImpl(gluProcAddressTable);
- protected Thread renderingThread;
- protected Runnable deferredReshapeAction;
- // Support for OpenGL context destruction and recreation in the face
- // of the setRenderingThread optimization, which makes the context
- // permanently current on the animation thread. FIXME: should make
- // this more uniform and general, possibly by implementing in terms
- // of Runnables; however, necessary sequence of operations in
- // invokeGL makes this tricky.
- protected boolean deferredDestroy;
- protected boolean deferredSetRealized;
-
- // Error checking for setRenderingThread to ensure that one thread
- // doesn't attempt to call setRenderingThread on more than one
- // drawable
- protected static final ThreadLocal perThreadRenderingContext = new ThreadLocal();
-
- // This is a workaround for a bug in NVidia's drivers where
- // vertex_array_range is only safe for single-threaded use; a bug
- // has been filed, ID 80174. When an Animator is created for a
- // GLDrawable, the expectation is that the Animator will be started
- // shortly and that the user doesn't want rendering to occur from
- // the AWT thread. However, there is a small window between when the
- // Animator is created and attached to the GLDrawable and when it's
- // started (and sets the rendering thread) when repaint events can
- // be issued by the AWT thread if the component is realized. To work
- // around this problem, we currently specify in the Animator's API
- // that between the time it's created and started no redraws will
- // occur.
- protected volatile boolean willSetRenderingThread;
-
- // Flag for disabling all repaint and resize processing on the AWT
- // thread to avoid application-level deadlocks; only really used for
- // GLCanvas
- protected boolean noAutoRedraw;
-
- // Flag for enabling / disabling automatic swapping of the front and
- // back buffers
- protected boolean autoSwapBuffers = true;
-
- // Offscreen context handling. Offscreen contexts should handle
- // these resize requests in makeCurrent and clear the
- // pendingOffscreenResize flag.
- protected boolean pendingOffscreenResize;
- protected int pendingOffscreenWidth;
- protected int pendingOffscreenHeight;
-
- // Cache of the functions that are available to be called at the current
- // moment in time
- protected FunctionAvailabilityCache functionAvailability;
-
- // Support for recursive makeCurrent() calls as well as calling
- // other drawables' display() methods from within another one's
- protected static final ThreadLocal perThreadContextStack = new ThreadLocal() {
- protected synchronized Object initialValue() {
- return new GLContextStack();
- }
- };
- // This thread-local variable helps implement setRenderingThread()'s
- // optimized context handling. When the bottommost invokeGL() on the
- // execution stack finishes for the rendering thread for that
- // context, we pop the context off the context stack but do not free
- // it, instead storing it in this thread-local variable. This gives
- // us enough information to recover the context stack state in
- // subsequent invokeGL() calls.
- protected static final ThreadLocal perThreadSavedCurrentContext = new ThreadLocal() {
- protected synchronized Object initialValue() {
- return new GLContextInitActionPair(null, null);
- }
- };
-
- public GLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- this.component = component;
- this.capabilities = (GLCapabilities) capabilities.clone();
- this.chooser = chooser;
- setGL(createGL());
- functionAvailability = new FunctionAvailabilityCache(this);
- if (shareWith != null) {
- GLContextShareSet.registerSharing(this, shareWith);
- }
- }
-
- /** Runs the given runnable with this OpenGL context valid. */
- public synchronized void invokeGL(Runnable runnable, boolean isReshape, Runnable initAction) throws GLException {
- // Could be more clever about not calling this every time, but
- // Thread.currentThread() is very fast and this makes the logic simpler
- Thread currentThread = Thread.currentThread();
-
- // Defer JAWT and OpenGL operations until onscreen components are
- // realized
- if (!isRealized() ||
- willSetRenderingThread ||
- (renderingThread != null &&
- renderingThread != currentThread)) {
- // Support for removeNotify()/addNotify() when the
- // setRenderingThread optimization is in effect and before the
- // animation thread gets a chance to handle either request
- if (!isRealized() && deferredSetRealized) {
- setRealized();
- deferredSetRealized = false;
- } else {
- if (isReshape) {
- deferredReshapeAction = runnable;
- }
- return;
- }
- }
-
- if (isReshape && noAutoRedraw && !SingleThreadedWorkaround.doWorkaround()) {
- // Don't process reshape requests on the AWT thread
- deferredReshapeAction = runnable;
- return;
- }
-
- if (deferredDestroy) {
- deferredDestroy = false;
- if (renderingThread != null) {
- // Need to disable the setRenderingThread optimization to free
- // up the context
- setRenderingThread(null, initAction);
- }
- destroy();
- return;
- }
-
- // The goal of this code is to optimize OpenGL context handling as
- // much as possible. In particular:
- //
- // - setRenderingThread() works by making the "bottommost" OpenGL
- // context current once and not freeing it until the rendering
- // thread has been unset. Note that subsequent pushes of other
- // contexts will still necessarily cause them to be made current
- // and freed.
- //
- // - If the same context is pushed on the per-thread context stack
- // more than once back-to-back, the subsequent pushes will not
- // actually cause a makeCurrent/free to occur.
- //
- // Complexities occur because setRenderingThread() can be called
- // at any time. Currently we implement the rendering thread
- // optimization by popping it off the OpenGL context stack and
- // storing it in a thread-local variable.
-
- GLContextStack ctxStack = getPerThreadContextStack();
- GLContext savedPerThreadContext = getPerThreadSavedCurrentContext();
- Runnable savedPerThreadInitAction = getPerThreadSavedInitAction();
- setPerThreadSavedCurrentContext(null, null);
- if (ctxStack.size() == 0 &&
- savedPerThreadContext != null) {
- // The setRenderingThread optimization moved the current context
- // into thread-local storage. Put it back on the context stack,
- // because we might need to free it later.
- ctxStack.push(savedPerThreadContext, savedPerThreadInitAction);
- }
-
- GLContext curContext = ctxStack.peekContext();
- Runnable curInitAction = ctxStack.peekInitAction();
- boolean mustDoMakeCurrent = true;
-
- if (curContext == this) {
- mustDoMakeCurrent = false;
- }
-
- if (mustDoMakeCurrent) {
- if (curContext != null) {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": Freeing context " + curContext + " due to recursive makeCurrent");
- }
- curContext.free();
- }
-
- if (!makeCurrent(initAction)) {
- // Couldn't make the thread current because the component has not yet
- // been visualized, and therefore the context cannot be created.
- // We'll defer any actions until invokeGL() is called again at a time
- // when the component has been visualized.
- if (isReshape) {
- deferredReshapeAction = runnable;
- }
-
- // Clean up after ourselves on the way out.
- // NOTE that this is an abbreviated version of the code below
- // and should probably be refactored/cleaned up -- this bug
- // fix was done without a lot of intense thought about the
- // situation
- if (curContext != null) {
- curContext.makeCurrent(curInitAction);
- }
- return;
- }
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": Making context " + this + " current");
- }
- }
- ctxStack.push(this, initAction);
-
- // At this point the OpenGL context is current. Offscreen contexts
- // handle resizing the backing bitmap in makeCurrent. Therefore we
- // may need to free and make the context current again if we
- // didn't actually make it current above.
- if (pendingOffscreenResize && renderingThread != null) {
- ctxStack.pop();
- free();
- if (!makeCurrent(initAction)) {
- throw new GLException("Error while resizing offscreen context");
- }
- ctxStack.push(this, initAction);
- }
-
- RuntimeException userException = null;
- GLException internalException = null;
-
- try {
- if (deferredReshapeAction != null) {
- deferredReshapeAction.run();
- deferredReshapeAction = null;
- }
- runnable.run();
- if (autoSwapBuffers && !isReshape) {
- swapBuffers();
- }
- } catch (RuntimeException e) {
- userException = e;
- throw(userException);
- } finally {
- if (userException != null) {
- // Disallow setRenderingThread if display action is throwing exceptions
- renderingThread = null;
- }
-
- boolean mustSkipFreeForRenderingThread = false;
- if (currentThread == renderingThread && curContext == null) {
- mustSkipFreeForRenderingThread = true;
- setPerThreadSavedCurrentContext(this, initAction);
- }
-
- // Always pop myself off the per-thread context stack
- ctxStack.pop();
-
- // Free the context unless the setRenderingThread optimization
- // kicks in.
- if (mustDoMakeCurrent && !mustSkipFreeForRenderingThread) {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": Freeing context " + this);
- }
-
- try {
- free();
- } catch (GLException e) {
- internalException = e;
- }
-
- if (curContext != null) {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": Making context " + curContext + " current again");
- }
- try {
- curContext.makeCurrent(curInitAction);
- } catch (GLException e) {
- internalException = e;
- }
- }
- }
-
- // Check to see whether we pushed any remaining entry on the
- // per-thread context stack. If so, put it back in thread-local
- // storage unless the rendering thread optimization was recently
- // disabled.
- if (savedPerThreadContext != null) {
- assert(savedPerThreadContext == curContext);
- ctxStack.pop();
- if (savedPerThreadContext.getRenderingThread() == null) {
- try {
- savedPerThreadContext.free();
- } catch (GLException e) {
- internalException = e;
- }
- } else {
- setPerThreadSavedCurrentContext(savedPerThreadContext, savedPerThreadInitAction);
- }
- }
-
- // Make sure the end user's exception shows up in any stack
- // traces; the rethrow of the userException above should take
- // precedence if the internalException will otherwise squelch it
- if (internalException != null) {
- if (userException != null &&
- internalException.getCause() == null) {
- internalException.initCause(userException);
- throw(internalException);
- } else if (userException == null) {
- throw(internalException);
- }
- }
- }
- }
-
- public GL getGL() {
- return gl;
- }
-
- public void setGL(GL gl) {
- this.gl = gl;
- // Also reset the GL object for the pure-Java GLU implementation
- ((GLUImpl) glu).setGL(gl);
- }
-
- public GLU getGLU() {
- return glu;
- }
-
- public void setGLU(GLU glu) {
- this.glu = glu;
- }
-
- /** Gives a hint to the context that setRenderingThread will be
- called in the near future; causes redraws to be halted. This is
- a workaround for bugs in NVidia's drivers and is used only by
- the Animator class. */
- public synchronized void willSetRenderingThread() {
- this.willSetRenderingThread = true;
- }
-
- public synchronized void setRenderingThread(Thread currentThreadOrNull, Runnable initAction) {
- if (SingleThreadedWorkaround.doWorkaround()) {
- willSetRenderingThread = false;
- return;
- }
-
- Thread currentThread = Thread.currentThread();
- if (currentThreadOrNull != null && currentThreadOrNull != currentThread) {
- throw new GLException("Argument must be either the current thread or null");
- }
- if (renderingThread != null && currentThreadOrNull != null) {
- throw new GLException("Attempt to re-set or change rendering thread");
- }
- if (renderingThread == null && currentThreadOrNull == null) {
- throw new GLException("Attempt to clear rendering thread when already cleared");
- }
-
- Object currentThreadRenderingContext = perThreadRenderingContext.get();
- if (currentThreadOrNull != null &&
- currentThreadRenderingContext != null &&
- currentThreadRenderingContext != this) {
- throw new GLException("Attempt to call setRenderingThread on more than one drawable in this thread");
- }
-
- this.willSetRenderingThread = false;
- if (currentThreadOrNull == null) {
- renderingThread = null;
- perThreadRenderingContext.set(null);
- // Just in case the end user wasn't planning on drawing the
- // drawable even once more (which would give us a chance to free
- // the context), try to free the context now by performing an
- // invokeGL with a do-nothing action
- invokeGL(new Runnable() {
- public void run() {
- }
- }, false, initAction);
- } else {
- renderingThread = currentThreadOrNull;
- perThreadRenderingContext.set(this);
- }
- }
-
- public Thread getRenderingThread() {
- return renderingThread;
- }
-
- public void setNoAutoRedrawMode(boolean noAutoRedraw) {
- this.noAutoRedraw = noAutoRedraw;
- }
-
- public boolean getNoAutoRedrawMode() {
- return noAutoRedraw;
- }
-
- public void setAutoSwapBufferMode(boolean autoSwapBuffers) {
- this.autoSwapBuffers = autoSwapBuffers;
- }
-
- public boolean getAutoSwapBufferMode() {
- return autoSwapBuffers;
- }
-
- /** Swaps the buffers of the OpenGL context if necessary. All error
- conditions cause a GLException to be thrown. */
- public abstract void swapBuffers() throws GLException;
-
- /** Routine needed only for offscreen contexts in order to resize
- the underlying bitmap. Called by GLJPanel. */
- public void resizeOffscreenContext(int newWidth, int newHeight) {
- if (!isOffscreen()) {
- throw new GLException("Should only call for offscreen OpenGL contexts");
- }
- pendingOffscreenResize = true;
- pendingOffscreenWidth = newWidth;
- pendingOffscreenHeight = newHeight;
- }
-
- /** Indicates which floating-point pbuffer implementation is in
- use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT,
- or GLPbuffer.NV_FLOAT. */
- public int getFloatingPointMode() throws GLException {
- throw new GLException("Not supported on non-pbuffer contexts");
- }
-
- /** Returns a non-null (but possibly empty) string containing the
- space-separated list of available platform-dependent (e.g., WGL,
- GLX) extensions. Can only be called while this context is
- current. */
- public abstract String getPlatformExtensionsString();
-
- /**
- * Resets the cache of which GL functions are available for calling through this
- * context. See {@link #isFunctionAvailable(String)} for more information on
- * the definition of "available".
- */
- protected void resetGLFunctionAvailability() {
- // In order to be able to allow the user to uniformly install the
- // debug and trace pipelines in their GLEventListener.init()
- // method (for both GLCanvas and GLJPanel), we need to reset the
- // actual GL object in the GLDrawable as well
- setGL(createGL());
-
- functionAvailability.flush();
- if (!haveResetGLUProcAddressTable) {
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Initializing GLU extension address table");
- }
- resetProcAddressTable(gluProcAddressTable);
- haveResetGLUProcAddressTable = true; // Only need to do this once globally
- }
- recomputeSingleThreadedWorkaround();
- }
-
- /**
- * Returns true if the specified OpenGL core- or extension-function can be
- * successfully called using this GL context given the current host (OpenGL
- * <i>client</i>) and display (OpenGL <i>server</i>) configuration.
- *
- * See {@link GL#isFunctionAvailable(String)} for more details.
- *
- * @param glFunctionName the name of the OpenGL function (e.g., use
- * "glPolygonOffsetEXT" to check if the {@link
- * net.java.games.jogl.GL#glPolygonOffsetEXT(float,float)} is available).
- */
- protected boolean isFunctionAvailable(String glFunctionName) {
- return functionAvailability.isFunctionAvailable(mapToRealGLFunctionName(glFunctionName));
- }
-
- /**
- * Returns true if the specified OpenGL extension can be
- * successfully called using this GL context given the current host (OpenGL
- * <i>client</i>) and display (OpenGL <i>server</i>) configuration.
- *
- * See {@link GL#isExtensionAvailable(String)} for more details.
- *
- * @param glExtensionName the name of the OpenGL extension (e.g.,
- * "GL_VERTEX_PROGRAM_ARB").
- */
- public boolean isExtensionAvailable(String glExtensionName) {
- return functionAvailability.isExtensionAvailable(mapToRealGLExtensionName(glExtensionName));
- }
-
- /**
- * Pbuffer support; indicates whether this context is capable of
- * creating a subordinate pbuffer context (distinct from an
- * "offscreen context", which is typically software-rendered on all
- * platforms).
- */
- public abstract boolean canCreatePbufferContext();
-
- /**
- * Pbuffer support; creates a subordinate GLContext for a pbuffer
- * associated with this context.
- */
- public abstract GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight);
-
- /**
- * Pbuffer support; given that this is a GLContext associated with a
- * pbuffer, binds this pbuffer to its texture target.
- */
- public abstract void bindPbufferToTexture();
-
- /**
- * Pbuffer support; given that this is a GLContext associated with a
- * pbuffer, releases this pbuffer from its texture target.
- */
- public abstract void releasePbufferFromTexture();
-
- /*
- * Sets the swap interval for onscreen OpenGL contexts. Has no
- * effect for offscreen contexts.
- */
- public void setSwapInterval(final int interval) {
- }
-
- /** Maps the given "platform-independent" function name to a real function
- name. Currently this is only used to map "glAllocateMemoryNV" and
- associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
- protected abstract String mapToRealGLFunctionName(String glFunctionName);
-
- /** Maps the given "platform-independent" extension name to a real
- function name. Currently this is only used to map
- "GL_ARB_pbuffer" and "GL_ARB_pixel_format" to "WGL_ARB_pbuffer"
- and "WGL_ARB_pixel_format" (not yet mapped to X11). */
- protected abstract String mapToRealGLExtensionName(String glExtensionName);
-
- /** Create the GL for this context. */
- protected abstract GL createGL();
-
- /** Hook indicating whether the concrete GLContext implementation is
- offscreen and therefore whether we need to process resize
- requests. */
- protected abstract boolean isOffscreen();
-
- /** Only called for offscreen contexts; returns the buffer from
- which to read pixels (GL.GL_FRONT or GL.GL_BACK). */
- public abstract int getOffscreenContextReadBuffer();
-
- /** Only called for offscreen contexts; needed by glReadPixels */
- public abstract int getOffscreenContextWidth();
-
- /** Only called for offscreen contexts; needed by glReadPixels */
- public abstract int getOffscreenContextHeight();
-
- /** Only called for offscreen contexts; needed by glReadPixels */
- public abstract int getOffscreenContextPixelDataType();
-
- /** On some platforms the mismatch between OpenGL's coordinate
- system (origin at bottom left) and the window system's
- coordinate system (origin at top left) necessitates a vertical
- flip of pixels read from offscreen contexts. */
- public abstract boolean offscreenImageNeedsVerticalFlip();
-
- /** Attempts to make the GL context current. If necessary, creates a
- context and calls the initAction once the context is current.
- Most error conditions cause an exception to be thrown, except
- for the case where the context can not be created because the
- component has not yet been visualized. In this case makeCurrent
- returns false and the caller should abort any OpenGL event
- processing and instead return immediately. */
- protected abstract boolean makeCurrent(Runnable initAction) throws GLException;
-
- /** Frees the OpenGL context. All error conditions cause a
- GLException to be thrown. */
- protected abstract void free() throws GLException;
-
- /** Inform the system that the associated heavyweight widget has
- been realized and that it is safe to create an associated OpenGL
- context. If the widget is later destroyed then destroy() should
- be called, which will cause the underlying OpenGL context to be
- destroyed as well as the realized bit to be set to false. */
- public void setRealized() {
- if (getRenderingThread() != null &&
- Thread.currentThread() != getRenderingThread()) {
- deferredSetRealized = true;
- return;
- }
- setRealized(true);
- }
-
- /** Sets only the "realized" bit. Should be called by subclasses
- from within the destroy() implementation. */
- protected synchronized void setRealized(boolean realized) {
- this.realized = realized;
- if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setRealized(" + realized + ") for context " + this);
- }
- }
-
- /** Indicates whether the component associated with this context has
- been realized. */
- public synchronized boolean getRealized() {
- return realized;
- }
-
- /** Destroys the underlying OpenGL context and changes the realized
- state to false. This should be called when the widget is being
- destroyed. */
- public synchronized void destroy() throws GLException {
- if (getRenderingThread() != null &&
- Thread.currentThread() != getRenderingThread()) {
- if (DEBUG) {
- System.err.println(getThreadName() + ": Deferred destroy for context " + this);
- }
- deferredDestroy = true;
- return;
- }
- setRealized(false);
- GLContextShareSet.contextDestroyed(this);
- destroyImpl();
- }
-
- /** Destroys the underlying OpenGL context. */
- protected abstract void destroyImpl() throws GLException;
-
- public synchronized boolean isRealized() {
- return (component == null || getRealized());
- }
-
- /** Helper routine which resets a ProcAddressTable generated by the
- GLEmitter by looking up anew all of its function pointers. */
- protected void resetProcAddressTable(Object table) {
- Class tableClass = table.getClass();
- java.lang.reflect.Field[] fields = tableClass.getDeclaredFields();
-
- for (int i = 0; i < fields.length; ++i) {
- String addressFieldName = fields[i].getName();
- if (!addressFieldName.startsWith(ProcAddressHelper.PROCADDRESS_VAR_PREFIX)) {
- // not a proc address variable
- continue;
- }
- int startOfMethodName = ProcAddressHelper.PROCADDRESS_VAR_PREFIX.length();
- String glFuncName = addressFieldName.substring(startOfMethodName);
- try {
- java.lang.reflect.Field addressField = tableClass.getDeclaredField(addressFieldName);
- assert(addressField.getType() == Long.TYPE);
- long newProcAddress = dynamicLookupFunction(glFuncName);
- // set the current value of the proc address variable in the table object
- addressField.setLong(table, newProcAddress);
- if (DEBUG) {
- // System.err.println(glFuncName + " = 0x" + Long.toHexString(newProcAddress));
- }
- } catch (Exception e) {
- throw new GLException("Cannot get GL proc address for method \"" +
- glFuncName + "\": Couldn't set value of field \"" + addressFieldName +
- "\" in class " + tableClass.getName(), e);
- }
- }
- }
-
- /** Dynamically looks up the given function. */
- protected abstract long dynamicLookupFunction(String glFuncName);
-
- /** Indicates whether the underlying OpenGL context has been
- created. This is used to manage sharing of display lists and
- textures between contexts. */
- public abstract boolean isCreated();
-
- /** Support for recursive makeCurrent() calls as well as calling
- other drawables' display() methods from within another one's */
- protected static GLContextStack getPerThreadContextStack() {
- return (GLContextStack) perThreadContextStack.get();
- }
-
- /** Support for setRenderingThread()'s optimized context handling */
- protected static GLContext getPerThreadSavedCurrentContext() {
- return ((GLContextInitActionPair) perThreadSavedCurrentContext.get()).getContext();
- }
-
- /** Support for setRenderingThread()'s optimized context handling */
- protected static Runnable getPerThreadSavedInitAction() {
- return ((GLContextInitActionPair) perThreadSavedCurrentContext.get()).getInitAction();
- }
-
- /** Support for setRenderingThread()'s optimized context handling */
- protected static void setPerThreadSavedCurrentContext(GLContext context, Runnable initAction) {
- perThreadSavedCurrentContext.set(new GLContextInitActionPair(context, initAction));
- }
-
- /** Support for automatic detection of whether we need to enable the
- single-threaded workaround for ATI and other vendors' cards.
- Should be called by subclasses for onscreen rendering inside
- their makeCurrent() implementation once the context is
- current. */
- private void recomputeSingleThreadedWorkaround() {
- GL gl = getGL();
- String str = gl.glGetString(GL.GL_VENDOR);
- if (str != null && str.indexOf("ATI") >= 0) {
- // Doing this instead of calling setRenderingThread(null) should
- // be OK since we are doing this very early in the maintenance
- // of the per-thread context stack, before we are actually
- // pushing any GLContext objects on it
- SingleThreadedWorkaround.shouldDoWorkaround();
- if( SingleThreadedWorkaround.doWorkaround() ) {
- renderingThread = null;
- }
- }
- }
-
- protected static String getThreadName() {
- return Thread.currentThread().getName();
- }
-}
diff --git a/src/net/java/games/jogl/impl/GLContextFactory.java b/src/net/java/games/jogl/impl/GLContextFactory.java
deleted file mode 100644
index 40a90f883..000000000
--- a/src/net/java/games/jogl/impl/GLContextFactory.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import net.java.games.jogl.*;
-
-public abstract class GLContextFactory {
- private static GLContextFactory factory;
-
- public static GLContextFactory getFactory() {
- if (factory == null) {
- try {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- Class factoryClass = null;
-
- // Because there are some complications with generating all
- // platforms' Java glue code on all platforms (among them that we
- // would have to include jawt.h and jawt_md.h in the jogl
- // sources, which we currently don't have to do) we break the only
- // static dependencies with platform-specific code here using reflection.
-
- if (osNameLowerCase.startsWith("wind")) {
- factoryClass = Class.forName("net.java.games.jogl.impl.windows.WindowsGLContextFactory");
- } else if (osNameLowerCase.startsWith("mac os x")) {
- factoryClass = Class.forName("net.java.games.jogl.impl.macosx.MacOSXGLContextFactory");
- } else {
- // Assume Linux, Solaris, etc. Should probably test for these explicitly.
- factoryClass = Class.forName("net.java.games.jogl.impl.x11.X11GLContextFactory");
- }
-
- if (factoryClass == null) {
- throw new GLException("OS " + osName + " not yet supported");
- }
-
- factory = (GLContextFactory) factoryClass.newInstance();
- } catch (ClassNotFoundException e) {
- throw new GLException(e);
- } catch (InstantiationException e) {
- throw new GLException(e);
- } catch (IllegalAccessException e) {
- throw new GLException(e);
- }
- }
-
- return factory;
- }
-
- /** Selects a GraphicsConfiguration on the specified GraphicsDevice
- that matches the desired GLCapabilities according to the
- specified GLCapabilitiesChooser's selection algorithm and any
- hints provided by the underlying window system. This routine is
- currently only implemented on X11, where it is necessary to
- choose the desired visual before creating the underlying AWT
- Canvas; on other platforms it returns null, yielding the default
- behavior. */
- public abstract GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GraphicsDevice device);
-
- public abstract GLContext createGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith);
-}
diff --git a/src/net/java/games/jogl/impl/GLContextInitActionPair.java b/src/net/java/games/jogl/impl/GLContextInitActionPair.java
deleted file mode 100755
index 379dda3ee..000000000
--- a/src/net/java/games/jogl/impl/GLContextInitActionPair.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-public class GLContextInitActionPair {
- private GLContext ctx;
- private Runnable initAction;
-
- public GLContextInitActionPair(GLContext ctx, Runnable initAction) {
- this.ctx = ctx;
- this.initAction = initAction;
- }
-
- public GLContext getContext() {
- return ctx;
- }
-
- public Runnable getInitAction() {
- return initAction;
- }
-}
diff --git a/src/net/java/games/jogl/impl/GLContextShareSet.java b/src/net/java/games/jogl/impl/GLContextShareSet.java
deleted file mode 100644
index 60c6b7d59..000000000
--- a/src/net/java/games/jogl/impl/GLContextShareSet.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.lang.ref.*;
-import java.util.*;
-
-/** Provides a mechanism by which OpenGL contexts can share textures
- and display lists in the face of multithreading and asynchronous
- context creation as is inherent in the AWT and Swing. */
-
-public class GLContextShareSet {
- // This class is implemented with a WeakHashMap that goes from the
- // contexts as keys to a complex data structure as value that tracks
- // context creation and deletion.
-
- private static Map/*<GLContext, WeakReference<ShareSet>>*/ shareMap = new WeakHashMap();
- private static Object dummyValue = new Object();
-
- private static class ShareSet {
- private Map allShares = new WeakHashMap();
- private Map createdShares = new WeakHashMap();
- private Map destroyedShares = new WeakHashMap();
-
- public void add(GLContext ctx) {
- if (allShares.put(ctx, dummyValue) == null) {
- if (ctx.isCreated()) {
- createdShares.put(ctx, dummyValue);
- } else {
- destroyedShares.put(ctx, dummyValue);
- }
- }
- }
-
- public GLContext getCreatedShare(GLContext ignore) {
- for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
- GLContext ctx = (GLContext) iter.next();
- if (ctx != ignore) {
- return ctx;
- }
- }
- return null;
- }
-
- public void contextCreated(GLContext ctx) {
- Object res = destroyedShares.remove(ctx);
- assert res != null : "State of ShareSet corrupted; thought context " +
- ctx + " should have been in destroyed set but wasn't";
- res = createdShares.put(ctx, dummyValue);
- assert res == null : "State of ShareSet corrupted; thought context " +
- ctx + " shouldn't have been in created set but was";
- }
-
- public void contextDestroyed(GLContext ctx) {
- Object res = createdShares.remove(ctx);
- assert res != null : "State of ShareSet corrupted; thought context " +
- ctx + " should have been in created set but wasn't";
- res = destroyedShares.put(ctx, dummyValue);
- assert res == null : "State of ShareSet corrupted; thought context " +
- ctx + " shouldn't have been in destroyed set but was";
- }
- }
-
-
- /** Indicate that contexts <code>share1</code> and
- <code>share2</code> will share textures and display lists. */
- public static synchronized void registerSharing(GLContext share1, GLContext share2) {
- ShareSet share = entryFor(share1);
- if (share == null) {
- share = entryFor(share2);
- }
- if (share == null) {
- share = new ShareSet();
- }
- share.add(share1);
- share.add(share2);
- addEntry(share1, share);
- addEntry(share2, share);
- }
-
- public static synchronized GLContext getShareContext(GLContext contextToCreate) {
- ShareSet share = entryFor(contextToCreate);
- if (share == null) {
- return null;
- }
- return share.getCreatedShare(contextToCreate);
- }
-
- public static synchronized void contextCreated(GLContext context) {
- ShareSet share = entryFor(context);
- if (share != null) {
- share.contextCreated(context);
- }
- }
-
- public static synchronized void contextDestroyed(GLContext context) {
- ShareSet share = entryFor(context);
- if (share != null) {
- share.contextDestroyed(context);
- }
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private static ShareSet entryFor(GLContext context) {
- return (ShareSet) shareMap.get(context);
- }
-
- private static void addEntry(GLContext context, ShareSet share) {
- if (shareMap.get(context) == null) {
- shareMap.put(context, share);
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/GLContextStack.java b/src/net/java/games/jogl/impl/GLContextStack.java
deleted file mode 100755
index 089d53525..000000000
--- a/src/net/java/games/jogl/impl/GLContextStack.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.util.*;
-
-/** Implements a stack of GLContext objects along with the initActions
- that need to be run if their creation is necessary. This is used
- to detect redundant makeCurrent() calls and to allow one drawable
- to call display() of another from within the first drawable's
- display() method. */
-
-public class GLContextStack {
- private ArrayList data = new ArrayList();
-
- /** Pushes this GLContext on the stack. The passed context must be non-null. */
- public void push(GLContext ctx, Runnable initAction) {
- if (ctx == null) {
- throw new IllegalArgumentException("Null contexts are not allowed here");
- }
-
- data.add(new GLContextInitActionPair(ctx, initAction));
- }
-
- /** Removes and returns the top GLContext and associated
- initialization action, or null if there is none. */
- public GLContextInitActionPair pop() {
- if (data.size() == 0) {
- return null;
- }
-
- return (GLContextInitActionPair) data.remove(data.size() - 1);
- }
-
- /** Returns the top GLContext and associated initialization action
- without removing it, or null if there is none. */
- public GLContextInitActionPair peek() {
- return peek(0);
- }
-
- /** Returns the <i>i</i>th GLContext and associated initialization
- action from the top without removing it, or null if there is
- none. */
- public GLContextInitActionPair peek(int i) {
- if (data.size() - i <= 0) {
- return null;
- }
-
- return (GLContextInitActionPair) data.get(data.size() - i - 1);
- }
-
- /** Returns the top GLContext without removing it, or null if there
- is none. */
- public GLContext peekContext() {
- return peekContext(0);
- }
-
- /** Returns the <i>i</i>th GLContext from the top without removing
- it, or null if there is none. */
- public GLContext peekContext(int i) {
- GLContextInitActionPair pair = peek(i);
- if (pair == null) {
- return null;
- }
-
- return pair.getContext();
- }
-
- /** Returns the top initialization action without removing it, or
- null if there is none. */
- public Runnable peekInitAction() {
- return peekInitAction(0);
- }
-
- /** Returns the <i>i</i>th initialization action from the top
- without removing it, or null if there is none. */
- public Runnable peekInitAction(int i) {
- GLContextInitActionPair pair = peek(i);
- if (pair == null) {
- return null;
- }
-
- return pair.getInitAction();
- }
-
- /** Returns the number of entries on the GLContext stack. */
- public int size() {
- return data.size();
- }
-}
diff --git a/src/net/java/games/jogl/impl/GLDrawableHelper.java b/src/net/java/games/jogl/impl/GLDrawableHelper.java
deleted file mode 100644
index dd5d7c17f..000000000
--- a/src/net/java/games/jogl/impl/GLDrawableHelper.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.util.*;
-import net.java.games.jogl.*;
-
-/** Encapsulates the implementation of most of the GLDrawable's
- methods to be able to share it between GLCanvas and GLJPanel. */
-
-public class GLDrawableHelper {
- private volatile List listeners = new ArrayList();
-
- public GLDrawableHelper() {
- }
-
- public synchronized void addGLEventListener(GLEventListener listener) {
- List newListeners = (List) ((ArrayList) listeners).clone();
- newListeners.add(listener);
- listeners = newListeners;
- }
-
- public synchronized void removeGLEventListener(GLEventListener listener) {
- List newListeners = (List) ((ArrayList) listeners).clone();
- newListeners.remove(listener);
- listeners = newListeners;
- }
-
- public void init(GLDrawable drawable) {
- for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
- ((GLEventListener) iter.next()).init(drawable);
- }
- }
-
- public void display(GLDrawable drawable) {
- for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
- ((GLEventListener) iter.next()).display(drawable);
- }
- }
-
- public void reshape(GLDrawable drawable,
- int x, int y, int width, int height) {
- for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
- ((GLEventListener) iter.next()).reshape(drawable, x, y, width, height);
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/GLPbufferImpl.java b/src/net/java/games/jogl/impl/GLPbufferImpl.java
deleted file mode 100644
index 7b17c3010..000000000
--- a/src/net/java/games/jogl/impl/GLPbufferImpl.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.awt.Dimension;
-import java.awt.EventQueue;
-import java.awt.event.*;
-import java.beans.PropertyChangeListener;
-
-import net.java.games.jogl.*;
-
-/** Platform-independent class exposing pbuffer functionality to
- applications. This class is not exposed in the public API as it
- would probably add no value; however it implements the GLDrawable
- interface so can be interacted with via its display() method. */
-
-public class GLPbufferImpl implements GLPbuffer {
- // GLPbufferContext
- private GLContext context;
- private GLDrawableHelper drawableHelper = new GLDrawableHelper();
- private boolean isInitialized=false;
- private int floatMode;
-
- public GLPbufferImpl(GLContext context) {
- this.context = context;
- }
-
- public void display() {
- maybeDoSingleThreadedWorkaround(displayOnEventDispatchThreadAction,
- displayAction,
- false);
- }
-
- public void setSize(int width, int height) {
- // FIXME
- throw new GLException("Not yet implemented");
- }
-
- public void setSize(Dimension d) {
- setSize(d.width, d.height);
- }
-
- public Dimension getSize() {
- return getSize(null);
- }
-
- public Dimension getSize(Dimension d) {
- // FIXME
- throw new GLException("Not yet implemented");
- }
-
- public void addGLEventListener(GLEventListener listener) {
- drawableHelper.addGLEventListener(listener);
- }
-
- public void removeGLEventListener(GLEventListener listener) {
- drawableHelper.removeGLEventListener(listener);
- }
-
- public GL getGL() {
- return context.getGL();
- }
-
- public void setGL(GL gl) {
- context.setGL(gl);
- }
-
- public GLU getGLU() {
- return context.getGLU();
- }
-
- public void setGLU(GLU glu) {
- context.setGLU(glu);
- }
-
- void willSetRenderingThread() {
- // Not supported for pbuffers
- }
-
- public void setRenderingThread(Thread currentThreadOrNull) throws GLException {
- // Not supported for pbuffers
- }
-
- public Thread getRenderingThread() {
- // Not supported for pbuffers
- return null;
- }
-
- public void setNoAutoRedrawMode(boolean noAutoRedraws) {
- }
-
- public boolean getNoAutoRedrawMode() {
- return false;
- }
-
- public void setAutoSwapBufferMode(boolean onOrOff) {
- context.setAutoSwapBufferMode(onOrOff);
- }
-
- public boolean getAutoSwapBufferMode() {
- return context.getAutoSwapBufferMode();
- }
-
- public void swapBuffers() {
- maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction, false);
- }
-
- public boolean canCreateOffscreenDrawable() {
- return false;
- }
-
- public GLPbuffer createOffscreenDrawable(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindTexture() {
- // Doesn't make much sense to try to do this on the event dispatch
- // thread given that it has to be called while the context is current
- context.bindPbufferToTexture();
- }
-
- public void releaseTexture() {
- // Doesn't make much sense to try to do this on the event dispatch
- // thread given that it has to be called while the context is current
- context.releasePbufferFromTexture();
- }
-
- public GLContext getContext() {
- return context;
- }
-
- //----------------------------------------------------------------------
- // No-ops for ComponentEvents
- //
-
- public void addComponentListener(ComponentListener l) {}
- public void removeComponentListener(ComponentListener l) {}
- public void addFocusListener(FocusListener l) {}
- public void removeFocusListener(FocusListener l) {}
- public void addHierarchyBoundsListener(HierarchyBoundsListener l) {}
- public void removeHierarchyBoundsListener(HierarchyBoundsListener l) {}
- public void addHierarchyListener(HierarchyListener l) {}
- public void removeHierarchyListener(HierarchyListener l) {}
- public void addInputMethodListener(InputMethodListener l) {}
- public void removeInputMethodListener(InputMethodListener l) {}
- public void addKeyListener(KeyListener l) {}
- public void removeKeyListener(KeyListener l) {}
- public void addMouseListener(MouseListener l) {}
- public void removeMouseListener(MouseListener l) {}
- public void addMouseMotionListener(MouseMotionListener l) {}
- public void removeMouseMotionListener(MouseMotionListener l) {}
- public void addMouseWheelListener(MouseWheelListener l) {}
- public void removeMouseWheelListener(MouseWheelListener l) {}
- public void addPropertyChangeListener(PropertyChangeListener listener) {}
- public void removePropertyChangeListener(PropertyChangeListener listener) {}
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {}
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {}
-
- /** Queries initialization status of this pBuffer.
- * @return true if initialized
- * */
- public boolean isInitialized(){
- return isInitialized;
- }
-
- public void destroy() {
- context.destroy();
- }
-
- public int getFloatingPointMode() {
- if (floatMode == 0) {
- throw new GLException("Pbuffer not initialized, or floating-point support not requested");
- }
- return floatMode;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private void maybeDoSingleThreadedWorkaround(Runnable eventDispatchThreadAction,
- Runnable invokeGLAction,
- boolean isReshape) {
- if (SingleThreadedWorkaround.doWorkaround() && !EventQueue.isDispatchThread()) {
- try {
- // Reshape events must not block on the event queue due to the
- // possibility of deadlocks during initial component creation.
- // This solution is not optimal, because it changes the
- // semantics of reshape() to have some of the processing being
- // done asynchronously, but at least it preserves the
- // semantics of the single-threaded workaround.
- if (!isReshape) {
- EventQueue.invokeAndWait(eventDispatchThreadAction);
- } else {
- EventQueue.invokeLater(eventDispatchThreadAction);
- }
- } catch (Exception e) {
- throw new GLException(e);
- }
- } else {
- context.invokeGL(invokeGLAction, isReshape, initAction);
- }
- }
-
- class InitAction implements Runnable {
- public void run() {
- isInitialized=true;
- floatMode = context.getFloatingPointMode();
- drawableHelper.init(GLPbufferImpl.this);
- }
- }
- private InitAction initAction = new InitAction();
-
- class DisplayAction implements Runnable {
- public void run() {
- drawableHelper.display(GLPbufferImpl.this);
- }
- }
- private DisplayAction displayAction = new DisplayAction();
-
- class SwapBuffersAction implements Runnable {
- public void run() {
- context.swapBuffers();
- }
- }
- private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
-
- // Workaround for ATI driver bugs related to multithreading issues
- // like simultaneous rendering via Animators to canvases that are
- // being resized on the AWT event dispatch thread
- class DisplayOnEventDispatchThreadAction implements Runnable {
- public void run() {
- context.invokeGL(displayAction, false, initAction);
- }
- }
- private DisplayOnEventDispatchThreadAction displayOnEventDispatchThreadAction =
- new DisplayOnEventDispatchThreadAction();
- class SwapBuffersOnEventDispatchThreadAction implements Runnable {
- public void run() {
- context.invokeGL(swapBuffersAction, false, initAction);
- }
- }
- private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction =
- new SwapBuffersOnEventDispatchThreadAction();
-}
diff --git a/src/net/java/games/jogl/impl/GLUquadricImpl.java b/src/net/java/games/jogl/impl/GLUquadricImpl.java
deleted file mode 100755
index dfc167dcb..000000000
--- a/src/net/java/games/jogl/impl/GLUquadricImpl.java
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** $Date$ $Revision$
-** $Header$
-*/
-
-/*
- * Copyright (c) 2002-2004 LWJGL Project
- * All rights reserved.
- *
- * 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 'LWJGL' 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) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 2003 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.games.jogl.impl;
-
-import net.java.games.jogl.*;
-
-/**
- * GLUquadricImpl.java
- *
- *
- * Created 22-dec-2003 (originally Quadric.java)
- * @author Erik Duijs
- * @author Kenneth Russell
- */
-
-class GLUquadricImpl implements GLUquadric {
- private int drawStyle;
- private int orientation;
- private boolean textureFlag;
- private int normals;
-
- GLUquadricImpl() {
- drawStyle = GLU.GLU_FILL;
- orientation = GLU.GLU_OUTSIDE;
- textureFlag = false;
- normals = GLU.GLU_SMOOTH;
- }
-
- /**
- * specifies the draw style for quadrics.
- *
- * The legal values are as follows:
- *
- * GLU.FILL: Quadrics are rendered with polygon primitives. The polygons
- * are drawn in a counterclockwise fashion with respect to
- * their normals (as defined with glu.quadricOrientation).
- *
- * GLU.LINE: Quadrics are rendered as a set of lines.
- *
- * GLU.SILHOUETTE: Quadrics are rendered as a set of lines, except that edges
- * separating coplanar faces will not be drawn.
- *
- * GLU.POINT: Quadrics are rendered as a set of points.
- *
- * @param drawStyle The drawStyle to set
- */
- void setDrawStyle(int drawStyle) {
- this.drawStyle = drawStyle;
- }
-
- /**
- * specifies what kind of normals are desired for quadrics.
- * The legal values are as follows:
- *
- * GLU.NONE: No normals are generated.
- *
- * GLU.FLAT: One normal is generated for every facet of a quadric.
- *
- * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This
- * is the default.
- *
- * @param normals The normals to set
- */
- void setNormals(int normals) {
- this.normals = normals;
- }
-
- /**
- * specifies what kind of orientation is desired for.
- * The orientation values are as follows:
- *
- * GLU.OUTSIDE: Quadrics are drawn with normals pointing outward.
- *
- * GLU.INSIDE: Normals point inward. The default is GLU.OUTSIDE.
- *
- * Note that the interpretation of outward and inward depends on the quadric
- * being drawn.
- *
- * @param orientation The orientation to set
- */
- void setOrientation(int orientation) {
- this.orientation = orientation;
- }
-
- /**
- * specifies if texture coordinates should be generated for
- * quadrics rendered with qobj. If the value of textureCoords is true,
- * then texture coordinates are generated, and if textureCoords is false,
- * they are not.. The default is false.
- *
- * The manner in which texture coordinates are generated depends upon the
- * specific quadric rendered.
- *
- * @param textureFlag The textureFlag to set
- */
- void setTextureFlag(boolean textureFlag) {
- this.textureFlag = textureFlag;
- }
-
- /**
- * Returns the drawStyle.
- * @return int
- */
- int getDrawStyle() {
- return drawStyle;
- }
-
- /**
- * Returns the normals.
- * @return int
- */
- int getNormals() {
- return normals;
- }
-
- /**
- * Returns the orientation.
- * @return int
- */
- int getOrientation() {
- return orientation;
- }
-
- /**
- * Returns the textureFlag.
- * @return boolean
- */
- boolean getTextureFlag() {
- return textureFlag;
- }
-
- /**
- * draws a cylinder oriented along the z axis. The base of the
- * cylinder is placed at z = 0, and the top at z=height. Like a sphere, a
- * cylinder is subdivided around the z axis into slices, and along the z axis
- * into stacks.
- *
- * Note that if topRadius is set to zero, then this routine will generate a
- * cone.
- *
- * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then
- * any generated normals point away from the z axis. Otherwise, they point
- * toward the z axis.
- *
- * If texturing is turned on (with glu.quadricTexture), then texture
- * coordinates are generated so that t ranges linearly from 0.0 at z = 0 to
- * 1.0 at z = height, and s ranges from 0.0 at the +y axis, to 0.25 at the +x
- * axis, to 0.5 at the -y axis, to 0.75 at the -x axis, and back to 1.0 at the
- * +y axis.
- *
- * @param baseRadius Specifies the radius of the cylinder at z = 0.
- * @param topRadius Specifies the radius of the cylinder at z = height.
- * @param height Specifies the height of the cylinder.
- * @param slices Specifies the number of subdivisions around the z axis.
- * @param stacks Specifies the number of subdivisions along the z axis.
- */
- void drawCylinder(GL gl, float baseRadius, float topRadius, float height, int slices, int stacks) {
-
- float da, r, dr, dz;
- float x, y, z, nz, nsign;
- int i, j;
-
- if (orientation == GLU.GLU_INSIDE) {
- nsign = -1.0f;
- } else {
- nsign = 1.0f;
- }
-
- da = 2.0f * PI / slices;
- dr = (topRadius - baseRadius) / stacks;
- dz = height / stacks;
- nz = (baseRadius - topRadius) / height;
- // Z component of normal vectors
-
- if (drawStyle == GLU.GLU_POINT) {
- gl.glBegin(GL.GL_POINTS);
- for (i = 0; i < slices; i++) {
- x = cos((i * da));
- y = sin((i * da));
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
-
- z = 0.0f;
- r = baseRadius;
- for (j = 0; j <= stacks; j++) {
- gl.glVertex3f((x * r), (y * r), z);
- z += dz;
- r += dr;
- }
- }
- gl.glEnd();
- } else if (drawStyle == GLU.GLU_LINE || drawStyle == GLU.GLU_SILHOUETTE) {
- // Draw rings
- if (drawStyle == GLU.GLU_LINE) {
- z = 0.0f;
- r = baseRadius;
- for (j = 0; j <= stacks; j++) {
- gl.glBegin(GL.GL_LINE_LOOP);
- for (i = 0; i < slices; i++) {
- x = cos((i * da));
- y = sin((i * da));
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- gl.glVertex3f((x * r), (y * r), z);
- }
- gl.glEnd();
- z += dz;
- r += dr;
- }
- } else {
- // draw one ring at each end
- if (baseRadius != 0.0) {
- gl.glBegin(GL.GL_LINE_LOOP);
- for (i = 0; i < slices; i++) {
- x = cos((i * da));
- y = sin((i * da));
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- gl.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
- }
- gl.glEnd();
- gl.glBegin(GL.GL_LINE_LOOP);
- for (i = 0; i < slices; i++) {
- x = cos((i * da));
- y = sin((i * da));
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- gl.glVertex3f((x * topRadius), (y * topRadius), height);
- }
- gl.glEnd();
- }
- }
- // draw length lines
- gl.glBegin(GL.GL_LINES);
- for (i = 0; i < slices; i++) {
- x = cos((i * da));
- y = sin((i * da));
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- gl.glVertex3f((x * baseRadius), (y * baseRadius), 0.0f);
- gl.glVertex3f((x * topRadius), (y * topRadius), (height));
- }
- gl.glEnd();
- } else if (drawStyle == GLU.GLU_FILL) {
- float ds = 1.0f / slices;
- float dt = 1.0f / stacks;
- float t = 0.0f;
- z = 0.0f;
- r = baseRadius;
- for (j = 0; j < stacks; j++) {
- float s = 0.0f;
- gl.glBegin(GL.GL_QUAD_STRIP);
- for (i = 0; i <= slices; i++) {
- if (i == slices) {
- x = sin(0.0f);
- y = cos(0.0f);
- } else {
- x = sin((i * da));
- y = cos((i * da));
- }
- if (nsign == 1.0f) {
- normal3f(gl, (x * nsign), (y * nsign), (nz * nsign));
- TXTR_COORD(gl, s, t);
- gl.glVertex3f((x * r), (y * r), z);
- normal3f(gl, (x * nsign), (y * nsign), (nz * nsign));
- TXTR_COORD(gl, s, t + dt);
- gl.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
- } else {
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- TXTR_COORD(gl, s, t);
- gl.glVertex3f((x * r), (y * r), z);
- normal3f(gl, x * nsign, y * nsign, nz * nsign);
- TXTR_COORD(gl, s, t + dt);
- gl.glVertex3f((x * (r + dr)), (y * (r + dr)), (z + dz));
- }
- s += ds;
- } // for slices
- gl.glEnd();
- r += dr;
- t += dt;
- z += dz;
- } // for stacks
- }
- }
-
- /**
- * renders a disk on the z = 0 plane. The disk has a radius of
- * outerRadius, and contains a concentric circular hole with a radius of
- * innerRadius. If innerRadius is 0, then no hole is generated. The disk is
- * subdivided around the z axis into slices (like pizza slices), and also
- * about the z axis into rings (as specified by slices and loops,
- * respectively).
- *
- * With respect to orientation, the +z side of the disk is considered to be
- * "outside" (see glu.quadricOrientation). This means that if the orientation
- * is set to GLU.OUTSIDE, then any normals generated point along the +z axis.
- * Otherwise, they point along the -z axis.
- *
- * If texturing is turned on (with glu.quadricTexture), texture coordinates are
- * generated linearly such that where r=outerRadius, the value at (r, 0, 0) is
- * (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), and at
- * (0, -r, 0) it is (0.5, 0).
- */
- public void drawDisk(GL gl, float innerRadius, float outerRadius, int slices, int loops)
- {
- float da, dr;
-
- /* Normal vectors */
- if (normals != GLU.GLU_NONE) {
- if (orientation == GLU.GLU_OUTSIDE) {
- gl.glNormal3f(0.0f, 0.0f, +1.0f);
- }
- else {
- gl.glNormal3f(0.0f, 0.0f, -1.0f);
- }
- }
-
- da = 2.0f * PI / slices;
- dr = (outerRadius - innerRadius) / loops;
-
- switch (drawStyle) {
- case GLU.GLU_FILL:
- {
- /* texture of a gluDisk is a cut out of the texture unit square
- * x, y in [-outerRadius, +outerRadius]; s, t in [0, 1]
- * (linear mapping)
- */
- float dtc = 2.0f * outerRadius;
- float sa, ca;
- float r1 = innerRadius;
- int l;
- for (l = 0; l < loops; l++) {
- float r2 = r1 + dr;
- if (orientation == GLU.GLU_OUTSIDE) {
- int s;
- gl.glBegin(gl.GL_QUAD_STRIP);
- for (s = 0; s <= slices; s++) {
- float a;
- if (s == slices)
- a = 0.0f;
- else
- a = s * da;
- sa = sin(a);
- ca = cos(a);
- TXTR_COORD(gl, 0.5f + sa * r2 / dtc, 0.5f + ca * r2 / dtc);
- gl.glVertex2f(r2 * sa, r2 * ca);
- TXTR_COORD(gl, 0.5f + sa * r1 / dtc, 0.5f + ca * r1 / dtc);
- gl.glVertex2f(r1 * sa, r1 * ca);
- }
- gl.glEnd();
- }
- else {
- int s;
- gl.glBegin(GL.GL_QUAD_STRIP);
- for (s = slices; s >= 0; s--) {
- float a;
- if (s == slices)
- a = 0.0f;
- else
- a = s * da;
- sa = sin(a);
- ca = cos(a);
- TXTR_COORD(gl, 0.5f - sa * r2 / dtc, 0.5f + ca * r2 / dtc);
- gl.glVertex2f(r2 * sa, r2 * ca);
- TXTR_COORD(gl, 0.5f - sa * r1 / dtc, 0.5f + ca * r1 / dtc);
- gl.glVertex2f(r1 * sa, r1 * ca);
- }
- gl.glEnd();
- }
- r1 = r2;
- }
- break;
- }
- case GLU.GLU_LINE:
- {
- int l, s;
- /* draw loops */
- for (l = 0; l <= loops; l++) {
- float r = innerRadius + l * dr;
- gl.glBegin(GL.GL_LINE_LOOP);
- for (s = 0; s < slices; s++) {
- float a = s * da;
- gl.glVertex2f(r * sin(a), r * cos(a));
- }
- gl.glEnd();
- }
- /* draw spokes */
- for (s = 0; s < slices; s++) {
- float a = s * da;
- float x = sin(a);
- float y = cos(a);
- gl.glBegin(GL.GL_LINE_STRIP);
- for (l = 0; l <= loops; l++) {
- float r = innerRadius + l * dr;
- gl.glVertex2f(r * x, r * y);
- }
- gl.glEnd();
- }
- break;
- }
- case GLU.GLU_POINT:
- {
- int s;
- gl.glBegin(GL.GL_POINTS);
- for (s = 0; s < slices; s++) {
- float a = s * da;
- float x = sin(a);
- float y = cos(a);
- int l;
- for (l = 0; l <= loops; l++) {
- float r = innerRadius * l * dr;
- gl.glVertex2f(r * x, r * y);
- }
- }
- gl.glEnd();
- break;
- }
- case GLU.GLU_SILHOUETTE:
- {
- if (innerRadius != 0.0) {
- float a;
- gl.glBegin(GL.GL_LINE_LOOP);
- for (a = 0.0f; a < 2.0 * PI; a += da) {
- float x = innerRadius * sin(a);
- float y = innerRadius * cos(a);
- gl.glVertex2f(x, y);
- }
- gl.glEnd();
- }
- {
- float a;
- gl.glBegin(GL.GL_LINE_LOOP);
- for (a = 0; a < 2.0f * PI; a += da) {
- float x = outerRadius * sin(a);
- float y = outerRadius * cos(a);
- gl.glVertex2f(x, y);
- }
- gl.glEnd();
- }
- break;
- }
- default:
- return;
- }
- }
-
- /**
- * renders a partial disk on the z=0 plane. A partial disk is similar to a
- * full disk, except that only the subset of the disk from startAngle
- * through startAngle + sweepAngle is included (where 0 degrees is along
- * the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and
- * 270 along the -x axis).
- *
- * The partial disk has a radius of outerRadius, and contains a concentric
- * circular hole with a radius of innerRadius. If innerRadius is zero, then
- * no hole is generated. The partial disk is subdivided around the z axis
- * into slices (like pizza slices), and also about the z axis into rings
- * (as specified by slices and loops, respectively).
- *
- * With respect to orientation, the +z side of the partial disk is
- * considered to be outside (see gluQuadricOrientation). This means that if
- * the orientation is set to GLU.GLU_OUTSIDE, then any normals generated point
- * along the +z axis. Otherwise, they point along the -z axis.
- *
- * If texturing is turned on (with gluQuadricTexture), texture coordinates
- * are generated linearly such that where r=outerRadius, the value at (r, 0, 0)
- * is (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5),
- * and at (0, -r, 0) it is (0.5, 0).
- */
- public void drawPartialDisk(GL gl,
- float innerRadius,
- float outerRadius,
- int slices,
- int loops,
- float startAngle,
- float sweepAngle) {
- int i, j, max;
- float[] sinCache = new float[CACHE_SIZE];
- float[] cosCache = new float[CACHE_SIZE];
- float angle;
- float x, y;
- float sintemp, costemp;
- float deltaRadius;
- float radiusLow, radiusHigh;
- float texLow = 0, texHigh = 0;
- float angleOffset;
- int slices2;
- int finish;
-
- if (slices >= CACHE_SIZE)
- slices = CACHE_SIZE - 1;
- if (slices < 2
- || loops < 1
- || outerRadius <= 0.0f
- || innerRadius < 0.0f
- || innerRadius > outerRadius) {
- //gluQuadricError(qobj, GLU.GLU_INVALID_VALUE);
- System.err.println("PartialDisk: GLU_INVALID_VALUE");
- return;
- }
-
- if (sweepAngle < -360.0f)
- sweepAngle = 360.0f;
- if (sweepAngle > 360.0f)
- sweepAngle = 360.0f;
- if (sweepAngle < 0) {
- startAngle += sweepAngle;
- sweepAngle = -sweepAngle;
- }
-
- if (sweepAngle == 360.0f) {
- slices2 = slices;
- } else {
- slices2 = slices + 1;
- }
-
- /* Compute length (needed for normal calculations) */
- deltaRadius = outerRadius - innerRadius;
-
- /* Cache is the vertex locations cache */
-
- angleOffset = startAngle / 180.0f * PI;
- for (i = 0; i <= slices; i++) {
- angle = angleOffset + ((PI * sweepAngle) / 180.0f) * i / slices;
- sinCache[i] = sin(angle);
- cosCache[i] = cos(angle);
- }
-
- if (sweepAngle == 360.0f) {
- sinCache[slices] = sinCache[0];
- cosCache[slices] = cosCache[0];
- }
-
- switch (normals) {
- case GLU.GLU_FLAT :
- case GLU.GLU_SMOOTH :
- if (orientation == GLU.GLU_OUTSIDE) {
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
- } else {
- gl.glNormal3f(0.0f, 0.0f, -1.0f);
- }
- break;
- default :
- case GLU.GLU_NONE :
- break;
- }
-
- switch (drawStyle) {
- case GLU.GLU_FILL :
- if (innerRadius == .0f) {
- finish = loops - 1;
- /* Triangle strip for inner polygons */
- gl.glBegin(GL.GL_TRIANGLE_FAN);
- if (textureFlag) {
- gl.glTexCoord2f(0.5f, 0.5f);
- }
- gl.glVertex3f(0.0f, 0.0f, 0.0f);
- radiusLow = outerRadius - deltaRadius * ((float) (loops - 1) / loops);
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- }
-
- if (orientation == GLU.GLU_OUTSIDE) {
- for (i = slices; i >= 0; i--) {
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
- }
- } else {
- for (i = 0; i <= slices; i++) {
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
- }
- }
- gl.glEnd();
- } else {
- finish = loops;
- }
- for (j = 0; j < finish; j++) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
- radiusHigh = outerRadius - deltaRadius * ((float) (j + 1) / loops);
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- texHigh = radiusHigh / outerRadius / 2;
- }
-
- gl.glBegin(GL.GL_QUAD_STRIP);
- for (i = 0; i <= slices; i++) {
- if (orientation == GLU.GLU_OUTSIDE) {
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
-
- if (textureFlag) {
- gl.glTexCoord2f(texHigh * sinCache[i] + 0.5f,
- texHigh * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusHigh * sinCache[i],
- radiusHigh * cosCache[i],
- 0.0f);
- } else {
- if (textureFlag) {
- gl.glTexCoord2f(texHigh * sinCache[i] + 0.5f,
- texHigh * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusHigh * sinCache[i],
- radiusHigh * cosCache[i],
- 0.0f);
-
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
- }
- }
- gl.glEnd();
- }
- break;
- case GLU.GLU_POINT :
- gl.glBegin(GL.GL_POINTS);
- for (i = 0; i < slices2; i++) {
- sintemp = sinCache[i];
- costemp = cosCache[i];
- for (j = 0; j <= loops; j++) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
-
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
-
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
- }
- }
- gl.glEnd();
- break;
- case GLU.GLU_LINE :
- if (innerRadius == outerRadius) {
- gl.glBegin(GL.GL_LINE_STRIP);
-
- for (i = 0; i <= slices; i++) {
- if (textureFlag) {
- gl.glTexCoord2f(sinCache[i] / 2 + 0.5f, cosCache[i] / 2 + 0.5f);
- }
- gl.glVertex3f(innerRadius * sinCache[i], innerRadius * cosCache[i], 0.0f);
- }
- gl.glEnd();
- break;
- }
- for (j = 0; j <= loops; j++) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- }
-
- gl.glBegin(GL.GL_LINE_STRIP);
- for (i = 0; i <= slices; i++) {
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
- }
- gl.glEnd();
- }
- for (i = 0; i < slices2; i++) {
- sintemp = sinCache[i];
- costemp = cosCache[i];
- gl.glBegin(GL.GL_LINE_STRIP);
- for (j = 0; j <= loops; j++) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- }
-
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
- }
- gl.glEnd();
- }
- break;
- case GLU.GLU_SILHOUETTE :
- if (sweepAngle < 360.0f) {
- for (i = 0; i <= slices; i += slices) {
- sintemp = sinCache[i];
- costemp = cosCache[i];
- gl.glBegin(GL.GL_LINE_STRIP);
- for (j = 0; j <= loops; j++) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
-
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0f);
- }
- gl.glEnd();
- }
- }
- for (j = 0; j <= loops; j += loops) {
- radiusLow = outerRadius - deltaRadius * ((float) j / loops);
- if (textureFlag) {
- texLow = radiusLow / outerRadius / 2;
- }
-
- gl.glBegin(GL.GL_LINE_STRIP);
- for (i = 0; i <= slices; i++) {
- if (textureFlag) {
- gl.glTexCoord2f(texLow * sinCache[i] + 0.5f,
- texLow * cosCache[i] + 0.5f);
- }
- gl.glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 0.0f);
- }
- gl.glEnd();
- if (innerRadius == outerRadius)
- break;
- }
- break;
- default :
- break;
- }
- }
-
- /**
- * draws a sphere of the given radius centered around the origin.
- * The sphere is subdivided around the z axis into slices and along the z axis
- * into stacks (similar to lines of longitude and latitude).
- *
- * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then
- * any normals generated point away from the center of the sphere. Otherwise,
- * they point toward the center of the sphere.
-
- * If texturing is turned on (with glu.quadricTexture), then texture
- * coordinates are generated so that t ranges from 0.0 at z=-radius to 1.0 at
- * z=radius (t increases linearly along longitudinal lines), and s ranges from
- * 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75
- * at the -x axis, and back to 1.0 at the +y axis.
- */
- public void drawSphere(GL gl, float radius, int slices, int stacks) {
- // TODO
-
- float rho, drho, theta, dtheta;
- float x, y, z;
- float s, t, ds, dt;
- int i, j, imin, imax;
- boolean normals;
- float nsign;
-
- normals = (this.normals != GLU.GLU_NONE);
-
- if (orientation == GLU.GLU_INSIDE) {
- nsign = -1.0f;
- } else {
- nsign = 1.0f;
- }
-
- drho = PI / stacks;
- dtheta = 2.0f * PI / slices;
-
- if (drawStyle == GLU.GLU_FILL) {
- if (!textureFlag) {
- // draw +Z end as a triangle fan
- gl.glBegin(GL.GL_TRIANGLE_FAN);
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
- gl.glVertex3f(0.0f, 0.0f, nsign * radius);
- for (j = 0; j <= slices; j++) {
- theta = (j == slices) ? 0.0f : j * dtheta;
- x = -sin(theta) * sin(drho);
- y = cos(theta) * sin(drho);
- z = nsign * cos(drho);
- if (normals) {
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- }
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- gl.glEnd();
- }
-
- ds = 1.0f / slices;
- dt = 1.0f / stacks;
- t = 1.0f; // because loop now runs from 0
- if (textureFlag) {
- imin = 0;
- imax = stacks;
- } else {
- imin = 1;
- imax = stacks - 1;
- }
-
- // draw intermediate stacks as quad strips
- for (i = imin; i < imax; i++) {
- rho = i * drho;
- gl.glBegin(GL.GL_QUAD_STRIP);
- s = 0.0f;
- for (j = 0; j <= slices; j++) {
- theta = (j == slices) ? 0.0f : j * dtheta;
- x = -sin(theta) * sin(rho);
- y = cos(theta) * sin(rho);
- z = nsign * cos(rho);
- if (normals) {
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- }
- TXTR_COORD(gl, s, t);
- gl.glVertex3f(x * radius, y * radius, z * radius);
- x = -sin(theta) * sin(rho + drho);
- y = cos(theta) * sin(rho + drho);
- z = nsign * cos(rho + drho);
- if (normals) {
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- }
- TXTR_COORD(gl, s, t - dt);
- s += ds;
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- gl.glEnd();
- t -= dt;
- }
-
- if (!textureFlag) {
- // draw -Z end as a triangle fan
- gl.glBegin(GL.GL_TRIANGLE_FAN);
- gl.glNormal3f(0.0f, 0.0f, -1.0f);
- gl.glVertex3f(0.0f, 0.0f, -radius * nsign);
- rho = PI - drho;
- s = 1.0f;
- for (j = slices; j >= 0; j--) {
- theta = (j == slices) ? 0.0f : j * dtheta;
- x = -sin(theta) * sin(rho);
- y = cos(theta) * sin(rho);
- z = nsign * cos(rho);
- if (normals)
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- s -= ds;
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- gl.glEnd();
- }
- } else if (
- drawStyle == GLU.GLU_LINE
- || drawStyle == GLU.GLU_SILHOUETTE) {
- // draw stack lines
- for (i = 1;
- i < stacks;
- i++) { // stack line at i==stacks-1 was missing here
- rho = i * drho;
- gl.glBegin(GL.GL_LINE_LOOP);
- for (j = 0; j < slices; j++) {
- theta = j * dtheta;
- x = cos(theta) * sin(rho);
- y = sin(theta) * sin(rho);
- z = cos(rho);
- if (normals)
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- gl.glEnd();
- }
- // draw slice lines
- for (j = 0; j < slices; j++) {
- theta = j * dtheta;
- gl.glBegin(GL.GL_LINE_STRIP);
- for (i = 0; i <= stacks; i++) {
- rho = i * drho;
- x = cos(theta) * sin(rho);
- y = sin(theta) * sin(rho);
- z = cos(rho);
- if (normals)
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- gl.glEnd();
- }
- } else if (drawStyle == GLU.GLU_POINT) {
- // top and bottom-most points
- gl.glBegin(GL.GL_POINTS);
- if (normals)
- gl.glNormal3f(0.0f, 0.0f, nsign);
- gl.glVertex3f(0.0f, 0.0f, radius);
- if (normals)
- gl.glNormal3f(0.0f, 0.0f, -nsign);
- gl.glVertex3f(0.0f, 0.0f, -radius);
-
- // loop over stacks
- for (i = 1; i < stacks - 1; i++) {
- rho = i * drho;
- for (j = 0; j < slices; j++) {
- theta = j * dtheta;
- x = cos(theta) * sin(rho);
- y = sin(theta) * sin(rho);
- z = cos(rho);
- if (normals)
- gl.glNormal3f(x * nsign, y * nsign, z * nsign);
- gl.glVertex3f(x * radius, y * radius, z * radius);
- }
- }
- gl.glEnd();
- }
- }
-
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private static final float PI = (float)Math.PI;
- private static final int CACHE_SIZE = 240;
-
- /**
- * Call glNormal3f after scaling normal to unit length.
- *
- * @param x
- * @param y
- * @param z
- */
- private void normal3f(GL gl, float x, float y, float z) {
- float mag;
-
- mag = (float)Math.sqrt(x * x + y * y + z * z);
- if (mag > 0.00001F) {
- x /= mag;
- y /= mag;
- z /= mag;
- }
- gl.glNormal3f(x, y, z);
- }
-
- private void TXTR_COORD(GL gl, float x, float y) {
- if (textureFlag) gl.glTexCoord2f(x,y);
- }
-
- private float sin(float r) {
- return (float)Math.sin(r);
- }
-
- private float cos(float r) {
- return (float)Math.cos(r);
- }
-}
diff --git a/src/net/java/games/jogl/impl/InternalBufferUtils.java b/src/net/java/games/jogl/impl/InternalBufferUtils.java
deleted file mode 100644
index 7ae5efb0e..000000000
--- a/src/net/java/games/jogl/impl/InternalBufferUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.nio.*;
-
-/** Utility routines available only to the JOGL implementation. */
-
-public class InternalBufferUtils {
- /** Allocates a new direct byte buffer at the given address with the
- given capacity. This is exposed only because of glMapBufferARB
- and its semantics; it is undesirable to allocate a new buffer
- every frame because (a) ByteBuffers are finalizable and (b) the
- application would typically need to re-slice the buffer every
- frame. Instead we cache these ByteBuffer objects up in Java and
- look them up in a HashMap by base address and capacity. */
- public static native ByteBuffer newDirectByteBuffer(long address, int capacity);
-}
diff --git a/src/net/java/games/jogl/impl/JAWT_PlatformInfo.java b/src/net/java/games/jogl/impl/JAWT_PlatformInfo.java
deleted file mode 100644
index 55eb43d42..000000000
--- a/src/net/java/games/jogl/impl/JAWT_PlatformInfo.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-/** Marker class for all window system-specific JAWT data structures. */
-
-public interface JAWT_PlatformInfo {
-}
diff --git a/src/net/java/games/jogl/impl/NativeLibLoader.java b/src/net/java/games/jogl/impl/NativeLibLoader.java
deleted file mode 100644
index 54d37f6ce..000000000
--- a/src/net/java/games/jogl/impl/NativeLibLoader.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.security.*;
-
-public class NativeLibLoader {
- private static volatile boolean doLoading = true;
- private static volatile boolean doneLoading = false;
-
- public static void disableLoading() {
- doLoading = false;
- }
-
- public static void enableLoading() {
- doLoading = true;
- }
-
- public static synchronized void load() {
- if (doLoading && !doneLoading) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
- if (!isOSX) {
- try {
- System.loadLibrary("jawt");
- } catch (UnsatisfiedLinkError e) {
- // Accessibility technologies load JAWT themselves; safe to continue
- // as long as JAWT is loaded by any loader
- if (e.getMessage().indexOf("already loaded") == -1) {
- throw e;
- }
- }
- }
- System.loadLibrary("jogl");
-
- // Workaround for 4845371.
- // Make sure the first reference to the JNI GetDirectBufferAddress is done
- // from a privileged context so the VM's internal class lookups will succeed.
- JAWT jawt = new JAWT();
- JAWTFactory.JAWT_GetAWT(jawt);
-
- return null;
- }
- });
- doneLoading = true;
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/Project.java b/src/net/java/games/jogl/impl/Project.java
deleted file mode 100755
index 90770309f..000000000
--- a/src/net/java/games/jogl/impl/Project.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** $Date$ $Revision$
-** $Header$
-*/
-
-/*
- * Copyright (c) 2002-2004 LWJGL Project
- * All rights reserved.
- *
- * 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 'LWJGL' 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) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 2003 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.games.jogl.impl;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.util.*;
-
-import java.nio.DoubleBuffer;
-
-/**
- * Project.java
- * <p/>
- * <p/>
- * Created 11-jan-2004
- *
- * @author Erik Duijs
- * @author Kenneth Russell
- */
-class Project {
- private static final double[] IDENTITY_MATRIX =
- new double[] {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0 };
-
- private final DoubleBuffer matrix = BufferUtils.newDoubleBuffer(16);
- private final double[] finalMatrix = new double[16];
-
- private final double[][] tempMatrix = new double[4][4];
- private final double[] in = new double[4];
- private final double[] out = new double[4];
-
- private final double[] forward = new double[3];
- private final double[] side = new double[3];
- private final double[] up = new double[3];
-
- /**
- * Make matrix an identity matrix
- */
- private void __gluMakeIdentityd(DoubleBuffer m) {
- int oldPos = m.position();
- m.put(IDENTITY_MATRIX);
- m.position(oldPos);
- }
-
- private void __gluMakeIdentityd(double[] m) {
- for (int i = 0; i < 16; i++) {
- m[i] = IDENTITY_MATRIX[i];
- }
- }
-
- /**
- * Method __gluMultMatrixVecd
- *
- * @param matrix
- * @param in
- * @param out
- */
- private void __gluMultMatrixVecd(double[] matrix, double[] in, double[] out) {
- for (int i = 0; i < 4; i++) {
- out[i] =
- in[0] * matrix[0*4+i] +
- in[1] * matrix[1*4+i] +
- in[2] * matrix[2*4+i] +
- in[3] * matrix[3*4+i];
-
- }
- }
-
- /**
- * @param src
- * @param inverse
- *
- * @return
- */
- private boolean __gluInvertMatrixd(double[] src, double[] inverse) {
- int i, j, k, swap;
- double t;
- double[][] temp = tempMatrix;
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- temp[i][j] = src[i*4+j];
- }
- }
- __gluMakeIdentityd(inverse);
-
- for (i = 0; i < 4; i++) {
- /*
- * * Look for largest element in column
- */
- swap = i;
- for (j = i + 1; j < 4; j++) {
- if (Math.abs(temp[j][i]) > Math.abs(temp[i][i])) {
- swap = j;
- }
- }
-
- if (swap != i) {
- /*
- * * Swap rows.
- */
- for (k = 0; k < 4; k++) {
- t = temp[i][k];
- temp[i][k] = temp[swap][k];
- temp[swap][k] = t;
-
- t = inverse[i*4+k];
- inverse[i*4+k] = inverse[swap*4+k];
- inverse[swap*4+k] = t;
- }
- }
-
- if (temp[i][i] == 0) {
- /*
- * No non-zero pivot. The matrix is singular, which shouldn't
- * happen. This means the user gave us a bad matrix.
- */
- return false;
- }
-
- t = temp[i][i];
- for (k = 0; k < 4; k++) {
- temp[i][k] /= t;
- inverse[i*4+k] /= t;
- }
- for (j = 0; j < 4; j++) {
- if (j != i) {
- t = temp[j][i];
- for (k = 0; k < 4; k++) {
- temp[j][k] -= temp[i][k] * t;
- inverse[j*4+k] -= inverse[i*4+k]*t;
- }
- }
- }
- }
- return true;
- }
-
- /**
- * @param a
- * @param b
- * @param r
- */
- private void __gluMultMatricesd(double[] a, double[] b, double[] r) {
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- r[i*4+j] =
- a[i*4+0]*b[0*4+j] +
- a[i*4+1]*b[1*4+j] +
- a[i*4+2]*b[2*4+j] +
- a[i*4+3]*b[3*4+j];
- }
- }
- }
-
- /**
- * Normalize vector
- *
- * @param v
- */
- private static void normalize(double[] v) {
- double r;
-
- r = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
- if ( r == 0.0 )
- return;
-
- r = 1.0 / r;
-
- v[0] *= r;
- v[1] *= r;
- v[2] *= r;
-
- return;
- }
-
- /**
- * Calculate cross-product
- *
- * @param v1
- * @param v2
- * @param result
- */
- private static void cross(double[] v1, double[] v2, double[] result) {
- result[0] = v1[1] * v2[2] - v1[2] * v2[1];
- result[1] = v1[2] * v2[0] - v1[0] * v2[2];
- result[2] = v1[0] * v2[1] - v1[1] * v2[0];
- }
-
- /**
- * Method gluOrtho2D.
- *
- * @param left
- * @param right
- * @param bottom
- * @param top
- */
- public void gluOrtho2D(GL gl, double left, double right, double bottom, double top) {
- gl.glOrtho(left, right, bottom, top, -1, 1);
- }
-
- /**
- * Method gluPerspective.
- *
- * @param fovy
- * @param aspect
- * @param zNear
- * @param zFar
- */
- public void gluPerspective(GL gl, double fovy, double aspect, double zNear, double zFar) {
- double sine, cotangent, deltaZ;
- double radians = fovy / 2 * Math.PI / 180;
-
- deltaZ = zFar - zNear;
- sine = Math.sin(radians);
-
- if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) {
- return;
- }
-
- cotangent = Math.cos(radians) / sine;
-
- __gluMakeIdentityd(matrix);
-
- matrix.put(0 * 4 + 0, cotangent / aspect);
- matrix.put(1 * 4 + 1, cotangent);
- matrix.put(2 * 4 + 2, - (zFar + zNear) / deltaZ);
- matrix.put(2 * 4 + 3, -1);
- matrix.put(3 * 4 + 2, -2 * zNear * zFar / deltaZ);
- matrix.put(3 * 4 + 3, 0);
-
- gl.glMultMatrixd(matrix);
- }
-
- /**
- * Method gluLookAt
- *
- * @param eyex
- * @param eyey
- * @param eyez
- * @param centerx
- * @param centery
- * @param centerz
- * @param upx
- * @param upy
- * @param upz
- */
- public void gluLookAt(GL gl,
- double eyex,
- double eyey,
- double eyez,
- double centerx,
- double centery,
- double centerz,
- double upx,
- double upy,
- double upz) {
- double[] forward = this.forward;
- double[] side = this.side;
- double[] up = this.up;
-
- forward[0] = centerx - eyex;
- forward[1] = centery - eyey;
- forward[2] = centerz - eyez;
-
- up[0] = upx;
- up[1] = upy;
- up[2] = upz;
-
- normalize(forward);
-
- /* Side = forward x up */
- cross(forward, up, side);
- normalize(side);
-
- /* Recompute up as: up = side x forward */
- cross(side, forward, up);
-
- __gluMakeIdentityd(matrix);
- matrix.put(0 * 4 + 0, side[0]);
- matrix.put(1 * 4 + 0, side[1]);
- matrix.put(2 * 4 + 0, side[2]);
-
- matrix.put(0 * 4 + 1, up[0]);
- matrix.put(1 * 4 + 1, up[1]);
- matrix.put(2 * 4 + 1, up[2]);
-
- matrix.put(0 * 4 + 2, -forward[0]);
- matrix.put(1 * 4 + 2, -forward[1]);
- matrix.put(2 * 4 + 2, -forward[2]);
-
- gl.glMultMatrixd(matrix);
- gl.glTranslated(-eyex, -eyey, -eyez);
- }
-
- /**
- * Method gluProject
- *
- * @param objx
- * @param objy
- * @param objz
- * @param modelMatrix
- * @param projMatrix
- * @param viewport
- * @param win_pos
- *
- * @return
- */
- public boolean gluProject(double objx,
- double objy,
- double objz,
- double[] modelMatrix,
- double[] projMatrix,
- int[] viewport,
- double[] win_pos) {
-
- double[] in = this.in;
- double[] out = this.out;
-
- in[0] = objx;
- in[1] = objy;
- in[2] = objz;
- in[3] = 1.0;
-
- __gluMultMatrixVecd(modelMatrix, in, out);
- __gluMultMatrixVecd(projMatrix, out, in);
-
- if (in[3] == 0.0)
- return false;
-
- in[3] = (1.0 / in[3]) * 0.5;
-
- // Map x, y and z to range 0-1
- in[0] = in[0] * in[3] + 0.5f;
- in[1] = in[1] * in[3] + 0.5f;
- in[2] = in[2] * in[3] + 0.5f;
-
- // Map x,y to viewport
- win_pos[0] = in[0] * viewport[2] + viewport[0];
- win_pos[1] = in[1] * viewport[3] + viewport[1];
- win_pos[2] = in[2];
-
- return true;
- }
-
- /**
- * Method gluUnproject
- *
- * @param winx
- * @param winy
- * @param winz
- * @param modelMatrix
- * @param projMatrix
- * @param viewport
- * @param obj_pos
- *
- * @return
- */
- public boolean gluUnProject(double winx,
- double winy,
- double winz,
- double[] modelMatrix,
- double[] projMatrix,
- int[] viewport,
- double[] obj_pos) {
- double[] in = this.in;
- double[] out = this.out;
-
- __gluMultMatricesd(modelMatrix, projMatrix, finalMatrix);
-
- if (!__gluInvertMatrixd(finalMatrix, finalMatrix))
- return false;
-
- in[0] = winx;
- in[1] = winy;
- in[2] = winz;
- in[3] = 1.0;
-
- // Map x and y from window coordinates
- in[0] = (in[0] - viewport[0]) / viewport[2];
- in[1] = (in[1] - viewport[1]) / viewport[3];
-
- // Map to range -1 to 1
- in[0] = in[0] * 2 - 1;
- in[1] = in[1] * 2 - 1;
- in[2] = in[2] * 2 - 1;
-
- __gluMultMatrixVecd(finalMatrix, in, out);
-
- if (out[3] == 0.0)
- return false;
-
- out[3] = 1.0 / out[3];
-
- obj_pos[0] = out[0] * out[3];
- obj_pos[1] = out[1] * out[3];
- obj_pos[2] = out[2] * out[3];
-
- return true;
- }
-
- /**
- * Method gluUnproject4
- *
- * @param winx
- * @param winy
- * @param winz
- * @param clipw
- * @param modelMatrix
- * @param projMatrix
- * @param viewport
- * @param near
- * @param far
- * @param obj_pos
- *
- * @return
- */
- public boolean gluUnProject4(double winx,
- double winy,
- double winz,
- double clipw,
- double[] modelMatrix,
- double[] projMatrix,
- int[] viewport,
- double near,
- double far,
- double[] obj_pos) {
- double[] in = this.in;
- double[] out = this.out;
-
- __gluMultMatricesd(modelMatrix, projMatrix, finalMatrix);
-
- if (!__gluInvertMatrixd(finalMatrix, finalMatrix))
- return false;
-
- in[0] = winx;
- in[1] = winy;
- in[2] = winz;
- in[3] = clipw;
-
- // Map x and y from window coordinates
- in[0] = (in[0] - viewport[0]) / viewport[2];
- in[1] = (in[1] - viewport[1]) / viewport[3];
- in[2] = (in[2] - near) / (far - near);
-
- // Map to range -1 to 1
- in[0] = in[0] * 2 - 1;
- in[1] = in[1] * 2 - 1;
- in[2] = in[2] * 2 - 1;
-
- __gluMultMatrixVecd(finalMatrix, in, out);
-
- if (out[3] == 0.0)
- return false;
-
- obj_pos[0] = out[0];
- obj_pos[1] = out[1];
- obj_pos[2] = out[2];
- obj_pos[3] = out[3];
- return true;
- }
-
- /**
- * Method gluPickMatrix
- *
- * @param x
- * @param y
- * @param deltaX
- * @param deltaY
- * @param viewport
- */
- public void gluPickMatrix(GL gl,
- double x,
- double y,
- double deltaX,
- double deltaY,
- int[] viewport) {
- if (deltaX <= 0 || deltaY <= 0) {
- return;
- }
-
- /* Translate and scale the picked region to the entire window */
- gl.glTranslated((viewport[2] - 2 * (x - viewport[0])) / deltaX,
- (viewport[3] - 2 * (y - viewport[1])) / deltaY,
- 0);
- gl.glScaled(viewport[2] / deltaX, viewport[3] / deltaY, 1.0);
- }
-}
diff --git a/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java b/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java
deleted file mode 100755
index f19c1fb67..000000000
--- a/src/net/java/games/jogl/impl/SingleThreadedWorkaround.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/** Encapsulates the workaround of running all display operations on
- the AWT event queue thread for the purposes of working around
- problems seen primarily on ATI cards when rendering into a surface
- that is simultaneously being resized by the event queue thread.
- <p>
-
- As of JOGL 1.1 b10, this property defaults to true. Problems have
- been seen on Windows, Linux and Mac OS X platforms that are solved
- by switching all OpenGL work to a single thread, which this
- workaround provides. The forthcoming JSR-231 work will rethink how
- such a mechanism is implemented, but the core result of needing to
- perform all OpenGL work on a single thread for best compatibility
- will remain.
-*/
-
-public class SingleThreadedWorkaround {
- private static boolean singleThreadedWorkaround = true;
- // If the user specified the workaround's system property (either
- // true or false), don't let the automatic detection have any effect
- private static boolean systemPropertySpecified = false;
-
- static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String workaround = System.getProperty("jogl.1thread");
- if (workaround == null) {
- // Old system property (for compatibility)
- workaround = System.getProperty("JOGL_SINGLE_THREADED_WORKAROUND");
- }
- if (workaround == null) {
- // Older system property (for compatibility)
- workaround = System.getProperty("ATI_WORKAROUND");
- }
- if (workaround != null && (!workaround.equals("auto"))) {
- systemPropertySpecified = true;
- singleThreadedWorkaround = Boolean.valueOf(workaround).booleanValue();
- }
- printWorkaroundNotice();
- return null;
- }
- });
- }
-
- /** Public method for users to disable the single-threaded
- workaround in application code. Should perhaps eventually
- promote this method to the public API. */
- public static void disableWorkaround() {
- systemPropertySpecified = true;
- singleThreadedWorkaround = false;
- if (Debug.verbose()) {
- System.err.println("Application forced disabling of single-threaded workaround of dispatching display() on event thread");
- }
- }
-
- public static void shouldDoWorkaround() {
- if (!systemPropertySpecified) {
- singleThreadedWorkaround = true;
- printWorkaroundNotice();
- }
- }
-
- public static boolean doWorkaround() {
- return singleThreadedWorkaround;
- }
-
- private static void printWorkaroundNotice() {
- if (singleThreadedWorkaround && Debug.verbose()) {
- System.err.println("Using single-threaded workaround of dispatching display() on event thread");
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/Util.java b/src/net/java/games/jogl/impl/Util.java
deleted file mode 100755
index 46bdfc79a..000000000
--- a/src/net/java/games/jogl/impl/Util.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2002-2004 LWJGL Project
- * All rights reserved.
- *
- * 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 'LWJGL' 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) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 2003 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.games.jogl.impl;
-
-import java.nio.IntBuffer;
-import net.java.games.jogl.*;
-
-/**
- * Util.java
- * <p/>
- * <p/>
- * Created 7-jan-2004
- *
- * @author Erik Duijs
- */
-class Util {
-
- /**
- * temp int[] of one for getting an int from some GL functions
- */
- private int[] scratch = new int[1];
-
- /**
- * Return ceiling of integer division
- *
- * @param a
- * @param b
- *
- * @return int
- */
- protected static int ceil(int a, int b) {
- return (a % b == 0 ? a / b : a / b + 1);
- }
-
- /**
- * Method compPerPix.
- *
- * @param format
- *
- * @return int
- */
- protected static int compPerPix(int format) {
- /* Determine number of components per pixel */
- switch ( format ) {
- case GL.GL_COLOR_INDEX:
- case GL.GL_STENCIL_INDEX:
- case GL.GL_DEPTH_COMPONENT:
- case GL.GL_RED:
- case GL.GL_GREEN:
- case GL.GL_BLUE:
- case GL.GL_ALPHA:
- case GL.GL_LUMINANCE:
- return 1;
- case GL.GL_LUMINANCE_ALPHA:
- return 2;
- case GL.GL_RGB:
- case GL.GL_BGR:
- return 3;
- case GL.GL_RGBA:
- case GL.GL_BGRA:
- return 4;
- default :
- return -1;
- }
- }
-
- /**
- * Method nearestPower.
- * <p/>
- * Compute the nearest power of 2 number. This algorithm is a little strange, but it works quite well.
- *
- * @param value
- *
- * @return int
- */
- protected static int nearestPower(int value) {
- int i;
-
- i = 1;
-
- /* Error! */
- if ( value == 0 )
- return -1;
-
- for ( ; ; ) {
- if ( value == 1 ) {
- return i;
- } else if ( value == 3 ) {
- return i << 2;
- }
- value >>= 1;
- i <<= 1;
- }
- }
-
- /**
- * Method bytesPerPixel.
- *
- * @param format
- * @param type
- *
- * @return int
- */
- protected static int bytesPerPixel(int format, int type) {
- int n, m;
-
- switch ( format ) {
- case GL.GL_COLOR_INDEX:
- case GL.GL_STENCIL_INDEX:
- case GL.GL_DEPTH_COMPONENT:
- case GL.GL_RED:
- case GL.GL_GREEN:
- case GL.GL_BLUE:
- case GL.GL_ALPHA:
- case GL.GL_LUMINANCE:
- n = 1;
- break;
- case GL.GL_LUMINANCE_ALPHA:
- n = 2;
- break;
- case GL.GL_RGB:
- case GL.GL_BGR:
- n = 3;
- break;
- case GL.GL_RGBA:
- case GL.GL_BGRA:
- n = 4;
- break;
- default :
- n = 0;
- }
-
- switch ( type ) {
- case GL.GL_UNSIGNED_BYTE:
- m = 1;
- break;
- case GL.GL_BYTE:
- m = 1;
- break;
- case GL.GL_BITMAP:
- m = 1;
- break;
- case GL.GL_UNSIGNED_SHORT:
- m = 2;
- break;
- case GL.GL_SHORT:
- m = 2;
- break;
- case GL.GL_UNSIGNED_INT:
- m = 4;
- break;
- case GL.GL_INT:
- m = 4;
- break;
- case GL.GL_FLOAT:
- m = 4;
- break;
- default :
- m = 0;
- }
-
- return n * m;
- }
-
- /**
- * Convenience method for returning an int, rather than getting it out of a buffer yourself.
- *
- * @param what
- *
- * @return int
- */
- protected int glGetIntegerv(GL gl, int what) {
- gl.glGetIntegerv(what, scratch);
- return scratch[0];
- }
-}
diff --git a/src/net/java/games/jogl/impl/error/Error.java b/src/net/java/games/jogl/impl/error/Error.java
deleted file mode 100644
index a9b4c48f1..000000000
--- a/src/net/java/games/jogl/impl/error/Error.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.error;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.GLU;
-import net.java.games.jogl.impl.GLUImpl;
-
-/**
- *
- * @author Administrator
- */
-public class Error {
-
- private static String[] glErrorStrings = {
- "invalid enumerant",
- "invalid value",
- "invalid operation",
- "stack overflow",
- "stack underflow",
- "out of memory"
- };
-
- private static String[] gluErrorStrings = {
- "invalid enumerant",
- "invalid value",
- "out of memory",
- "",
- "invalid operation"
- };
-
- /** Creates a new instance of Error */
- public Error() {
- }
-
- public static String gluErrorString( int errorCode ) {
- if( errorCode == 0 ) {
- return( "no error" );
- }
- if( (errorCode >= GL.GL_INVALID_ENUM) && (errorCode <= GL.GL_OUT_OF_MEMORY) ) {
- return( glErrorStrings[ errorCode - GL.GL_INVALID_ENUM ] );
- }
- if( errorCode == GL.GL_TABLE_TOO_LARGE ) {
- return( "table too large" );
- }
- if( (errorCode >= GLUImpl.GLU_INVALID_ENUM) && (errorCode <= GLUImpl.GLU_INVALID_OPERATION) ) {
- return( gluErrorStrings[ errorCode - GLUImpl.GLU_INVALID_ENUM ] );
- }
- if( (errorCode >= GLUImpl.GLU_NURBS_ERROR1) && (errorCode <= GLUImpl.GLU_NURBS_ERROR37) ) {
- return( gluErrorStrings[ errorCode - (GLUImpl.GLU_NURBS_ERROR1 - 1) ] );
- }
- if( (errorCode >= GLUImpl.GLU_TESS_ERROR1) && (errorCode <= GLUImpl.GLU_TESS_ERROR8) ) {
- return( gluErrorStrings[ errorCode - (GLUImpl.GLU_TESS_ERROR1 - 1) ] );
- }
- return( null );
- }
-}
diff --git a/src/net/java/games/jogl/impl/glue/Glue.java b/src/net/java/games/jogl/impl/glue/Glue.java
deleted file mode 100644
index 65ba2ad9d..000000000
--- a/src/net/java/games/jogl/impl/glue/Glue.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.glue;
-
-/**
- *
- * @author Administrator
- */
-public class Glue {
- private static String[] __gluNurbsErrors = {
- " ",
- "spline order un-supported",
- "too few knots",
- "valid knot range is empty",
- "decreasing knot sequence knot",
- "knot multiplicity greater than order of spline",
- "gluEndCurve() must follow gluBeginCurve()",
- "gluBeginCurve() must precede gluEndCurve()",
- "missing or extra geometric data",
- "can't draw piecewise linear trimming curves",
- "missing or extra domain data",
- "missing or extra domain data",
- "gluEndTrim() must precede gluEndSurface()",
- "gluBeginSurface() must precede gluEndSurface()",
- "curve of improper type passed as trim curve",
- "gluBeginSurface() must precede gluBeginTrim()",
- "gluEndTrim() must follow gluBeginTrim()",
- "gluBeginTrim() must follow gluEndTrim()",
- "invalid or missing trim curve",
- "gluBeginTrim() must precede gluPwlCurve()",
- "piecewise linear trimming curve referenced twice",
- "piecewise linear trimming curve and nurbs curve mixed",
- "improper usage of trim data type",
- "nurbs curve referenced twice",
- "nurbs curve and piecewise linear trimming curve mixed",
- "nurbs surface referenced twice",
- "invalid property",
- "gluEndSurface() must follow gluBeginSurface()",
- "intersecting or misoriented trim curve",
- "intersecting trim curves",
- "UNUSED",
- "inconnected trim curves",
- "unknown knot error",
- "negative vertex count encountered",
- "negative byte-stride encountered",
- "unknown type descriptor",
- "null control point reference",
- "duplicate point on piecewise linear trimming curve"
- } ;
-
- /** Creates a new instance of Glue */
- public Glue() {
- }
-
- public static String __gluNURBSErrorString( int errno ) {
- return( __gluNurbsErrors[ errno ] );
- }
-
- private static String[] __gluTessErrors = {
- " ",
- "gluTessBeginPolygon() must precede a gluTessEndPolygon",
- "gluTessBeginContour() must precede a gluTessEndContour()",
- "gluTessEndPolygon() must follow a gluTessBeginPolygon()",
- "gluTessEndContour() must follow a gluTessBeginContour()",
- "a coordinate is too large",
- "need combine callback"
- };
-
- public static String __gluTessErrorString( int errno ) {
- return( __gluTessErrors[ errno ] );
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java
deleted file mode 100644
index 29a3ef63b..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXDummyGLContext.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.macosx;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-/** This MacOSXGLContext implementation provides interoperability with
- the NSOpenGLView Cocoa widget. The MacOSXGLImpl can be
- instantiated without a GLContext, in which case it expects that
- the end user will handle all OpenGL context management. Dynamic
- function lookup is supported in this configuration by having this
- object provide the FunctionAvailabilityTable. */
-
-class MacOSXDummyGLContext extends MacOSXGLContext
-{
- private MacOSXGLImpl gl;
-
- MacOSXDummyGLContext(MacOSXGLImpl gl) {
- super(null, null, null, null);
- this.gl = gl;
- }
-
- protected GL createGL() {
- return gl;
- }
-
- protected boolean isOffscreen() {
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- public boolean canCreatePbufferContext() {
- throw new GLException("Should not call this");
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- throw new GLException("Should not call this");
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- throw new GLException("Should not call this");
- }
-
- public synchronized void swapBuffers() throws GLException {
- throw new GLException("Should not call this");
- }
-
- protected synchronized void free() throws GLException {
- throw new GLException("Should not call this");
- }
-
- protected boolean create() {
- throw new GLException("Should not call this");
- }
-
- public void destroy() {
- throw new GLException("Should not call this");
- }
-
- public void resetGLFunctionAvailability() {
- super.resetGLFunctionAvailability();
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
deleted file mode 100644
index ec58de9a6..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.macosx;
-
-import java.awt.Component;
-import java.util.*;
-import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public abstract class MacOSXGLContext extends GLContext
-{
- private static JAWT jawt;
- protected long nsContext; // NSOpenGLContext
- protected long nsView; // NSView
- protected long updater; // ContextUpdater
- // Table that holds the addresses of the native C-language entry points for
- // OpenGL functions.
- private GLProcAddressTable glProcAddressTable;
-
- public MacOSXGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith)
- {
- super(component, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new MacOSXGLImpl(this);
- }
-
- protected String mapToRealGLFunctionName(String glFunctionName)
- {
- return glFunctionName;
- }
-
- protected String mapToRealGLExtensionName(String glExtensionName)
- {
- return glExtensionName;
- }
-
- protected boolean isFunctionAvailable(String glFunctionName)
- {
- return super.isFunctionAvailable(glFunctionName);
- }
-
- public boolean isExtensionAvailable(String glExtensionName) {
- if (glExtensionName.equals("GL_ARB_pbuffer") ||
- glExtensionName.equals("GL_ARB_pixel_format")) {
- return true;
- }
- return super.isExtensionAvailable(glExtensionName);
- }
-
- protected abstract boolean isOffscreen();
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextWidth() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextHeight() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextPixelDataType() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- protected boolean create() {
- return create(false, false);
- }
-
- /**
- * Creates and initializes an appropriate OpenGl nsContext. Should only be
- * called by {@link makeCurrent(Runnable)}.
- */
- protected boolean create(boolean pbuffer, boolean floatingPoint) {
- MacOSXGLContext other = (MacOSXGLContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getNSContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- int[] viewNotReady = new int[1];
- nsContext = CGL.createContext(share,
- nsView,
- capabilities.getDoubleBuffered() ? 1 : 0,
- capabilities.getStereo() ? 1 : 0,
- capabilities.getRedBits(),
- capabilities.getGreenBits(),
- capabilities.getBlueBits(),
- capabilities.getAlphaBits(),
- capabilities.getDepthBits(),
- capabilities.getStencilBits(),
- capabilities.getAccumRedBits(),
- capabilities.getAccumGreenBits(),
- capabilities.getAccumBlueBits(),
- capabilities.getAccumAlphaBits(),
- capabilities.getSampleBuffers() ? 1 : 0,
- capabilities.getNumSamples(),
- (pbuffer ? 1 : 0),
- (floatingPoint ? 1 : 0),
- viewNotReady);
- if (nsContext == 0) {
- if (viewNotReady[0] == 1) {
- if (DEBUG) {
- System.err.println("!!! View not ready for " + getClass().getName());
- }
- // View not ready at the window system level -- this is OK
- return false;
- }
- throw new GLException("Error creating nsContext");
- }
- //updater = CGL.updateContextRegister(nsContext, nsView); // gznote: not thread safe yet!
- GLContextShareSet.contextCreated(this);
- return true;
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- boolean created = false;
- if (nsContext == 0) {
- if (!create()) {
- return false;
- }
- if (DEBUG) {
- System.err.println("!!! Created GL nsContext for " + getClass().getName());
- }
- created = true;
- }
-
- if (!CGL.makeCurrentContext(nsContext, nsView)) {
- throw new GLException("Error making nsContext current");
- }
-
- if (created) {
- resetGLFunctionAvailability();
- if (initAction != null) {
- initAction.run();
- }
- }
- return true;
- }
-
- protected synchronized void free() throws GLException {
- if (!CGL.clearCurrentContext(nsContext, nsView)) {
- throw new GLException("Error freeing OpenGL nsContext");
- }
- }
-
- protected void destroyImpl() throws GLException {
- if (nsContext != 0) {
- if (!CGL.deleteContext(nsContext, 0)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + nsContext);
- }
- nsContext = 0;
- }
- }
-
- public abstract void swapBuffers() throws GLException;
-
- protected long dynamicLookupFunction(String glFuncName) {
- return CGL.getProcAddress(glFuncName);
- }
-
- public boolean isCreated() {
- return (nsContext != 0);
- }
-
- protected void resetGLFunctionAvailability()
- {
- super.resetGLFunctionAvailability();
- if (DEBUG) {
- System.err.println("!!! Initializing OpenGL extension address table");
- }
- resetProcAddressTable(getGLProcAddressTable());
- }
-
- public GLProcAddressTable getGLProcAddressTable()
- {
- if (glProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by capability bits so we can
- // share them among contexts with the same capabilities
- glProcAddressTable = new GLProcAddressTable();
- }
- return glProcAddressTable;
- }
-
- public String getPlatformExtensionsString()
- {
- return "";
- }
-
- public void setSwapInterval(int interval) {
- if (nsContext == 0) {
- throw new GLException("OpenGL context not current");
- }
- CGL.setSwapInterval(nsContext, interval);
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- protected long getNSContext() {
- return nsContext;
- }
-
- protected long getNSView() {
- return nsView;
- }
-
- protected JAWT getJAWT()
- {
- if (jawt == null)
- {
- JAWT j = new JAWT();
- j.version(JAWTFactory.JAWT_VERSION_1_4);
- if (!JAWTFactory.JAWT_GetAWT(j))
- {
- throw new RuntimeException("Unable to initialize JAWT");
- }
- jawt = j;
- }
- return jawt;
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java
deleted file mode 100644
index 25f15b3f2..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContextFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.macosx;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class MacOSXGLContextFactory extends GLContextFactory {
- public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GraphicsDevice device) {
- return null;
- }
-
- public GLContext createGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- if (component != null) {
- return new MacOSXOnscreenGLContext(component, capabilities, chooser, shareWith);
- } else {
- return new MacOSXOffscreenGLContext(capabilities, chooser, shareWith);
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java
deleted file mode 100644
index 37b2302c0..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXOffscreenGLContext.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.macosx;
-
-import java.awt.image.BufferedImage;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class MacOSXOffscreenGLContext extends MacOSXPbufferGLContext
-{
- public MacOSXOffscreenGLContext(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(capabilities, -1, -1);
- }
-
- protected boolean isOffscreen() {
- return true;
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- return true;
- }
-
- public int getOffscreenContextWidth() {
- return initWidth;
- }
-
- public int getOffscreenContextHeight() {
- return initWidth;
- }
-
- public int getOffscreenContextPixelDataType() {
- return GL.GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- public int getOffscreenContextReadBuffer() {
- return GL.GL_BACK;
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- if (pendingOffscreenResize && (nsContext != 0)) {
- if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
- destroyPBuffer();
- initWidth = pendingOffscreenWidth;
- initHeight = pendingOffscreenHeight;
- createPbuffer(0, 0);
- pendingOffscreenResize = false;
- }
- }
- return super.makeCurrent(initAction);
- }
-
- public synchronized void swapBuffers() throws GLException {
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java
deleted file mode 100644
index ba4eee0ef..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.macosx;
-
-import java.awt.Component;
-import java.util.*;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-import java.security.*;
-
-public class MacOSXOnscreenGLContext extends MacOSXGLContext {
- // Variables for lockSurface/unlockSurface
- private JAWT_DrawingSurface ds;
- private JAWT_DrawingSurfaceInfo dsi;
- private JAWT_MacOSXDrawingSurfaceInfo macosxdsi;
-
- // Variables for pbuffer support
- List pbuffersToInstantiate = new ArrayList();
-
- // Workaround for instance of 4796548
- private boolean firstLock = true;
-
- public MacOSXOnscreenGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(component, capabilities, chooser, shareWith);
- }
-
- protected boolean isOffscreen() {
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- public boolean canCreatePbufferContext() {
- return true;
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- MacOSXPbufferGLContext ctx = new MacOSXPbufferGLContext(capabilities, initialWidth, initialHeight);
- GLContextShareSet.registerSharing(this, ctx);
- pbuffersToInstantiate.add(ctx);
- return ctx;
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- public synchronized void setRenderingThread(Thread currentThreadOrNull, Runnable initAction) {
- this.willSetRenderingThread = false;
- // FIXME: the JAWT in the Panther developer release
- // requires all JAWT operations to be done on the AWT
- // thread. This means that setRenderingThread won't work
- // yet on this platform. This method can be deleted once
- // the update for that release ships.
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- try {
- if (!lockSurface()) {
- return false;
- }
- boolean ret = super.makeCurrent(initAction);
- if (ret) {
- // Assume the canvas might have been resized or moved and tell the OpenGL
- // context to update itself. This used to be done only upon receiving a
- // reshape event but that doesn't appear to be sufficient. An experiment
- // was also done to add a HierarchyBoundsListener to the GLCanvas and
- // do this updating only upon reshape of this component or reshape or movement
- // of an ancestor, but this also wasn't sufficient and left garbage on the
- // screen in some situations.
- CGL.updateContext(nsContext, nsView);
- // Instantiate any pending pbuffers
- while (!pbuffersToInstantiate.isEmpty()) {
- MacOSXPbufferGLContext ctx =
- (MacOSXPbufferGLContext) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1);
- ctx.createPbuffer(nsView, nsContext);
- }
- } else {
- // View might not have been ready
- unlockSurface();
- }
- return ret;
- } catch (RuntimeException e) {
- try {
- unlockSurface();
- } catch (Exception e2) {
- // do nothing if unlockSurface throws
- }
- throw(e);
- }
- }
-
- protected synchronized void free() throws GLException {
- try {
- super.free();
- } finally {
- unlockSurface();
- }
- }
-
- public synchronized void swapBuffers() throws GLException {
- if (!CGL.flushBuffer(nsContext, nsView)) {
- throw new GLException("Error swapping buffers");
- }
- }
-
- private boolean lockSurface() throws GLException {
- if (nsView != 0) {
- throw new GLException("Surface already locked");
- }
-
- ds = getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return false;
- }
-
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
-
- // See whether the surface changed and if so destroy the old
- // OpenGL nsContext so it will be recreated
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- if (nsContext != 0) {
- //CGL.updateContextUnregister(nsContext, nsView, updater); // gznote: not thread safe yet!
- if (!CGL.deleteContext(nsContext, nsView)) {
- throw new GLException("Unable to delete old GL nsContext after surface changed");
- }
- }
- }
-
- if (firstLock) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- dsi = ds.GetDrawingSurfaceInfo();
- return null;
- }
- });
- } else {
- dsi = ds.GetDrawingSurfaceInfo();
- }
- if (dsi == null) {
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
-
- // Widget not yet realized
- return false;
- }
-
- firstLock = false;
-
- macosxdsi = (JAWT_MacOSXDrawingSurfaceInfo) dsi.platformInfo();
- if (macosxdsi == null) {
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
-
- // Widget not yet realized
- return false;
- }
-
- nsView = macosxdsi.cocoaViewRef();
- if (nsView == 0) {
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- macosxdsi = null;
-
- // Widget not yet realized
- return false;
- }
-
- return true;
- }
-
- private void unlockSurface() throws GLException {
- if (nsView == 0) {
- throw new GLException("Surface already unlocked");
- }
-
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- macosxdsi = null;
- nsView = 0;
- }
-}
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java
deleted file mode 100644
index 93bde269b..000000000
--- a/src/net/java/games/jogl/impl/macosx/MacOSXPbufferGLContext.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package net.java.games.jogl.impl.macosx;
-
-import java.security.*;
-import java.util.*;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class MacOSXPbufferGLContext extends MacOSXGLContext {
- private static final boolean DEBUG = Debug.debug("MacOSXPbufferGLContext");
- private static boolean isTigerOrLater;
-
- static {
- String osVersion =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("os.version");
- }
- });
- StringTokenizer tok = new StringTokenizer(osVersion, ". ");
- int major = Integer.parseInt(tok.nextToken());
- int minor = Integer.parseInt(tok.nextToken());
- isTigerOrLater = ((major > 10) || (minor > 3));
- }
-
- protected int initWidth;
- protected int initHeight;
-
- private long pBuffer;
-
- protected int width;
- protected int height;
-
- // State for render-to-texture and render-to-texture-rectangle support
- private boolean created;
- private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
- private int texture; // actual texture object
-
- public MacOSXPbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- super(null, capabilities, null, null);
- this.initWidth = initialWidth;
- this.initHeight = initialHeight;
- }
-
- public boolean canCreatePbufferContext() {
- return false;
- }
-
- public GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindPbufferToTexture() {
- GL gl = getGL();
- gl.glBindTexture(textureTarget, texture);
- // FIXME: not clear whether this is really necessary, but since
- // the API docs seem to imply it is and since it doesn't seem to
- // impact performance, leaving it in
- CGL.setContextTextureImageToPBuffer(nsContext, pBuffer, GL.GL_FRONT);
- }
-
- public void releasePbufferFromTexture() {
- }
-
- public void createPbuffer(long parentView, long parentContext) {
- GL gl = getGL();
- // Must initally grab OpenGL function pointers while parent's
- // context is current because otherwise we don't have the cgl
- // extensions available to us
- resetGLFunctionAvailability();
-
- int renderTarget;
- if (capabilities.getOffscreenRenderToTextureRectangle()) {
- width = initWidth;
- height = initHeight;
- renderTarget = GL.GL_TEXTURE_RECTANGLE_EXT;
- } else {
- width = getNextPowerOf2(initWidth);
- height = getNextPowerOf2(initHeight);
- renderTarget = GL.GL_TEXTURE_2D;
- }
-
- int internalFormat = GL.GL_RGBA;
- if (capabilities.getOffscreenFloatingPointBuffers()) {
- if (!gl.isExtensionAvailable("GL_APPLE_float_pixels")) {
- throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available");
- }
- switch (capabilities.getRedBits()) {
- case 16: internalFormat = GL.GL_RGBA_FLOAT16_APPLE; break;
- case 32: internalFormat = GL.GL_RGBA_FLOAT32_APPLE; break;
- default: throw new GLException("Invalid floating-point bit depth (only 16 and 32 supported)");
- }
- }
-
- pBuffer = CGL.createPBuffer(renderTarget, internalFormat, width, height);
- if (pBuffer == 0) {
- throw new GLException("pbuffer creation error: CGL.createPBuffer() failed");
- }
-
- if (DEBUG) {
- System.err.println("Created pbuffer 0x" + Long.toHexString(pBuffer) + ", " + width + " x " + height + " for " + this);
- }
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- created = false;
-
- if (pBuffer == 0) {
- if (DEBUG) {
- System.err.println("Pbuffer not instantiated yet for " + this);
- }
- // pbuffer not instantiated yet
- return false;
- }
-
- boolean res = super.makeCurrent(initAction);
- if (created) {
- // Initialize render-to-texture support if requested
- boolean rect = capabilities.getOffscreenRenderToTextureRectangle();
- GL gl = getGL();
- if (rect) {
- if (!gl.isExtensionAvailable("GL_EXT_texture_rectangle")) {
- System.err.println("MacOSXPbufferGLContext: WARNING: GL_EXT_texture_rectangle extension not " +
- "supported; skipping requested render_to_texture_rectangle support for pbuffer");
- rect = false;
- }
- }
- textureTarget = (rect ? GL.GL_TEXTURE_RECTANGLE_EXT : GL.GL_TEXTURE_2D);
- int[] tmp = new int[1];
- gl.glGenTextures(1, tmp);
- texture = tmp[0];
- gl.glBindTexture(textureTarget, texture);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
- gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, width, height, 0);
- }
- return res;
- }
-
- public void destroyPBuffer() {
- if (this.pBuffer != 0) {
- CGL.destroyPBuffer(nsContext, pBuffer);
- }
- this.pBuffer = 0;
-
- if (DEBUG) {
- System.err.println("Destroyed pbuffer " + width + " x " + height);
- }
- }
-
- public void handleModeSwitch(long parentView, long parentContext) {
- throw new GLException("Not yet implemented");
- }
-
- protected boolean isOffscreen() {
- // FIXME: currently the only caller of this won't cause proper
- // resizing of the pbuffer anyway.
- return false;
- }
-
- protected void destroyImpl() throws GLException {
- destroyPBuffer();
- }
-
- public void swapBuffers() throws GLException {
- // FIXME: do we need to do anything if the pbuffer is double-buffered?
- }
-
- public int getFloatingPointMode() {
- return GLPbuffer.APPLE_FLOAT;
- }
-
- private int getNextPowerOf2(int number) {
- if (((number-1) & number) == 0) {
- //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0
- return number;
- }
- int power = 0;
- while (number > 0) {
- number = number>>1;
- power++;
- }
- return (1<<power);
- }
-
- protected boolean create() {
- if (capabilities.getOffscreenFloatingPointBuffers() &&
- !isTigerOrLater) {
- throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
- }
- if (!super.create(true, capabilities.getOffscreenFloatingPointBuffers())) {
- return false;
- }
- created = true;
- // Must now associate the pbuffer with our newly-created context
- CGL.setContextPBuffer(nsContext, pBuffer);
- return true;
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/BuildMipmap.java b/src/net/java/games/jogl/impl/mipmap/BuildMipmap.java
deleted file mode 100644
index 9c9c3122b..000000000
--- a/src/net/java/games/jogl/impl/mipmap/BuildMipmap.java
+++ /dev/null
@@ -1,1576 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.GLU;
-import net.java.games.jogl.impl.Debug;
-import java.nio.*;
-import java.io.*;
-
-/**
- *
- * @author Administrator
- */
-public class BuildMipmap {
-
- private static boolean DEBUG = Debug.debug("BuildMipmap");
-
- /** Creates a new instance of BuildMipmap */
- public BuildMipmap() {
- }
-
- public static int gluBuild1DMipmapLevelsCore( GL gl, int target, int internalFormat,
- int width, int widthPowerOf2, int format, int type, int userLevel,
- int baseLevel, int maxLevel, ByteBuffer data ) {
- int newwidth;
- int level, levels;
- ShortBuffer newImage = null;
- int newImage_width;
- ShortBuffer otherImage = null;
- ShortBuffer imageTemp = null;
- int memreq;
- int maxsize;
- int cmpts;
- PixelStorageModes psm = new PixelStorageModes();
-
- assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 );
- assert( width >= 1 );
-
- newwidth = widthPowerOf2;
- levels = Mipmap.computeLog( newwidth );
-
- levels += userLevel;
-
- Mipmap.retrieveStoreModes( gl, psm );
- try {
- newImage = ByteBuffer.allocateDirect( Mipmap.image_size( width, 1, format,
- GL.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ).asShortBuffer();
- } catch( OutOfMemoryError ome ) {
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- newImage_width = width;
-
- Image.fill_image( psm, width, 1, format, type, Mipmap.is_index( format ), data, newImage );
- cmpts = Mipmap.elements_per_group( format, type );
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, 2 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, 0 );
-
- // if swap_bytes was set, swapping occurred in fill_image
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE );
-
- for( level = userLevel; level <= levels; level++ ) {
- if( newImage_width == newwidth ) {
- // user newimage for this level
- if( baseLevel <= level && level <= maxLevel ) {
- gl.glTexImage1D( target, level, internalFormat, newImage_width, 0, format,
- GL.GL_UNSIGNED_SHORT, newImage );
- }
- } else {
- if( otherImage == null ) {
- memreq = Mipmap.image_size( newwidth, 1, format, GL.GL_UNSIGNED_SHORT );
- try {
- otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ).asShortBuffer();
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- }
- ScaleInternal.scale_internal( cmpts, newImage_width, 1, newImage, newwidth, 1, otherImage );
- // swap newImage and otherImage
- imageTemp = otherImage;
- otherImage = newImage;
- newImage = imageTemp;
-
- newImage_width = newwidth;
- if( baseLevel <= level && level <= maxLevel ) {
- gl.glTexImage1D( target, level, internalFormat, newImage_width, 0,
- format, GL.GL_UNSIGNED_SHORT, newImage );
- }
- }
- if( newwidth > 1 ) {
- newwidth /= 2;
- }
- }
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
-
- return( 0 );
- }
-
- public static int bitmapBuild2DMipmaps( GL gl, int target, int internalFormat,
- int width, int height, int format, int type, ByteBuffer data ) {
- int newwidth[] = new int[1];
- int newheight[] = new int[1];
- int level, levels;
- ShortBuffer newImage = null;
- int newImage_width;
- int newImage_height;
- ShortBuffer otherImage = null;
- ShortBuffer tempImage = null;
- int memreq;
- int maxsize;
- int cmpts;
- PixelStorageModes psm = new PixelStorageModes();
-
- Mipmap.retrieveStoreModes( gl, psm );
-
- Mipmap.closestFit( gl, target, width, height, internalFormat, format, type, newwidth, newheight );
-
- levels = Mipmap.computeLog( newwidth[0] );
- level = Mipmap.computeLog( newheight[0] );
- if( level > levels ) {
- levels = level;
- }
-
- try {
- newImage = ByteBuffer.allocateDirect( Mipmap.image_size( width, height,
- format, GL.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() ).asShortBuffer();
- } catch( OutOfMemoryError ome ) {
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- newImage_width = width;
- newImage_height = height;
-
- Image.fill_image( psm, width, height, format, type, Mipmap.is_index( format ), data, newImage );
-
- cmpts = Mipmap.elements_per_group( format, type );
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, 2 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, 0 );
-
- // if swap_bytes is set, swapping occurred in fill_image
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE );
-
- for( level = 0; level < levels; level++ ) {
- if( newImage_width == newwidth[0] && newImage_height == newheight[0] ) {
- gl.glTexImage2D( target, level, internalFormat, newImage_width,
- newImage_height, 0, format, GL.GL_UNSIGNED_SHORT, newImage );
- } else {
- if( otherImage == null ) {
- memreq = Mipmap.image_size( newwidth[0], newheight[0], format, GL.GL_UNSIGNED_SHORT );
- try {
- otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() ).asShortBuffer();
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- }
- ScaleInternal.scale_internal( cmpts, newImage_width, newImage_height,
- newImage, newwidth[0], newheight[0], otherImage );
- // swap newImage and otherImage
- tempImage = otherImage;
- otherImage = newImage;
- newImage = tempImage;
-
- newImage_width = newwidth[0];
- newImage_height = newheight[0];
- gl.glTexImage2D( target, level, internalFormat, newImage_width, newImage_height,
- 0, format, GL.GL_UNSIGNED_SHORT, newImage );
- }
- if( newheight[0] > 1 ) {
- newwidth[0] /= 2;
- }
- if( newheight[0] > 1 ) {
- newheight[0] /= 2;
- }
- }
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
-
- return( 0 );
- }
-
- public static int gluBuild2DMipmapLevelsCore( GL gl, int target, int internalFormat,
- int width, int height, int widthPowerOf2, int heightPowerOf2,
- int format, int type, int userLevel, int baseLevel, int maxLevel,
- ByteBuffer data ) { // PointerWrapper data
- int newwidth;
- int newheight;
- int level, levels;
- int usersImage;
- ByteBuffer srcImage = null;
- ByteBuffer dstImage = null;
- ByteBuffer tempImage = null;
- int newImage_width;
- int newImage_height;
- short[] SWAP_IMAGE = null;
- int memreq;
- int maxsize;
- int cmpts;
-
- boolean myswap_bytes;
- int groups_per_line, element_size, group_size;
- int rowsize, padding;
- PixelStorageModes psm = new PixelStorageModes();
-
- assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 );
- assert( width >= 1 && height >= 1 );
-
- if( type == GL.GL_BITMAP ) {
- return( bitmapBuild2DMipmaps( gl, target, internalFormat, width, height, format, type, data ) );
- }
-
- newwidth = widthPowerOf2;
- newheight = heightPowerOf2;
- levels = Mipmap.computeLog( newwidth );
- level = Mipmap.computeLog( newheight );
- if( level > levels ) {
- levels = level;
- }
-
- levels += userLevel;
-
- Mipmap.retrieveStoreModes( gl, psm );
- myswap_bytes = psm.getUnpackSwapBytes();
- cmpts = Mipmap.elements_per_group( format, type );
- if( psm.getUnpackRowLength() > 0 ) {
- groups_per_line = psm.getUnpackRowLength();
- } else {
- groups_per_line = width;
- }
-
- element_size = Mipmap.bytes_per_element( type );
- group_size = element_size * cmpts;
- if( element_size == 1 ) {
- myswap_bytes = false;
- }
-
- rowsize = groups_per_line * group_size;
- padding = ( rowsize % psm.getUnpackAlignment() );
- if( padding != 0 ) {
- rowsize += psm.getUnpackAlignment() - padding;
- }
-
- data.position( psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size );
- data.mark();
-
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, 0 );
-
- level = userLevel;
-
- // already power of two square
- if( width == newwidth && height == newheight ) {
- // use usersImage for level userLevel
- if( baseLevel <= level && level <= maxLevel ) {
- gl.glTexImage2D( target, level, internalFormat, width, height, 0, format, type, data );
- }
- if( levels == 0 ) { /* we're done. clean up and return */
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( 0 );
- }
- int nextWidth = newwidth / 2;
- int nextHeight = newheight / 2;
-
- // clamp to 1
- if( nextWidth < 1 ) {
- nextWidth = 1;
- }
- if( nextHeight < 1 ) {
- nextHeight = 1;
- }
- memreq = Mipmap.image_size( nextWidth, nextHeight, format, type );
-
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- if( dstImage != null ) {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- HalveImage.halveImage_ubyte( cmpts, width, height, data, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_BYTE ):
- HalveImage.halveImage_byte( cmpts, width, height, data, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- HalveImage.halveImage_ushort( cmpts, width, height, data, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_SHORT ):
- HalveImage.halveImage_short( cmpts, width, height, data, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT ):
- HalveImage.halveImage_uint( cmpts, width, height, data, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_INT ):
- HalveImage.halveImage_int( cmpts, width, height, data, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_FLOAT ):
- HalveImage.halveImage_float( cmpts, width, height, data, dstImage.asFloatBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel( 3, new Extract332(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel( 3, new Extract233rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- HalveImage.halveImagePackedPixel( 3, new Extract565(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- HalveImage.halveImagePackedPixel( 3, new Extract565rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- HalveImage.halveImagePackedPixel( 4, new Extract4444(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract4444rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- HalveImage.halveImagePackedPixel( 4, new Extract5551(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract1555rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- HalveImage.halveImagePackedPixel( 4, new Extract8888(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract8888rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- HalveImage.halveImagePackedPixel( 4, new Extract1010102(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract2101010rev(), width, height, data, dstImage, element_size, rowsize, myswap_bytes );
- break;
- default:
- assert( false );
- break;
- }
- }
- newwidth = width / 2;
- newheight = height / 2;
- // clamp to 1
- if( newwidth < 1 ) {
- newwidth = 1;
- }
- if( newheight < 1 ) {
- newheight = 1;
- }
-
- myswap_bytes = false;
- rowsize = newwidth * group_size;
- memreq = Mipmap.image_size( newwidth, newheight, format, type );
- // swap srcImage and dstImage
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- // level userLevel+1 is in srcImage; level userLevel already saved
- level = userLevel + 1;
- } else { // user's image is not nice powerof2 size square
- memreq = Mipmap.image_size( newwidth, newheight, format, type );
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- data.reset();
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- ScaleInternal.scale_internal_ubyte( cmpts, width, height, data,
- newwidth, newheight, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_BYTE ):
- ScaleInternal.scale_internal_byte( cmpts, width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- ScaleInternal.scale_internal_ushort( cmpts, width, height, data, newwidth,
- newheight, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_SHORT ):
- ScaleInternal.scale_internal_ushort( cmpts, width, height, data, newwidth,
- newheight, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT ):
- ScaleInternal.scale_internal_uint( cmpts, width, height, data, newwidth,
- newheight, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_INT ):
- ScaleInternal.scale_internal_int( cmpts, width, height, data, newwidth,
- newheight, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_FLOAT ):
- ScaleInternal.scale_internal_float( cmpts, width, height, data, newwidth,
- newheight, dstImage.asFloatBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- ScaleInternal.scaleInternalPackedPixel( 3, new Extract332(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- ScaleInternal.scaleInternalPackedPixel( 3, new Extract233rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- ScaleInternal.scaleInternalPackedPixel( 3, new Extract565(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- ScaleInternal.scaleInternalPackedPixel( 3, new Extract565rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract4444(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract4444rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract5551(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract1555rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract8888(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract8888rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract1010102(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- ScaleInternal.scaleInternalPackedPixel( 4, new Extract2101010rev(), width, height, data, newwidth,
- newheight, dstImage, element_size, rowsize, myswap_bytes );
- break;
- default:
- assert( false );
- break;
- }
- myswap_bytes = false;
- rowsize = newwidth * group_size;
- // swap dstImage and srcImage
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
-
- if( levels != 0 ) { // use as little memory as possible
- int nextWidth = newwidth / 2;
- int nextHeight = newheight / 2;
- if( nextWidth < 1 ) {
- nextWidth = 1;
- }
- if( nextHeight < 1 ) {
- nextHeight = 1;
- }
-
- memreq = Mipmap.image_size( nextWidth, nextHeight, format, type );
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- }
- // level userLevel is in srcImage; nothing saved yet
- level = userLevel;
- }
-
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE );
- if( baseLevel <= level && level <= maxLevel ) {
- srcImage.rewind();
- if (DEBUG) {
- System.err.println("GL Error(" + level + "): " + gl.glGetError() );
- }
- gl.glTexImage2D( target, level, internalFormat, newwidth, newheight, 0, format, type, srcImage );
- if (DEBUG) {
- System.err.println("GL Error(" + level + "): " + gl.glGetError() );
- try {
- File file = new File( "glu2DMipmapJ" + level + ".bin" );
- FileOutputStream fos = new FileOutputStream( file );
- srcImage.limit( Mipmap.image_size( newwidth, newheight, format, type ) );
- fos.getChannel().write( srcImage );
- srcImage.clear();
- fos.close();
- } catch( IOException e ) {
- System.err.println("IOException");
- System.err.println(e.getMessage());
- }
- }
- }
-
- level++; // update current level for the loop
- for( ; level <= levels; level++ ) {
- srcImage.rewind();
- dstImage.rewind();
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- HalveImage.halveImage_ubyte( cmpts, newwidth, newheight, srcImage, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_BYTE ):
- HalveImage.halveImage_byte( cmpts, newwidth, newheight, srcImage, dstImage, element_size, rowsize, group_size );
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- HalveImage.halveImage_ushort( cmpts, newwidth, newheight, srcImage, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_SHORT ):
- HalveImage.halveImage_short( cmpts, newwidth, newheight, srcImage, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT ):
- HalveImage.halveImage_uint( cmpts, newwidth, newheight, srcImage, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_INT ):
- HalveImage.halveImage_int( cmpts, newwidth, newheight, srcImage, dstImage.asIntBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_FLOAT ):
- HalveImage.halveImage_float( cmpts, newwidth, newheight, srcImage, dstImage.asFloatBuffer(), element_size, rowsize, group_size, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel( 3, new Extract332(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel( 3, new Extract233rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- HalveImage.halveImagePackedPixel( 3, new Extract565(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- HalveImage.halveImagePackedPixel( 3, new Extract565rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- HalveImage.halveImagePackedPixel( 4, new Extract4444(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract4444rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- HalveImage.halveImagePackedPixel( 4, new Extract5551(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract1555rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- HalveImage.halveImagePackedPixel( 4, new Extract8888(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract8888rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- HalveImage.halveImagePackedPixel( 4, new Extract1010102(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- HalveImage.halveImagePackedPixel( 4, new Extract2101010rev(), newwidth, newheight, srcImage, dstImage, element_size, rowsize, myswap_bytes );
- break;
- default:
- assert( false );
- break;
- }
-
- // swap dstImage and srcImage
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
-
- if( newwidth > 1 ) {
- newwidth /= 2;
- rowsize /= 2;
- }
- if( newheight > 1 ) {
- newheight /= 2;
- }
- // compute amount to pad per row if any
- int rowPad = rowsize % psm.getUnpackAlignment();
-
- // should row be padded
- if( rowPad == 0 ) {
- // call teximage with srcImage untouched since its not padded
- if( baseLevel <= level && level <= maxLevel ) {
- srcImage.rewind();
- gl.glTexImage2D( target, level, internalFormat, newwidth, newheight, 0, format, type, srcImage );
- if (DEBUG) {
- System.err.println("GL Error(" + level + "): " + gl.glGetError() );
- try {
- File file = new File( "glu2DMipmapJ" + level + ".bin" );
- FileOutputStream fos = new FileOutputStream( file );
- srcImage.limit( Mipmap.image_size( newwidth, newheight, format, type ) );
- fos.getChannel().write( srcImage );
- srcImage.clear();
- } catch( IOException e ) {
- System.err.println("IOException");
- System.err.println(e.getMessage());
- }
- }
- }
- } else {
- // compute length of new row in bytes, including padding
- int newRowLength = rowsize + psm.getUnpackAlignment() - rowPad;
- int ii, jj;
- int dstTrav;
- int srcTrav;
-
- // allocate new image for mipmap of size newRowLength x newheight
- ByteBuffer newMipmapImage = null;
- try {
- newMipmapImage = ByteBuffer.allocateDirect( newRowLength * newheight );
- } catch( OutOfMemoryError ome ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- srcImage.rewind();
- // copy image from srcImage into newMipmapImage by rows
- for( ii = 0; ii < newheight; ii++ ) {
- for( jj = 0; jj < rowsize; jj++ ) {
- newMipmapImage.put( srcImage.get() );
- }
- if( jj < rowsize - 1 ) {
- newMipmapImage.position( newMipmapImage.position() + rowPad );
- }
- }
-
- // and use this new image for mipmapping instead
- if( baseLevel <= level && level <= maxLevel ) {
- newMipmapImage.rewind();
- gl.glTexImage2D( target, level, internalFormat, newwidth, newheight, 0, format, type, newMipmapImage );
- if (DEBUG) {
- System.err.println("GL Error: " + gl.glGetError() );
- try {
- File file = new File( "glu2DMipmapJ" + level + ".bin" );
- FileOutputStream fos = new FileOutputStream( file );
- srcImage.limit( Mipmap.image_size( newwidth, newheight, format, type ) );
- fos.getChannel().write( newMipmapImage );
- srcImage.clear();
- } catch( IOException e ) {
- System.err.println("IOException");
- System.err.println(e.getMessage());
- }
- }
- }
- }
- }
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) );
-
- return( 0 );
- }
-
- public static int fastBuild2DMipmaps( GL gl, PixelStorageModes psm, int target,
- int components, int width, int height, int format, int type, ByteBuffer data ) {
- int[] newwidth = new int[1];
- int[] newheight = new int[1];
- int level, levels;
- ByteBuffer newImage;
- int newImage_width;
- int newImage_height;
- ByteBuffer otherImage;
- ByteBuffer imageTemp;
- int memreq;
- int maxsize;
- int cmpts;
-
- Mipmap.closestFit( gl, target, width, height, components, format, type, newwidth,
- newheight );
-
- levels = Mipmap.computeLog( newwidth[0] );
- level = Mipmap.computeLog( newheight[0] );
- if( level > levels ) {
- levels = level;
- }
-
- cmpts = Mipmap.elements_per_group( format, type );
-
- otherImage = null;
- // No need to copy the user data if its packed correctly.
- // Make sure that later routines don't change that data.
-
- if( psm.getUnpackSkipRows() == 0 && psm.getUnpackSkipPixels() == 0 ) {
- newImage = data;
- newImage_width = width;
- newImage_height = height;
- } else {
- int rowsize;
- int group_per_line;
- int elements_per_line;
- int start;
- int iter;
- int iter2;
- int i, j;
-
- try {
- newImage = ByteBuffer.allocateDirect( Mipmap.image_size(
- width, height, format, GL.GL_UNSIGNED_BYTE ) ).order( ByteOrder.nativeOrder() );
- } catch( OutOfMemoryError err ) {
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- newImage_width = width;
- newImage_height = height;
-
- // Abbreviated version of fill_image for the restricted case.
- if( psm.getUnpackRowLength() > 0 ) {
- group_per_line = psm.getUnpackRowLength();
- } else {
- group_per_line = width;
- }
- rowsize = group_per_line * cmpts;
- elements_per_line = width * cmpts;
- start = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * cmpts;
-
- for( i = 0; i < height; i++ ) {
- iter = start;
- data.position( iter );
- for( j = 0; j < elements_per_line; j++ ) {
- newImage.put( data.get() );
- }
- start += rowsize;
- }
- }
-
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, 1 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE );
-
- for( level = 0; level <= levels; level++ ) {
- if( newImage_width == newwidth[0] && newImage_height == newheight[0] ) {
- // use newImage for this level
- gl.glTexImage2D( target, level, components, newImage_width, newImage_height,
- 0, format, GL.GL_UNSIGNED_BYTE, newImage );
- } else {
- if( otherImage == null ) {
- memreq = Mipmap.image_size( newwidth[0], newheight[0], format, GL.GL_UNSIGNED_BYTE );
- try {
- otherImage = ByteBuffer.allocateDirect( memreq ).order( ByteOrder.nativeOrder() );
- } catch( OutOfMemoryError err ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, ( psm.getUnpackSwapBytes() ? 1 : 0 ) ) ;
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- }
- // swap newImage and otherImage
- imageTemp = otherImage;
- otherImage = newImage;
- newImage = imageTemp;
-
- newImage_width = newwidth[0];
- newImage_height = newheight[0];
- gl.glTexImage2D( target, level, components, newImage_width, newImage_height,
- 0, format, GL.GL_UNSIGNED_BYTE, newImage );
- }
- if( newwidth[0] > 1 ) {
- newwidth[0] /= 2;
- }
- if( newheight[0] > 1 ) {
- newheight[0] /= 2;
- }
- }
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, ( psm.getUnpackSwapBytes() ? 1 : 0 ) ) ;
-
- return( 0 );
- }
-
- public static int gluBuild3DMipmapLevelsCore( GL gl, int target, int internalFormat,
- int width, int height, int depth, int widthPowerOf2, int heightPowerOf2,
- int depthPowerOf2, int format, int type, int userLevel, int baseLevel,
- int maxLevel, ByteBuffer data ) {
- int newWidth;
- int newHeight;
- int newDepth;
- int level, levels;
- ByteBuffer usersImage;
- ByteBuffer srcImage, dstImage, tempImage;
- int newImageWidth;
- int newImageHeight;
- int newImageDepth;
- int memReq;
- int maxSize;
- int cmpts;
-
- boolean myswapBytes;
- int groupsPerLine, elementSize, groupSize;
- int rowsPerImage, imageSize;
- int rowSize, padding;
- PixelStorageModes psm = new PixelStorageModes();
-
- assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 );
- assert( width >= 1 && height >= 1 && depth >= 1 );
- assert( type != GL.GL_BITMAP );
-
- srcImage = dstImage = null;
-
- newWidth = widthPowerOf2;
- newHeight = heightPowerOf2;
- newDepth = depthPowerOf2;
- levels = Mipmap.computeLog( newWidth );
- level = Mipmap.computeLog( newHeight );
- if( level > levels ) {
- levels = level;
- }
- level = Mipmap.computeLog( newDepth );
- if( level > levels ) {
- levels = level;
- }
-
- levels += userLevel;
-
- Mipmap.retrieveStoreModes3D( gl, psm );
- myswapBytes = psm.getUnpackSwapBytes();
- cmpts = Mipmap.elements_per_group( format, type );
- if( psm.getUnpackRowLength() > 0 ) {
- groupsPerLine = psm.getUnpackRowLength();
- } else {
- groupsPerLine = width;
- }
-
- elementSize = Mipmap.bytes_per_element( type );
- groupSize = elementSize * cmpts;
- if( elementSize == 1 ) {
- myswapBytes = false;
- }
-
- // 3dstuff
- if( psm.getUnpackImageHeight() > 0 ) {
- rowsPerImage = psm.getUnpackImageHeight();
- } else {
- rowsPerImage = height;
- }
-
- rowSize = groupsPerLine * groupSize;
- padding = ( rowSize % psm.getUnpackAlignment() );
- if( padding != 0 ) {
- rowSize += psm.getUnpackAlignment() - padding;
- }
-
- imageSize = rowsPerImage * rowSize;
-
- usersImage = data.duplicate();
- usersImage.position( psm.getUnpackSkipRows() * rowSize +
- psm.getUnpackSkipPixels() * groupSize +
- psm.getUnpackSkipImages() * imageSize );
- usersImage.mark();
-
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, 0 );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, 0 );
-
- level = userLevel;
-
- if( width == newWidth && height == newHeight && depth == newDepth ) {
- // use usersImage for level userlevel
- if( baseLevel <= level && level <= maxLevel ) {
- gl.glTexImage3D( target, level, internalFormat, width, height, depth,
- 0, format, type, usersImage );
- }
- if( levels == 0 ) { /* we're done. clean up and return */
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( 0 );
- }
- int nextWidth = newWidth / 2;
- int nextHeight = newHeight / 2;
- int nextDepth = newDepth / 2;
-
- // clamp to one
- if( nextWidth < 1 ) {
- nextWidth = 1;
- }
- if( nextHeight < 1 ) {
- nextHeight = 1;
- }
- if( nextDepth < 1 ) {
- nextDepth = 1;
- }
- memReq = Mipmap.imageSize3D( nextWidth, nextHeight, nextDepth, format, type );
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError err ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
-
- if( dstImage != null ) {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUByte(), width, height, depth,
- usersImage, dstImage, elementSize,
- groupSize, rowSize, imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_ubyte( cmpts, width, height, usersImage,
- dstImage, elementSize, rowSize, groupSize );
- }
- break;
- case( GL.GL_BYTE ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSByte(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_byte( cmpts, width, height, usersImage,
- dstImage, elementSize, rowSize, groupSize );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUShort(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_ushort( cmpts, width, height, usersImage,
- dstImage.asShortBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_SHORT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSShort(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_short( cmpts, width, height, usersImage,
- dstImage.asShortBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_UNSIGNED_INT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUInt(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_uint( cmpts, width, height, usersImage,
- dstImage.asIntBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_INT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSInt(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_int( cmpts, width, height, usersImage,
- dstImage.asIntBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_FLOAT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractFloat(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_float( cmpts, width, height, usersImage,
- dstImage.asFloatBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel3D( 3, new Extract332(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- assert( format == GL.GL_RGB );
- HalveImage.halveImagePackedPixel3D( 3, new Extract233rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract565(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract565rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract4444(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract4444rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract5551(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract1555rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract8888(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract8888rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract1010102(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract2101010rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- default:
- assert( false );
- break;
- }
- }
- newWidth = width / 2;
- newHeight = height / 2;
- newDepth = depth / 2;
- // clamp to 1
- if( newWidth < 1 ) {
- newWidth = 1;
- }
- if( newHeight < 1 ) {
- newHeight = 1;
- }
- if( newDepth < 1 ) {
- newDepth = 1;
- }
-
- myswapBytes = false;
- rowSize = newWidth * groupSize;
- imageSize = rowSize * newHeight;
- memReq = Mipmap.imageSize3D( newWidth, newHeight, newDepth, format, type );
- // swap srcImage and dstImage
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError err ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
-
- // level userLevel + 1 is in srcImage; level userLevel already saved
- level = userLevel + 1;
- } else {
- memReq = Mipmap.imageSize3D( newWidth, newHeight, newDepth, format, type );
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError err ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
-
- ScaleInternal.gluScaleImage3D( gl, format, width, height, depth, type,
- usersImage, newWidth, newHeight, newDepth, type, dstImage );
-
- myswapBytes = false;
- rowSize = newWidth * groupSize;
- imageSize = rowSize * newHeight;
- // swap dstImage and srcImage
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
-
- if( levels != 0 ) {
- int nextWidth = newWidth / 2;
- int nextHeight = newHeight / 2;
- int nextDepth = newDepth / 2;
- if( nextWidth < 1 ) {
- nextWidth = 1;
- }
- if( nextHeight < 1 ) {
- nextHeight = 1;
- }
- if( nextDepth < 1 ) {
- nextDepth = 1;
- }
- memReq = Mipmap.imageSize3D( nextWidth, nextHeight, nextDepth, format, type );
- try {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = ByteBuffer.allocateDirect( memReq ).order( ByteOrder.nativeOrder() );
- break;
- default:
- return( GLU.GLU_INVALID_ENUM );
- }
- } catch( OutOfMemoryError err ) {
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- }
- // level userLevel is in srcImage; nothing saved yet
- level = userLevel;
- }
-
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE );
- if( baseLevel <= level && level <= maxLevel ) {
- usersImage.reset();
- gl.glTexImage3D( target, level, internalFormat, width, height, depth,
- 0, format, type, usersImage );
- }
- level++;
- for( ; level <= levels; level++ ) {
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUByte(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_ubyte( cmpts, width, height, usersImage,
- dstImage, elementSize, rowSize, groupSize );
- }
- break;
- case( GL.GL_BYTE ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSByte(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_byte( cmpts, width, height, usersImage,
- dstImage, elementSize, rowSize, groupSize );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUShort(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_ushort( cmpts, width, height, usersImage,
- dstImage.asShortBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_SHORT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSShort(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_short( cmpts, width, height, usersImage,
- dstImage.asShortBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_UNSIGNED_INT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractUInt(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_uint( cmpts, width, height, usersImage,
- dstImage.asIntBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_INT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractSInt(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_int( cmpts, width, height, usersImage,
- dstImage.asIntBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_FLOAT ):
- if( depth > 1 ) {
- HalveImage.halveImage3D( cmpts, new ExtractFloat(), width, height, depth,
- usersImage, dstImage, elementSize, groupSize, rowSize,
- imageSize, myswapBytes );
- } else {
- HalveImage.halveImage_float( cmpts, width, height, usersImage,
- dstImage.asFloatBuffer(), elementSize, rowSize, groupSize, myswapBytes );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract332(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract233rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract565(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- HalveImage.halveImagePackedPixel3D( 3, new Extract565rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract4444(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract4444rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract5551(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract1555rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract8888(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract8888rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract1010102(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- HalveImage.halveImagePackedPixel3D( 4, new Extract2101010rev(), width, height, depth, usersImage,
- dstImage, elementSize, rowSize, imageSize, myswapBytes );
- break;
- default:
- assert( false );
- break;
- }
-
- tempImage = srcImage;
- srcImage = dstImage;
- dstImage = tempImage;
-
- if( newWidth > 1 ) {
- newWidth /= 2;
- rowSize /= 2;
- }
- if( newHeight > 1 ) {
- newHeight /= 2;
- imageSize = rowSize * newHeight;
- }
- if( newDepth > 1 ) {
- newDepth /= 2;
- }
- if( baseLevel <= level && level <= maxLevel ) {
- usersImage.reset();
- gl.glTexImage3D( target, level, internalFormat, width, height, depth,
- 0, format, type, usersImage );
- }
- }
- gl.glPixelStorei( GL.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() );
- gl.glPixelStorei( GL.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() );
- gl.glPixelStorei( GL.GL_UNPACK_SWAP_BYTES, psm.getUnpackSwapBytes() ? 1 : 0 );
- gl.glPixelStorei( GL.GL_UNPACK_SKIP_IMAGES, psm.getUnpackSkipImages() );
- gl.glPixelStorei( GL.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() );
- return( 0 );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract.java b/src/net/java/games/jogl/impl/mipmap/Extract.java
deleted file mode 100644
index c78bcd9ce..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public interface Extract {
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents );
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel );
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract1010102.java b/src/net/java/games/jogl/impl/mipmap/Extract1010102.java
deleted file mode 100644
index d6fcc5977..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract1010102.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Extract1010102 implements Extract {
-
- /** Creates a new instance of Extract1010102 */
- public Extract1010102() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- long uint = 0;
-
- if( isSwap ) {
- uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() );
- } else {
- uint = 0x00000000FFFFFFFF & packedPixel.getInt();
- }
-
- // 11111111,11000000,00000000,00000000 == 0xFFC00000
- // 00000000,00111111,11110000,00000000 == 0x003F0000
- // 00000000,00000000,00001111,11111100 == 0x00000FFC
- // 00000000,00000000,00000000,00000011 == 0x00000003
-
- extractComponents[0] = (float)( ( uint & 0xFFC00000 ) >> 22 ) / 1023.0f;
- extractComponents[1] = (float)( ( uint & 0x003FF000 ) >> 12 ) / 1023.0f;
- extractComponents[2] = (float)( ( uint & 0x00000FFC ) >> 2 ) / 1023.0f;
- extractComponents[3] = (float)( ( uint & 0x00000003 ) ) / 3.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- long uint = (((int)((shoveComponents[0] * 1023) + 0.5f) << 22) & 0xFFC00000 );
- uint |= (((int)((shoveComponents[1] * 1023) + 0.5f) << 12) & 0x003FF000 );
- uint |= (((int)((shoveComponents[2] * 1023) + 0.5f) << 2) & 0x00000FFC );
- uint |= (((int)((shoveComponents[3] * 3) + 0.5f) ) & 0x00000003 );
- packedPixel.asIntBuffer().put( index, (int)uint );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract1555rev.java b/src/net/java/games/jogl/impl/mipmap/Extract1555rev.java
deleted file mode 100644
index 10a132417..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract1555rev.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Extract1555rev implements Extract {
-
- /** Creates a new instance of Extract1555rev */
- public Extract1555rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 00000000,00011111 == 0x001F
- // 00000011,11100000 == 0x03E0
- // 01111100,00000000 == 0x7C00
- // 10000000,00000000 == 0x8000
-
- extractComponents[0] = (float)( ( ushort & 0x001F ) ) / 31.0f;
- extractComponents[1] = (float)( ( ushort & 0x003E ) >> 5 ) / 31.0f;
- extractComponents[2] = (float)( ( ushort & 0x7C00 ) >> 10) / 31.0f;
- extractComponents[3] = (float)( ( ushort & 0x8000 ) >> 15);
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 00000000,00011111 == 0x001F
- // 00000011,11100000 == 0x03E0
- // 01111100,00000000 == 0x7C00
- // 10000000,00000000 == 0x8000
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) ) & 0x0000001F );
- ushort |= (((int)((shoveComponents[1] * 31) + 0.5f) << 5) & 0x000003E0 );
- ushort |= (((int)((shoveComponents[2] * 31) + 0.5f) << 10) & 0x00007C00 );
- ushort |= (((int)((shoveComponents[3]) + 0.5f) << 15) & 0x00008000 );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract2101010rev.java b/src/net/java/games/jogl/impl/mipmap/Extract2101010rev.java
deleted file mode 100644
index 5d98f19a7..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract2101010rev.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Extract2101010rev implements Extract {
-
- /** Creates a new instance of Extract2101010 */
- public Extract2101010rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- long uint = 0;
-
- if( isSwap ) {
- uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() );
- } else {
- uint = 0x00000000FFFFFFFF & packedPixel.getInt();
- }
-
- // 11111111,11000000,00000000,00000000 == 0xFFC00000
- // 00000000,00111111,11110000,00000000 == 0x003F0000
- // 00000000,00000000,00001111,11111100 == 0x00000FFC
- // 00000000,00000000,00000000,00000011 == 0x00000003
-
- extractComponents[0] = (float)( ( uint & 0x000003FF ) ) / 1023.0f;
- extractComponents[1] = (float)( ( uint & 0x000FFC00 ) >> 10 ) / 1023.0f;
- extractComponents[2] = (float)( ( uint & 0x3FF00000 ) >> 20 ) / 1023.0f;
- extractComponents[3] = (float)( ( uint & 0xC0000000 ) >> 30 ) / 3.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- long uint = (((int)((shoveComponents[0] * 1023) + 0.5f) ) & 0x000003FF );
- uint |= (((int)((shoveComponents[1] * 1023) + 0.5f) << 10) & 0x000FFC00 );
- uint |= (((int)((shoveComponents[2] * 1023) + 0.5f) << 20) & 0x3FF00000 );
- uint |= (((int)((shoveComponents[3] * 3) + 0.5f) << 30) & 0xC0000000 );
- packedPixel.asIntBuffer().put( index, (int)uint );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract233rev.java b/src/net/java/games/jogl/impl/mipmap/Extract233rev.java
deleted file mode 100644
index 46d45cbcb..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract233rev.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Extract233rev implements Extract {
-
- /** Creates a new instance of Extract223rev */
- public Extract233rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- // 11100000 == 0xe0
- // 00011100 == 0x1c
- // 00000011 == 0x03
- byte ubyte = packedPixel.get();
- extractComponents[0] = (float)((ubyte & 0x07) ) / 7.0f;
- extractComponents[1] = (float)((ubyte & 0x38) >> 3) / 7.0f;
- extractComponents[2] = (float)((ubyte & 0xC0) >> 6) / 3.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11100000 == 0xE0
- // 00011100 == 0x1C
- // 00000011 == 0x03
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- byte b = (byte)( ( (int)( ( shoveComponents[0] * 7 ) + 0.5f ) ) & 0x07 );
- b |= (byte)( ( (int)( ( shoveComponents[1] * 7 ) + 0.5f ) << 3 ) & 0x38 );
- b |= (byte)( ( (int)( ( shoveComponents[2] * 3 ) + 0.5f ) << 6 ) & 0xC0 );
- packedPixel.position( index );
- packedPixel.put( b );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract332.java b/src/net/java/games/jogl/impl/mipmap/Extract332.java
deleted file mode 100644
index 6a3bcdc0a..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract332.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class Extract332 implements Extract {
-
- /** Creates a new instance of Extract332 */
- public Extract332() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- // 11100000 == 0xe0
- // 00011100 == 0x1c
- // 00000011 == 0x03
- byte ubyte = packedPixel.get();
- extractComponents[0] = (float)((ubyte & 0xe0) >> 5) / 7.0f;
- extractComponents[1] = (float)((ubyte & 0x1c) >> 2) / 7.0f;
- extractComponents[2] = (float)((ubyte & 0x03)) / 3.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11100000 == 0xE0
- // 00011100 == 0x1C
- // 00000011 == 0x03
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- byte b = (byte)( ( (int)( ( shoveComponents[0] * 7 ) + 0.5f ) << 5 ) & 0xE0 );
- b |= (byte)( ( (int)( ( shoveComponents[1] * 7 ) + 0.5f ) << 2 ) & 0x1C );
- b |= (byte)( ( (int)( ( shoveComponents[2] * 3 ) + 0.5f ) ) & 0x03 );
- packedPixel.put( index, b );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract4444.java b/src/net/java/games/jogl/impl/mipmap/Extract4444.java
deleted file mode 100644
index c2b5fc95f..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract4444.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract4444 implements Extract {
-
- /** Creates a new instance of Extract4444 */
- public Extract4444() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- extractComponents[0] = (float)( ( ushort & 0xF000 ) >> 12 ) / 15.0f;
- extractComponents[1] = (float)( ( ushort & 0x0F00 ) >> 8 ) / 15.0f;
- extractComponents[2] = (float)( ( ushort & 0x00F0 ) >> 4 ) / 15.0f;
- extractComponents[3] = (float)( ( ushort & 0x000F ) ) / 15.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 15) + 0.5f) << 12) & 0x0000F000 );
- ushort |= (((int)((shoveComponents[1] * 15) + 0.5f) << 8) & 0x00000F00 );
- ushort |= (((int)((shoveComponents[2] * 15) + 0.5f) << 4) & 0x000000F0 );
- ushort |= (((int)((shoveComponents[3] * 15) + 0.5f) ) & 0x0000000F );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract4444rev.java b/src/net/java/games/jogl/impl/mipmap/Extract4444rev.java
deleted file mode 100644
index e8adf3004..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract4444rev.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract4444rev implements Extract {
-
- /** Creates a new instance of Extract4444rev */
- public Extract4444rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 00000000,00001111 == 0x000F
- // 00000000,11110000 == 0x00F0
- // 00001111,00000000 == 0x0F00
- // 11110000,00000000 == 0xF000
-
- extractComponents[0] = (float)( ( ushort & 0x000F ) ) / 15.0f;
- extractComponents[1] = (float)( ( ushort & 0x00F0 ) >> 4 ) / 15.0f;
- extractComponents[2] = (float)( ( ushort & 0x0F00 ) >> 8 ) / 15.0f;
- extractComponents[3] = (float)( ( ushort & 0xF000 ) >> 12 ) / 15.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 15) + 0.5f) ) & 0x0000000F );
- ushort |= (((int)((shoveComponents[1] * 15) + 0.5f) << 4) & 0x000000F0 );
- ushort |= (((int)((shoveComponents[2] * 15) + 0.5f) << 8) & 0x00000F00 );
- ushort |= (((int)((shoveComponents[3] * 15) + 0.5f) << 12) & 0x0000F000 );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract5551.java b/src/net/java/games/jogl/impl/mipmap/Extract5551.java
deleted file mode 100644
index b7e3a027b..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract5551.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract5551 implements Extract {
-
- /** Creates a new instance of Extract5551 */
- public Extract5551() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 11111000,00000000 == 0xF800
- // 00000111,11000000 == 0x07C0
- // 00000000,00111110 == 0x003E
- // 00000000,00000001 == 0x0001
-
- extractComponents[0] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f;
- extractComponents[1] = (float)( ( ushort & 0x00F0 ) >> 6 ) / 31.0f;
- extractComponents[2] = (float)( ( ushort & 0x0F00 ) >> 1 ) / 31.0f;
- extractComponents[3] = (float)( ( ushort & 0xF000 ) );
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) << 11) & 0x0000F800 );
- ushort |= (((int)((shoveComponents[1] * 31) + 0.5f) << 6) & 0x000007C0 );
- ushort |= (((int)((shoveComponents[2] * 31) + 0.5f) << 1) & 0x0000003E );
- ushort |= (((int)((shoveComponents[3]) + 0.5f)) & 0x00000001 );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract565.java b/src/net/java/games/jogl/impl/mipmap/Extract565.java
deleted file mode 100644
index 43158bb6c..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract565.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract565 implements Extract {
-
- /** Creates a new instance of Extract565 */
- public Extract565() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 11111000,00000000 == 0xF800
- // 00000111,11100000 == 0x07E0
- // 00000000,00111111 == 0x001F
-
- extractComponents[0] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f;
- extractComponents[1] = (float)( ( ushort & 0x07E0 ) >> 5 ) / 63.0f;
- extractComponents[2] = (float)( ( ushort & 0x001F ) ) / 31.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11111000,00000000 == 0xF800
- // 00000111,11100000 == 0x07E0
- // 00000000,00111111 == 0x001F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) << 11) & 0x0000F800 );
- ushort |= (((int)((shoveComponents[1] * 63) + 0.5f) << 5) & 0x000007E0 );
- ushort |= (((int)((shoveComponents[2] * 31) + 0.5f) ) & 0x0000001F );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract565rev.java b/src/net/java/games/jogl/impl/mipmap/Extract565rev.java
deleted file mode 100644
index b6f3af966..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract565rev.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract565rev implements Extract {
-
- /** Creates a new instance of Extract565rev */
- public Extract565rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- int ushort = 0;
-
- if( isSwap ) {
- ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() );
- } else {
- ushort = 0x0000FFFF & packedPixel.getShort();
- }
-
- // 00000000,00011111 == 0x001F
- // 00000111,11100000 == 0x07E0
- // 11111000,00000000 == 0xF800
-
- extractComponents[0] = (float)( ( ushort & 0x001F ) ) / 31.0f;
- extractComponents[1] = (float)( ( ushort & 0x07E0 ) >> 5 ) / 63.0f;
- extractComponents[2] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 00000000,00111111 == 0x001F
- // 00000111,11100000 == 0x07E0
- // 11111000,00000000 == 0xF800
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) ) & 0x0000001F );
- ushort |= (((int)((shoveComponents[1] * 63) + 0.5f) << 5) & 0x000007E0 );
- ushort |= (((int)((shoveComponents[2] * 31) + 0.5f) << 11) & 0x0000F800 );
- packedPixel.asShortBuffer().put( index, (short)ushort );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract8888.java b/src/net/java/games/jogl/impl/mipmap/Extract8888.java
deleted file mode 100644
index c013fae28..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract8888.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract8888 implements Extract {
-
- /** Creates a new instance of Extract8888 */
- public Extract8888() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- long uint = 0;
-
- if( isSwap ) {
- uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() );
- } else {
- uint = 0x00000000FFFFFFFF & packedPixel.getInt();
- }
-
- // 11111000,00000000 == 0xF800
- // 00000111,11000000 == 0x07C0
- // 00000000,00111110 == 0x003E
- // 00000000,00000001 == 0x0001
-
- extractComponents[0] = (float)( ( uint & 0xFF000000 ) >> 24 ) / 255.0f;
- extractComponents[1] = (float)( ( uint & 0x00FF0000 ) >> 16 ) / 255.0f;
- extractComponents[2] = (float)( ( uint & 0x0000FF00 ) >> 8 ) / 255.0f;
- extractComponents[3] = (float)( ( uint & 0x000000FF ) ) / 255.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- long uint = (((int)((shoveComponents[0] * 255) + 0.5f) << 24) & 0xFF000000 );
- uint |= (((int)((shoveComponents[1] * 255) + 0.5f) << 16) & 0x00FF0000 );
- uint |= (((int)((shoveComponents[2] * 255) + 0.5f) << 8) & 0x0000FF00 );
- uint |= (((int)((shoveComponents[3] * 255) + 0.5f) ) & 0x000000FF );
- packedPixel.asIntBuffer().put( index, (int)uint );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Extract8888rev.java b/src/net/java/games/jogl/impl/mipmap/Extract8888rev.java
deleted file mode 100644
index 9104ed7b1..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Extract8888rev.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Extract8888rev implements Extract {
-
- /** Creates a new instance of Extract8888rev */
- public Extract8888rev() {
- }
-
- public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) {
- long uint = 0;
-
- if( isSwap ) {
- uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() );
- } else {
- uint = 0x00000000FFFFFFFF & packedPixel.getInt();
- }
-
- // 11111000,00000000 == 0xF800
- // 00000111,11000000 == 0x07C0
- // 00000000,00111110 == 0x003E
- // 00000000,00000001 == 0x0001
-
- extractComponents[0] = (float)( ( uint & 0x000000FF ) ) / 255.0f;
- extractComponents[1] = (float)( ( uint & 0x0000FF00 ) >> 8 ) / 255.0f;
- extractComponents[2] = (float)( ( uint & 0x00FF0000 ) >> 16 ) / 255.0f;
- extractComponents[3] = (float)( ( uint & 0xFF000000 ) >> 24 ) / 255.0f;
- }
-
- public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) {
- // 11110000,00000000 == 0xF000
- // 00001111,00000000 == 0x0F00
- // 00000000,11110000 == 0x00F0
- // 00000000,00001111 == 0x000F
-
- assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f );
- assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f );
- assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f );
- assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f );
-
- // due to limited precision, need to round before shoving
- long uint = (((int)((shoveComponents[0] * 255) + 0.5f) ) & 0x000000FF );
- uint |= (((int)((shoveComponents[1] * 255) + 0.5f) << 8) & 0x0000FF00 );
- uint |= (((int)((shoveComponents[2] * 255) + 0.5f) << 16) & 0x00FF0000 );
- uint |= (((int)((shoveComponents[3] * 255) + 0.5f) << 24) & 0xFF000000 );
- packedPixel.asIntBuffer().put( index, (int)uint );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractFloat.java b/src/net/java/games/jogl/impl/mipmap/ExtractFloat.java
deleted file mode 100644
index 3dad2de29..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractFloat.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractFloat implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractFloat */
- public ExtractFloat() {
- }
-
- public double extract( boolean isSwap, ByteBuffer data ) {
- float f = 0;
- if( isSwap ) {
- f = Mipmap.GLU_SWAP_4_BYTES( data.getInt() );
- } else {
- f = data.getInt();
- }
- assert( f <= 1.0f );
- return( f );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < 1.0);
- data.asFloatBuffer().put( index, (float)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractPrimitive.java b/src/net/java/games/jogl/impl/mipmap/ExtractPrimitive.java
deleted file mode 100644
index 242d8f331..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractPrimitive.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public interface ExtractPrimitive {
- public double extract( boolean isSwap, ByteBuffer pointer );
- public void shove( double value, int index, ByteBuffer pointer );
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractSByte.java b/src/net/java/games/jogl/impl/mipmap/ExtractSByte.java
deleted file mode 100644
index f925eb7bd..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractSByte.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractSByte implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractUByte */
- public ExtractSByte() {
- }
-
- public double extract( boolean isSwap, ByteBuffer sbyte ) {
- byte b = sbyte.get();
- assert( b <= 127 );
- return( b );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- data.position( index );
- data.put( (byte)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractSInt.java b/src/net/java/games/jogl/impl/mipmap/ExtractSInt.java
deleted file mode 100644
index c874c82f1..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractSInt.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractSInt implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractSInt */
- public ExtractSInt() {
- }
-
- public double extract( boolean isSwap, ByteBuffer uint ) {
- int i = 0;
- if( isSwap ) {
- i = Mipmap.GLU_SWAP_4_BYTES( uint.getInt() );
- } else {
- i = uint.getInt();
- }
- assert( i <= 0x7FFFFFFF );
- return( i );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < Integer.MAX_VALUE);
- IntBuffer ib = data.asIntBuffer();
- ib.position( index );
- ib.put( (int)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractSShort.java b/src/net/java/games/jogl/impl/mipmap/ExtractSShort.java
deleted file mode 100644
index 73a0f9c5e..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractSShort.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractSShort implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractSShort */
- public ExtractSShort() {
- }
-
- public double extract( boolean isSwap, ByteBuffer ushort ) {
- short s = 0;
- if( isSwap ) {
- s = Mipmap.GLU_SWAP_2_BYTES( ushort.getShort() );
- } else {
- s = ushort.getShort();
- }
- assert( s <= 32767 );
- return( s );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < 32768.0);
- ShortBuffer sb = data.asShortBuffer();
- sb.position( index );
- sb.put( (short)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractUByte.java b/src/net/java/games/jogl/impl/mipmap/ExtractUByte.java
deleted file mode 100644
index 031aa74ce..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractUByte.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractUByte implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractUByte */
- public ExtractUByte() {
- }
-
- public double extract( boolean isSwap, ByteBuffer ubyte ) {
- int i = 0x000000FF & ubyte.get();
- assert( i <= 255 );
- return( i );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < 256.0);
- data.position( index );
- data.put( (byte)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractUInt.java b/src/net/java/games/jogl/impl/mipmap/ExtractUInt.java
deleted file mode 100644
index b80afd41e..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractUInt.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractUInt implements ExtractPrimitive {
-
- /** Creates a new instance of ExtractUInt */
- public ExtractUInt() {
- }
-
- public double extract( boolean isSwap, ByteBuffer uint ) {
- long i = 0;
- if( isSwap ) {
- i = 0xFFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( uint.getInt() );
- } else {
- i = 0xFFFFFFFF & uint.getInt();
- }
- assert( i <= 0xFFFFFFFF );
- return( i );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < 0xFFFFFFFF);
- IntBuffer ib = data.asIntBuffer();
- ib.position( index );
- ib.put( (int)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ExtractUShort.java b/src/net/java/games/jogl/impl/mipmap/ExtractUShort.java
deleted file mode 100644
index 130f2c833..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ExtractUShort.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ExtractUShort implements ExtractPrimitive {
-
- /** Creates a new instance of ExtracUShort */
- public ExtractUShort() {
- }
-
- public double extract( boolean isSwap, ByteBuffer ushort ) {
- int i = 0;
- if( isSwap ) {
- i = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( ushort.getShort() );
- } else {
- i = 0x0000FFFF & ushort.getShort();
- }
- assert( i <= 65535 );
- return( i );
- }
-
- public void shove( double value, int index, ByteBuffer data ) {
- assert(0.0 <= value && value < 65536.0);
- ShortBuffer sb = data.asShortBuffer();
- sb.position( index );
- sb.put( (short)value );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/HalveImage.java b/src/net/java/games/jogl/impl/mipmap/HalveImage.java
deleted file mode 100644
index ea12577b9..000000000
--- a/src/net/java/games/jogl/impl/mipmap/HalveImage.java
+++ /dev/null
@@ -1,1523 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import net.java.games.jogl.GL;
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class HalveImage {
-
- private static final int BOX2 = 2;
- private static final int BOX4 = 4;
- private static final int BOX8 = 8;
-
- public static void halveImage( int components, int width, int height,
- ShortBuffer datain, ShortBuffer dataout ) {
- int i, j, k;
- int newwidth, newheight;
- int delta;
- int t = 0;
- short temp = 0;
-
- newwidth = width / 2;
- newheight = height /2;
- delta = width * components;
-
- // Piece of cake
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = datain.get();
- datain.position( t + components );
- temp += datain.get();
- datain.position( t + delta );
- temp += datain.get();
- datain.position( t + delta + components );
- temp +=datain.get();
- temp += 2;
- temp /= 4;
- dataout.put( temp );
- t++;
- }
- t += components;
- }
- t += delta;
- }
- }
-
- public static void halveImage_ubyte( int components, int width, int height,
- ByteBuffer datain, ByteBuffer dataout,
- int element_size, int ysize, int group_size ) {
- int i, j, k;
- int newwidth, newheight;
- int s;
- int t;
-
- // Handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_ubyte( components, width, height, datain, dataout, element_size, ysize, group_size );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
- s = 0;
- t = 0;
-
- int temp = 0;
- // piece of cake
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = ( 0x000000FF & datain.get() );
- datain.position( t + group_size );
- temp += ( 0x000000FF & datain.get() );
- datain.position( t + ysize );
- temp += ( 0x000000FF & datain.get() );
- datain.position( t + ysize + group_size );
- temp += ( 0x000000FF & datain.get() ) + 2;
- dataout.put( (byte)(temp / 4) );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
-
- public static void halve1Dimage_ubyte( int components, int width, int height,
- ByteBuffer datain, ByteBuffer dataout,
- int element_size, int ysize, int group_size ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
- int temp = 0;
-
- assert( width == 1 || height == 1 ); // Must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // widthxheight can't be 1x1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- datain.position( src );
- temp = ( 0x000000FF & datain.get() );
- datain.position( src + group_size );
- temp += ( 0x000000FF & datain.get() );
- temp /= 2;
- dataout.put( (byte)temp );
- /*
- dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
- (0x000000FF & datain.setIndexInBytes( src + group_size ).getByte())) / 2 ) );
- */
- src += element_size;
- //dataout.plusPlus();
- dest++;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) { // 1 column
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 );
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- datain.position( src );
- temp = ( 0x000000FF & datain.get() );
- datain.position( src + ysize );
- temp += ( 0x000000FF & datain.get() );
- temp /= 2;
- dataout.put( (byte)temp );
- /*
- dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) +
- (0x000000FF & datain.setIndexInBytes(src + ysize).getByte()) ) / 2 ) );
- */
- src += element_size;
- //dataout.plusPlus();
- dest++;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- }
- assert( src == ysize * height );
- assert( dest == components * element_size * halfWidth * halfHeight );
- }
-
- public static void halveImage_byte( int components, int width, int height,
- ByteBuffer datain, ByteBuffer dataout, int element_size,
- int ysize, int group_size ) {
- int i, j, k;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- byte temp = (byte)0;
-
- // handle case where there is only 1 column
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) );
- halve1Dimage_byte( components, width, height, datain, dataout, element_size,
- ysize, group_size );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = datain.get();
- datain.position( t + group_size );
- temp += datain.get();
- datain.position( t + ysize );
- temp += datain.get();
- datain.position( t + ysize + group_size );
- temp += datain.get();
- temp += 2;
- temp /= 4;
- dataout.put( temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
-
- public static void halve1Dimage_byte( int components, int width, int height,
- ByteBuffer datain, ByteBuffer dataout,
- int element_size, int ysize, int group_size ) {
- int halfWidth = width / 2;
- int halfHeight = width / 2;
- int src = 0;
- int dest = 0;
- int jj;
- byte temp = (byte)0;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // widthxheight can't be 1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- datain.position( src );
- temp = datain.get();
- datain.position( src + group_size );
- temp += datain.get();
- temp /= 2;
- dataout.put( temp );
- src += element_size;
- dest++;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assert only
- } else if( width == 1 ) { // 1 column
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 ); // widthxheight can't be 1
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- datain.position( src );
- temp = datain.get();
- datain.position( src + ysize );
- temp += datain.get();
- temp /= 2;
- src += element_size;
- dest++;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == components * element_size * halfWidth * halfHeight );
- }
-
- public static void halveImage_ushort( int components, int width, int height,
- ByteBuffer datain, ShortBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int i, j, k, l;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- int temp = 0;
- // handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_ushort( components, width, height, datain, dataout, element_size,
- ysize, group_size, myswap_bytes );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- // Piece of cake
- if( !myswap_bytes ) {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = ( 0x0000FFFF & datain.getShort() );
- datain.position( t + group_size );
- temp += ( 0x0000FFFF & datain.getShort() );
- datain.position( t + ysize );
- temp += ( 0x0000FFFF & datain.getShort() );
- datain.position( t + ysize + group_size );
- temp += ( 0x0000FFFF & datain.getShort() );
- dataout.put( (short)( ( temp + 2 ) / 4 ) );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- } else {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- datain.position( t + group_size );
- temp += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- datain.position( t + ysize );
- temp += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- datain.position( t + ysize + group_size );
- temp += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- dataout.put( (short)( ( temp + 2 ) / 4 ) );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
- }
-
- public static void halve1Dimage_ushort( int components, int width, int height,
- ByteBuffer datain, ShortBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // widthxheight can't be 1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < halfHeight; kk++ ) {
- int[] ushort = new int[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- ushort[0] = ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- datain.position( src + group_size );
- ushort[1] = (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- } else {
- datain.position( src );
- ushort[0] = (0x0000FFFF & datain.getShort() );
- datain.position( src + group_size );
- ushort[1] = (0x0000FFFF & datain.getShort() );
- }
- dataout.put( (short)( (ushort[0] + ushort[1]) / 2 ) );
- src += element_size;
- dest += 2;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) { // 1 column
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 ); // widthxheight can't be 1
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- int[] ushort = new int[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- ushort[0] = ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- datain.position( src + ysize );
- ushort[0] = ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ) );
- } else {
- datain.position( src );
- ushort[0] = ( 0x0000FFFF & datain.getShort() );
- datain.position( src + ysize );
- ushort[1] = ( 0x0000FFFF & datain.getShort() );
- }
- dataout.put( (short)((ushort[0] + ushort[1]) / 2) );
- src += element_size;
- dest += 2;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == components * element_size * halfWidth * halfHeight );
- }
-
- public static void halveImage_short( int components, int width, int height,
- ByteBuffer datain, ShortBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int i, j, k, l;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- short temp = (short)0;
- // handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_short( components, width, height, datain, dataout, element_size,
- ysize, group_size, myswap_bytes );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- // Piece of cake
- if( !myswap_bytes ) {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = datain.getShort();
- datain.position( t + group_size );
- temp += datain.getShort();
- datain.position( t + ysize );
- temp += datain.getShort();
- datain.position( t + ysize + group_size );
- temp += datain.getShort();
- temp += 2;
- temp /= 4;
- dataout.put( (short)temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- } else {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- short b;
- int buf;
- datain.position( t );
- temp = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- datain.position( t + group_size );
- temp += Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- datain.position( t + ysize );
- temp += Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- datain.position( t + ysize + group_size );
- temp += Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- temp += 2;
- temp /= 4;
- dataout.put( temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
- }
-
- public static void halve1Dimage_short( int components, int width, int height,
- ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // can't be 1x1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- short[] sshort = new short[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- sshort[0] = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- datain.position( src + group_size );
- sshort[1] = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- } else {
- datain.position( src );
- sshort[0] = datain.getShort();
- datain.position( src + group_size );
- sshort[1] = datain.getShort();
- }
- dataout.put( (short)(( sshort[0] + sshort[1] ) / 2) );
- src += element_size;
- dest += 2;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) {
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 );
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- short[] sshort = new short[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- sshort[0] = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- datain.position( src + ysize );
- sshort[1] = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- } else {
- datain.position( src );
- sshort[0] = datain.getShort();
- datain.position( src + ysize );
- sshort[1] = datain.getShort();
- }
- dataout.put( (short)(( sshort[0] + sshort[1] ) / 2) );
- src += element_size;
- dest += 2;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == ( components * element_size * halfWidth * halfHeight ) );
- }
-
- public static void halveImage_uint( int components, int width, int height,
- ByteBuffer datain, IntBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int i, j, k, l;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- double temp = 0;
-
- // handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_uint( components, width, height, datain, dataout, element_size,
- ysize, group_size, myswap_bytes );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- // Piece of cake
- if( !myswap_bytes ) {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = (0x000000007FFFFFFFL & datain.getInt() );
- datain.position( t + group_size );
- temp += (0x000000007FFFFFFFL & datain.getInt() );
- datain.position( t + ysize );
- temp += (0x000000007FFFFFFFL & datain.getInt() );
- datain.position( t + ysize + group_size );
- temp += (0x000000007FFFFFFFL & datain.getInt() );
- dataout.put( (int)( ( temp / 4 ) + 0.5 ) );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- } else {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- // need to cast to double to hold large unsigned ints
- double buf;
- datain.position( t );
- buf = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( t + group_size );
- buf += ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( t + ysize );
- buf += ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( t + ysize + group_size );
- buf += ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- temp /= 4;
- temp += 0.5;
- dataout.put( (int)temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
- }
-
- public static void halve1Dimage_uint( int components, int width, int height,
- ByteBuffer datain, IntBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // widthxheight can't be 1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < halfHeight; kk++ ) {
- long[] uint = new long[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( src + group_size );
- uint[1] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- } else {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & datain.getInt() );
- datain.position( src + group_size );
- uint[1] = (0x00000000FFFFFFFF & datain.getInt() );
- }
- dataout.put( (int)( ( uint[0] + uint[1] ) / 2.0 ) );
- src += element_size;
- dest += 4;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) { // 1 column
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 ); // widthxheight can't be 1
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- long[] uint = new long[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( src + group_size );
- uint[0] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- } else {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & datain.getInt() );
- datain.position( src + ysize );
- uint[1] = ( 0x00000000FFFFFFFF & datain.getInt() );
- }
- dataout.put( (int)( ( uint[0] + uint[1] ) / 2.0 ) );
- src += element_size;
- dest += 4;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == components * element_size * halfWidth * halfHeight );
- }
-
- public static void halveImage_int( int components, int width, int height,
- ByteBuffer datain, IntBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int i, j, k, l;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- int temp = 0;
-
- // handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_int( components, width, height, datain, dataout, element_size,
- ysize, group_size, myswap_bytes );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- // Piece of cake
- if( !myswap_bytes ) {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = datain.getInt();
- datain.position( t + group_size );
- temp += datain.getInt();
- datain.position( t + ysize );
- temp += datain.getInt();
- datain.position( t + ysize + group_size );
- temp += datain.getInt();
- temp = (int)( ( temp / 4.0f ) + 0.5f );
- dataout.put( temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- } else {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- long b;
- float buf;
- datain.position( t );
- b = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- buf = b;
- datain.position( t + group_size );
- b = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- buf += b;
- datain.position( t + ysize );
- b = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- buf += b;
- datain.position( t + ysize + group_size );
- b = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- buf += b;
- dataout.put( (int)( ( buf / 4.0f ) + 0.5f ) );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
- }
-
- public static void halve1Dimage_int( int components, int width, int height,
- ByteBuffer datain, IntBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // can't be 1x1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- long[] uint = new long[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( src + group_size );
- uint[1] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- } else {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & datain.getInt() );
- datain.position( src + group_size );
- uint[1] = ( 0x00000000FFFFFFFF & datain.getInt() );
- }
- dataout.put( (int)( ( (float)uint[0] + (float)uint[1] ) / 2.0f) );
- src += element_size;
- dest += 4;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) {
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 );
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- long[] uint = new long[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- datain.position( src + ysize );
- uint[1] = ( 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt() ) );
- } else {
- datain.position( src );
- uint[0] = ( 0x00000000FFFFFFFF & datain.getInt() );
- datain.position( src + ysize );
- uint[1] = ( 0x00000000FFFFFFFF & datain.getInt() );
- }
- dataout.put( (int)(( (float)uint[0] + (float)uint[1] ) / 2.0f) );
- src += element_size;
- dest += 4;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == ( components * element_size * halfWidth * halfHeight ) );
- }
-
- public static void halveImage_float( int components, int width, int height,
- ByteBuffer datain, FloatBuffer dataout, int element_size,
- int ysize, int group_size, boolean myswap_bytes ) {
- int i, j, k, l;
- int newwidth, newheight;
- int s = 0;
- int t = 0;
- float temp = 0.0f;
- // handle case where there is only 1 column/row
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) ); // can't be 1x1
- halve1Dimage_float( components, width, height, datain, dataout, element_size,
- ysize, group_size, myswap_bytes );
- return;
- }
-
- newwidth = width / 2;
- newheight = height / 2;
-
- // Piece of cake
- if( !myswap_bytes ) {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- datain.position( t );
- temp = datain.getFloat();
- datain.position( t + group_size );
- temp += datain.getFloat();
- datain.position( t + ysize );
- temp += datain.getFloat();
- datain.position( t + ysize + group_size );
- temp /= 4.0f;
- dataout.put( temp );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- } else {
- for( i = 0; i < newheight; i++ ) {
- for( j = 0; j < newwidth; j++ ) {
- for( k = 0; k < components; k++ ) {
- float buf;
- datain.position( t );
- buf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- datain.position( t + group_size );
- buf += Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- datain.position( t + ysize );
- buf += Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- datain.position( t + ysize + group_size );
- buf += Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- dataout.put( buf / 4.0f );
- t += element_size;
- }
- t += group_size;
- }
- t += ysize;
- }
- }
- }
-
- public static void halve1Dimage_float( int components, int width, int height,
- ByteBuffer datain, FloatBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int dest = 0;
- int jj;
-
- assert( width == 1 || height == 1 ); // must be 1D
- assert( width != height ); // can't be square
-
- if( height == 1 ) { // 1 row
- assert( width != 1 ); // can't be 1x1
- halfHeight = 1;
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- float[] sfloat = new float[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- sfloat[0] = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- datain.position( src + group_size );
- sfloat[1] = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- } else {
- datain.position( src );
- sfloat[0] = datain.getFloat();
- datain.position( src + group_size );
- sfloat[1] = datain.getFloat();
- }
- dataout.put( (sfloat[0] + sfloat[1]) / 2.0f );
- src += element_size;
- dest += 4;
- }
- src += group_size; // skip to next 2
- }
- int padBytes = ysize - ( width * group_size );
- src += padBytes; // for assertion only
- } else if( width == 1 ) {
- int padBytes = ysize - ( width * group_size );
- assert( height != 1 );
- halfWidth = 1;
- // one vertical column with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- int kk;
- for( kk = 0; kk < components; kk++ ) {
- float[] sfloat = new float[BOX2];
- if( myswap_bytes ) {
- datain.position( src );
- sfloat[0] = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- datain.position( src + ysize );
- sfloat[1] = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- } else {
- datain.position( src );
- sfloat[0] = datain.getFloat();
- datain.position( src + ysize );
- sfloat[1] = datain.getFloat();
- }
- dataout.put( ( sfloat[0] + sfloat[1] ) / 2.0f );
- src += element_size;
- dest += 4;
- }
- src += padBytes; // add pad bytes, if any, to get to end of row
- src += ysize;
- }
- assert( src == ysize * height );
- }
- assert( dest == ( components * element_size * halfWidth * halfHeight ) );
- }
-
- public static void halveImagePackedPixel( int components, Extract extract, int width,
- int height, ByteBuffer datain, ByteBuffer dataout,
- int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) {
- if( width == 1 || height == 1 ) {
- assert( !( width == 1 && height == 1 ) );
- halve1DimagePackedPixel( components, extract, width, height, datain, dataout,
- pixelSizeInBytes, rowSizeInBytes, isSwap );
- return;
- }
- int ii, jj;
-
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
- int outIndex = 0;
-
- for( ii = 0; ii < halfHeight; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- float totals[] = new float[4];
- float extractTotals[][] = new float[BOX4][4];
- int cc;
-
- datain.position( src );
- extract.extract( isSwap, datain, extractTotals[0] );
- datain.position( src + pixelSizeInBytes );
- extract.extract( isSwap, datain, extractTotals[1] );
- datain.position( src + rowSizeInBytes );
- extract.extract( isSwap, datain, extractTotals[2] );
- datain.position( src + rowSizeInBytes + pixelSizeInBytes );
- extract.extract( isSwap, datain, extractTotals[3] );
- for( cc = 0; cc < components; cc++ ) {
- int kk = 0;
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX4; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= BOX4;
- }
- extract.shove( totals, outIndex, dataout );
- outIndex++;
- src += pixelSizeInBytes + pixelSizeInBytes;
- }
- // skip past pad bytes, if any, to get to next row
- src += padBytes;
- src += rowSizeInBytes;
- }
- assert( src == rowSizeInBytes * height );
- assert( outIndex == halfWidth * halfHeight );
- }
-
- public static void halve1DimagePackedPixel( int components, Extract extract, int width,
- int height, ByteBuffer datain, ByteBuffer dataout,
- int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) {
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int src = 0;
- int jj;
-
- assert( width == 1 || height == 1 );
- assert( width != height );
-
- if( height == 1 ) {
- int outIndex = 0;
-
- assert( width != 1 );
- halfHeight = 1;
-
- // one horizontal row with possible pad bytes
-
- for( jj = 0; jj < halfWidth; jj++ ) {
- float[] totals = new float[4];
- float[][] extractTotals = new float[BOX2][4];
- int cc;
-
- datain.position( src );
- extract.extract( isSwap, datain, extractTotals[0] );
- datain.position( src + pixelSizeInBytes );
- extract.extract( isSwap, datain, extractTotals[1] );
- for( cc = 0; cc < components; cc++ ) {
- int kk = 0;
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX2; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= BOX2;
- }
- extract.shove( totals, outIndex, dataout );
- outIndex++;
- // skip over to next group of 2
- src += pixelSizeInBytes + pixelSizeInBytes;
- }
- int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
- src += padBytes;
-
- assert( src == rowSizeInBytes );
- assert( outIndex == halfWidth * halfHeight );
- } else if( width == 1 ) {
- int outIndex = 0;
-
- assert( height != 1 );
- halfWidth = 1;
- // one vertical volumn with possible pad bytes per row
- // average two at a time
-
- for( jj = 0; jj < halfHeight; jj++ ) {
- float[] totals = new float[4];
- float[][] extractTotals = new float[BOX2][4];
- int cc;
- // average two at a time, instead of four
- datain.position( src );
- extract.extract( isSwap, datain, extractTotals[0] );
- datain.position( src + rowSizeInBytes );
- extract.extract( isSwap, datain, extractTotals[1] );
- for( cc = 0; cc < components; cc++ ) {
- int kk = 0;
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX2; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= BOX2;
- }
- extract.shove( totals, outIndex, dataout );
- outIndex++;
- // skip over to next group of 2
- src += rowSizeInBytes + rowSizeInBytes;
- }
- assert( src == rowSizeInBytes );
- assert( outIndex == halfWidth * halfHeight );
- }
- }
-
- public static void halveImagePackedPixelSlice( int components, Extract extract,
- int width, int height, int depth, ByteBuffer dataIn,
- ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes,
- int imageSizeInBytes, boolean isSwap ) {
- int ii, jj;
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int halfDepth = depth / 2;
- int src = 0;
- int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
- int outIndex = 0;
-
- assert( (width == 1 || height == 1) && depth >= 2 );
-
- if( width == height ) {
- assert( width == 1 && height == 1 );
- assert( depth >= 2 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- float totals[] = new float[4];
- float extractTotals[][] = new float[BOX2][4];
- int cc;
-
- dataIn.position( src );
- extract.extract( isSwap, dataIn, extractTotals[0] );
- dataIn.position( src + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[1] );
-
- for( cc = 0; cc < components; cc++ ) {
- int kk;
-
- // average only 2 pixels since a column
- totals[cc]= 0.0f;
- for( kk = 0; kk < BOX2; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= BOX2;
- } // for cc
-
- extract.shove( totals, outIndex, dataOut );
- outIndex++;
- // skip over to next group of 2
- src += imageSizeInBytes + imageSizeInBytes;
- } // for ii
- } else if( height == 1 ) {
- assert( width != 1 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- float totals[] = new float[4];
- float extractTotals[][] = new float[BOX4][4];
- int cc;
-
- dataIn.position( src );
- extract.extract( isSwap, dataIn, extractTotals[0] );
- dataIn.position( src + pixelSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[1] );
- dataIn.position( src + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[2] );
- dataIn.position( src + pixelSizeInBytes + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[3] );
-
- for( cc = 0; cc < components; cc++ ) {
- int kk;
-
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX4; kk++ ) {
- totals[cc]+= extractTotals[kk][cc];
- }
- totals[cc]/= (float)BOX4;
- }
- extract.shove( totals, outIndex, dataOut );
- outIndex++;
- // skip over to next horizontal square of 4
- src += imageSizeInBytes + imageSizeInBytes;
- }
- }
- } else if( width == 1 ) {
- assert( height != 1 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- float totals[] = new float[4];
- float extractTotals[][] = new float[BOX4][4];
- int cc;
-
- dataIn.position( src );
- extract.extract( isSwap, dataIn, extractTotals[0] );
- dataIn.position( src + rowSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[1] );
- dataIn.position( src + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[2] );
- dataIn.position( src + rowSizeInBytes + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[3] );
-
- for( cc = 0; cc < components; cc++ ) {
- int kk;
-
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX4; kk++ ) {
- totals[cc]+= extractTotals[kk][cc];
- }
- totals[cc]/= (float)BOX4;
- }
- extract.shove( totals, outIndex, dataOut );
- outIndex++;
- // skip over to next horizontal square of 4
- src += imageSizeInBytes + imageSizeInBytes;
- }
- }
- }
- }
-
- public static void halveImageSlice( int components, ExtractPrimitive extract, int width,
- int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut,
- int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes,
- int imageSizeInBytes, boolean isSwap ) {
- int ii, jj;
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int halfDepth = depth / 2;
- int src = 0;
- int padBytes = rowSizeInBytes - ( width * groupSizeInBytes );
- int outIndex = 0;
-
- assert( (width == 1 || height == 1) && depth >= 2 );
-
- if( width == height ) {
- assert( width == 1 && height == 1 );
- assert( depth >= 2 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- int cc;
- for( cc = 0; cc < components; cc++ ) {
- double[] totals = new double[4];
- double[][] extractTotals = new double[BOX2][4];
- int kk;
-
- dataIn.position( src );
- extractTotals[0][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes );
- extractTotals[1][cc] = extract.extract( isSwap, dataIn );
-
- // average 2 pixels since only a column
- totals[cc] = 0.0f;
- // totals[red] = extractTotals[0][red] + extractTotals[1][red];
- // totals[red] = red / 2;
- for( kk = 0; kk < BOX2; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= (double)BOX2;
-
- extract.shove( totals[cc], outIndex, dataOut );
- outIndex++;
- src += elementSizeInBytes;
- } // for cc
- // skip over next group of 2
- src += rowSizeInBytes;
- } // for ii
-
- assert( src == rowSizeInBytes * height * depth );
- assert( outIndex == halfDepth * components );
- } else if( height == 1 ) {
- assert( width != 1 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- int cc;
- for( cc = 0; cc < components; cc++ ) {
- int kk;
- double totals[] = new double[4];
- double extractTotals[][] = new double[BOX4][4];
-
- dataIn.position( src );
- extractTotals[0][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + groupSizeInBytes );
- extractTotals[1][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes );
- extractTotals[2][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes + groupSizeInBytes );
- extractTotals[3][cc] = extract.extract( isSwap, dataIn );
-
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- // totals[red] = extractTotals[0][red] + extractTotals[1][red] +
- // extractTotals[2][red] + extractTotals[3][red];
- // totals[red] /= (double)BOX4;
- for( kk = 0; kk < BOX4; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= (double)BOX4;
-
- extract.shove( totals[cc], outIndex, dataOut );
- outIndex++;
- src += elementSizeInBytes;
- } // for cc
- // skip over to next horizontal square of 4
- src += elementSizeInBytes;
- } // for jj
- src += padBytes;
- src += rowSizeInBytes;
- } // for ii
- assert( src == rowSizeInBytes * height * depth );
- assert( outIndex == halfWidth * halfDepth * components );
- } else if( width == 1 ) {
- assert( height != 1 );
-
- for( ii = 0; ii < halfDepth; ii++ ) {
- for( jj = 0; jj < halfHeight; jj++ ) {
- int cc;
- for( cc = 0; cc < components; cc++ ) {
- int kk;
- double totals[] = new double[4];
- double extractTotals[][] = new double[BOX4][4];
-
- dataIn.position( src );
- extractTotals[0][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + rowSizeInBytes );
- extractTotals[1][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes );
- extractTotals[2][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes + groupSizeInBytes );
- extractTotals[3][cc] = extract.extract( isSwap, dataIn );
-
-
- // grab 4 pixels to average
- totals[cc] = 0.0f;
- // totals[red] = extractTotals[0][red] + extractTotals[1][red] +
- // extractTotals[2][red] + extractTotals[3][red];
- // totals[red] /= (double)BOX4;
- for( kk = 0; kk < BOX4; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= (double)BOX4;
-
- extract.shove( totals[cc], outIndex, dataOut );
- outIndex++;
- src += elementSizeInBytes;
- } // for cc
- // skip over to next horizontal square of 4
- src += padBytes;
- src += rowSizeInBytes;
- } // for jj
- src += imageSizeInBytes;
- } // for ii
- assert( src == rowSizeInBytes * height * depth );
- assert( outIndex == halfWidth * halfDepth * components );
- }
- }
-
- public static void halveImage3D( int components, ExtractPrimitive extract,
- int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut,
- int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes,
- int imageSizeInBytes, boolean isSwap ) {
- assert( depth > 1 );
-
- // horizontal/vertical/onecolumn slice viewed from top
- if( width == 1 || height == 1 ) {
- assert( 1 <= depth );
-
- halveImageSlice( components, extract, width, height, depth, dataIn, dataOut,
- elementSizeInBytes, groupSizeInBytes, rowSizeInBytes, imageSizeInBytes,
- isSwap );
- return;
- }
-
- int ii, jj, dd;
-
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int halfDepth = depth / 2;
- int src = 0;
- int padBytes = rowSizeInBytes - ( width * groupSizeInBytes );
- int outIndex = 0;
-
- for( dd = 0; dd < halfDepth; dd++ ) {
- for( ii = 0; ii < halfHeight; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- int cc;
- for( cc = 0; cc < components; cc++ ) {
- int kk;
- double totals[] = new double[4];
- double extractTotals[][] = new double[BOX8][4];
-
- dataIn.position( src );
- extractTotals[0][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + groupSizeInBytes );
- extractTotals[1][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + rowSizeInBytes );
- extractTotals[2][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + rowSizeInBytes + groupSizeInBytes );
- extractTotals[3][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + imageSizeInBytes );
- extractTotals[4][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + groupSizeInBytes + imageSizeInBytes );
- extractTotals[5][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + rowSizeInBytes + imageSizeInBytes );
- extractTotals[6][cc] = extract.extract( isSwap, dataIn );
- dataIn.position( src + rowSizeInBytes + imageSizeInBytes + groupSizeInBytes );
- extractTotals[7][cc] = extract.extract( isSwap, dataIn );
-
- totals[cc] = 0.0f;
-
- for( kk = 0; kk < BOX8; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= (double)BOX8;
-
- extract.shove( totals[cc], outIndex, dataOut );
- outIndex++;
-
- src += elementSizeInBytes;
- } // for cc
- // skip over to next square of 4
- src += groupSizeInBytes;
- } // for jj
- // skip past pad bytes, if any, to get to next row
- src += padBytes;
- src += rowSizeInBytes;
- } // for ii
- src += imageSizeInBytes;
- } // for dd
- assert( src == rowSizeInBytes * height * depth );
- assert( outIndex == halfWidth * halfHeight * halfDepth * components );
- }
-
- public static void halveImagePackedPixel3D( int components, Extract extract,
- int width, int height, int depth, ByteBuffer dataIn,
- ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes,
- int imageSizeInBytes, boolean isSwap ) {
- if( depth == 1 ) {
- assert( 1 <= width && 1 <= height );
-
- halveImagePackedPixel( components, extract, width, height, dataIn, dataOut,
- pixelSizeInBytes, rowSizeInBytes, isSwap );
- return;
- } else if( width == 1 || height == 1 ) { // a horizontal or vertical slice viewed from top
- assert( 1 <= depth );
-
- halveImagePackedPixelSlice( components, extract, width, height, depth, dataIn,
- dataOut, pixelSizeInBytes, rowSizeInBytes, imageSizeInBytes, isSwap );
- return;
- }
- int ii, jj, dd;
-
- int halfWidth = width / 2;
- int halfHeight = height / 2;
- int halfDepth = depth / 2;
- int src = 0;
- int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes );
- int outIndex = 0;
-
- for( dd = 0; dd < halfDepth; dd++ ) {
- for( ii = 0; ii < halfHeight; ii++ ) {
- for( jj = 0; jj < halfWidth; jj++ ) {
- float totals[] = new float[4]; // 4 is max components
- float extractTotals[][] = new float[BOX8][4];
- int cc;
-
- dataIn.position( src );
- extract.extract( isSwap, dataIn, extractTotals[0] );
- dataIn.position( src + pixelSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[1] );
- dataIn.position( src + rowSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[2] );
- dataIn.position( src + rowSizeInBytes + pixelSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[3] );
- dataIn.position( src + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[4] );
- dataIn.position( src + pixelSizeInBytes + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[5] );
- dataIn.position( src + rowSizeInBytes + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[6] );
- dataIn.position( src + rowSizeInBytes + pixelSizeInBytes + imageSizeInBytes );
- extract.extract( isSwap, dataIn, extractTotals[7] );
-
- for( cc = 0; cc < components; cc++ ) {
- int kk;
- // grab 8 pixels to average
- totals[cc] = 0.0f;
- for( kk = 0; kk < BOX8; kk++ ) {
- totals[cc] += extractTotals[kk][cc];
- }
- totals[cc] /= (float)BOX8;
- }
- extract.shove( totals, outIndex, dataOut );
- outIndex++;
- // skip over to next square of 4
- src += pixelSizeInBytes + pixelSizeInBytes;
- }
- // skip past pad bytes, if any, to get to next row
- src += padBytes;
- src += rowSizeInBytes;
- }
- src += imageSizeInBytes;
- }
- assert( src == rowSizeInBytes * height * depth );
- assert( outIndex == halfWidth * halfHeight * halfDepth );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Image.java b/src/net/java/games/jogl/impl/mipmap/Image.java
deleted file mode 100644
index 1ea3b1f52..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Image.java
+++ /dev/null
@@ -1,1402 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import net.java.games.jogl.GL;
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Image {
-
- /** Creates a new instance of Image */
- public Image() {
- }
-
- public static short getShortFromByteArray( byte[] array, int index ) {
- short s;
- s = (short)(array[index] << 8 );
- s |= (short)(0x00FF & array[index+1]);
- return( s );
- }
-
- public static int getIntFromByteArray( byte[] array, int index ) {
- int i;
- i = ( array[index] << 24 ) & 0xFF000000;
- i |= ( array[index+1] << 16 ) & 0x00FF0000;
- i |= ( array[index+2] << 8 ) & 0x0000FF00;
- i |= ( array[index+3] ) & 0x000000FF;
- return( i );
- }
-
- public static float getFloatFromByteArray( byte[] array, int index ) {
- int i = getIntFromByteArray( array, index );
- return( Float.intBitsToFloat(i) );
- }
-
- /*
- * Extract array from user's data applying all pixel store modes.
- * The internal format used is an array of unsigned shorts.
- */
- public static void fill_image( PixelStorageModes psm, int width, int height,
- int format, int type, boolean index_format, ByteBuffer userdata,
- ShortBuffer newimage ) {
- int components;
- int element_size;
- int rowsize;
- int padding;
- int groups_per_line;
- int group_size;
- int elements_per_line;
- int start;
- int iter = 0;
- int iter2;
- int i, j, k;
- boolean myswap_bytes;
-
- // Create a Extract interface object
- Extract extract = null;
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- extract = new Extract332();
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- extract = new Extract233rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- extract = new Extract565();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- extract = new Extract565rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- extract = new Extract4444();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- extract = new Extract4444rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- extract = new Extract5551();
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- extract = new Extract1555rev();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- extract = new Extract8888();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- extract = new Extract8888rev();
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- extract = new Extract1010102();
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract = new Extract2101010rev();
- break;
- }
-
- myswap_bytes = psm.getUnpackSwapBytes();
- components = Mipmap.elements_per_group( format, type );
- if( psm.getUnpackRowLength() > 0 ) {
- groups_per_line = psm.getUnpackRowLength();
- } else {
- groups_per_line = width;
- }
-
- // All formats except GL_BITMAP fall out trivially
- if( type == GL.GL_BITMAP ) {
- int bit_offset;
- int current_bit;
-
- rowsize = ( groups_per_line * components + 7 ) / 8;
- padding = ( rowsize % psm.getUnpackAlignment() );
- if( padding != 0 ) {
- rowsize += psm.getUnpackAlignment() - padding;
- }
- start = psm.getUnpackSkipRows() * rowsize + ( psm.getUnpackSkipPixels() * components / 8 );
- elements_per_line = width * components;
- iter2 = 0;
- for( i = 0; i < height; i++ ) {
- iter = start;
- userdata.position( iter ); // ****************************************
- bit_offset = (psm.getUnpackSkipPixels() * components) % 8;
- for( j = 0; j < elements_per_line; j++ ) {
- // retrieve bit
- if( psm.getUnpackLsbFirst() ) {
- userdata.position( iter );
- current_bit = ( userdata.get() & 0x000000FF ) & ( 1 << bit_offset );//userdata[iter] & ( 1 << bit_offset );
- } else {
- current_bit = ( userdata.get() & 0x000000FF ) & ( 1 << ( 7 - bit_offset ) );
- }
- if( current_bit != 0 ) {
- if( index_format ) {
- newimage.position( iter2 );
- newimage.put( (short)1 );
- } else {
- newimage.position( iter2 );
- newimage.put( (short)65535 );
- }
- } else {
- newimage.position( iter2 );
- newimage.put( (short)0 );
- }
- bit_offset++;
- if( bit_offset == 8 ) {
- bit_offset = 0;
- iter++;
- }
- iter2++;
- }
- start += rowsize;
- }
- } else {
- element_size = Mipmap.bytes_per_element( type );
- group_size = element_size * components;
- if( element_size == 1 ) {
- myswap_bytes = false;
- }
-
- rowsize = groups_per_line * group_size;
- padding = ( rowsize % psm.getUnpackAlignment() );
- if( padding != 0 ) {
- rowsize += psm.getUnpackAlignment() - padding;
- }
- start = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size;
- elements_per_line = width * components;
-
- iter2 = 0;
- for( i = 0; i < height; i++ ) {
- iter = start;
- userdata.position( iter ); //***************************************
- for( j = 0; j < elements_per_line; j++ ) {
- Type_Widget widget = new Type_Widget();
- float[] extractComponents = new float[4];
- userdata.position( iter );
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- extract.extract( false, userdata /*userdata[iter]*/, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- extract.extract( false, userdata /*userdata[iter]*/, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE ):
- if( index_format ) {
- newimage.put( (short)( 0x000000FF & userdata.get() ) );//userdata[iter];
- } else {
- newimage.put( (short)( 0x000000FF & userdata.get()/*userdata[iter]*/ * 257 ) );
- }
- break;
- case( GL.GL_BYTE ):
- if( index_format ) {
- newimage.put( userdata.get() ); //userdata[iter];
- } else {
- newimage.put( (short)(userdata.get()/*userdata[iter]*/ * 516 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- extract.extract( myswap_bytes, userdata/*userdata[iter]*/, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)(extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- if( myswap_bytes ) {
- widget.setUB1( userdata.get() );
- widget.setUB0( userdata.get() );
- } else {
- widget.setUB0( userdata.get() );
- widget.setUB1( userdata.get() );
- }
- if( type == GL.GL_SHORT ) {
- if( index_format ) {
- newimage.put( widget.getS0() );
- } else {
- newimage.put( (short)(widget.getS0() * 2) );
- }
- } else {
- newimage.put( widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract.extract( myswap_bytes, userdata, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newimage.put( (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_FLOAT ):
- if( myswap_bytes ) {
- widget.setUB3( userdata.get() );
- widget.setUB2( userdata.get() );
- widget.setUB1( userdata.get() );
- widget.setUB0( userdata.get() );
- } else {
- widget.setUB0( userdata.get() );
- widget.setUB1( userdata.get() );
- widget.setUB2( userdata.get() );
- widget.setUB3( userdata.get() );
- }
- if( type == GL.GL_FLOAT ) {
- if( index_format ) {
- newimage.put( (short)widget.getF() );
- } else {
- newimage.put( (short)(widget.getF() * 65535 ) );
- }
- } else if( type == GL.GL_UNSIGNED_INT ) {
- if( index_format ) {
- newimage.put( (short)( widget.getUI() ) );
- } else {
- newimage.put( (short)( widget.getUI() >> 16 ) );
- }
- } else {
- if( index_format ) {
- newimage.put( (short)( widget.getI() ) );
- } else {
- newimage.put( (short)( widget.getI() >> 15 ) );
- }
- }
- break;
- }
- iter += element_size;
- } // for j
- start += rowsize;
- // want iter pointing at start, not within, row for assertion purposes
- iter = start;
- } // for i
-
- // iterators should be one byte past end
- if( !Mipmap.isTypePackedPixel( type ) ) {
- assert( iter2 == ( width * height * components ) );
- } else {
- assert( iter2 == ( width * height * Mipmap.elements_per_group( format, 0 ) ) );
- }
- assert( iter == ( rowsize * height + psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size ) );
- }
- }
-
- /*
- * Insert array into user's data applying all pixel store modes.
- * Theinternal format is an array of unsigned shorts.
- * empty_image() because it is the opposet of fill_image().
- */
- public static void empty_image( PixelStorageModes psm, int width, int height,
- int format, int type, boolean index_format,
- ShortBuffer oldimage, ByteBuffer userdata ) {
-
- int components;
- int element_size;
- int rowsize;
- int padding;
- int groups_per_line;
- int group_size;
- int elements_per_line;
- int start;
- int iter = 0;
- int iter2;
- int i, j, k;
- boolean myswap_bytes;
-
- // Create a Extract interface object
- Extract extract = null;
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- extract = new Extract332();
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- extract = new Extract233rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- extract = new Extract565();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- extract = new Extract565rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- extract = new Extract4444();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- extract = new Extract4444rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- extract = new Extract5551();
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- extract = new Extract1555rev();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- extract = new Extract8888();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- extract = new Extract8888rev();
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- extract = new Extract1010102();
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract = new Extract2101010rev();
- break;
- }
-
- myswap_bytes = psm.getPackSwapBytes();
- components = Mipmap.elements_per_group( format, type );
- if( psm.getPackRowLength() > 0 ) {
- groups_per_line = psm.getPackRowLength();
- } else {
- groups_per_line = width;
- }
-
- // all formats except GL_BITMAP fall out trivially
- if( type == GL.GL_BITMAP ) {
- int bit_offset;
- int current_bit;
-
- rowsize = ( groups_per_line * components + 7 ) / 8;
- padding = ( rowsize % psm.getPackAlignment() );
- if( padding != 0 ) {
- rowsize += psm.getPackAlignment() - padding;
- }
- start = psm.getPackSkipRows() * rowsize + psm.getPackSkipPixels() * components / 8;
- elements_per_line = width * components;
- iter2 = 0;
- for( i = 0; i < height; i++ ) {
- iter = start;
- bit_offset = ( psm.getPackSkipPixels() * components ) % 8;
- for( j = 0; j < elements_per_line; j++ ) {
- if( index_format ) {
- current_bit = oldimage.get( iter2 ) & 1;
- } else {
- if( oldimage.get( iter2 ) < 0 ) { // must check for negative rather than 32767
- current_bit = 1;
- } else {
- current_bit = 0;
- }
- }
-
- if( current_bit != 0 ) {
- if( psm.getPackLsbFirst() ) {
- userdata.put( iter, (byte)( ( userdata.get( iter ) | ( 1 << bit_offset ) ) ) );
- } else {
- userdata.put( iter, (byte)( ( userdata.get( iter ) | ( 7 - bit_offset ) ) ) );
- }
- } else {
- if( psm.getPackLsbFirst() ) {
- //userdata[iter] &= ~( 1 << bit_offset );
- userdata.put( iter, (byte)( ( userdata.get( iter ) & ~( 1 << bit_offset ) ) ) );
- } else {
- //userdata[iter] &= ~( 1 << ( 7 - bit_offset ) );
- userdata.put( iter, (byte)( ( userdata.get( iter ) & ~( 7 - bit_offset ) ) ) );
- }
- }
-
- bit_offset++;
- if( bit_offset == 8 ) {
- bit_offset = 0;
- iter++;
- }
- iter2++;
- }
- start += rowsize;
- }
- } else {
- float shoveComponents[] = new float[4];
-
- element_size = Mipmap.bytes_per_element( type );
- group_size = element_size * components;
- if( element_size == 1 ) {
- myswap_bytes = false;
- }
-
- rowsize = groups_per_line * group_size;
- padding = ( rowsize % psm.getPackAlignment() );
- if( padding != 0 ) {
- rowsize += psm.getPackAlignment() - padding;
- }
- start = psm.getPackSkipRows() * rowsize + psm.getPackSkipPixels() * group_size;
- elements_per_line = width * components;
-
- iter2 = 0;
- for( i = 0; i < height; i++ ) {
- iter = start;
- for( j = 0; j < elements_per_line; j++ ) {
- Type_Widget widget = new Type_Widget();
-
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, userdata );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldimage.get(iter2++) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, userdata );
- break;
- case( GL.GL_UNSIGNED_BYTE ):
- if( index_format ) {
- //userdata[iter] = (byte)oldimage[iter2++];
- userdata.put( iter, (byte)oldimage.get(iter2++) );
- } else {
- //userdata[iter] = (byte)( oldimage[iter2++] >> 8 );
- userdata.put( iter, (byte)( oldimage.get(iter2++) ) );
- }
- break;
- case( GL.GL_BYTE ):
- if( index_format ) {
- //userdata[iter] = (byte)oldimage[iter2++];
- userdata.put( iter, (byte)oldimage.get(iter2++) );
- } else {
- //userdata[iter] = (byte)( oldimage[iter2++] >> 9 );
- userdata.put( iter, (byte)( oldimage.get(iter2++) ) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldimage.get(iter2++) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1,widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldimage.get(iter2++) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get(iter2++) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter+1] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- if( type == GL.GL_SHORT ) {
- if( index_format ) {
- widget.setS0( oldimage.get( iter2++ ) );
- } else {
- widget.setS0( (short)(oldimage.get( iter2++ ) >> 1) );
- }
- } else {
- widget.setUS0( oldimage.get( iter2++ ) );
- }
- if( myswap_bytes ) {
- //userdata[iter] = widget.getUB1();
- //userdata[iter+1] = widget.getUB0();
- userdata.put( iter, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB0() );
- } else {
- //userdata[iter] = widget.getUB0();
- //userdata[iter] = widget.getUB1();
- userdata.put( iter, widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter+3] = widget.getUB0();
- //userdata[iter+2] = widget.getUB1();
- //userdata[iter+1] = widget.getUB2();
- //userdata[iter ] = widget.getUB3();
- userdata.put( iter + 3, widget.getUB0() );
- userdata.put( iter + 2, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB2() );
- userdata.put( iter , widget.getUB3() );
- } else {
- userdata.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter+3] = widget.getUB0();
- //userdata[iter+2] = widget.getUB1();
- //userdata[iter+1] = widget.getUB2();
- //userdata[iter ] = widget.getUB3();
- userdata.put( iter + 3, widget.getUB0() );
- userdata.put( iter + 2, widget.getUB1() );
- userdata.put( iter + 2, widget.getUB2() );
- userdata.put( iter , widget.getUB3() );
- } else {
- userdata.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter+3] = widget.getUB0();
- //userdata[iter+2] = widget.getUB1();
- //userdata[iter+1] = widget.getUB2();
- //userdata[iter ] = widget.getUB3();
- userdata.put( iter + 3, widget.getUB0() );
- userdata.put( iter + 2, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB2() );
- userdata.put( iter , widget.getUB3() );
- } else {
- userdata.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldimage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswap_bytes ) {
- //userdata[iter+3] = widget.getUB0();
- //userdata[iter+2] = widget.getUB1();
- //userdata[iter+1] = widget.getUB2();
- //userdata[iter ] = widget.getUB3();
- userdata.put( iter + 3, widget.getUB0() );
- userdata.put( iter + 2, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB2() );
- userdata.put( iter , widget.getUB3() );
- } else {
- userdata.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_FLOAT ):
- if( type == GL.GL_FLOAT ) {
- if( index_format ) {
- widget.setF( oldimage.get( iter2++ ) );
- } else {
- widget.setF( oldimage.get( iter2++ ) / 65535.0f );
- }
- } else if( type == GL.GL_UNSIGNED_INT ) {
- if( index_format ) {
- widget.setUI( oldimage.get( iter2++ ) );
- } else {
- widget.setUI( oldimage.get( iter2++ ) * 65537 );
- }
- } else {
- if( index_format ) {
- widget.setI( oldimage.get( iter2++ ) );
- } else {
- widget.setI( (oldimage.get( iter2++ ) * 65537) / 2 );
- }
- }
- if( myswap_bytes ) {
- userdata.put( iter + 3, widget.getUB0() );
- userdata.put( iter + 2, widget.getUB1() );
- userdata.put( iter + 1, widget.getUB2() );
- userdata.put( iter , widget.getUB3() );
- } else {
- userdata.put( iter , widget.getUB0() );
- userdata.put( iter + 1, widget.getUB1() );
- userdata.put( iter + 2, widget.getUB2() );
- userdata.put( iter + 3, widget.getUB3() );
- }
- break;
- }
- iter += element_size;
- } // for j
- start += rowsize;
- // want iter pointing at start, not within, row for assertion purposes
- iter = start;
- } // for i
- // iterators should be one byte past end
- if( !Mipmap.isTypePackedPixel( type ) ) {
- assert( iter2 == width * height * components );
- } else {
- assert( iter2 == width * height * Mipmap.elements_per_group( format, 0 ) );
- }
- assert( iter == rowsize * height + psm.getPackSkipRows() * rowsize + psm.getPackSkipPixels() * group_size );
- }
- }
-
- public static void fillImage3D( PixelStorageModes psm, int width, int height,
- int depth, int format, int type, boolean indexFormat, ByteBuffer userImage,
- ShortBuffer newImage ) {
- boolean myswapBytes;
- int components;
- int groupsPerLine;
- int elementSize;
- int groupSize;
- int rowSize;
- int padding;
- int elementsPerLine;
- int rowsPerImage;
- int imageSize;
- int start, rowStart;
- int iter = 0;
- int iter2 = 0;
- int ww, hh, dd, k;
- Type_Widget widget = new Type_Widget();
- float extractComponents[] = new float[4];
-
- // Create a Extract interface object
- Extract extract = null;
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- extract = new Extract332();
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- extract = new Extract233rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- extract = new Extract565();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- extract = new Extract565rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- extract = new Extract4444();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- extract = new Extract4444rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- extract = new Extract5551();
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- extract = new Extract1555rev();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- extract = new Extract8888();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- extract = new Extract8888rev();
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- extract = new Extract1010102();
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract = new Extract2101010rev();
- break;
- }
-
- myswapBytes = psm.getUnpackSwapBytes();
- components = Mipmap.elements_per_group( format, type );
- if( psm.getUnpackRowLength() > 0 ) {
- groupsPerLine = psm.getUnpackRowLength();
- } else {
- groupsPerLine = width;
- }
- elementSize = Mipmap.bytes_per_element( type );
- groupSize = elementSize * components;
- if( elementSize == 1 ) {
- myswapBytes = false;
- }
-
- // 3dstuff begin
- if( psm.getUnpackImageHeight() > 0 ) {
- rowsPerImage = psm.getUnpackImageHeight();
- } else {
- rowsPerImage = height;
- }
- // 3dstuff end
-
- rowSize = groupsPerLine * groupSize;
- padding = rowSize % psm.getUnpackAlignment();
- if( padding != 0 ) {
- rowSize += psm.getUnpackAlignment() - padding;
- }
-
- imageSize = rowsPerImage * rowSize; // 3dstuff
-
- start = psm.getUnpackSkipRows() * rowSize +
- psm.getUnpackSkipPixels() * groupSize +
- psm.getUnpackSkipImages() * imageSize;
- elementsPerLine = width * components;
-
- iter2 = 0;
- for( dd = 0; dd < depth; dd++ ) {
- rowStart = start;
- for( hh = 0; hh < height; hh++ ) {
- iter = rowStart;
- for( ww = 0; ww < elementsPerLine; ww++ ) {
-
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- if( indexFormat ) {
- newImage.put( iter2++, (short)(0x000000FF & userImage.get( iter ) ) );
- } else {
- newImage.put( iter2++, (short)((0x000000FF & userImage.get( iter ) ) * 257 ) );
- }
- break;
- case( GL.GL_BYTE ):
- if( indexFormat ) {
- newImage.put( iter2++, userImage.get( iter ) );
- } else {
- newImage.put( iter2++, (short)(userImage.get( iter ) * 516 ) );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- userImage.position( iter );
- extract.extract( false, userImage, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- userImage.position( iter );
- extract.extract( false, userImage, extractComponents );
- for( k = 0; k < 3; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)(extractComponents[k] * 65535) );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- if( myswapBytes ) {
- widget.setUB0( userImage.get( iter + 1 ) );
- widget.setUB1( userImage.get( iter ) );
- } else {
- widget.setUB0( userImage.get( iter ) );
- widget.setUB1( userImage.get( iter + 1 ) );
- }
- if( type == GL.GL_SHORT ) {
- if( indexFormat ) {
- newImage.put( iter2++, widget.getUS0() );
- } else {
- newImage.put( iter2++, (short)(widget.getUS0() * 2) );
- }
- } else {
- newImage.put( iter2++, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- userImage.position( iter );
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract.extract( myswapBytes, userImage, extractComponents );
- for( k = 0; k < 4; k++ ) {
- newImage.put( iter2++, (short)( extractComponents[k] * 65535 ) );
- }
- break;
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_FLOAT ):
- if( myswapBytes ) {
- widget.setUB0( userImage.get( iter + 3 ) );
- widget.setUB1( userImage.get( iter + 2 ) );
- widget.setUB2( userImage.get( iter + 1 ) );
- widget.setUB3( userImage.get( iter ) );
- } else {
- widget.setUB0( userImage.get( iter ) );
- widget.setUB1( userImage.get( iter + 1 ) );
- widget.setUB2( userImage.get( iter + 2 ) );
- widget.setUB3( userImage.get( iter + 3 ) );
- }
- if( type == GL.GL_FLOAT ) {
- if( indexFormat ) {
- newImage.put( iter2++, (short)widget.getF() );
- } else {
- newImage.put( iter2++, (short)( widget.getF() * 65535.0f ) );
- }
- } else if( type == GL.GL_UNSIGNED_INT ) {
- if( indexFormat ) {
- newImage.put( iter2++, (short)widget.getUI() );
- } else {
- newImage.put( iter2++, (short)(widget.getUI() >> 16) );
- }
- } else {
- if( indexFormat ) {
- newImage.put( iter2++, (short)widget.getI() );
- } else {
- newImage.put( iter2++, (short)(widget.getI() >> 15) );
- }
- }
- break;
- default:
- assert( false );
- }
- iter += elementSize;
- } // for ww
- rowStart += rowSize;
- iter = rowStart; // for assert
- } // for hh
- start += imageSize;
- }// for dd
-
- // iterators should be one byte past end
- if( !Mipmap.isTypePackedPixel( type ) ) {
- assert( iter2 == width * height * depth * components );
- } else {
- assert( iter2 == width * height * depth * Mipmap.elements_per_group( format, 0 ) );
- }
- assert( iter == rowSize * height * depth + psm.getUnpackSkipRows() * rowSize +
- psm.getUnpackSkipPixels() * groupSize +
- psm.getUnpackSkipImages() * imageSize );
- }
-
- public static void emptyImage3D( PixelStorageModes psm, int width, int height, int depth,
- int format, int type, boolean indexFormat, ShortBuffer oldImage, ByteBuffer userImage ) {
- boolean myswapBytes;
- int components;
- int groupsPerLine;
- int elementSize;
- int groupSize;
- int rowSize;
- int padding;
- int start, rowStart, iter;
- int elementsPerLine;
- int iter2;
- int ii, jj, dd, k;
- int rowsPerImage;
- int imageSize;
- Type_Widget widget = new Type_Widget();
- float[] shoveComponents = new float[4];
-
- // Create a Extract interface object
- Extract extract = null;
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- extract = new Extract332();
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- extract = new Extract233rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- extract = new Extract565();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- extract = new Extract565rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- extract = new Extract4444();
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- extract = new Extract4444rev();
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- extract = new Extract5551();
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- extract = new Extract1555rev();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- extract = new Extract8888();
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- extract = new Extract8888rev();
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- extract = new Extract1010102();
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- extract = new Extract2101010rev();
- break;
- }
-
- iter = 0;
-
- myswapBytes = psm.getPackSwapBytes();
- components = Mipmap.elements_per_group( format, type );
- if( psm.getPackRowLength() > 0 ) {
- groupsPerLine = psm.getPackRowLength();
- } else {
- groupsPerLine = width;
- }
-
- elementSize = Mipmap.bytes_per_element( type );
- groupSize = elementSize * components;
- if( elementSize == 1 ) {
- myswapBytes = false;
- }
-
- // 3dstuff begin
- if( psm.getPackImageHeight() > 0 ) {
- rowsPerImage = psm.getPackImageHeight();
- } else {
- rowsPerImage = height;
- }
-
- // 3dstuff end
-
- rowSize = groupsPerLine * groupSize;
- padding = rowSize % psm.getPackAlignment();
- if( padding != 0 ) {
- rowSize += psm.getPackAlignment() - padding;
- }
-
- imageSize = rowsPerImage * rowSize;
-
- start = psm.getPackSkipRows() * rowSize +
- psm.getPackSkipPixels() * groupSize +
- psm.getPackSkipImages() * imageSize;
- elementsPerLine = width * components;
-
- iter2 = 0;
- for( dd = 0; dd < depth; dd++ ) {
- rowStart = start;
-
- for( ii = 0; ii < height; ii++ ) {
- iter = rowStart;
-
- for( jj = 0; jj < elementsPerLine; jj++ ) {
-
- switch( type ) {
- case( GL.GL_UNSIGNED_BYTE ):
- if( indexFormat ) {
- userImage.put( iter, (byte)(oldImage.get( iter2++ ) ) );
- } else {
- userImage.put( iter, (byte)(oldImage.get( iter2++ ) >> 8 ) );
- }
- break;
- case( GL.GL_BYTE ):
- if( indexFormat ) {
- userImage.put( iter, (byte)(oldImage.get(iter2++) ) );
- } else {
- userImage.put( iter, (byte)(oldImage.get(iter2++) >> 9) );
- }
- break;
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, userImage );
- break;
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- for( k = 0; k < 3; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, userImage );
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.putShort( iter, widget.getUB1() );
- userImage.putShort( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.putShort( iter, widget.getUS0() );
- }
- break;
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_SHORT ):
- if( type == GL.GL_SHORT ) {
- if( indexFormat ) {
- widget.setS0( (short)oldImage.get( iter2++ ) );
- } else {
- widget.setS0( (short)(oldImage.get( iter2++ ) >> 1) );
- }
- } else {
- widget.setUS0( (short)oldImage.get( iter2++ ) );
- }
- if( myswapBytes ) {
- userImage.put( iter, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB0() );
- } else {
- userImage.put( iter, widget.getUB0() );
- userImage.put( iter + 1, widget.getUB1() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter + 3, widget.getUB0() );
- userImage.put( iter + 2, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB2() );
- userImage.put( iter , widget.getUB3() );
- } else {
- userImage.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter + 3, widget.getUB0() );
- userImage.put( iter + 2, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB2() );
- userImage.put( iter , widget.getUB3() );
- } else {
- userImage.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter + 3, widget.getUB0() );
- userImage.put( iter + 2, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB2() );
- userImage.put( iter ,widget.getUB3() );
- } else {
- userImage.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- for( k = 0; k < 4; k++ ) {
- shoveComponents[k] = oldImage.get( iter2++ ) / 65535.0f;
- }
- extract.shove( shoveComponents, 0, widget.getBuffer() );
- if( myswapBytes ) {
- userImage.put( iter + 3, widget.getUB0() );
- userImage.put( iter + 2, widget.getUB2() );
- userImage.put( iter + 1, widget.getUB1() );
- userImage.put( iter , widget.getUB0() );
- } else {
- userImage.putInt( iter, widget.getUI() );
- }
- break;
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_FLOAT ):
- if( type == GL.GL_FLOAT ) {
- if( indexFormat ) {
- widget.setF( oldImage.get( iter2++ ) );
- } else {
- widget.setF( oldImage.get( iter2++ ) / 65535.0f );
- }
- } else if( type == GL.GL_UNSIGNED_INT ) {
- if( indexFormat ) {
- widget.setUI( oldImage.get( iter2++ ) );
- } else {
- widget.setUI( oldImage.get( iter2++ ) * 65537 );
- }
- } else {
- if( indexFormat ) {
- widget.setI( oldImage.get( iter2++ ) );
- } else {
- widget.setI( ( oldImage.get( iter2++ ) * 65535 ) / 2 );
- }
- }
- if( myswapBytes ) {
- userImage.put( iter + 3, widget.getUB0() );
- userImage.put( iter + 2, widget.getUB1() );
- userImage.put( iter + 1, widget.getUB2() );
- userImage.put( iter , widget.getUB3() );
- } else {
- userImage.put( iter , widget.getUB0() );
- userImage.put( iter + 1, widget.getUB1() );
- userImage.put( iter + 2, widget.getUB2() );
- userImage.put( iter + 3, widget.getUB3() );
- }
- break;
- default:
- assert( false );
- }
-
- iter += elementSize;
- } // for jj
- rowStart += rowSize;
- } // for ii
- start += imageSize;
- } // for dd
-
- if( !Mipmap.isTypePackedPixel( type ) ) {
- assert( iter2 == width * height * depth * components );
- } else {
- assert( iter2 == width * height * depth * Mipmap.elements_per_group( format, 0 ) );
- }
- assert( iter == rowSize * height * depth +
- psm.getUnpackSkipRows() * rowSize +
- psm.getUnpackSkipPixels() * groupSize +
- psm.getUnpackSkipImages() * imageSize );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Mipmap.java b/src/net/java/games/jogl/impl/mipmap/Mipmap.java
deleted file mode 100644
index b3954704d..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Mipmap.java
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.GLU;
-import net.java.games.jogl.GLException;
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Mipmap {
-
- /** Creates a new instance of Mipmap */
- public Mipmap() {
- }
-
- public static int computeLog( int value ) {
- int i = 0;
- // Error
- if( value == 0 ) {
- return( -1 );
- }
- for( ;; ) {
- if( (value & 1) >= 1 ) {
- if( value != 1 ) {
- return( -1 );
- }
- return( i );
- }
- value = value >> 1;
- i++;
- }
- }
-
- /* Compute the nearest power of 2 number. This algorithm is a little strange
- * but it works quite well.
- */
- public static int nearestPower( int value ) {
- int i = 1;
- // Error!
- if( value == 0 ) {
- return( -1 );
- }
- for( ;; ) {
- if( value == 1 ) {
- return( i );
- } else if( value == 3 ) {
- return( i * 4 );
- }
- value = value >> 1;
- i *= 2;
- }
- }
-
- public static short GLU_SWAP_2_BYTES( short s ) {
- byte b = 0;
- b = (byte)( s >>> 8 );
- s = (short)( s << 8 );
- s = (short)( s | (0x00FF & b) );
- return( s );
- }
-
- public static int GLU_SWAP_4_BYTES( int i ) {
- int t = i << 24;
- t |= 0x00FF0000 & ( i << 8 );
- t |= 0x0000FF00 & ( i >>> 8 );
- t |= 0x000000FF & ( i >>> 24 );
- return( t );
- }
-
- public static float GLU_SWAP_4_BYTES( float f ) {
- int i = Float.floatToRawIntBits( f );
- float temp = Float.intBitsToFloat( i );
- return( temp );
- }
-
- public static int checkMipmapArgs( int internalFormat, int format, int type ) {
- if( !legalFormat( format ) || !legalType( type ) ) {
- return( GLU.GLU_INVALID_ENUM );
- }
- if( format == GL.GL_STENCIL_INDEX ) {
- return( GLU.GLU_INVALID_ENUM );
- }
- if( !isLegalFormatForPackedPixelType( format, type ) ) {
- return( GLU.GLU_INVALID_OPERATION );
- }
- return( 0 );
- }
-
- public static boolean legalFormat( int format ) {
- switch( format ) {
- case( GL.GL_COLOR_INDEX ):
- case( GL.GL_STENCIL_INDEX ):
- case( GL.GL_DEPTH_COMPONENT ):
- case( GL.GL_RED ):
- case( GL.GL_GREEN ):
- case( GL.GL_BLUE ):
- case( GL.GL_ALPHA ):
- case( GL.GL_RGB ):
- case( GL.GL_RGBA ):
- case( GL.GL_LUMINANCE ):
- case( GL.GL_LUMINANCE_ALPHA ):
- case( GL.GL_BGR ):
- case( GL.GL_BGRA ):
- return( true );
- default:
- return( false );
- }
- }
-
- public static boolean legalType( int type ) {
- switch( type ) {
- case( GL.GL_BITMAP ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_FLOAT ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- return( true );
- default:
- return( false );
- }
- }
-
- public static boolean isTypePackedPixel( int type ) {
- assert( legalType( type ) );
-
- if( type == GL.GL_UNSIGNED_BYTE_3_3_2 ||
- type == GL.GL_UNSIGNED_BYTE_2_3_3_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_6_5 ||
- type == GL.GL_UNSIGNED_SHORT_5_6_5_REV ||
- type == GL.GL_UNSIGNED_SHORT_4_4_4_4 ||
- type == GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_5_5_1 ||
- type == GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8 ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8_REV ||
- type == GL.GL_UNSIGNED_INT_10_10_10_2 ||
- type == GL.GL_UNSIGNED_INT_2_10_10_10_REV ) {
- return( true );
- }
- return( false );
- }
-
- public static boolean isLegalFormatForPackedPixelType( int format, int type ) {
- // if not a packed pixel type then return true
- if( isTypePackedPixel( type ) ) {
- return( true );
- }
-
- // 3_3_2/2_3_3_REV & 5_6_5/5_6_5_REV are only compatible with RGB
- if( (type == GL.GL_UNSIGNED_BYTE_3_3_2 || type == GL.GL_UNSIGNED_BYTE_2_3_3_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_6_5 || type == GL.GL_UNSIGNED_SHORT_5_6_5_REV )
- & format != GL.GL_RGB ) {
- return( false );
- }
-
- // 4_4_4_4/4_4_4_4_REV & 5_5_5_1/1_5_5_5_REV & 8_8_8_8/8_8_8_8_REV &
- // 10_10_10_2/2_10_10_10_REV are only campatible with RGBA, BGRA & ARGB_EXT
- if( ( type == GL.GL_UNSIGNED_SHORT_4_4_4_4 ||
- type == GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_5_5_1 ||
- type == GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8 ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8_REV ||
- type == GL.GL_UNSIGNED_INT_10_10_10_2 ||
- type == GL.GL_UNSIGNED_INT_2_10_10_10_REV ) &&
- (format != GL.GL_RGBA && format != GL.GL_BGRA) ) {
- return( false );
- }
- return( true );
- }
-
- public static boolean isLegalLevels( int userLevel, int baseLevel, int maxLevel,
- int totalLevels ) {
- if( (baseLevel < 0) || (baseLevel < userLevel) || (maxLevel < baseLevel) ||
- (totalLevels < maxLevel) ) {
- return( false );
- }
- return( true );
- }
-
- /* Given user requested textures size, determine if it fits. If it doesn't then
- * halve both sides and make the determination again until it does fit ( for
- * IR only ).
- * Note that proxy textures are not implemented in RE* even though they
- * advertise the texture extension.
- * Note that proxy textures are implemented but not according to spec in IMPACT*
- */
- public static void closestFit( GL gl, int target, int width, int height, int internalFormat,
- int format, int type, int[] newWidth, int[] newHeight ) {
- // Use proxy textures if OpenGL version >= 1.1
- if( Double.parseDouble( gl.glGetString( GL.GL_VERSION ).trim().substring( 0, 3 ) ) >= 1.1 ) {
- int widthPowerOf2 = nearestPower( width );
- int heightPowerOf2 = nearestPower( height );
- int[] proxyWidth = new int[1];
- boolean noProxyTextures = false;
-
- // Some drivers (in particular, ATI's) seem to set a GL error
- // when proxy textures are used even though this is in violation
- // of the spec. Guard against this and interactions with the
- // DebugGL by watching for GLException.
- try {
- do {
- // compute level 1 width & height, clamping each at 1
- int widthAtLevelOne = ( ( width > 1 ) ? (widthPowerOf2 >> 1) : widthPowerOf2 );
- int heightAtLevelOne = ( ( height > 1 ) ? (heightPowerOf2 >> 1) : heightPowerOf2 );
- int proxyTarget;
-
- assert( widthAtLevelOne > 0 );
- assert( heightAtLevelOne > 0 );
-
- // does width x height at level 1 & all their mipmaps fit?
- if( target == GL.GL_TEXTURE_2D || target == GL.GL_PROXY_TEXTURE_2D ) {
- proxyTarget = GL.GL_PROXY_TEXTURE_2D;
- gl.glTexImage2D( proxyTarget, 1, internalFormat, widthAtLevelOne,
- heightAtLevelOne, 0, format, type, (double[])null );
- } else if( (target == GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB) ||
- (target == GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB) ||
- (target == GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB) ||
- (target == GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB) ||
- (target == GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB) ||
- (target == GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) ) {
- proxyTarget = GL.GL_PROXY_TEXTURE_CUBE_MAP_ARB;
- gl.glTexImage2D( proxyTarget, 1, internalFormat, widthAtLevelOne,
- heightAtLevelOne, 0, format, type, (double[])null );
- } else {
- assert( target == GL.GL_TEXTURE_1D || target == GL.GL_PROXY_TEXTURE_1D );
- proxyTarget = GL.GL_PROXY_TEXTURE_1D;
- gl.glTexImage1D( proxyTarget, 1, internalFormat, widthAtLevelOne,
- 0, format, type, (double[])null );
- }
- gl.glGetTexLevelParameteriv( proxyTarget, 1, GL.GL_TEXTURE_WIDTH, proxyWidth );
- // does it fit?
- if( proxyWidth[0] == 0 ) { // nope, so try again with theses sizes
- if( widthPowerOf2 == 1 && heightPowerOf2 == 1 ) {
- /* A 1x1 texture couldn't fit for some reason so break out. This
- * should never happen. But things happen. The disadvantage with
- * this if-statement is that we will never be aware of when this
- * happens since it will silently branch out.
- */
- noProxyTextures = true;
- break;
- }
- widthPowerOf2 = widthAtLevelOne;
- heightPowerOf2 = heightAtLevelOne;
- }
- // else it does fit
- } while( proxyWidth[0] == 0 );
- } catch (GLException e) {
- noProxyTextures = true;
- }
- // loop must terminate
- // return the width & height at level 0 that fits
- if( !noProxyTextures ) {
- newWidth[0] = widthPowerOf2;
- newHeight[0] = heightPowerOf2;
- return;
- }
- }
- int[] maxsize = new int[1];
- gl.glGetIntegerv( GL.GL_MAX_TEXTURE_SIZE, maxsize );
- // clamp user's texture sizes to maximum sizes, if necessary
- newWidth[0] = nearestPower( width );
- if( newWidth[0] > maxsize[0] ) {
- newWidth[0] = maxsize[0];
- }
- newHeight[0] = nearestPower( height );
- if( newHeight[0] > maxsize[0] ) {
- newHeight[0] = maxsize[0];
- }
- }
-
- public static void closestFit3D( GL gl, int target, int width, int height, int depth,
- int internalFormat, int format, int type, int[] newWidth, int[] newHeight,
- int[] newDepth ) {
- int widthPowerOf2 = nearestPower( width );
- int heightPowerOf2 = nearestPower( height );
- int depthPowerOf2 = nearestPower( depth );
- int[] proxyWidth = new int[1];
-
- do {
- // compute level 1 width & height & depth, clamping each at 1
- int widthAtLevelOne = (widthPowerOf2 > 1) ? widthPowerOf2 >> 1 : widthPowerOf2;
- int heightAtLevelOne = (heightPowerOf2 > 1) ? heightPowerOf2 >> 1 : heightPowerOf2;
- int depthAtLevelOne = (depthPowerOf2 > 1) ? depthPowerOf2 >> 1 : depthPowerOf2;
- int proxyTarget = 0;
- assert( widthAtLevelOne > 0 );
- assert( heightAtLevelOne > 0 );
- assert( depthAtLevelOne > 0 );
-
- // does width x height x depth at level 1 & all their mipmaps fit?
- if( target == GL.GL_TEXTURE_3D || target == GL.GL_PROXY_TEXTURE_3D ) {
- proxyTarget = GL.GL_PROXY_TEXTURE_3D;
- gl.glTexImage3D( proxyTarget, 1, internalFormat, widthAtLevelOne,
- heightAtLevelOne, depthAtLevelOne, 0, format, type, (double[])null );
- }
- gl.glGetTexLevelParameteriv( proxyTarget, 1, GL.GL_TEXTURE_WIDTH, proxyWidth );
- // does it fit
- if( proxyWidth[0] == 0 ) {
- if( widthPowerOf2 == 1 && heightPowerOf2 == 1 && depthPowerOf2 == 1 ) {
- newWidth[0] = newHeight[0] = newDepth[0] = 1;
- return;
- }
- widthPowerOf2 = widthAtLevelOne;
- heightPowerOf2 = heightAtLevelOne;
- depthPowerOf2 = depthAtLevelOne;
- }
- } while( proxyWidth[0] == 0 );
- // loop must terminate
-
- // return the width & height at level 0 that fits
- newWidth[0] = widthPowerOf2;
- newHeight[0] = heightPowerOf2;
- newDepth[0] = depthPowerOf2;
- }
-
- public static int elements_per_group( int format, int type ) {
- // Return the number of elements per grtoup of a specified gromat
-
- // If the type is packedpixels then answer is 1
- if( type == GL.GL_UNSIGNED_BYTE_3_3_2 ||
- type == GL.GL_UNSIGNED_BYTE_2_3_3_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_6_5 ||
- type == GL.GL_UNSIGNED_SHORT_5_6_5_REV ||
- type == GL.GL_UNSIGNED_SHORT_4_4_4_4 ||
- type == GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ||
- type == GL.GL_UNSIGNED_SHORT_5_5_5_1 ||
- type == GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8 ||
- type == GL.GL_UNSIGNED_INT_8_8_8_8_REV ||
- type == GL.GL_UNSIGNED_INT_10_10_10_2 ||
- type == GL.GL_UNSIGNED_INT_2_10_10_10_REV ) {
- return( 1 );
- }
-
- // Types are not packed pixels so get elements per group
- switch( format ) {
- case( GL.GL_RGB ):
- case( GL.GL_BGR ):
- return( 3 );
- case( GL.GL_LUMINANCE_ALPHA ):
- return( 2 );
- case( GL.GL_RGBA ):
- case( GL.GL_BGRA ):
- return( 4 );
- default:
- return( 1 );
- }
- }
-
- public static int bytes_per_element( int type ) {
- // return the number of bytes per element, based on the element type
-
- switch( type ) {
- case( GL.GL_BITMAP ):
- case( GL.GL_BYTE ):
- case( GL.GL_UNSIGNED_BYTE ):
- case( GL.GL_UNSIGNED_BYTE_3_3_2 ):
- case( GL.GL_UNSIGNED_BYTE_2_3_3_REV ):
- return( 1 );
- case( GL.GL_SHORT ):
- case( GL.GL_UNSIGNED_SHORT ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5 ):
- case( GL.GL_UNSIGNED_SHORT_5_6_5_REV ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4 ):
- case( GL.GL_UNSIGNED_SHORT_4_4_4_4_REV ):
- case( GL.GL_UNSIGNED_SHORT_5_5_5_1 ):
- case( GL.GL_UNSIGNED_SHORT_1_5_5_5_REV ):
- return( 2 );
- case( GL.GL_INT ):
- case( GL.GL_UNSIGNED_INT ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8 ):
- case( GL.GL_UNSIGNED_INT_8_8_8_8_REV ):
- case( GL.GL_UNSIGNED_INT_10_10_10_2 ):
- case( GL.GL_UNSIGNED_INT_2_10_10_10_REV ):
- case( GL.GL_FLOAT ):
- return( 4 );
- default:
- return( 4 );
- }
- }
-
- public static boolean is_index( int format ) {
- return( format == GL.GL_COLOR_INDEX || format == GL.GL_STENCIL_INDEX );
- }
-
- /* Compute memory required for internal packed array of data of given type and format. */
-
- public static int image_size( int width, int height, int format, int type ) {
- int bytes_per_row;
- int components;
-
- assert( width > 0 );
- assert( height > 0 );
- components = elements_per_group( format, type );
- if( type == GL.GL_BITMAP ) {
- bytes_per_row = (width + 7) / 8;
- } else {
- bytes_per_row = bytes_per_element( type ) * width;
- }
- return( bytes_per_row * height * components );
- }
-
- public static int imageSize3D( int width, int height, int depth, int format, int type ) {
- int components = elements_per_group( format, type );
- int bytes_per_row = bytes_per_element( type ) * width;
-
- assert( width > 0 && height > 0 && depth > 0 );
- assert( type != GL.GL_BITMAP );
-
- return( bytes_per_row * height * depth * components );
- }
-
- public static void retrieveStoreModes( GL gl, PixelStorageModes psm ) {
- int[] a = new int[1];
- gl.glGetIntegerv( GL.GL_UNPACK_ALIGNMENT, a );
- psm.setUnpackAlignment( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_ROW_LENGTH, a );
- psm.setUnpackRowLength( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_SKIP_ROWS, a );
- psm.setUnpackSkipRows( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_SKIP_PIXELS, a );
- psm.setUnpackSkipPixels( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_LSB_FIRST, a );
- psm.setUnpackLsbFirst( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_UNPACK_SWAP_BYTES, a );
- psm.setUnpackSwapBytes( ( a[0] == 1 ) );
-
- gl.glGetIntegerv( GL.GL_PACK_ALIGNMENT, a );
- psm.setPackAlignment( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_ROW_LENGTH, a );
- psm.setPackRowLength( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_SKIP_ROWS, a );
- psm.setPackSkipRows( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_SKIP_PIXELS, a );
- psm.setPackSkipPixels( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_LSB_FIRST, a );
- psm.setPackLsbFirst( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_PACK_SWAP_BYTES, a );
- psm.setPackSwapBytes( ( a[0] == 1 ) );
- }
-
- public static void retrieveStoreModes3D( GL gl, PixelStorageModes psm ) {
- int[] a = new int[1];
- gl.glGetIntegerv( GL.GL_UNPACK_ALIGNMENT, a );
- psm.setUnpackAlignment( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_ROW_LENGTH, a );
- psm.setUnpackRowLength( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_SKIP_ROWS, a );
- psm.setUnpackSkipRows( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_SKIP_PIXELS, a );
- psm.setUnpackSkipPixels( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_LSB_FIRST, a );
- psm.setUnpackLsbFirst( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_UNPACK_SWAP_BYTES, a );
- psm.setUnpackSwapBytes( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_UNPACK_SKIP_IMAGES, a );
- psm.setUnpackSkipImages( a[0] );
- gl.glGetIntegerv( GL.GL_UNPACK_IMAGE_HEIGHT, a );
- psm.setUnpackImageHeight( a[0] );
-
- gl.glGetIntegerv( GL.GL_PACK_ALIGNMENT, a );
- psm.setPackAlignment( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_ROW_LENGTH, a );
- psm.setPackRowLength( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_SKIP_ROWS, a );
- psm.setPackSkipRows( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_SKIP_PIXELS, a );
- psm.setPackSkipPixels( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_LSB_FIRST, a );
- psm.setPackLsbFirst( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_PACK_SWAP_BYTES, a );
- psm.setPackSwapBytes( ( a[0] == 1 ) );
- gl.glGetIntegerv( GL.GL_PACK_SKIP_IMAGES, a );
- psm.setPackSkipImages( a[0] );
- gl.glGetIntegerv( GL.GL_PACK_IMAGE_HEIGHT, a );
- psm.setPackImageHeight( a[0] );
- }
-
- public static int gluScaleImage( GL gl, int format, int widthin, int heightin,
- int typein, ByteBuffer datain, int widthout, int heightout,
- int typeout, ByteBuffer dataout ) {
- int components;
- ByteBuffer beforeimage;
- ByteBuffer afterimage;
- PixelStorageModes psm = new PixelStorageModes();
-
- if( (widthin == 0) || (heightin == 0) || (widthout == 0) || (heightout == 0) ) {
- return( 0 );
- }
- if( (widthin < 0) || (heightin < 0) || (widthout < 0) || (heightout < 0) ) {
- return( GLU.GLU_INVALID_VALUE );
- }
- if( !legalFormat( format ) || !legalType( typein ) || !legalType( typeout ) ) {
- return( GLU.GLU_INVALID_ENUM );
- }
- if( !isLegalFormatForPackedPixelType( format, typein ) ) {
- return( GLU.GLU_INVALID_OPERATION );
- }
- if( !isLegalFormatForPackedPixelType( format, typeout ) ) {
- return( GLU.GLU_INVALID_OPERATION );
- }
- beforeimage = ByteBuffer.allocateDirect( image_size( widthin, heightin, format, GL.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() );
- afterimage = ByteBuffer.allocateDirect( image_size( widthout, heightout, format, GL.GL_UNSIGNED_SHORT ) ).order( ByteOrder.nativeOrder() );
- if( beforeimage == null || afterimage == null ) {
- return( GLU.GLU_OUT_OF_MEMORY );
- }
-
- retrieveStoreModes( gl, psm );
- Image.fill_image( psm, widthin, heightin, format, typein, is_index( format ), datain, beforeimage.asShortBuffer() );
- components = elements_per_group( format, 0 );
- ScaleInternal.scale_internal( components, widthin, heightin, beforeimage.asShortBuffer(), widthout, heightout, afterimage.asShortBuffer() );
- Image.empty_image( psm, widthout, heightout, format, typeout, is_index( format ), afterimage.asShortBuffer(), dataout );
-
- return( 0 );
- }
-
- public static int gluBuild1DMipmapLevels( GL gl, int target, int internalFormat,
- int width, int format, int type, int userLevel, int baseLevel,
- int maxLevel, ByteBuffer data ) {
- int levels;
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- levels = computeLog( width );
-
- levels += userLevel;
- if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- return( BuildMipmap.gluBuild1DMipmapLevelsCore( gl, target, internalFormat, width,
- width, format, type, userLevel, baseLevel, maxLevel, data ) );
- }
-
- public static int gluBuild1DMipmaps( GL gl, int target, int internalFormat, int width,
- int format, int type, ByteBuffer data ) {
- int[] widthPowerOf2 = new int[1];
- int levels;
- int[] dummy = new int[1];
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- closestFit( gl, target, width, 1, internalFormat, format, type, widthPowerOf2, dummy );
- levels = computeLog( widthPowerOf2[0] );
-
- return( BuildMipmap.gluBuild1DMipmapLevelsCore( gl, target, internalFormat,
- width, widthPowerOf2[0], format, type, 0, 0, levels, data ) );
- }
-
- public static int gluBuild2DMipmapLevels( GL gl, int target, int internalFormat,
- int width, int height, int format, int type, int userLevel,
- int baseLevel, int maxLevel, Object data ) {
- int level, levels;
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 || height < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- levels = computeLog( width );
- level = computeLog( height );
- if( level > levels ) {
- levels = level;
- }
-
- levels += userLevel;
- if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data );
- ByteBuffer buffer = null;
- if( data instanceof ByteBuffer ) {
- buffer = (ByteBuffer)data;
- } else if( data instanceof byte[] ) {
- byte[] array = (byte[])data;
- buffer = ByteBuffer.allocateDirect(array.length);
- buffer.put(array);
- } else if( data instanceof short[] ) {
- short[] array = (short[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 2 );
- ShortBuffer sb = buffer.asShortBuffer();
- sb.put( array );
- } else if( data instanceof int[] ) {
- int[] array = (int[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 4 );
- IntBuffer ib = buffer.asIntBuffer();
- ib.put( array );
- } else if( data instanceof float[] ) {
- float[] array = (float[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 4 );
- FloatBuffer fb = buffer.asFloatBuffer();
- fb.put( array );
- }
-
- return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat,
- width, height, width, height, format, type, userLevel, baseLevel,
- maxLevel, buffer ) );
- }
-
- public static int gluBuild2DMipmaps( GL gl, int target, int internalFormat,
- int width, int height, int format, int type, Object data ) {
- int[] widthPowerOf2 = new int[1];
- int[] heightPowerOf2 = new int[1];
- int level, levels;
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 || height < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- closestFit( gl, target, width, height, internalFormat, format, type,
- widthPowerOf2, heightPowerOf2 );
-
- levels = computeLog( widthPowerOf2[0] );
- level = computeLog( heightPowerOf2[0] );
- if( level > levels ) {
- levels = level;
- }
-
- //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data );
- ByteBuffer buffer = null;
- if( data instanceof ByteBuffer ) {
- buffer = (ByteBuffer)data;
- } else if( data instanceof byte[] ) {
- byte[] array = (byte[])data;
- buffer = ByteBuffer.allocateDirect(array.length);
- buffer.put(array);
- } else if( data instanceof short[] ) {
- short[] array = (short[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 2 );
- ShortBuffer sb = buffer.asShortBuffer();
- sb.put( array );
- } else if( data instanceof int[] ) {
- int[] array = (int[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 4 );
- IntBuffer ib = buffer.asIntBuffer();
- ib.put( array );
- } else if( data instanceof float[] ) {
- float[] array = (float[])data;
- buffer = ByteBuffer.allocateDirect( array.length * 4 );
- FloatBuffer fb = buffer.asFloatBuffer();
- fb.put( array );
- }
-
- return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat,
- width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0,
- 0, levels, buffer ) );
- }
-
- public static int gluBuild3DMipmaps( GL gl, int target, int internalFormat,
- int width, int height, int depth, int format, int type, ByteBuffer data ) {
- int[] widthPowerOf2 = new int[1];
- int[] heightPowerOf2 = new int[1];
- int[] depthPowerOf2 = new int[1];
- int level, levels;
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 || height < 1 || depth < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- if( type == GL.GL_BITMAP ) {
- return( GLU.GLU_INVALID_ENUM );
- }
-
- closestFit3D( gl, target, width, height, depth, internalFormat, format,
- type, widthPowerOf2, heightPowerOf2, depthPowerOf2 );
-
- levels = computeLog( widthPowerOf2[0] );
- level = computeLog( heightPowerOf2[0] );
- if( level > levels ) {
- levels = level;
- }
- level = computeLog( depthPowerOf2[0] );
- if( level > levels ) {
- levels = level;
- }
-
- return( BuildMipmap.gluBuild3DMipmapLevelsCore( gl, target, internalFormat, width,
- height, depth, widthPowerOf2[0], heightPowerOf2[0], depthPowerOf2[0],
- format, type, 0, 0, levels, data ) );
- }
-
- public static int gluBuild3DMipmapLevels( GL gl, int target, int internalFormat,
- int width, int height, int depth, int format, int type, int userLevel,
- int baseLevel, int maxLevel, ByteBuffer data ) {
- int level, levels;
-
- int rc = checkMipmapArgs( internalFormat, format, type );
- if( rc != 0 ) {
- return( rc );
- }
-
- if( width < 1 || height < 1 || depth < 1 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- if( type == GL.GL_BITMAP ) {
- return( GLU.GLU_INVALID_ENUM );
- }
-
- levels = computeLog( width );
- level = computeLog( height );
- if( level > levels ) {
- levels = level;
- }
- level = computeLog( depth );
- if( level > levels ) {
- levels = level;
- }
-
- levels += userLevel;
- if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- return( BuildMipmap.gluBuild3DMipmapLevelsCore( gl, target, internalFormat, width,
- height, depth, width, height, depth, format, type, userLevel,
- baseLevel, maxLevel, data ) );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/PixelStorageModes.java b/src/net/java/games/jogl/impl/mipmap/PixelStorageModes.java
deleted file mode 100644
index cc3b4ed47..000000000
--- a/src/net/java/games/jogl/impl/mipmap/PixelStorageModes.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-/**
- *
- * @author Administrator
- */
-public class PixelStorageModes {
-
- /**
- * Holds value of property packAlignment.
- */
- private int packAlignment;
-
- /**
- * Holds value of property packRowLength.
- */
- private int packRowLength;
-
- /**
- * Holds value of property packSkipRows.
- */
- private int packSkipRows;
-
- /**
- * Holds value of property packSkipPixels.
- */
- private int packSkipPixels;
-
- /**
- * Holds value of property packLsbFirst.
- */
- private boolean packLsbFirst;
-
- /**
- * Holds value of property packSwapBytes.
- */
- private boolean packSwapBytes;
-
- /**
- * Holds value of property packSkipImages.
- */
- private int packSkipImages;
-
- /**
- * Holds value of property packImageHeight.
- */
- private int packImageHeight;
-
- /**
- * Holds value of property unpackAlignment.
- */
- private int unpackAlignment;
-
- /**
- * Holds value of property unpackRowLength.
- */
- private int unpackRowLength;
-
- /**
- * Holds value of property unpackSkipRows.
- */
- private int unpackSkipRows;
-
- /**
- * Holds value of property unpackSkipPixels.
- */
- private int unpackSkipPixels;
-
- /**
- * Holds value of property unpackLsbFirst.
- */
- private boolean unpackLsbFirst;
-
- /**
- * Holds value of property unpackSwapBytes.
- */
- private boolean unpackSwapBytes;
-
- /**
- * Holds value of property unpackSkipImages.
- */
- private int unpackSkipImages;
-
- /**
- * Holds value of property unpackImageHeight.
- */
- private int unpackImageHeight;
-
- /** Creates a new instance of PixelStorageModes */
- public PixelStorageModes() {
- }
-
- /**
- * Getter for property packAlignment.
- * @return Value of property packAlignment.
- */
- public int getPackAlignment() {
-
- return this.packAlignment;
- }
-
- /**
- * Setter for property packAlignment.
- * @param packAlignment New value of property packAlignment.
- */
- public void setPackAlignment(int packAlignment) {
-
- this.packAlignment = packAlignment;
- }
-
- /**
- * Getter for property packRowLength.
- * @return Value of property packRowLength.
- */
- public int getPackRowLength() {
-
- return this.packRowLength;
- }
-
- /**
- * Setter for property packRowLength.
- * @param packRowLength New value of property packRowLength.
- */
- public void setPackRowLength(int packRowLength) {
-
- this.packRowLength = packRowLength;
- }
-
- /**
- * Getter for property packSkipRows.
- * @return Value of property packSkipRows.
- */
- public int getPackSkipRows() {
-
- return this.packSkipRows;
- }
-
- /**
- * Setter for property packSkipRows.
- * @param packSkipRows New value of property packSkipRows.
- */
- public void setPackSkipRows(int packSkipRows) {
-
- this.packSkipRows = packSkipRows;
- }
-
- /**
- * Getter for property packSkipPixels.
- * @return Value of property packSkipPixels.
- */
- public int getPackSkipPixels() {
-
- return this.packSkipPixels;
- }
-
- /**
- * Setter for property packSkipPixels.
- * @param packSkipPixels New value of property packSkipPixels.
- */
- public void setPackSkipPixels(int packSkipPixels) {
-
- this.packSkipPixels = packSkipPixels;
- }
-
- /**
- * Getter for property packLsbFirst.
- * @return Value of property packLsbFirst.
- */
- public boolean getPackLsbFirst() {
-
- return this.packLsbFirst;
- }
-
- /**
- * Setter for property packLsbFirst.
- * @param packLsbFirst New value of property packLsbFirst.
- */
- public void setPackLsbFirst(boolean packLsbFirst) {
-
- this.packLsbFirst = packLsbFirst;
- }
-
- /**
- * Getter for property packSwapBytes.
- * @return Value of property packSwapBytes.
- */
- public boolean getPackSwapBytes() {
-
- return this.packSwapBytes;
- }
-
- /**
- * Setter for property packSwapBytes.
- * @param packSwapBytes New value of property packSwapBytes.
- */
- public void setPackSwapBytes(boolean packSwapBytes) {
-
- this.packSwapBytes = packSwapBytes;
- }
-
- /**
- * Getter for property packSkipImages.
- * @return Value of property packSkipImages.
- */
- public int getPackSkipImages() {
-
- return this.packSkipImages;
- }
-
- /**
- * Setter for property packSkipImages.
- * @param packSkipImages New value of property packSkipImages.
- */
- public void setPackSkipImages(int packSkipImages) {
-
- this.packSkipImages = packSkipImages;
- }
-
- /**
- * Getter for property packImageHeight.
- * @return Value of property packImageHeight.
- */
- public int getPackImageHeight() {
-
- return this.packImageHeight;
- }
-
- /**
- * Setter for property packImageHeight.
- * @param packImageHeight New value of property packImageHeight.
- */
- public void setPackImageHeight(int packImageHeight) {
-
- this.packImageHeight = packImageHeight;
- }
-
- /**
- * Getter for property unpackAlignment.
- * @return Value of property unpackAlignment.
- */
- public int getUnpackAlignment() {
-
- return this.unpackAlignment;
- }
-
- /**
- * Setter for property unpackAlignment.
- * @param unpackAlignment New value of property unpackAlignment.
- */
- public void setUnpackAlignment(int unpackAlignment) {
-
- this.unpackAlignment = unpackAlignment;
- }
-
- /**
- * Getter for property unpackRowLength.
- * @return Value of property unpackRowLength.
- */
- public int getUnpackRowLength() {
-
- return this.unpackRowLength;
- }
-
- /**
- * Setter for property unpackRowLength.
- * @param unpackRowLength New value of property unpackRowLength.
- */
- public void setUnpackRowLength(int unpackRowLength) {
-
- this.unpackRowLength = unpackRowLength;
- }
-
- /**
- * Getter for property unpackSkipRows.
- * @return Value of property unpackSkipRows.
- */
- public int getUnpackSkipRows() {
-
- return this.unpackSkipRows;
- }
-
- /**
- * Setter for property unpackSkipRows.
- * @param unpackSkipRows New value of property unpackSkipRows.
- */
- public void setUnpackSkipRows(int unpackSkipRows) {
-
- this.unpackSkipRows = unpackSkipRows;
- }
-
- /**
- * Getter for property unpackSkipPixels.
- * @return Value of property unpackSkipPixels.
- */
- public int getUnpackSkipPixels() {
-
- return this.unpackSkipPixels;
- }
-
- /**
- * Setter for property unpackSkipPixels.
- * @param unpackSkipPixels New value of property unpackSkipPixels.
- */
- public void setUnpackSkipPixels(int unpackSkipPixels) {
-
- this.unpackSkipPixels = unpackSkipPixels;
- }
-
- /**
- * Getter for property unpackLsbFirst.
- * @return Value of property unpackLsbFirst.
- */
- public boolean getUnpackLsbFirst() {
-
- return this.unpackLsbFirst;
- }
-
- /**
- * Setter for property unpackLsbFirst.
- * @param unpackLsbFirst New value of property unpackLsbFirst.
- */
- public void setUnpackLsbFirst(boolean unpackLsbFirst) {
-
- this.unpackLsbFirst = unpackLsbFirst;
- }
-
- /**
- * Getter for property unpackSwapBytes.
- * @return Value of property unpackSwapBytes.
- */
- public boolean getUnpackSwapBytes() {
-
- return this.unpackSwapBytes;
- }
-
- /**
- * Setter for property unpackSwapBytes.
- * @param unpackSwapBytes New value of property unpackSwapBytes.
- */
- public void setUnpackSwapBytes(boolean unpackSwapBytes) {
-
- this.unpackSwapBytes = unpackSwapBytes;
- }
-
- /**
- * Getter for property unpackSkipImages.
- * @return Value of property unpackSkipImages.
- */
- public int getUnpackSkipImages() {
-
- return this.unpackSkipImages;
- }
-
- /**
- * Setter for property unpackSkipImages.
- * @param unpackSkipImages New value of property unpackSkipImages.
- */
- public void setUnpackSkipImages(int unpackSkipImages) {
-
- this.unpackSkipImages = unpackSkipImages;
- }
-
- /**
- * Getter for property unpackImageHeight.
- * @return Value of property unpackImageHeight.
- */
- public int getUnpackImageHeight() {
-
- return this.unpackImageHeight;
- }
-
- /**
- * Setter for property unpackImageHeight.
- * @param unpackImageHeight New value of property unpackImageHeight.
- */
- public void setUnpackImageHeight(int unpackImageHeight) {
-
- this.unpackImageHeight = unpackImageHeight;
- }
-
-
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/ScaleInternal.java b/src/net/java/games/jogl/impl/mipmap/ScaleInternal.java
deleted file mode 100644
index 06c8e582f..000000000
--- a/src/net/java/games/jogl/impl/mipmap/ScaleInternal.java
+++ /dev/null
@@ -1,2381 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import net.java.games.jogl.GLU;
-import net.java.games.jogl.GL;
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class ScaleInternal {
-
- public static final float UINT_MAX = (float)(0x00000000FFFFFFFF);
-
- public static void scale_internal( int components, int widthin, int heightin,
- ShortBuffer datain, int widthout, int heightout, ShortBuffer dataout ) {
- float x, lowx, highx, convx, halfconvx;
- float y, lowy, highy, convy, halfconvy;
- float xpercent, ypercent;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, yint, xint, xindex, yindex;
- int temp;
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage( components, widthin, heightin, datain, dataout );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- halfconvx = convx / 2;
- halfconvy = convy / 2;
- for( i = 0; i < heightout; i++ ) {
- y = convy * ( i + 0.5f );
- if( heightin > heightout ) {
- highy = y + halfconvy;
- lowy = y - halfconvy;
- } else {
- highy = y + 0.5f;
- lowy = y - 0.5f;
- }
- for( j = 0; j < widthout; j++ ) {
- x = convx * ( j + 0.5f );
- if( widthin > widthout ) {
- highx = x + halfconvx;
- lowx = x - halfconvx;
- } else {
- highx = x + 0.5f;
- lowx = x - 0.5f;
- }
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
- area = 0.0f;
-
- y = lowy;
- yint = (int)Math.floor( y );
- while( y < highy ) {
- yindex = ( yint + heightin ) % heightin;
- if( highy < yint + 1 ) {
- ypercent = highy - y;
- } else {
- ypercent = yint + 1 - y;
- }
-
- x = lowx;
- xint = (int)Math.floor( x );
-
- while( x < highx ) {
- xindex = ( xint + widthin ) % widthin;
- if( highx < xint + 1 ) {
- xpercent = highx -x;
- } else {
- xpercent = xint + 1 - x;
- }
-
- percent = xpercent * ypercent;
- area += percent;
- temp = ( xindex + ( yindex * widthin) ) * components;
- for( k = 0; k < components; k++ ) {
- totals[k] += datain.get( temp + k ) * percent;
- }
-
- xint++;
- x = xint;
- }
- yint++;
- y = yint;
- }
-
- temp = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- // totals[] should be rounded in the case of enlarging an RGB
- // ramp when the type is 332 or 4444
- dataout.put( temp + k, (short)((totals[k] + 0.5f) / area) );
- }
- }
- }
- }
-
- public static void scale_internal_ubyte( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- ByteBuffer dataout, int element_size, int ysize, int group_size ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_ubyte( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size );
- return;
- }
- convy = (float)heightin / heightout;
- convx = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
-
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * y_percent;
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * y_percent;
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- float f = 0.0f;
- datain.position( left );
- f = ( 0x000000FF & datain.get() ) * ( 1.0f - lowx_float );
- datain.position( right );
- f += ( 0x000000FF & datain.get() ) * highx_float;
- totals[k] += f;
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * x_percent;
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * y_percent;
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() ) * percent;
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += ( 0x000000FF & datain.get() );
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (byte)(totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_byte( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- ByteBuffer dataout, int element_size, int ysize,
- int group_size ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_byte( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * y_percent;
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * y_percent;
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- float f = 0.0f;
- datain.position( left );
- f = datain.get() * ( 1 - lowx_float );
- datain.position( right );
- f += datain.get() * highx_float;
- totals[k] += f;
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * x_percent;
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * y_percent;
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get() * percent;
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- totals[k] += datain.get();
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (byte)(totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_ushort( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- ShortBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_ushort( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size, myswap_bytes );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & ((int)Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ))) * percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort() ) * percent;
- }
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & ((int)Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ))) * y_percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort()) * y_percent;
- }
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & (Mipmap.GLU_SWAP_2_BYTES( datain.getShort() ))) * percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort()) * percent;
- }
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort() ) * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * y_percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort()) * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += ( 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * percent;
- } else {
- totals[k] += ( 0x0000FFFF & datain.getShort()) * percent;
- }
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- if( myswap_bytes ) {
- datain.position( left );
- float f = (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES(datain.getShort())) * ( 1 - lowx_float );
- datain.position( right );
- f += ((0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES(datain.getShort())) * highx_float);
- totals[k] += f;
- } else {
- datain.position( left );
- float f = ((0x0000FFFF & datain.getShort()) * ( 1 - lowx_float ));
- datain.position( right );
- f += ((0x0000FFFF & datain.getShort()) * highx_float);
- totals[k] += f;
- }
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() )) * percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * percent;
- }
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * x_percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * x_percent;
- }
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort() )) * percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * percent;
- }
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * y_percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * percent;
- }
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()) ) * percent;
- } else {
- totals[k] += (0x0000FFFF & datain.getShort()) * percent;
- }
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( datain.getShort()));
- } else {
- totals[k] += (0x0000FFFF & datain.getShort());
- }
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (short)(totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_short( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- ShortBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- int swapbuf; // unsigned buffer
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_short( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size, myswap_bytes );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getShort() * y_percent;
- }
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getShort() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- if( myswap_bytes ) {
- datain.position( left );
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * ( 1 - lowx_float );
- datain.position( right );
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * highx_float;
- } else {
- datain.position( left );
- totals[k] += datain.getShort() * ( 1 - lowx_float );
- datain.position( right );
- totals[k] += datain.getShort() * highx_float;
- }
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort());
- totals[k] += swapbuf * x_percent;
- } else {
- totals[k] += datain.getShort() * x_percent;
- }
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getShort() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getShort() * percent;
- }
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_2_BYTES( datain.getShort() );
- totals[k] += swapbuf;
- } else {
- totals[k] += datain.getShort();
- }
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (short)(totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_uint( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- IntBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_uint( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size, myswap_bytes );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * y_percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * y_percent;
- }
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * y_percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()) ) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- if( myswap_bytes ) {
- datain.position( left );
- totals[k] += ((0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES(datain.getInt())) * ( 1 - lowx_float ));
- datain.position( right );
- totals[k] += ((0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES(datain.getInt())) * highx_float);
- } else {
- datain.position( left );
- totals[k] += ((0x00000000FFFFFFFF & datain.getInt()) * ( 1 - lowx_float ));
- datain.position( right );
- totals[k] += ((0x00000000FFFFFFFF & datain.getInt()) * highx_float);
- }
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * x_percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * x_percent;
- }
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * y_percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- long tempInt0 = ( 0xFFFFFFFFL & datain.getInt( temp_index ) );
- datain.position( temp_index );
- long tempInt1 = ( 0xFFFFFFFFL & datain.getInt() );
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt())) * percent;
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
- }
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- totals[k] += (0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( datain.getInt()));
- } else {
- totals[k] += (0x00000000FFFFFFFF & datain.getInt());
- }
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- float value = 0.0f;
- for( k = 0; k < components; k++ ) {
- value = totals[k] / area;
- dataout.position( outindex + k );
- if( value >= UINT_MAX ) {
- dataout.put( (int)value );
- } else {
- dataout.put( (int)(totals[k] / area) );
- }
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_int( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- IntBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- long swapbuf; // unsigned buffer
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_int( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size, myswap_bytes );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getInt() * y_percent;
- }
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getInt() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- if( myswap_bytes ) {
- datain.position( left );
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * ( 1 - lowx_float );
- datain.position( right );
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * highx_float;
- } else {
- datain.position( left );
- totals[k] += (datain.getInt() * ( 1 - lowx_float ));
- datain.position( right );
- totals[k] += (datain.getInt() * highx_float);
- }
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * x_percent;
- } else {
- totals[k] += datain.getInt() * x_percent;
- }
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getInt() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getInt() * percent;
- }
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getInt() );
- totals[k] += swapbuf;
- } else {
- totals[k] += datain.getInt();
- }
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (int)(totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scale_internal_float( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- FloatBuffer dataout, int element_size, int ysize,
- int group_size, boolean myswap_bytes ) {
- float x, convx;
- float y, convy;
- float percent;
- // Max components in a format is 4, so...
- float[] totals = new float[4];
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outindex;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- float swapbuf; // unsigned buffer
-
- if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_float( components, widthin, heightin, datain, dataout,
- element_size, ysize, group_size, myswap_bytes );
- return;
- }
- convx = (float)heightin / heightout;
- convy = (float)widthin / widthout;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convy_float;
-
- for( i = 0; i < heightout; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightin)
- highy_int = heightin - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthout; j++ ) {
-
- // Ok, now apply box filter to box that goes from (lowx, lowy)
- // to (highx, highy) on input data into this pixel on output
- // data.
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // caulate the value for pixels in the 1st row
- xindex = lowx_int * group_size;
- if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * ysize;
- percent = y_percent * ( 1 - lowx_float );
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getFloat() * y_percent;
- }
- }
- }
- temp += group_size;
- right = temp;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
-
- // calculate the value for pixels in the last row
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getFloat() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
-
- // calculate the value for the pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += ysize;
- right += ysize;
- for( k = 0; k < components; k++, left += element_size, right += element_size ) {
- if( myswap_bytes ) {
- datain.position( left );
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * ( 1 - lowx_float );
- datain.position( right );
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * highx_float;
- } else {
- datain.position( left );
- totals[k] += (datain.getFloat() * ( 1 - lowx_float ));
- datain.position( right );
- totals[k] += (datain.getFloat() * highx_float);
- }
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float) * x_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * x_percent;
- } else {
- totals[k] += datain.getFloat() * x_percent;
- }
- }
- }
- percent = x_percent * highy_float;
- temp += ysize;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += group_size;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * y_percent;
- } else {
- totals[k] += datain.getFloat() * y_percent;
- }
- }
- }
- temp += group_size;
- percent = y_percent * highx_float;
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + (lowy_int * ysize);
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf * percent;
- } else {
- totals[k] += datain.getFloat() * percent;
- }
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- for( k = 0, temp_index = temp; k < components; k++, temp_index += element_size ) {
- datain.position( temp_index );
- if( myswap_bytes ) {
- swapbuf = Mipmap.GLU_SWAP_4_BYTES( datain.getFloat() );
- totals[k] += swapbuf;
- } else {
- totals[k] += datain.getFloat();
- }
- }
- temp += group_size;
- }
- temp0 += ysize;
- }
-
- outindex = ( j + ( i * widthout ) ) * components;
- for( k = 0; k < components; k++ ) {
- dataout.position( outindex + k );
- dataout.put( (totals[k] / area) );
- }
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- }
-
- public static void scaleInternalPackedPixel( int components, Extract extract,
- int widthIn, int heightIn, ByteBuffer dataIn, int widthOut,
- int heightOut, ByteBuffer dataOut, int pixelSizeInBytes,
- int rowSizeInBytes, boolean isSwap ) {
- float x, convx;
- float y, convy;
- float percent;
-
- // max components in a format is 4, so
- float[] totals = new float[4];
- float[] extractTotals = new float[4];
- float[] extractMoreTotals = new float[4];
- float[] shoveTotals = new float[4];
-
- float area;
- int i, j, k, xindex;
-
- int temp, temp0;
- int temp_index;
- int outIndex = 0;
-
- int lowx_int, highx_int, lowy_int, highy_int;
- float x_percent, y_percent;
- float lowx_float, highx_float, lowy_float, highy_float;
- float convy_float, convx_float;
- int convy_int, convx_int;
- int l, m;
- int left, right;
-
- if( widthIn == widthOut * 2 && heightIn == heightOut * 2 ) {
- HalveImage.halveImagePackedPixel( components, extract, widthIn, heightIn, dataIn, dataOut,
- pixelSizeInBytes, rowSizeInBytes, isSwap );
- return;
- }
- convy = (float)heightIn / (float)heightOut;
- convx = (float)widthIn / (float)widthOut;
- convy_int = (int)Math.floor( convy );
- convy_float = convy - convy_int;
- convx_int = (int)Math.floor( convx );
- convx_float = convx - convx_int;
-
- area = convx * convy;
-
- lowy_int = 0;
- lowy_float = 0.0f;
- highy_int = convy_int;
- highy_float = convx_float;
-
- for( i = 0; i < heightOut; i++ ) {
- // Clamp here to be sure we don't read beyond input buffer.
- if (highy_int >= heightIn)
- highy_int = heightIn - 1;
- lowx_int = 0;
- lowx_float = 0.0f;
- highx_int = convx_int;
- highx_float = convx_float;
-
- for( j = 0; j < widthOut; j++ ) {
- // ok now apply box filter to box that goes from( lowx, lowy )
- // to ( highx, highy ) on input data into this pixel on output data
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
- // calculate that value for pixels in the 1st row
- xindex = lowx_int * pixelSizeInBytes;
- if( (highy_int > lowy_int) && (highx_int > lowx_int) ) {
-
- y_percent = 1 - lowy_float;
- temp = xindex + lowy_int * rowSizeInBytes;
- percent = y_percent * ( 1 - lowx_float );
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- left = temp;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += pixelSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * y_percent;
- }
- }
- temp += pixelSizeInBytes;
- right = temp;
- percent = y_percent * highx_float;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- // calculate the value for pixels in the last row
-
- y_percent = highy_float;
- percent = y_percent * ( 1 - lowx_float );
- temp = xindex + highy_int * rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += pixelSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * y_percent;
- }
- }
- temp += pixelSizeInBytes;
- percent = y_percent * highx_float;
- dataIn.position( temp );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
-
- // calculate the value for pixels in the 1st and last column
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- left += rowSizeInBytes;
- right += rowSizeInBytes;
- dataIn.position( left );
- extract.extract( isSwap, dataIn, extractTotals );
- dataIn.position( right );
- extract.extract( isSwap, dataIn, extractMoreTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += ( extractTotals[k] * ( 1 - lowx_float ) + extractMoreTotals[k] * highx_float );
- }
- }
- } else if( highy_int > lowy_int ) {
- x_percent = highx_float - lowx_float;
- percent = ( 1 - lowy_float ) * x_percent;
- temp = xindex + lowy_int * rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp += rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * x_percent;
- }
- }
- percent = x_percent * highy_float;
- temp += rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- } else if( highx_int > lowx_int ) {
- y_percent = highy_float - lowy_float;
- percent = ( 1 - lowx_float ) * y_percent;
- temp = xindex + lowy_int * rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- temp += pixelSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * y_percent;
- }
- }
- temp += pixelSizeInBytes;
- percent = y_percent * highx_float;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- } else {
- percent = ( highy_float - lowy_float ) * ( highx_float - lowx_float );
- temp = xindex + lowy_int * rowSizeInBytes;
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- }
-
- // this is for the pixels in the body
- temp0 = xindex + pixelSizeInBytes + ( lowy_int + 1 ) * rowSizeInBytes;
- for( m = lowy_int + 1; m < highy_int; m++ ) {
- temp = temp0;
- for( l = lowx_int + 1; l < highx_int; l++ ) {
- dataIn.position( temp );
- extract.extract( isSwap, dataIn, extractTotals );
- for( k = 0; k < components; k++ ) {
- totals[k] += extractTotals[k] * percent;
- }
- temp += pixelSizeInBytes;
- }
- temp0 += rowSizeInBytes;
- }
-
- outIndex = ( j + ( i * widthOut ) );
- for( k = 0; k < components; k++ ) {
- shoveTotals[k] = totals[k] / area;
- }
- extract.shove( shoveTotals, outIndex, dataOut );
- lowx_int = highx_int;
- lowx_float = highx_float;
- highx_int += convx_int;
- highx_float += convx_float;
- if( highx_float > 1.0f ) {
- highx_float -= 1.0f;
- highx_int++;
- }
- }
- lowy_int = highy_int;
- lowy_float = highy_float;
- highy_int += convy_int;
- highy_float += convy_float;
- if( highy_float > 1.0f ) {
- highy_float -= 1.0f;
- highy_int++;
- }
- }
- assert( outIndex == ( widthOut * heightOut - 1) );
- }
-
- public static void scaleInternal3D( int components, int widthIn, int heightIn,
- int depthIn, ShortBuffer dataIn, int widthOut, int heightOut,
- int depthOut, ShortBuffer dataOut ) {
- float x, lowx, highx, convx, halfconvx;
- float y, lowy, highy, convy, halfconvy;
- float z, lowz, highz, convz, halfconvz;
- float xpercent, ypercent, zpercent;
- float percent;
- // max compnents in a format is 4
- float[] totals = new float[4];
- float volume;
- int i, j, d, k, zint, yint, xint, xindex, yindex, zindex;
- int temp;
-
- lowy = highy = lowx = highx = 0.0f;
-
- convz = (float)depthIn / depthOut;
- convy = (float)heightIn / heightOut;
- convx = (float)widthIn / widthOut;
- halfconvz = convz / 2.0f;
- halfconvy = convy / 2.0f;
- halfconvx = convx / 2.0f;
- for( d = 0; d < depthOut; d++ ) {
- z = convz * ( d + 0.5f );
- if( depthIn > depthOut ) {
- highz = z + halfconvz;
- lowz = z - halfconvz;
- } else {
- highz = z + 0.5f;
- lowz = z - 0.5f;
- }
- for( i = 0; i < heightOut; i++ ) {
- y = convy * ( i + 0.5f );
- if( heightIn > heightOut ) {
- highz = y + halfconvy;
- lowz = y - halfconvy;
- } else {
- highz = y + 0.5f;
- lowz = y - 0.5f;
- }
- for( j = 0; j < widthOut; j++ ) {
- x = convx * ( j + 0.5f );
- if( depthIn > depthOut ) {
- highz = x + halfconvx;
- lowz = x - halfconvx;
- } else {
- highz = x + 0.5f;
- lowz = x - 0.5f;
- }
-
- // Ok, now apply box filter to box that goes from ( lowx, lowy, lowz )
- // to ( highx, highy, highz ) on input data into this pixel on output data
-
- totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
- volume = 0.0f;
-
- z = lowz;
- zint = (int)(Math.floor( z ) );
- while( z < highz ) {
- zindex = ( zint + depthIn ) % depthIn;
- if( highz < zint + 1 ) {
- zpercent = highz - z;
- } else {
- zpercent = zint + 1 - z;
- }
-
- y = lowy;
- yint = (int)(Math.floor( y ) );
- while( y < highy ) {
- yindex = ( yint + heightIn ) % heightIn;
- if( highy < yint + 1 ) {
- ypercent = highy - y;
- } else {
- ypercent = yint + 1 - y;
- }
-
- x = lowx;
- xint = (int)(Math.floor( x ) );
-
- while( x < highx ) {
- xindex = (xint + widthIn ) % widthIn;
- if( highx < xint + 1 ) {
- xpercent = highx - x;
- } else {
- xpercent = xint + 1 - x;
- }
-
- percent = xpercent * ypercent * zpercent;
- volume += percent;
-
- temp = (xindex + ( yindex *widthIn) + (zindex * widthIn *heightIn)) * components;
- for( k = 0; k < components; k++ ) {
- assert( 0 <= (temp+k) && (temp+k) < (widthIn * heightIn * depthIn * components) );
- totals[k] += dataIn.get( temp + k ) * percent;
- }
- xint++;
- x = xint;
- } // while x
- yint++;
- y = yint;
- } // while y
- zint++;
- z = zint;
- } // while z
-
- temp = ( j + ( i * widthOut ) + (d * widthOut * heightOut ) ) * components;
- for( k = 0; k < components; k++ ) {
- // totals should be rounded in the case of enlarging an rgb ramp when the type is 332 or 4444
- assert( 0 <= ( temp + k ) && ( temp + k ) < (widthOut * heightOut* depthOut * components) );
- dataOut.put( temp + k, (short)((totals[k] + 0.5f) / volume ) );
- }
- }
- }
- }
- }
-
- public static int gluScaleImage3D( GL gl, int format, int widthIn, int heightIn,
- int depthIn, int typeIn, ByteBuffer dataIn, int widthOut, int heightOut,
- int depthOut, int typeOut, ByteBuffer dataOut ) {
- int components;
- ShortBuffer beforeImage, afterImage;
- PixelStorageModes psm = new PixelStorageModes();
-
- if( widthIn == 0 || heightIn == 0 || depthIn == 0 ||
- widthOut == 0 || heightOut == 0 || depthOut == 0 ) {
- return( 0 );
- }
-
- if( widthIn < 0 || heightIn < 0 || depthIn < 0 ||
- widthOut < 0 || heightOut < 0 || depthOut < 0 ) {
- return( GLU.GLU_INVALID_VALUE );
- }
-
- if( !Mipmap.legalFormat(format) || !Mipmap.legalType(typeIn) ||
- !Mipmap.legalType(typeOut) || typeIn == GL.GL_BITMAP ||
- typeOut == GL.GL_BITMAP ) {
- return( GLU.GLU_INVALID_ENUM );
- }
-
- if( !Mipmap.isLegalFormatForPackedPixelType( format, typeIn ) ) {
- return( GLU.GLU_INVALID_OPERATION );
- }
-
- if( !Mipmap.isLegalFormatForPackedPixelType( format, typeOut ) ) {
- return( GLU.GLU_INVALID_OPERATION );
- }
-
- try {
- beforeImage = ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn,
- heightIn, depthIn, format, GL.GL_UNSIGNED_SHORT ) ).order(
- ByteOrder.nativeOrder() ).asShortBuffer();
- afterImage = ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn,
- heightIn, depthIn, format, GL.GL_UNSIGNED_SHORT ) ).order(
- ByteOrder.nativeOrder() ).asShortBuffer();
- } catch( OutOfMemoryError err ) {
- return( GLU.GLU_OUT_OF_MEMORY );
- }
- Mipmap.retrieveStoreModes3D( gl, psm );
-
- Image.fillImage3D( psm, widthIn, heightIn, depthIn, format, typeIn,
- Mipmap.is_index( format ), dataIn, beforeImage );
- components = Mipmap.elements_per_group( format, 0 );
- ScaleInternal.scaleInternal3D( components, widthIn, heightIn, depthIn,
- beforeImage, widthOut, heightOut, depthOut, afterImage );
- Image.emptyImage3D( psm, widthOut, heightOut, depthOut, format, typeOut,
- Mipmap.is_index( format ), afterImage, dataOut );
-
- return( 0 );
- }
-}
diff --git a/src/net/java/games/jogl/impl/mipmap/Type_Widget.java b/src/net/java/games/jogl/impl/mipmap/Type_Widget.java
deleted file mode 100644
index f749d5348..000000000
--- a/src/net/java/games/jogl/impl/mipmap/Type_Widget.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.mipmap;
-
-import java.nio.*;
-
-/**
- *
- * @author Administrator
- */
-public class Type_Widget {
-
- ByteBuffer buffer;
-
- /** Creates a new instance of Type_Widget */
- public Type_Widget() {
- buffer = ByteBuffer.allocate( 4 );
- }
-
- public void setUB0( byte b ) {
- buffer.position( 0 );
- buffer.put( b );
- }
-
- public byte getUB0() {
- buffer.position( 0 );
- return( buffer.get() );
- }
-
- public void setUB1( byte b ) {
- buffer.position( 1 );
- buffer.put( b );
- }
-
- public byte getUB1() {
- buffer.position( 1 );
- return( buffer.get() );
- }
-
- public void setUB2( byte b ) {
- buffer.position( 2 );
- buffer.put( b );
- }
-
- public byte getUB2() {
- buffer.position( 2 );
- return( buffer.get() );
- }
-
- public void setUB3( byte b ) {
- buffer.position( 3 );
- buffer.put( b );
- }
-
- public byte getUB3() {
- buffer.position( 3 );
- return( buffer.get() );
- }
-
- public void setUS0( short s ) {
- buffer.position( 0 );
- buffer.putShort( s );
- }
-
- public short getUS0() {
- buffer.position( 0 );
- return( buffer.getShort() );
- }
-
- public void setUS1( short s ) {
- buffer.position( 2 );
- buffer.putShort( s );
- }
-
- public short getUS1() {
- buffer.position( 2 );
- return( buffer.getShort() );
- }
-
- public void setUI( int i ) {
- buffer.position( 0 );
- buffer.putInt( i );
- }
-
- public int getUI() {
- buffer.position( 0 );
- return( buffer.getInt() );
- }
-
- public void setB0( byte b ) {
- buffer.position( 0 );
- buffer.put( b );
- }
-
- public byte getB0() {
- buffer.position( 0 );
- return( buffer.get() );
- }
-
- public void setB1( byte b ) {
- buffer.position( 1 );
- buffer.put( b );
- }
-
- public byte getB1() {
- buffer.position( 1 );
- return( buffer.get() );
- }
-
- public void setB2( byte b ) {
- buffer.position( 2 );
- buffer.put( b );
- }
-
- public byte getB2() {
- buffer.position( 2 );
- return( buffer.get() );
- }
-
- public void setB3( byte b ) {
- buffer.position( 3 );
- buffer.put( b );
- }
-
- public byte getB3() {
- buffer.position( 3 );
- return( buffer.get() );
- }
-
- public void setS0( short s ) {
- buffer.position( 0 );
- buffer.putShort( s );
- }
-
- public short getS0() {
- buffer.position( 0 );
- return( buffer.getShort() );
- }
-
- public void setS1( short s ) {
- buffer.position( 2 );
- buffer.putShort( s );
- }
-
- public short getS1() {
- buffer.position( 2 );
- return( buffer.getShort() );
- }
-
- public void setI( int i ) {
- buffer.position( 0 );
- buffer.putInt( i );
- }
-
- public int getI() {
- buffer.position( 0 );
- return( buffer.getInt() );
- }
-
- public void setF( float f ) {
- buffer.position( 0 );
- buffer.putFloat( f );
- }
-
- public float getF() {
- buffer.position( 0 );
- return( buffer.getFloat() );
- }
-
- public ByteBuffer getBuffer() {
- buffer.rewind();
- return( buffer );
- }
-
- public static void main( String args[] ) {
- Type_Widget t = new Type_Widget();
- t.setI( 1000000 );
-
- System.out.println("int: " + Integer.toHexString( t.getI() ) );
-
- }
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/README-PORTING.txt b/src/net/java/games/jogl/impl/nurbs/README-PORTING.txt
deleted file mode 100755
index df5f41782..000000000
--- a/src/net/java/games/jogl/impl/nurbs/README-PORTING.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-This is a currently incomplete port of SGI's GLU NURBS library from
-C++ to Java. There are a few reasons for doing such a port:
-
- - The C interface is structured around function pointers. It is
- generally difficult to bind such interfaces up to Java.
-
- - Some people have reported crashes on certain Linux distributions
- when trying to use any routines out of the C GLU library. To date
- we have not been able to diagnose the root cause of these failures.
- Porting the code involved from C++ to Java has solved these
- problems.
-
-The port so far has been started in the internals/ directory. The C++
-sources have been gone through roughly alphabetically and
-transliterated into the appropriate files. The large Subdivider class
-was the current focus of attention at the time of this writing, and a
-closer look indicates that at least a few classes were skipped on the
-way down to some of the Subdivider's sources like intersect.cc. It may
-be a good idea to continue the port in this directory first, since it
-looks like the other directories' sources are built on top of these
-and it would be good to firm up the Java interfaces for the internals
-(and perhaps get the sources to compile) before porting lots of code
-built on top of them.
-
-A couple of notes on the translation:
-
- - All object pool classes have been removed. The intention is to have
- a static allocate() method on the appropriate classes which will
- instantiate populated arrays of these types (not just arrays of
- null references). See uses of TrimVertex.allocate().
-
- - There are a significant number of places in the original C++ code
- where pointer arithmetic is used. Some of these are not obvious
- until the code has been ported and examined. Bin.java was a good
- example of this where the algorithms needed some restructuring. At
- the time of this writing intersect.cc was in the process of being
- ported and it wasn't clear whether we would need to change some of
- the APIs or add more utility routines to be able to do pointer
- arithmetic on, for example, the TrimVertex arrays returned from the
- allocate() routine.
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/Arc.java b/src/net/java/games/jogl/impl/nurbs/internals/Arc.java
deleted file mode 100755
index 076c68b72..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/Arc.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-/* an arc, in two list, the trim list and bin */
-public class Arc {
- public static final int SIDE_NONE = 0;
- public static final int SIDE_RIGHT = 1;
- public static final int SIDE_TOP = 2;
- public static final int SIDE_LEFT = 3;
- public static final int SIDE_BOTTOM = 4;
-
- public static final int bezier_tag = (1 << 13);
- public static final int arc_tag = (1 << 3);
- public static final int tail_tag = (1 << 6);
- public Arc prev; /* trim list pointer */
- public Arc next; /* trim list pointer */
- public Arc link; /* bin pointers */
- public BezierArc bezierArc; /* associated bezier arc */
- public PwlArc pwlArc; /* associated pwl arc */
- public long type; /* curve type */
- public long nuid;
-
- private static final float ZERO = 0.00001f;
-
- public Arc(Arc j, PwlArc p) {
- pwlArc = p;
- type = j.type;
- nuid = j.nuid;
- }
-
- public Arc(int arcSide, long nuid) {
- type = 0;
- setside(arcSide);
- this.nuid = nuid;
- }
-
- public Arc append(Arc jarc) {
- if ( jarc != null ) {
- next = jarc.next;
- prev = jarc;
- next.prev = prev.next = this;
- } else {
- next = prev = this;
- }
- return this;
- }
-
- public boolean check() {
- Arc jarc = this;
- do {
- assert( (jarc.pwlArc != null) || (jarc.bezierArc != null) );
-
- if (jarc.prev == 0 || jarc.next == 0) {
- System.out.println( "checkjarc:null next/prev pointer");
- jarc.print( );
- return false;
- }
-
- if (jarc.next.prev != jarc) {
- System.out.println( "checkjarc: pointer linkage screwed up");
- jarc.print( );
- return false;
- }
-
- if( jarc.pwlArc != null ) {
- assert( jarc.pwlArc.npts >= 1 );
- assert( jarc.pwlArc.npts < 100000 );
- if( jarc.prev.pwlArc != null ) {
- if( jarc.tail()[1] != jarc.prev.rhead()[1] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 1");
- jarc.prev.show();
- jarc.show();
- return false;
- }
- if( jarc.tail()[0] != jarc.prev.rhead()[0] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 2");
- jarc.prev.show();
- jarc.show();
- return false;
- }
- }
- if( jarc.next.pwlArc ) {
- if( jarc.next.tail()[0] != jarc.rhead()[0] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 3");
- jarc.show();
- jarc.next.show();
- return false;
- }
- if( jarc.next.tail()[1] != jarc.rhead()[1] ) {
- System.out.println( "checkjarc: geometric linkage screwed up 4");
- jarc.show();
- jarc.next.show();
- return false;
- }
- }
- if( jarc.isbezier() ) {
- assert( jarc.pwlArc.npts == 2 );
- assert( (jarc.pwlArc.pts[0].param[0] ==
- jarc.pwlArc.pts[1].param[0]) ||
- (jarc.pwlArc.pts[0].param[1] ==
- jarc.pwlArc.pts[1].param[1]) );
- }
- }
- jarc = jarc.next;
- } while (jarc != this);
- return true;
- }
-
- /**
- * Checks if tail of arc and head of prev meet.
- */
- public boolean isDisconnected() {
- if( pwlArc == 0 ) return 0;
- if( prev.pwlArc == 0 ) return 0;
-
- float[] p0 = tail();
- float[] p1 = prev.rhead();
-
- if( ((p0[0] - p1[0]) > ZERO) || ((p1[0] - p0[0]) > ZERO) ||
- ((p0[1] - p1[1]) > ZERO) || ((p1[1] - p0[1]) > ZERO) ) {
- return true;
- } else {
- /* average two points together */
- p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5f;
- p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5f;
- return false;
- }
- }
-
- /**
- * Counts number of points on arc loop.
- */
- public int numpts( ) {
- Arc jarc = this;
- int npts = 0;
- do {
- npts += jarc.pwlArc.npts;
- jarc = jarc.next;
- } while( jarc != this );
- return npts;
- }
-
- /**
- * Marks each point with id of arc.
- */
- public void markverts( void ) {
- Arc jarc = this;
-
- do {
- TrimVertex p = jarc.pwlArc.pts;
- for( int i=0; i<jarc.pwlArc.npts; i++ )
- p[i].nuid = jarc.nuid;
- jarc = jarc.next;
- } while( jarc != this );
- }
-
- /**
- * Finds axis extrema on arc loop.
- */
- public void getextrema( Arc[4] ) {
- float leftpt, botpt, rightpt, toppt;
-
- extrema[0] = extrema[1] = extrema[2] = extrema[3] = this;
-
- leftpt = rightpt = this.tail()[0];
- botpt = toppt = this.tail()[1];
-
- for( Arc jarc = this.next; jarc != this; jarc = jarc.next ) {
- if ( jarc.tail()[0] < leftpt ||
- (jarc.tail()[0] <= leftpt && jarc.rhead()[0]<=leftpt)) {
- leftpt = jarc.pwlArc.pts.param[0];
- extrema[1] = jarc;
- }
- if ( jarc.tail()[0] > rightpt ||
- (jarc.tail()[0] >= rightpt && jarc.rhead()[0] >= rightpt)) {
- rightpt = jarc.pwlArc.pts.param[0];
- extrema[3] = jarc;
- }
- if ( jarc.tail()[1] < botpt ||
- (jarc.tail()[1] <= botpt && jarc.rhead()[1] <= botpt )) {
- botpt = jarc.pwlArc.pts.param[1];
- extrema[2] = jarc;
- }
- if ( jarc.tail()[1] > toppt ||
- (jarc.tail()[1] >= toppt && jarc.rhead()[1] >= toppt)) {
- toppt = jarc.pwlArc.pts.param[1];
- extrema[0] = jarc;
- }
- }
- }
-
- /**
- * Prints out the vertices of all pwl arcs on a loop.
- */
- public void print( ) {
- Arc jarc = this;
-
- do {
- jarc.show( );
- jarc = jarc.next;
- } while (jarc != this);
- }
-
- public void show( ) {
- System.out.println( "\tPWLARC NP: " + pwlArc.npts + " FL: 1");
- for( int i = 0; i < pwlArc.npts; i++ ) {
- System.out.println( "\t\tVERTEX " + pwlArc.pts[i].param[0] + " " +
- pwlArc.pts[i].param[1] );
- }
- }
-
- /**
- * Attaches a pwl arc to an arc and mark it as a border arc.
- */
- public void makeSide( PwlArc pwl, int arcSide ) {
- assert( pwl != 0);
- assert( pwlArc == 0 );
- assert( pwl.npts > 0 );
- assert( pwl.pts != 0);
- pwlArc = pwl;
- clearbezier();
- setside( arcSide );
- }
-
- public boolean isTessellated() { return (pwlArc != null); }
- public boolean isbezier() { return (type & bezier_tag) != 0; }
- public void setbezier() { type |= bezier_tag; }
- public void clearbezier() { type &= ~bezier_tag; }
- public long npts() { return pwlArc.npts; }
- public TrimVertex[] pts() { return pwlArc.pts; }
- public float[] tail() { return pwlArc.pts[0].param; }
- public float[] head() { return next.pwlArc.pts[0].param; }
- public float[] rhead() { return pwlArc.pts[pwlArc.npts-1].param; }
- public long ismarked() { return type & arc_tag; }
- public void setmark() { type |= arc_tag; }
- public void clearmark() { type &= (~arc_tag); }
- public void clearside() { type &= ~(0x7 << 8); }
- public void setside( int arcSide ) { clearside(); type |= (((long)arcSide)<<8); }
- public int getside() { return ((type>>8) & 0x7); }
- public int getitail() { return type & tail_tag; }
- public void setitail() { type |= tail_tag; }
- public void clearitail() { type &= (~tail_tag); }
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/ArcTesselator.java b/src/net/java/games/jogl/impl/nurbs/internals/ArcTesselator.java
deleted file mode 100755
index cb77dfbd0..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/ArcTesselator.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class ArcTessellator {
- /**
- * Constructs a bezier arc and attaches it to an Arc.
- */
- public void bezier( Arc arc, float s1, float s2, float t1, float t2 ) {
- assert( arc != null );
- assert( ! arc.isTessellated() );
-
- switch( arc.getside() ) {
- case Arc.SIDE_LEFT:
- assert( s1 == s2 );
- assert( t2 < t1 );
- break;
- case Arc.SIDE_RIGHT:
- assert( s1 == s2 );
- assert( t1 < t2 );
- break;
- case Arc.SIDE_TOP:
- assert( t1 == t2 );
- assert( s2 < s1 );
- break;
- case Arc.SIDE_BOTTOM:
- assert( t1 == t2 );
- assert( s1 < s2 );
- break;
- case Arc.SIDE_NONE:
- throw new InternalError();
- break;
- }
-
- TrimVertex[] p = TrimVertex.allocate(2);
- arc.pwlArc = new PwlArc( p );
- p[0].param[0] = s1;
- p[0].param[1] = t1;
- p[1].param[0] = s2;
- p[1].param[1] = t2;
- assert( (s1 == s2) || (t1 == t2) );
- arc.setbezier();
- }
-
- /**
- * Constructs a pwl arc and attaches it to an arc.
- */
- public void pwl( Arc arc, float s1, float s2, float t1, float t2, float rate ) {
- int snsteps = 1 + (int) (Math.abs(s2 - s1) / rate );
- int tnsteps = 1 + (int) (Math.abs(t2 - t1) / rate );
- int nsteps = (int) Math.max(1, Math.max( snsteps, tnsteps ));
-
- float sstepsize = (s2 - s1) / (float) nsteps;
- float tstepsize = (t2 - t1) / (float) nsteps;
- TrimVertex[] newvert = TrimVertex.allocate( nsteps+1 );
- long i;
- for( i = 0; i < nsteps; i++ ) {
- newvert[i].param[0] = s1;
- newvert[i].param[1] = t1;
- s1 += sstepsize;
- t1 += tstepsize;
- }
- newvert[i].param[0] = s2;
- newvert[i].param[1] = t2;
-
- arc.pwlArc = new PwlArc( newvert );
-
- arc.clearbezier();
- arc.clearside( );
- }
-
- /**
- * Constructs a left boundary pwl arc and attaches it to an arc.
- */
- public void pwl_left( Arc arc, float s, float t1, float t2, float rate ) {
- assert( t2 < t1 );
-
- int nsteps = steps_function(t1, t2, rate);
-
- float stepsize = (t1 - t2) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( nsteps+1 );
- int i;
- for( i = nsteps; i > 0; i-- ) {
- newvert[i].param[0] = s;
- newvert[i].param[1] = t2;
- t2 += stepsize;
- }
- newvert[i].param[0] = s;
- newvert[i].param[1] = t1;
-
- arc.makeSide( new PwlArc( newvert ), Arc.SIDE_LEFT );
- }
-
- /**
- * Constructs a right boundary pwl arc and attaches it to an arc.
- */
- public void pwl_right( Arc arc, float s, float t1, float t2, float rate ) {
- assert( t1 < t2 );
-
- int nsteps = steps_function(t2,t1,rate);
- float stepsize = (t2 - t1) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( nsteps+1 );
- int i;
- for( i = 0; i < nsteps; i++ ) {
- newvert[i].param[0] = s;
- newvert[i].param[1] = t1;
- t1 += stepsize;
- }
- newvert[i].param[0] = s;
- newvert[i].param[1] = t2;
-
- arc.makeSide( new PwlArc( newvert ), Arc.SIDE_RIGHT );
- }
-
- /**
- * Constructs a top boundary pwl arc and attaches it to an arc.
- */
- public void pwl_top( Arc arc, float t, float s1, float s2, float rate ) {
- assert( s2 < s1 );
-
- int nsteps = steps_function(s1,s2,rate);
- float stepsize = (s1 - s2) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( nsteps+1 );
- int i;
- for( i = nsteps; i > 0; i-- ) {
- newvert[i].param[0] = s2;
- newvert[i].param[1] = t;
- s2 += stepsize;
- }
- newvert[i].param[0] = s1;
- newvert[i].param[1] = t;
-
- arc.makeSide( new PwlArc( newvert ), Arc.SIDE_TOP );
- }
-
- /**
- * Constructs a bottom boundary pwl arc and attaches it to an arc.
- */
- public void pwl_bottom( Arc arc, float t, float s1, float s2, float rate ) {
- assert( s1 < s2 );
-
- int nsteps = steps_function(s2,s1,rate);
- float stepsize = (s2 - s1) / (float) nsteps;
-
- TrimVertex[] newvert = TrimVertex.allocate( nsteps+1 );
- int i;
- for( i = 0; i < nsteps; i++ ) {
- newvert[i].param[0] = s1;
- newvert[i].param[1] = t;
- s1 += stepsize;
- }
- newvert[i].param[0] = s2;
- newvert[i].param[1] = t;
-
- arc.makeSide( new PwlArc( newvert ), Arc.SIDE_BOTTOM );
- }
-
- /**
- * Constucts a linear pwl arc and attaches it to an Arc.
- */
- public void tessellateLinear( Arc arc, float geo_stepsize, float arc_stepsize, boolean isrational ) {
- assert( arc.pwlArc == null );
- float s1, s2, t1, t2;
-
- //we don't need to scale by arc_stepsize if the trim curve
- //is piecewise linear. Reason: In pwl_right, pwl_left, pwl_top, pwl_left,
- //and pwl, the nsteps is computed by deltaU (or V) /stepsize.
- //The quantity deltaU/arc_stepsize doesn't have any meaning. And
- //it causes problems: see bug 517641
- float stepsize = geo_stepsize; /* * arc_stepsize*/;
-
- BezierArc b = arc.bezierArc;
-
- if( isrational ) {
- s1 = b.cpts[0] / b.cpts[2];
- t1 = b.cpts[1] / b.cpts[2];
- s2 = b.cpts[b.stride+0] / b.cpts[b.stride+2];
- t2 = b.cpts[b.stride+1] / b.cpts[b.stride+2];
- } else {
- s1 = b.cpts[0];
- t1 = b.cpts[1];
- s2 = b.cpts[b.stride+0];
- t2 = b.cpts[b.stride+1];
- }
- if( s1 == s2 )
- if( t1 < t2 )
- pwl_right( arc, s1, t1, t2, stepsize );
- else
- pwl_left( arc, s1, t1, t2, stepsize );
- else if( t1 == t2 )
- if( s1 < s2 )
- pwl_bottom( arc, t1, s1, s2, stepsize );
- else
- pwl_top( arc, t1, s1, s2, stepsize );
- else
- pwl( arc, s1, s2, t1, t2, stepsize );
- }
-
- /**
- * Constucts a nonlinear pwl arc and attaches it to an Arc.
- */
- public void tessellateNonlinear( Arc arc, float geo_stepsize, float arc_stepsize, int isrational ) {
- assert( arc.pwlArc == null );
-
- float stepsize = geo_stepsize * arc_stepsize;
-
- BezierArc *bezierArc = arc.bezierArc;
-
- float size; //bounding box size of the curve in UV
- {
- int i,j;
- float min_u, min_v, max_u,max_v;
- min_u = max_u = bezierArc.cpts[0];
- min_v = max_v = bezierArc.cpts[1];
- for(i=1, j=2; i<bezierArc.order; i++, j+= bezierArc.stride)
- {
- if(bezierArc.cpts[j] < min_u)
- min_u = bezierArc.cpts[j];
- if(bezierArc.cpts[j] > max_u)
- max_u = bezierArc.cpts[j];
- if(bezierArc.cpts[j+1] < min_v)
- min_v = bezierArc.cpts[j+1];
- if(bezierArc.cpts[j+1] > max_v)
- max_v = bezierArc.cpts[j+1];
- }
-
- size = max_u - min_u;
- if(size < max_v - min_v)
- size = max_v - min_v;
- }
-
- /*int nsteps = 1 + (int) (1.0/stepsize);*/
-
- int nsteps = (int) (size/stepsize);
- if(nsteps <=0)
- nsteps=1;
-
- TrimVertex[] vert = TrimVertex.allocate( nsteps+1 );
- float dp = 1.0/nsteps;
- int vi = 0; // vertIdx
-
- arc.pwlArc = new PwlArc();
- arc.pwlArc.pts = vert;
-
- if( isrational ) {
- float[] pow_u = new float[Defines.MAXORDER];
- float[] pow_v = new float[Defines.MAXORDER];
- float[] pow_w = new float[Defines.MAXORDER];
- trim_power_coeffs( bezierArc, pow_u, 0 );
- trim_power_coeffs( bezierArc, pow_v, 1 );
- trim_power_coeffs( bezierArc, pow_w, 2 );
-
- /* compute first point exactly */
- float[] b = bezierArc.cpts;
- vert[vi].param[0] = b[0]/b[2];
- vert[vi].param[1] = b[1]/b[2];
-
- /* strength reduction on p = dp * step would introduce error */
- long order = bezierArc.order;
- for( int step=1, ++vi; step<nsteps; step++, vi++ ) {
- float p = dp * step;
- float u = pow_u[0];
- float v = pow_v[0];
- float w = pow_w[0];
- for( int i = 1; i < order; i++ ) {
- u = u * p + pow_u[i];
- v = v * p + pow_v[i];
- w = w * p + pow_w[i];
- }
- vert[vi].param[0] = u/w;
- vert[vi].param[1] = v/w;
- }
-
- /* compute last point exactly */
- b += (order - 1) * bezierArc.stride;
- vert[vi].param[0] = b[0]/b[2];
- vert[vi].param[1] = b[1]/b[2];
-
- } else {
- float[] pow_u = new float[Defines.MAXORDER];
- float[] pow_v = new float[Defines.MAXORDER];
- trim_power_coeffs( bezierArc, pow_u, 0 );
- trim_power_coeffs( bezierArc, pow_v, 1 );
-
- /* compute first point exactly */
- float[] b = bezierArc.cpts;
- vert[vi].param[0] = b[0];
- vert[vi].param[1] = b[1];
-
- /* strength reduction on p = dp * step would introduce error */
- long order = bezierArc.order;
- for( int step=1, ++vi; step<nsteps; step++, vi++ ) {
- float p = dp * step;
- float u = pow_u[0];
- float v = pow_v[0];
- for( int i = 1; i < bezierArc.order; i++ ) {
- u = u * p + pow_u[i];
- v = v * p + pow_v[i];
- }
- vert[vi].param[0] = u;
- vert[vi].param[1] = v;
- }
-
- /* compute last point exactly */
- b += (order - 1) * bezierArc.stride;
- vert[vi].param[0] = b[0];
- vert[vi].param[1] = b[1];
- }
- arc.pwlArc.npts = vi + 1;
- }
-
- private static final float gl_Bernstein[][Defines.MAXORDER][Defines.MAXORDER] = {
- {
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {-1, 1, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {1, -2, 1, 0, 0, 0, 0, 0 },
- {-2, 2, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {-1, 3, -3, 1, 0, 0, 0, 0 },
- {3, -6, 3, 0, 0, 0, 0, 0 },
- {-3, 3, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {1, -4, 6, -4, 1, 0, 0, 0 },
- {-4, 12, -12, 4, 0, 0, 0, 0 },
- {6, -12, 6, 0, 0, 0, 0, 0 },
- {-4, 4, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {-1, 5, -10, 10, -5, 1, 0, 0 },
- {5, -20, 30, -20, 5, 0, 0, 0 },
- {-10, 30, -30, 10, 0, 0, 0, 0 },
- {10, -20, 10, 0, 0, 0, 0, 0 },
- {-5, 5, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {1, -6, 15, -20, 15, -6, 1, 0 },
- {-6, 30, -60, 60, -30, 6, 0, 0 },
- {15, -60, 90, -60, 15, 0, 0, 0 },
- {-20, 60, -60, 20, 0, 0, 0, 0 },
- {15, -30, 15, 0, 0, 0, 0, 0 },
- {-6, 6, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 },
- {0, 0, 0, 0, 0, 0, 0, 0 }
- },
- {
- {-1, 7, -21, 35, -35, 21, -7, 1 },
- {7, -42, 105, -140, 105, -42, 7, 0 },
- {-21, 105, -210, 210, -105, 21, 0, 0 },
- {35, -140, 210, -140, 35, 0, 0, 0 },
- {-35, 105, -105, 35, 0, 0, 0, 0 },
- {21, -42, 21, 0, 0, 0, 0, 0 },
- {-7, 7, 0, 0, 0, 0, 0, 0 },
- {1, 0, 0, 0, 0, 0, 0, 0 }
- }
- };
-
- /**
- * Computes power basis coefficients from bezier coeffients.
- */
- private static void trim_power_coeffs( BezierArc bez_arc, float[] p, int coord ) {
- int stride = bez_arc.stride;
- int order = bez_arc.order;
- float[] base = bez_arc.cpts;
- int baseIdx = coord;
-
- float[][] mat = gl_Bernstein[order-1];
-
- for (int i = 0; i < order; i++) {
- float[] row = mat[i];
- float s = 0.0f;
- int pointIdx = baseIdx;
- for (int j = 0; j < order; j++, pointIdx += stride) {
- s += row[j] * base[pointIdx];
- }
- p[i] = s;
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/Backend.java b/src/net/java/games/jogl/impl/nurbs/internals/Backend.java
deleted file mode 100755
index e99822f0b..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/Backend.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class Backend {
- private BasicCurveEvaluator curveEvaluator;
- private BasicSurfaceEvaluator surfaceEvaluator;
-
- public Backend( BasicCurveEvaluator c, BasicSurfaceEvaluator e ) {
- this.c = c;
- this.e = e;
- }
-
- /* surface backend routines */
-
- /**
- * bgnsurf - preamble to surface definition and evaluations
- */
- public void bgnsurf( boolean wiretris, boolean wirequads, long nuid ) {
- wireframetris = wiretris;
- wireframequads = wirequads;
-
- /*in the spec, GLU_DISPLAY_MODE is either
- * GLU_FILL
- * GLU_OUTLINE_POLY
- * GLU_OUTLINE_PATCH.
- *In fact, GLU_FLL is has the same effect as
- * set GL_FRONT_AND_BACK to be GL_FILL
- * and GLU_OUTLINE_POLY is the same as set
- * GL_FRONT_AND_BACK to be GL_LINE
- *It is more efficient to do this once at the beginning of
- *each surface than to do it for each primitive.
- * The internal has more options: outline_triangle and outline_quad
- *can be seperated. But since this is not in spec, and more importantly,
- *this is not so useful, so we don't need to keep this option.
- */
-
- surfaceEvaluator.bgnmap2f( nuid );
-
- if(wiretris)
- surfaceEvaluator.polymode(N_MESHLINE);
- else
- surfaceEvaluator.polymode(N_MESHFILL);
- }
-
- public void patch( float ulo, float uhi, float vlo, float vhi ) {
- surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
- }
-
- /**
- * surfpts - pass a desription of a surface map
- */
- public void surfpts(long type, /* geometry, color, texture, normal */
- float[] pts, /* control points */
- long ustride, /* distance to next point in u direction */
- long vstride, /* distance to next point in v direction */
- int uorder, /* u parametric order */
- int vorder, /* v parametric order */
- float ulo, /* u lower bound */
- float uhi, /* u upper bound */
- float vlo, /* v lower bound */
- float vhi /* v upper bound */ ) {
- surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
- surfaceEvaluator.enable( type );
- }
- public void surfbbox( long type, float[] from, float[] to ) {
- surfaceEvaluator.range2f( type, from, to );
- }
- /**
- * surfgrid - define a lattice of points with origin and offset
- */
- public void surfgrid( float u0, float u1, long nu, float v0, float v1, long nv ) {
- surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
- }
- /**
- * surfmesh - evaluate a mesh of points on lattice
- */
- public void surfmesh( long u, long v, long n, long m ) {
- if( wireframequads ) {
- long v0, v1;
- long u0f = u, u1f = u+n;
- long v0f = v, v1f = v+m;
- long parity = (u & 1);
-
- for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
- surfaceEvaluator.bgnline();
- for( long u = u0f; u<=u1f; u++ ) {
- if( parity ) {
- surfaceEvaluator.evalpoint2i( u, v0 );
- surfaceEvaluator.evalpoint2i( u, v1 );
- } else {
- surfaceEvaluator.evalpoint2i( u, v1 );
- surfaceEvaluator.evalpoint2i( u, v0 );
- }
- parity = 1 - parity;
- }
- surfaceEvaluator.endline();
- }
- } else {
- surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
- }
- }
- /**
- * bgntmesh - preamble to a triangle mesh
- */
- public void bgntmesh() {
- meshindex = 0; /* I think these need to be initialized to zero */
- npts = 0;
-
- if( !wireframetris ) {
- surfaceEvaluator.bgntmesh();
- }
- }
- /**
- * endtmesh - postamble to triangle mesh
- */
- public void endtmesh( ) {
- if( ! wireframetris )
- surfaceEvaluator.endtmesh();
- }
- /**
- * swaptmesh - perform a swap of the triangle mesh pointers
- */
- public void swaptmesh( ) {
- if( wireframetris ) {
- meshindex = 1 - meshindex;
- } else {
- surfaceEvaluator.swaptmesh();
- }
- }
- public void tmeshvert( GridTrimVertex v ) {
- if( v.isGridVert() ) {
- tmeshvert( v.g );
- } else {
- tmeshvert( v.t );
- }
- }
- /**
- * tmeshvert - evaluate a point on a triangle mesh
- */
- public void tmeshvert( TrimVertex t ) {
- long nuid = t.nuid;
- float u = t.param[0];
- float v = t.param[1];
-
- npts++;
- if( wireframetris ) {
- if( npts >= 3 ) {
- surfaceEvaluator.bgnclosedline();
- if( mesh[0][2] == 0 )
- surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
- if( mesh[1][2] == 0 )
- surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
- surfaceEvaluator.evalcoord2f( nuid, u, v );
- surfaceEvaluator.endclosedline();
- }
- mesh[meshindex][0] = u;
- mesh[meshindex][1] = v;
- mesh[meshindex][2] = 0;
- mesh[meshindex][3] = nuid;
- meshindex = (meshindex+1) % 2;
- } else {
- surfaceEvaluator.evalcoord2f( nuid, u, v );
- }
- }
- /**
- * tmeshvert - evaluate a grid point of a triangle mesh
- */
- public void tmeshvert( GridVertex g ) {
- long u = g->gparam[0];
- long v = g->gparam[1];
-
- npts++;
- if( wireframetris ) {
- if( npts >= 3 ) {
- surfaceEvaluator.bgnclosedline();
- if( mesh[0][2] == 0 )
- surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
- if( mesh[1][2] == 0 )
- surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
- surfaceEvaluator.evalpoint2i( u, v );
- surfaceEvaluator.endclosedline();
- }
- mesh[meshindex][0] = u;
- mesh[meshindex][1] = v;
- mesh[meshindex][2] = 1;
- meshindex = (meshindex+1) % 2;
- } else {
- surfaceEvaluator.evalpoint2i( u, v );
- }
- }
- /** the same as tmeshvert(trimvertex), for efficiency purpose */
- public void tmeshvert( float u, float v ) {
- long nuid = 0;
-
- npts++;
- if( wireframetris ) {
- if( npts >= 3 ) {
- surfaceEvaluator.bgnclosedline();
- if( mesh[0][2] == 0 )
- surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
- if( mesh[1][2] == 0 )
- surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
- else
- surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
- surfaceEvaluator.evalcoord2f( nuid, u, v );
- surfaceEvaluator.endclosedline();
- }
- mesh[meshindex][0] = u;
- mesh[meshindex][1] = v;
- mesh[meshindex][2] = 0;
- mesh[meshindex][3] = nuid;
- meshindex = (meshindex+1) % 2;
- } else {
- surfaceEvaluator.evalcoord2f( nuid, u, v );
- }
- }
- /**
- * linevert - evaluate a point on an outlined contour
- */
- public void linevert( TrimVertex t ) {
- surfaceEvaluator.evalcoord2f( t.nuid, t.param[0], t.param[1] );
- }
- /**
- * linevert - evaluate a grid point of an outlined contour
- */
- public void linevert( GridVertex g ) {
- surfaceEvaluator.evalpoint2i( g.gparam[0], g.gparam[1] );
- }
- /**
- * bgnoutline - preamble to outlined rendering
- */
- public void bgnoutline( ) {
- surfaceEvaluator.bgnline();
- }
- /**
- * endoutline - postamble to outlined rendering
- */
- public void endoutline( ) {
- surfaceEvaluator.endline();
- }
- /**
- * endsurf - postamble to surface
- */
- public void endsurf( ) {
- surfaceEvaluator.endmap2f();
- }
- /**
- * triangle - output a triangle
- */
- public void triangle( TrimVertex a, TrimVertex b, TrimVertex c ) {
- bgntfan();
- tmeshvert( a );
- tmeshvert( b );
- tmeshvert( c );
- endtfan();
- }
-
- public void bgntfan() {
- surfaceEvaluator.bgntfan();
- }
- public void endtfan() {
- surfaceEvaluator.endtfan();
- }
- public void bgnqstrip() {
- surfaceEvaluator.bgnqstrip();
- }
- public void endqstrip() {
- surfaceEvaluator.endqstrip();
- }
- public void evalUStrip(int n_upper, float v_upper, float[] upper_val,
- int n_lower, float v_lower, float[] lower_val) {
- surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
- n_lower, v_lower, lower_val);
- }
- public void evalVStrip(int n_left, float u_left, float[] left_val,
- int n_right, float v_right, float[] right_val) {
- surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
- n_right, u_right, right_val);
- }
- public void tmeshvertNOGE(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void tmeshvertNOGE_BU(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void tmeshvertNOGE_BV(TrimVertex *t) {
- // NOTE: under undefined USE_OPTTT #ifdef
- }
- public void preEvaluateBU(float u) {
- surfaceEvaluator.inPreEvaluateBU_intfac(u);
- }
- public void preEvaluateBV(float v) {
- surfaceEvaluator.inPreEvaluateBV_intfac(v);
- }
-
- /* curve backend routines */
- public void bgncurv( void ) {
- curveEvaluator.bgnmap1f( 0 );
- }
- public void segment( float ulo, float uhi ) {
- curveEvaluator.domain1f( ulo, uhi );
- }
- public void curvpts(long type, /* geometry, color, texture, normal */
- float[] pts, /* control points */
- long stride, /* distance to next point */
- int order, /* parametric order */
- float ulo, /* lower parametric bound */
- float uhi ) /* upper parametric bound */ {
- curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
- curveEvaluator.enable( type );
- }
- public void curvgrid( float u0, float u1, long nu ) {
- curveEvaluator.mapgrid1f( nu, u0, u1 );
- }
- public void curvmesh( long from, long n ) {
- curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
- }
- public void curvpt( float u ) {
- curveEvaluator.evalcoord1f( 0, u );
- }
- public void bgnline( ) {
- curveEvaluator.bgnline();
- }
- public void endline( ) {
- curveEvaluator.endline();
- }
- public void endcurv( ) {
- curveEvaluator.endmap1f();
- }
-
- private boolean wireframetris;
- private boolean wireframequads;
- private int npts;
- private float[][] mesh = new float[3][4];
- private int meshindex;
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/BasicCurveEvaluator.java b/src/net/java/games/jogl/impl/nurbs/internals/BasicCurveEvaluator.java
deleted file mode 100755
index 3aae3674b..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/BasicCurveEvaluator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class BasicCurveEvaluator extends CachingEvaluator {
- public void domain1f(float ulo, float uhi) {}
- public void range1f(long type, float[] from, float[] to) {}
-
- public void enable(long type) {}
- public void disable(long type) {}
- public void bgnmap1f(long type) {}
- public void map1f(long type, float ulo, float uhi, long stride, long order, float[] pts) {}
- public void mapgrid1f(long nu, float u0, float u1) {}
- public void mapmesh1f(long style, long from, long to) {}
- public void evalcoord1f(long type, float u) {}
- public void endmap1f() {}
-
- public void bgnline() {}
- public void endline() {}
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/BasicSurfaceEvaluator.java b/src/net/java/games/jogl/impl/nurbs/internals/BasicSurfaceEvaluator.java
deleted file mode 100755
index f2b4a6679..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/BasicSurfaceEvaluator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public abstract class BasicSurfaceEvaluator extends CachingEvaluator {
- public void range2f(long, float[] from, float[] to) {}
- public void domain2f(float ulo, float uhi, float vlo, float vhi) {}
-
- public void enable(long type) {}
- public void disable(long type) {}
- public void bgnmap2f(long type) {}
- public void map2f(long type, float ulower, float uupper, long ustride, long uorder,
- float vlower, float vupper, long vstride, long vorder,
- float[] pts) {}
- public void mapgrid2f(long nu, float u0, float u1,
- long nv, float v0, float v1) {}
- public void mapmesh2f(long style, long umin, long umax,
- long vmin, long vmax) {}
- public void evalcoord2f(long type, float u, float v) {}
- public void evalpoint2i(long u, long v) {}
- public void endmap2f() {}
-
- public void polymode(long style) {}
- public void bgnline() {}
- public void endline() {}
- public void bgnclosedline() {}
- public void endclosedline() {}
- public void bgntmesh() {}
- public void swaptmesh() {}
- public void endtmesh() {}
- public void bgnqstrip() {}
- public void endqstrip() {}
-
- public void bgntfan() {}
- public void endtfan() {}
-
- public abstract void evalUStrip(int n_upper, float v_upper, float[] upper_val,
- int n_lower, float v_lower, float[] lower_val);
- public abstract void evalVStrip(int n_left, float u_left, float[] left_val,
- int n_right, float u_right, float[] right_val);
- public abstract void inDoEvalCoord2NOGE(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inDoEvalCoord2NOGE_BU(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inDoEvalCoord2NOGE_BV(float u, float v, float[] ret_point, float[] ret_normal);
- public abstract void inPreEvaluateBV_intfac(float v);
- public abstract void inPreEvaluateBU_intfac(float u);
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/BezierArc.java b/src/net/java/games/jogl/impl/nurbs/internals/BezierArc.java
deleted file mode 100755
index feac7d544..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/BezierArc.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-/** A bezier arc. */
-class BezierArc {
- public float[] cpts; /* control points of arc */
- public int order; /* order of arc */
- public int stride; /* REAL distance between points */
- public long type; /* curve type */
- public Mapdesc mapdesc;
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/Bin.java b/src/net/java/games/jogl/impl/nurbs/internals/Bin.java
deleted file mode 100755
index 55bec5eae..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/Bin.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class Bin {
- private Arc head; /*first arc on list */
- private Arc current; /* current arc on list */
-
- /**
- * Sets current arc to first arc of bin; advances to next arc.
- */
- public Arc firstarc( ) {
- current = head;
- return nextarc( );
- }
- /**
- * Returns current arc in bin and advances pointer to next arc.
- */
- public Arc nextarc( ) {
- Arc jarc = current;
-
- assert( (jarc == null) || jarc.check() );
-
- if( jarc != null ) current = jarc.link;
- return jarc;
- }
- /**
- * Removes first Arc from bin.
- */
- public Arc removearc( ) {
- Arc jarc = head;
-
- if( jarc != null ) head = jarc.link;
- return jarc;
- }
- public boolean isnonempty( ) { return (head != null); }
- /**
- * Adds an Arc to head of the linked list of Arcs.
- */
- public void addarc( Arc jarc ) {
- jarc.link = head;
- head = jarc;
- }
- /**
- * Removes given Arc from bin.
- */
- public void remove_this_arc( Arc arc ) {
- Arc j, prev;
- for( j = head; (j != null) && (j != arc); prev = j, j = j.link );
-
- if( j != null ) {
- if( j == current )
- current = j.link;
- if ( prev != null )
- prev.link = j.link;
- }
- }
- /**
- * Counts number of arcs in bin.
- */
- public int numarcs( ) {
- long count = 0;
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- count++;
- return count;
- }
- /**
- * Places an orphaned arc into its new parent's bin.
- */
- public void adopt( ) {
- markall();
-
- Arc orphan;
- while( (orphan = removearc()) != null ) {
- for( Arc parent = orphan.next; parent != orphan; parent = parent.next ) {
- if (! parent.ismarked() ) {
- orphan.link = parent.link;
- parent.link = orphan;
- orphan.clearmark();
- break;
- }
- }
- }
- }
- /**
- * Marks all arcs with an identifying tag.
- */
- public void markall( ) {
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- jarc.setmark();
- }
- /**
- * Prints out descriptions of the arcs in the bin.
- */
- public void show( String name ) {
- System.out.println( name );
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() )
- jarc.show( );
- }
- /**
- * Prints out all arcs that are untessellated border arcs.
- */
- public void listBezier( ) {
- for( Arc jarc = firstarc(); jarc != null; jarc = nextarc() ) {
- if( jarc.isbezier( ) ) {
- assert( jarc.pwlArc.npts == 2 );
- TrimVertex[] pts = jarc.pwlArc.pts;
- float s1 = pts[0].param[0];
- float t1 = pts[0].param[1];
- float s2 = pts[1].param[0];
- float t2 = pts[1].param[1];
- System.out.println( "arc ( " + s1 + "," + t1 + ") (" +
- s2 + "," + t2 + ")");
- }
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/CachingEvaluator.java b/src/net/java/games/jogl/impl/nurbs/internals/CachingEvaluator.java
deleted file mode 100755
index c9c8c5cf9..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/CachingEvaluator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class CachingEvaluator {
- public int ServiceModePlay = 0;
- public int ServiceModeRecord = 1;
- public int ServiceModePlayAndRecord = 2;
-
- public int canRecord() {
- return 0;
- }
-
- public int canPlayAndRecord() {
- return 0;
- }
-
- public int createHandle( int handle ) {
- return 0;
- }
-
- public void beginOutput( int serviceMode, int handle ) {}
- public void endOutput() {}
- public void discardRecording(int handle) {}
- public void playRecording(int handle) {}
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/Defines.java b/src/net/java/games/jogl/impl/nurbs/internals/Defines.java
deleted file mode 100755
index fc284abbd..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/Defines.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class Defines {
- /* culling constants */
- public static final int CULL_TRIVIAL_REJECT = 0;
- public static final int CULL_TRIVIAL_ACCEPT = 1;
- public static final int CULL_ACCEPT = 2;
-
- /* maximum order of a B-Spline */
- public static final int MAXORDER = 24;
-
- /* maximum dimension of any B-spline range space */
- public static final int MAXCOORDS = 5;
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/NurbsConsts.java b/src/net/java/games/jogl/impl/nurbs/internals/NurbsConsts.java
deleted file mode 100755
index 74c9c150c..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/NurbsConsts.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class NurbsConsts {
- /* NURBS Properties - one set per map,
- each takes a single INREAL arg */
- public static final int N_SAMPLING_TOLERANCE = 1;
- public static final int N_S_RATE = 6;
- public static final int N_T_RATE = 7;
- public static final int N_CLAMPFACTOR = 13;
- public static final float N_NOCLAMPING = 0.0f;
- public static final int N_MINSAVINGS = 14;
- public static final float N_NOSAVINGSSUBDIVISION = 0.0f;
-
- /* NURBS Properties - one set per map,
- each takes an enumerated value */
- public static final int N_CULLING = 2;
- public static final float N_NOCULLING = 0.0f;
- public static final float N_CULLINGON = 1.0f;
- public static final int N_SAMPLINGMETHOD 10;
- public static final float N_NOSAMPLING = 0.0f;
- public static final float N_FIXEDRATE = 3.0f;
- public static final float N_DOMAINDISTANCE = 2.0f;
- public static final float N_PARAMETRICDISTANCE = 5.0f;
- public static final float N_PATHLENGTH = 6.0f;
- public static final float N_SURFACEAREA = 7.0f;
- public static final float N_OBJECTSPACE_PARA = 8.0f;
- public static final float N_OBJECTSPACE_PATH = 9.0f;
- public static final int N_BBOX_SUBDIVIDING = 17;
- public static final float N_NOBBOXSUBDIVISION = 0.0f;
- public static final float N_BBOXTIGHT = 1.0f;
- public static final float N_BBOXROUND = 2.0f;
-
- /* NURBS Rendering Properties - one set per renderer
- each takes an enumerated value */
-public static final int N_DISPLAY 3
-public static final int N_FILL 1.0
-public static final int N_OUTLINE_POLY 2.0
-public static final int N_OUTLINE_TRI 3.0
-public static final int N_OUTLINE_QUAD 4.0
-public static final int N_OUTLINE_PATCH 5.0
-public static final int N_OUTLINE_PARAM 6.0
-public static final int N_OUTLINE_PARAM_S 7.0
-public static final int N_OUTLINE_PARAM_ST 8.0
-public static final int N_OUTLINE_SUBDIV 9.0
-public static final int N_OUTLINE_SUBDIV_S 10.0
-public static final int N_OUTLINE_SUBDIV_ST 11.0
-public static final int N_ISOLINE_S 12.0
-public static final int N_ERRORCHECKING 4
-public static final int N_NOMSG 0.0
-public static final int N_MSG 1.0
-
-/* GL 4.0 propeties not defined above */
-#ifndef N_PIXEL_TOLERANCE
-public static final int N_PIXEL_TOLERANCE N_SAMPLING_TOLERANCE
-public static final int N_ERROR_TOLERANCE 20
-public static final int N_SUBDIVISIONS 5
-public static final int N_TILES 8
-public static final int N_TMP1 9
-public static final int N_TMP2 N_SAMPLINGMETHOD
-public static final int N_TMP3 11
-public static final int N_TMP4 12
-public static final int N_TMP5 N_CLAMPFACTOR
-public static final int N_TMP6 N_MINSAVINGS
-public static final int N_S_STEPS N_S_RATE
-public static final int N_T_STEPS N_T_RATE
-#endif
-
-/* NURBS Rendering Properties - one set per map,
- each takes an INREAL matrix argument */
-public static final int N_CULLINGMATRIX 1
-public static final int N_SAMPLINGMATRIX 2
-public static final int N_BBOXMATRIX 3
-
-
-/* NURBS Rendering Properties - one set per map,
- each takes an INREAL vector argument */
-public static final int N_BBOXSIZE 4
-
-/* type argument for trimming curves */
-#ifndef N_P2D
-public static final int N_P2D 0x8
-public static final int N_P2DR 0xd
-#endif
-
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/NurbsException.java b/src/net/java/games/jogl/impl/nurbs/internals/NurbsException.java
deleted file mode 100755
index 5453807cd..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/NurbsException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/** Encapsulates functionality of the C GLU NURBS implementation's
- setjmp/longjmp wrappers. */
-
-public class NurbsException extends RuntimeException {
- private int errorCode;
-
- public NurbsException(int code) {
- super();
- errorCode = code;
- }
-
- public NurbsException(String message, int code) {
- super(message);
- errorCode = code;
- }
-
- public NurbsException(String message, Throwable cause, int code) {
- super(message, cause);
- errorCode = code;
- }
-
- public NurbsException(Throwable cause, int code) {
- super(cause);
- errorCode = code;
- }
-
- public int errorCode() {
- return errorCode;
- }
-}
diff --git a/src/net/java/games/jogl/impl/nurbs/internals/Subdivider.java b/src/net/java/games/jogl/impl/nurbs/internals/Subdivider.java
deleted file mode 100755
index 155b6b7ac..000000000
--- a/src/net/java/games/jogl/impl/nurbs/internals/Subdivider.java
+++ /dev/null
@@ -1,1781 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-*/
-
-public class Subdivider {
-
- /**
- * Constructs a subdivider.
- */
- public Subdivider(RenderHints hints, Backend b) {
- renderhints = hints;
- arctessellator = new ArcTesselator();
- backend = b;
- slicer = new Slicer(b);
- }
-
- /**
- * Resets all state after possible error condition.
- */
- public void clear() {
- // FIXME: looks like nothing to do given that we have no object pools
- }
- public void beginTrims() {}
- public void beginLoop() {
- pjarc = 0;
- }
-
- /**
- * Adds a bezier arc to a trim loop and to a bin.
- */
- public void addArc(float[] cpts, Quilt quilt, long _nuid) {
- BezierArc bezierArc = new BezierArc();
- Arc jarc = new Arc(Arc.SIDE_NONE, _nuid);
- jarc.bezierArc = bezierArc;
- bezierArc.order = quilt.qspec.order;
- bezierArc.stride = quilt.qspec.stride;
- bezierArc.mapdesc = quilt.mapdesc;
- bezierArc.cpts = cpts;
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
- }
-
- /**
- * Adds a pwl arc to a trim loop and to a bin.
- */
- public void addArc(int npts, TrimVertex[] pts, long _nuid) {
- Arc jarc = new Arc( Arc.SIDE_NONE, _nuid );
- jarc.pwlArc = new PwlArc( npts, pts );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
- }
- public void endLoop() {}
- public void endTrims() {}
-
- public void beginQuilts() {
- qlist = null;
- }
- public void addQuilt( Quilt quilt ) {
- quilt.next = qlist;
- qlist = quilt;
- }
- public void endQuilts() {}
-
- /**
- * Main curve rendering entry point
- */
- public void drawCurves() {
- float[] from = new float[1];
- float[] to = new float[1];
- Flist bpts = new Flist();
- qlist.getRange( from, to, bpts );
-
- renderhints.init( );
-
- backend.bgncurv();
- float[] pta = new float[0];
- float[] ptb = new float[1];
- for( int i=bpts.start; i<bpts.end-1; i++ ) {
- pta[0] = bpts.pts[i];
- ptb[0] = bpts.pts[i+1];
-
- qlist.downloadAll( pta, ptb, backend );
-
- Curvelist curvelist = new Curvelist( qlist, pta, ptb );
- samplingSplit( curvelist, renderhints.maxsubdivisions );
- }
- backend.endcurv();
- }
- public void drawSurfaces(long nuid) {
- renderhints.init( );
-
- if (qlist == null) {
- //initialbin could be nonempty due to some errors
- freejarcs(initialbin);
- return;
- }
-
- for( Quilt q = qlist; q != null; q = q.next ) {
- if( q.isCulled( ) == Defines.CULL_TRIVIAL_REJECT ) {
- freejarcs( initialbin );
- return;
- }
- }
-
-
- float[] from = new float[2];
- float[] to = new float[2];
- qlist.getRange( from, to, spbrkpts, tpbrkpts );
- //perform optimization only when the samplng method is
- //DOMAIN_DISTANCE and the display methdo is either
- //fill or outline_polygon.
- bool optimize = (is_domain_distance_sampling && (renderhints.display_method != N_OUTLINE_PATCH));
-
- if( ! initialbin.isnonempty() ) {
- if(! optimize )
- {
- makeBorderTrim( from, to );
- }
- } else {
- float[] rate = new float[2];
- qlist.findRates( spbrkpts, tpbrkpts, rate );
-
- if( decompose( initialbin, Math.min(rate[0], rate[1]) ) )
- throw new NurbsException( 31 );
- }
-
- backend.bgnsurf( renderhints.wiretris, renderhints.wirequads, nuid );
-
- if( (!initialbin.isnonempty()) && optimize )
- {
- int i,j;
- int num_u_steps;
- int num_v_steps;
- for(i=spbrkpts.start; i<spbrkpts.end-1; i++){
- for(j=tpbrkpts.start; j<tpbrkpts.end-1; j++){
- float[] pta = new float[2];
- float[] ptb = new float[2];
- pta[0] = spbrkpts.pts[i];
- ptb[0] = spbrkpts.pts[i+1];
- pta[1] = tpbrkpts.pts[j];
- ptb[1] = tpbrkpts.pts[j+1];
- qlist.downloadAll(pta, ptb, backend);
-
- num_u_steps = (int) (domain_distance_u_rate * (ptb[0]-pta[0]));
- num_v_steps = (int) (domain_distance_v_rate * (ptb[1]-pta[1]));
-
- if(num_u_steps <= 0) num_u_steps = 1;
- if(num_v_steps <= 0) num_v_steps = 1;
-
- backend.surfgrid(pta[0], ptb[0], num_u_steps,
- ptb[1], pta[1], num_v_steps);
- backend.surfmesh(0,0,num_u_steps,num_v_steps);
-
- continue;
- }
- }
- }
- else
- subdivideInS( initialbin );
-
- backend.endsurf();
- }
-
- public int ccwTurn_sl(Arc j1, Arc j2 ) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // the arcs lie on the line (0 == v1.param[0])
- if( v1.param[0] == v1next.param[0] && v2.param[0] == v2next.param[0] )
- return 0;
-
- if( v2next.param[0] > v2.param[0] || v1next.param[0] > v1.param[0] )
- throw new NurbsException(28);
-
- if( v1.param[1] < v2.param[1] )
- return 1;
- else if( v1.param[1] > v2.param[1] )
- return 0;
-
- while( true ) {
- if( v1next.param[0] > v2next.param[0] ) {
- assert( v1.param[0] >= v1next.param[0] );
- assert( v2.param[0] >= v1next.param[0] );
- switch( bbox( v2next, v2, v1next, 1 ) ) {
- case -1:
- return 1;
- case 0:
- sgn = ccw( v1next, v2, v2next );
- if( sgn != -1 )
- return sgn;
- else {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else if( v1next.param[0] < v2next.param[0] ) {
- assert( v1.param[0] >= v2next.param[0] );
- assert( v2.param[0] >= v2next.param[0] );
- switch( bbox( v1next, v1, v2next, 1 ) ) {
- case -1:
- return 0;
- case 0:
- sgn = ccw( v1next, v1, v2next );
- if( sgn != -1 )
- return sgn;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else {
- if( v1next.param[1] < v2next.param[1] )
- return 1;
- else if( v1next.param[1] > v2next.param[1] )
- return 0;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_sr(Arc j1, Arc j2 ) {
- // dir = 1
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // the arcs lie on the line (0 == v1.param[0])
- if( v1.param[0] == v1next.param[0] && v2.param[0] == v2next.param[0] )
- return 0;
-
- if( v2next.param[0] < v2.param[0] || v1next.param[0] < v1.param[0] )
- throw new NurbsException(28);
-
- if( v1.param[1] < v2.param[1] )
- return 0;
- else if( v1.param[1] > v2.param[1] )
- return 1;
-
- while( true ) {
- if( v1next.param[0] < v2next.param[0] ) {
- assert( v1.param[0] <= v1next.param[0] );
- assert( v2.param[0] <= v1next.param[0] );
- switch( bbox( v2, v2next, v1next, 1 ) ) {
- case -1:
- return 0;
- case 0:
- sgn = ccw( v1next, v2, v2next );
- if( sgn != -1 ) {
- return sgn;
- } else {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else if( v1next.param[0] > v2next.param[0] ) {
- assert( v1.param[0] <= v2next.param[0] );
- assert( v2.param[0] <= v2next.param[0] );
- switch( bbox( v1, v1next, v2next, 1 ) ) {
- case -1:
- return 1;
- case 0:
- sgn = ccw( v1next, v1, v2next );
- if( sgn != -1 ) {
- return sgn;
- } else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else {
- if( v1next.param[1] < v2next.param[1] )
- return 0;
- else if( v1next.param[1] > v2next.param[1] )
- return 1;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_tl(Arc j1, Arc j2 ) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // the arcs lie on the line (1 == v1.param[1])
- if( v1.param[1] == v1next.param[1] && v2.param[1] == v2next.param[1] )
- return 0;
-
- if( v2next.param[1] > v2.param[1] || v1next.param[1] > v1.param[1] )
- throw new NurbsException(28 );
-
- if( v1.param[0] < v2.param[0] )
- return 0;
- else if( v1.param[0] > v2.param[0] )
- return 1;
-
- while( true ) {
- if( v1next.param[1] > v2next.param[1] ) {
- assert( v1.param[1] >= v1next.param[1] );
- assert( v2.param[1] >= v1next.param[1] );
- switch( bbox( v2next, v2, v1next, 0 ) ) {
- case -1:
- return 0;
- case 0:
- sgn = ccw( v1next, v2, v2next );
- if( sgn != -1 )
- return sgn;
- else {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else if( v1next.param[1] < v2next.param[1] ) {
- switch( bbox( v1next, v1, v2next, 0 ) ) {
- case -1:
- return 1;
- case 0:
- sgn = ccw( v1next, v1, v2next );
- if( sgn != -1 )
- return sgn;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else {
- if( v1next.param[0] < v2next.param[0] )
- return 0;
- else if( v1next.param[0] > v2next.param[0] )
- return 1;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public int ccwTurn_tr(Arc j1, Arc j2) {
- int v1i = j1.pwlArc.npts-1;
- int v1lasti = 0;
- int v2i = 0;
- int v2lasti = j2.pwlArc.npts-1;
- int v1nexti = v1i-1;
- int v2nexti = v2i+1;
- TrimVertex v1 = j1.pwlArc.pts[v1i];
- TrimVertex v1last = j1.pwlArc.pts[v1lasti];
- TrimVertex v2 = j2.pwlArc.pts[v2i];
- TrimVertex v2last = j2.pwlArc.pts[v2lasti];
- TrimVertex v1next = j1.pwlArc.pts[v1nexti];
- TrimVertex v2next = j2.pwlArc.pts[v2nexti];
- int sgn;
-
- assert( v1 != v1last );
- assert( v2 != v2last );
-
- // the arcs lie on the line (1 == v1.param[1])
- if( v1.param[1] == v1next.param[1] && v2.param[1] == v2next.param[1] )
- return 0;
-
- if( v2next.param[1] < v2.param[1] || v1next.param[1] < v1.param[1] )
- throw new NurbsException( 28 );
-
- if( v1.param[0] < v2.param[0] )
- return 1;
- else if( v1.param[0] > v2.param[0] )
- return 0;
-
- while( 1 ) {
- if( v1next.param[1] < v2next.param[1] ) {
- assert( v1.param[1] <= v1next.param[1] );
- assert( v2.param[1] <= v1next.param[1] );
- switch( bbox( v2, v2next, v1next, 0 ) ) {
- case -1:
- return 1;
- case 0:
- sgn = ccw( v1next, v2, v2next );
- if( sgn != -1 ) {
- return sgn;
- } else {
- v1i = v1nexti--;
- v1 = j1.pwlArc.pts[v1i];
- v1next = j1.pwlArc.pts[v1nexti];
- if( v1 == v1last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 0;
- }
- } else if( v1next.param[1] > v2next.param[1] ) {
- assert( v1.param[1] <= v2next.param[1] );
- assert( v2.param[1] <= v2next.param[1] );
- switch( bbox( v1, v1next, v2next, 0 ) ) {
- case -1:
- return 0;
- case 0:
- sgn = ccw( v1next, v1, v2next );
- if( sgn != -1 ) {
- return sgn;
- } else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- break;
- case 1:
- return 1;
- }
- } else {
- if( v1next.param[0] < v2next.param[0] )
- return 1;
- else if( v1next.param[0] > v2next.param[0] )
- return 0;
- else {
- v2i = v2nexti++;
- v2 = j2.pwlArc.pts[v2i];
- v2next = j2.pwlArc.pts[v2nexti];
- if( v2 == v2last ) {
- return 0; // ill-conditioned, guess answer
- }
- }
- }
- }
- }
-
- public void set_domain_distance_u_rate(float u_rate) {
- domain_distance_u_rate = u_rate;
- }
-
- public void set_domain_distance_v_rate(float v_rate) {
- domain_distance_v_rate = v_rate;
- }
-
- public void set_is_domain_distance_sampling(int flag) {
- is_domain_distance_sampling = flag;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- /**
- * Determine which side of a line a jarc lies (for debugging only)
- */
- private int arc_classify( Arc jarc, int param, float value )
- {
- float tdiff, hdiff;
- if( param == 0 ) {
- tdiff = jarc.tail()[0] - value;
- hdiff = jarc.head()[0] - value;
- } else {
- tdiff = jarc.tail()[1] - value;
- hdiff = jarc.head()[1] - value;
- }
-
- if( tdiff > 0.0 ) {
- if( hdiff > 0.0 ) {
- return 0x11;
- } else if( hdiff == 0.0 ) {
- return 0x12;
- } else {
- return 0x10;
- }
- } else if( tdiff == 0.0 ) {
- if( hdiff > 0.0 ) {
- return 0x21;
- } else if( hdiff == 0.0 ) {
- return 0x22;
- } else {
- return 0x20;
- }
- } else {
- if( hdiff > 0.0 ) {
- return 0x01;
- } else if( hdiff == 0.0 ) {
- return 0x02;
- } else {
- return 0;
- }
- }
- }
-
- private void classify_headonleft_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at left */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x20 );
-
- j.setitail();
-
- float diff = j.prev.tail()[0] - val;
- if( diff > 0.0 ) {
- out.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_sl( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if( j.prev.tail()[1] > j.prev.head()[1] )
- in.addarc( j );
- else
- out.addarc( j );
- }
- }
- }
-
- private void classify_tailonleft_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail at left, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x02 );
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- in.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if (j.next.tail()[0] > j.next.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_headonright_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at right */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x21 );
-
- j.setitail();
-
- float diff = j.prev.tail()[0] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_sr( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else if( diff < 0.0 ) {
- out.addarc( j );
- } else {
- if( j.prev.tail()[1] > j.prev.head()[1] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_tailonright_s( Bin bin, Bin in, Bin out, float val ) {
- /* tail at right, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 0, val ) == 0x12);
-
- j.clearitail();
-
- float diff = j.next.head()[0] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_sr( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else if( diff < 0.0 ) {
- in.addarc( j );
- } else {
- if( j.next.tail()[1] > j.next.head()[1] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_headonleft_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at left */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x20 );
- j.setitail();
-
- float diff = j.prev.tail()[1] - val;
- if( diff > 0.0 ) {
- out.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if( j.prev.tail()[0] > j.prev.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_tailonleft_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail at left, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x02 );
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- in.addarc( j );
- } else if( diff < 0.0 ) {
- if( ccwTurn_tl( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else {
- if (j.next.tail()[0] > j.next.head()[0] )
- out.addarc( j );
- else
- in.addarc( j );
- }
- }
- }
-
- private void classify_headonright_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail on line, head at right */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x21 );
-
- j.setitail();
-
- float diff = j.prev.tail()[1] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_tr( j.prev, j ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else if( diff < 0.0 ) {
- out.addarc( j );
- } else {
- if( j.prev.tail()[0] > j.prev.head()[0] )
- in.addarc( j );
- else
- out.addarc( j );
- }
- }
- }
-
- private void classify_tailonright_t( Bin bin, Bin in, Bin out, float val ) {
- /* tail at right, head on line */
- Arc j;
-
- while( (j = bin.removearc()) != null ) {
- assert( arc_classify( j, 1, val ) == 0x12);
-
- j.clearitail();
-
- float diff = j.next.head()[1] - val;
- if( diff > 0.0 ) {
- if( ccwTurn_tr( j, j.next ) != 0 )
- out.addarc( j );
- else
- in.addarc( j );
- } else if( diff < 0.0 ) {
- in.addarc( j );
- } else {
- if( j.next.tail()[0] > j.next.head()[0] )
- in.addarc( j );
- else
- out.addarc( j );
- }
- }
- }
-
- private int DIR_DOWN = 0;
- private int DIR_SAME = 1;
- private int DIR_UP = 2;
- private int DIR_NONE = 3;
-
- private void tessellate( Arc_ptr, float );
- private void monotonize( Arc_ptr , Bin & );
- private int isMonotone( Arc_ptr );
- private int decompose( Bin &, float );
-
-
- private Slicer slicer;
- private ArcTessellator arctessellator;
- // private Pool arcpool;
- // private Pool bezierarcpool;
- // private Pool pwlarcpool;
- // private TrimVertexPool trimvertexpool;
-
- private JumpBuffer* jumpbuffer;
- private Renderhints& renderhints;
- private Backend& backend;
-
- private Bin initialbin;
- private Arc pjarc;
- private int s_index;
- private int t_index;
- private Quilt *qlist;
- private Flist spbrkpts;
- private Flist tpbrkpts;
- private Flist smbrkpts;
- private Flist tmbrkpts;
- private float stepsizes[4];
- private int showDegenerate;
- private int isArcTypeBezier;
-
- // FIXME: NOT FINISHED
- private void samplingSplit( Curvelist&, int );
-
- private void subdivideInS( Bin source ) {
- if( renderhints.display_method == N_OUTLINE_PARAM ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypeBezier();
- setNonDegenerate();
- splitInS( source, spbrkpts.start, spbrkpts.end );
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void splitInS( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 0, spbrkpts.pts[i] );
- splitInS( left, start, i );
- splitInS( right, i+1, end );
- } else {
- if( start == spbrkpts.start || start == spbrkpts.end ) {
- freejarcs( source );
- } else if( renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_S ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypeBezier();
- setNonDegenerate();
- s_index = start;
- splitInT( source, tpbrkpts.start, tpbrkpts.end );
- }
- }
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void splitInT( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 1, tpbrkpts.pts[i] );
- splitInT( left, start, i );
- splitInT( right, i+1, end );
- } else {
- if( start == tpbrkpts.start || start == tpbrkpts.end ) {
- freejarcs( source );
- } else if( renderhints.display_method == NurbsConsts.N_OUTLINE_PARAM_ST ) {
- outline( source );
- freejarcs( source );
- } else {
- t_index = start;
- setArcTypeBezier();
- setDegenerate();
-
- float[] pta = new float[2];
- float[] ptb = new float[2];
- pta[0] = spbrkpts.pts[s_index-1];
- pta[1] = tpbrkpts.pts[t_index-1];
-
- ptb[0] = spbrkpts.pts[s_index];
- ptb[1] = tpbrkpts.pts[t_index];
- qlist.downloadAll( pta, ptb, backend );
-
- Patchlist patchlist = new Patchlist( qlist, pta, ptb );
- /*
- printf("-------samplingSplit-----\n");
- source.show("samplingSplit source");
- */
- samplingSplit( source, patchlist, renderhints.maxsubdivisions, 0 );
- setNonDegenerate();
- setArcTypeBezier();
- }
- }
- }
- }
-
- /**
- * Recursively subdivides patch, cull checks each subpatch
- */
- private void samplingSplit( Bin source, Patchlist patchlist, int subdivisions, int param ) {
- if( ! source.isnonempty() ) return;
-
- if( patchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT ) {
- freejarcs( source );
- return;
- }
-
- patchlist.getstepsize();
-
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_PATCH ) {
- tessellation( source, patchlist );
- outline( source );
- freejarcs( source );
- return;
- }
-
- //patchlist.clamp();
-
- tessellation( source, patchlist );
-
- if( patchlist.needsSamplingSubdivision() && (subdivisions > 0) ) {
- if( ! patchlist.needsSubdivision( 0 ) )
- param = 1;
- else if( ! patchlist.needsSubdivision( 1 ) )
- param = 0;
- else
- param = 1 - param;
-
- Bin left = new Bin();
- Bin right = new Bin();
- float mid = ( patchlist.pspec[param].range[0] +
- patchlist.pspec[param].range[1] ) * 0.5;
- split( source, left, right, param, mid );
- Patchlist subpatchlist = new Patchlist( patchlist, param, mid );
- samplingSplit( left, subpatchlist, subdivisions-1, param );
- samplingSplit( right, patchlist, subdivisions-1, param );
- } else {
- setArcTypePwl();
- setDegenerate();
- nonSamplingSplit( source, patchlist, subdivisions, param );
- setDegenerate();
- setArcTypeBezier();
- }
- }
-
- private void nonSamplingSplit( Bin source, Patchlist patchlist, int subdivisions, int param ) {
- if( patchlist.needsNonSamplingSubdivision() && (subdivisions > 0) ) {
- param = 1 - param;
-
- Bin left = new Bin();
- Bin right = new Bin();
- float mid = ( patchlist.pspec[param].range[0] +
- patchlist.pspec[param].range[1] ) * 0.5;
- split( source, left, right, param, mid );
- Patchlist subpatchlist = new Patchlist( patchlist, param, mid );
- if( left.isnonempty() )
- if( subpatchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT )
- freejarcs( left );
- else
- nonSamplingSplit( left, subpatchlist, subdivisions-1, param );
- if( right.isnonempty() )
- if( patchlist.cullCheck() == Defines.CULL_TRIVIAL_REJECT )
- freejarcs( right );
- else
- nonSamplingSplit( right, patchlist, subdivisions-1, param );
-
- } else {
- // make bbox calls
- patchlist.bbox();
- backend.patch( patchlist.pspec[0].range[0], patchlist.pspec[0].range[1],
- patchlist.pspec[1].range[0], patchlist.pspec[1].range[1] );
-
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypePwl();
- setDegenerate();
- findIrregularS( source );
- monosplitInS( source, smbrkpts.start, smbrkpts.end );
- }
- }
- }
-
- /**
- * Sets tessellation of interior and boundary of patch.
- */
- private void tessellation( Bin bin, Patchlist patchlist ) {
- // tessellate unsampled trim curves
- tessellate( bin, patchlist.pspec[1].sidestep[1], patchlist.pspec[0].sidestep[1],
- patchlist.pspec[1].sidestep[0], patchlist.pspec[0].sidestep[0] );
-
- // set interior sampling rates
- slicer.setstriptessellation( patchlist.pspec[0].stepsize, patchlist.pspec[1].stepsize );
-
- //added by zl: set the order which will be used in slicer.c++
- slicer.set_ulinear( (patchlist.get_uorder() == 2));
- slicer.set_vlinear( (patchlist.get_vorder() == 2));
-
- // set boundary sampling rates
- stepsizes[0] = patchlist.pspec[1].stepsize;
- stepsizes[1] = patchlist.pspec[0].stepsize;
- stepsizes[2] = patchlist.pspec[1].stepsize;
- stepsizes[3] = patchlist.pspec[0].stepsize;
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void monosplitInS( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 0, smbrkpts.pts[i] );
- monosplitInS( left, start, i );
- monosplitInS( right, i+1, end );
- } else {
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV_S ) {
- outline( source );
- freejarcs( source );
- } else {
- setArcTypePwl();
- setDegenerate();
- findIrregularT( source );
- monosplitInT( source, tmbrkpts.start, tmbrkpts.end );
- }
- }
- }
- }
-
- /**
- * Splits a patch and a bin by an isoparametric line.
- */
- private void monosplitInT( Bin source, int start, int end ) {
- if( source.isnonempty() ) {
- if( start != end ) {
- int i = start + (end - start) / 2;
- Bin left = new Bin();
- Bin right = new Bin();
- split( source, left, right, 1, tmbrkpts.pts[i] );
- monosplitInT( left, start, i );
- monosplitInT( right, i+1, end );
- } else {
- if( renderhints.display_method == NurbsConsts.N_OUTLINE_SUBDIV_ST ) {
- outline( source );
- freejarcs( source );
- } else {
- /*
- printf("*******render\n");
- source.show("source\n");
- */
- render( source );
- freejarcs( source );
- }
- }
- }
- }
-
- /**
- * Renders the trimmed patch by outlining the boundary .
- */
- private void outline( Bin bin ) {
- bin.markall();
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.ismarked() ) {
- assert( jarc.check( ) );
- Arc jarchead = jarc;
- do {
- slicer.outline( jarc );
- jarc.clearmark();
- jarc = jarc.prev;
- } while (jarc != jarchead);
- }
- }
- }
-
- /**
- * Frees all arcs in a bin.
- */
- private void freejarcs( Bin & ) {
- bin.adopt(); /* XXX - should not be necessary */
-
- Arc jarc;
- while( (jarc = bin.removearc()) != null ) {
- if( jarc.pwlArc != null ) jarc.pwlArc.deleteMe( ); jarc.pwlArc = null;
- if( jarc.bezierArc != null) jarc.bezierArc.deleteMe( ); jarc.bezierArc = null;
- jarc.deleteMe( );
- }
- }
-
- /**
- * Renders all monotone regions in a bin and frees the bin.
- */
- private void render( Bin bin ) {
- bin.markall();
-
- slicer.setisolines( ( renderhints.display_method == N_ISOLINE_S ) ? 1 : 0 );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.ismarked() ) {
- assert( jarc.check( ) != 0 );
- Arc jarchead = jarc;
- do {
- jarc.clearmark();
- jarc = jarc.next;
- } while (jarc != jarchead);
- slicer.slice( jarc );
- }
- }
- }
-
- private void split( Bin &, Bin &, Bin &, int, float );
-
- /**
- * Tessellates all Bezier arcs in a bin.
- * <ol>
- * <li> only accepts linear Bezier arcs as input
- * <li> the Bezier arcs are stored in the pwlArc structure
- * <li> only vertical or horizontal lines work
- * </ol>
- * should:
- * <ol>
- * <li> represent Bezier arcs in BezierArc structure
- * (this requires a multitude of changes to the code)
- * <li> accept high degree Bezier arcs (hard)
- * <il> map the curve onto the surface to determine tessellation
- * <li> work for curves of arbitrary geometry
- * </ol>
- *----------------------------------------------------------------------------
- */
- private void tessellate( Bin bin, float rrate, float trate, float lrate, float brate ) {
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- if( jarc.isbezier( ) ) {
- assert( jarc.pwlArc.npts == 2 );
- TrimVertex[] pts = jarc.pwlArc.pts;
- float s1 = pts[0].param[0];
- float t1 = pts[0].param[1];
- float s2 = pts[1].param[0];
- float t2 = pts[1].param[1];
-
- jarc.pwlArc.deleteMe( );
- jarc.pwlArc = null;
-
- switch( jarc.getside() ) {
- case Arc.SIDE_LEFT:
- assert( s1 == s2 );
- arctessellator.pwl_left( jarc, s1, t1, t2, lrate );
- break;
- case Arc.SIDE_RIGHT:
- assert( s1 == s2 );
- arctessellator.pwl_right( jarc, s1, t1, t2, rrate );
- break;
- case Arc.SIDE_TOP:
- assert( t1 == t2 );
- arctessellator.pwl_top( jarc, t1, s1, s2, trate );
- break;
- case Arc.SIDE_BOTTOM:
- assert( t1 == t2 );
- arctessellator.pwl_bottom( jarc, t1, s1, s2, brate );
- break;
- case Arc.SIDE_NONE:
- throw new InternalError("Incorrect tesselation state");
- break;
- }
- assert( ! jarc.isbezier() );
- assert( jarc.check() != 0 );
- }
- }
- }
-
- private inline void setDegenerate( void ) { showDegenerate = 1; }
- private inline void setNonDegenerate( void ) { showDegenerate = 0; }
- private inline int showingDegenerate( void ) { return showDegenerate; }
- private inline void setArcTypeBezier( void ) { isArcTypeBezier = 1; }
- private inline void setArcTypePwl( void ) { isArcTypeBezier = 0; }
- private inline int isBezierArcType( void ) { return isArcTypeBezier; }
-
- /**
- * If no user input trimming data, then create a trimming curve
- * around the boundaries of the Quilt. The curve consists of four
- * Jordan arcs, one for each side of the Quilt, connected, of
- * course, head to tail.
- */
- private void makeBorderTrim( float[] from, float[] to ) {
- float smin = from[0];
- float smax = to[0];
- float tmin = from[1];
- float tmax = to[1];
-
- pjarc = null;
-
- Arc jarc = new Arc( Arc.SIDE_BOTTOM, 0 );
- arctessellator.bezier( jarc, smin, smax, tmin, tmin );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_RIGHT, 0 );
- arctessellator.bezier( jarc, smax, smax, tmin, tmax );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_TOP, 0 );
- arctessellator.bezier( jarc, smax, smin, tmax, tmax );
- initialbin.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new Arc( Arc.SIDE_LEFT, 0 );
- arctessellator.bezier( jarc, smin, smin, tmax, tmin );
- initialbin.addarc( jarc );
- jarc.append( pjarc );
-
- assert( jarc.check() );
- }
-
- private void split( Bin &, int, const float *, int, int );
- private void partition( Bin bin, Bin left, Bin intersections, Bin right, Bin unknown, int param, float value ) {
- Bin headonleft = new Bin();
- Bin headonright = new Bin();
- Bin tailonleft = new Bin();
- Bin tailonright = new Bin();
-
- for( Arc jarc = bin.removearc(); jarc != null; jarc = bin.removearc() ) {
-
- float tdiff = jarc.tail()[param] - value;
- float hdiff = jarc.head()[param] - value;
-
- if( tdiff > 0.0 ) {
- if( hdiff > 0.0 ) {
- right.addarc( jarc );
- } else if( hdiff == 0.0 ) {
- tailonright.addarc( jarc );
- } else {
- Arc jtemp;
- switch( arc_split(jarc, param, value, 0) ) {
- case 2:
- tailonright.addarc( jarc );
- headonleft.addarc( jarc.next );
- break;
- case 31:
- assert( jarc.head()[param] > value );
- right.addarc( jarc );
- tailonright.addarc( jtemp = jarc.next );
- headonleft.addarc( jtemp.next );
- break;
- case 32:
- assert( jarc.head()[param] <= value );
- tailonright .addarc( jarc );
- headonleft.addarc( jtemp = jarc.next );
- left.addarc( jtemp.next );
- break;
- case 4:
- right.addarc( jarc );
- tailonright.addarc( jtemp = jarc.next );
- headonleft.addarc( jtemp = jtemp.next );
- left.addarc( jtemp.next );
- }
- }
- } else if( tdiff == 0.0 ) {
- if( hdiff > 0.0 ) {
- headonright.addarc( jarc );
- } else if( hdiff == 0.0 ) {
- unknown.addarc( jarc );
- } else {
- headonleft.addarc( jarc );
- }
- } else {
- if( hdiff > 0.0 ) {
- Arc jtemp;
- switch( arc_split(jarc, param, value, 1) ) {
- case 2:
- tailonleft.addarc( jarc );
- headonright.addarc( jarc.next );
- break;
- case 31:
- assert( jarc.head()[param] < value );
- left.addarc( jarc );
- tailonleft.addarc( jtemp = jarc.next );
- headonright.addarc( jtemp.next );
- break;
- case 32:
- assert( jarc.head()[param] >= value );
- tailonleft.addarc( jarc );
- headonright.addarc( jtemp = jarc.next );
- right.addarc( jtemp.next );
- break;
- case 4:
- left.addarc( jarc );
- tailonleft.addarc( jtemp = jarc.next );
- headonright.addarc( jtemp = jtemp.next );
- right.addarc( jtemp.next );
- }
- } else if( hdiff == 0.0 ) {
- tailonleft.addarc( jarc );
- } else {
- left.addarc( jarc );
- }
- }
- }
- if( param == 0 ) {
- classify_headonleft_s( headonleft, intersections, left, value );
- classify_tailonleft_s( tailonleft, intersections, left, value );
- classify_headonright_s( headonright, intersections, right, value );
- classify_tailonright_s( tailonright, intersections, right, value );
- } else {
- classify_headonleft_t( headonleft, intersections, left, value );
- classify_tailonleft_t( tailonleft, intersections, left, value );
- classify_headonright_t( headonright, intersections, right, value );
- classify_tailonright_t( tailonright, intersections, right, value );
- }
- }
-
- /**
- * Determine points of non-monotonicity in s direction.
- */
- private void findIrregularS( Bin bin ) {
- assert( bin.firstarc() == null || bin.firstarc().check() );
-
- smbrkpts.grow( bin.numarcs() );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- float[] a = jarc.prev.tail();
- float[] b = jarc.tail();
- float[] c = jarc.head();
-
- if( b[1] == a[1] && b[1] == c[1] ) continue;
-
- //corrected code
- if((b[1]<=a[1] && b[1] <= c[1]) ||
- (b[1]>=a[1] && b[1] >= c[1]))
- {
- //each arc (jarc, jarc.prev, jarc.next) is a
- //monotone arc consisting of multiple line segements.
- //it may happen that jarc.prev and jarc.next are the same,
- //that is, jarc.prev and jarc form a closed loop.
- //In such case, a and c will be the same.
- if(a[0]==c[0] && a[1] == c[1])
- {
- if(jarc.pwlArc.npts >2)
- {
- c = jarc.pwlArc.pts[jarc.pwlArc.npts-2].param;
- }
- else
- {
- assert(jarc.prev.pwlArc.npts>2);
- a = jarc.prev.pwlArc.pts[jarc.prev.pwlArc.npts-2].param;
- }
-
- }
- if(area(a,b,c) < 0)
- {
- smbrkpts.add(b[0]);
- }
-
- }
-
- /* old code,
- if( b[1] <= a[1] && b[1] <= c[1] ) {
- if( ! ccwTurn_tr( jarc.prev, jarc ) )
- smbrkpts.add( b[0] );
- } else if( b[1] >= a[1] && b[1] >= c[1] ) {
- if( ! ccwTurn_tl( jarc.prev, jarc ) )
- smbrkpts.add( b[0] );
- }
- */
-
- }
-
- smbrkpts.filter();
- }
-
- /**
- * Determines points of non-monotonicity in t direction where one
- * arc is parallel to the s axis.
- */
- private void findIrregularT( Bin bin ) {
- assert( bin.firstarc() == null || bin.firstarc().check() );
-
- tmbrkpts.grow( bin.numarcs() );
-
- for( Arc jarc=bin.firstarc(); jarc != null; jarc=bin.nextarc() ) {
- float[] a = jarc.prev.tail();
- float[] b = jarc.tail();
- float[] c = jarc.head();
-
- if( b[0] == a[0] && b[0] == c[0] ) continue;
-
- if( b[0] <= a[0] && b[0] <= c[0] ) {
- if( a[1] != b[1] && b[1] != c[1] ) continue;
- if( ccwTurn_sr( jarc.prev, jarc ) == 0)
- tmbrkpts.add( b[1] );
- } else if ( b[0] >= a[0] && b[0] >= c[0] ) {
- if( a[1] != b[1] && b[1] != c[1] ) continue;
- if( ccwTurn_sl( jarc.prev, jarc ) == 0)
- tmbrkpts.add( b[1] );
- }
- }
- tmbrkpts.filter( );
- }
-
-
- private int bbox( TrimVertex a, TrimVertex b, TrimVertex c, int p ) {
- return bbox( a.param[p], b.param[p], c.param[p],
- a.param[1-p], b.param[1-p], c.param[1-p] );
- }
-
- private static int bbox( float sa, float sb, float sc, float ta, float tb, float tc ) {
- assert( tc >= ta );
- assert( tc <= tb );
-
- if( sa < sb ) {
- if( sc <= sa ) {
- return -1;
- } else if( sb <= sc ) {
- return 1;
- } else {
- return 0;
- }
- } else if( sa > sb ) {
- if( sc >= sa ) {
- return 1;
- } else if( sb >= sc ) {
- return -1;
- } else {
- return 0;
- }
- } else {
- if( sc > sa ) {
- return 1;
- } else if( sb > sc ) {
- return -1;
- } else {
- return 0;
- }
- }
- }
- /**
- * Determines how three points are oriented by computing their
- * determinant.
- *
- * @return 1 if the vertices are ccw oriented, 0 if they are cw
- * oriented, or -1 if the computation is ill-conditioned.
- */
- private static int ccw( TrimVertex a, TrimVertex b, TrimVertex c ) {
- float d = TrimVertex.det3( a, b, c );
- if( Math.abs(d) < 0.0001 ) return -1;
- return (d < 0.0) ? 0 : 1;
- }
- private void join_s( Bin &, Bin &, Arc_ptr, Arc_ptr );
- private void join_t( Bin &, Bin &, Arc_ptr , Arc_ptr );
-
- private static void vert_interp( TrimVertex n, TrimVertex l, TrimVertex r, int p, float val ) {
- assert( val > l.param[p]);
- assert( val < r.param[p]);
-
- n.nuid = l.nuid;
-
- n.param[p] = val;
- if( l.param[1-p] != r.param[1-p] ) {
- float ratio = (val - l.param[p]) / (r.param[p] - l.param[p]);
- n.param[1-p] = l.param[1-p] +
- ratio * (r.param[1-p] - l.param[1-p]);
- } else {
- n.param[1-p] = l.param[1-p];
- }
- }
-
- private static final int INTERSECT_VERTEX = 1;
- private static final int INTERSECT_EDGE = 2;
-
- /**
- * Finds intersection of pwlArc and isoparametric line.
- */
- private static int pwlarc_intersect( PwlArc pwlArc, int param, float value, int dir, int[] loc ) {
- assert( pwlArc.npts > 0 );
-
- if( dir != 0 ) {
- TrimVertex[] v = pwlArc.pts;
- int imin = 0;
- int imax = pwlArc.npts - 1;
- assert( value > v[imin].param[param] );
- assert( value < v[imax].param[param] );
- while( (imax - imin) > 1 ) {
- int imid = (imax + imin)/2;
- if( v[imid].param[param] > value )
- imax = imid;
- else if( v[imid].param[param] < value )
- imin = imid;
- else {
- loc[1] = imid;
- return INTERSECT_VERTEX;
- }
- }
- loc[0] = imin;
- loc[2] = imax;
- return INTERSECT_EDGE;
- } else {
- TrimVertex[] v = pwlArc.pts;
- int imax = 0;
- int imin = pwlArc.npts - 1;
- assert( value > v[imin].param[param] );
- assert( value < v[imax].param[param] );
- while( (imin - imax) > 1 ) {
- int imid = (imax + imin)/2;
- if( v[imid].param[param] > value )
- imax = imid;
- else if( v[imid].param[param] < value )
- imin = imid;
- else {
- loc[1] = imid;
- return INTERSECT_VERTEX;
- }
- }
- loc[0] = imin;
- loc[2] = imax;
- return INTERSECT_EDGE;
- }
- }
-
- private int arc_split( Arc jarc , int param, float value, int dir ) {
- int maxvertex = jarc.pwlArc.npts;
- Arc jarc1, jarc2, jarc3;
- TrimVertex v = jarc.pwlArc.pts;
-
- int[] loc = new int[3];
- switch( pwlarc_intersect( jarc.pwlArc, param, value, dir, loc ) ) {
-
- // When the parameter value lands on a vertex, life is sweet
- case INTERSECT_VERTEX: {
- jarc1 = new Arc( jarc, new PwlArc( maxvertex-loc[1], /* &v[loc[1]] */ v, loc[1] ) );
- jarc.pwlArc.npts = loc[1] + 1;
- jarc1.next = jarc.next;
- jarc1.next.prev = jarc1;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- assert(jarc.check());
- return 2;
- }
-
- // When the parameter value intersects an edge, we have to
- // interpolate a new vertex. There are special cases
- // if the new vertex is adjacent to one or both of the
- // endpoints of the arc.
- case INTERSECT_EDGE: {
- int i, j;
- if( dir == 0 ) {
- i = loc[0];
- j = loc[2];
- } else {
- i = loc[2];
- j = loc[0];
- }
-
- // The split is between vertices at index j and i, in that
- // order (j < i)
-
- // JEB: This code is my idea of how to do the split without
- // increasing the number of links. I'm doing this so that
- // the is_rect routine can recognize rectangles created by
- // subdivision. In exchange for simplifying the curve list,
- // however, it costs in allocated space and vertex copies.
-
- TrimVertex[] newjunk = TrimVertex.allocate(maxvertex -i+1 /*-j*/);
- int k;
- for(k=0; k<maxvertex-i; k++)
- {
- newjunk[k+1] = v[i+k];
- newjunk[k+1].nuid = jarc.nuid;
- }
-
- TrimVertex[] vcopy = TrimVertex.allocate(maxvertex);
- for(k=0; k<maxvertex; k++)
- {
- vcopy[k].param[0] = v[k].param[0];
- vcopy[k].param[1] = v[k].param[1];
- }
- jarc.pwlArc.pts=vcopy;
-
- v[i].nuid = jarc.nuid;
- v[j].nuid = jarc.nuid;
- vert_interp( newjunk[0], v[loc[0]], v[loc[2]], param, value );
-
- if( showingDegenerate() )
- backend.triangle( v[i], newjunk[0], v[j] );
-
- vcopy[j+1].param[0]=newjunk[0].param[0];
- vcopy[j+1].param[1]=newjunk[0].param[1];
-
-
- jarc1 = new Arc( jarc,
- new PwlArc(maxvertex-i+1 , newjunk ) );
-
- jarc.pwlArc.npts = j+2;
- jarc1.next = jarc.next;
- jarc1.next.prev = jarc1;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- assert(jarc.check());
-
- return 2;
-
- /***
- // JEB: This is the original version:
-
- TrimVertex[] newjunk = TrimVertex.allocate(3);
- v[i].nuid = jarc.nuid;
- v[j].nuid = jarc.nuid;
- newjunk[0] = v[j];
- newjunk[2] = v[i];
- vert_interp( &newjunk[1], &v[loc[0]], &v[loc[2]], param, value );
-
- if( showingDegenerate() )
- backend.triangle( &newjunk[2], &newjunk[1], &newjunk[0] );
-
- // New vertex adjacent to both endpoints
- if (maxvertex == 2) {
- jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
- jarc.pwlArc.npts = 2;
- jarc.pwlArc.pts = newjunk;
- jarc1.next = jarc.next;
- jarc1.next.prev = jarc1;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- assert(jarc.check() != 0);
-
- return 2;
-
- // New vertex adjacent to ending point of arc
- } else if (maxvertex - j == 2) {
- jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
- jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
- jarc.pwlArc.npts = maxvertex-1;
- jarc2.next = jarc.next;
- jarc2.next.prev = jarc2;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- jarc1.next = jarc2;
- jarc2.prev = jarc1;
- assert(jarc.check() != 0);
- return 31;
-
- // New vertex adjacent to starting point of arc
- } else if (i == 1) {
- jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
- jarc2 = new(arcpool) Arc( jarc,
- new(pwlarcpool) PwlArc( maxvertex-1, &jarc.pwlArc.pts[1] ) );
- jarc.pwlArc.npts = 2;
- jarc.pwlArc.pts = newjunk;
- jarc2.next = jarc.next;
- jarc2.next.prev = jarc2;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- jarc1.next = jarc2;
- jarc2.prev = jarc1;
- assert(jarc.check() != 0);
- return 32;
-
- // It's somewhere in the middle
- } else {
- jarc1 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk ) );
- jarc2 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( 2, newjunk+1 ) );
- jarc3 = new(arcpool) Arc( jarc, new(pwlarcpool) PwlArc( maxvertex-i, v+i ) );
- jarc.pwlArc.npts = j + 1;
- jarc3.next = jarc.next;
- jarc3.next.prev = jarc3;
- jarc.next = jarc1;
- jarc1.prev = jarc;
- jarc1.next = jarc2;
- jarc2.prev = jarc1;
- jarc2.next = jarc3;
- jarc3.prev = jarc2;
- assert(jarc.check() != 0);
- return 4;
- }
- ***/
- }
- default:
- return -1; //picked -1 since it's not used
- }
- }
-
- private void check_s( Arc_ptr , Arc_ptr );
- private void check_t( Arc_ptr , Arc_ptr );
- private inline void link( Arc_ptr , Arc_ptr , Arc_ptr , Arc_ptr );
- private inline void simple_link( Arc_ptr , Arc_ptr );
-
- private Bin makePatchBoundary( const float[] from, const float[] to ) {
- Bin ret = new Bin();
- float smin = from[0];
- float smax = to[0];
- float tmin = from[1];
- float tmax = to[1];
-
- pjarc = 0;
-
- Arc jarc = new Arc( arc_bottom, 0 );
- arctessellator.bezier( jarc, smin, smax, tmin, tmin );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_right, 0 );
- arctessellator.bezier( jarc, smax, smax, tmin, tmax );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_top, 0 );
- arctessellator.bezier( jarc, smax, smin, tmax, tmax );
- ret.addarc( jarc );
- pjarc = jarc.append( pjarc );
-
- jarc = new(arcpool) Arc( arc_left, 0 );
- arctessellator.bezier( jarc, smin, smin, tmax, tmin );
- ret.addarc( jarc );
- jarc.append( pjarc );
-
- assert( jarc.check() != 0 );
- return ret;
- }
-
- /*in domain distance method, the tessellation is controled by two numbers:
- *GLU_U_STEP: number of u-segments per unit u length of domain
- *GLU_V_STEP: number of v-segments per unit v length of domain
- *These two numbers are normally stored in mapdesc.maxs(t)rate.
- *I (ZL) put these two numbers here so that I can optimize the untrimmed
- *case in the case of domain distance sampling.
- *These two numbers are set by set_domain_distance_u_rate() and ..._v_..().
- */
- private float domain_distance_u_rate;
- private float domain_distance_v_rate;
- private int is_domain_distance_sampling;
-
-}
diff --git a/src/net/java/games/jogl/impl/registry/Registry.java b/src/net/java/games/jogl/impl/registry/Registry.java
deleted file mode 100644
index ef9f868f3..000000000
--- a/src/net/java/games/jogl/impl/registry/Registry.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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
- * file are subject only to the provisions of the License. You may not use
- * this file except in compliance with the License. You may obtain a copy
- * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
- * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
- * http://oss.sgi.com/projects/FreeB
- *
- * Note that, as provided in the License, the Software is distributed on an
- * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
- * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
- * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
- * 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.
- * Copyright in any portions created by third parties is as indicated
- * elsewhere herein. All Rights Reserved.
- *
- * Additional Notice Provisions: The application programming interfaces
- * established by SGI in conjunction with the Original Code are The
- * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
- * April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
- * 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
- * Window System(R) (Version 1.3), released October 19, 1998. This software
- * was created using the OpenGL(R) version 1.2.1 Sample Implementation
- * published by SGI, but has not been independently verified as being
- * compliant with the OpenGL(R) version 1.2.1 Specification.
- */
-
-package net.java.games.jogl.impl.registry;
-
-import java.util.regex.*;
-import net.java.games.jogl.GLU;
-
-/**
- *
- * @author Administrator
- */
-public class Registry {
-
- /** Creates a new instance of Registry */
- public Registry() {
- }
-
- public static String gluGetString(int name) {
- if( name == GLU.GLU_VERSION ) {
- return( "1.3" );
- } else if( name == GLU.GLU_EXTENSIONS ) {
- return( "GLU_EXT_nurbs_tessellator GLU_EXT_object_space_tess " );
- }
- return( null );
- }
-
- public static boolean gluCheckExtensions( String extName, String extString ) {
- if( extName == null || extString == null ) {
- return( false );
- }
- return( Pattern.compile( extName + "\\b" ).matcher( extString ).find() );
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/ActiveRegion.java b/src/net/java/games/jogl/impl/tesselator/ActiveRegion.java
deleted file mode 100644
index a3b3f953a..000000000
--- a/src/net/java/games/jogl/impl/tesselator/ActiveRegion.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class ActiveRegion {
- GLUhalfEdge eUp; /* upper edge, directed right to left */
- DictNode nodeUp; /* dictionary node corresponding to eUp */
- int windingNumber; /* used to determine which regions are
- * inside the polygon */
- boolean inside; /* is this region inside the polygon? */
- boolean sentinel; /* marks fake edges at t = +/-infinity */
- boolean dirty; /* marks regions where the upper or lower
- * edge has changed, but we haven't checked
- * whether they intersect yet */
- boolean fixUpperEdge; /* marks temporary edges introduced when
- * we process a "right vertex" (one without
- * any edges leaving to the right) */
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/CachedVertex.java b/src/net/java/games/jogl/impl/tesselator/CachedVertex.java
deleted file mode 100644
index 3f8661d78..000000000
--- a/src/net/java/games/jogl/impl/tesselator/CachedVertex.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class CachedVertex {
- public double[] coords = new double[3];
- public Object data;
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Dict.java b/src/net/java/games/jogl/impl/tesselator/Dict.java
deleted file mode 100644
index 6d3d80d0c..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Dict.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class Dict {
- DictNode head;
- Object frame;
- DictLeq leq;
-
- private Dict() {
- }
-
- static Dict dictNewDict(Object frame, DictLeq leq) {
- Dict dict = new Dict();
- dict.head = new DictNode();
-
- dict.head.key = null;
- dict.head.next = dict.head;
- dict.head.prev = dict.head;
-
- dict.frame = frame;
- dict.leq = leq;
-
- return dict;
- }
-
- static void dictDeleteDict(Dict dict) {
- dict.head = null;
- dict.frame = null;
- dict.leq = null;
- }
-
- static DictNode dictInsert(Dict dict, Object key) {
- return dictInsertBefore(dict, dict.head, key);
- }
-
- static DictNode dictInsertBefore(Dict dict, DictNode node, Object key) {
- do {
- node = node.prev;
- } while (node.key != null && !dict.leq.leq(dict.frame, node.key, key));
-
- DictNode newNode = new DictNode();
- newNode.key = key;
- newNode.next = node.next;
- node.next.prev = newNode;
- newNode.prev = node;
- node.next = newNode;
-
- return newNode;
- }
-
- static Object dictKey(DictNode aNode) {
- return aNode.key;
- }
-
- static DictNode dictSucc(DictNode aNode) {
- return aNode.next;
- }
-
- static DictNode dictPred(DictNode aNode) {
- return aNode.prev;
- }
-
- static DictNode dictMin(Dict aDict) {
- return aDict.head.next;
- }
-
- static DictNode dictMax(Dict aDict) {
- return aDict.head.prev;
- }
-
- static void dictDelete(Dict dict, DictNode node) {
- node.next.prev = node.prev;
- node.prev.next = node.next;
- }
-
- static DictNode dictSearch(Dict dict, Object key) {
- DictNode node = dict.head;
-
- do {
- node = node.next;
- } while (node.key != null && !(dict.leq.leq(dict.frame, key, node.key)));
-
- return node;
- }
-
- public interface DictLeq {
- boolean leq(Object frame, Object key1, Object key2);
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/DictNode.java b/src/net/java/games/jogl/impl/tesselator/DictNode.java
deleted file mode 100644
index da870b6d9..000000000
--- a/src/net/java/games/jogl/impl/tesselator/DictNode.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class DictNode {
- Object key;
- DictNode next;
- DictNode prev;
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/GLUface.java b/src/net/java/games/jogl/impl/tesselator/GLUface.java
deleted file mode 100644
index fa2449a5a..000000000
--- a/src/net/java/games/jogl/impl/tesselator/GLUface.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class GLUface {
- public GLUface next; /* next face (never NULL) */
- public GLUface prev; /* previous face (never NULL) */
- public GLUhalfEdge anEdge; /* a half edge with this left face */
- public Object data; /* room for client's data */
-
- /* Internal data (keep hidden) */
- public GLUface trail; /* "stack" for conversion to strips */
- public boolean marked; /* flag for conversion to strips */
- public boolean inside; /* this face is in the polygon interior */
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/GLUhalfEdge.java b/src/net/java/games/jogl/impl/tesselator/GLUhalfEdge.java
deleted file mode 100644
index 8e2abcb78..000000000
--- a/src/net/java/games/jogl/impl/tesselator/GLUhalfEdge.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-
-
-class GLUhalfEdge {
- public GLUhalfEdge next; /* doubly-linked list (prev==Sym->next) */
- public GLUhalfEdge Sym; /* same edge, opposite direction */
- public GLUhalfEdge Onext; /* next edge CCW around origin */
- public GLUhalfEdge Lnext; /* next edge CCW around left face */
- public GLUvertex Org; /* origin vertex (Overtex too long) */
- public net.java.games.jogl.impl.tesselator.GLUface Lface; /* left face */
-
- /* Internal data (keep hidden) */
- public net.java.games.jogl.impl.tesselator.ActiveRegion activeRegion; /* a region with this upper edge (sweep.c) */
- public int winding; /* change in winding number when crossing */
- public boolean first;
-
- public GLUhalfEdge(boolean first) {
- this.first = first;
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/GLUmesh.java b/src/net/java/games/jogl/impl/tesselator/GLUmesh.java
deleted file mode 100644
index 0ab3b2626..000000000
--- a/src/net/java/games/jogl/impl/tesselator/GLUmesh.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-
-
-class GLUmesh {
- GLUvertex vHead = new GLUvertex(); /* dummy header for vertex list */
- net.java.games.jogl.impl.tesselator.GLUface fHead = new GLUface(); /* dummy header for face list */
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eHead = new GLUhalfEdge(true); /* dummy header for edge list */
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eHeadSym = new GLUhalfEdge(false); /* and its symmetric counterpart */
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/GLUtesselatorImpl.java b/src/net/java/games/jogl/impl/tesselator/GLUtesselatorImpl.java
deleted file mode 100644
index 90de5bcc9..000000000
--- a/src/net/java/games/jogl/impl/tesselator/GLUtesselatorImpl.java
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.tesselator.*;
-
-public class GLUtesselatorImpl implements GLUtesselator {
- public static final int TESS_MAX_CACHE = 100;
-
- private int state; /* what begin/end calls have we seen? */
-
- private GLUhalfEdge lastEdge; /* lastEdge->Org is the most recent vertex */
- GLUmesh mesh; /* stores the input contours, and eventually
- the tessellation itself */
-
- /*** state needed for projecting onto the sweep plane ***/
-
- double[] normal = new double[3]; /* user-specified normal (if provided) */
- double[] sUnit = new double[3]; /* unit vector in s-direction (debugging) */
- double[] tUnit = new double[3]; /* unit vector in t-direction (debugging) */
-
- /*** state needed for the line sweep ***/
-
- private double relTolerance; /* tolerance for merging features */
- int windingRule; /* rule for determining polygon interior */
- boolean fatalError; /* fatal error: needed combine callback */
-
- Dict dict; /* edge dictionary for sweep line */
- PriorityQ pq; /* priority queue of vertex events */
- GLUvertex event; /* current sweep event being processed */
-
- /*** state needed for rendering callbacks (see render.c) ***/
-
- boolean flagBoundary; /* mark boundary edges (use EdgeFlag) */
- boolean boundaryOnly; /* Extract contours, not triangles */
- GLUface lonelyTriList;
- /* list of triangles which could not be rendered as strips or fans */
-
-
-
- /*** state needed to cache single-contour polygons for renderCache() */
-
- private boolean flushCacheOnNextVertex; /* empty cache on next vertex() call */
- int cacheCount; /* number of cached vertices */
- CachedVertex[] cache = new CachedVertex[TESS_MAX_CACHE]; /* the vertex data */
-
- /*** rendering callbacks that also pass polygon data ***/
- private Object polygonData; /* client data for current polygon */
-
- private GLUtesselatorCallback callBegin;
- private GLUtesselatorCallback callEdgeFlag;
- private GLUtesselatorCallback callVertex;
- private GLUtesselatorCallback callEnd;
-// private GLUtesselatorCallback callMesh;
- private GLUtesselatorCallback callError;
- private GLUtesselatorCallback callCombine;
-
- private GLUtesselatorCallback callBeginData;
- private GLUtesselatorCallback callEdgeFlagData;
- private GLUtesselatorCallback callVertexData;
- private GLUtesselatorCallback callEndData;
-// private GLUtesselatorCallback callMeshData;
- private GLUtesselatorCallback callErrorData;
- private GLUtesselatorCallback callCombineData;
-
- private static final double GLU_TESS_DEFAULT_TOLERANCE = 0.0;
-// private static final int GLU_TESS_MESH = 100112; /* void (*)(GLUmesh *mesh) */
- private static GLUtesselatorCallback NULL_CB = new GLUtesselatorCallbackAdapter();
-
-// #define MAX_FAST_ALLOC (MAX(sizeof(EdgePair), \
-// MAX(sizeof(GLUvertex),sizeof(GLUface))))
-
- private GLUtesselatorImpl() {
- state = TessState.T_DORMANT;
-
- normal[0] = 0;
- normal[1] = 0;
- normal[2] = 0;
-
- relTolerance = GLU_TESS_DEFAULT_TOLERANCE;
- windingRule = GLU.GLU_TESS_WINDING_ODD;
- flagBoundary = false;
- boundaryOnly = false;
-
- callBegin = NULL_CB;
- callEdgeFlag = NULL_CB;
- callVertex = NULL_CB;
- callEnd = NULL_CB;
- callError = NULL_CB;
- callCombine = NULL_CB;
-// callMesh = NULL_CB;
-
- callBeginData = NULL_CB;
- callEdgeFlagData = NULL_CB;
- callVertexData = NULL_CB;
- callEndData = NULL_CB;
- callErrorData = NULL_CB;
- callCombineData = NULL_CB;
-
- polygonData = null;
-
- for (int i = 0; i < cache.length; i++) {
- cache[i] = new CachedVertex();
- }
- }
-
- static public GLUtesselator gluNewTess()
- {
- return new GLUtesselatorImpl();
- }
-
-
- private void makeDormant() {
- /* Return the tessellator to its original dormant state. */
-
- if (mesh != null) {
- Mesh.__gl_meshDeleteMesh(mesh);
- }
- state = TessState.T_DORMANT;
- lastEdge = null;
- mesh = null;
- }
-
- private void requireState(int newState) {
- if (state != newState) gotoState(newState);
- }
-
- private void gotoState(int newState) {
- while (state != newState) {
- /* We change the current state one level at a time, to get to
- * the desired state.
- */
- if (state < newState) {
- if (state == TessState.T_DORMANT) {
- callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_POLYGON);
- gluTessBeginPolygon(null);
- } else if (state == TessState.T_IN_POLYGON) {
- callErrorOrErrorData(GLU.GLU_TESS_MISSING_BEGIN_CONTOUR);
- gluTessBeginContour();
- }
- } else {
- if (state == TessState.T_IN_CONTOUR) {
- callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_CONTOUR);
- gluTessEndContour();
- } else if (state == TessState.T_IN_POLYGON) {
- callErrorOrErrorData(GLU.GLU_TESS_MISSING_END_POLYGON);
- /* gluTessEndPolygon( tess ) is too much work! */
- makeDormant();
- }
- }
- }
- }
-
- public void gluDeleteTess() {
- requireState(TessState.T_DORMANT);
- }
-
- public void gluTessProperty(int which, double value) {
- switch (which) {
- case GLU.GLU_TESS_TOLERANCE:
- if (value < 0.0 || value > 1.0) break;
- relTolerance = value;
- return;
-
- case GLU.GLU_TESS_WINDING_RULE:
- int windingRule = (int) value;
- if (windingRule != value) break; /* not an integer */
-
- switch (windingRule) {
- case GLU.GLU_TESS_WINDING_ODD:
- case GLU.GLU_TESS_WINDING_NONZERO:
- case GLU.GLU_TESS_WINDING_POSITIVE:
- case GLU.GLU_TESS_WINDING_NEGATIVE:
- case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
- this.windingRule = windingRule;
- return;
- default:
- break;
- }
-
- case GLU.GLU_TESS_BOUNDARY_ONLY:
- boundaryOnly = (value != 0);
- return;
-
- default:
- callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
- return;
- }
- callErrorOrErrorData(GLU.GLU_INVALID_VALUE);
- }
-
-/* Returns tessellator property */
- public void gluGetTessProperty(int which, double[] value) {
- switch (which) {
- case GLU.GLU_TESS_TOLERANCE:
-/* tolerance should be in range [0..1] */
- assert (0.0 <= relTolerance && relTolerance <= 1.0);
- value[0] = relTolerance;
- break;
- case GLU.GLU_TESS_WINDING_RULE:
- assert (windingRule == GLU.GLU_TESS_WINDING_ODD ||
- windingRule == GLU.GLU_TESS_WINDING_NONZERO ||
- windingRule == GLU.GLU_TESS_WINDING_POSITIVE ||
- windingRule == GLU.GLU_TESS_WINDING_NEGATIVE ||
- windingRule == GLU.GLU_TESS_WINDING_ABS_GEQ_TWO);
- value[0] = windingRule;
- break;
- case GLU.GLU_TESS_BOUNDARY_ONLY:
- assert (boundaryOnly == true || boundaryOnly == false);
- value[0] = boundaryOnly ? 1 : 0;
- break;
- default:
- value[0] = 0.0;
- callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
- break;
- }
- } /* gluGetTessProperty() */
-
- public void gluTessNormal(double x, double y, double z) {
- normal[0] = x;
- normal[1] = y;
- normal[2] = z;
- }
-
- public void gluTessCallback(int which, GLUtesselatorCallback aCallback) {
- switch (which) {
- case GLU.GLU_TESS_BEGIN:
- callBegin = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_BEGIN_DATA:
- callBeginData = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_EDGE_FLAG:
- callEdgeFlag = aCallback == null ? NULL_CB : aCallback;
-/* If the client wants boundary edges to be flagged,
- * we render everything as separate triangles (no strips or fans).
- */
- flagBoundary = aCallback != null;
- return;
- case GLU.GLU_TESS_EDGE_FLAG_DATA:
- callEdgeFlagData = callBegin = aCallback == null ? NULL_CB : aCallback;
-/* If the client wants boundary edges to be flagged,
- * we render everything as separate triangles (no strips or fans).
- */
- flagBoundary = (aCallback != null);
- return;
- case GLU.GLU_TESS_VERTEX:
- callVertex = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_VERTEX_DATA:
- callVertexData = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_END:
- callEnd = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_END_DATA:
- callEndData = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_ERROR:
- callError = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_ERROR_DATA:
- callErrorData = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_COMBINE:
- callCombine = aCallback == null ? NULL_CB : aCallback;
- return;
- case GLU.GLU_TESS_COMBINE_DATA:
- callCombineData = aCallback == null ? NULL_CB : aCallback;
- return;
-// case GLU_TESS_MESH:
-// callMesh = aCallback == null ? NULL_CB : aCallback;
-// return;
- default:
- callErrorOrErrorData(GLU.GLU_INVALID_ENUM);
- return;
- }
- }
-
- private boolean addVertex(double[] coords, Object vertexData) {
- GLUhalfEdge e;
-
- e = lastEdge;
- if (e == null) {
-/* Make a self-loop (one vertex, one edge). */
-
- e = Mesh.__gl_meshMakeEdge(mesh);
- if (e == null) return false;
- if (!Mesh.__gl_meshSplice(e, e.Sym)) return false;
- } else {
-/* Create a new vertex and edge which immediately follow e
- * in the ordering around the left face.
- */
- if (Mesh.__gl_meshSplitEdge(e) == null) return false;
- e = e.Lnext;
- }
-
-/* The new vertex is now e.Org. */
- e.Org.data = vertexData;
- e.Org.coords[0] = coords[0];
- e.Org.coords[1] = coords[1];
- e.Org.coords[2] = coords[2];
-
-/* The winding of an edge says how the winding number changes as we
- * cross from the edge''s right face to its left face. We add the
- * vertices in such an order that a CCW contour will add +1 to
- * the winding number of the region inside the contour.
- */
- e.winding = 1;
- e.Sym.winding = -1;
-
- lastEdge = e;
-
- return true;
- }
-
- private void cacheVertex(double[] coords, Object vertexData) {
- if (cache[cacheCount] == null) {
- cache[cacheCount] = new CachedVertex();
- }
-
- CachedVertex v = cache[cacheCount];
-
- v.data = vertexData;
- v.coords[0] = coords[0];
- v.coords[1] = coords[1];
- v.coords[2] = coords[2];
- ++cacheCount;
- }
-
-
- private boolean flushCache() {
- CachedVertex[] v = cache;
-
- mesh = Mesh.__gl_meshNewMesh();
- if (mesh == null) return false;
-
- for (int i = 0; i < cacheCount; i++) {
- CachedVertex vertex = v[i];
- if (!addVertex(vertex.coords, vertex.data)) return false;
- }
- cacheCount = 0;
- flushCacheOnNextVertex = false;
-
- return true;
- }
-
- public void gluTessVertex(double[] coords, Object vertexData) {
- int i;
- boolean tooLarge = false;
- double x;
- double[] clamped = new double[3];
-
- requireState(TessState.T_IN_CONTOUR);
-
- if (flushCacheOnNextVertex) {
- if (!flushCache()) {
- callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
- return;
- }
- lastEdge = null;
- }
- for (i = 0; i < 3; ++i) {
- x = coords[i];
- if (x < -GLU.GLU_TESS_MAX_COORD) {
- x = -GLU.GLU_TESS_MAX_COORD;
- tooLarge = true;
- }
- if (x > GLU.GLU_TESS_MAX_COORD) {
- x = GLU.GLU_TESS_MAX_COORD;
- tooLarge = true;
- }
- clamped[i] = x;
- }
- if (tooLarge) {
- callErrorOrErrorData(GLU.GLU_TESS_COORD_TOO_LARGE);
- }
-
- if (mesh == null) {
- if (cacheCount < TESS_MAX_CACHE) {
- cacheVertex(clamped, vertexData);
- return;
- }
- if (!flushCache()) {
- callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
- return;
- }
- }
-
- if (!addVertex(clamped, vertexData)) {
- callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
- }
- }
-
-
- public void gluTessBeginPolygon(Object data) {
- requireState(TessState.T_DORMANT);
-
- state = TessState.T_IN_POLYGON;
- cacheCount = 0;
- flushCacheOnNextVertex = false;
- mesh = null;
-
- polygonData = data;
- }
-
-
- public void gluTessBeginContour() {
- requireState(TessState.T_IN_POLYGON);
-
- state = TessState.T_IN_CONTOUR;
- lastEdge = null;
- if (cacheCount > 0) {
-/* Just set a flag so we don't get confused by empty contours
- * -- these can be generated accidentally with the obsolete
- * NextContour() interface.
- */
- flushCacheOnNextVertex = true;
- }
- }
-
-
- public void gluTessEndContour() {
- requireState(TessState.T_IN_CONTOUR);
- state = TessState.T_IN_POLYGON;
- }
-
- public void gluTessEndPolygon() {
- GLUmesh mesh;
-
- try {
- requireState(TessState.T_IN_POLYGON);
- state = TessState.T_DORMANT;
-
- if (this.mesh == null) {
- if (!flagBoundary /*&& callMesh == NULL_CB*/) {
-
-/* Try some special code to make the easy cases go quickly
- * (eg. convex polygons). This code does NOT handle multiple contours,
- * intersections, edge flags, and of course it does not generate
- * an explicit mesh either.
- */
- if (Render.__gl_renderCache(this)) {
- polygonData = null;
- return;
- }
- }
- if (!flushCache()) throw new RuntimeException(); /* could've used a label*/
- }
-
-/* Determine the polygon normal and project vertices onto the plane
- * of the polygon.
- */
- Normal.__gl_projectPolygon(this);
-
-/* __gl_computeInterior( tess ) computes the planar arrangement specified
- * by the given contours, and further subdivides this arrangement
- * into regions. Each region is marked "inside" if it belongs
- * to the polygon, according to the rule given by windingRule.
- * Each interior region is guaranteed be monotone.
- */
- if (!Sweep.__gl_computeInterior(this)) {
- throw new RuntimeException(); /* could've used a label */
- }
-
- mesh = this.mesh;
- if (!fatalError) {
- boolean rc = true;
-
-/* If the user wants only the boundary contours, we throw away all edges
- * except those which separate the interior from the exterior.
- * Otherwise we tessellate all the regions marked "inside".
- */
- if (boundaryOnly) {
- rc = TessMono.__gl_meshSetWindingNumber(mesh, 1, true);
- } else {
- rc = TessMono.__gl_meshTessellateInterior(mesh);
- }
- if (!rc) throw new RuntimeException(); /* could've used a label */
-
- Mesh.__gl_meshCheckMesh(mesh);
-
- if (callBegin != NULL_CB || callEnd != NULL_CB
- || callVertex != NULL_CB || callEdgeFlag != NULL_CB
- || callBeginData != NULL_CB
- || callEndData != NULL_CB
- || callVertexData != NULL_CB
- || callEdgeFlagData != NULL_CB) {
- if (boundaryOnly) {
- Render.__gl_renderBoundary(this, mesh); /* output boundary contours */
- } else {
- Render.__gl_renderMesh(this, mesh); /* output strips and fans */
- }
- }
-// if (callMesh != NULL_CB) {
-//
-///* Throw away the exterior faces, so that all faces are interior.
-// * This way the user doesn't have to check the "inside" flag,
-// * and we don't need to even reveal its existence. It also leaves
-// * the freedom for an implementation to not generate the exterior
-// * faces in the first place.
-// */
-// TessMono.__gl_meshDiscardExterior(mesh);
-// callMesh.mesh(mesh); /* user wants the mesh itself */
-// mesh = null;
-// polygonData = null;
-// return;
-// }
- }
- Mesh.__gl_meshDeleteMesh(mesh);
- polygonData = null;
- mesh = null;
- } catch (Exception e) {
- e.printStackTrace();
- callErrorOrErrorData(GLU.GLU_OUT_OF_MEMORY);
- }
- }
-
- /*******************************************************/
-
-/* Obsolete calls -- for backward compatibility */
-
- public void gluBeginPolygon() {
- gluTessBeginPolygon(null);
- gluTessBeginContour();
- }
-
-
-/*ARGSUSED*/
- public void gluNextContour(int type) {
- gluTessEndContour();
- gluTessBeginContour();
- }
-
-
- public void gluEndPolygon() {
- gluTessEndContour();
- gluTessEndPolygon();
- }
-
- void callBeginOrBeginData(int a) {
- if (callBeginData != NULL_CB)
- callBeginData.beginData(a, polygonData);
- else
- callBegin.begin(a);
- }
-
- void callVertexOrVertexData(Object a) {
- if (callVertexData != NULL_CB)
- callVertexData.vertexData(a, polygonData);
- else
- callVertex.vertex(a);
- }
-
- void callEdgeFlagOrEdgeFlagData(boolean a) {
- if (callEdgeFlagData != NULL_CB)
- callEdgeFlagData.edgeFlagData(a, polygonData);
- else
- callEdgeFlag.edgeFlag(a);
- }
-
- void callEndOrEndData() {
- if (callEndData != NULL_CB)
- callEndData.endData(polygonData);
- else
- callEnd.end();
- }
-
- void callCombineOrCombineData(double[] coords, Object[] vertexData, float[] weights, Object[] outData) {
- if (callCombineData != NULL_CB)
- callCombineData.combineData(coords, vertexData, weights, outData, polygonData);
- else
- callCombine.combine(coords, vertexData, weights, outData);
- }
-
- void callErrorOrErrorData(int a) {
- if (callErrorData != NULL_CB)
- callErrorData.errorData(a, polygonData);
- else
- callError.error(a);
- }
-
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/GLUvertex.java b/src/net/java/games/jogl/impl/tesselator/GLUvertex.java
deleted file mode 100644
index 6497aa2d7..000000000
--- a/src/net/java/games/jogl/impl/tesselator/GLUvertex.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class GLUvertex {
- public GLUvertex next; /* next vertex (never NULL) */
- public GLUvertex prev; /* previous vertex (never NULL) */
- public net.java.games.jogl.impl.tesselator.GLUhalfEdge anEdge; /* a half-edge with this origin */
- public Object data; /* client's data */
-
- /* Internal data (keep hidden) */
- public double[] coords = new double[3]; /* vertex location in 3D */
- public double s, t; /* projection onto the sweep plane */
- public int pqHandle; /* to allow deletion from priority queue */
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Geom.java b/src/net/java/games/jogl/impl/tesselator/Geom.java
deleted file mode 100644
index 9693b3a48..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Geom.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class Geom {
- private Geom() {
- }
-
- /* Given three vertices u,v,w such that VertLeq(u,v) && VertLeq(v,w),
- * evaluates the t-coord of the edge uw at the s-coord of the vertex v.
- * Returns v->t - (uw)(v->s), ie. the signed distance from uw to v.
- * If uw is vertical (and thus passes thru v), the result is zero.
- *
- * The calculation is extremely accurate and stable, even when v
- * is very close to u or w. In particular if we set v->t = 0 and
- * let r be the negated result (this evaluates (uw)(v->s)), then
- * r is guaranteed to satisfy MIN(u->t,w->t) <= r <= MAX(u->t,w->t).
- */
- static double EdgeEval(GLUvertex u, GLUvertex v, GLUvertex w) {
- double gapL, gapR;
-
- assert (VertLeq(u, v) && VertLeq(v, w));
-
- gapL = v.s - u.s;
- gapR = w.s - v.s;
-
- if (gapL + gapR > 0) {
- if (gapL < gapR) {
- return (v.t - u.t) + (u.t - w.t) * (gapL / (gapL + gapR));
- } else {
- return (v.t - w.t) + (w.t - u.t) * (gapR / (gapL + gapR));
- }
- }
- /* vertical line */
- return 0;
- }
-
- static double EdgeSign(GLUvertex u, GLUvertex v, GLUvertex w) {
- double gapL, gapR;
-
- assert (VertLeq(u, v) && VertLeq(v, w));
-
- gapL = v.s - u.s;
- gapR = w.s - v.s;
-
- if (gapL + gapR > 0) {
- return (v.t - w.t) * gapL + (v.t - u.t) * gapR;
- }
- /* vertical line */
- return 0;
- }
-
-
- /***********************************************************************
- * Define versions of EdgeSign, EdgeEval with s and t transposed.
- */
-
- static double TransEval(GLUvertex u, GLUvertex v, GLUvertex w) {
- /* Given three vertices u,v,w such that TransLeq(u,v) && TransLeq(v,w),
- * evaluates the t-coord of the edge uw at the s-coord of the vertex v.
- * Returns v->s - (uw)(v->t), ie. the signed distance from uw to v.
- * If uw is vertical (and thus passes thru v), the result is zero.
- *
- * The calculation is extremely accurate and stable, even when v
- * is very close to u or w. In particular if we set v->s = 0 and
- * let r be the negated result (this evaluates (uw)(v->t)), then
- * r is guaranteed to satisfy MIN(u->s,w->s) <= r <= MAX(u->s,w->s).
- */
- double gapL, gapR;
-
- assert (TransLeq(u, v) && TransLeq(v, w));
-
- gapL = v.t - u.t;
- gapR = w.t - v.t;
-
- if (gapL + gapR > 0) {
- if (gapL < gapR) {
- return (v.s - u.s) + (u.s - w.s) * (gapL / (gapL + gapR));
- } else {
- return (v.s - w.s) + (w.s - u.s) * (gapR / (gapL + gapR));
- }
- }
- /* vertical line */
- return 0;
- }
-
- static double TransSign(GLUvertex u, GLUvertex v, GLUvertex w) {
- /* Returns a number whose sign matches TransEval(u,v,w) but which
- * is cheaper to evaluate. Returns > 0, == 0 , or < 0
- * as v is above, on, or below the edge uw.
- */
- double gapL, gapR;
-
- assert (TransLeq(u, v) && TransLeq(v, w));
-
- gapL = v.t - u.t;
- gapR = w.t - v.t;
-
- if (gapL + gapR > 0) {
- return (v.s - w.s) * gapL + (v.s - u.s) * gapR;
- }
- /* vertical line */
- return 0;
- }
-
-
- static boolean VertCCW(GLUvertex u, GLUvertex v, GLUvertex w) {
- /* For almost-degenerate situations, the results are not reliable.
- * Unless the floating-point arithmetic can be performed without
- * rounding errors, *any* implementation will give incorrect results
- * on some degenerate inputs, so the client must have some way to
- * handle this situation.
- */
- return (u.s * (v.t - w.t) + v.s * (w.t - u.t) + w.s * (u.t - v.t)) >= 0;
- }
-
-/* Given parameters a,x,b,y returns the value (b*x+a*y)/(a+b),
- * or (x+y)/2 if a==b==0. It requires that a,b >= 0, and enforces
- * this in the rare case that one argument is slightly negative.
- * The implementation is extremely stable numerically.
- * In particular it guarantees that the result r satisfies
- * MIN(x,y) <= r <= MAX(x,y), and the results are very accurate
- * even when a and b differ greatly in magnitude.
- */
- static double Interpolate(double a, double x, double b, double y) {
- a = (a < 0) ? 0 : a;
- b = (b < 0) ? 0 : b;
- if (a <= b) {
- if (b == 0) {
- return (x + y) / 2.0;
- } else {
- return (x + (y - x) * (a / (a + b)));
- }
- } else {
- return (y + (x - y) * (b / (a + b)));
- }
- }
-
- static void EdgeIntersect(GLUvertex o1, GLUvertex d1,
- GLUvertex o2, GLUvertex d2,
- GLUvertex v)
-/* Given edges (o1,d1) and (o2,d2), compute their point of intersection.
- * The computed point is guaranteed to lie in the intersection of the
- * bounding rectangles defined by each edge.
- */ {
- double z1, z2;
-
- /* This is certainly not the most efficient way to find the intersection
- * of two line segments, but it is very numerically stable.
- *
- * Strategy: find the two middle vertices in the VertLeq ordering,
- * and interpolate the intersection s-value from these. Then repeat
- * using the TransLeq ordering to find the intersection t-value.
- */
-
- if (!VertLeq(o1, d1)) {
- GLUvertex temp = o1;
- o1 = d1;
- d1 = temp;
- }
- if (!VertLeq(o2, d2)) {
- GLUvertex temp = o2;
- o2 = d2;
- d2 = temp;
- }
- if (!VertLeq(o1, o2)) {
- GLUvertex temp = o1;
- o1 = o2;
- o2 = temp;
- temp = d1;
- d1 = d2;
- d2 = temp;
- }
-
- if (!VertLeq(o2, d1)) {
- /* Technically, no intersection -- do our best */
- v.s = (o2.s + d1.s) / 2.0;
- } else if (VertLeq(d1, d2)) {
- /* Interpolate between o2 and d1 */
- z1 = EdgeEval(o1, o2, d1);
- z2 = EdgeEval(o2, d1, d2);
- if (z1 + z2 < 0) {
- z1 = -z1;
- z2 = -z2;
- }
- v.s = Interpolate(z1, o2.s, z2, d1.s);
- } else {
- /* Interpolate between o2 and d2 */
- z1 = EdgeSign(o1, o2, d1);
- z2 = -EdgeSign(o1, d2, d1);
- if (z1 + z2 < 0) {
- z1 = -z1;
- z2 = -z2;
- }
- v.s = Interpolate(z1, o2.s, z2, d2.s);
- }
-
- /* Now repeat the process for t */
-
- if (!TransLeq(o1, d1)) {
- GLUvertex temp = o1;
- o1 = d1;
- d1 = temp;
- }
- if (!TransLeq(o2, d2)) {
- GLUvertex temp = o2;
- o2 = d2;
- d2 = temp;
- }
- if (!TransLeq(o1, o2)) {
- GLUvertex temp = o2;
- o2 = o1;
- o1 = temp;
- temp = d2;
- d2 = d1;
- d1 = temp;
- }
-
- if (!TransLeq(o2, d1)) {
- /* Technically, no intersection -- do our best */
- v.t = (o2.t + d1.t) / 2.0;
- } else if (TransLeq(d1, d2)) {
- /* Interpolate between o2 and d1 */
- z1 = TransEval(o1, o2, d1);
- z2 = TransEval(o2, d1, d2);
- if (z1 + z2 < 0) {
- z1 = -z1;
- z2 = -z2;
- }
- v.t = Interpolate(z1, o2.t, z2, d1.t);
- } else {
- /* Interpolate between o2 and d2 */
- z1 = TransSign(o1, o2, d1);
- z2 = -TransSign(o1, d2, d1);
- if (z1 + z2 < 0) {
- z1 = -z1;
- z2 = -z2;
- }
- v.t = Interpolate(z1, o2.t, z2, d2.t);
- }
- }
-
- static boolean VertEq(GLUvertex u, GLUvertex v) {
- return u.s == v.s && u.t == v.t;
- }
-
- static boolean VertLeq(GLUvertex u, GLUvertex v) {
- return u.s < v.s || (u.s == v.s && u.t <= v.t);
- }
-
-/* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
-
- static boolean TransLeq(GLUvertex u, GLUvertex v) {
- return u.t < v.t || (u.t == v.t && u.s <= v.s);
- }
-
- static boolean EdgeGoesLeft(GLUhalfEdge e) {
- return VertLeq(e.Sym.Org, e.Org);
- }
-
- static boolean EdgeGoesRight(GLUhalfEdge e) {
- return VertLeq(e.Org, e.Sym.Org);
- }
-
- static double VertL1dist(GLUvertex u, GLUvertex v) {
- return Math.abs(u.s - v.s) + Math.abs(u.t - v.t);
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Mesh.java b/src/net/java/games/jogl/impl/tesselator/Mesh.java
deleted file mode 100644
index 4eee1f8ac..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Mesh.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class Mesh {
- private Mesh() {
- }
-
- /************************ Utility Routines ************************/
-/* MakeEdge creates a new pair of half-edges which form their own loop.
- * No vertex or face structures are allocated, but these must be assigned
- * before the current edge operation is completed.
- */
- static net.java.games.jogl.impl.tesselator.GLUhalfEdge MakeEdge(net.java.games.jogl.impl.tesselator.GLUhalfEdge eNext) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eSym;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge ePrev;
-
-// EdgePair * pair = (EdgePair *)
-// memAlloc(sizeof(EdgePair));
-// if (pair == NULL) return NULL;
-//
-// e = &pair - > e;
- e = new net.java.games.jogl.impl.tesselator.GLUhalfEdge(true);
-// eSym = &pair - > eSym;
- eSym = new net.java.games.jogl.impl.tesselator.GLUhalfEdge(false);
-
-
- /* Make sure eNext points to the first edge of the edge pair */
- if (!eNext.first) {
- eNext = eNext.Sym;
- }
-
- /* Insert in circular doubly-linked list before eNext.
- * Note that the prev pointer is stored in Sym->next.
- */
- ePrev = eNext.Sym.next;
- eSym.next = ePrev;
- ePrev.Sym.next = e;
- e.next = eNext;
- eNext.Sym.next = eSym;
-
- e.Sym = eSym;
- e.Onext = e;
- e.Lnext = eSym;
- e.Org = null;
- e.Lface = null;
- e.winding = 0;
- e.activeRegion = null;
-
- eSym.Sym = e;
- eSym.Onext = eSym;
- eSym.Lnext = e;
- eSym.Org = null;
- eSym.Lface = null;
- eSym.winding = 0;
- eSym.activeRegion = null;
-
- return e;
- }
-
-/* Splice( a, b ) is best described by the Guibas/Stolfi paper or the
- * CS348a notes (see mesh.h). Basically it modifies the mesh so that
- * a->Onext and b->Onext are exchanged. This can have various effects
- * depending on whether a and b belong to different face or vertex rings.
- * For more explanation see __gl_meshSplice() below.
- */
- static void Splice(net.java.games.jogl.impl.tesselator.GLUhalfEdge a, net.java.games.jogl.impl.tesselator.GLUhalfEdge b) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge aOnext = a.Onext;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge bOnext = b.Onext;
-
- aOnext.Sym.Lnext = b;
- bOnext.Sym.Lnext = a;
- a.Onext = bOnext;
- b.Onext = aOnext;
- }
-
-/* MakeVertex( newVertex, eOrig, vNext ) attaches a new vertex and makes it the
- * origin of all edges in the vertex loop to which eOrig belongs. "vNext" gives
- * a place to insert the new vertex in the global vertex list. We insert
- * the new vertex *before* vNext so that algorithms which walk the vertex
- * list will not see the newly created vertices.
- */
- static void MakeVertex(net.java.games.jogl.impl.tesselator.GLUvertex newVertex,
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrig, net.java.games.jogl.impl.tesselator.GLUvertex vNext) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
- net.java.games.jogl.impl.tesselator.GLUvertex vPrev;
- net.java.games.jogl.impl.tesselator.GLUvertex vNew = newVertex;
-
- assert (vNew != null);
-
- /* insert in circular doubly-linked list before vNext */
- vPrev = vNext.prev;
- vNew.prev = vPrev;
- vPrev.next = vNew;
- vNew.next = vNext;
- vNext.prev = vNew;
-
- vNew.anEdge = eOrig;
- vNew.data = null;
- /* leave coords, s, t undefined */
-
- /* fix other edges on this vertex loop */
- e = eOrig;
- do {
- e.Org = vNew;
- e = e.Onext;
- } while (e != eOrig);
- }
-
-/* MakeFace( newFace, eOrig, fNext ) attaches a new face and makes it the left
- * face of all edges in the face loop to which eOrig belongs. "fNext" gives
- * a place to insert the new face in the global face list. We insert
- * the new face *before* fNext so that algorithms which walk the face
- * list will not see the newly created faces.
- */
- static void MakeFace(net.java.games.jogl.impl.tesselator.GLUface newFace, net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrig, net.java.games.jogl.impl.tesselator.GLUface fNext) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
- net.java.games.jogl.impl.tesselator.GLUface fPrev;
- net.java.games.jogl.impl.tesselator.GLUface fNew = newFace;
-
- assert (fNew != null);
-
- /* insert in circular doubly-linked list before fNext */
- fPrev = fNext.prev;
- fNew.prev = fPrev;
- fPrev.next = fNew;
- fNew.next = fNext;
- fNext.prev = fNew;
-
- fNew.anEdge = eOrig;
- fNew.data = null;
- fNew.trail = null;
- fNew.marked = false;
-
- /* The new face is marked "inside" if the old one was. This is a
- * convenience for the common case where a face has been split in two.
- */
- fNew.inside = fNext.inside;
-
- /* fix other edges on this face loop */
- e = eOrig;
- do {
- e.Lface = fNew;
- e = e.Lnext;
- } while (e != eOrig);
- }
-
-/* KillEdge( eDel ) destroys an edge (the half-edges eDel and eDel->Sym),
- * and removes from the global edge list.
- */
- static void KillEdge(net.java.games.jogl.impl.tesselator.GLUhalfEdge eDel) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge ePrev, eNext;
-
- /* Half-edges are allocated in pairs, see EdgePair above */
- if (!eDel.first) {
- eDel = eDel.Sym;
- }
-
- /* delete from circular doubly-linked list */
- eNext = eDel.next;
- ePrev = eDel.Sym.next;
- eNext.Sym.next = ePrev;
- ePrev.Sym.next = eNext;
- }
-
-
-/* KillVertex( vDel ) destroys a vertex and removes it from the global
- * vertex list. It updates the vertex loop to point to a given new vertex.
- */
- static void KillVertex(net.java.games.jogl.impl.tesselator.GLUvertex vDel, net.java.games.jogl.impl.tesselator.GLUvertex newOrg) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, eStart = vDel.anEdge;
- net.java.games.jogl.impl.tesselator.GLUvertex vPrev, vNext;
-
- /* change the origin of all affected edges */
- e = eStart;
- do {
- e.Org = newOrg;
- e = e.Onext;
- } while (e != eStart);
-
- /* delete from circular doubly-linked list */
- vPrev = vDel.prev;
- vNext = vDel.next;
- vNext.prev = vPrev;
- vPrev.next = vNext;
- }
-
-/* KillFace( fDel ) destroys a face and removes it from the global face
- * list. It updates the face loop to point to a given new face.
- */
- static void KillFace(net.java.games.jogl.impl.tesselator.GLUface fDel, net.java.games.jogl.impl.tesselator.GLUface newLface) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, eStart = fDel.anEdge;
- net.java.games.jogl.impl.tesselator.GLUface fPrev, fNext;
-
- /* change the left face of all affected edges */
- e = eStart;
- do {
- e.Lface = newLface;
- e = e.Lnext;
- } while (e != eStart);
-
- /* delete from circular doubly-linked list */
- fPrev = fDel.prev;
- fNext = fDel.next;
- fNext.prev = fPrev;
- fPrev.next = fNext;
- }
-
-
- /****************** Basic Edge Operations **********************/
-
-/* __gl_meshMakeEdge creates one edge, two vertices, and a loop (face).
- * The loop consists of the two new half-edges.
- */
- public static net.java.games.jogl.impl.tesselator.GLUhalfEdge __gl_meshMakeEdge(net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUvertex newVertex1 = new net.java.games.jogl.impl.tesselator.GLUvertex();
- net.java.games.jogl.impl.tesselator.GLUvertex newVertex2 = new net.java.games.jogl.impl.tesselator.GLUvertex();
- net.java.games.jogl.impl.tesselator.GLUface newFace = new net.java.games.jogl.impl.tesselator.GLUface();
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
-
- e = MakeEdge(mesh.eHead);
- if (e == null) return null;
-
- MakeVertex(newVertex1, e, mesh.vHead);
- MakeVertex(newVertex2, e.Sym, mesh.vHead);
- MakeFace(newFace, e, mesh.fHead);
- return e;
- }
-
-
-/* __gl_meshSplice( eOrg, eDst ) is the basic operation for changing the
- * mesh connectivity and topology. It changes the mesh so that
- * eOrg->Onext <- OLD( eDst->Onext )
- * eDst->Onext <- OLD( eOrg->Onext )
- * where OLD(...) means the value before the meshSplice operation.
- *
- * This can have two effects on the vertex structure:
- * - if eOrg->Org != eDst->Org, the two vertices are merged together
- * - if eOrg->Org == eDst->Org, the origin is split into two vertices
- * In both cases, eDst->Org is changed and eOrg->Org is untouched.
- *
- * Similarly (and independently) for the face structure,
- * - if eOrg->Lface == eDst->Lface, one loop is split into two
- * - if eOrg->Lface != eDst->Lface, two distinct loops are joined into one
- * In both cases, eDst->Lface is changed and eOrg->Lface is unaffected.
- *
- * Some special cases:
- * If eDst == eOrg, the operation has no effect.
- * If eDst == eOrg->Lnext, the new face will have a single edge.
- * If eDst == eOrg->Lprev, the old face will have a single edge.
- * If eDst == eOrg->Onext, the new vertex will have a single edge.
- * If eDst == eOrg->Oprev, the old vertex will have a single edge.
- */
- public static boolean __gl_meshSplice(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrg, net.java.games.jogl.impl.tesselator.GLUhalfEdge eDst) {
- boolean joiningLoops = false;
- boolean joiningVertices = false;
-
- if (eOrg == eDst) return true;
-
- if (eDst.Org != eOrg.Org) {
- /* We are merging two disjoint vertices -- destroy eDst->Org */
- joiningVertices = true;
- KillVertex(eDst.Org, eOrg.Org);
- }
- if (eDst.Lface != eOrg.Lface) {
- /* We are connecting two disjoint loops -- destroy eDst.Lface */
- joiningLoops = true;
- KillFace(eDst.Lface, eOrg.Lface);
- }
-
- /* Change the edge structure */
- Splice(eDst, eOrg);
-
- if (!joiningVertices) {
- net.java.games.jogl.impl.tesselator.GLUvertex newVertex = new net.java.games.jogl.impl.tesselator.GLUvertex();
-
- /* We split one vertex into two -- the new vertex is eDst.Org.
- * Make sure the old vertex points to a valid half-edge.
- */
- MakeVertex(newVertex, eDst, eOrg.Org);
- eOrg.Org.anEdge = eOrg;
- }
- if (!joiningLoops) {
- net.java.games.jogl.impl.tesselator.GLUface newFace = new net.java.games.jogl.impl.tesselator.GLUface();
-
- /* We split one loop into two -- the new loop is eDst.Lface.
- * Make sure the old face points to a valid half-edge.
- */
- MakeFace(newFace, eDst, eOrg.Lface);
- eOrg.Lface.anEdge = eOrg;
- }
-
- return true;
- }
-
-
-/* __gl_meshDelete( eDel ) removes the edge eDel. There are several cases:
- * if (eDel.Lface != eDel.Rface), we join two loops into one; the loop
- * eDel.Lface is deleted. Otherwise, we are splitting one loop into two;
- * the newly created loop will contain eDel.Dst. If the deletion of eDel
- * would create isolated vertices, those are deleted as well.
- *
- * This function could be implemented as two calls to __gl_meshSplice
- * plus a few calls to memFree, but this would allocate and delete
- * unnecessary vertices and faces.
- */
- static boolean __gl_meshDelete(net.java.games.jogl.impl.tesselator.GLUhalfEdge eDel) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eDelSym = eDel.Sym;
- boolean joiningLoops = false;
-
- /* First step: disconnect the origin vertex eDel.Org. We make all
- * changes to get a consistent mesh in this "intermediate" state.
- */
- if (eDel.Lface != eDel.Sym.Lface) {
- /* We are joining two loops into one -- remove the left face */
- joiningLoops = true;
- KillFace(eDel.Lface, eDel.Sym.Lface);
- }
-
- if (eDel.Onext == eDel) {
- KillVertex(eDel.Org, null);
- } else {
- /* Make sure that eDel.Org and eDel.Sym.Lface point to valid half-edges */
- eDel.Sym.Lface.anEdge = eDel.Sym.Lnext;
- eDel.Org.anEdge = eDel.Onext;
-
- Splice(eDel, eDel.Sym.Lnext);
- if (!joiningLoops) {
- net.java.games.jogl.impl.tesselator.GLUface newFace = new net.java.games.jogl.impl.tesselator.GLUface();
-
- /* We are splitting one loop into two -- create a new loop for eDel. */
- MakeFace(newFace, eDel, eDel.Lface);
- }
- }
-
- /* Claim: the mesh is now in a consistent state, except that eDel.Org
- * may have been deleted. Now we disconnect eDel.Dst.
- */
- if (eDelSym.Onext == eDelSym) {
- KillVertex(eDelSym.Org, null);
- KillFace(eDelSym.Lface, null);
- } else {
- /* Make sure that eDel.Dst and eDel.Lface point to valid half-edges */
- eDel.Lface.anEdge = eDelSym.Sym.Lnext;
- eDelSym.Org.anEdge = eDelSym.Onext;
- Splice(eDelSym, eDelSym.Sym.Lnext);
- }
-
- /* Any isolated vertices or faces have already been freed. */
- KillEdge(eDel);
-
- return true;
- }
-
-
- /******************** Other Edge Operations **********************/
-
-/* All these routines can be implemented with the basic edge
- * operations above. They are provided for convenience and efficiency.
- */
-
-
-/* __gl_meshAddEdgeVertex( eOrg ) creates a new edge eNew such that
- * eNew == eOrg.Lnext, and eNew.Dst is a newly created vertex.
- * eOrg and eNew will have the same left face.
- */
- static net.java.games.jogl.impl.tesselator.GLUhalfEdge __gl_meshAddEdgeVertex(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrg) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eNewSym;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eNew = MakeEdge(eOrg);
-
- eNewSym = eNew.Sym;
-
- /* Connect the new edge appropriately */
- Splice(eNew, eOrg.Lnext);
-
- /* Set the vertex and face information */
- eNew.Org = eOrg.Sym.Org;
- {
- net.java.games.jogl.impl.tesselator.GLUvertex newVertex = new net.java.games.jogl.impl.tesselator.GLUvertex();
-
- MakeVertex(newVertex, eNewSym, eNew.Org);
- }
- eNew.Lface = eNewSym.Lface = eOrg.Lface;
-
- return eNew;
- }
-
-
-/* __gl_meshSplitEdge( eOrg ) splits eOrg into two edges eOrg and eNew,
- * such that eNew == eOrg.Lnext. The new vertex is eOrg.Sym.Org == eNew.Org.
- * eOrg and eNew will have the same left face.
- */
- public static net.java.games.jogl.impl.tesselator.GLUhalfEdge __gl_meshSplitEdge(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrg) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eNew;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge tempHalfEdge = __gl_meshAddEdgeVertex(eOrg);
-
- eNew = tempHalfEdge.Sym;
-
- /* Disconnect eOrg from eOrg.Sym.Org and connect it to eNew.Org */
- Splice(eOrg.Sym, eOrg.Sym.Sym.Lnext);
- Splice(eOrg.Sym, eNew);
-
- /* Set the vertex and face information */
- eOrg.Sym.Org = eNew.Org;
- eNew.Sym.Org.anEdge = eNew.Sym; /* may have pointed to eOrg.Sym */
- eNew.Sym.Lface = eOrg.Sym.Lface;
- eNew.winding = eOrg.winding; /* copy old winding information */
- eNew.Sym.winding = eOrg.Sym.winding;
-
- return eNew;
- }
-
-
-/* __gl_meshConnect( eOrg, eDst ) creates a new edge from eOrg.Sym.Org
- * to eDst.Org, and returns the corresponding half-edge eNew.
- * If eOrg.Lface == eDst.Lface, this splits one loop into two,
- * and the newly created loop is eNew.Lface. Otherwise, two disjoint
- * loops are merged into one, and the loop eDst.Lface is destroyed.
- *
- * If (eOrg == eDst), the new face will have only two edges.
- * If (eOrg.Lnext == eDst), the old face is reduced to a single edge.
- * If (eOrg.Lnext.Lnext == eDst), the old face is reduced to two edges.
- */
- static net.java.games.jogl.impl.tesselator.GLUhalfEdge __gl_meshConnect(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrg, net.java.games.jogl.impl.tesselator.GLUhalfEdge eDst) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eNewSym;
- boolean joiningLoops = false;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eNew = MakeEdge(eOrg);
-
- eNewSym = eNew.Sym;
-
- if (eDst.Lface != eOrg.Lface) {
- /* We are connecting two disjoint loops -- destroy eDst.Lface */
- joiningLoops = true;
- KillFace(eDst.Lface, eOrg.Lface);
- }
-
- /* Connect the new edge appropriately */
- Splice(eNew, eOrg.Lnext);
- Splice(eNewSym, eDst);
-
- /* Set the vertex and face information */
- eNew.Org = eOrg.Sym.Org;
- eNewSym.Org = eDst.Org;
- eNew.Lface = eNewSym.Lface = eOrg.Lface;
-
- /* Make sure the old face points to a valid half-edge */
- eOrg.Lface.anEdge = eNewSym;
-
- if (!joiningLoops) {
- net.java.games.jogl.impl.tesselator.GLUface newFace = new net.java.games.jogl.impl.tesselator.GLUface();
-
- /* We split one loop into two -- the new loop is eNew.Lface */
- MakeFace(newFace, eNew, eOrg.Lface);
- }
- return eNew;
- }
-
-
- /******************** Other Operations **********************/
-
-/* __gl_meshZapFace( fZap ) destroys a face and removes it from the
- * global face list. All edges of fZap will have a null pointer as their
- * left face. Any edges which also have a null pointer as their right face
- * are deleted entirely (along with any isolated vertices this produces).
- * An entire mesh can be deleted by zapping its faces, one at a time,
- * in any order. Zapped faces cannot be used in further mesh operations!
- */
- static void __gl_meshZapFace(net.java.games.jogl.impl.tesselator.GLUface fZap) {
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eStart = fZap.anEdge;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, eNext, eSym;
- net.java.games.jogl.impl.tesselator.GLUface fPrev, fNext;
-
- /* walk around face, deleting edges whose right face is also null */
- eNext = eStart.Lnext;
- do {
- e = eNext;
- eNext = e.Lnext;
-
- e.Lface = null;
- if (e.Sym.Lface == null) {
- /* delete the edge -- see __gl_MeshDelete above */
-
- if (e.Onext == e) {
- KillVertex(e.Org, null);
- } else {
- /* Make sure that e.Org points to a valid half-edge */
- e.Org.anEdge = e.Onext;
- Splice(e, e.Sym.Lnext);
- }
- eSym = e.Sym;
- if (eSym.Onext == eSym) {
- KillVertex(eSym.Org, null);
- } else {
- /* Make sure that eSym.Org points to a valid half-edge */
- eSym.Org.anEdge = eSym.Onext;
- Splice(eSym, eSym.Sym.Lnext);
- }
- KillEdge(e);
- }
- } while (e != eStart);
-
- /* delete from circular doubly-linked list */
- fPrev = fZap.prev;
- fNext = fZap.next;
- fNext.prev = fPrev;
- fPrev.next = fNext;
- }
-
-
-/* __gl_meshNewMesh() creates a new mesh with no edges, no vertices,
- * and no loops (what we usually call a "face").
- */
- public static net.java.games.jogl.impl.tesselator.GLUmesh __gl_meshNewMesh() {
- net.java.games.jogl.impl.tesselator.GLUvertex v;
- net.java.games.jogl.impl.tesselator.GLUface f;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eSym;
- net.java.games.jogl.impl.tesselator.GLUmesh mesh = new net.java.games.jogl.impl.tesselator.GLUmesh();
-
- v = mesh.vHead;
- f = mesh.fHead;
- e = mesh.eHead;
- eSym = mesh.eHeadSym;
-
- v.next = v.prev = v;
- v.anEdge = null;
- v.data = null;
-
- f.next = f.prev = f;
- f.anEdge = null;
- f.data = null;
- f.trail = null;
- f.marked = false;
- f.inside = false;
-
- e.next = e;
- e.Sym = eSym;
- e.Onext = null;
- e.Lnext = null;
- e.Org = null;
- e.Lface = null;
- e.winding = 0;
- e.activeRegion = null;
-
- eSym.next = eSym;
- eSym.Sym = e;
- eSym.Onext = null;
- eSym.Lnext = null;
- eSym.Org = null;
- eSym.Lface = null;
- eSym.winding = 0;
- eSym.activeRegion = null;
-
- return mesh;
- }
-
-
-/* __gl_meshUnion( mesh1, mesh2 ) forms the union of all structures in
- * both meshes, and returns the new mesh (the old meshes are destroyed).
- */
- static net.java.games.jogl.impl.tesselator.GLUmesh __gl_meshUnion(net.java.games.jogl.impl.tesselator.GLUmesh mesh1, net.java.games.jogl.impl.tesselator.GLUmesh mesh2) {
- net.java.games.jogl.impl.tesselator.GLUface f1 = mesh1.fHead;
- net.java.games.jogl.impl.tesselator.GLUvertex v1 = mesh1.vHead;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e1 = mesh1.eHead;
- net.java.games.jogl.impl.tesselator.GLUface f2 = mesh2.fHead;
- net.java.games.jogl.impl.tesselator.GLUvertex v2 = mesh2.vHead;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e2 = mesh2.eHead;
-
- /* Add the faces, vertices, and edges of mesh2 to those of mesh1 */
- if (f2.next != f2) {
- f1.prev.next = f2.next;
- f2.next.prev = f1.prev;
- f2.prev.next = f1;
- f1.prev = f2.prev;
- }
-
- if (v2.next != v2) {
- v1.prev.next = v2.next;
- v2.next.prev = v1.prev;
- v2.prev.next = v1;
- v1.prev = v2.prev;
- }
-
- if (e2.next != e2) {
- e1.Sym.next.Sym.next = e2.next;
- e2.next.Sym.next = e1.Sym.next;
- e2.Sym.next.Sym.next = e1;
- e1.Sym.next = e2.Sym.next;
- }
-
- return mesh1;
- }
-
-
-/* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh.
- */
- static void __gl_meshDeleteMeshZap(net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUface fHead = mesh.fHead;
-
- while (fHead.next != fHead) {
- __gl_meshZapFace(fHead.next);
- }
- assert (mesh.vHead.next == mesh.vHead);
- }
-
-/* __gl_meshDeleteMesh( mesh ) will free all storage for any valid mesh.
- */
- public static void __gl_meshDeleteMesh(net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUface f, fNext;
- net.java.games.jogl.impl.tesselator.GLUvertex v, vNext;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, eNext;
-
- for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) {
- fNext = f.next;
- }
-
- for (v = mesh.vHead.next; v != mesh.vHead; v = vNext) {
- vNext = v.next;
- }
-
- for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) {
- /* One call frees both e and e.Sym (see EdgePair above) */
- eNext = e.next;
- }
- }
-
-/* __gl_meshCheckMesh( mesh ) checks a mesh for self-consistency.
- */
- public static void __gl_meshCheckMesh(net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUface fHead = mesh.fHead;
- net.java.games.jogl.impl.tesselator.GLUvertex vHead = mesh.vHead;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eHead = mesh.eHead;
- net.java.games.jogl.impl.tesselator.GLUface f, fPrev;
- net.java.games.jogl.impl.tesselator.GLUvertex v, vPrev;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, ePrev;
-
- fPrev = fHead;
- for (fPrev = fHead; (f = fPrev.next) != fHead; fPrev = f) {
- assert (f.prev == fPrev);
- e = f.anEdge;
- do {
- assert (e.Sym != e);
- assert (e.Sym.Sym == e);
- assert (e.Lnext.Onext.Sym == e);
- assert (e.Onext.Sym.Lnext == e);
- assert (e.Lface == f);
- e = e.Lnext;
- } while (e != f.anEdge);
- }
- assert (f.prev == fPrev && f.anEdge == null && f.data == null);
-
- vPrev = vHead;
- for (vPrev = vHead; (v = vPrev.next) != vHead; vPrev = v) {
- assert (v.prev == vPrev);
- e = v.anEdge;
- do {
- assert (e.Sym != e);
- assert (e.Sym.Sym == e);
- assert (e.Lnext.Onext.Sym == e);
- assert (e.Onext.Sym.Lnext == e);
- assert (e.Org == v);
- e = e.Onext;
- } while (e != v.anEdge);
- }
- assert (v.prev == vPrev && v.anEdge == null && v.data == null);
-
- ePrev = eHead;
- for (ePrev = eHead; (e = ePrev.next) != eHead; ePrev = e) {
- assert (e.Sym.next == ePrev.Sym);
- assert (e.Sym != e);
- assert (e.Sym.Sym == e);
- assert (e.Org != null);
- assert (e.Sym.Org != null);
- assert (e.Lnext.Onext.Sym == e);
- assert (e.Onext.Sym.Lnext == e);
- }
- assert (e.Sym.next == ePrev.Sym
- && e.Sym == mesh.eHeadSym
- && e.Sym.Sym == e
- && e.Org == null && e.Sym.Org == null
- && e.Lface == null && e.Sym.Lface == null);
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Normal.java b/src/net/java/games/jogl/impl/tesselator/Normal.java
deleted file mode 100644
index 900219662..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Normal.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-import net.java.games.jogl.*;
-
-class Normal {
- private Normal() {
- }
-
- static boolean SLANTED_SWEEP = false;
- static double S_UNIT_X; /* Pre-normalized */
- static double S_UNIT_Y;
- private static final boolean TRUE_PROJECT = false;
-
- static {
- if (SLANTED_SWEEP) {
-/* The "feature merging" is not intended to be complete. There are
- * special cases where edges are nearly parallel to the sweep line
- * which are not implemented. The algorithm should still behave
- * robustly (ie. produce a reasonable tesselation) in the presence
- * of such edges, however it may miss features which could have been
- * merged. We could minimize this effect by choosing the sweep line
- * direction to be something unusual (ie. not parallel to one of the
- * coordinate axes).
- */
- S_UNIT_X = 0.50941539564955385; /* Pre-normalized */
- S_UNIT_Y = 0.86052074622010633;
- } else {
- S_UNIT_X = 1.0;
- S_UNIT_Y = 0.0;
- }
- }
-
- private static double Dot(double[] u, double[] v) {
- return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]);
- }
-
- static void Normalize(double[] v) {
- double len = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
-
- assert (len > 0);
- len = Math.sqrt(len);
- v[0] /= len;
- v[1] /= len;
- v[2] /= len;
- }
-
- static int LongAxis(double[] v) {
- int i = 0;
-
- if (Math.abs(v[1]) > Math.abs(v[0])) {
- i = 1;
- }
- if (Math.abs(v[2]) > Math.abs(v[i])) {
- i = 2;
- }
- return i;
- }
-
- static void ComputeNormal(GLUtesselatorImpl tess, double[] norm) {
- net.java.games.jogl.impl.tesselator.GLUvertex v, v1, v2;
- double c, tLen2, maxLen2;
- double[] maxVal, minVal, d1, d2, tNorm;
- net.java.games.jogl.impl.tesselator.GLUvertex[] maxVert, minVert;
- net.java.games.jogl.impl.tesselator.GLUvertex vHead = tess.mesh.vHead;
- int i;
-
- maxVal = new double[3];
- minVal = new double[3];
- minVert = new net.java.games.jogl.impl.tesselator.GLUvertex[3];
- maxVert = new net.java.games.jogl.impl.tesselator.GLUvertex[3];
- d1 = new double[3];
- d2 = new double[3];
- tNorm = new double[3];
-
- maxVal[0] = maxVal[1] = maxVal[2] = -2 * GLU.GLU_TESS_MAX_COORD;
- minVal[0] = minVal[1] = minVal[2] = 2 * GLU.GLU_TESS_MAX_COORD;
-
- for (v = vHead.next; v != vHead; v = v.next) {
- for (i = 0; i < 3; ++i) {
- c = v.coords[i];
- if (c < minVal[i]) {
- minVal[i] = c;
- minVert[i] = v;
- }
- if (c > maxVal[i]) {
- maxVal[i] = c;
- maxVert[i] = v;
- }
- }
- }
-
-/* Find two vertices separated by at least 1/sqrt(3) of the maximum
- * distance between any two vertices
- */
- i = 0;
- if (maxVal[1] - minVal[1] > maxVal[0] - minVal[0]) {
- i = 1;
- }
- if (maxVal[2] - minVal[2] > maxVal[i] - minVal[i]) {
- i = 2;
- }
- if (minVal[i] >= maxVal[i]) {
-/* All vertices are the same -- normal doesn't matter */
- norm[0] = 0;
- norm[1] = 0;
- norm[2] = 1;
- return;
- }
-
-/* Look for a third vertex which forms the triangle with maximum area
- * (Length of normal == twice the triangle area)
- */
- maxLen2 = 0;
- v1 = minVert[i];
- v2 = maxVert[i];
- d1[0] = v1.coords[0] - v2.coords[0];
- d1[1] = v1.coords[1] - v2.coords[1];
- d1[2] = v1.coords[2] - v2.coords[2];
- for (v = vHead.next; v != vHead; v = v.next) {
- d2[0] = v.coords[0] - v2.coords[0];
- d2[1] = v.coords[1] - v2.coords[1];
- d2[2] = v.coords[2] - v2.coords[2];
- tNorm[0] = d1[1] * d2[2] - d1[2] * d2[1];
- tNorm[1] = d1[2] * d2[0] - d1[0] * d2[2];
- tNorm[2] = d1[0] * d2[1] - d1[1] * d2[0];
- tLen2 = tNorm[0] * tNorm[0] + tNorm[1] * tNorm[1] + tNorm[2] * tNorm[2];
- if (tLen2 > maxLen2) {
- maxLen2 = tLen2;
- norm[0] = tNorm[0];
- norm[1] = tNorm[1];
- norm[2] = tNorm[2];
- }
- }
-
- if (maxLen2 <= 0) {
-/* All points lie on a single line -- any decent normal will do */
- norm[0] = norm[1] = norm[2] = 0;
- norm[LongAxis(d1)] = 1;
- }
- }
-
- static void CheckOrientation(GLUtesselatorImpl tess) {
- double area;
- net.java.games.jogl.impl.tesselator.GLUface f, fHead = tess.mesh.fHead;
- net.java.games.jogl.impl.tesselator.GLUvertex v, vHead = tess.mesh.vHead;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
-
-/* When we compute the normal automatically, we choose the orientation
- * so that the the sum of the signed areas of all contours is non-negative.
- */
- area = 0;
- for (f = fHead.next; f != fHead; f = f.next) {
- e = f.anEdge;
- if (e.winding <= 0) continue;
- do {
- area += (e.Org.s - e.Sym.Org.s) * (e.Org.t + e.Sym.Org.t);
- e = e.Lnext;
- } while (e != f.anEdge);
- }
- if (area < 0) {
-/* Reverse the orientation by flipping all the t-coordinates */
- for (v = vHead.next; v != vHead; v = v.next) {
- v.t = -v.t;
- }
- tess.tUnit[0] = -tess.tUnit[0];
- tess.tUnit[1] = -tess.tUnit[1];
- tess.tUnit[2] = -tess.tUnit[2];
- }
- }
-
-/* Determine the polygon normal and project vertices onto the plane
- * of the polygon.
- */
- public static void __gl_projectPolygon(GLUtesselatorImpl tess) {
- net.java.games.jogl.impl.tesselator.GLUvertex v, vHead = tess.mesh.vHead;
- double w;
- double[] norm = new double[3];
- double[] sUnit, tUnit;
- int i;
- boolean computedNormal = false;
-
- norm[0] = tess.normal[0];
- norm[1] = tess.normal[1];
- norm[2] = tess.normal[2];
- if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) {
- ComputeNormal(tess, norm);
- computedNormal = true;
- }
- sUnit = tess.sUnit;
- tUnit = tess.tUnit;
- i = LongAxis(norm);
-
- if (TRUE_PROJECT) {
-/* Choose the initial sUnit vector to be approximately perpendicular
- * to the normal.
- */
- Normalize(norm);
-
- sUnit[i] = 0;
- sUnit[(i + 1) % 3] = S_UNIT_X;
- sUnit[(i + 2) % 3] = S_UNIT_Y;
-
-/* Now make it exactly perpendicular */
- w = Dot(sUnit, norm);
- sUnit[0] -= w * norm[0];
- sUnit[1] -= w * norm[1];
- sUnit[2] -= w * norm[2];
- Normalize(sUnit);
-
-/* Choose tUnit so that (sUnit,tUnit,norm) form a right-handed frame */
- tUnit[0] = norm[1] * sUnit[2] - norm[2] * sUnit[1];
- tUnit[1] = norm[2] * sUnit[0] - norm[0] * sUnit[2];
- tUnit[2] = norm[0] * sUnit[1] - norm[1] * sUnit[0];
- Normalize(tUnit);
- } else {
-/* Project perpendicular to a coordinate axis -- better numerically */
- sUnit[i] = 0;
- sUnit[(i + 1) % 3] = S_UNIT_X;
- sUnit[(i + 2) % 3] = S_UNIT_Y;
-
- tUnit[i] = 0;
- tUnit[(i + 1) % 3] = (norm[i] > 0) ? -S_UNIT_Y : S_UNIT_Y;
- tUnit[(i + 2) % 3] = (norm[i] > 0) ? S_UNIT_X : -S_UNIT_X;
- }
-
-/* Project the vertices onto the sweep plane */
- for (v = vHead.next; v != vHead; v = v.next) {
- v.s = Dot(v.coords, sUnit);
- v.t = Dot(v.coords, tUnit);
- }
- if (computedNormal) {
- CheckOrientation(tess);
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/PriorityQ.java b/src/net/java/games/jogl/impl/tesselator/PriorityQ.java
deleted file mode 100644
index 0f92dcecd..000000000
--- a/src/net/java/games/jogl/impl/tesselator/PriorityQ.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-abstract class PriorityQ {
- public static final int INIT_SIZE = 32;
-
- public static class PQnode {
- int handle;
- }
-
- public static class PQhandleElem {
- Object key;
- int node;
- }
-
- public static interface Leq {
- boolean leq(Object key1, Object key2);
- }
-
- // #ifdef FOR_TRITE_TEST_PROGRAM
-// private static boolean LEQ(PriorityQCommon.Leq leq, Object x,Object y) {
-// return pq.leq.leq(x,y);
-// }
-// #else
-/* Violates modularity, but a little faster */
-// #include "geom.h"
- public static boolean LEQ(Leq leq, Object x, Object y) {
- return net.java.games.jogl.impl.tesselator.Geom.VertLeq((net.java.games.jogl.impl.tesselator.GLUvertex) x, (net.java.games.jogl.impl.tesselator.GLUvertex) y);
- }
-
- static PriorityQ pqNewPriorityQ(Leq leq) {
- return new PriorityQSort(leq);
- }
-
- abstract void pqDeletePriorityQ();
-
- abstract boolean pqInit();
-
- abstract int pqInsert(Object keyNew);
-
- abstract Object pqExtractMin();
-
- abstract void pqDelete(int hCurr);
-
- abstract Object pqMinimum();
-
- abstract boolean pqIsEmpty();
-// #endif
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/PriorityQHeap.java b/src/net/java/games/jogl/impl/tesselator/PriorityQHeap.java
deleted file mode 100644
index b360e37d3..000000000
--- a/src/net/java/games/jogl/impl/tesselator/PriorityQHeap.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-
-
-class PriorityQHeap extends net.java.games.jogl.impl.tesselator.PriorityQ {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] handles;
- int size, max;
- int freeList;
- boolean initialized;
- net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq;
-
-/* really __gl_pqHeapNewPriorityQ */
- public PriorityQHeap(net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq) {
- size = 0;
- max = net.java.games.jogl.impl.tesselator.PriorityQ.INIT_SIZE;
- nodes = new net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[net.java.games.jogl.impl.tesselator.PriorityQ.INIT_SIZE + 1];
- for (int i = 0; i < nodes.length; i++) {
- nodes[i] = new PQnode();
- }
- handles = new net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[net.java.games.jogl.impl.tesselator.PriorityQ.INIT_SIZE + 1];
- for (int i = 0; i < handles.length; i++) {
- handles[i] = new PQhandleElem();
- }
- initialized = false;
- freeList = 0;
- this.leq = leq;
-
- nodes[1].handle = 1; /* so that Minimum() returns NULL */
- handles[1].key = null;
- }
-
-/* really __gl_pqHeapDeletePriorityQ */
- void pqDeletePriorityQ() {
- handles = null;
- nodes = null;
- }
-
- void FloatDown(int curr) {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] n = nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] h = handles;
- int hCurr, hChild;
- int child;
-
- hCurr = n[curr].handle;
- for (; ;) {
- child = curr << 1;
- if (child < size && LEQ(leq, h[n[child + 1].handle].key,
- h[n[child].handle].key)) {
- ++child;
- }
-
- assert (child <= max);
-
- hChild = n[child].handle;
- if (child > size || LEQ(leq, h[hCurr].key, h[hChild].key)) {
- n[curr].handle = hCurr;
- h[hCurr].node = curr;
- break;
- }
- n[curr].handle = hChild;
- h[hChild].node = curr;
- curr = child;
- }
- }
-
-
- void FloatUp(int curr) {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] n = nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] h = handles;
- int hCurr, hParent;
- int parent;
-
- hCurr = n[curr].handle;
- for (; ;) {
- parent = curr >> 1;
- hParent = n[parent].handle;
- if (parent == 0 || LEQ(leq, h[hParent].key, h[hCurr].key)) {
- n[curr].handle = hCurr;
- h[hCurr].node = curr;
- break;
- }
- n[curr].handle = hParent;
- h[hParent].node = curr;
- curr = parent;
- }
- }
-
-/* really __gl_pqHeapInit */
- boolean pqInit() {
- int i;
-
- /* This method of building a heap is O(n), rather than O(n lg n). */
-
- for (i = size; i >= 1; --i) {
- FloatDown(i);
- }
- initialized = true;
-
- return true;
- }
-
-/* really __gl_pqHeapInsert */
-/* returns LONG_MAX iff out of memory */
- int pqInsert(Object keyNew) {
- int curr;
- int free;
-
- curr = ++size;
- if ((curr * 2) > max) {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] saveNodes = nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] saveHandles = handles;
-
- /* If the heap overflows, double its size. */
- max <<= 1;
-// pq->nodes = (PQnode *)memRealloc( pq->nodes, (size_t) ((pq->max + 1) * sizeof( pq->nodes[0] )));
- PriorityQ.PQnode[] pqNodes = new PriorityQ.PQnode[max + 1];
- System.arraycopy( nodes, 0, pqNodes, 0, nodes.length );
- for (int i = nodes.length; i < pqNodes.length; i++) {
- pqNodes[i] = new PQnode();
- }
- nodes = pqNodes;
- if (nodes == null) {
- nodes = saveNodes; /* restore ptr to free upon return */
- return Integer.MAX_VALUE;
- }
-
-// pq->handles = (PQhandleElem *)memRealloc( pq->handles,(size_t)((pq->max + 1) * sizeof( pq->handles[0] )));
- PriorityQ.PQhandleElem[] pqHandles = new PriorityQ.PQhandleElem[max + 1];
- System.arraycopy( handles, 0, pqHandles, 0, handles.length );
- for (int i = handles.length; i < pqHandles.length; i++) {
- pqHandles[i] = new PQhandleElem();
- }
- handles = pqHandles;
- if (handles == null) {
- handles = saveHandles; /* restore ptr to free upon return */
- return Integer.MAX_VALUE;
- }
- }
-
- if (freeList == 0) {
- free = curr;
- } else {
- free = freeList;
- freeList = handles[free].node;
- }
-
- nodes[curr].handle = free;
- handles[free].node = curr;
- handles[free].key = keyNew;
-
- if (initialized) {
- FloatUp(curr);
- }
- assert (free != Integer.MAX_VALUE);
- return free;
- }
-
-/* really __gl_pqHeapExtractMin */
- Object pqExtractMin() {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] n = nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] h = handles;
- int hMin = n[1].handle;
- Object min = h[hMin].key;
-
- if (size > 0) {
- n[1].handle = n[size].handle;
- h[n[1].handle].node = 1;
-
- h[hMin].key = null;
- h[hMin].node = freeList;
- freeList = hMin;
-
- if (--size > 0) {
- FloatDown(1);
- }
- }
- return min;
- }
-
-/* really __gl_pqHeapDelete */
- void pqDelete(int hCurr) {
- net.java.games.jogl.impl.tesselator.PriorityQ.PQnode[] n = nodes;
- net.java.games.jogl.impl.tesselator.PriorityQ.PQhandleElem[] h = handles;
- int curr;
-
- assert (hCurr >= 1 && hCurr <= max && h[hCurr].key != null);
-
- curr = h[hCurr].node;
- n[curr].handle = n[size].handle;
- h[n[curr].handle].node = curr;
-
- if (curr <= --size) {
- if (curr <= 1 || LEQ(leq, h[n[curr >> 1].handle].key, h[n[curr].handle].key)) {
- FloatDown(curr);
- } else {
- FloatUp(curr);
- }
- }
- h[hCurr].key = null;
- h[hCurr].node = freeList;
- freeList = hCurr;
- }
-
- Object pqMinimum() {
- return handles[nodes[1].handle].key;
- }
-
- boolean pqIsEmpty() {
- return size == 0;
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/PriorityQSort.java b/src/net/java/games/jogl/impl/tesselator/PriorityQSort.java
deleted file mode 100644
index d37580ff2..000000000
--- a/src/net/java/games/jogl/impl/tesselator/PriorityQSort.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-
-
-class PriorityQSort extends net.java.games.jogl.impl.tesselator.PriorityQ {
- net.java.games.jogl.impl.tesselator.PriorityQHeap heap;
- Object[] keys;
-
- // JAVA: 'order' contains indices into the keys array.
- // This simulates the indirect pointers used in the original C code
- // (from Frank Suykens, Luciad.com).
- int[] order;
- int size, max;
- boolean initialized;
- net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq;
-
- public PriorityQSort(net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq) {
- heap = new net.java.games.jogl.impl.tesselator.PriorityQHeap(leq);
-
- keys = new Object[net.java.games.jogl.impl.tesselator.PriorityQ.INIT_SIZE];
-
- size = 0;
- max = net.java.games.jogl.impl.tesselator.PriorityQ.INIT_SIZE;
- initialized = false;
- this.leq = leq;
- }
-
-/* really __gl_pqSortDeletePriorityQ */
- void pqDeletePriorityQ() {
- if (heap != null) heap.pqDeletePriorityQ();
- order = null;
- keys = null;
- }
-
- private static boolean LT(net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq, Object x, Object y) {
- return (!net.java.games.jogl.impl.tesselator.PriorityQHeap.LEQ(leq, y, x));
- }
-
- private static boolean GT(net.java.games.jogl.impl.tesselator.PriorityQ.Leq leq, Object x, Object y) {
- return (!net.java.games.jogl.impl.tesselator.PriorityQHeap.LEQ(leq, x, y));
- }
-
- private static void Swap(int[] array, int a, int b) {
- if (true) {
- int tmp = array[a];
- array[a] = array[b];
- array[b] = tmp;
- } else {
-
- }
- }
-
- private static class Stack {
- int p, r;
- }
-
-/* really __gl_pqSortInit */
- boolean pqInit() {
- int p, r, i, j;
- int piv;
- Stack[] stack = new Stack[50];
- for (int k = 0; k < stack.length; k++) {
- stack[k] = new Stack();
- }
- int top = 0;
-
- int seed = 2016473283;
-
- /* Create an array of indirect pointers to the keys, so that we
- * the handles we have returned are still valid.
- */
- order = new int[size + 1];
-/* the previous line is a patch to compensate for the fact that IBM */
-/* machines return a null on a malloc of zero bytes (unlike SGI), */
-/* so we have to put in this defense to guard against a memory */
-/* fault four lines down. from [email protected]. */
- p = 0;
- r = size - 1;
- for (piv = 0, i = p; i <= r; ++piv, ++i) {
- // indirect pointers: keep an index into the keys array, not a direct pointer to its contents
- order[i] = piv;
- }
-
- /* Sort the indirect pointers in descending order,
- * using randomized Quicksort
- */
- stack[top].p = p;
- stack[top].r = r;
- ++top;
- while (--top >= 0) {
- p = stack[top].p;
- r = stack[top].r;
- while (r > p + 10) {
- seed = Math.abs( seed * 1539415821 + 1 );
- i = p + seed % (r - p + 1);
- piv = order[i];
- order[i] = order[p];
- order[p] = piv;
- i = p - 1;
- j = r + 1;
- do {
- do {
- ++i;
- } while (GT(leq, keys[order[i]], keys[piv]));
- do {
- --j;
- } while (LT(leq, keys[order[j]], keys[piv]));
- Swap(order, i, j);
- } while (i < j);
- Swap(order, i, j); /* Undo last swap */
- if (i - p < r - j) {
- stack[top].p = j + 1;
- stack[top].r = r;
- ++top;
- r = i - 1;
- } else {
- stack[top].p = p;
- stack[top].r = i - 1;
- ++top;
- p = j + 1;
- }
- }
- /* Insertion sort small lists */
- for (i = p + 1; i <= r; ++i) {
- piv = order[i];
- for (j = i; j > p && LT(leq, keys[order[j - 1]], keys[piv]); --j) {
- order[j] = order[j - 1];
- }
- order[j] = piv;
- }
- }
- max = size;
- initialized = true;
- heap.pqInit(); /* always succeeds */
-
-/* #ifndef NDEBUG
- p = order;
- r = p + size - 1;
- for (i = p; i < r; ++i) {
- Assertion.doAssert(LEQ( * * (i + 1), **i ));
- }
- #endif*/
-
- return true;
- }
-
-/* really __gl_pqSortInsert */
-/* returns LONG_MAX iff out of memory */
- int pqInsert(Object keyNew) {
- int curr;
-
- if (initialized) {
- return heap.pqInsert(keyNew);
- }
- curr = size;
- if (++size >= max) {
- Object[] saveKey = keys;
-
- /* If the heap overflows, double its size. */
- max <<= 1;
-// pq->keys = (PQHeapKey *)memRealloc( pq->keys,(size_t)(pq->max * sizeof( pq->keys[0] )));
- Object[] pqKeys = new Object[max];
- System.arraycopy( keys, 0, pqKeys, 0, keys.length );
- keys = pqKeys;
- if (keys == null) {
- keys = saveKey; /* restore ptr to free upon return */
- return Integer.MAX_VALUE;
- }
- }
- assert curr != Integer.MAX_VALUE;
- keys[curr] = keyNew;
-
- /* Negative handles index the sorted array. */
- return -(curr + 1);
- }
-
-/* really __gl_pqSortExtractMin */
- Object pqExtractMin() {
- Object sortMin, heapMin;
-
- if (size == 0) {
- return heap.pqExtractMin();
- }
- sortMin = keys[order[size - 1]];
- if (!heap.pqIsEmpty()) {
- heapMin = heap.pqMinimum();
- if (LEQ(leq, heapMin, sortMin)) {
- return heap.pqExtractMin();
- }
- }
- do {
- --size;
- } while (size > 0 && keys[order[size - 1]] == null);
- return sortMin;
- }
-
-/* really __gl_pqSortMinimum */
- Object pqMinimum() {
- Object sortMin, heapMin;
-
- if (size == 0) {
- return heap.pqMinimum();
- }
- sortMin = keys[order[size - 1]];
- if (!heap.pqIsEmpty()) {
- heapMin = heap.pqMinimum();
- if (net.java.games.jogl.impl.tesselator.PriorityQHeap.LEQ(leq, heapMin, sortMin)) {
- return heapMin;
- }
- }
- return sortMin;
- }
-
-/* really __gl_pqSortIsEmpty */
- boolean pqIsEmpty() {
- return (size == 0) && heap.pqIsEmpty();
- }
-
-/* really __gl_pqSortDelete */
- void pqDelete(int curr) {
- if (curr >= 0) {
- heap.pqDelete(curr);
- return;
- }
- curr = -(curr + 1);
- assert curr < max && keys[curr] != null;
-
- keys[curr] = null;
- while (size > 0 && keys[order[size - 1]] == null) {
- --size;
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Render.java b/src/net/java/games/jogl/impl/tesselator/Render.java
deleted file mode 100644
index 4763992b8..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Render.java
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-import net.java.games.jogl.*;
-
-class Render {
- private static final boolean USE_OPTIMIZED_CODE_PATH = false;
-
- private Render() {
- }
-
- private static final RenderFan renderFan = new RenderFan();
- private static final RenderStrip renderStrip = new RenderStrip();
- private static final RenderTriangle renderTriangle = new RenderTriangle();
-
-/* This structure remembers the information we need about a primitive
- * to be able to render it later, once we have determined which
- * primitive is able to use the most triangles.
- */
- private static class FaceCount {
- public FaceCount() {
- }
-
- public FaceCount(long size, net.java.games.jogl.impl.tesselator.GLUhalfEdge eStart, renderCallBack render) {
- this.size = size;
- this.eStart = eStart;
- this.render = render;
- }
-
- long size; /* number of triangles used */
- net.java.games.jogl.impl.tesselator.GLUhalfEdge eStart; /* edge where this primitive starts */
- renderCallBack render;
- };
-
- private static interface renderCallBack {
- void render(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUhalfEdge e, long size);
- }
-
- /************************ Strips and Fans decomposition ******************/
-
-/* __gl_renderMesh( tess, mesh ) takes a mesh and breaks it into triangle
- * fans, strips, and separate triangles. A substantial effort is made
- * to use as few rendering primitives as possible (ie. to make the fans
- * and strips as large as possible).
- *
- * The rendering output is provided as callbacks (see the api).
- */
- public static void __gl_renderMesh(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUface f;
-
- /* Make a list of separate triangles so we can render them all at once */
- tess.lonelyTriList = null;
-
- for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
- f.marked = false;
- }
- for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
-
- /* We examine all faces in an arbitrary order. Whenever we find
- * an unprocessed face F, we output a group of faces including F
- * whose size is maximum.
- */
- if (f.inside && !f.marked) {
- RenderMaximumFaceGroup(tess, f);
- assert (f.marked);
- }
- }
- if (tess.lonelyTriList != null) {
- RenderLonelyTriangles(tess, tess.lonelyTriList);
- tess.lonelyTriList = null;
- }
- }
-
-
- static void RenderMaximumFaceGroup(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUface fOrig) {
- /* We want to find the largest triangle fan or strip of unmarked faces
- * which includes the given face fOrig. There are 3 possible fans
- * passing through fOrig (one centered at each vertex), and 3 possible
- * strips (one for each CCW permutation of the vertices). Our strategy
- * is to try all of these, and take the primitive which uses the most
- * triangles (a greedy approach).
- */
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e = fOrig.anEdge;
- FaceCount max = new FaceCount();
- FaceCount newFace = new FaceCount();
-
- max.size = 1;
- max.eStart = e;
- max.render = renderTriangle;
-
- if (!tess.flagBoundary) {
- newFace = MaximumFan(e);
- if (newFace.size > max.size) {
- max = newFace;
- }
- newFace = MaximumFan(e.Lnext);
- if (newFace.size > max.size) {
- max = newFace;
- }
- newFace = MaximumFan(e.Onext.Sym);
- if (newFace.size > max.size) {
- max = newFace;
- }
-
- newFace = MaximumStrip(e);
- if (newFace.size > max.size) {
- max = newFace;
- }
- newFace = MaximumStrip(e.Lnext);
- if (newFace.size > max.size) {
- max = newFace;
- }
- newFace = MaximumStrip(e.Onext.Sym);
- if (newFace.size > max.size) {
- max = newFace;
- }
- }
- max.render.render(tess, max.eStart, max.size);
- }
-
-
-/* Macros which keep track of faces we have marked temporarily, and allow
- * us to backtrack when necessary. With triangle fans, this is not
- * really necessary, since the only awkward case is a loop of triangles
- * around a single origin vertex. However with strips the situation is
- * more complicated, and we need a general tracking method like the
- * one here.
- */
- private static boolean Marked(net.java.games.jogl.impl.tesselator.GLUface f) {
- return !f.inside || f.marked;
- }
-
- private static GLUface AddToTrail(net.java.games.jogl.impl.tesselator.GLUface f, net.java.games.jogl.impl.tesselator.GLUface t) {
- f.trail = t;
- f.marked = true;
- return f;
- }
-
- private static void FreeTrail(net.java.games.jogl.impl.tesselator.GLUface t) {
- if (true) {
- while (t != null) {
- t.marked = false;
- t = t.trail;
- }
- } else {
- /* absorb trailing semicolon */
- }
- }
-
- static FaceCount MaximumFan(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrig) {
- /* eOrig.Lface is the face we want to render. We want to find the size
- * of a maximal fan around eOrig.Org. To do this we just walk around
- * the origin vertex as far as possible in both directions.
- */
- FaceCount newFace = new FaceCount(0, null, renderFan);
- net.java.games.jogl.impl.tesselator.GLUface trail = null;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
-
- for (e = eOrig; !Marked(e.Lface); e = e.Onext) {
- trail = AddToTrail(e.Lface, trail);
- ++newFace.size;
- }
- for (e = eOrig; !Marked(e.Sym.Lface); e = e.Sym.Lnext) {
- trail = AddToTrail(e.Sym.Lface, trail);
- ++newFace.size;
- }
- newFace.eStart = e;
- /*LINTED*/
- FreeTrail(trail);
- return newFace;
- }
-
-
- private static boolean IsEven(long n) {
- return (n & 0x1L) == 0;
- }
-
- static FaceCount MaximumStrip(net.java.games.jogl.impl.tesselator.GLUhalfEdge eOrig) {
- /* Here we are looking for a maximal strip that contains the vertices
- * eOrig.Org, eOrig.Dst, eOrig.Lnext.Dst (in that order or the
- * reverse, such that all triangles are oriented CCW).
- *
- * Again we walk forward and backward as far as possible. However for
- * strips there is a twist: to get CCW orientations, there must be
- * an *even* number of triangles in the strip on one side of eOrig.
- * We walk the strip starting on a side with an even number of triangles;
- * if both side have an odd number, we are forced to shorten one side.
- */
- FaceCount newFace = new FaceCount(0, null, renderStrip);
- long headSize = 0, tailSize = 0;
- net.java.games.jogl.impl.tesselator.GLUface trail = null;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e, eTail, eHead;
-
- for (e = eOrig; !Marked(e.Lface); ++tailSize, e = e.Onext) {
- trail = AddToTrail(e.Lface, trail);
- ++tailSize;
- e = e.Lnext.Sym;
- if (Marked(e.Lface)) break;
- trail = AddToTrail(e.Lface, trail);
- }
- eTail = e;
-
- for (e = eOrig; !Marked(e.Sym.Lface); ++headSize, e = e.Sym.Onext.Sym) {
- trail = AddToTrail(e.Sym.Lface, trail);
- ++headSize;
- e = e.Sym.Lnext;
- if (Marked(e.Sym.Lface)) break;
- trail = AddToTrail(e.Sym.Lface, trail);
- }
- eHead = e;
-
- newFace.size = tailSize + headSize;
- if (IsEven(tailSize)) {
- newFace.eStart = eTail.Sym;
- } else if (IsEven(headSize)) {
- newFace.eStart = eHead;
- } else {
- /* Both sides have odd length, we must shorten one of them. In fact,
- * we must start from eHead to guarantee inclusion of eOrig.Lface.
- */
- --newFace.size;
- newFace.eStart = eHead.Onext;
- }
- /*LINTED*/
- FreeTrail(trail);
- return newFace;
- }
-
- private static class RenderTriangle implements renderCallBack {
- public void render(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUhalfEdge e, long size) {
- /* Just add the triangle to a triangle list, so we can render all
- * the separate triangles at once.
- */
- assert (size == 1);
- tess.lonelyTriList = AddToTrail(e.Lface, tess.lonelyTriList);
- }
- }
-
-
- static void RenderLonelyTriangles(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUface f) {
- /* Now we render all the separate triangles which could not be
- * grouped into a triangle fan or strip.
- */
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
- int newState;
- int edgeState = -1; /* force edge state output for first vertex */
-
- tess.callBeginOrBeginData(GL.GL_TRIANGLES);
-
- for (; f != null; f = f.trail) {
- /* Loop once for each edge (there will always be 3 edges) */
-
- e = f.anEdge;
- do {
- if (tess.flagBoundary) {
- /* Set the "edge state" to true just before we output the
- * first vertex of each edge on the polygon boundary.
- */
- newState = (!e.Sym.Lface.inside) ? 1 : 0;
- if (edgeState != newState) {
- edgeState = newState;
- tess.callEdgeFlagOrEdgeFlagData( edgeState != 0);
- }
- }
- tess.callVertexOrVertexData( e.Org.data);
-
- e = e.Lnext;
- } while (e != f.anEdge);
- }
- tess.callEndOrEndData();
- }
-
- private static class RenderFan implements renderCallBack {
- public void render(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUhalfEdge e, long size) {
- /* Render as many CCW triangles as possible in a fan starting from
- * edge "e". The fan *should* contain exactly "size" triangles
- * (otherwise we've goofed up somewhere).
- */
- tess.callBeginOrBeginData( GL.GL_TRIANGLE_FAN);
- tess.callVertexOrVertexData( e.Org.data);
- tess.callVertexOrVertexData( e.Sym.Org.data);
-
- while (!Marked(e.Lface)) {
- e.Lface.marked = true;
- --size;
- e = e.Onext;
- tess.callVertexOrVertexData( e.Sym.Org.data);
- }
-
- assert (size == 0);
- tess.callEndOrEndData();
- }
- }
-
- private static class RenderStrip implements renderCallBack {
- public void render(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUhalfEdge e, long size) {
- /* Render as many CCW triangles as possible in a strip starting from
- * edge "e". The strip *should* contain exactly "size" triangles
- * (otherwise we've goofed up somewhere).
- */
- tess.callBeginOrBeginData( GL.GL_TRIANGLE_STRIP);
- tess.callVertexOrVertexData( e.Org.data);
- tess.callVertexOrVertexData( e.Sym.Org.data);
-
- while (!Marked(e.Lface)) {
- e.Lface.marked = true;
- --size;
- e = e.Lnext.Sym;
- tess.callVertexOrVertexData( e.Org.data);
- if (Marked(e.Lface)) break;
-
- e.Lface.marked = true;
- --size;
- e = e.Onext;
- tess.callVertexOrVertexData( e.Sym.Org.data);
- }
-
- assert (size == 0);
- tess.callEndOrEndData();
- }
- }
-
- /************************ Boundary contour decomposition ******************/
-
-/* __gl_renderBoundary( tess, mesh ) takes a mesh, and outputs one
- * contour for each face marked "inside". The rendering output is
- * provided as callbacks (see the api).
- */
- public static void __gl_renderBoundary(GLUtesselatorImpl tess, net.java.games.jogl.impl.tesselator.GLUmesh mesh) {
- net.java.games.jogl.impl.tesselator.GLUface f;
- net.java.games.jogl.impl.tesselator.GLUhalfEdge e;
-
- for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) {
- if (f.inside) {
- tess.callBeginOrBeginData( GL.GL_LINE_LOOP);
- e = f.anEdge;
- do {
- tess.callVertexOrVertexData( e.Org.data);
- e = e.Lnext;
- } while (e != f.anEdge);
- tess.callEndOrEndData();
- }
- }
- }
-
-
- /************************ Quick-and-dirty decomposition ******************/
-
- private static final int SIGN_INCONSISTENT = 2;
-
- static int ComputeNormal(GLUtesselatorImpl tess, double[] norm, boolean check)
-/*
- * If check==false, we compute the polygon normal and place it in norm[].
- * If check==true, we check that each triangle in the fan from v0 has a
- * consistent orientation with respect to norm[]. If triangles are
- * consistently oriented CCW, return 1; if CW, return -1; if all triangles
- * are degenerate return 0; otherwise (no consistent orientation) return
- * SIGN_INCONSISTENT.
- */ {
- net.java.games.jogl.impl.tesselator.CachedVertex[] v = tess.cache;
-// CachedVertex vn = v0 + tess.cacheCount;
- int vn = tess.cacheCount;
-// CachedVertex vc;
- int vc;
- double dot, xc, yc, zc, xp, yp, zp;
- double[] n = new double[3];
- int sign = 0;
-
- /* Find the polygon normal. It is important to get a reasonable
- * normal even when the polygon is self-intersecting (eg. a bowtie).
- * Otherwise, the computed normal could be very tiny, but perpendicular
- * to the true plane of the polygon due to numerical noise. Then all
- * the triangles would appear to be degenerate and we would incorrectly
- * decompose the polygon as a fan (or simply not render it at all).
- *
- * We use a sum-of-triangles normal algorithm rather than the more
- * efficient sum-of-trapezoids method (used in CheckOrientation()
- * in normal.c). This lets us explicitly reverse the signed area
- * of some triangles to get a reasonable normal in the self-intersecting
- * case.
- */
- if (!check) {
- norm[0] = norm[1] = norm[2] = 0.0;
- }
-
- vc = 1;
- xc = v[vc].coords[0] - v[0].coords[0];
- yc = v[vc].coords[1] - v[0].coords[1];
- zc = v[vc].coords[2] - v[0].coords[2];
- while (++vc < vn) {
- xp = xc;
- yp = yc;
- zp = zc;
- xc = v[vc].coords[0] - v[0].coords[0];
- yc = v[vc].coords[1] - v[0].coords[1];
- zc = v[vc].coords[2] - v[0].coords[2];
-
- /* Compute (vp - v0) cross (vc - v0) */
- n[0] = yp * zc - zp * yc;
- n[1] = zp * xc - xp * zc;
- n[2] = xp * yc - yp * xc;
-
- dot = n[0] * norm[0] + n[1] * norm[1] + n[2] * norm[2];
- if (!check) {
- /* Reverse the contribution of back-facing triangles to get
- * a reasonable normal for self-intersecting polygons (see above)
- */
- if (dot >= 0) {
- norm[0] += n[0];
- norm[1] += n[1];
- norm[2] += n[2];
- } else {
- norm[0] -= n[0];
- norm[1] -= n[1];
- norm[2] -= n[2];
- }
- } else if (dot != 0) {
- /* Check the new orientation for consistency with previous triangles */
- if (dot > 0) {
- if (sign < 0) return SIGN_INCONSISTENT;
- sign = 1;
- } else {
- if (sign > 0) return SIGN_INCONSISTENT;
- sign = -1;
- }
- }
- }
- return sign;
- }
-
-/* __gl_renderCache( tess ) takes a single contour and tries to render it
- * as a triangle fan. This handles convex polygons, as well as some
- * non-convex polygons if we get lucky.
- *
- * Returns true if the polygon was successfully rendered. The rendering
- * output is provided as callbacks (see the api).
- */
- public static boolean __gl_renderCache(GLUtesselatorImpl tess) {
- net.java.games.jogl.impl.tesselator.CachedVertex[] v = tess.cache;
-// CachedVertex vn = v0 + tess.cacheCount;
- int vn = tess.cacheCount;
-// CachedVertex vc;
- int vc;
- double[] norm = new double[3];
- int sign;
-
- if (tess.cacheCount < 3) {
- /* Degenerate contour -- no output */
- return true;
- }
-
- norm[0] = tess.normal[0];
- norm[1] = tess.normal[1];
- norm[2] = tess.normal[2];
- if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) {
- ComputeNormal( tess, norm, false);
- }
-
- sign = ComputeNormal( tess, norm, true);
- if (sign == SIGN_INCONSISTENT) {
- /* Fan triangles did not have a consistent orientation */
- return false;
- }
- if (sign == 0) {
- /* All triangles were degenerate */
- return true;
- }
-
- if ( !USE_OPTIMIZED_CODE_PATH ) {
- return false;
- } else {
- /* Make sure we do the right thing for each winding rule */
- switch (tess.windingRule) {
- case GLU.GLU_TESS_WINDING_ODD:
- case GLU.GLU_TESS_WINDING_NONZERO:
- break;
- case GLU.GLU_TESS_WINDING_POSITIVE:
- if (sign < 0) return true;
- break;
- case GLU.GLU_TESS_WINDING_NEGATIVE:
- if (sign > 0) return true;
- break;
- case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
- return true;
- }
-
- tess.callBeginOrBeginData( tess.boundaryOnly ? GL.GL_LINE_LOOP
- : (tess.cacheCount > 3) ? GL.GL_TRIANGLE_FAN
- : GL.GL_TRIANGLES);
-
- tess.callVertexOrVertexData( v[0].data);
- if (sign > 0) {
- for (vc = 1; vc < vn; ++vc) {
- tess.callVertexOrVertexData( v[vc].data);
- }
- } else {
- for (vc = vn - 1; vc > 0; --vc) {
- tess.callVertexOrVertexData( v[vc].data);
- }
- }
- tess.callEndOrEndData();
- return true;
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/Sweep.java b/src/net/java/games/jogl/impl/tesselator/Sweep.java
deleted file mode 100644
index 3674d12e1..000000000
--- a/src/net/java/games/jogl/impl/tesselator/Sweep.java
+++ /dev/null
@@ -1,1342 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-import net.java.games.jogl.*;
-
-class Sweep {
- private Sweep() {
- }
-
-// #ifdef FOR_TRITE_TEST_PROGRAM
-// extern void DebugEvent( GLUtesselator *tess );
-// #else
- private static void DebugEvent(GLUtesselatorImpl tess) {
-
- }
-// #endif
-
-/*
- * Invariants for the Edge Dictionary.
- * - each pair of adjacent edges e2=Succ(e1) satisfies EdgeLeq(e1,e2)
- * at any valid location of the sweep event
- * - if EdgeLeq(e2,e1) as well (at any valid sweep event), then e1 and e2
- * share a common endpoint
- * - for each e, e.Dst has been processed, but not e.Org
- * - each edge e satisfies VertLeq(e.Dst,event) && VertLeq(event,e.Org)
- * where "event" is the current sweep line event.
- * - no edge e has zero length
- *
- * Invariants for the Mesh (the processed portion).
- * - the portion of the mesh left of the sweep line is a planar graph,
- * ie. there is *some* way to embed it in the plane
- * - no processed edge has zero length
- * - no two processed vertices have identical coordinates
- * - each "inside" region is monotone, ie. can be broken into two chains
- * of monotonically increasing vertices according to VertLeq(v1,v2)
- * - a non-invariant: these chains may intersect (very slightly)
- *
- * Invariants for the Sweep.
- * - if none of the edges incident to the event vertex have an activeRegion
- * (ie. none of these edges are in the edge dictionary), then the vertex
- * has only right-going edges.
- * - if an edge is marked "fixUpperEdge" (it is a temporary edge introduced
- * by ConnectRightVertex), then it is the only right-going edge from
- * its associated vertex. (This says that these edges exist only
- * when it is necessary.)
- */
-
-/* When we merge two edges into one, we need to compute the combined
- * winding of the new edge.
- */
- private static void AddWinding(GLUhalfEdge eDst, GLUhalfEdge eSrc) {
- eDst.winding += eSrc.winding;
- eDst.Sym.winding += eSrc.Sym.winding;
- }
-
-
- private static ActiveRegion RegionBelow(ActiveRegion r) {
- return ((ActiveRegion) Dict.dictKey(Dict.dictPred(r.nodeUp)));
- }
-
- private static ActiveRegion RegionAbove(ActiveRegion r) {
- return ((ActiveRegion) Dict.dictKey(Dict.dictSucc(r.nodeUp)));
- }
-
- static boolean EdgeLeq(GLUtesselatorImpl tess, ActiveRegion reg1, ActiveRegion reg2)
-/*
- * Both edges must be directed from right to left (this is the canonical
- * direction for the upper edge of each region).
- *
- * The strategy is to evaluate a "t" value for each edge at the
- * current sweep line position, given by tess.event. The calculations
- * are designed to be very stable, but of course they are not perfect.
- *
- * Special case: if both edge destinations are at the sweep event,
- * we sort the edges by slope (they would otherwise compare equally).
- */ {
- GLUvertex event = tess.event;
- GLUhalfEdge e1, e2;
- double t1, t2;
-
- e1 = reg1.eUp;
- e2 = reg2.eUp;
-
- if (e1.Sym.Org == event) {
- if (e2.Sym.Org == event) {
- /* Two edges right of the sweep line which meet at the sweep event.
- * Sort them by slope.
- */
- if (Geom.VertLeq(e1.Org, e2.Org)) {
- return Geom.EdgeSign(e2.Sym.Org, e1.Org, e2.Org) <= 0;
- }
- return Geom.EdgeSign(e1.Sym.Org, e2.Org, e1.Org) >= 0;
- }
- return Geom.EdgeSign(e2.Sym.Org, event, e2.Org) <= 0;
- }
- if (e2.Sym.Org == event) {
- return Geom.EdgeSign(e1.Sym.Org, event, e1.Org) >= 0;
- }
-
- /* General case - compute signed distance *from* e1, e2 to event */
- t1 = Geom.EdgeEval(e1.Sym.Org, event, e1.Org);
- t2 = Geom.EdgeEval(e2.Sym.Org, event, e2.Org);
- return (t1 >= t2);
- }
-
-
- static void DeleteRegion(GLUtesselatorImpl tess, ActiveRegion reg) {
- if (reg.fixUpperEdge) {
- /* It was created with zero winding number, so it better be
- * deleted with zero winding number (ie. it better not get merged
- * with a real edge).
- */
- assert (reg.eUp.winding == 0);
- }
- reg.eUp.activeRegion = null;
- Dict.dictDelete(tess.dict, reg.nodeUp); /* __gl_dictListDelete */
- }
-
-
- static boolean FixUpperEdge(ActiveRegion reg, GLUhalfEdge newEdge)
-/*
- * Replace an upper edge which needs fixing (see ConnectRightVertex).
- */ {
- assert (reg.fixUpperEdge);
- if (!Mesh.__gl_meshDelete(reg.eUp)) return false;
- reg.fixUpperEdge = false;
- reg.eUp = newEdge;
- newEdge.activeRegion = reg;
-
- return true;
- }
-
- static ActiveRegion TopLeftRegion(ActiveRegion reg) {
- GLUvertex org = reg.eUp.Org;
- GLUhalfEdge e;
-
- /* Find the region above the uppermost edge with the same origin */
- do {
- reg = RegionAbove(reg);
- } while (reg.eUp.Org == org);
-
- /* If the edge above was a temporary edge introduced by ConnectRightVertex,
- * now is the time to fix it.
- */
- if (reg.fixUpperEdge) {
- e = Mesh.__gl_meshConnect(RegionBelow(reg).eUp.Sym, reg.eUp.Lnext);
- if (e == null) return null;
- if (!FixUpperEdge(reg, e)) return null;
- reg = RegionAbove(reg);
- }
- return reg;
- }
-
- static ActiveRegion TopRightRegion(ActiveRegion reg) {
- GLUvertex dst = reg.eUp.Sym.Org;
-
- /* Find the region above the uppermost edge with the same destination */
- do {
- reg = RegionAbove(reg);
- } while (reg.eUp.Sym.Org == dst);
- return reg;
- }
-
- static ActiveRegion AddRegionBelow(GLUtesselatorImpl tess,
- ActiveRegion regAbove,
- GLUhalfEdge eNewUp)
-/*
- * Add a new active region to the sweep line, *somewhere* below "regAbove"
- * (according to where the new edge belongs in the sweep-line dictionary).
- * The upper edge of the new region will be "eNewUp".
- * Winding number and "inside" flag are not updated.
- */ {
- ActiveRegion regNew = new ActiveRegion();
- if (regNew == null) throw new RuntimeException();
-
- regNew.eUp = eNewUp;
- /* __gl_dictListInsertBefore */
- regNew.nodeUp = Dict.dictInsertBefore(tess.dict, regAbove.nodeUp, regNew);
- if (regNew.nodeUp == null) throw new RuntimeException();
- regNew.fixUpperEdge = false;
- regNew.sentinel = false;
- regNew.dirty = false;
-
- eNewUp.activeRegion = regNew;
- return regNew;
- }
-
- static boolean IsWindingInside(GLUtesselatorImpl tess, int n) {
- switch (tess.windingRule) {
- case GLU.GLU_TESS_WINDING_ODD:
- return (n & 1) != 0;
- case GLU.GLU_TESS_WINDING_NONZERO:
- return (n != 0);
- case GLU.GLU_TESS_WINDING_POSITIVE:
- return (n > 0);
- case GLU.GLU_TESS_WINDING_NEGATIVE:
- return (n < 0);
- case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO:
- return (n >= 2) || (n <= -2);
- }
- /*LINTED*/
-// assert (false);
- throw new InternalError();
- /*NOTREACHED*/
- }
-
-
- static void ComputeWinding(GLUtesselatorImpl tess, ActiveRegion reg) {
- reg.windingNumber = RegionAbove(reg).windingNumber + reg.eUp.winding;
- reg.inside = IsWindingInside(tess, reg.windingNumber);
- }
-
-
- static void FinishRegion(GLUtesselatorImpl tess, ActiveRegion reg)
-/*
- * Delete a region from the sweep line. This happens when the upper
- * and lower chains of a region meet (at a vertex on the sweep line).
- * The "inside" flag is copied to the appropriate mesh face (we could
- * not do this before -- since the structure of the mesh is always
- * changing, this face may not have even existed until now).
- */ {
- GLUhalfEdge e = reg.eUp;
- GLUface f = e.Lface;
-
- f.inside = reg.inside;
- f.anEdge = e; /* optimization for __gl_meshTessellateMonoRegion() */
- DeleteRegion(tess, reg);
- }
-
-
- static GLUhalfEdge FinishLeftRegions(GLUtesselatorImpl tess,
- ActiveRegion regFirst, ActiveRegion regLast)
-/*
- * We are given a vertex with one or more left-going edges. All affected
- * edges should be in the edge dictionary. Starting at regFirst.eUp,
- * we walk down deleting all regions where both edges have the same
- * origin vOrg. At the same time we copy the "inside" flag from the
- * active region to the face, since at this point each face will belong
- * to at most one region (this was not necessarily true until this point
- * in the sweep). The walk stops at the region above regLast; if regLast
- * is null we walk as far as possible. At the same time we relink the
- * mesh if necessary, so that the ordering of edges around vOrg is the
- * same as in the dictionary.
- */ {
- ActiveRegion reg, regPrev;
- GLUhalfEdge e, ePrev;
-
- regPrev = regFirst;
- ePrev = regFirst.eUp;
- while (regPrev != regLast) {
- regPrev.fixUpperEdge = false; /* placement was OK */
- reg = RegionBelow(regPrev);
- e = reg.eUp;
- if (e.Org != ePrev.Org) {
- if (!reg.fixUpperEdge) {
- /* Remove the last left-going edge. Even though there are no further
- * edges in the dictionary with this origin, there may be further
- * such edges in the mesh (if we are adding left edges to a vertex
- * that has already been processed). Thus it is important to call
- * FinishRegion rather than just DeleteRegion.
- */
- FinishRegion(tess, regPrev);
- break;
- }
- /* If the edge below was a temporary edge introduced by
- * ConnectRightVertex, now is the time to fix it.
- */
- e = Mesh.__gl_meshConnect(ePrev.Onext.Sym, e.Sym);
- if (e == null) throw new RuntimeException();
- if (!FixUpperEdge(reg, e)) throw new RuntimeException();
- }
-
- /* Relink edges so that ePrev.Onext == e */
- if (ePrev.Onext != e) {
- if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(ePrev, e)) throw new RuntimeException();
- }
- FinishRegion(tess, regPrev); /* may change reg.eUp */
- ePrev = reg.eUp;
- regPrev = reg;
- }
- return ePrev;
- }
-
-
- static void AddRightEdges(GLUtesselatorImpl tess, ActiveRegion regUp,
- GLUhalfEdge eFirst, GLUhalfEdge eLast, GLUhalfEdge eTopLeft,
- boolean cleanUp)
-/*
- * Purpose: insert right-going edges into the edge dictionary, and update
- * winding numbers and mesh connectivity appropriately. All right-going
- * edges share a common origin vOrg. Edges are inserted CCW starting at
- * eFirst; the last edge inserted is eLast.Sym.Lnext. If vOrg has any
- * left-going edges already processed, then eTopLeft must be the edge
- * such that an imaginary upward vertical segment from vOrg would be
- * contained between eTopLeft.Sym.Lnext and eTopLeft; otherwise eTopLeft
- * should be null.
- */ {
- ActiveRegion reg, regPrev;
- GLUhalfEdge e, ePrev;
- boolean firstTime = true;
-
- /* Insert the new right-going edges in the dictionary */
- e = eFirst;
- do {
- assert (Geom.VertLeq(e.Org, e.Sym.Org));
- AddRegionBelow(tess, regUp, e.Sym);
- e = e.Onext;
- } while (e != eLast);
-
- /* Walk *all* right-going edges from e.Org, in the dictionary order,
- * updating the winding numbers of each region, and re-linking the mesh
- * edges to match the dictionary ordering (if necessary).
- */
- if (eTopLeft == null) {
- eTopLeft = RegionBelow(regUp).eUp.Sym.Onext;
- }
- regPrev = regUp;
- ePrev = eTopLeft;
- for (; ;) {
- reg = RegionBelow(regPrev);
- e = reg.eUp.Sym;
- if (e.Org != ePrev.Org) break;
-
- if (e.Onext != ePrev) {
- /* Unlink e from its current position, and relink below ePrev */
- if (!Mesh.__gl_meshSplice(e.Sym.Lnext, e)) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(ePrev.Sym.Lnext, e)) throw new RuntimeException();
- }
- /* Compute the winding number and "inside" flag for the new regions */
- reg.windingNumber = regPrev.windingNumber - e.winding;
- reg.inside = IsWindingInside(tess, reg.windingNumber);
-
- /* Check for two outgoing edges with same slope -- process these
- * before any intersection tests (see example in __gl_computeInterior).
- */
- regPrev.dirty = true;
- if (!firstTime && CheckForRightSplice(tess, regPrev)) {
- AddWinding(e, ePrev);
- DeleteRegion(tess, regPrev);
- if (!Mesh.__gl_meshDelete(ePrev)) throw new RuntimeException();
- }
- firstTime = false;
- regPrev = reg;
- ePrev = e;
- }
- regPrev.dirty = true;
- assert (regPrev.windingNumber - e.winding == reg.windingNumber);
-
- if (cleanUp) {
- /* Check for intersections between newly adjacent edges. */
- WalkDirtyRegions(tess, regPrev);
- }
- }
-
-
- static void CallCombine(GLUtesselatorImpl tess, GLUvertex isect,
- Object[] data, float[] weights, boolean needed) {
- double[] coords = new double[3];
-
- /* Copy coord data in case the callback changes it. */
- coords[0] = isect.coords[0];
- coords[1] = isect.coords[1];
- coords[2] = isect.coords[2];
-
- Object[] outData = new Object[1];
- tess.callCombineOrCombineData(coords, data, weights, outData);
- isect.data = outData[0];
- if (isect.data == null) {
- if (!needed) {
- isect.data = data[0];
- } else if (!tess.fatalError) {
- /* The only way fatal error is when two edges are found to intersect,
- * but the user has not provided the callback necessary to handle
- * generated intersection points.
- */
- tess.callErrorOrErrorData(GLU.GLU_TESS_NEED_COMBINE_CALLBACK);
- tess.fatalError = true;
- }
- }
- }
-
- static void SpliceMergeVertices(GLUtesselatorImpl tess, GLUhalfEdge e1,
- GLUhalfEdge e2)
-/*
- * Two vertices with idential coordinates are combined into one.
- * e1.Org is kept, while e2.Org is discarded.
- */ {
- Object[] data = new Object[4];
- float[] weights = new float[]{0.5f, 0.5f, 0.0f, 0.0f};
-
- data[0] = e1.Org.data;
- data[1] = e2.Org.data;
- CallCombine(tess, e1.Org, data, weights, false);
- if (!Mesh.__gl_meshSplice(e1, e2)) throw new RuntimeException();
- }
-
- static void VertexWeights(GLUvertex isect, GLUvertex org, GLUvertex dst,
- float[] weights)
-/*
- * Find some weights which describe how the intersection vertex is
- * a linear combination of "org" and "dest". Each of the two edges
- * which generated "isect" is allocated 50% of the weight; each edge
- * splits the weight between its org and dst according to the
- * relative distance to "isect".
- */ {
- double t1 = Geom.VertL1dist(org, isect);
- double t2 = Geom.VertL1dist(dst, isect);
-
- weights[0] = (float) (0.5 * t2 / (t1 + t2));
- weights[1] = (float) (0.5 * t1 / (t1 + t2));
- isect.coords[0] += weights[0] * org.coords[0] + weights[1] * dst.coords[0];
- isect.coords[1] += weights[0] * org.coords[1] + weights[1] * dst.coords[1];
- isect.coords[2] += weights[0] * org.coords[2] + weights[1] * dst.coords[2];
- }
-
-
- static void GetIntersectData(GLUtesselatorImpl tess, GLUvertex isect,
- GLUvertex orgUp, GLUvertex dstUp,
- GLUvertex orgLo, GLUvertex dstLo)
-/*
- * We've computed a new intersection point, now we need a "data" pointer
- * from the user so that we can refer to this new vertex in the
- * rendering callbacks.
- */ {
- Object[] data = new Object[4];
- float[] weights = new float[4];
- float[] weights1 = new float[2];
- float[] weights2 = new float[2];
-
- data[0] = orgUp.data;
- data[1] = dstUp.data;
- data[2] = orgLo.data;
- data[3] = dstLo.data;
-
- isect.coords[0] = isect.coords[1] = isect.coords[2] = 0;
- VertexWeights(isect, orgUp, dstUp, weights1);
- VertexWeights(isect, orgLo, dstLo, weights2);
- System.arraycopy(weights1, 0, weights, 0, 2);
- System.arraycopy(weights2, 0, weights, 2, 2);
-
- CallCombine(tess, isect, data, weights, true);
- }
-
- static boolean CheckForRightSplice(GLUtesselatorImpl tess, ActiveRegion regUp)
-/*
- * Check the upper and lower edge of "regUp", to make sure that the
- * eUp.Org is above eLo, or eLo.Org is below eUp (depending on which
- * origin is leftmost).
- *
- * The main purpose is to splice right-going edges with the same
- * dest vertex and nearly identical slopes (ie. we can't distinguish
- * the slopes numerically). However the splicing can also help us
- * to recover from numerical errors. For example, suppose at one
- * point we checked eUp and eLo, and decided that eUp.Org is barely
- * above eLo. Then later, we split eLo into two edges (eg. from
- * a splice operation like this one). This can change the result of
- * our test so that now eUp.Org is incident to eLo, or barely below it.
- * We must correct this condition to maintain the dictionary invariants.
- *
- * One possibility is to check these edges for intersection again
- * (ie. CheckForIntersect). This is what we do if possible. However
- * CheckForIntersect requires that tess.event lies between eUp and eLo,
- * so that it has something to fall back on when the intersection
- * calculation gives us an unusable answer. So, for those cases where
- * we can't check for intersection, this routine fixes the problem
- * by just splicing the offending vertex into the other edge.
- * This is a guaranteed solution, no matter how degenerate things get.
- * Basically this is a combinatorial solution to a numerical problem.
- */ {
- ActiveRegion regLo = RegionBelow(regUp);
- GLUhalfEdge eUp = regUp.eUp;
- GLUhalfEdge eLo = regLo.eUp;
-
- if (Geom.VertLeq(eUp.Org, eLo.Org)) {
- if (Geom.EdgeSign(eLo.Sym.Org, eUp.Org, eLo.Org) > 0) return false;
-
- /* eUp.Org appears to be below eLo */
- if (!Geom.VertEq(eUp.Org, eLo.Org)) {
- /* Splice eUp.Org into eLo */
- if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eUp, eLo.Sym.Lnext)) throw new RuntimeException();
- regUp.dirty = regLo.dirty = true;
-
- } else if (eUp.Org != eLo.Org) {
- /* merge the two vertices, discarding eUp.Org */
- tess.pq.pqDelete(eUp.Org.pqHandle); /* __gl_pqSortDelete */
- SpliceMergeVertices(tess, eLo.Sym.Lnext, eUp);
- }
- } else {
- if (Geom.EdgeSign(eUp.Sym.Org, eLo.Org, eUp.Org) < 0) return false;
-
- /* eLo.Org appears to be above eUp, so splice eLo.Org into eUp */
- RegionAbove(regUp).dirty = regUp.dirty = true;
- if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException();
- }
- return true;
- }
-
- static boolean CheckForLeftSplice(GLUtesselatorImpl tess, ActiveRegion regUp)
-/*
- * Check the upper and lower edge of "regUp", to make sure that the
- * eUp.Sym.Org is above eLo, or eLo.Sym.Org is below eUp (depending on which
- * destination is rightmost).
- *
- * Theoretically, this should always be true. However, splitting an edge
- * into two pieces can change the results of previous tests. For example,
- * suppose at one point we checked eUp and eLo, and decided that eUp.Sym.Org
- * is barely above eLo. Then later, we split eLo into two edges (eg. from
- * a splice operation like this one). This can change the result of
- * the test so that now eUp.Sym.Org is incident to eLo, or barely below it.
- * We must correct this condition to maintain the dictionary invariants
- * (otherwise new edges might get inserted in the wrong place in the
- * dictionary, and bad stuff will happen).
- *
- * We fix the problem by just splicing the offending vertex into the
- * other edge.
- */ {
- ActiveRegion regLo = RegionBelow(regUp);
- GLUhalfEdge eUp = regUp.eUp;
- GLUhalfEdge eLo = regLo.eUp;
- GLUhalfEdge e;
-
- assert (!Geom.VertEq(eUp.Sym.Org, eLo.Sym.Org));
-
- if (Geom.VertLeq(eUp.Sym.Org, eLo.Sym.Org)) {
- if (Geom.EdgeSign(eUp.Sym.Org, eLo.Sym.Org, eUp.Org) < 0) return false;
-
- /* eLo.Sym.Org is above eUp, so splice eLo.Sym.Org into eUp */
- RegionAbove(regUp).dirty = regUp.dirty = true;
- e = Mesh.__gl_meshSplitEdge(eUp);
- if (e == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eLo.Sym, e)) throw new RuntimeException();
- e.Lface.inside = regUp.inside;
- } else {
- if (Geom.EdgeSign(eLo.Sym.Org, eUp.Sym.Org, eLo.Org) > 0) return false;
-
- /* eUp.Sym.Org is below eLo, so splice eUp.Sym.Org into eLo */
- regUp.dirty = regLo.dirty = true;
- e = Mesh.__gl_meshSplitEdge(eLo);
- if (e == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym)) throw new RuntimeException();
- e.Sym.Lface.inside = regUp.inside;
- }
- return true;
- }
-
-
- static boolean CheckForIntersect(GLUtesselatorImpl tess, ActiveRegion regUp)
-/*
- * Check the upper and lower edges of the given region to see if
- * they intersect. If so, create the intersection and add it
- * to the data structures.
- *
- * Returns true if adding the new intersection resulted in a recursive
- * call to AddRightEdges(); in this case all "dirty" regions have been
- * checked for intersections, and possibly regUp has been deleted.
- */ {
- ActiveRegion regLo = RegionBelow(regUp);
- GLUhalfEdge eUp = regUp.eUp;
- GLUhalfEdge eLo = regLo.eUp;
- GLUvertex orgUp = eUp.Org;
- GLUvertex orgLo = eLo.Org;
- GLUvertex dstUp = eUp.Sym.Org;
- GLUvertex dstLo = eLo.Sym.Org;
- double tMinUp, tMaxLo;
- GLUvertex isect = new GLUvertex();
- GLUvertex orgMin;
- GLUhalfEdge e;
-
- assert (!Geom.VertEq(dstLo, dstUp));
- assert (Geom.EdgeSign(dstUp, tess.event, orgUp) <= 0);
- assert (Geom.EdgeSign(dstLo, tess.event, orgLo) >= 0);
- assert (orgUp != tess.event && orgLo != tess.event);
- assert (!regUp.fixUpperEdge && !regLo.fixUpperEdge);
-
- if (orgUp == orgLo) return false; /* right endpoints are the same */
-
- tMinUp = Math.min(orgUp.t, dstUp.t);
- tMaxLo = Math.max(orgLo.t, dstLo.t);
- if (tMinUp > tMaxLo) return false; /* t ranges do not overlap */
-
- if (Geom.VertLeq(orgUp, orgLo)) {
- if (Geom.EdgeSign(dstLo, orgUp, orgLo) > 0) return false;
- } else {
- if (Geom.EdgeSign(dstUp, orgLo, orgUp) < 0) return false;
- }
-
- /* At this point the edges intersect, at least marginally */
- DebugEvent(tess);
-
- Geom.EdgeIntersect(dstUp, orgUp, dstLo, orgLo, isect);
- /* The following properties are guaranteed: */
- assert (Math.min(orgUp.t, dstUp.t) <= isect.t);
- assert (isect.t <= Math.max(orgLo.t, dstLo.t));
- assert (Math.min(dstLo.s, dstUp.s) <= isect.s);
- assert (isect.s <= Math.max(orgLo.s, orgUp.s));
-
- if (Geom.VertLeq(isect, tess.event)) {
- /* The intersection point lies slightly to the left of the sweep line,
- * so move it until it''s slightly to the right of the sweep line.
- * (If we had perfect numerical precision, this would never happen
- * in the first place). The easiest and safest thing to do is
- * replace the intersection by tess.event.
- */
- isect.s = tess.event.s;
- isect.t = tess.event.t;
- }
- /* Similarly, if the computed intersection lies to the right of the
- * rightmost origin (which should rarely happen), it can cause
- * unbelievable inefficiency on sufficiently degenerate inputs.
- * (If you have the test program, try running test54.d with the
- * "X zoom" option turned on).
- */
- orgMin = Geom.VertLeq(orgUp, orgLo) ? orgUp : orgLo;
- if (Geom.VertLeq(orgMin, isect)) {
- isect.s = orgMin.s;
- isect.t = orgMin.t;
- }
-
- if (Geom.VertEq(isect, orgUp) || Geom.VertEq(isect, orgLo)) {
- /* Easy case -- intersection at one of the right endpoints */
- CheckForRightSplice(tess, regUp);
- return false;
- }
-
- if ((!Geom.VertEq(dstUp, tess.event)
- && Geom.EdgeSign(dstUp, tess.event, isect) >= 0)
- || (!Geom.VertEq(dstLo, tess.event)
- && Geom.EdgeSign(dstLo, tess.event, isect) <= 0)) {
- /* Very unusual -- the new upper or lower edge would pass on the
- * wrong side of the sweep event, or through it. This can happen
- * due to very small numerical errors in the intersection calculation.
- */
- if (dstLo == tess.event) {
- /* Splice dstLo into eUp, and process the new region(s) */
- if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eLo.Sym, eUp)) throw new RuntimeException();
- regUp = TopLeftRegion(regUp);
- if (regUp == null) throw new RuntimeException();
- eUp = RegionBelow(regUp).eUp;
- FinishLeftRegions(tess, RegionBelow(regUp), regLo);
- AddRightEdges(tess, regUp, eUp.Sym.Lnext, eUp, eUp, true);
- return true;
- }
- if (dstUp == tess.event) {
- /* Splice dstUp into eLo, and process the new region(s) */
- if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eUp.Lnext, eLo.Sym.Lnext)) throw new RuntimeException();
- regLo = regUp;
- regUp = TopRightRegion(regUp);
- e = RegionBelow(regUp).eUp.Sym.Onext;
- regLo.eUp = eLo.Sym.Lnext;
- eLo = FinishLeftRegions(tess, regLo, null);
- AddRightEdges(tess, regUp, eLo.Onext, eUp.Sym.Onext, e, true);
- return true;
- }
- /* Special case: called from ConnectRightVertex. If either
- * edge passes on the wrong side of tess.event, split it
- * (and wait for ConnectRightVertex to splice it appropriately).
- */
- if (Geom.EdgeSign(dstUp, tess.event, isect) >= 0) {
- RegionAbove(regUp).dirty = regUp.dirty = true;
- if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
- eUp.Org.s = tess.event.s;
- eUp.Org.t = tess.event.t;
- }
- if (Geom.EdgeSign(dstLo, tess.event, isect) <= 0) {
- regUp.dirty = regLo.dirty = true;
- if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
- eLo.Org.s = tess.event.s;
- eLo.Org.t = tess.event.t;
- }
- /* leave the rest for ConnectRightVertex */
- return false;
- }
-
- /* General case -- split both edges, splice into new vertex.
- * When we do the splice operation, the order of the arguments is
- * arbitrary as far as correctness goes. However, when the operation
- * creates a new face, the work done is proportional to the size of
- * the new face. We expect the faces in the processed part of
- * the mesh (ie. eUp.Lface) to be smaller than the faces in the
- * unprocessed original contours (which will be eLo.Sym.Lnext.Lface).
- */
- if (Mesh.__gl_meshSplitEdge(eUp.Sym) == null) throw new RuntimeException();
- if (Mesh.__gl_meshSplitEdge(eLo.Sym) == null) throw new RuntimeException();
- if (!Mesh.__gl_meshSplice(eLo.Sym.Lnext, eUp)) throw new RuntimeException();
- eUp.Org.s = isect.s;
- eUp.Org.t = isect.t;
- eUp.Org.pqHandle = tess.pq.pqInsert(eUp.Org); /* __gl_pqSortInsert */
- if (eUp.Org.pqHandle == Long.MAX_VALUE) {
- tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
- tess.pq = null;
- throw new RuntimeException();
- }
- GetIntersectData(tess, eUp.Org, orgUp, dstUp, orgLo, dstLo);
- RegionAbove(regUp).dirty = regUp.dirty = regLo.dirty = true;
- return false;
- }
-
- static void WalkDirtyRegions(GLUtesselatorImpl tess, ActiveRegion regUp)
-/*
- * When the upper or lower edge of any region changes, the region is
- * marked "dirty". This routine walks through all the dirty regions
- * and makes sure that the dictionary invariants are satisfied
- * (see the comments at the beginning of this file). Of course
- * new dirty regions can be created as we make changes to restore
- * the invariants.
- */ {
- ActiveRegion regLo = RegionBelow(regUp);
- GLUhalfEdge eUp, eLo;
-
- for (; ;) {
- /* Find the lowest dirty region (we walk from the bottom up). */
- while (regLo.dirty) {
- regUp = regLo;
- regLo = RegionBelow(regLo);
- }
- if (!regUp.dirty) {
- regLo = regUp;
- regUp = RegionAbove(regUp);
- if (regUp == null || !regUp.dirty) {
- /* We've walked all the dirty regions */
- return;
- }
- }
- regUp.dirty = false;
- eUp = regUp.eUp;
- eLo = regLo.eUp;
-
- if (eUp.Sym.Org != eLo.Sym.Org) {
- /* Check that the edge ordering is obeyed at the Dst vertices. */
- if (CheckForLeftSplice(tess, regUp)) {
-
- /* If the upper or lower edge was marked fixUpperEdge, then
- * we no longer need it (since these edges are needed only for
- * vertices which otherwise have no right-going edges).
- */
- if (regLo.fixUpperEdge) {
- DeleteRegion(tess, regLo);
- if (!Mesh.__gl_meshDelete(eLo)) throw new RuntimeException();
- regLo = RegionBelow(regUp);
- eLo = regLo.eUp;
- } else if (regUp.fixUpperEdge) {
- DeleteRegion(tess, regUp);
- if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException();
- regUp = RegionAbove(regLo);
- eUp = regUp.eUp;
- }
- }
- }
- if (eUp.Org != eLo.Org) {
- if (eUp.Sym.Org != eLo.Sym.Org
- && !regUp.fixUpperEdge && !regLo.fixUpperEdge
- && (eUp.Sym.Org == tess.event || eLo.Sym.Org == tess.event)) {
- /* When all else fails in CheckForIntersect(), it uses tess.event
- * as the intersection location. To make this possible, it requires
- * that tess.event lie between the upper and lower edges, and also
- * that neither of these is marked fixUpperEdge (since in the worst
- * case it might splice one of these edges into tess.event, and
- * violate the invariant that fixable edges are the only right-going
- * edge from their associated vertex).
- */
- if (CheckForIntersect(tess, regUp)) {
- /* WalkDirtyRegions() was called recursively; we're done */
- return;
- }
- } else {
- /* Even though we can't use CheckForIntersect(), the Org vertices
- * may violate the dictionary edge ordering. Check and correct this.
- */
- CheckForRightSplice(tess, regUp);
- }
- }
- if (eUp.Org == eLo.Org && eUp.Sym.Org == eLo.Sym.Org) {
- /* A degenerate loop consisting of only two edges -- delete it. */
- AddWinding(eLo, eUp);
- DeleteRegion(tess, regUp);
- if (!Mesh.__gl_meshDelete(eUp)) throw new RuntimeException();
- regUp = RegionAbove(regLo);
- }
- }
- }
-
-
- static void ConnectRightVertex(GLUtesselatorImpl tess, ActiveRegion regUp,
- GLUhalfEdge eBottomLeft)
-/*
- * Purpose: connect a "right" vertex vEvent (one where all edges go left)
- * to the unprocessed portion of the mesh. Since there are no right-going
- * edges, two regions (one above vEvent and one below) are being merged
- * into one. "regUp" is the upper of these two regions.
- *
- * There are two reasons for doing this (adding a right-going edge):
- * - if the two regions being merged are "inside", we must add an edge
- * to keep them separated (the combined region would not be monotone).
- * - in any case, we must leave some record of vEvent in the dictionary,
- * so that we can merge vEvent with features that we have not seen yet.
- * For example, maybe there is a vertical edge which passes just to
- * the right of vEvent; we would like to splice vEvent into this edge.
- *
- * However, we don't want to connect vEvent to just any vertex. We don''t
- * want the new edge to cross any other edges; otherwise we will create
- * intersection vertices even when the input data had no self-intersections.
- * (This is a bad thing; if the user's input data has no intersections,
- * we don't want to generate any false intersections ourselves.)
- *
- * Our eventual goal is to connect vEvent to the leftmost unprocessed
- * vertex of the combined region (the union of regUp and regLo).
- * But because of unseen vertices with all right-going edges, and also
- * new vertices which may be created by edge intersections, we don''t
- * know where that leftmost unprocessed vertex is. In the meantime, we
- * connect vEvent to the closest vertex of either chain, and mark the region
- * as "fixUpperEdge". This flag says to delete and reconnect this edge
- * to the next processed vertex on the boundary of the combined region.
- * Quite possibly the vertex we connected to will turn out to be the
- * closest one, in which case we won''t need to make any changes.
- */ {
- GLUhalfEdge eNew;
- GLUhalfEdge eTopLeft = eBottomLeft.Onext;
- ActiveRegion regLo = RegionBelow(regUp);
- GLUhalfEdge eUp = regUp.eUp;
- GLUhalfEdge eLo = regLo.eUp;
- boolean degenerate = false;
-
- if (eUp.Sym.Org != eLo.Sym.Org) {
- CheckForIntersect(tess, regUp);
- }
-
- /* Possible new degeneracies: upper or lower edge of regUp may pass
- * through vEvent, or may coincide with new intersection vertex
- */
- if (Geom.VertEq(eUp.Org, tess.event)) {
- if (!Mesh.__gl_meshSplice(eTopLeft.Sym.Lnext, eUp)) throw new RuntimeException();
- regUp = TopLeftRegion(regUp);
- if (regUp == null) throw new RuntimeException();
- eTopLeft = RegionBelow(regUp).eUp;
- FinishLeftRegions(tess, RegionBelow(regUp), regLo);
- degenerate = true;
- }
- if (Geom.VertEq(eLo.Org, tess.event)) {
- if (!Mesh.__gl_meshSplice(eBottomLeft, eLo.Sym.Lnext)) throw new RuntimeException();
- eBottomLeft = FinishLeftRegions(tess, regLo, null);
- degenerate = true;
- }
- if (degenerate) {
- AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true);
- return;
- }
-
- /* Non-degenerate situation -- need to add a temporary, fixable edge.
- * Connect to the closer of eLo.Org, eUp.Org.
- */
- if (Geom.VertLeq(eLo.Org, eUp.Org)) {
- eNew = eLo.Sym.Lnext;
- } else {
- eNew = eUp;
- }
- eNew = Mesh.__gl_meshConnect(eBottomLeft.Onext.Sym, eNew);
- if (eNew == null) throw new RuntimeException();
-
- /* Prevent cleanup, otherwise eNew might disappear before we've even
- * had a chance to mark it as a temporary edge.
- */
- AddRightEdges(tess, regUp, eNew, eNew.Onext, eNew.Onext, false);
- eNew.Sym.activeRegion.fixUpperEdge = true;
- WalkDirtyRegions(tess, regUp);
- }
-
-/* Because vertices at exactly the same location are merged together
- * before we process the sweep event, some degenerate cases can't occur.
- * However if someone eventually makes the modifications required to
- * merge features which are close together, the cases below marked
- * TOLERANCE_NONZERO will be useful. They were debugged before the
- * code to merge identical vertices in the main loop was added.
- */
- private static final boolean TOLERANCE_NONZERO = false;
-
- static void ConnectLeftDegenerate(GLUtesselatorImpl tess,
- ActiveRegion regUp, GLUvertex vEvent)
-/*
- * The event vertex lies exacty on an already-processed edge or vertex.
- * Adding the new vertex involves splicing it into the already-processed
- * part of the mesh.
- */ {
- GLUhalfEdge e, eTopLeft, eTopRight, eLast;
- ActiveRegion reg;
-
- e = regUp.eUp;
- if (Geom.VertEq(e.Org, vEvent)) {
- /* e.Org is an unprocessed vertex - just combine them, and wait
- * for e.Org to be pulled from the queue
- */
- assert (TOLERANCE_NONZERO);
- SpliceMergeVertices(tess, e, vEvent.anEdge);
- return;
- }
-
- if (!Geom.VertEq(e.Sym.Org, vEvent)) {
- /* General case -- splice vEvent into edge e which passes through it */
- if (Mesh.__gl_meshSplitEdge(e.Sym) == null) throw new RuntimeException();
- if (regUp.fixUpperEdge) {
- /* This edge was fixable -- delete unused portion of original edge */
- if (!Mesh.__gl_meshDelete(e.Onext)) throw new RuntimeException();
- regUp.fixUpperEdge = false;
- }
- if (!Mesh.__gl_meshSplice(vEvent.anEdge, e)) throw new RuntimeException();
- SweepEvent(tess, vEvent); /* recurse */
- return;
- }
-
- /* vEvent coincides with e.Sym.Org, which has already been processed.
- * Splice in the additional right-going edges.
- */
- assert (TOLERANCE_NONZERO);
- regUp = TopRightRegion(regUp);
- reg = RegionBelow(regUp);
- eTopRight = reg.eUp.Sym;
- eTopLeft = eLast = eTopRight.Onext;
- if (reg.fixUpperEdge) {
- /* Here e.Sym.Org has only a single fixable edge going right.
- * We can delete it since now we have some real right-going edges.
- */
- assert (eTopLeft != eTopRight); /* there are some left edges too */
- DeleteRegion(tess, reg);
- if (!Mesh.__gl_meshDelete(eTopRight)) throw new RuntimeException();
- eTopRight = eTopLeft.Sym.Lnext;
- }
- if (!Mesh.__gl_meshSplice(vEvent.anEdge, eTopRight)) throw new RuntimeException();
- if (!Geom.EdgeGoesLeft(eTopLeft)) {
- /* e.Sym.Org had no left-going edges -- indicate this to AddRightEdges() */
- eTopLeft = null;
- }
- AddRightEdges(tess, regUp, eTopRight.Onext, eLast, eTopLeft, true);
- }
-
-
- static void ConnectLeftVertex(GLUtesselatorImpl tess, GLUvertex vEvent)
-/*
- * Purpose: connect a "left" vertex (one where both edges go right)
- * to the processed portion of the mesh. Let R be the active region
- * containing vEvent, and let U and L be the upper and lower edge
- * chains of R. There are two possibilities:
- *
- * - the normal case: split R into two regions, by connecting vEvent to
- * the rightmost vertex of U or L lying to the left of the sweep line
- *
- * - the degenerate case: if vEvent is close enough to U or L, we
- * merge vEvent into that edge chain. The subcases are:
- * - merging with the rightmost vertex of U or L
- * - merging with the active edge of U or L
- * - merging with an already-processed portion of U or L
- */ {
- ActiveRegion regUp, regLo, reg;
- GLUhalfEdge eUp, eLo, eNew;
- ActiveRegion tmp = new ActiveRegion();
-
- /* assert ( vEvent.anEdge.Onext.Onext == vEvent.anEdge ); */
-
- /* Get a pointer to the active region containing vEvent */
- tmp.eUp = vEvent.anEdge.Sym;
- /* __GL_DICTLISTKEY */ /* __gl_dictListSearch */
- regUp = (ActiveRegion) Dict.dictKey(Dict.dictSearch(tess.dict, tmp));
- regLo = RegionBelow(regUp);
- eUp = regUp.eUp;
- eLo = regLo.eUp;
-
- /* Try merging with U or L first */
- if (Geom.EdgeSign(eUp.Sym.Org, vEvent, eUp.Org) == 0) {
- ConnectLeftDegenerate(tess, regUp, vEvent);
- return;
- }
-
- /* Connect vEvent to rightmost processed vertex of either chain.
- * e.Sym.Org is the vertex that we will connect to vEvent.
- */
- reg = Geom.VertLeq(eLo.Sym.Org, eUp.Sym.Org) ? regUp : regLo;
-
- if (regUp.inside || reg.fixUpperEdge) {
- if (reg == regUp) {
- eNew = Mesh.__gl_meshConnect(vEvent.anEdge.Sym, eUp.Lnext);
- if (eNew == null) throw new RuntimeException();
- } else {
- GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(eLo.Sym.Onext.Sym, vEvent.anEdge);
- if (tempHalfEdge == null) throw new RuntimeException();
-
- eNew = tempHalfEdge.Sym;
- }
- if (reg.fixUpperEdge) {
- if (!FixUpperEdge(reg, eNew)) throw new RuntimeException();
- } else {
- ComputeWinding(tess, AddRegionBelow(tess, regUp, eNew));
- }
- SweepEvent(tess, vEvent);
- } else {
- /* The new vertex is in a region which does not belong to the polygon.
- * We don''t need to connect this vertex to the rest of the mesh.
- */
- AddRightEdges(tess, regUp, vEvent.anEdge, vEvent.anEdge, null, true);
- }
- }
-
-
- static void SweepEvent(GLUtesselatorImpl tess, GLUvertex vEvent)
-/*
- * Does everything necessary when the sweep line crosses a vertex.
- * Updates the mesh and the edge dictionary.
- */ {
- ActiveRegion regUp, reg;
- GLUhalfEdge e, eTopLeft, eBottomLeft;
-
- tess.event = vEvent; /* for access in EdgeLeq() */
- DebugEvent(tess);
-
- /* Check if this vertex is the right endpoint of an edge that is
- * already in the dictionary. In this case we don't need to waste
- * time searching for the location to insert new edges.
- */
- e = vEvent.anEdge;
- while (e.activeRegion == null) {
- e = e.Onext;
- if (e == vEvent.anEdge) {
- /* All edges go right -- not incident to any processed edges */
- ConnectLeftVertex(tess, vEvent);
- return;
- }
- }
-
- /* Processing consists of two phases: first we "finish" all the
- * active regions where both the upper and lower edges terminate
- * at vEvent (ie. vEvent is closing off these regions).
- * We mark these faces "inside" or "outside" the polygon according
- * to their winding number, and delete the edges from the dictionary.
- * This takes care of all the left-going edges from vEvent.
- */
- regUp = TopLeftRegion(e.activeRegion);
- if (regUp == null) throw new RuntimeException();
- reg = RegionBelow(regUp);
- eTopLeft = reg.eUp;
- eBottomLeft = FinishLeftRegions(tess, reg, null);
-
- /* Next we process all the right-going edges from vEvent. This
- * involves adding the edges to the dictionary, and creating the
- * associated "active regions" which record information about the
- * regions between adjacent dictionary edges.
- */
- if (eBottomLeft.Onext == eTopLeft) {
- /* No right-going edges -- add a temporary "fixable" edge */
- ConnectRightVertex(tess, regUp, eBottomLeft);
- } else {
- AddRightEdges(tess, regUp, eBottomLeft.Onext, eTopLeft, eTopLeft, true);
- }
- }
-
-
-/* Make the sentinel coordinates big enough that they will never be
- * merged with real input features. (Even with the largest possible
- * input contour and the maximum tolerance of 1.0, no merging will be
- * done with coordinates larger than 3 * GLU_TESS_MAX_COORD).
- */
- private static final double SENTINEL_COORD = (4.0 * GLU.GLU_TESS_MAX_COORD);
-
- static void AddSentinel(GLUtesselatorImpl tess, double t)
-/*
- * We add two sentinel edges above and below all other edges,
- * to avoid special cases at the top and bottom.
- */ {
- GLUhalfEdge e;
- ActiveRegion reg = new ActiveRegion();
- if (reg == null) throw new RuntimeException();
-
- e = Mesh.__gl_meshMakeEdge(tess.mesh);
- if (e == null) throw new RuntimeException();
-
- e.Org.s = SENTINEL_COORD;
- e.Org.t = t;
- e.Sym.Org.s = -SENTINEL_COORD;
- e.Sym.Org.t = t;
- tess.event = e.Sym.Org; /* initialize it */
-
- reg.eUp = e;
- reg.windingNumber = 0;
- reg.inside = false;
- reg.fixUpperEdge = false;
- reg.sentinel = true;
- reg.dirty = false;
- reg.nodeUp = Dict.dictInsert(tess.dict, reg); /* __gl_dictListInsertBefore */
- if (reg.nodeUp == null) throw new RuntimeException();
- }
-
-
- static void InitEdgeDict(final GLUtesselatorImpl tess)
-/*
- * We maintain an ordering of edge intersections with the sweep line.
- * This order is maintained in a dynamic dictionary.
- */ {
- /* __gl_dictListNewDict */
- tess.dict = Dict.dictNewDict(tess, new Dict.DictLeq() {
- public boolean leq(Object frame, Object key1, Object key2) {
- return EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2);
- }
- });
- if (tess.dict == null) throw new RuntimeException();
-
- AddSentinel(tess, -SENTINEL_COORD);
- AddSentinel(tess, SENTINEL_COORD);
- }
-
-
- static void DoneEdgeDict(GLUtesselatorImpl tess) {
- ActiveRegion reg;
- int fixedEdges = 0;
-
- /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */
- while ((reg = (ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))) != null) {
- /*
- * At the end of all processing, the dictionary should contain
- * only the two sentinel edges, plus at most one "fixable" edge
- * created by ConnectRightVertex().
- */
- if (!reg.sentinel) {
- assert (reg.fixUpperEdge);
- assert (++fixedEdges == 1);
- }
- assert (reg.windingNumber == 0);
- DeleteRegion(tess, reg);
-/* __gl_meshDelete( reg.eUp );*/
- }
- Dict.dictDeleteDict(tess.dict); /* __gl_dictListDeleteDict */
- }
-
-
- static void RemoveDegenerateEdges(GLUtesselatorImpl tess)
-/*
- * Remove zero-length edges, and contours with fewer than 3 vertices.
- */ {
- GLUhalfEdge e, eNext, eLnext;
- GLUhalfEdge eHead = tess.mesh.eHead;
-
- /*LINTED*/
- for (e = eHead.next; e != eHead; e = eNext) {
- eNext = e.next;
- eLnext = e.Lnext;
-
- if (Geom.VertEq(e.Org, e.Sym.Org) && e.Lnext.Lnext != e) {
- /* Zero-length edge, contour has at least 3 edges */
-
- SpliceMergeVertices(tess, eLnext, e); /* deletes e.Org */
- if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException(); /* e is a self-loop */
- e = eLnext;
- eLnext = e.Lnext;
- }
- if (eLnext.Lnext == e) {
- /* Degenerate contour (one or two edges) */
-
- if (eLnext != e) {
- if (eLnext == eNext || eLnext == eNext.Sym) {
- eNext = eNext.next;
- }
- if (!Mesh.__gl_meshDelete(eLnext)) throw new RuntimeException();
- }
- if (e == eNext || e == eNext.Sym) {
- eNext = eNext.next;
- }
- if (!Mesh.__gl_meshDelete(e)) throw new RuntimeException();
- }
- }
- }
-
- static boolean InitPriorityQ(GLUtesselatorImpl tess)
-/*
- * Insert all vertices into the priority queue which determines the
- * order in which vertices cross the sweep line.
- */ {
- PriorityQ pq;
- GLUvertex v, vHead;
-
- /* __gl_pqSortNewPriorityQ */
- pq = tess.pq = PriorityQ.pqNewPriorityQ(new PriorityQ.Leq() {
- public boolean leq(Object key1, Object key2) {
- return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2);
- }
- });
- if (pq == null) return false;
-
- vHead = tess.mesh.vHead;
- for (v = vHead.next; v != vHead; v = v.next) {
- v.pqHandle = pq.pqInsert(v); /* __gl_pqSortInsert */
- if (v.pqHandle == Long.MAX_VALUE) break;
- }
- if (v != vHead || !pq.pqInit()) { /* __gl_pqSortInit */
- tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
- tess.pq = null;
- return false;
- }
-
- return true;
- }
-
-
- static void DonePriorityQ(GLUtesselatorImpl tess) {
- tess.pq.pqDeletePriorityQ(); /* __gl_pqSortDeletePriorityQ */
- }
-
-
- static boolean RemoveDegenerateFaces(GLUmesh mesh)
-/*
- * Delete any degenerate faces with only two edges. WalkDirtyRegions()
- * will catch almost all of these, but it won't catch degenerate faces
- * produced by splice operations on already-processed edges.
- * The two places this can happen are in FinishLeftRegions(), when
- * we splice in a "temporary" edge produced by ConnectRightVertex(),
- * and in CheckForLeftSplice(), where we splice already-processed
- * edges to ensure that our dictionary invariants are not violated
- * by numerical errors.
- *
- * In both these cases it is *very* dangerous to delete the offending
- * edge at the time, since one of the routines further up the stack
- * will sometimes be keeping a pointer to that edge.
- */ {
- GLUface f, fNext;
- GLUhalfEdge e;
-
- /*LINTED*/
- for (f = mesh.fHead.next; f != mesh.fHead; f = fNext) {
- fNext = f.next;
- e = f.anEdge;
- assert (e.Lnext != e);
-
- if (e.Lnext.Lnext == e) {
- /* A face with only two edges */
- AddWinding(e.Onext, e);
- if (!Mesh.__gl_meshDelete(e)) return false;
- }
- }
- return true;
- }
-
- public static boolean __gl_computeInterior(GLUtesselatorImpl tess)
-/*
- * __gl_computeInterior( tess ) computes the planar arrangement specified
- * by the given contours, and further subdivides this arrangement
- * into regions. Each region is marked "inside" if it belongs
- * to the polygon, according to the rule given by tess.windingRule.
- * Each interior region is guaranteed be monotone.
- */ {
- GLUvertex v, vNext;
-
- tess.fatalError = false;
-
- /* Each vertex defines an event for our sweep line. Start by inserting
- * all the vertices in a priority queue. Events are processed in
- * lexicographic order, ie.
- *
- * e1 < e2 iff e1.x < e2.x || (e1.x == e2.x && e1.y < e2.y)
- */
- RemoveDegenerateEdges(tess);
- if (!InitPriorityQ(tess)) return false; /* if error */
- InitEdgeDict(tess);
-
- /* __gl_pqSortExtractMin */
- while ((v = (GLUvertex) tess.pq.pqExtractMin()) != null) {
- for (; ;) {
- vNext = (GLUvertex) tess.pq.pqMinimum(); /* __gl_pqSortMinimum */
- if (vNext == null || !Geom.VertEq(vNext, v)) break;
-
- /* Merge together all vertices at exactly the same location.
- * This is more efficient than processing them one at a time,
- * simplifies the code (see ConnectLeftDegenerate), and is also
- * important for correct handling of certain degenerate cases.
- * For example, suppose there are two identical edges A and B
- * that belong to different contours (so without this code they would
- * be processed by separate sweep events). Suppose another edge C
- * crosses A and B from above. When A is processed, we split it
- * at its intersection point with C. However this also splits C,
- * so when we insert B we may compute a slightly different
- * intersection point. This might leave two edges with a small
- * gap between them. This kind of error is especially obvious
- * when using boundary extraction (GLU_TESS_BOUNDARY_ONLY).
- */
- vNext = (GLUvertex) tess.pq.pqExtractMin(); /* __gl_pqSortExtractMin*/
- SpliceMergeVertices(tess, v.anEdge, vNext.anEdge);
- }
- SweepEvent(tess, v);
- }
-
- /* Set tess.event for debugging purposes */
- /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */
- tess.event = ((ActiveRegion) Dict.dictKey(Dict.dictMin(tess.dict))).eUp.Org;
- DebugEvent(tess);
- DoneEdgeDict(tess);
- DonePriorityQ(tess);
-
- if (!RemoveDegenerateFaces(tess.mesh)) return false;
- Mesh.__gl_meshCheckMesh(tess.mesh);
-
- return true;
- }
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/TessMono.java b/src/net/java/games/jogl/impl/tesselator/TessMono.java
deleted file mode 100644
index 9e55e1194..000000000
--- a/src/net/java/games/jogl/impl/tesselator/TessMono.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-class TessMono {
-/* __gl_meshTessellateMonoRegion( face ) tessellates a monotone region
- * (what else would it do??) The region must consist of a single
- * loop of half-edges (see mesh.h) oriented CCW. "Monotone" in this
- * case means that any vertical line intersects the interior of the
- * region in a single interval.
- *
- * Tessellation consists of adding interior edges (actually pairs of
- * half-edges), to split the region into non-overlapping triangles.
- *
- * The basic idea is explained in Preparata and Shamos (which I don''t
- * have handy right now), although their implementation is more
- * complicated than this one. The are two edge chains, an upper chain
- * and a lower chain. We process all vertices from both chains in order,
- * from right to left.
- *
- * The algorithm ensures that the following invariant holds after each
- * vertex is processed: the untessellated region consists of two
- * chains, where one chain (say the upper) is a single edge, and
- * the other chain is concave. The left vertex of the single edge
- * is always to the left of all vertices in the concave chain.
- *
- * Each step consists of adding the rightmost unprocessed vertex to one
- * of the two chains, and forming a fan of triangles from the rightmost
- * of two chain endpoints. Determining whether we can add each triangle
- * to the fan is a simple orientation test. By making the fan as large
- * as possible, we restore the invariant (check it yourself).
- */
- static boolean __gl_meshTessellateMonoRegion(GLUface face) {
- GLUhalfEdge up, lo;
-
- /* All edges are oriented CCW around the boundary of the region.
- * First, find the half-edge whose origin vertex is rightmost.
- * Since the sweep goes from left to right, face->anEdge should
- * be close to the edge we want.
- */
- up = face.anEdge;
- assert (up.Lnext != up && up.Lnext.Lnext != up);
-
- for (; Geom.VertLeq(up.Sym.Org, up.Org); up = up.Onext.Sym)
- ;
- for (; Geom.VertLeq(up.Org, up.Sym.Org); up = up.Lnext)
- ;
- lo = up.Onext.Sym;
-
- while (up.Lnext != lo) {
- if (Geom.VertLeq(up.Sym.Org, lo.Org)) {
- /* up.Sym.Org is on the left. It is safe to form triangles from lo.Org.
- * The EdgeGoesLeft test guarantees progress even when some triangles
- * are CW, given that the upper and lower chains are truly monotone.
- */
- while (lo.Lnext != up && (Geom.EdgeGoesLeft(lo.Lnext)
- || Geom.EdgeSign(lo.Org, lo.Sym.Org, lo.Lnext.Sym.Org) <= 0)) {
- GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo);
- if (tempHalfEdge == null) return false;
- lo = tempHalfEdge.Sym;
- }
- lo = lo.Onext.Sym;
- } else {
- /* lo.Org is on the left. We can make CCW triangles from up.Sym.Org. */
- while (lo.Lnext != up && (Geom.EdgeGoesRight(up.Onext.Sym)
- || Geom.EdgeSign(up.Sym.Org, up.Org, up.Onext.Sym.Org) >= 0)) {
- GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(up, up.Onext.Sym);
- if (tempHalfEdge == null) return false;
- up = tempHalfEdge.Sym;
- }
- up = up.Lnext;
- }
- }
-
- /* Now lo.Org == up.Sym.Org == the leftmost vertex. The remaining region
- * can be tessellated in a fan from this leftmost vertex.
- */
- assert (lo.Lnext != up);
- while (lo.Lnext.Lnext != up) {
- GLUhalfEdge tempHalfEdge = Mesh.__gl_meshConnect(lo.Lnext, lo);
- if (tempHalfEdge == null) return false;
- lo = tempHalfEdge.Sym;
- }
-
- return true;
- }
-
-
-/* __gl_meshTessellateInterior( mesh ) tessellates each region of
- * the mesh which is marked "inside" the polygon. Each such region
- * must be monotone.
- */
- public static boolean __gl_meshTessellateInterior(GLUmesh mesh) {
- GLUface f, next;
-
- /*LINTED*/
- for (f = mesh.fHead.next; f != mesh.fHead; f = next) {
- /* Make sure we don''t try to tessellate the new triangles. */
- next = f.next;
- if (f.inside) {
- if (!__gl_meshTessellateMonoRegion(f)) return false;
- }
- }
-
- return true;
- }
-
-
-/* __gl_meshDiscardExterior( mesh ) zaps (ie. sets to NULL) all faces
- * which are not marked "inside" the polygon. Since further mesh operations
- * on NULL faces are not allowed, the main purpose is to clean up the
- * mesh so that exterior loops are not represented in the data structure.
- */
- public static void __gl_meshDiscardExterior(GLUmesh mesh) {
- GLUface f, next;
-
- /*LINTED*/
- for (f = mesh.fHead.next; f != mesh.fHead; f = next) {
- /* Since f will be destroyed, save its next pointer. */
- next = f.next;
- if (!f.inside) {
- Mesh.__gl_meshZapFace(f);
- }
- }
- }
-
- private static final int MARKED_FOR_DELETION = 0x7fffffff;
-
-/* __gl_meshSetWindingNumber( mesh, value, keepOnlyBoundary ) resets the
- * winding numbers on all edges so that regions marked "inside" the
- * polygon have a winding number of "value", and regions outside
- * have a winding number of 0.
- *
- * If keepOnlyBoundary is TRUE, it also deletes all edges which do not
- * separate an interior region from an exterior one.
- */
- public static boolean __gl_meshSetWindingNumber(GLUmesh mesh, int value, boolean keepOnlyBoundary) {
- GLUhalfEdge e, eNext;
-
- for (e = mesh.eHead.next; e != mesh.eHead; e = eNext) {
- eNext = e.next;
- if (e.Sym.Lface.inside != e.Lface.inside) {
-
- /* This is a boundary edge (one side is interior, one is exterior). */
- e.winding = (e.Lface.inside) ? value : -value;
- } else {
-
- /* Both regions are interior, or both are exterior. */
- if (!keepOnlyBoundary) {
- e.winding = 0;
- } else {
- if (!Mesh.__gl_meshDelete(e)) return false;
- }
- }
- }
- return true;
- }
-
-}
diff --git a/src/net/java/games/jogl/impl/tesselator/TessState.java b/src/net/java/games/jogl/impl/tesselator/TessState.java
deleted file mode 100644
index 6d89d4678..000000000
--- a/src/net/java/games/jogl/impl/tesselator/TessState.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Portions Copyright (C) 2003 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** 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
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** 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.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package net.java.games.jogl.impl.tesselator;
-
-
-class TessState {
- public static final int T_DORMANT = 0;
- public static final int T_IN_POLYGON = 1;
- public static final int T_IN_CONTOUR = 2;
-}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
deleted file mode 100644
index e838c68aa..000000000
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.windows;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.Rectangle;
-import java.util.*;
-import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public abstract class WindowsGLContext extends GLContext {
- private static JAWT jawt;
- protected long hglrc;
- protected long hdc;
- private boolean wglGetExtensionsStringEXTInitialized;
- private boolean wglGetExtensionsStringEXTAvailable;
- private static final Map/*<String, String>*/ functionNameMap;
- private static final Map/*<String, String>*/ extensionNameMap;
- // Table that holds the addresses of the native C-language entry points for
- // OpenGL functions.
- private GLProcAddressTable glProcAddressTable;
- // Handle to GLU32.dll
- private long hglu32;
- private boolean haveWGLARBPbuffer = true;
-
- private static final int MAX_PFORMATS = 256;
- private static final int MAX_ATTRIBS = 256;
-
- static {
- functionNameMap = new HashMap();
- functionNameMap.put("glAllocateMemoryNV", "wglAllocateMemoryNV");
- functionNameMap.put("glFreeMemoryNV", "wglFreeMemoryNV");
-
- extensionNameMap = new HashMap();
- extensionNameMap.put("GL_ARB_pbuffer", "WGL_ARB_pbuffer");
- extensionNameMap.put("GL_ARB_pixel_format", "WGL_ARB_pixel_format");
- }
-
- public WindowsGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(component, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new WindowsGLImpl(this);
- }
-
- protected String mapToRealGLFunctionName(String glFunctionName) {
- String lookup = (String) functionNameMap.get(glFunctionName);
- if (lookup != null) {
- return lookup;
- }
- return glFunctionName;
- }
-
- protected String mapToRealGLExtensionName(String glExtensionName) {
- String lookup = (String) extensionNameMap.get(glExtensionName);
- if (lookup != null) {
- return lookup;
- }
- return glExtensionName;
- }
-
- protected abstract boolean isOffscreen();
-
- public int getOffscreenContextWidth() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextHeight() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextPixelDataType() {
- throw new GLException("Should not call this");
- }
-
- public abstract int getOffscreenContextReadBuffer();
-
- public abstract boolean offscreenImageNeedsVerticalFlip();
-
- /**
- * Creates and initializes an appropriate OpenGL context. Should only be
- * called by {@link #makeCurrent(Runnable)}.
- */
- protected abstract void create();
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- boolean created = false;
- if (hglrc == 0) {
- create();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
-
- boolean skipMakeCurrent = false;
- if (NO_FREE) {
- if (WGL.wglGetCurrentContext() == hglrc) {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": skipping wglMakeCurrent because context already current");
- }
- skipMakeCurrent = true;
- }
- }
-
- if (!skipMakeCurrent) {
- if (!WGL.wglMakeCurrent(hdc, hglrc)) {
- throw new GLException("Error making context current: " + WGL.GetLastError());
- } else {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) +
- ", hglrc " + hdcToString(hglrc) + ") succeeded");
- }
- }
- }
-
- if (created) {
- resetGLFunctionAvailability();
- haveWGLARBPbuffer = (isExtensionAvailable("WGL_ARB_pbuffer") &&
- isExtensionAvailable("WGL_ARB_pixel_format"));
- // Windows can set up sharing of display lists after creation time
- WindowsGLContext other = (WindowsGLContext) GLContextShareSet.getShareContext(this);
- if (other != null) {
- long hglrc2 = other.getHGLRC();
- if (hglrc2 == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- if (!WGL.wglShareLists(hglrc2, hglrc)) {
- throw new GLException("wglShareLists(0x" + Long.toHexString(hglrc2) +
- ", 0x" + Long.toHexString(hglrc) + ") failed: error code " +
- WGL.GetLastError());
- }
- }
- GLContextShareSet.contextCreated(this);
-
- initAction.run();
- }
- return true;
- }
-
- protected synchronized void free() throws GLException {
- if (!NO_FREE) {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError());
- }
- }
- }
-
- protected void destroyImpl() throws GLException {
- if (hglrc != 0) {
- if (!WGL.wglDeleteContext(hglrc)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Destroyed OpenGL context " + hglrc);
- }
- hglrc = 0;
- }
- }
-
- public abstract void swapBuffers() throws GLException;
-
- protected long dynamicLookupFunction(String glFuncName) {
- long res = WGL.wglGetProcAddress(glFuncName);
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- if (hglu32 == 0) {
- hglu32 = WGL.LoadLibraryA("GLU32");
- if (hglu32 == 0) {
- throw new GLException("Error loading GLU32.DLL");
- }
- }
- res = WGL.GetProcAddress(hglu32, glFuncName);
- }
- return res;
- }
-
- public boolean isCreated() {
- return (hglrc != 0);
- }
-
- protected void resetGLFunctionAvailability() {
- super.resetGLFunctionAvailability();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table");
- }
- resetProcAddressTable(getGLProcAddressTable());
- }
-
- public GLProcAddressTable getGLProcAddressTable() {
- if (glProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by capability bits so we can
- // share them among contexts with the same capabilities
- glProcAddressTable = new GLProcAddressTable();
- }
- return glProcAddressTable;
- }
-
- public String getPlatformExtensionsString() {
- if (!wglGetExtensionsStringEXTInitialized) {
- wglGetExtensionsStringEXTAvailable = (WGL.wglGetProcAddress("wglGetExtensionsStringEXT") != 0);
- wglGetExtensionsStringEXTInitialized = true;
- }
- if (wglGetExtensionsStringEXTAvailable) {
- return gl.wglGetExtensionsStringEXT();
- } else {
- return "";
- }
- }
-
- protected boolean isFunctionAvailable(String glFunctionName)
- {
- boolean available = super.isFunctionAvailable(glFunctionName);
-
- // Sanity check for implementations that use proc addresses for run-time
- // linking: if the function IS available, then make sure there's a proc
- // address for it if it's an extension or not part of the OpenGL 1.1 core
- // (post GL 1.1 functions are run-time linked on windows).
- assert(!available ||
- (getGLProcAddressTable().getAddressFor(mapToRealGLFunctionName(glFunctionName)) != 0 ||
- FunctionAvailabilityCache.isPartOfGLCore("1.1", mapToRealGLFunctionName(glFunctionName)))
- );
-
- return available;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- protected JAWT getJAWT() {
- if (jawt == null) {
- JAWT j = new JAWT();
- j.version(JAWTFactory.JAWT_VERSION_1_4);
- if (!JAWTFactory.JAWT_GetAWT(j)) {
- throw new RuntimeException("Unable to initialize JAWT");
- }
- jawt = j;
- }
- return jawt;
- }
-
- // Helper routine for the overridden create() to call
- protected void choosePixelFormatAndCreateContext(boolean onscreen) {
- PIXELFORMATDESCRIPTOR pfd = null;
- int pixelFormat = 0;
- if (onscreen) {
- GLCapabilities[] availableCaps = null;
- int numFormats = 0;
- pfd = newPixelFormatDescriptor();
- GraphicsConfiguration config = component.getGraphicsConfiguration();
- GraphicsDevice device = config.getDevice();
- // Produce a recommended pixel format selection for the GLCapabilitiesChooser.
- // Use wglChoosePixelFormatARB if user requested multisampling and if we have it available
- GL dummyGL = null;
- if (capabilities.getSampleBuffers()) {
- dummyGL = WindowsGLContextFactory.getDummyGL(device);
- }
- int recommendedPixelFormat = -1;
- boolean haveWGLChoosePixelFormatARB = false;
- boolean haveWGLARBMultisample = false;
- if (dummyGL != null) {
- String availableWGLExtensions = WindowsGLContextFactory.getDummyGLExtensions(device);
- if (availableWGLExtensions.indexOf("WGL_ARB_pixel_format") >= 0) {
- haveWGLChoosePixelFormatARB = true;
- if (availableWGLExtensions.indexOf("WGL_ARB_multisample") >= 0) {
- haveWGLARBMultisample = true;
- }
- }
- }
- Rectangle rect = config.getBounds();
- long dc = 0;
- long rc = 0;
- boolean freeWGLC = false;
- if( dummyGL != null ) {
- dc = WindowsGLContextFactory.getDummyGLContext( device ).hdc;
- rc = WindowsGLContextFactory.getDummyGLContext( device ).hglrc;
- if( !WGL.wglMakeCurrent( dc, rc ) ) {
- System.err.println(getThreadName() + ": Error Making WGLC Current: " + WGL.GetLastError() );
- } else {
- freeWGLC = true;
- }
- }
- // Fallback path for older cards, in particular Intel Extreme motherboard graphics
- boolean gotAvailableCaps = false;
- if (dummyGL != null && haveWGLChoosePixelFormatARB) {
- int[] iattributes = new int [2 * MAX_ATTRIBS];
- int[] iresults = new int [2 * MAX_ATTRIBS];
- float[] fattributes = new float[2 * MAX_ATTRIBS];
- int niattribs = 0;
- int nfattribs = 0;
- iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
- iattributes[niattribs++] = GL.WGL_DRAW_TO_WINDOW_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
- iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = GL.WGL_TYPE_RGBA_ARB;
- iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB;
- if (capabilities.getDoubleBuffered()) {
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = GL.GL_FALSE;
- }
- iattributes[niattribs++] = GL.WGL_STEREO_ARB;
- if (capabilities.getStereo()) {
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = GL.GL_FALSE;
- }
- iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = capabilities.getDepthBits();
- iattributes[niattribs++] = GL.WGL_RED_BITS_ARB;
- iattributes[niattribs++] = capabilities.getRedBits();
- iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB;
- iattributes[niattribs++] = capabilities.getGreenBits();
- iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB;
- iattributes[niattribs++] = capabilities.getBlueBits();
- iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAlphaBits();
- iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = capabilities.getStencilBits();
- if (capabilities.getAccumRedBits() > 0 ||
- capabilities.getAccumGreenBits() > 0 ||
- capabilities.getAccumBlueBits() > 0 ||
- capabilities.getAccumAlphaBits() > 0) {
- iattributes[niattribs++] = GL.WGL_ACCUM_BITS_ARB;
- iattributes[niattribs++] = (capabilities.getAccumRedBits() +
- capabilities.getAccumGreenBits() +
- capabilities.getAccumBlueBits() +
- capabilities.getAccumAlphaBits());
- iattributes[niattribs++] = GL.WGL_ACCUM_RED_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAccumRedBits();
- iattributes[niattribs++] = GL.WGL_ACCUM_GREEN_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAccumGreenBits();
- iattributes[niattribs++] = GL.WGL_ACCUM_BLUE_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAccumBlueBits();
- iattributes[niattribs++] = GL.WGL_ACCUM_ALPHA_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAccumAlphaBits();
- }
- if (haveWGLARBMultisample) {
- if (capabilities.getSampleBuffers()) {
- iattributes[niattribs++] = GL.WGL_SAMPLE_BUFFERS_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
- iattributes[niattribs++] = GL.WGL_SAMPLES_ARB;
- iattributes[niattribs++] = capabilities.getNumSamples();
- }
- }
-
- int[] pformats = new int[MAX_PFORMATS];
- int[] numFormatsTmp = new int[1];
- if (dummyGL.wglChoosePixelFormatARB(hdc,
- iattributes,
- fattributes,
- MAX_PFORMATS,
- pformats,
- numFormatsTmp)) {
- numFormats = numFormatsTmp[0];
- if (numFormats > 0) {
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat = pformats[0] - 1;
- if (DEBUG) {
- System.err.println(getThreadName() + ": Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat);
- }
- }
- } else {
- if (DEBUG) {
- System.err.println(getThreadName() + ": wglChoosePixelFormatARB failed: " + WGL.GetLastError() );
- Thread.dumpStack();
- }
- }
- if (DEBUG) {
- if (recommendedPixelFormat < 0) {
- System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format");
- if (capabilities.getSampleBuffers()) {
- System.err.print(" for multisampled GLCapabilities");
- }
- System.err.println();
- }
- }
-
- // Produce a list of GLCapabilities to give to the
- // GLCapabilitiesChooser.
- // Use wglGetPixelFormatAttribivARB instead of
- // DescribePixelFormat to get higher-precision information
- // about the pixel format (should make the GLCapabilities
- // more precise as well...i.e., remove the
- // "HardwareAccelerated" bit, which is basically
- // meaningless, and put in whether it can render to a
- // window, to a pbuffer, or to a pixmap)
- niattribs = 0;
- iattributes[0] = GL.WGL_NUMBER_PIXEL_FORMATS_ARB;
- if (dummyGL.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, iresults)) {
- numFormats = iresults[0];
- // Should we be filtering out the pixel formats which aren't
- // applicable, as we are doing here?
- // We don't have enough information in the GLCapabilities to
- // represent those that aren't...
- iattributes[niattribs++] = GL.WGL_DRAW_TO_WINDOW_ARB;
- iattributes[niattribs++] = GL.WGL_ACCELERATION_ARB;
- iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB;
- iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB;
- iattributes[niattribs++] = GL.WGL_STEREO_ARB;
- iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = GL.WGL_RED_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_ACCUM_RED_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_ACCUM_GREEN_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_ACCUM_BLUE_BITS_ARB;
- iattributes[niattribs++] = GL.WGL_ACCUM_ALPHA_BITS_ARB;
- if (haveWGLARBMultisample) {
- iattributes[niattribs++] = GL.WGL_SAMPLE_BUFFERS_ARB;
- iattributes[niattribs++] = GL.WGL_SAMPLES_ARB;
- }
-
- availableCaps = new GLCapabilities[numFormats];
- for (int i = 0; i < numFormats; i++) {
- if (!dummyGL.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, iresults)) {
- throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context");
- }
- availableCaps[i] = iattributes2GLCapabilities(iattributes, iresults, niattribs, true);
- }
- if( freeWGLC ) {
- WGL.wglMakeCurrent( 0, 0 );
- }
- gotAvailableCaps = true;
- } else {
- int lastErr = WGL.GetLastError();
- // Intel Extreme graphics fails with a zero error code
- if (lastErr != 0) {
- throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
- }
- }
- }
-
- if (!gotAvailableCaps) {
- if (DEBUG) {
- if (!capabilities.getSampleBuffers()) {
- System.err.println(getThreadName() + ": Using ChoosePixelFormat because multisampling not requested");
- } else {
- System.err.println(getThreadName() + ": Using ChoosePixelFormat because no wglChoosePixelFormatARB: dummyGL = " + dummyGL);
- }
- }
- pfd = glCapabilities2PFD(capabilities, onscreen);
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat = WGL.ChoosePixelFormat(hdc, pfd) - 1;
-
- numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null);
- if (numFormats == 0) {
- throw new GLException("Unable to enumerate pixel formats of window for GLCapabilitiesChooser");
- }
- availableCaps = new GLCapabilities[numFormats];
- for (int i = 0; i < numFormats; i++) {
- if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
- throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
- }
- availableCaps[i] = pfd2GLCapabilities(pfd);
- }
- }
-
- // Supply information to chooser
- pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat);
- if ((pixelFormat < 0) || (pixelFormat >= numFormats)) {
- throw new GLException("Invalid result " + pixelFormat +
- " from GLCapabilitiesChooser (should be between 0 and " +
- (numFormats - 1) + ")");
- }
- if (DEBUG) {
- System.err.println(getThreadName() + ": Chosen pixel format (" + pixelFormat + "):");
- System.err.println(availableCaps[pixelFormat]);
- }
- pixelFormat += 1; // one-base the index
- if (WGL.DescribePixelFormat(hdc, pixelFormat, pfd.size(), pfd) == 0) {
- throw new GLException("Error re-describing the chosen pixel format: " + WGL.GetLastError());
- }
- } else {
- // For now, use ChoosePixelFormat for offscreen surfaces until
- // we figure out how to properly choose an offscreen-
- // compatible pixel format
- pfd = glCapabilities2PFD(capabilities, onscreen);
- pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
- }
- if (!WGL.SetPixelFormat(hdc, pixelFormat, pfd)) {
- int lastError = WGL.GetLastError();
- if (DEBUG) {
- System.err.println(getThreadName() + ": SetPixelFormat failed: current context = " + WGL.wglGetCurrentContext() +
- ", current DC = " + WGL.wglGetCurrentDC());
- System.err.println(getThreadName() + ": GetPixelFormat(hdc " + hdcToString(hdc) + ") returns " + WGL.GetPixelFormat(hdc));
- }
- throw new GLException("Unable to set pixel format " + pixelFormat + " for device context " + hdcToString(hdc) + ": error code " + lastError);
- }
- hglrc = WGL.wglCreateContext(hdc);
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created OpenGL context " + hglrc + " for device context " + hdcToString(hdc) + " using pixel format " + pixelFormat);
- }
- if (hglrc == 0) {
- throw new GLException("Unable to create OpenGL context");
- }
- }
-
- protected long getHGLRC() {
- return hglrc;
- }
-
- static PIXELFORMATDESCRIPTOR glCapabilities2PFD(GLCapabilities caps, boolean onscreen) {
- int colorDepth = (caps.getRedBits() +
- caps.getGreenBits() +
- caps.getBlueBits());
- if (colorDepth < 15) {
- throw new GLException("Bit depths < 15 (i.e., non-true-color) not supported");
- }
- PIXELFORMATDESCRIPTOR pfd = newPixelFormatDescriptor();
- int pfdFlags = (WGL.PFD_SUPPORT_OPENGL |
- WGL.PFD_GENERIC_ACCELERATED);
- if (caps.getDoubleBuffered()) {
- pfdFlags |= WGL.PFD_DOUBLEBUFFER;
- }
- if (onscreen) {
- pfdFlags |= WGL.PFD_DRAW_TO_WINDOW;
- } else {
- pfdFlags |= WGL.PFD_DRAW_TO_BITMAP;
- }
- pfd.dwFlags(pfdFlags);
- pfd.iPixelType((byte) WGL.PFD_TYPE_RGBA);
- pfd.cColorBits((byte) colorDepth);
- pfd.cRedBits ((byte) caps.getRedBits());
- pfd.cGreenBits((byte) caps.getGreenBits());
- pfd.cBlueBits ((byte) caps.getBlueBits());
- pfd.cAlphaBits((byte) caps.getAlphaBits());
- int accumDepth = (caps.getAccumRedBits() +
- caps.getAccumGreenBits() +
- caps.getAccumBlueBits());
- pfd.cAccumBits ((byte) accumDepth);
- pfd.cAccumRedBits ((byte) caps.getAccumRedBits());
- pfd.cAccumGreenBits((byte) caps.getAccumGreenBits());
- pfd.cAccumBlueBits ((byte) caps.getAccumBlueBits());
- pfd.cAccumAlphaBits((byte) caps.getAccumAlphaBits());
- pfd.cDepthBits((byte) caps.getDepthBits());
- pfd.cStencilBits((byte) caps.getStencilBits());
- pfd.iLayerType((byte) WGL.PFD_MAIN_PLANE);
- return pfd;
- }
-
- static PIXELFORMATDESCRIPTOR newPixelFormatDescriptor() {
- PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR();
- pfd.nSize((short) pfd.size());
- pfd.nVersion((short) 1);
- return pfd;
- }
-
- static GLCapabilities pfd2GLCapabilities(PIXELFORMATDESCRIPTOR pfd) {
- if ((pfd.dwFlags() & WGL.PFD_SUPPORT_OPENGL) == 0) {
- return null;
- }
- GLCapabilities res = new GLCapabilities();
- res.setRedBits (pfd.cRedBits());
- res.setGreenBits (pfd.cGreenBits());
- res.setBlueBits (pfd.cBlueBits());
- res.setAlphaBits (pfd.cAlphaBits());
- res.setAccumRedBits (pfd.cAccumRedBits());
- res.setAccumGreenBits(pfd.cAccumGreenBits());
- res.setAccumBlueBits (pfd.cAccumBlueBits());
- res.setAccumAlphaBits(pfd.cAccumAlphaBits());
- res.setDepthBits (pfd.cDepthBits());
- res.setStencilBits (pfd.cStencilBits());
- res.setDoubleBuffered((pfd.dwFlags() & WGL.PFD_DOUBLEBUFFER) != 0);
- res.setStereo ((pfd.dwFlags() & WGL.PFD_STEREO) != 0);
- res.setHardwareAccelerated(((pfd.dwFlags() & WGL.PFD_GENERIC_FORMAT) == 0) ||
- ((pfd.dwFlags() & WGL.PFD_GENERIC_ACCELERATED) != 0));
- return res;
- }
-
- static GLCapabilities iattributes2GLCapabilities(int[] iattribs,
- int[] iresults,
- int niattribs,
- boolean requireRenderToWindow) {
- GLCapabilities res = new GLCapabilities();
- for (int i = 0; i < niattribs; i++) {
- switch (iattribs[i]) {
- case GL.WGL_DRAW_TO_WINDOW_ARB:
- if (iresults[i] != GL.GL_TRUE)
- return null;
- break;
-
- case GL.WGL_ACCELERATION_ARB:
- res.setHardwareAccelerated(iresults[i] == GL.WGL_FULL_ACCELERATION_ARB);
- break;
-
- case GL.WGL_SUPPORT_OPENGL_ARB:
- if (iresults[i] != GL.GL_TRUE)
- return null;
- break;
-
- case GL.WGL_DEPTH_BITS_ARB:
- res.setDepthBits(iresults[i]);
- break;
-
- case GL.WGL_STENCIL_BITS_ARB:
- res.setStencilBits(iresults[i]);
- break;
-
- case GL.WGL_DOUBLE_BUFFER_ARB:
- res.setDoubleBuffered(iresults[i] == GL.GL_TRUE);
- break;
-
- case GL.WGL_STEREO_ARB:
- res.setStereo(iresults[i] == GL.GL_TRUE);
- break;
-
- case GL.WGL_PIXEL_TYPE_ARB:
- if (iresults[i] != GL.WGL_TYPE_RGBA_ARB)
- return null;
- break;
-
- case GL.WGL_RED_BITS_ARB:
- res.setRedBits(iresults[i]);
- break;
-
- case GL.WGL_GREEN_BITS_ARB:
- res.setGreenBits(iresults[i]);
- break;
-
- case GL.WGL_BLUE_BITS_ARB:
- res.setBlueBits(iresults[i]);
- break;
-
- case GL.WGL_ALPHA_BITS_ARB:
- res.setAlphaBits(iresults[i]);
- break;
-
- case GL.WGL_ACCUM_RED_BITS_ARB:
- res.setAccumRedBits(iresults[i]);
- break;
-
- case GL.WGL_ACCUM_GREEN_BITS_ARB:
- res.setAccumGreenBits(iresults[i]);
- break;
-
- case GL.WGL_ACCUM_BLUE_BITS_ARB:
- res.setAccumBlueBits(iresults[i]);
- break;
-
- case GL.WGL_ACCUM_ALPHA_BITS_ARB:
- res.setAccumAlphaBits(iresults[i]);
- break;
-
- case GL.WGL_SAMPLE_BUFFERS_ARB:
- res.setSampleBuffers(iresults[i] == GL.GL_TRUE);
- break;
-
- case GL.WGL_SAMPLES_ARB:
- res.setNumSamples(iresults[i]);
- break;
-
- default:
- throw new GLException("Unknown pixel format attribute " + iattribs[i]);
- }
- }
- return res;
- }
-
- protected static String hdcToString(long hdc) {
- return "0x" + Long.toHexString(hdc);
- }
-
- protected boolean haveWGLARBPbuffer() {
- return haveWGLARBPbuffer;
- }
-}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
deleted file mode 100644
index dd6f8daca..000000000
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.windows;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.Rectangle;
-import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
-import java.util.Iterator;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class WindowsGLContextFactory extends GLContextFactory {
- private static final boolean DEBUG = Debug.debug("WindowsGLContextFactory");
- private static final boolean VERBOSE = Debug.verbose();
-
- // On Windows we want to be able to use some extension routines like
- // wglChoosePixelFormatARB during the creation of the user's first
- // GLContext. However, this and other routines' function pointers
- // aren't loaded by the driver until the first OpenGL context is
- // created. The standard way of working around this chicken-and-egg
- // problem is to create a dummy window, show it, send it a paint
- // message, create an OpenGL context, fetch the needed function
- // pointers, and then destroy the dummy window and context. It turns
- // out that ATI cards need the dummy context to be current while
- // wglChoosePixelFormatARB is called, so we cache the extension
- // strings the dummy context reports as being available.
- private static Map/*<GraphicsDevice, GL>*/ dummyContextMap = new HashMap();
- private static Map/*<GraphicsDevice, String>*/ dummyExtensionsMap = new HashMap();
- private static Set/*<GraphicsDevice >*/ pendingContextSet = new HashSet();
-
- public WindowsGLContextFactory() {
- AccessController.doPrivileged( new PrivilegedAction() {
- public Object run() {
- Runtime.getRuntime().addShutdownHook( new ShutdownHook() );
-
- // Test for whether we should enable the single-threaded
- // workaround for ATI cards. It appears that if we make any
- // OpenGL context current on more than one thread on ATI cards
- // on Windows then we see random failures like the inability
- // to create more OpenGL contexts, or having just the next
- // OpenGL SetPixelFormat operation fail with a GetNextError()
- // code of 0 (but subsequent ones on subsequently-created
- // windows succeed). These kinds of failures are obviously due
- // to bugs in ATI's OpenGL drivers. Through trial and error it
- // was found that specifying
- // -DJOGL_SINGLE_THREADED_WORKAROUND=true on the command line
- // caused these problems to completely disappear. Therefore at
- // least on Windows we try to enable the single-threaded
- // workaround before creating any OpenGL contexts. In the
- // future, if problems are encountered on other platforms and
- // -DJOGL_SINGLE_THREADED_WORKAROUND=true works around them,
- // we may want to implement a workaround like this on other
- // platforms.
-
- // The algorithm here is to try to find the system directory
- // (assuming it is on the same drive as TMPDIR, exposed
- // through the system property java.io.tmpdir) and see whether
- // a known file in the ATI drivers is present; if it is, we
- // enable the single-threaded workaround.
-
- // If any path down this code fails, we simply bail out -- we
- // don't go to great lengths to figure out if the ATI drivers
- // are present. We could add more checks here in the future if
- // these appear to be insufficient.
-
- String tmpDirProp = System.getProperty("java.io.tmpdir");
- if (tmpDirProp != null) {
- File file = new File(tmpDirProp);
- if (file.isAbsolute()) {
- File parent = null;
- do {
- parent = file.getParentFile();
- if (parent != null) {
- file = parent;
- }
- } while (parent != null);
- // Now the file contains just the drive letter
- file = new File(new File(new File(file, "windows"), "system32"), "atioglxx.dll");
- if (file.exists()) {
- SingleThreadedWorkaround.shouldDoWorkaround();
- }
- }
- }
-
- return( null );
- }
- });
- }
-
- public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GraphicsDevice device) {
- return null;
- }
-
- public GLContext createGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- if (component != null) {
- return new WindowsOnscreenGLContext(component, capabilities, chooser, shareWith);
- } else {
- return new WindowsOffscreenGLContext(capabilities, chooser, shareWith);
- }
- }
-
- // Return cached GL context
- public static WindowsGLContext getDummyGLContext( final GraphicsDevice device ) {
- checkForDummyContext( device );
- NativeWindowStruct nws = (NativeWindowStruct) dummyContextMap.get(device);
- return nws.getWindowsContext();
- }
-
- // Return cached extension string
- public static String getDummyGLExtensions(final GraphicsDevice device) {
- checkForDummyContext( device );
- String exts = (String) dummyExtensionsMap.get(device);
- return (exts == null) ? "" : exts;
- }
-
- // Return cached GL function pointers
- public static GL getDummyGL(final GraphicsDevice device) {
- checkForDummyContext( device );
- NativeWindowStruct nws = (NativeWindowStruct) dummyContextMap.get(device);
- return( nws.getWindowsContext().getGL() );
- }
-
- /*
- * Locate a cached native window, if one doesn't exist create one amd
- * cache it.
- */
- private static void checkForDummyContext( final GraphicsDevice device ) {
- if (!pendingContextSet.contains(device) && !dummyContextMap.containsKey( device ) ) {
- if (DEBUG) {
- System.err.println("WindowsGLContextFactory.checkForDummyContext() called on thread " +
- Thread.currentThread().getName());
- }
-
- pendingContextSet.add(device);
- GraphicsConfiguration config = device.getDefaultConfiguration();
- Rectangle rect = config.getBounds();
- GLCapabilities caps = new GLCapabilities();
- caps.setDepthBits( 16 );
- // Create a context that we use to query pixel formats
- WindowsOnscreenGLContext context = new WindowsOnscreenGLContext( null, caps, null, null );
- // Start a native thread and grab native screen resources from the thread
- NativeWindowThread nwt = new NativeWindowThread( rect );
- nwt.start();
- long hWnd = 0;
- long tempHDC = 0;
- while( (hWnd = nwt.getHWND()) == 0 || (tempHDC = nwt.getHDC()) == 0 ) {
- Thread.yield();
- }
- // Choose a hardware accelerated pixel format
- PIXELFORMATDESCRIPTOR pfd = context.glCapabilities2PFD( caps, true );
- int pixelFormat = WGL.ChoosePixelFormat( tempHDC, pfd );
- if( pixelFormat == 0 ) {
- System.err.println("Pixel Format is Zero");
- pendingContextSet.remove(device);
- return;
- }
- // Set the hardware accelerated pixel format
- if (!WGL.SetPixelFormat(tempHDC, pixelFormat, pfd)) {
- System.err.println("SetPixelFormat Failed");
- pendingContextSet.remove( device );
- return;
- }
- // Create a rendering context
- long tempHGLRC = WGL.wglCreateContext( tempHDC );
- if( hWnd == 0 || tempHDC == 0 || tempHGLRC == 0 ) {
- pendingContextSet.remove( device );
- return;
- }
- // Store native handles for later use
- NativeWindowStruct nws = new NativeWindowStruct();
- nws.setHWND( hWnd );
- nws.setWindowsContext( context );
- nws.setWindowThread( nwt );
- long currentHDC = WGL.wglGetCurrentDC();
- long currentHGLRC = WGL.wglGetCurrentContext();
- // Make the new hardware accelerated context current
- if( !WGL.wglMakeCurrent( tempHDC, tempHGLRC ) ) {
- pendingContextSet.remove( device );
- return;
- }
- // Grab function pointers
- context.hdc = tempHDC;
- context.hglrc = tempHGLRC;
- context.resetGLFunctionAvailability();
- context.createGL();
- pendingContextSet.remove( device );
- dummyContextMap.put( device, nws );
- String availableGLExtensions = "";
- String availableWGLExtensions = "";
- String availableEXTExtensions = "";
- try {
- availableWGLExtensions = context.getGL().wglGetExtensionsStringARB( currentHDC );
- } catch( GLException e ) {
- }
- try {
- availableEXTExtensions = context.getGL().wglGetExtensionsStringEXT();
- } catch( GLException e ) {
- }
- availableGLExtensions = context.getGL().glGetString( GL.GL_EXTENSIONS );
- dummyExtensionsMap.put(device, availableGLExtensions + " " + availableEXTExtensions + " " + availableWGLExtensions);
- WGL.wglMakeCurrent( currentHDC, currentHGLRC );
- }
- }
-
- /*
- * This class stores handles to native resources that need to be destroyed
- * at JVM shutdown.
- */
- static class NativeWindowStruct {
- private long HWND;
- private WindowsGLContext windowsContext;
- private Thread windowThread;
-
- public NativeWindowStruct() {
- }
-
- public long getHDC() {
- return( windowsContext.hdc );
- }
-
- public long getHGLRC() {
- return( windowsContext.hglrc );
- }
-
- public void setHWND( long hwnd ) {
- HWND = hwnd;
- }
-
- public long getHWND() {
- return( HWND );
- }
-
- public void setWindowsContext( WindowsGLContext context ) {
- windowsContext = context;
- }
-
- public WindowsGLContext getWindowsContext() {
- return( windowsContext );
- }
-
- public void setWindowThread( Thread thread ) {
- windowThread = thread;
- }
-
- public Thread getWindowThread() {
- return( windowThread );
- }
- }
-
- /*
- * Native HWDN and HDC handles must be created and destroyed on the same
- * thread.
- */
-
- static class NativeWindowThread extends Thread {
- private long HWND = 0;
- private long HDC = 0;
- private Rectangle rectangle;
-
- public NativeWindowThread( Rectangle rect ) {
- rectangle = rect;
- }
-
- public synchronized long getHWND() {
- return( HWND );
- }
-
- public synchronized long getHDC() {
- return( HDC );
- }
-
- public void run() {
- // Create a native window and device context
- synchronized (WindowsGLContextFactory.class) {
- HWND = WGL.CreateDummyWindow( rectangle.x, rectangle.y, rectangle.width, rectangle.height );
- }
- HDC = WGL.GetDC( HWND );
-
- // Start the message pump at shutdown
- WGL.NativeEventLoop();
- }
- }
-
- /*
- * This class is registered with the JVM to destroy all cached redering
- * contexts, device contexts, and window handles.
- */
-
- class ShutdownHook extends Thread {
- public void run() {
- // Collect all saved screen resources
- Collection c = dummyContextMap.values();
- Iterator iter = c.iterator();
- while( iter.hasNext() ) {
- // NativeWindowStruct holds refs to native resources that need to be destroyed
- NativeWindowStruct struct = (NativeWindowStruct)iter.next();
- // Restart native window threads to respond to window closing events
- synchronized( struct.getWindowThread() ) {
- struct.getWindowThread().notifyAll();
- }
- // Destroy OpenGL rendering context
- if( !WGL.wglDeleteContext( struct.getHGLRC() ) ) {
- System.err.println( "Error Destroying NativeWindowStruct RC: " + WGL.GetLastError() );
- }
- // Send context handles to native method for deletion
- WGL.DestroyDummyWindow( struct.getHWND(), struct.getHDC() );
- }
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
deleted file mode 100644
index c70607da7..000000000
--- a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.windows;
-
-import java.awt.image.BufferedImage;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class WindowsOffscreenGLContext extends WindowsGLContext {
- private long origbitmap;
- private long hbitmap;
- // Width and height of the underlying bitmap
- private int width;
- private int height;
-
- public WindowsOffscreenGLContext(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(null, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new WindowsGLImpl(this);
- }
-
- protected boolean isOffscreen() {
- return true;
- }
-
- public int getOffscreenContextWidth() {
- return width;
- }
-
- public int getOffscreenContextHeight() {
- return height;
- }
-
- public int getOffscreenContextPixelDataType() {
- return GL.GL_UNSIGNED_BYTE;
- }
-
- public int getOffscreenContextReadBuffer() {
- // On Windows these contexts are always single-buffered
- return GL.GL_FRONT;
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- // We can take care of this in the DIB creation (see below)
- return false;
- }
-
- public boolean canCreatePbufferContext() {
- // For now say no
- return false;
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- if (pendingOffscreenResize) {
- if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
- if (hglrc != 0) {
- destroyImpl();
- }
- width = pendingOffscreenWidth;
- height = pendingOffscreenHeight;
- pendingOffscreenResize = false;
- }
- }
- return super.makeCurrent(initAction);
- }
-
- protected void destroyImpl() {
- if (hglrc != 0) {
- super.destroyImpl();
- // Must destroy OpenGL context, bitmap and device context
- WGL.SelectObject(hdc, origbitmap);
- WGL.DeleteObject(hbitmap);
- WGL.DeleteDC(hdc);
- origbitmap = 0;
- hbitmap = 0;
- hdc = 0;
- }
- }
-
- public synchronized void swapBuffers() throws GLException {
- }
-
- protected void create() {
- BITMAPINFO info = new BITMAPINFO();
- BITMAPINFOHEADER header = info.bmiHeader();
- int bitsPerPixel = (capabilities.getRedBits() +
- capabilities.getGreenBits() +
- capabilities.getBlueBits());
- header.biSize(header.size());
- header.biWidth(width);
- // NOTE: negating the height causes the DIB to be in top-down row
- // order rather than bottom-up; ends up being correct during pixel
- // readback
- header.biHeight(-1 * height);
- header.biPlanes((short) 1);
- header.biBitCount((short) bitsPerPixel);
- header.biXPelsPerMeter(0);
- header.biYPelsPerMeter(0);
- header.biClrUsed(0);
- header.biClrImportant(0);
- header.biCompression(WGL.BI_RGB);
- header.biSizeImage(width * height * bitsPerPixel / 8);
-
- hdc = WGL.CreateCompatibleDC(0);
- if (hdc == 0) {
- System.out.println("LastError: " + WGL.GetLastError());
- throw new GLException("Error creating device context for offscreen OpenGL context");
- }
- hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, 0, 0, 0);
- if (hbitmap == 0) {
- throw new GLException("Error creating offscreen bitmap of width " + width +
- ", height " + height);
- }
- if ((origbitmap = WGL.SelectObject(hdc, hbitmap)) == 0) {
- throw new GLException("Error selecting bitmap into new device context");
- }
-
- choosePixelFormatAndCreateContext(false);
- }
-}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
deleted file mode 100644
index 0dc1818fb..000000000
--- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.windows;
-
-import java.awt.Component;
-import java.util.*;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class WindowsOnscreenGLContext extends WindowsGLContext {
- // Variables for lockSurface/unlockSurface
- JAWT_DrawingSurface ds;
- JAWT_DrawingSurfaceInfo dsi;
- JAWT_Win32DrawingSurfaceInfo win32dsi;
-
- // Variables for pbuffer support
- List pbuffersToInstantiate = new ArrayList();
-
- public WindowsOnscreenGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(component, capabilities, chooser, shareWith);
- }
-
- public void invokeGL(Runnable runnable, boolean isReshape, Runnable initAction) throws GLException {
- // Unfortunately, invokeGL can be called with the AWT tree lock
- // held, and the Windows onscreen implementation of
- // choosePixelFormatAndCreateContext calls
- // Component.getGraphicsConfiguration(), which grabs the tree
- // lock. To avoid deadlock we have to lock the tree lock before
- // grabbing the GLContext's lock if we're going to create an
- // OpenGL context during this call. This code might not be
- // completely correct, and we might need to uniformly grab the AWT
- // tree lock, which might become a performance issue...
- if (hglrc == 0) {
- synchronized(component.getTreeLock()) {
- super.invokeGL(runnable, isReshape, initAction);
- }
- } else {
- super.invokeGL(runnable, isReshape, initAction);
- }
- }
-
- protected GL createGL()
- {
- return new WindowsGLImpl(this);
- }
-
- protected boolean isOffscreen() {
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- public boolean canCreatePbufferContext() {
- return haveWGLARBPbuffer();
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- WindowsPbufferGLContext ctx = new WindowsPbufferGLContext(capabilities, initialWidth, initialHeight);
- pbuffersToInstantiate.add(ctx);
- return ctx;
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- try {
- if (!lockSurface()) {
- return false;
- }
- boolean ret = super.makeCurrent(initAction);
- if (ret) {
- // Instantiate any pending pbuffers
- while (!pbuffersToInstantiate.isEmpty()) {
- WindowsPbufferGLContext ctx =
- (WindowsPbufferGLContext) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1);
- ctx.createPbuffer(hdc, hglrc);
- }
- }
- return ret;
- } catch (RuntimeException e) {
- try {
- unlockSurface();
- } catch (Exception e2) {
- // do nothing if unlockSurface throws
- }
- throw(e);
- }
- }
-
- protected synchronized void free() throws GLException {
- try {
- super.free();
- } finally {
- unlockSurface();
- }
- }
-
- public synchronized void swapBuffers() throws GLException {
- if (!WGL.SwapBuffers(hdc) && (WGL.GetLastError() != 0)) {
- throw new GLException("Error swapping buffers");
- }
- }
-
- private boolean lockSurface() throws GLException {
- if (hdc != 0) {
- throw new GLException("Surface already locked");
- }
- ds = getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return false;
- }
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
- // See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated (NOTE: removeNotify
- // should handle this case, but it may be possible that race
- // conditions can cause this code to be triggered -- should test
- // more)
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- if (hglrc != 0) {
- if (!WGL.wglDeleteContext(hglrc)) {
- throw new GLException("Unable to delete old GL context after surface changed");
- }
- GLContextShareSet.contextDestroyed(this);
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Destroyed OpenGL context " + hglrc + " due to JAWT_LOCK_SURFACE_CHANGED");
- }
- hglrc = 0;
- }
- }
- dsi = ds.GetDrawingSurfaceInfo();
- if (dsi == null) {
- // Widget not yet realized
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- return false;
- }
- win32dsi = (JAWT_Win32DrawingSurfaceInfo) dsi.platformInfo();
- hdc = win32dsi.hdc();
- if (hdc == 0) {
- // Widget not yet realized
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- win32dsi = null;
- return false;
- }
- return true;
- }
-
- private void unlockSurface() {
- if (hdc == 0) {
- throw new GLException("Surface already unlocked");
- }
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- win32dsi = null;
- hdc = 0;
- }
-
- protected void create() {
- choosePixelFormatAndCreateContext(true);
- }
-}
diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
deleted file mode 100644
index 1d5d78296..000000000
--- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.windows;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class WindowsPbufferGLContext extends WindowsGLContext {
- private static final boolean DEBUG = Debug.debug("WindowsPbufferGLContext");
-
- private int initWidth;
- private int initHeight;
-
- private long buffer; // pbuffer handle
- private int width;
- private int height;
-
- // FIXME: kept around because we create the OpenGL context lazily to
- // better integrate with the WindowsGLContext framework
- private long parentHglrc;
-
- private static final int MAX_PFORMATS = 256;
- private static final int MAX_ATTRIBS = 256;
-
- // State for render-to-texture and render-to-texture-rectangle support
- private boolean created;
- private boolean rtt; // render-to-texture?
- private boolean hasRTT; // render-to-texture extension available?
- private boolean rect; // render-to-texture-rectangle?
- private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
- private int texture; // actual texture object
- private int floatMode;
-
- public WindowsPbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- super(null, capabilities, null, null);
- this.initWidth = initialWidth;
- this.initHeight = initialHeight;
- if (initWidth <= 0 || initHeight <= 0) {
- throw new GLException("Initial width and height of pbuffer must be positive (were (" +
- initWidth + ", " + initHeight + "))");
- }
-
- if (DEBUG) {
- System.out.println("Pbuffer caps on init: " + capabilities +
- (capabilities.getOffscreenRenderToTexture() ? " [rtt]" : "") +
- (capabilities.getOffscreenRenderToTextureRectangle() ? " [rect]" : "") +
- (capabilities.getOffscreenFloatingPointBuffers() ? " [float]" : ""));
- }
- }
-
- public boolean canCreatePbufferContext() {
- return false;
- }
-
- public GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindPbufferToTexture() {
- if (!rtt) {
- throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
- "specified in its GLCapabilities");
- }
- GL gl = getGL();
- gl.glBindTexture(textureTarget, texture);
- if (rtt && hasRTT) {
- if (!gl.wglBindTexImageARB(buffer, GL.WGL_FRONT_LEFT_ARB)) {
- throw new GLException("Binding of pbuffer to texture failed: " + wglGetLastError());
- }
- }
- // Note that if the render-to-texture extension is not supported,
- // we perform a glCopyTexImage2D in swapBuffers().
- }
-
- public void releasePbufferFromTexture() {
- if (!rtt) {
- throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
- "specified in its GLCapabilities");
- }
- if (rtt && hasRTT) {
- GL gl = getGL();
- if (!gl.wglReleaseTexImageARB(buffer, GL.WGL_FRONT_LEFT_ARB)) {
- throw new GLException("Releasing of pbuffer from texture failed: " + wglGetLastError());
- }
- }
- }
-
- public void createPbuffer(long parentHdc, long parentHglrc) {
- GL gl = getGL();
- // Must initally grab OpenGL function pointers while parent's
- // context is current because otherwise we don't have the wgl
- // extensions available to us
- resetGLFunctionAvailability();
-
- int[] iattributes = new int [2*MAX_ATTRIBS];
- float[] fattributes = new float[2*MAX_ATTRIBS];
- int nfattribs = 0;
- int niattribs = 0;
-
- if (DEBUG) {
- System.out.println("Pbuffer caps: " + capabilities +
- (capabilities.getOffscreenRenderToTexture() ? " [rtt]" : "") +
- (capabilities.getOffscreenRenderToTextureRectangle() ? " [rect]" : "") +
- (capabilities.getOffscreenFloatingPointBuffers() ? " [float]" : ""));
- }
-
- rtt = capabilities.getOffscreenRenderToTexture();
- rect = capabilities.getOffscreenRenderToTextureRectangle();
- boolean useFloat = capabilities.getOffscreenFloatingPointBuffers();
- boolean ati = false;
-
- // Since we are trying to create a pbuffer, the pixel format we
- // request (and subsequently use) must be "p-buffer capable".
- iattributes[niattribs++] = GL.WGL_DRAW_TO_PBUFFER_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
-
- if (rtt && !rect) {
- throw new GLException("Render-to-texture-rectangle requires render-to-texture to be specified");
- }
-
- if (rect) {
- if (!gl.isExtensionAvailable("GL_NV_texture_rectangle")) {
- throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension");
- }
- }
-
- if (useFloat) {
- if (!gl.isExtensionAvailable("WGL_ATI_pixel_format_float") &&
- !gl.isExtensionAvailable("WGL_NV_float_buffer")) {
- throw new GLException("Floating-point pbuffers not supported by this hardware");
- }
-
- // Prefer NVidia extension over ATI
- if (gl.isExtensionAvailable("WGL_NV_float_buffer")) {
- ati = false;
- floatMode = GLPbuffer.NV_FLOAT;
- } else {
- ati = true;
- floatMode = GLPbuffer.ATI_FLOAT;
- }
- if (DEBUG) {
- System.err.println("Using " + (ati ? "ATI" : "NVidia") + " floating-point extension");
- }
- }
-
- if (useFloat && ati) {
- if (rtt) {
- throw new GLException("Render-to-floating-point-texture not supported on ATI hardware");
- } else {
- iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = GL.WGL_TYPE_RGBA_FLOAT_ATI;
- }
- } else {
- if (!rtt) {
- // Currently we don't support non-truecolor visuals in the
- // GLCapabilities, so we don't offer the option of making
- // color-index pbuffers.
- iattributes[niattribs++] = GL.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = GL.WGL_TYPE_RGBA_ARB;
- }
- }
-
- iattributes[niattribs++] = GL.WGL_DOUBLE_BUFFER_ARB;
- if (capabilities.getDoubleBuffered()) {
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = GL.GL_FALSE;
- }
-
- iattributes[niattribs++] = GL.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = capabilities.getDepthBits();
-
- iattributes[niattribs++] = GL.WGL_RED_BITS_ARB;
- iattributes[niattribs++] = capabilities.getRedBits();
-
- iattributes[niattribs++] = GL.WGL_GREEN_BITS_ARB;
- iattributes[niattribs++] = capabilities.getGreenBits();
-
- iattributes[niattribs++] = GL.WGL_BLUE_BITS_ARB;
- iattributes[niattribs++] = capabilities.getBlueBits();
-
- iattributes[niattribs++] = GL.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = capabilities.getAlphaBits();
-
- iattributes[niattribs++] = GL.WGL_STENCIL_BITS_ARB;
- if (capabilities.getStencilBits() > 0) {
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = GL.GL_FALSE;
- }
-
- if (capabilities.getAccumRedBits() > 0 ||
- capabilities.getAccumGreenBits() > 0 ||
- capabilities.getAccumBlueBits() > 0) {
- iattributes[niattribs++] = GL.WGL_ACCUM_BITS_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
- }
-
- if (useFloat && !ati) {
- iattributes[niattribs++] = GL.WGL_FLOAT_COMPONENTS_NV;
- iattributes[niattribs++] = GL.GL_TRUE;
- }
-
- if (rtt) {
- if (useFloat) {
- assert(!ati);
- if (!rect) {
- throw new GLException("Render-to-floating-point-texture only supported on NVidia hardware with render-to-texture-rectangle");
- }
- iattributes[niattribs++] = GL.WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV;
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = rect ? GL.WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV : GL.WGL_BIND_TO_TEXTURE_RGB_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
- }
- }
-
- iattributes[niattribs++] = GL.WGL_SUPPORT_OPENGL_ARB;
- iattributes[niattribs++] = GL.GL_TRUE;
-
- int[] pformats = new int[MAX_PFORMATS];
- int nformats;
- int[] nformatsTmp = new int[1];
- if (!gl.wglChoosePixelFormatARB(parentHdc,
- iattributes,
- fattributes,
- MAX_PFORMATS,
- pformats,
- nformatsTmp)) {
- throw new GLException("pbuffer creation error: wglChoosePixelFormatARB() failed");
- }
- nformats = nformatsTmp[0];
- if (nformats <= 0) {
- throw new GLException("pbuffer creation error: Couldn't find a suitable pixel format");
- }
-
- if (DEBUG) {
- System.err.println("" + nformats + " suitable pixel formats found");
- // query pixel format
- iattributes[0] = GL.WGL_RED_BITS_ARB;
- iattributes[1] = GL.WGL_GREEN_BITS_ARB;
- iattributes[2] = GL.WGL_BLUE_BITS_ARB;
- iattributes[3] = GL.WGL_ALPHA_BITS_ARB;
- iattributes[4] = GL.WGL_DEPTH_BITS_ARB;
- iattributes[5] = (useFloat ? (ati ? GL.WGL_PIXEL_TYPE_ARB : GL.WGL_FLOAT_COMPONENTS_NV) : GL.WGL_RED_BITS_ARB);
- iattributes[6] = GL.WGL_SAMPLE_BUFFERS_EXT;
- iattributes[7] = GL.WGL_SAMPLES_EXT;
- iattributes[8] = GL.WGL_DRAW_TO_PBUFFER_ARB;
- int[] ivalues = new int[9];
- for (int i = 0; i < nformats; i++) {
- if (!gl.wglGetPixelFormatAttribivARB(parentHdc, pformats[i], 0, 9, iattributes, ivalues)) {
- throw new GLException("Error while querying pixel format " + pformats[i] +
- "'s (index " + i + "'s) capabilities for debugging");
- }
- System.err.print("pixel format " + pformats[i] + " (index " + i + "): ");
- System.err.print( "r: " + ivalues[0]);
- System.err.print(" g: " + ivalues[1]);
- System.err.print(" b: " + ivalues[2]);
- System.err.print(" a: " + ivalues[3]);
- System.err.print(" depth: " + ivalues[4]);
- System.err.print(" multisample: " + ivalues[6]);
- System.err.print(" samples: " + ivalues[7]);
- if (useFloat) {
- if (ati) {
- if (ivalues[5] == GL.WGL_TYPE_RGBA_FLOAT_ATI) {
- System.err.print(" [ati float]");
- } else if (ivalues[5] != GL.WGL_TYPE_RGBA_ARB) {
- System.err.print(" [unknown pixel type " + ivalues[5] + "]");
- }
- } else {
- if (ivalues[5] != 0) {
- System.err.print(" [float]");
- }
- }
- }
-
- if (ivalues[8] != 0) {
- System.err.print(" [pbuffer]");
- }
- System.err.println();
- }
- }
-
- long tmpBuffer = 0;
- int whichFormat = 0;
- // Loop is a workaround for bugs in NVidia's recent drivers
- do {
- int format = pformats[whichFormat];
-
- // Create the p-buffer.
- niattribs = 0;
-
- if (rtt) {
- iattributes[niattribs++] = GL.WGL_TEXTURE_FORMAT_ARB;
- if (useFloat) {
- iattributes[niattribs++] = GL.WGL_TEXTURE_FLOAT_RGB_NV;
- } else {
- iattributes[niattribs++] = GL.WGL_TEXTURE_RGBA_ARB;
- }
-
- iattributes[niattribs++] = GL.WGL_TEXTURE_TARGET_ARB;
- iattributes[niattribs++] = rect ? GL.WGL_TEXTURE_RECTANGLE_NV : GL.WGL_TEXTURE_2D_ARB;
-
- iattributes[niattribs++] = GL.WGL_MIPMAP_TEXTURE_ARB;
- iattributes[niattribs++] = GL.GL_FALSE;
-
- iattributes[niattribs++] = GL.WGL_PBUFFER_LARGEST_ARB;
- iattributes[niattribs++] = GL.GL_FALSE;
- }
-
- iattributes[niattribs++] = 0;
-
- tmpBuffer = gl.wglCreatePbufferARB(parentHdc, format, initWidth, initHeight, iattributes);
- ++whichFormat;
- } while ((tmpBuffer == 0) && (whichFormat < nformats));
-
- if (tmpBuffer == 0) {
- throw new GLException("pbuffer creation error: wglCreatePbufferARB() failed: tried " + nformats +
- " pixel formats, last error was: " + wglGetLastError());
- }
-
- // Get the device context.
- long tmpHdc = gl.wglGetPbufferDCARB(tmpBuffer);
- if (tmpHdc == 0) {
- throw new GLException("pbuffer creation error: wglGetPbufferDCARB() failed");
- }
-
- this.parentHglrc = parentHglrc;
-
- // Set up instance variables
- buffer = tmpBuffer;
- hdc = tmpHdc;
-
- // Determine the actual width and height we were able to create.
- int[] tmp = new int[1];
- gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_WIDTH_ARB, tmp );
- width = tmp[0];
- gl.wglQueryPbufferARB( buffer, GL.WGL_PBUFFER_HEIGHT_ARB, tmp );
- height = tmp[0];
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- created = false;
-
- if (buffer == 0) {
- // pbuffer not instantiated yet
- if (DEBUG) {
- System.err.println("pbuffer not instantiated yet");
- }
- return false;
- }
-
- boolean res = super.makeCurrent(initAction);
- if (DEBUG) {
- System.err.println("super.makeCurrent() = " + res + ", created = " + created);
- }
- if (created) {
- // Initialize render-to-texture support if requested
- rtt = capabilities.getOffscreenRenderToTexture();
- rect = capabilities.getOffscreenRenderToTextureRectangle();
-
- if (rtt) {
- if (DEBUG) {
- System.err.println("Initializing render-to-texture support");
- }
-
- if (!gl.isExtensionAvailable("WGL_ARB_render_texture")) {
- System.err.println("WindowsPbufferGLContext: WARNING: WGL_ARB_render_texture extension not " +
- "supported; implementing render_to_texture support using slow texture readback");
- } else {
- hasRTT = true;
- GL gl = getGL();
-
- if (rect && !gl.isExtensionAvailable("GL_NV_texture_rectangle")) {
- System.err.println("WindowsPbufferGLContext: WARNING: GL_NV_texture_rectangle extension not " +
- "supported; skipping requested render_to_texture_rectangle support for pbuffer");
- rect = false;
- }
- if (rect) {
- if (DEBUG) {
- System.err.println(" Using render-to-texture-rectangle");
- }
- textureTarget = GL.GL_TEXTURE_RECTANGLE_NV;
- } else {
- if (DEBUG) {
- System.err.println(" Using vanilla render-to-texture");
- }
- textureTarget = GL.GL_TEXTURE_2D;
- }
- int[] tmp = new int[1];
- gl.glGenTextures(1, tmp);
- texture = tmp[0];
- gl.glBindTexture(textureTarget, texture);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
- gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
- gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, width, height, 0);
- }
- }
- }
- return res;
- }
-
- public void handleModeSwitch(long parentHdc, long parentHglrc) {
- throw new GLException("Not yet implemented");
- }
-
- protected boolean isOffscreen() {
- // FIXME: currently the only caller of this won't cause proper
- // resizing of the pbuffer anyway.
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- protected void create() {
- created = true;
- // Create a gl context for the p-buffer.
- hglrc = WGL.wglCreateContext(hdc);
- if (hglrc == 0) {
- throw new GLException("pbuffer creation error: wglCreateContext() failed");
- }
-
- // FIXME: provide option to not share display lists with subordinate pbuffer?
- if (!WGL.wglShareLists(parentHglrc, hglrc)) {
- throw new GLException("pbuffer: wglShareLists() failed");
- }
- }
-
- protected void destroyImpl() throws GLException {
- if (hglrc != 0) {
- super.destroyImpl();
- // Must release DC and pbuffer
- // NOTE that since the context is not current, glGetError() can
- // not be called here, so we skip the use of any composable
- // pipelines
- GL gl = createGL();
- if (gl.wglReleasePbufferDCARB(buffer, hdc) == 0) {
- throw new GLException("Error releasing pbuffer device context: error code " + WGL.GetLastError());
- }
- hdc = 0;
- if (!gl.wglDestroyPbufferARB(buffer)) {
- throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
- }
- buffer = 0;
- }
- }
-
- public void swapBuffers() throws GLException {
- // FIXME: do we need to do anything if the pbuffer is double-buffered?
- // For now, just grab the pixels for the render-to-texture support.
- if (rtt && !hasRTT) {
- if (DEBUG) {
- System.err.println("Copying pbuffer data to GL_TEXTURE_2D state");
- }
-
- GL gl = getGL();
- gl.glCopyTexSubImage2D(textureTarget, 0, 0, 0, 0, 0, width, height);
- }
- }
-
- public int getFloatingPointMode() {
- return floatMode;
- }
-
- private String wglGetLastError() {
- int err = WGL.GetLastError();
- String detail = null;
- switch (err) {
- case WGL.ERROR_INVALID_PIXEL_FORMAT: detail = "ERROR_INVALID_PIXEL_FORMAT"; break;
- case WGL.ERROR_NO_SYSTEM_RESOURCES: detail = "ERROR_NO_SYSTEM_RESOURCES"; break;
- case WGL.ERROR_INVALID_DATA: detail = "ERROR_INVALID_DATA"; break;
- case WGL.ERROR_PROC_NOT_FOUND: detail = "ERROR_PROC_NOT_FOUND"; break;
- case WGL.ERROR_INVALID_WINDOW_HANDLE:detail = "ERROR_INVALID_WINDOW_HANDLE"; break;
- default: detail = "(Unknown error code " + err + ")"; break;
- }
- return detail;
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContext.java b/src/net/java/games/jogl/impl/x11/X11GLContext.java
deleted file mode 100644
index 53f44101f..000000000
--- a/src/net/java/games/jogl/impl/x11/X11GLContext.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import java.awt.Component;
-import java.security.*;
-import java.util.*;
-import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public abstract class X11GLContext extends GLContext {
- protected long display;
- protected long drawable;
- protected long visualID;
- protected long context;
- private boolean glXQueryExtensionsStringInitialized;
- private boolean glXQueryExtensionsStringAvailable;
- private static final Map/*<String, String>*/ functionNameMap;
- private boolean isGLX13;
- // Table that holds the addresses of the native C-language entry points for
- // OpenGL functions.
- private GLProcAddressTable glProcAddressTable;
- private static boolean haveResetGLXProcAddressTable;
- // Cache the most recent value of the "display" variable (which we
- // only guarantee to be valid in between makeCurrent / free pairs)
- // so that we can implement displayImpl() (which must be done when
- // the context is not current)
- protected long mostRecentDisplay;
- // There is currently a bug on Linux/AMD64 distributions in glXGetProcAddressARB
- protected static boolean isLinuxAMD64;
-
- static {
- functionNameMap = new HashMap();
- functionNameMap.put("glAllocateMemoryNV", "glXAllocateMemoryNV");
- functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV");
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String os = System.getProperty("os.name").toLowerCase();
- String arch = System.getProperty("os.arch").toLowerCase();
- if (os.startsWith("linux") && arch.equals("amd64")) {
- isLinuxAMD64 = true;
- }
- return null;
- }
- });
- }
-
- public X11GLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(component, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new X11GLImpl(this);
- }
-
- protected String mapToRealGLFunctionName(String glFunctionName) {
- String lookup = (String) functionNameMap.get(glFunctionName);
- if (lookup != null) {
- return lookup;
- }
- return glFunctionName;
- }
-
- protected String mapToRealGLExtensionName(String glExtensionName) {
- return glExtensionName;
- }
-
- protected abstract boolean isOffscreen();
-
- public int getOffscreenContextWidth() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextHeight() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextPixelDataType() {
- throw new GLException("Should not call this");
- }
-
- public abstract int getOffscreenContextReadBuffer();
-
- public abstract boolean offscreenImageNeedsVerticalFlip();
-
- public synchronized void setRenderingThread(Thread currentThreadOrNull, Runnable initAction) {
- this.willSetRenderingThread = false;
- // FIXME: the JAWT on X11 grabs the AWT lock while the
- // DrawingSurface is locked, which means that no other events can
- // be processed. Currently we handle this by preventing the
- // effects of setRenderingThread. We should figure out a better
- // solution that is reasonably robust. Must file a bug to be fixed
- // in the 1.5 JAWT.
- }
-
- /**
- * Creates and initializes an appropriate OpenGl context. Should only be
- * called by {@link makeCurrent(Runnable)}.
- */
- protected abstract void create();
-
- public boolean isExtensionAvailable(String glExtensionName) {
- if (glExtensionName.equals("GL_ARB_pbuffer") ||
- glExtensionName.equals("GL_ARB_pixel_format")) {
- return isGLX13;
- }
- return super.isExtensionAvailable(glExtensionName);
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- boolean created = false;
- if (context == 0) {
- create();
- if (DEBUG) {
- System.err.println("!!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
- if (drawable == 0) {
- throw new GLException("Unable to make context current; drawable was null");
- }
-
- // FIXME: this cast to int would be wrong on 64-bit platforms
- // where the argument type to glXMakeCurrent would change (should
- // probably make GLXDrawable, and maybe XID, Opaque as long)
- if (!GLX.glXMakeCurrent(display, (int) drawable, context)) {
- throw new GLException("Error making context current");
- }
-
- if (created) {
- resetGLFunctionAvailability();
- initAction.run();
- }
- return true;
- }
-
- protected synchronized void free() throws GLException {
- if (!GLX.glXMakeCurrent(display, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- }
-
- protected void destroyImpl() throws GLException {
- lockAWT();
- if (context != 0) {
- GLX.glXDestroyContext(mostRecentDisplay, context);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + context);
- }
- context = 0;
- }
- unlockAWT();
- }
-
- public abstract void swapBuffers() throws GLException;
-
- protected long dynamicLookupFunction(String glFuncName) {
- long res = 0;
- if (!isLinuxAMD64) {
- res = GLX.glXGetProcAddressARB(glFuncName);
- }
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- res = GLX.dlsym(glFuncName);
- }
- return res;
- }
-
- public boolean isCreated() {
- return (context != 0);
- }
-
- protected void resetGLFunctionAvailability() {
- super.resetGLFunctionAvailability();
- if (DEBUG) {
- System.err.println("!!! Initializing OpenGL extension address table");
- }
- resetProcAddressTable(getGLProcAddressTable());
-
- if (!haveResetGLXProcAddressTable) {
- resetProcAddressTable(GLX.getGLXProcAddressTable());
- }
-
- // Figure out whether we are running GLX version 1.3 or above and
- // therefore have pbuffer support
- if (display == 0) {
- throw new GLException("Expected non-null DISPLAY for querying GLX version");
- }
- int[] major = new int[1];
- int[] minor = new int[1];
- if (!GLX.glXQueryVersion(display, major, minor)) {
- throw new GLException("glXQueryVersion failed");
- }
- if (DEBUG) {
- System.err.println("!!! GLX version: major " + major[0] +
- ", minor " + minor[0]);
- }
-
- // Work around bugs in ATI's Linux drivers where they report they
- // only implement GLX version 1.2 but actually do support pbuffers
- if (major[0] == 1 && minor[0] == 2) {
- GL gl = getGL();
- String str = gl.glGetString(GL.GL_VENDOR);
- if (str != null && str.indexOf("ATI") >= 0) {
- isGLX13 = true;
- return;
- }
- }
-
- isGLX13 = ((major[0] > 1) || (minor[0] > 2));
- }
-
- public GLProcAddressTable getGLProcAddressTable() {
- if (glProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by capability bits so we can
- // share them among contexts with the same capabilities
- glProcAddressTable = new GLProcAddressTable();
- }
- return glProcAddressTable;
- }
-
- public synchronized String getPlatformExtensionsString() {
- if (display == 0) {
- throw new GLException("Context not current");
- }
- if (!glXQueryExtensionsStringInitialized) {
- glXQueryExtensionsStringAvailable = (dynamicLookupFunction("glXQueryExtensionsString") != 0);
- glXQueryExtensionsStringInitialized = true;
- }
- if (glXQueryExtensionsStringAvailable) {
- lockAWT();
- try {
- String ret = GLX.glXQueryExtensionsString(display, GLX.DefaultScreen(display));
- if (DEBUG) {
- System.err.println("!!! GLX extensions: " + ret);
- }
- return ret;
- } finally {
- unlockAWT();
- }
- } else {
- return "";
- }
- }
-
- protected boolean isFunctionAvailable(String glFunctionName)
- {
- boolean available = super.isFunctionAvailable(glFunctionName);
-
- // Sanity check for implementations that use proc addresses for run-time
- // linking: if the function IS available, then make sure there's a proc
- // address for it if it's an extension or not part of the OpenGL 1.1 core
- // (post GL 1.1 functions are run-time linked on windows).
- assert(!available ||
- (getGLProcAddressTable().getAddressFor(mapToRealGLFunctionName(glFunctionName)) != 0 ||
- FunctionAvailabilityCache.isPartOfGLCore("1.1", mapToRealGLFunctionName(glFunctionName)))
- );
-
- return available;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- protected JAWT getJAWT() {
- return X11GLContextFactory.getJAWT();
- }
-
- protected XVisualInfo chooseVisual() {
- if (!isOffscreen()) {
- // The visual has already been chosen by the time we get here;
- // it's specified by the GraphicsConfiguration of the
- // GLCanvas. Fortunately, the JAWT supplies the visual ID for
- // the component in a portable fashion, so all we have to do is
- // use XGetVisualInfo with a VisualIDMask to get the
- // corresponding XVisualInfo to pass into glXChooseVisual.
- int[] count = new int[1];
- XVisualInfo template = new XVisualInfo();
- // FIXME: probably not 64-bit clean
- template.visualid((int) visualID);
- XVisualInfo[] infos = GLX.XGetVisualInfo(display, GLX.VisualIDMask, template, count);
- if (infos == null || infos.length == 0) {
- throw new GLException("Error while getting XVisualInfo for visual ID " + visualID);
- }
- // FIXME: the storage for the infos array is leaked (should
- // clean it up somehow when we're done with the visual we're
- // returning)
- return infos[0];
- } else {
- // It isn't clear to me whether we need this much code to handle
- // the offscreen case, where we're creating a pixmap into which
- // to render...this is what we (incorrectly) used to do for the
- // onscreen case
-
- int screen = 0; // FIXME: provide way to specify this?
- XVisualInfo vis = null;
- int[] count = new int[1];
- XVisualInfo template = new XVisualInfo();
- template.screen(screen);
- XVisualInfo[] infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count);
- if (infos == null) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- GLCapabilities[] caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLContextFactory.xvi2GLCapabilities(display, infos[i]);
- }
- int chosen = chooser.chooseCapabilities(capabilities, caps, -1);
- if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- if (DEBUG) {
- System.err.println("Chosen visual (" + chosen + "):");
- System.err.println(caps[chosen]);
- }
- vis = infos[chosen];
- if (vis == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual");
- }
- // FIXME: the storage for the infos array is leaked (should
- // clean it up somehow when we're done with the visual we're
- // returning)
-
- return vis;
- }
- }
-
- protected long createContext(XVisualInfo vis, boolean onscreen) {
- X11GLContext other = (X11GLContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- long res = GLX.glXCreateContext(display, vis, share, onscreen);
- if (res != 0) {
- GLContextShareSet.contextCreated(this);
- }
- return res;
- }
-
- // Helper routine for the overridden create() to call
- protected void chooseVisualAndCreateContext(boolean onscreen) {
- XVisualInfo vis = chooseVisual();
- context = createContext(vis, onscreen);
- if (context == 0) {
- throw new GLException("Unable to create OpenGL context");
- }
- }
-
- protected long getContext() {
- return context;
- }
-
- // These synchronization primitives prevent the AWT from making
- // requests from the X server asynchronously to this code.
- protected void lockAWT() {
- X11GLContextFactory.lockAWT();
- }
-
- protected void unlockAWT() {
- X11GLContextFactory.unlockAWT();
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java b/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java
deleted file mode 100644
index a1b299478..000000000
--- a/src/net/java/games/jogl/impl/x11/X11GLContextFactory.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import java.awt.Component;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class X11GLContextFactory extends GLContextFactory {
- static {
- NativeLibLoader.load();
- }
-
- private static final int MAX_ATTRIBS = 128;
-
- public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GraphicsDevice device) {
- int screen = X11SunJDKReflection.graphicsDeviceGetScreen(device);
- // Until we have a rock-solid visual selection algorithm written
- // in pure Java, we're going to provide the underlying window
- // system's selection to the chooser as a hint
-
- int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable());
- XVisualInfo[] infos = null;
- GLCapabilities[] caps = null;
- int recommendedIndex = -1;
- lockAWT();
- try {
- long display = getDisplayConnection();
- XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs);
- int[] count = new int[1];
- XVisualInfo template = new XVisualInfo();
- template.screen(screen);
- infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count);
- if (infos == null) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = xvi2GLCapabilities(display, infos[i]);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
- recommendedIndex = i;
- }
- }
- } finally {
- unlockAWT();
- }
- int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- XVisualInfo vis = infos[chosen];
- if (vis == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual");
- }
- // FIXME: need to look at glue code and see type of this field
- long visualID = vis.visualid();
- // FIXME: the storage for the infos array, as well as that for the
- // recommended visual, is leaked; should free them here with XFree()
-
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return config;
- }
- }
- }
-
- // Either we weren't able to reflectively introspect on the
- // X11GraphicsConfig or something went wrong in the steps above;
- // we're going to return null without signaling an error condition
- // in this case (although we should distinguish between the two
- // and possibly report more of an error in the latter case)
- return null;
- }
-
- public GLContext createGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- if (component != null) {
- return new X11OnscreenGLContext(component, capabilities, chooser, shareWith);
- } else {
- return new X11OffscreenGLContext(capabilities, chooser, shareWith);
- }
- }
-
- public static GLCapabilities xvi2GLCapabilities(long display, XVisualInfo info) {
- int[] tmp = new int[1];
- int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp);
- if (val == 0) {
- // Visual does not support OpenGL
- return null;
- }
- val = glXGetConfig(display, info, GLX.GLX_RGBA, tmp);
- if (val == 0) {
- // Visual does not support RGBA
- return null;
- }
- GLCapabilities res = new GLCapabilities();
- res.setDoubleBuffered(glXGetConfig(display, info, GLX.GLX_DOUBLEBUFFER, tmp) != 0);
- res.setStereo (glXGetConfig(display, info, GLX.GLX_STEREO, tmp) != 0);
- // Note: use of hardware acceleration is determined by
- // glXCreateContext, not by the XVisualInfo. Optimistically claim
- // that all GLCapabilities have the capability to be hardware
- // accelerated.
- res.setHardwareAccelerated(true);
- res.setDepthBits (glXGetConfig(display, info, GLX.GLX_DEPTH_SIZE, tmp));
- res.setStencilBits (glXGetConfig(display, info, GLX.GLX_STENCIL_SIZE, tmp));
- res.setRedBits (glXGetConfig(display, info, GLX.GLX_RED_SIZE, tmp));
- res.setGreenBits (glXGetConfig(display, info, GLX.GLX_GREEN_SIZE, tmp));
- res.setBlueBits (glXGetConfig(display, info, GLX.GLX_BLUE_SIZE, tmp));
- res.setAlphaBits (glXGetConfig(display, info, GLX.GLX_ALPHA_SIZE, tmp));
- res.setAccumRedBits (glXGetConfig(display, info, GLX.GLX_ACCUM_RED_SIZE, tmp));
- res.setAccumGreenBits(glXGetConfig(display, info, GLX.GLX_ACCUM_GREEN_SIZE, tmp));
- res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp));
- res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp));
- if (isMultisampleAvailable()) {
- res.setSampleBuffers(glXGetConfig(display, info, GLX.GLX_SAMPLE_BUFFERS_ARB, tmp) != 0);
- res.setNumSamples (glXGetConfig(display, info, GLX.GLX_SAMPLES_ARB, tmp));
- }
- return res;
- }
-
- public static int[] glCapabilities2AttribList(GLCapabilities caps,
- boolean isMultisampleAvailable) {
- int colorDepth = (caps.getRedBits() +
- caps.getGreenBits() +
- caps.getBlueBits());
- if (colorDepth < 15) {
- throw new GLException("Bit depths < 15 (i.e., non-true-color) not supported");
- }
- int[] res = new int[MAX_ATTRIBS];
- int idx = 0;
- res[idx++] = GLX.GLX_RGBA;
- if (caps.getDoubleBuffered()) {
- res[idx++] = GLX.GLX_DOUBLEBUFFER;
- }
- if (caps.getStereo()) {
- res[idx++] = GLX.GLX_STEREO;
- }
- res[idx++] = GLX.GLX_RED_SIZE;
- res[idx++] = caps.getRedBits();
- res[idx++] = GLX.GLX_GREEN_SIZE;
- res[idx++] = caps.getGreenBits();
- res[idx++] = GLX.GLX_BLUE_SIZE;
- res[idx++] = caps.getBlueBits();
- res[idx++] = GLX.GLX_ALPHA_SIZE;
- res[idx++] = caps.getAlphaBits();
- res[idx++] = GLX.GLX_DEPTH_SIZE;
- res[idx++] = caps.getDepthBits();
- res[idx++] = GLX.GLX_STENCIL_SIZE;
- res[idx++] = caps.getStencilBits();
- res[idx++] = GLX.GLX_ACCUM_RED_SIZE;
- res[idx++] = caps.getAccumRedBits();
- res[idx++] = GLX.GLX_ACCUM_GREEN_SIZE;
- res[idx++] = caps.getAccumGreenBits();
- res[idx++] = GLX.GLX_ACCUM_BLUE_SIZE;
- res[idx++] = caps.getAccumBlueBits();
- if (isMultisampleAvailable && caps.getSampleBuffers()) {
- res[idx++] = GL.GLX_SAMPLE_BUFFERS_ARB;
- res[idx++] = GL.GL_TRUE;
- res[idx++] = GL.GLX_SAMPLES_ARB;
- res[idx++] = caps.getNumSamples();
- }
- res[idx++] = 0;
- return res;
- }
-
- // JAWT access
- private static JAWT jawt;
- public static JAWT getJAWT() {
- if (jawt == null) {
- JAWT j = new JAWT();
- j.version(JAWTFactory.JAWT_VERSION_1_4);
- if (!JAWTFactory.JAWT_GetAWT(j)) {
- throw new RuntimeException("Unable to initialize JAWT");
- }
- jawt = j;
- }
- return jawt;
- }
-
- public static void lockAWT() {
- getJAWT().Lock();
- }
-
- public static void unlockAWT() {
- getJAWT().Unlock();
- }
-
- // Display connection for use by visual selection algorithm and by all offscreen surfaces
- private static long staticDisplay;
- public static long getDisplayConnection() {
- if (staticDisplay == 0) {
- lockAWT();
- try {
- staticDisplay = GLX.XOpenDisplay(null);
- } finally {
- unlockAWT();
- }
- if (staticDisplay == 0) {
- throw new GLException("Unable to open default display, needed for visual selection and offscreen surface handling");
- }
- }
- return staticDisplay;
- }
-
- private static boolean checkedMultisample;
- private static boolean multisampleAvailable;
- public static boolean isMultisampleAvailable() {
- if (!checkedMultisample) {
- long display = getDisplayConnection();
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- multisampleAvailable = (exts.indexOf("GLX_ARB_multisample") >= 0);
- }
- checkedMultisample = true;
- }
- return multisampleAvailable;
- }
-
- private static String glXGetConfigErrorCode(int err) {
- switch (err) {
- case GLX.GLX_NO_EXTENSION: return "GLX_NO_EXTENSION";
- case GLX.GLX_BAD_SCREEN: return "GLX_BAD_SCREEN";
- case GLX.GLX_BAD_ATTRIBUTE: return "GLX_BAD_ATTRIBUTE";
- case GLX.GLX_BAD_VISUAL: return "GLX_BAD_VISUAL";
- default: return "Unknown error code " + err;
- }
- }
-
- public static int glXGetConfig(long display, XVisualInfo info, int attrib, int[] tmp) {
- if (display == 0) {
- throw new GLException("No display connection");
- }
- int res = GLX.glXGetConfig(display, info, attrib, tmp);
- if (res != 0) {
- throw new GLException("glXGetConfig failed: error code " + glXGetConfigErrorCode(res));
- }
- return tmp[0];
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
deleted file mode 100644
index 8f0aa06a5..000000000
--- a/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import java.awt.image.BufferedImage;
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class X11OffscreenGLContext extends X11GLContext {
- private long pixmap;
- private boolean isDoubleBuffered;
- // Width and height of the underlying bitmap
- private int width;
- private int height;
-
- public X11OffscreenGLContext(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(null, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new X11GLImpl(this);
- }
-
- protected boolean isOffscreen() {
- return true;
- }
-
- public int getOffscreenContextWidth() {
- return width;
- }
-
- public int getOffscreenContextHeight() {
- return height;
- }
-
- public int getOffscreenContextPixelDataType() {
- return GL.GL_UNSIGNED_BYTE;
- }
-
- public int getOffscreenContextReadBuffer() {
- if (isDoubleBuffered) {
- return GL.GL_BACK;
- }
- return GL.GL_FRONT;
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- // There doesn't seem to be a way to do this in the construction
- // of the Pixmap or GLXPixmap
- return true;
- }
-
- public boolean canCreatePbufferContext() {
- // For now say no
- return false;
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- display = X11GLContextFactory.getDisplayConnection();
- if (pendingOffscreenResize) {
- if (pendingOffscreenWidth != width || pendingOffscreenHeight != height) {
- if (context != 0) {
- destroy();
- }
- width = pendingOffscreenWidth;
- height = pendingOffscreenHeight;
- pendingOffscreenResize = false;
- }
- }
- mostRecentDisplay = display;
- return super.makeCurrent(initAction);
- }
-
- public synchronized void swapBuffers() throws GLException {
- }
-
- protected synchronized void free() throws GLException {
- try {
- super.free();
- } finally {
- display = 0;
- }
- }
-
- protected void create() {
- XVisualInfo vis = chooseVisual();
- int bitsPerPixel = vis.depth();
-
- if (display == 0) {
- throw new GLException("No active display");
- }
- int screen = GLX.DefaultScreen(display);
- pixmap = GLX.XCreatePixmap(display, (int) GLX.RootWindow(display, screen), width, height, bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- drawable = GLX.glXCreateGLXPixmap(display, vis, pixmap);
- if (drawable == 0) {
- throw new GLException("glXCreateGLXPixmap failed");
- }
- context = createContext(vis, false);
- if (context == 0) {
- throw new GLException("Unable to create OpenGL context");
- }
- isDoubleBuffered = (X11GLContextFactory.glXGetConfig(display, vis, GLX.GLX_DOUBLEBUFFER, new int[1]) != 0);
- }
-
- protected void destroyImpl() {
- if (context != 0) {
- super.destroyImpl();
- // Must destroy OpenGL context, pixmap and GLXPixmap
- GLX.glXDestroyContext(display, context);
- GLX.glXDestroyGLXPixmap(display, (int) drawable);
- GLX.XFreePixmap(display, pixmap);
- context = 0;
- drawable = 0;
- pixmap = 0;
- GLContextShareSet.contextDestroyed(this);
- }
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java b/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
deleted file mode 100644
index 2fd340d79..000000000
--- a/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import java.awt.Component;
-import java.util.*;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class X11OnscreenGLContext extends X11GLContext {
- // Variables for lockSurface/unlockSurface
- private JAWT_DrawingSurface ds;
- private JAWT_DrawingSurfaceInfo dsi;
- private JAWT_X11DrawingSurfaceInfo x11dsi;
-
- // Variables for pbuffer support
- List pbuffersToInstantiate = new ArrayList();
-
- public X11OnscreenGLContext(Component component,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- GLContext shareWith) {
- super(component, capabilities, chooser, shareWith);
- }
-
- protected GL createGL()
- {
- return new X11GLImpl(this);
- }
-
- protected boolean isOffscreen() {
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- public boolean canCreatePbufferContext() {
- // FIXME: should we gate this on GLX 1.3 being available?
- return true;
- }
-
- public synchronized GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- X11PbufferGLContext ctx = new X11PbufferGLContext(capabilities, initialWidth, initialHeight);
- pbuffersToInstantiate.add(ctx);
- return ctx;
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- public void setSwapInterval(int interval) {
- GL gl = getGL();
- if (gl.isExtensionAvailable("GLX_SGI_swap_control")) {
- gl.glXSwapIntervalSGI(interval);
- }
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- try {
- if (!lockSurface()) {
- return false;
- }
- boolean ret = super.makeCurrent(initAction);
- if (ret) {
- // Instantiate any pending pbuffers
- while (!pbuffersToInstantiate.isEmpty()) {
- X11PbufferGLContext ctx =
- (X11PbufferGLContext) pbuffersToInstantiate.remove(pbuffersToInstantiate.size() - 1);
- ctx.createPbuffer(display, context, getGL());
- }
- }
- return ret;
- } catch (RuntimeException e) {
- try {
- unlockSurface();
- } catch (Exception e2) {
- // do nothing if unlockSurface throws
- }
- throw(e);
- }
- }
-
- protected synchronized void free() throws GLException {
- try {
- super.free();
- } finally {
- unlockSurface();
- }
- }
-
- public synchronized void swapBuffers() throws GLException {
- // FIXME: this cast to int would be wrong on 64-bit platforms
- // where the argument type to glXMakeCurrent would change (should
- // probably make GLXDrawable, and maybe XID, Opaque as long)
- GLX.glXSwapBuffers(display, (int) drawable);
- }
-
- private boolean lockSurface() throws GLException {
- if (drawable != 0) {
- throw new GLException("Surface already locked");
- }
- ds = getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return false;
- }
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
- // See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- if (context != 0) {
- GLX.glXDestroyContext(display, context);
- context = 0;
- }
- }
- dsi = ds.GetDrawingSurfaceInfo();
- if (dsi == null) {
- // Widget not yet realized
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- return false;
- }
- x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
- display = x11dsi.display();
- drawable = x11dsi.drawable();
- visualID = x11dsi.visualID();
- if (display == 0 || drawable == 0) {
- // Widget not yet realized
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- return false;
- }
- mostRecentDisplay = display;
- return true;
- }
-
- private void unlockSurface() {
- if (drawable == 0) {
- throw new GLException("Surface already unlocked");
- }
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- }
-
- protected void create() {
- chooseVisualAndCreateContext(true);
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java b/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
deleted file mode 100644
index d9f18a760..000000000
--- a/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import net.java.games.jogl.*;
-import net.java.games.jogl.impl.*;
-
-public class X11PbufferGLContext extends X11GLContext {
- private static final boolean DEBUG = Debug.debug("X11PbufferGLContext");
-
- private int initWidth;
- private int initHeight;
-
- private long buffer; // GLXPbuffer
- private GLXFBConfig fbConfig;
- private int width;
- private int height;
-
- // FIXME: kept around because we create the OpenGL context lazily to
- // better integrate with the X11GLContext framework
- private long parentContext;
-
- private static final int MAX_PFORMATS = 256;
- private static final int MAX_ATTRIBS = 256;
-
- public X11PbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- super(null, capabilities, null, null);
- this.initWidth = initialWidth;
- this.initHeight = initialHeight;
- if (initWidth <= 0 || initHeight <= 0) {
- throw new GLException("Initial width and height of pbuffer must be positive (were (" +
- initWidth + ", " + initHeight + "))");
- }
- }
-
- public boolean canCreatePbufferContext() {
- return false;
- }
-
- public GLContext createPbufferContext(GLCapabilities capabilities,
- int initialWidth,
- int initialHeight) {
- throw new GLException("Not supported");
- }
-
- public void bindPbufferToTexture() {
- // FIXME: figure out how to implement this
- throw new GLException("Not yet implemented");
- }
-
- public void releasePbufferFromTexture() {
- // FIXME: figure out how to implement this
- throw new GLException("Not yet implemented");
- }
-
- public void createPbuffer(long display, long parentContext, GL gl) {
- if (display == 0) {
- throw new GLException("Null display");
- }
-
- if (parentContext == 0) {
- throw new GLException("Null parentContext");
- }
-
- if (capabilities.getOffscreenRenderToTexture()) {
- throw new GLException("Render-to-texture pbuffers not supported yet on X11");
- }
-
- if (capabilities.getOffscreenRenderToTextureRectangle()) {
- throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11");
- }
-
- int[] iattributes = new int [2*MAX_ATTRIBS];
- float[] fattributes = new float[2*MAX_ATTRIBS];
- int nfattribs = 0;
- int niattribs = 0;
-
- // Since we are trying to create a pbuffer, the GLXFBConfig we
- // request (and subsequently use) must be "p-buffer capable".
- iattributes[niattribs++] = GL.GLX_DRAWABLE_TYPE;
- iattributes[niattribs++] = GL.GLX_PBUFFER_BIT;
-
- iattributes[niattribs++] = GL.GLX_RENDER_TYPE;
- iattributes[niattribs++] = GL.GLX_RGBA_BIT;
-
- iattributes[niattribs++] = GLX.GLX_DOUBLEBUFFER;
- if (capabilities.getDoubleBuffered()) {
- iattributes[niattribs++] = GL.GL_TRUE;
- } else {
- iattributes[niattribs++] = GL.GL_FALSE;
- }
-
- iattributes[niattribs++] = GLX.GLX_DEPTH_SIZE;
- iattributes[niattribs++] = capabilities.getDepthBits();
-
- iattributes[niattribs++] = GLX.GLX_RED_SIZE;
- iattributes[niattribs++] = capabilities.getRedBits();
-
- iattributes[niattribs++] = GLX.GLX_GREEN_SIZE;
- iattributes[niattribs++] = capabilities.getGreenBits();
-
- iattributes[niattribs++] = GLX.GLX_BLUE_SIZE;
- iattributes[niattribs++] = capabilities.getBlueBits();
-
- iattributes[niattribs++] = GLX.GLX_ALPHA_SIZE;
- iattributes[niattribs++] = capabilities.getAlphaBits();
-
- if (capabilities.getStencilBits() > 0) {
- iattributes[niattribs++] = GLX.GLX_STENCIL_SIZE;
- iattributes[niattribs++] = capabilities.getStencilBits();
- }
-
- if (capabilities.getAccumRedBits() > 0 ||
- capabilities.getAccumGreenBits() > 0 ||
- capabilities.getAccumBlueBits() > 0) {
- iattributes[niattribs++] = GLX.GLX_ACCUM_RED_SIZE;
- iattributes[niattribs++] = capabilities.getAccumRedBits();
- iattributes[niattribs++] = GLX.GLX_ACCUM_GREEN_SIZE;
- iattributes[niattribs++] = capabilities.getAccumGreenBits();
- iattributes[niattribs++] = GLX.GLX_ACCUM_BLUE_SIZE;
- iattributes[niattribs++] = capabilities.getAccumBlueBits();
- }
-
- if (capabilities.getOffscreenFloatingPointBuffers()) {
- if (!gl.isExtensionAvailable("GLX_NV_float_buffer")) {
- throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware");
- }
- iattributes[niattribs++] = GLX.GLX_FLOAT_COMPONENTS_NV;
- iattributes[niattribs++] = GL.GL_TRUE;
- }
-
- // FIXME: add FSAA support? Don't want to get into a situation
- // where we have to retry the glXChooseFBConfig call if it fails
- // due to a lack of an antialiased visual...
-
- iattributes[niattribs++] = 0; // null-terminate
-
- int screen = 0; // FIXME: provide way to specify this?
- int[] nelementsTmp = new int[1];
- GLXFBConfig[] fbConfigs = GLX.glXChooseFBConfig(display, screen, iattributes, nelementsTmp);
- if (fbConfigs == null || fbConfigs.length == 0 || fbConfigs[0] == null) {
- throw new GLException("pbuffer creation error: glXChooseFBConfig() failed");
- }
- // Note that we currently don't allow selection of anything but
- // the first GLXFBConfig in the returned list
- GLXFBConfig fbConfig = fbConfigs[0];
- int nelements = nelementsTmp[0];
- if (nelements <= 0) {
- throw new GLException("pbuffer creation error: couldn't find a suitable frame buffer configuration");
- }
-
- if (DEBUG) {
- System.err.println("Found " + fbConfigs.length + " matching GLXFBConfigs");
- System.err.println("Parameters of default one:");
- System.err.println("render type: 0x" + Integer.toHexString(queryFBConfig(display, fbConfig, GLX.GLX_RENDER_TYPE)));
- System.err.println("rgba: " + ((queryFBConfig(display, fbConfig, GLX.GLX_RENDER_TYPE) & GLX.GLX_RGBA_BIT) != 0));
- System.err.println("r: " + queryFBConfig(display, fbConfig, GLX.GLX_RED_SIZE));
- System.err.println("g: " + queryFBConfig(display, fbConfig, GLX.GLX_GREEN_SIZE));
- System.err.println("b: " + queryFBConfig(display, fbConfig, GLX.GLX_BLUE_SIZE));
- System.err.println("a: " + queryFBConfig(display, fbConfig, GLX.GLX_ALPHA_SIZE));
- System.err.println("depth: " + queryFBConfig(display, fbConfig, GLX.GLX_DEPTH_SIZE));
- System.err.println("double buffered: " + queryFBConfig(display, fbConfig, GLX.GLX_DOUBLEBUFFER));
- }
-
- // Create the p-buffer.
- niattribs = 0;
-
- iattributes[niattribs++] = GL.GLX_PBUFFER_WIDTH;
- iattributes[niattribs++] = initWidth;
- iattributes[niattribs++] = GL.GLX_PBUFFER_HEIGHT;
- iattributes[niattribs++] = initHeight;
-
- iattributes[niattribs++] = 0;
-
- long tmpBuffer = GLX.glXCreatePbuffer(display, fbConfig, iattributes);
- if (tmpBuffer == 0) {
- // FIXME: query X error code for detail error message
- throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
- }
-
- // Set up instance variables
- this.display = display;
- mostRecentDisplay = display;
- this.parentContext = parentContext;
- buffer = tmpBuffer;
- this.fbConfig = fbConfig;
-
- // Determine the actual width and height we were able to create.
- int[] tmp = new int[1];
- GLX.glXQueryDrawable(display, (int) buffer, GL.GLX_WIDTH, tmp);
- width = tmp[0];
- GLX.glXQueryDrawable(display, (int) buffer, GL.GLX_HEIGHT, tmp);
- height = tmp[0];
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
- }
-
- protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
- if (buffer == 0) {
- // pbuffer not instantiated yet
- return false;
- }
-
- lockAWT();
- try {
- boolean created = false;
- if (context == 0) {
- create();
- if (DEBUG) {
- System.err.println("!!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
-
- if (!GLX.glXMakeContextCurrent(display, buffer, buffer, context)) {
- throw new GLException("Error making context current");
- }
-
- if (created) {
- resetGLFunctionAvailability();
- initAction.run();
- }
- return true;
- } finally {
- unlockAWT();
- }
- }
-
- protected synchronized void free() throws GLException {
- lockAWT();
- try {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- unlockAWT();
- }
- }
-
- public void handleModeSwitch(long parentHdc, long parentHglrc) {
- throw new GLException("Not yet implemented");
- }
-
- protected boolean isOffscreen() {
- // FIXME: currently the only caller of this won't cause proper
- // resizing of the pbuffer anyway.
- return false;
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- protected void create() {
- if (DEBUG) {
- System.err.println("Creating context for pbuffer " + width + " x " + height);
- }
-
- // Create a gl context for the p-buffer.
- // FIXME: provide option to not share display lists with subordinate pbuffer?
- context = GLX.glXCreateNewContext(display, fbConfig, GL.GLX_RGBA_TYPE, parentContext, true);
- if (context == 0) {
- throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
- }
-
- if (DEBUG) {
- System.err.println("Created context for pbuffer " + width + " x " + height);
- }
- }
-
- protected void destroyImpl() throws GLException {
- lockAWT();
- try {
- if (context != 0) {
- super.destroyImpl();
- GLX.glXDestroyPbuffer(display, buffer);
- buffer = 0;
- }
- } finally {
- unlockAWT();
- }
- }
-
- public void swapBuffers() throws GLException {
- // FIXME: do we need to do anything if the pbuffer is double-buffered?
- }
-
- public int getFloatingPointMode() {
- // Floating-point pbuffers currently require NVidia hardware on X11
- return GLPbuffer.NV_FLOAT;
- }
-
- private int queryFBConfig(long display, GLXFBConfig fbConfig, int attrib) {
- int[] tmp = new int[1];
- if (GLX.glXGetFBConfigAttrib(display, fbConfig, attrib, tmp) != 0) {
- throw new GLException("glXGetFBConfigAttrib failed");
- }
- return tmp[0];
- }
-}
diff --git a/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java b/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java
deleted file mode 100755
index 59208e5a9..000000000
--- a/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2003 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.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package net.java.games.jogl.impl.x11;
-
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.lang.reflect.*;
-import java.security.*;
-
-/** This class encapsulates the reflection routines necessary to peek
- inside a few data structures in the AWT implementation on X11 for
- the purposes of correctly enumerating the available visuals. */
-
-public class X11SunJDKReflection {
- private static Class x11GraphicsDeviceClass;
- private static Method x11GraphicsDeviceGetScreenMethod;
- private static Class x11GraphicsConfigClass;
- private static Method x11GraphicsConfigGetVisualMethod;
- private static boolean initted;
-
- static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- try {
- x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice");
- x11GraphicsDeviceGetScreenMethod = x11GraphicsDeviceClass.getDeclaredMethod("getScreen", new Class[] {});
- x11GraphicsDeviceGetScreenMethod.setAccessible(true);
-
- x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig");
- x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {});
- x11GraphicsConfigGetVisualMethod.setAccessible(true);
- initted = true;
- } catch (Exception e) {
- // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
- }
- return null;
- }
- });
- }
-
- public static int graphicsDeviceGetScreen(GraphicsDevice device) {
- if (!initted) {
- return 0;
- }
-
- try {
- return ((Integer) x11GraphicsDeviceGetScreenMethod.invoke(device, new Object[] {})).intValue();
- } catch (Exception e) {
- return 0;
- }
- }
-
- public static int graphicsConfigurationGetVisualID(GraphicsConfiguration config) {
- if (!initted) {
- return 0;
- }
-
- try {
- return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config, new Object[] {})).intValue();
- } catch (Exception e) {
- return 0;
- }
- }
-}