From 5e9c02bce7b241a0bf95c8abca9a91cd25e51ed3 Mon Sep 17 00:00:00 2001
From: Harvey Harrison
* If true, either prolog (if exist) is called or downstream's method, but not both.
- * By default, both methods would be called.
+ * By default, both methods would be called.
* Default: false Default: false An ANT {@link org.apache.tools.ant.Task}
* for using {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo}. Usage: The {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} classname. The {@link org.apache.tools.ant.types.CommandlineJava} that is used
@@ -90,12 +90,12 @@ public class StaticGLGenTask extends Task
* The output directory. The {@link org.apache.tools.ant.types.FileSet} of GL headers. Create and add the VM and classname to {@link org.apache.tools.ant.types.CommandlineJava}. Set the package name for the generated files. This is called by ANT. Set the output directory. This is called by ANT. Add a header file to the list. This is called by ANT for a nested
* element. Add a header file to the list. This is called by ANT for a nested
* element. Add an optional classpath that defines the location of {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo}
* and Run the task. This involves validating the set attributes, creating
* the command line to be executed and finally executing the command. Ensure that the user specified all required arguments. Is the specified string valid? A valid string is non- Execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} in a
+ /**
+ * Execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} in a
* forked JVM. If the {@link #getLastOutline()} is empty already, no new one will be added. A clean tail is ensured, no double empty Outlines are produced
* and a pre-existing empty outline will be replaced with the given one. If the {@code position} indicates the end of this list,
* a clean tail is ensured, no double empty Outlines are produced
* and a pre-existing empty outline will be replaced with the given one. Closes the current last outline via {@link #closeLastOutline()} before adding the new ones. Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it. Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it. If last vertex is not equal to first vertex.
- * A new temp vertex is added at the end which
+ * A new temp vertex is added at the end which
* is equal to the first. Allocates the ogl related data and initializes it the 1st time.
+ * Allocates the ogl related data and initializes it the 1st time.
* Called by {@link #draw(GL2ES2, RenderState, int, int, int)}. Leaves the renderer enabled, ie ShaderState. Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, float[], int)} Sets the cache limit for reusing GlyphString's and their Region.
* Default is {@link #DEFAULT_CACHE_LIMIT}, -1 unlimited, 0 turns cache off, >0 limited The cache will be validate when the next string rendering happens. {@link #getName(StringBuilder, int)} w/ {@link #NAME_FAMILY} and {@link #NAME_SUBFAMILY} Example: "{@code Ubuntu-Regular}" Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it. Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it. Validates the bounding box.
* Supports on-the-fly reconfiguration of dimension and multisample buffers via {@link #reset(GL, int, int, int, boolean)}
* while preserving the {@link Attachment} references.
@@ -55,50 +55,50 @@ import com.jogamp.opengl.FBObject.Attachment.Type;
* Integrates default read/write framebuffers via {@link GLContext#getDefaultReadFramebuffer()} and {@link GLContext#getDefaultReadFramebuffer()},
* which is being hooked at {@link GL#glBindFramebuffer(int, int)} when the default ( FIXME: Implement support for {@link Type#DEPTH_TEXTURE}, {@link Type#STENCIL_TEXTURE} . Always an instance of {@link Attachment}. Either an instance of {@link ColorAttachment} or {@link TextureAttachment}.
+ * Either an instance of {@link ColorAttachment} or {@link TextureAttachment}.
*/
- public static interface Colorbuffer {
- /**
+ public static interface Colorbuffer {
+ /**
* Initializes the color buffer and set it's parameter, if uninitialized, i.e. name is
* Comparison by {@link #type}, {@link #format}, {@link #width}, {@link #height} and {@link #name}.
@@ -272,7 +272,7 @@ public class FBObject {
height== a.height &&
name == a.name ;
}
-
+
/**
*
* Hashed by {@link #type}, {@link #format}, {@link #width}, {@link #height} and {@link #name}.
@@ -289,14 +289,14 @@ public class FBObject {
hash = ((hash << 5) - hash) + name;
return hash;
}
-
+
int objectHashCode() { return super.hashCode(); }
-
+
public String toString() {
return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", "+width+"x"+height+
"; name "+toHexString(name)+", obj "+toHexString(objectHashCode())+"]";
}
-
+
public static Type getType(int attachmentPoint, int maxColorAttachments) {
if( GL.GL_COLOR_ATTACHMENT0 <= attachmentPoint && attachmentPoint < GL.GL_COLOR_ATTACHMENT0+maxColorAttachments ) {
return Type.COLOR;
@@ -304,9 +304,9 @@ public class FBObject {
switch(attachmentPoint) {
case GL.GL_DEPTH_ATTACHMENT:
return Type.DEPTH;
- case GL.GL_STENCIL_ATTACHMENT:
+ case GL.GL_STENCIL_ATTACHMENT:
return Type.STENCIL;
- default:
+ default:
throw new IllegalArgumentException("Invalid attachment point "+toHexString(attachmentPoint));
}
}
@@ -315,7 +315,7 @@ public class FBObject {
/** Other renderbuffer attachment which maybe a colorbuffer, depth or stencil. */
public static class RenderAttachment extends Attachment {
private int samples;
-
+
/**
* @param type allowed types are {@link Type#DEPTH_STENCIL} {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#COLOR}
* @param iFormat
@@ -328,11 +328,11 @@ public class FBObject {
super(validateType(type), iFormat, width, height, name);
this.samples = samples;
}
-
+
/** number of samples, or zero for no multisampling */
public final int getSamples() { return samples; }
/* pp */ final void setSamples(int s) { samples = s; }
-
+
private static Type validateType(Type type) {
switch(type) {
case DEPTH_STENCIL:
@@ -340,11 +340,11 @@ public class FBObject {
case STENCIL:
case COLOR:
return type;
- default:
+ default:
throw new IllegalArgumentException("Invalid type: "+type);
}
}
-
+
/**
*
* Comparison by {@link #type}, {@link #format}, {@link #samples}, {@link #width}, {@link #height} and {@link #name}.
@@ -358,7 +358,7 @@ public class FBObject {
return super.equals(o) &&
samples == ((RenderAttachment)o).samples;
}
-
+
/**
*
* Hashed by {@link #type}, {@link #format}, {@link #samples}, {@link #width}, {@link #height} and {@link #name}.
@@ -378,14 +378,14 @@ public class FBObject {
final boolean init = 0 == getName();
if( init ) {
checkPreGLError(gl);
-
+
final int[] name = new int[] { -1 };
gl.glGenRenderbuffers(1, name, 0);
setName(name[0]);
-
+
gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName());
if( samples > 0 ) {
- ((GL2GL3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, getWidth(), getHeight());
+ ((GL2GL3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, getWidth(), getHeight());
} else {
gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight());
}
@@ -401,7 +401,7 @@ public class FBObject {
}
return init;
}
-
+
@Override
public void free(GL gl) {
final int[] name = new int[] { getName() };
@@ -413,20 +413,20 @@ public class FBObject {
setName(0);
}
}
-
+
public String toString() {
return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", samples "+samples+", "+getWidth()+"x"+getHeight()+
", name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]";
}
}
-
+
/** Color render buffer attachment */
public static class ColorAttachment extends RenderAttachment implements Colorbuffer {
public ColorAttachment(int iFormat, int samples, int width, int height, int name) {
super(Type.COLOR, iFormat, samples, width, height, name);
- }
+ }
}
-
+
/** Texture attachment */
public static class TextureAttachment extends Attachment implements Colorbuffer {
/** details of the texture setup */
@@ -445,7 +445,7 @@ public class FBObject {
* @param wrapT
* @param name
*/
- public TextureAttachment(Type type, int iFormat, int width, int height, int dataFormat, int dataType,
+ public TextureAttachment(Type type, int iFormat, int width, int height, int dataFormat, int dataType,
int magFilter, int minFilter, int wrapS, int wrapT, int name) {
super(validateType(type), iFormat, width, height, name);
this.dataFormat = dataFormat;
@@ -455,35 +455,35 @@ public class FBObject {
this.wrapS = wrapS;
this.wrapT = wrapT;
}
-
+
private static Type validateType(Type type) {
switch(type) {
case COLOR_TEXTURE:
case DEPTH_TEXTURE:
case STENCIL_TEXTURE:
return type;
- default:
+ default:
throw new IllegalArgumentException("Invalid type: "+type);
}
}
-
- /**
+
+ /**
* Initializes the texture and set it's parameter, if uninitialized, i.e. name is Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.prolog_xor_downstream
.
*
*
*
- *
+ *
* #ifndef GL_XXXX
* GLAPI
*
* @author Rob Grzywinski rgrzywinski@yahoo.com
*/
@@ -72,7 +72,7 @@ public class StaticGLGenTask extends Task
*
- *
+ *
* #ifndef GL_VERSION_1_3
* GLAPI void APIENTRY glActiveTexture (GLenum);
* GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
@@ -89,7 +89,7 @@ import java.util.regex.Pattern;
* GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
* GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
* #endif
- *
+ *
*
*
* It will associate
@@ -105,7 +105,7 @@ import java.util.regex.Pattern;
* */
public class BuildStaticGLInfo {
- // Handles function pointer
+ // Handles function pointer
protected static final int funcIdentifierGroup = 9;
protected static Pattern funcPattern =
Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s+\\*\\s*|\\s*\\*\\s+|\\s+)?(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
@@ -119,7 +119,7 @@ public class BuildStaticGLInfo {
Pattern.compile("\\#(elif|else)(.*)");
protected static Pattern endifPattern =
Pattern.compile("\\#endif(.*)");
-
+
protected static final int defineIdentifierGroup = 1;
protected static Pattern definePattern =
Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)");
@@ -203,7 +203,7 @@ public class BuildStaticGLInfo {
Matcher m = null;
int block = 0;
while ((line = reader.readLine()) != null) {
- int type = 0; // 1-define, 2-function
+ int type = 0; // 1-define, 2-function
if ( 0 < block ) { // inside a #ifndef GL_XXX block and matching a function, if block > 0
String identifier = null;
if( 2 >= block ) { // not within sub-blocks > 2, i.e. further typedefs
@@ -216,9 +216,9 @@ public class BuildStaticGLInfo {
}
}
if ( identifier != null &&
- activeAssociation != null &&
- !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_...
- )
+ activeAssociation != null &&
+ !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_...
+ )
{
addAssociation(identifier, activeAssociation);
if (DEBUG) {
@@ -243,7 +243,7 @@ public class BuildStaticGLInfo {
if (DEBUG) {
System.err.println("<"+block+"> END ASSOCIATION BLOCK: <" + activeAssociation + " <-> " + comment + ">");
}
- activeAssociation = null;
+ activeAssociation = null;
} else {
if (DEBUG) {
System.err.println("<"+block+"> END IF BLOCK: <" + comment + ">");
@@ -251,7 +251,7 @@ public class BuildStaticGLInfo {
}
}
}
- } else if ((m = associationPattern.matcher(line)).matches()) {
+ } else if ((m = associationPattern.matcher(line)).matches()) {
// found a new #ifndef GL_XXX block
activeAssociation = m.group(1).trim();
block++;
@@ -387,7 +387,7 @@ public class BuildStaticGLInfo {
declarationToExtensionMap.put(identifier, extensions);
}
extensions.add(association);
-
+
Set ");
writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding));
writer.print("
");
-
+
newComment.append("
Part of ");
if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, binding.getAliasedNames())) {
if (glEmitter.getGLConfig().getAllowNonGLExtensions()) {
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java
index e3e7cb970..b98f17117 100644
--- a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java
+++ b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java
@@ -55,13 +55,13 @@ import org.apache.tools.ant.util.JavaEnvUtils;
/**
*
- <staticglgen package="[generated files package]"
+ <staticglgen package="[generated files package]"
headers="[file pattern of GL headers]"
outputdir="[directory to output the generated files]" />
- *
+ * BuildStaticGLInfo
's dependencies.null
* and has a non-zero length.true
if the string is valid. false
- * otherwise.
+ * otherwise.
*/
private boolean isValid(String string)
{
// check for null
if(string == null)
return false;
-
+
// ensure that the string has a non-zero length
// NOTE: must trim() to remove leading and trailing whitespace
if(string.trim().length() < 1)
return false;
-
+
// the string is valid
return true;
}
@@ -258,10 +258,10 @@ public class StaticGLGenTask extends Task
{
// add the package name
glgenCommandline.createArgument().setValue(packageName);
-
+
// add the output directory name
glgenCommandline.createArgument().setValue(outputDirectory);
-
+
// add the header -files- from the FileSet
headerSet.setDir(getProject().getBaseDir());
DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject());
@@ -272,25 +272,25 @@ public class StaticGLGenTask extends Task
}
}
- /**
- *
* Example to creating an Outline Shape:
*
@@ -60,18 +60,18 @@ import com.jogamp.opengl.math.geom.AABBox;
addVertex(...)
addVertex(...)
*
- *
- * The above will create two outlines each with three vertices. By adding these two outlines to
+ *
+ * The above will create two outlines each with three vertices. By adding these two outlines to
* the OutlineShape, we are stating that the combination of the two outlines represent the shape.
*
- *
- * To specify that the shape is curved at a region, the on-curve flag should be set to false
+ *
+ * To specify that the shape is curved at a region, the on-curve flag should be set to false
* for the vertex that is in the middle of the curved region (if the curved region is defined by 3
* vertices (quadratic curve).
*
- * In case the curved region is defined by 4 or more vertices the middle vertices should both have
+ * In case the curved region is defined by 4 or more vertices the middle vertices should both have
* the on-curve flag set to false.
- *
+ *
*
Example:
*
addVertex(0,0, true);
@@ -79,16 +79,16 @@ import com.jogamp.opengl.math.geom.AABBox;
addVertex(1,1, false);
addVertex(1,0, true);
*
- *
- * The above snippet defines a cubic nurbs curve where (0,1 and 1,1)
+ *
+ * The above snippet defines a cubic nurbs curve where (0,1 and 1,1)
* do not belong to the final rendered shape.
- *
+ *
* Implementation Notes:
*
*
- *
+ *
* @see Outline
* @see Region
*/
@@ -104,21 +104,21 @@ public class OutlineShape implements Comparablezero
) framebuffer is selected.
* zero
.
* @return true
if newly initialized, otherwise false
.
- * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case.
+ * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case.
*/
public boolean initialize(GL gl) throws GLException;
-
- /**
+
+ /**
* Releases the color buffer if initialized, i.e. name is not zero
.
- * @throws GLException if buffer release fails.
+ * @throws GLException if buffer release fails.
*/
public void free(GL gl) throws GLException;
-
+
/**
* Writes the internal format to the given GLCapabilities object.
* @param caps the destination for format bits
* @param rgba8Avail whether rgba8 is available
*/
- public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail);
+ public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail);
}
-
+
/** Common super class of all attachments */
public static abstract class Attachment {
- public enum Type {
+ public enum Type {
NONE, DEPTH, STENCIL, DEPTH_STENCIL, COLOR, COLOR_TEXTURE, DEPTH_TEXTURE, STENCIL_TEXTURE;
-
- /**
+
+ /**
* Returns {@link #COLOR}, {@link #DEPTH}, {@link #STENCIL} or {@link #DEPTH_STENCIL}
- * @throws IllegalArgumentException if format
cannot be handled.
+ * @throws IllegalArgumentException if format
cannot be handled.
*/
public static Type determine(int format) throws IllegalArgumentException {
switch(format) {
@@ -120,20 +120,20 @@ public class FBObject {
return Type.DEPTH_STENCIL;
default:
throw new IllegalArgumentException("format invalid: "+toHexString(format));
- }
+ }
}
};
-
+
/** immutable type [{@link #COLOR}, {@link #DEPTH}, {@link #STENCIL}, {@link #COLOR_TEXTURE}, {@link #DEPTH_TEXTURE}, {@link #STENCIL_TEXTURE} ] */
public final Type type;
-
+
/** immutable the internal format */
public final int format;
-
+
private int width, height;
-
+
private int name;
-
+
protected Attachment(Type type, int iFormat, int width, int height, int name) {
this.type = type;
this.format = iFormat;
@@ -141,18 +141,18 @@ public class FBObject {
this.height = height;
this.name = name;
}
-
+
/**
* Writes the internal format to the given GLCapabilities object.
* @param caps the destination for format bits
* @param rgba8Avail whether rgba8 is available
*/
- public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) {
+ public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) {
final int _format;
switch(format) {
case GL.GL_RGBA:
case 4:
- _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4;
+ _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4;
break;
case GL.GL_RGB:
case 3:
@@ -191,7 +191,7 @@ public class FBObject {
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setAlphaBits(8);
- break;
+ break;
case GL.GL_DEPTH_COMPONENT16:
caps.setDepthBits(16);
break;
@@ -218,18 +218,18 @@ public class FBObject {
throw new IllegalArgumentException("format invalid: "+toHexString(format));
}
}
-
+
/** width of attachment */
public final int getWidth() { return width; }
/** height of attachment */
public final int getHeight() { return height; }
/* pp */ final void setSize(int w, int h) { width = w; height = h; }
-
+
/** buffer name [1..max], maybe a texture or renderbuffer name, depending on type. */
- public final int getName() { return name; }
+ public final int getName() { return name; }
/* pp */ final void setName(int n) { name = n; }
-
- /**
+
+ /**
* Initializes the attachment and set it's parameter, if uninitialized, i.e. name is zero
.
*
final boolean init = 0 == name;
@@ -239,11 +239,11 @@ public class FBObject {
return init;
*
* @return true
if newly initialized, otherwise false
.
- * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case.
+ * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case.
*/
public abstract boolean initialize(GL gl) throws GLException;
-
- /**
+
+ /**
* Releases the attachment if initialized, i.e. name is not zero
.
*
if(0 != name) {
@@ -251,10 +251,10 @@ public class FBObject {
name = 0;
}
*
- * @throws GLException if buffer release fails.
+ * @throws GLException if buffer release fails.
*/
public abstract void free(GL gl) throws GLException;
-
+
/**
* zero
.
- * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case.
+ * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case.
*/
@Override
public boolean initialize(GL gl) throws GLException {
final boolean init = 0 == getName();
if( init ) {
checkPreGLError(gl);
-
- final int[] name = new int[] { -1 };
+
+ final int[] name = new int[] { -1 };
gl.glGenTextures(1, name, 0);
if(0 == name[0]) {
throw new GLException("null texture, "+this);
}
setName(name[0]);
-
+
gl.glBindTexture(GL.GL_TEXTURE_2D, name[0]);
if( 0 < magFilter ) {
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, magFilter);
@@ -495,7 +495,7 @@ public class FBObject {
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, wrapS);
}
if( 0 < wrapT ) {
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT);
}
boolean preTexImage2D = true;
int glerr = gl.glGetError();
@@ -534,50 +534,50 @@ public class FBObject {
"; min/mag "+toHexString(minFilter)+"/"+toHexString(magFilter)+
", wrap S/T "+toHexString(wrapS)+"/"+toHexString(wrapT)+
"; name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]";
- }
+ }
}
static String toHexString(int v) {
return "0x"+Integer.toHexString(v);
}
-
+
/**
- * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE},
+ * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE},
* selecting the texture data type and format automatically.
- *
+ *
* true
if you request alpha channel, otherwise false
;
- * @param width texture width
+ * @param width texture width
* @param height texture height
* @return the created and uninitialized color {@link TextureAttachment}
*/
public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height) {
return createColorTextureAttachment(glp, alpha, width, height, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
}
-
+
/**
- * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE},
+ * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE},
* selecting the texture data type and format automatically.
- *
+ *
* @param glp the chosen {@link GLProfile}
* @param alpha set to true
if you request alpha channel, otherwise false
;
- * @param width texture width
+ * @param width texture width
* @param height texture height
* @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER}
- * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
+ * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
* @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S}
* @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T}
* @return the created and uninitialized color {@link TextureAttachment}
*/
- public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height,
+ public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height,
int magFilter, int minFilter, int wrapS, int wrapT) {
final int textureInternalFormat, textureDataFormat, textureDataType;
- if(glp.isGLES()) {
+ if(glp.isGLES()) {
textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
textureDataType = GL.GL_UNSIGNED_BYTE;
- } else {
+ } else {
textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8;
// textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
// textureInternalFormat = alpha ? 4 : 3;
@@ -586,27 +586,27 @@ public class FBObject {
}
return createColorTextureAttachment(textureInternalFormat, width, height, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT);
}
-
+
/**
- * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}.
+ * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}.
*
* @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)}
- * @param width texture width
+ * @param width texture width
* @param height texture height
* @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)}
* @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)}
* @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER}
- * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
+ * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
* @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S}
* @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T}
* @return the created and uninitialized color {@link TextureAttachment}
*/
public static final TextureAttachment createColorTextureAttachment(int internalFormat, int width, int height, int dataFormat, int dataType,
int magFilter, int minFilter, int wrapS, int wrapT) {
- return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType,
+ return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType,
magFilter, minFilter, wrapS, wrapT, 0 /* name */);
}
-
+
private static boolean hasAlpha(int format) {
switch(format) {
case GL.GL_RGBA8:
@@ -619,7 +619,7 @@ public class FBObject {
return false;
}
}
-
+
private boolean initialized;
private boolean fullFBOSupport;
private boolean rgba8Avail;
@@ -629,7 +629,7 @@ public class FBObject {
private boolean stencil04Avail;
private boolean stencil08Avail;
private boolean stencil16Avail;
- private boolean packedDepthStencilAvail;
+ private boolean packedDepthStencilAvail;
private int maxColorAttachments, maxSamples, maxTextureSize, maxRenderbufferSize;
private int width, height, samples;
@@ -639,21 +639,21 @@ public class FBObject {
private boolean bound;
private int colorAttachmentCount;
- private Colorbuffer[] colorAttachmentPoints; // colorbuffer attachment points
+ private Colorbuffer[] colorAttachmentPoints; // colorbuffer attachment points
private RenderAttachment depth, stencil; // depth and stencil maybe equal in case of packed-depth-stencil
private FBObject samplingSink; // MSAA sink
- private TextureAttachment samplingSinkTexture;
+ private TextureAttachment samplingSinkTexture;
private boolean samplingSinkDirty;
//
// ColorAttachment helper ..
//
-
+
private final void validateColorAttachmentPointRange(int point) {
if(!initialized) {
throw new GLException("FBO not initialized");
- }
+ }
if(maxColorAttachments != colorAttachmentPoints.length) {
throw new InternalError("maxColorAttachments "+maxColorAttachments+", array.lenght "+colorAttachmentPoints);
}
@@ -661,14 +661,14 @@ public class FBObject {
throw new IllegalArgumentException("attachment point out of range: "+point+", should be within [0.."+(maxColorAttachments-1)+"], "+this);
}
}
-
+
private final void validateAddColorAttachment(int point, Colorbuffer ca) {
validateColorAttachmentPointRange(point);
if( null != colorAttachmentPoints[point] ) {
throw new IllegalArgumentException("Cannot attach "+ca+", attachment point already in use by "+colorAttachmentPoints[point]+", "+this);
- }
+ }
}
-
+
private final void addColorAttachment(int point, Colorbuffer ca) {
validateColorAttachmentPointRange(point);
final Colorbuffer c = colorAttachmentPoints[point];
@@ -678,7 +678,7 @@ public class FBObject {
colorAttachmentPoints[point] = ca;
colorAttachmentCount++;
}
-
+
private final void removeColorAttachment(int point, Colorbuffer ca) {
validateColorAttachmentPointRange(point);
final Colorbuffer c = colorAttachmentPoints[point];
@@ -688,20 +688,20 @@ public class FBObject {
colorAttachmentPoints[point] = null;
colorAttachmentCount--;
}
-
+
/**
* Return the {@link Colorbuffer} attachment at attachmentPoint
if it is attached to this FBO, otherwise null.
- *
+ *
* @see #attachColorbuffer(GL, boolean)
* @see #attachColorbuffer(GL, boolean)
* @see #attachTexture2D(GL, int, boolean, int, int, int, int)
- * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int)
+ * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int)
*/
public final Colorbuffer getColorbuffer(int attachmentPoint) {
- validateColorAttachmentPointRange(attachmentPoint);
+ validateColorAttachmentPointRange(attachmentPoint);
return colorAttachmentPoints[attachmentPoint];
}
-
+
/**
* Finds the passed {@link Colorbuffer} within the valid range of attachment points
* using reference comparison only.
@@ -709,36 +709,36 @@ public class FBObject {
* Note: Slow. Implementation uses a logN array search to save resources, i.e. not using a HashMap.
*
* Note: Slow. Uses {@link #getColorbufferAttachmentPoint(Colorbuffer)} to determine it's attachment point * to be used for {@link #getColorbuffer(int)} *
- * + * * @see #attachColorbuffer(GL, boolean) * @see #attachColorbuffer(GL, boolean) * @see #attachTexture2D(GL, int, boolean, int, int, int, int) - * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) + * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) */ public final Colorbuffer getColorbuffer(Colorbuffer ca) { final int p = getColorbufferAttachmentPoint(ca); return p>=0 ? getColorbuffer(p) : null; } - + /** * Creates an uninitialized FBObject instance. *@@ -747,7 +747,7 @@ public class FBObject { */ public FBObject() { this.initialized = false; - + // TBD @ init this.fullFBOSupport = false; this.rgba8Avail = false; @@ -762,7 +762,7 @@ public class FBObject { this.maxSamples=-1; this.maxTextureSize = 0; this.maxRenderbufferSize = 0; - + this.width = 0; this.height = 0; this.samples = 0; @@ -770,17 +770,17 @@ public class FBObject { this.ignoreStatus = false; this.fbName = 0; this.bound = false; - + this.colorAttachmentPoints = null; // at init .. this.colorAttachmentCount = 0; this.depth = null; - this.stencil = null; - + this.stencil = null; + this.samplingSink = null; this.samplingSinkTexture = null; this.samplingSinkDirty = true; } - + private void init(GL gl, int width, int height, int samples) throws GLException { if(initialized) { throw new GLException("FBO already initialized"); @@ -788,8 +788,8 @@ public class FBObject { if( !gl.hasBasicFBOSupport() ) { throw new GLException("FBO not supported w/ context: "+gl.getContext()+", "+this); } - fullFBOSupport = gl.hasFullFBOSupport(); - + fullFBOSupport = gl.hasFullFBOSupport(); + rgba8Avail = gl.isGL2GL3() || gl.isExtensionAvailable(GLExtensions.OES_rgb8_rgba8); depth24Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth24); depth32Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth32); @@ -797,15 +797,15 @@ public class FBObject { stencil04Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_stencil4); stencil08Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_stencil8); stencil16Avail = fullFBOSupport; - + packedDepthStencilAvail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_packed_depth_stencil) || gl.isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) ; - + final boolean NV_fbo_color_attachments = gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments); - + int val[] = new int[1]; - + checkPreGLError(gl); int realMaxColorAttachments = 1; @@ -818,24 +818,24 @@ public class FBObject { } catch (GLException gle) { gle.printStackTrace(); } } maxColorAttachments = realMaxColorAttachments <= 8 ? realMaxColorAttachments : 8; // cap to limit array size - + colorAttachmentPoints = new Colorbuffer[maxColorAttachments]; colorAttachmentCount = 0; - + maxSamples = gl.getMaxRenderbufferSamples(); gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); maxTextureSize = val[0]; gl.glGetIntegerv(GL.GL_MAX_RENDERBUFFER_SIZE, val, 0); maxRenderbufferSize = val[0]; - + checkPreGLError(gl); - + if( 0 >= width ) { width = 1; } if( 0 >= height ) { height = 1; } this.width = width; this.height = height; this.samples = samples <= maxSamples ? samples : maxSamples; - + if(DEBUG) { System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+this.samples+" samples"); System.err.println("fullFBOSupport: "+fullFBOSupport); @@ -856,16 +856,16 @@ public class FBObject { System.err.println(JoglVersion.getGLStrings(gl, null).toString()); System.err.println(gl.getContext()); } - + checkNoError(null, gl.glGetError(), "FBObject Init.pre"); // throws GLException if error - + if(width > 2 + maxTextureSize || height> 2 + maxTextureSize || width > maxRenderbufferSize || height> maxRenderbufferSize ) { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } resetSamplingSink(gl); - + // generate fbo .. gl.glGenFramebuffers(1, val, 0); fbName = val[0]; @@ -874,15 +874,15 @@ public class FBObject { } // bind fbo .. - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbName); - checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbName); + checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error if(!gl.glIsFramebuffer(fbName)) { checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException } bound = true; samplingSinkDirty = true; initialized = true; - + vStatus = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; // always incomplete w/o attachments! if(DEBUG) { System.err.println("FBObject.init(): "+this); @@ -900,9 +900,9 @@ public class FBObject { * Incompatibility and hence recreation is forced if * the size or sample count doesn't match for subsequent calls. *
- * + * *Leaves the FBO bound state untouched
- * + * * @param gl the current GL context * @param newWidth * @param newHeight @@ -911,7 +911,7 @@ public class FBObject { public final void reset(GL gl, int newWidth, int newHeight) { reset(gl, newWidth, newHeight, 0, false); } - + /** * Initializes or resets this FBO's instance. *@@ -920,21 +920,21 @@ public class FBObject { * to match the new given parameters. *
*- * Currently incompatibility and hence recreation of the attachments will be performed + * Currently incompatibility and hence recreation of the attachments will be performed * if the size or sample count doesn't match for subsequent calls. *
- * + * *Leaves the FBO bound state untouched
- * + * * @param gl the current GL context * @param newWidth the new width, it's minimum is capped to 1 * @param newHeight the new height, it's minimum is capped to 1 * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}. - * @param resetSamplingSinktrue
calls {@link #resetSamplingSink(GL)} immediatly.
+ * @param resetSamplingSink true
calls {@link #resetSamplingSink(GL)} immediatly.
* false
postpones resetting the sampling sink until {@link #use(GL, TextureAttachment)} or {@link #syncSamplingSink(GL)},
- * allowing to use the samples sink's FBO and texture until then. The latter is useful to benefit
- * from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer.
- *
+ * allowing to use the samples sink's FBO and texture until then. The latter is useful to benefit
+ * from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer.
+ *
* @throws GLException in case of an error, i.e. size too big, etc ..
*/
public final void reset(GL gl, int newWidth, int newHeight, int newSamples, boolean resetSamplingSink) {
@@ -942,9 +942,9 @@ public class FBObject {
init(gl, newWidth, newHeight, newSamples);
return;
}
-
+
newSamples = newSamples <= maxSamples ? newSamples : maxSamples; // clamp
-
+
if( newWidth != width || newHeight != height || newSamples != samples ) {
if( 0 >= newWidth ) { newWidth = 1; }
if( 0 >= newHeight ) { newHeight = 1; }
@@ -952,39 +952,39 @@ public class FBObject {
newWidth > maxRenderbufferSize || newHeight > maxRenderbufferSize ) {
throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]");
}
-
+
if(DEBUG) {
System.err.println("FBObject.reset - START - "+width+"x"+height+", "+samples+" -> "+newWidth+"x"+newHeight+", "+newSamples+"; "+this);
- }
-
+ }
+
final boolean wasBound = isBound();
-
+
width = newWidth;
height = newHeight;
samples = newSamples;
-
+
if(0 < samples && null == samplingSink ) {
// needs valid samplingSink for detach*() -> bind()
samplingSink = new FBObject();
samplingSink.init(gl, width, height, 0);
}
- detachAllImpl(gl, true , true);
+ detachAllImpl(gl, true , true);
if(resetSamplingSink) {
resetSamplingSink(gl);
}
-
+
samplingSinkDirty = true;
if(!wasBound) {
unbind(gl);
}
-
+
if(DEBUG) {
System.err.println("FBObject.reset - END - "+this);
}
- }
+ }
}
-
+
/**
* Writes the internal format of the attachments to the given GLCapabilities object.
* @param caps the destination for format bits
@@ -994,11 +994,11 @@ public class FBObject {
caps.setNumSamples(samples);
caps.setDepthBits(0);
caps.setStencilBits(0);
-
+
final Colorbuffer cb = samples > 0 ? getSamplingSink() : getColorbuffer(0);
if(null != cb) {
cb.formatToGLCapabilities(caps, rgba8Avail);
- }
+ }
if(null != depth) {
depth.formatToGLCapabilities(caps, rgba8Avail);
}
@@ -1006,11 +1006,11 @@ public class FBObject {
stencil.formatToGLCapabilities(caps, rgba8Avail);
}
}
-
- /**
+
+ /**
* Note that the status may reflect an incomplete state during transition of attachments.
* @return The FB status. {@link GL.GL_FRAMEBUFFER_COMPLETE} if ok, otherwise return GL FBO error state or -1
- * @see #validateStatus()
+ * @see #validateStatus()
*/
public final int getStatus() {
return vStatus;
@@ -1020,15 +1020,15 @@ public class FBObject {
public final String getStatusString() {
return getStatusString(vStatus);
}
-
+
public static final String getStatusString(int fbStatus) {
switch(fbStatus) {
case -1:
return "NOT A FBO";
-
+
case GL.GL_FRAMEBUFFER_COMPLETE:
return "OK";
-
+
case GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
return("FBO incomplete attachment\n");
case GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
@@ -1043,21 +1043,21 @@ public class FBObject {
return("FBO missing read buffer");
case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
return("FBO missing multisample buffer");
- case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
+ case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
return("FBO missing layer targets");
-
+
case GL.GL_FRAMEBUFFER_UNSUPPORTED:
return("Unsupported FBO format");
case GL2GL3.GL_FRAMEBUFFER_UNDEFINED:
return("FBO undefined");
-
+
case 0:
return("FBO implementation fault");
default:
return("FBO incomplete, implementation ERROR "+toHexString(fbStatus));
}
}
-
+
/**
* The status may even be valid if incomplete during transition of attachments.
* @see #getStatus()
@@ -1066,7 +1066,7 @@ public class FBObject {
switch(vStatus) {
case GL.GL_FRAMEBUFFER_COMPLETE:
return true;
-
+
case GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
case GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
case GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
@@ -1079,29 +1079,29 @@ public class FBObject {
// we are in transition
return true;
}
-
+
case GL.GL_FRAMEBUFFER_UNSUPPORTED:
case GL2GL3.GL_FRAMEBUFFER_UNDEFINED:
-
- case 0:
+
+ case 0:
default:
if(DEBUG) {
- System.err.println("Framebuffer " + fbName + " is incomplete, status = " + toHexString(vStatus) +
+ System.err.println("Framebuffer " + fbName + " is incomplete, status = " + toHexString(vStatus) +
" : " + getStatusString(vStatus));
}
return false;
}
}
-
+
private static int checkPreGLError(GL gl) {
int glerr = gl.glGetError();
if(DEBUG && GL.GL_NO_ERROR != glerr) {
System.err.println("Pre-existing GL error: "+toHexString(glerr));
Thread.dumpStack();
}
- return glerr;
+ return glerr;
}
-
+
private final boolean checkNoError(GL gl, int err, String exceptionMessage) throws GLException {
if(GL.GL_NO_ERROR != err) {
if(null != gl) {
@@ -1118,17 +1118,17 @@ public class FBObject {
private final void checkInitialized() throws GLException {
if(!initialized) {
throw new GLException("FBO not initialized, call init(GL) first.");
- }
+ }
}
-
+
/**
* Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point,
* selecting the texture data type and format automatically.
- *
+ *
* Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.
- * + * *Leaves the FBO bound.
- * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set totrue
if you request alpha channel, otherwise false
;
@@ -1140,18 +1140,18 @@ public class FBObject {
return (TextureAttachment)attachColorbuffer(gl, attachmentPoint,
createColorTextureAttachment(gl.getGLProfile(), alpha, width, height));
}
-
+
/**
* Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point,
* selecting the texture data type and format automatically.
- *
+ *
* Leaves the FBO bound.
- * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set totrue
if you request alpha channel, otherwise false
;
* @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER}
- * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
+ * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER}
* @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S}
* @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T}
* @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown
@@ -1162,19 +1162,19 @@ public class FBObject {
return (TextureAttachment)attachColorbuffer(gl, attachmentPoint,
createColorTextureAttachment(gl.getGLProfile(), alpha, width, height, magFilter, minFilter, wrapS, wrapT));
}
-
+
/**
* Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point.
- *
+ *
* Leaves the FBO bound.
- * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} - * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown @@ -1187,10 +1187,10 @@ public class FBObject { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT)); } - + /** * Creates a {@link ColorAttachment}, selecting the format automatically. - * + * * @param alpha set totrue
if you request alpha channel, otherwise false
;
* @return uninitialized ColorAttachment instance describing the new attached colorbuffer
*/
@@ -1203,13 +1203,13 @@ public class FBObject {
}
return new ColorAttachment(internalFormat, samples, width, height, 0);
}
-
+
/**
* Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point,
* selecting the format automatically.
- *
+ *
* Leaves the FBO bound.
- * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set totrue
if you request alpha channel, otherwise false
;
@@ -1220,15 +1220,15 @@ public class FBObject {
public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, boolean alpha) throws GLException {
return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, createColorAttachment(alpha));
}
-
+
/**
* Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point.
- *
+ *
* Leaves the FBO bound.
- * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param internalFormat usually {@link GL#GL_RGBA4}, {@link GL#GL_RGB5_A1}, {@link GL#GL_RGB565}, {@link GL#GL_RGB8} or {@link GL#GL_RGBA8} + * @param internalFormat usually {@link GL#GL_RGBA4}, {@link GL#GL_RGB5_A1}, {@link GL#GL_RGB565}, {@link GL#GL_RGB8} or {@link GL#GL_RGBA8} * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the colorbuffer couldn't be allocated * @throws IllegalArgumentException ifinternalFormat
doesn't reflect a colorbuffer
@@ -1238,28 +1238,28 @@ public class FBObject {
if( Attachment.Type.COLOR != atype ) {
throw new IllegalArgumentException("colorformat invalid: "+toHexString(internalFormat)+", "+this);
}
-
+
return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0));
}
-
+
/**
- * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment},
+ * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment},
* to this FBO's instance at the given attachment point.
- *
+ *
*
* If {@link Colorbuffer} is a {@link TextureAttachment} and is uninitialized, i.e. it's texture name is zero
,
* a new texture name is generated and setup w/ the texture parameter.
* Otherwise, i.e. texture name is not zero
, the passed TextureAttachment texA
is
- * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue.
+ * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue.
*
Leaves the FBO bound.
- * + * * @param gl * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param colbuf the to be attached {@link Colorbuffer} + * @param colbuf the to be attached {@link Colorbuffer} * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} + * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} */ public final Colorbuffer attachColorbuffer(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { bind(gl); @@ -1268,13 +1268,13 @@ public class FBObject { private final Colorbuffer attachColorbufferImpl(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { validateAddColorAttachment(attachmentPoint, colbuf); - + final boolean initializedColorbuf = colbuf.initialize(gl); addColorAttachment(attachmentPoint, colbuf); - + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; - + if(samples>0) { removeColorAttachment(attachmentPoint, texA); if(initializedColorbuf) { @@ -1282,14 +1282,14 @@ public class FBObject { } throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); } - + // Set up the color buffer for use as a renderable texture: gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, GL.GL_TEXTURE_2D, texA.getName(), 0); - + if(!ignoreStatus) { - updateStatus(gl); + updateStatus(gl); if(!isStatusValid()) { detachColorbuffer(gl, attachmentPoint, true); throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); @@ -1297,12 +1297,12 @@ public class FBObject { } } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; - + // Attach the color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, GL.GL_RENDERBUFFER, colA.getName()); - + if(!ignoreStatus) { updateStatus(gl); if(!isStatusValid()) { @@ -1316,7 +1316,7 @@ public class FBObject { } return colbuf; } - + /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, * selecting the internalFormat automatically. @@ -1325,30 +1325,30 @@ public class FBObject { * ** In case the desired type or bit-number is not supported, the next available one is chosen. - *
+ * ** Use {@link #getDepthAttachment()} and/or {@link #getStencilAttachment()} to retrieve details * about the attached buffer. The details cannot be returned, since it's possible 2 buffers * are being created, depth and stencil. *
- * + * *Leaves the FBO bound.
- * + * * @param gl - * @param atype either {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#DEPTH_STENCIL} + * @param atype either {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#DEPTH_STENCIL} * @param reqBits desired bits for depth or -1 for default (24 bits) * @throws GLException in case the renderbuffer couldn't be allocated or one is already attached. * @throws IllegalArgumentException * @see #getDepthAttachment() * @see #getStencilAttachment() */ - public final void attachRenderbuffer(GL gl, Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { + public final void attachRenderbuffer(GL gl, Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { if( 0 > reqBits ) { reqBits = 24; - } + } final int internalFormat; int internalStencilFormat = -1; - + switch ( atype ) { case DEPTH: if( 32 <= reqBits && depth32Avail ) { @@ -1356,10 +1356,10 @@ public class FBObject { } else if( 24 <= reqBits && depth24Avail ) { internalFormat = GL.GL_DEPTH_COMPONENT24; } else { - internalFormat = GL.GL_DEPTH_COMPONENT16; + internalFormat = GL.GL_DEPTH_COMPONENT16; } break; - + case STENCIL: if( 16 <= reqBits && stencil16Avail ) { internalFormat = GL2GL3.GL_STENCIL_INDEX16; @@ -1370,10 +1370,10 @@ public class FBObject { } else if( 1 <= reqBits && stencil01Avail ) { internalFormat = GL.GL_STENCIL_INDEX1; } else { - throw new GLException("stencil buffer n/a"); + throw new GLException("stencil buffer n/a"); } break; - + case DEPTH_STENCIL: if( packedDepthStencilAvail ) { internalFormat = GL.GL_DEPTH24_STENCIL8; @@ -1381,7 +1381,7 @@ public class FBObject { if( 24 <= reqBits && depth24Avail ) { internalFormat = GL.GL_DEPTH_COMPONENT24; } else { - internalFormat = GL.GL_DEPTH_COMPONENT16; + internalFormat = GL.GL_DEPTH_COMPONENT16; } if( stencil08Avail ) { internalStencilFormat = GL.GL_STENCIL_INDEX8; @@ -1397,17 +1397,17 @@ public class FBObject { default: throw new IllegalArgumentException("only depth/stencil types allowed, was "+atype+", "+this); } - + attachRenderbufferImpl(gl, atype, internalFormat); - + if(0<=internalStencilFormat) { attachRenderbufferImpl(gl, Attachment.Type.STENCIL, internalStencilFormat); } } - + /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, - * depending on theinternalFormat
.
+ * depending on the internalFormat
.
* * Stencil and depth buffer can be attached only once. *
@@ -1416,9 +1416,9 @@ public class FBObject { * about the attached buffer. The details cannot be returned, since it's possible 2 buffers * are being created, depth and stencil. * - * + * *Leaves the FBO bound.
- * + * * @param gl the current GL context * @param internalFormat {@link GL#GL_DEPTH_COMPONENT16}, {@link GL#GL_DEPTH_COMPONENT24}, {@link GL#GL_DEPTH_COMPONENT32}, * {@link GL#GL_STENCIL_INDEX1}, {@link GL#GL_STENCIL_INDEX4}, {@link GL#GL_STENCIL_INDEX8} @@ -1435,19 +1435,19 @@ public class FBObject { } attachRenderbufferImpl(gl, atype, internalFormat); } - + protected final void attachRenderbufferImpl(GL gl, Attachment.Type atype, int internalFormat) throws GLException { if( null != depth && ( Attachment.Type.DEPTH == atype || Attachment.Type.DEPTH_STENCIL == atype ) ) { throw new GLException("FBO depth buffer already attached (rb "+depth+"), type is "+atype+", "+toHexString(internalFormat)+", "+this); - } + } if( null != stencil && ( Attachment.Type.STENCIL== atype || Attachment.Type.DEPTH_STENCIL == atype ) ) { throw new GLException("FBO stencil buffer already attached (rb "+stencil+"), type is "+atype+", "+toHexString(internalFormat)+", "+this); } bind(gl); - + attachRenderbufferImpl2(gl, atype, internalFormat); } - + private final void attachRenderbufferImpl2(GL gl, Attachment.Type atype, int internalFormat) throws GLException { if( Attachment.Type.DEPTH == atype ) { if(null == depth) { @@ -1486,10 +1486,10 @@ public class FBObject { } else if( Attachment.Type.STENCIL == atype ) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, stencil.getName()); } else if( Attachment.Type.DEPTH_STENCIL == atype ) { - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, depth.getName()); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, depth.getName()); gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, stencil.getName()); } - + if(!ignoreStatus) { updateStatus(gl); if( !isStatusValid() ) { @@ -1500,13 +1500,13 @@ public class FBObject { if(DEBUG) { System.err.println("FBObject.attachRenderbuffer.X: [attachmentType "+atype+", iformat "+toHexString(internalFormat)+"]: "+this); - } + } } - + /** - * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. + * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. *Leaves the FBO bound!
- * + * * @param gl * @param attachmentPoint * @param dispose true if the Colorbuffer shall be disposed @@ -1515,26 +1515,26 @@ public class FBObject { */ public final Colorbuffer detachColorbuffer(GL gl, int attachmentPoint, boolean dispose) throws IllegalArgumentException { bind(gl); - + final Colorbuffer res = detachColorbufferImpl(gl, attachmentPoint, dispose ? DetachAction.DISPOSE : DetachAction.NONE); if(null == res) { - throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); + throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); } if(DEBUG) { System.err.println("FBObject.detachColorbuffer.X: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this); } return res; } - + private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, DetachAction detachAction) { Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here - + if(null == colbuf) { return null; } - + removeColorAttachment(attachmentPoint, colbuf); - + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; if( 0 != texA.getName() ) { @@ -1553,7 +1553,7 @@ public class FBObject { if(DetachAction.RECREATE == detachAction) { if(samples == 0) { // stay non MSAA - texA.setSize(width, height); + texA.setSize(width, height); } else { // switch to MSAA colbuf = createColorAttachment(hasAlpha(texA.format)); @@ -1563,8 +1563,8 @@ public class FBObject { } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; if( 0 != colA.getName() ) { - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0+attachmentPoint, + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0+attachmentPoint, GL.GL_RENDERBUFFER, 0); switch(detachAction) { case DISPOSE: @@ -1582,9 +1582,9 @@ public class FBObject { } else { // switch to non MSAA if(null != samplingSinkTexture) { - colbuf = createColorTextureAttachment(samplingSinkTexture.format, width, height, - samplingSinkTexture.dataFormat, samplingSinkTexture.dataType, - samplingSinkTexture.magFilter, samplingSinkTexture.minFilter, + colbuf = createColorTextureAttachment(samplingSinkTexture.format, width, height, + samplingSinkTexture.dataFormat, samplingSinkTexture.dataType, + samplingSinkTexture.magFilter, samplingSinkTexture.minFilter, samplingSinkTexture.wrapS, samplingSinkTexture.wrapT); } else { colbuf = createColorTextureAttachment(gl.getGLProfile(), true, width, height); @@ -1595,15 +1595,15 @@ public class FBObject { } return colbuf; } - + private final void freeAllColorbufferImpl(GL gl) { for(int i=0; i* An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *
+ * * @param gl the current GL context */ public final void detachAll(GL gl) { if(null != samplingSink) { samplingSink.detachAll(gl); - } + } detachAllImpl(gl, true/* detachNonColorbuffer */, false /* recreate */); } - - /** - * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s + + /** + * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s * and disposes them. *Leaves the FBO bound, if initialized!
** An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *
+ * * @param gl the current GL context */ public final void detachAllColorbuffer(GL gl) { if(null != samplingSink) { samplingSink.detachAllColorbuffer(gl); - } + } detachAllImpl(gl, false/* detachNonColorbuffer */, false /* recreate */); } - - /** + + /** * Detaches all {@link TextureAttachment}s and disposes them. *Leaves the FBO bound, if initialized!
** An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *
+ * * @param gl the current GL context */ public final void detachAllTexturebuffer(GL gl) { @@ -1826,7 +1826,7 @@ public class FBObject { if(null != samplingSink) { samplingSink.detachAllTexturebuffer(gl); } - bind(gl); + bind(gl); for(int i=0; i@@ -1948,7 +1948,7 @@ public class FBObject { * a new sampling sink is being created. *
*- * Automatically called by {@link #reset(GL, int, int, int, boolean)} + * Automatically called by {@link #reset(GL, int, int, int, boolean)} * and {@link #syncSamplingSink(GL)}. *
*@@ -1967,58 +1967,58 @@ public class FBObject { } return; } - + if(null == samplingSink ) { samplingSink = new FBObject(); } - + if(!samplingSink.initialized) { samplingSink.init(gl, width, height, 0); } - + boolean sampleSinkSizeMismatch = sampleSinkSizeMismatch(); boolean sampleSinkTexMismatch = sampleSinkTexMismatch(); boolean sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); - + /** if(DEBUG) { System.err.println("FBObject.resetSamplingSink.0: \n\tTHIS "+this+",\n\tSINK "+samplesSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } */ - + if(!sampleSinkSizeMismatch && !sampleSinkTexMismatch && !sampleSinkDepthStencilMismatch) { - // all properties match .. - return; + // all properties match .. + return; } - + unbind(gl); - + if(DEBUG) { System.err.println("FBObject.resetSamplingSink: BEGIN\n\tTHIS "+this+",\n\tSINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } - + if( sampleSinkDepthStencilMismatch ) { samplingSink.detachAllRenderbuffer(gl); } - + if( sampleSinkSizeMismatch ) { samplingSink.reset(gl, width, height); } - + if(null == samplingSinkTexture) { samplingSinkTexture = samplingSink.attachTexture2D(gl, 0, true); } else if( 0 == samplingSinkTexture.getName() ) { samplingSinkTexture.setSize(width, height); samplingSink.attachColorbuffer(gl, 0, samplingSinkTexture); } - + if( sampleSinkDepthStencilMismatch ) { samplingSink.attachRenderbuffer(gl, depth.format); if( null != stencil && !isDepthStencilPackedFormat() ) { samplingSink.attachRenderbuffer(gl, stencil.format); } - } - + } + sampleSinkSizeMismatch = sampleSinkSizeMismatch(); sampleSinkTexMismatch = sampleSinkTexMismatch(); sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); @@ -2026,21 +2026,21 @@ public class FBObject { throw new InternalError("Samples sink mismatch after reset: \n\tTHIS "+this+",\n\t SINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } - + if(DEBUG) { System.err.println("FBObject.resetSamplingSink: END\n\tTHIS "+this+",\n\tSINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } } - + /** * Setting this FBO sampling sink. * @param newSamplingSink the new FBO sampling sink to use, or null to remove current sampling sink - * @return the previous sampling sink or null if none was attached + * @return the previous sampling sink or null if none was attached * @throws GLException if this FBO doesn't use MSAA or the given sink uses MSAA itself */ public FBObject setSamplingSink(FBObject newSamplingSink) throws GLException { - final FBObject prev = samplingSink; + final FBObject prev = samplingSink; if( null == newSamplingSink) { samplingSink = null; samplingSinkTexture = null; @@ -2056,14 +2056,14 @@ public class FBObject { samplingSinkDirty = true; return prev; } - - /** + + /** * Bind this FBO, i.e. bind write framebuffer to {@link #getWriteFramebuffer()}. - * - *
If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}, + * + *
If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}, * if full FBO is supported.
- * - *+ * + *
* In case you have attached more than one color buffer, * you may want to setup {@link GL2GL3#glDrawBuffers(int, int[], int)}. *
@@ -2079,7 +2079,7 @@ public class FBObject { gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, getReadFramebuffer()); } else { // one for all - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); } bound = true; @@ -2087,29 +2087,29 @@ public class FBObject { } } - /** + /** * Unbind this FBO, i.e. bind read and write framebuffer to default, see {@link GLBase#getDefaultDrawFramebuffer()}. - * - *If full FBO is supported, sets the read and write framebuffer individually to default, hence not disturbing + * + *
If full FBO is supported, sets the read and write framebuffer individually to default, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()}
- * + * * @param gl the current GL context * @throws GLException */ public final void unbind(GL gl) throws GLException { if(bound) { if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of + // default read/draw buffers, may utilize GLContext/GLDrawable override of // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } bound = false; } } - + /** * Method simply marks this FBO unbound w/o interfering w/ the bound framebuffer as perfomed by {@link #unbind(GL)}. *
@@ -2121,22 +2121,22 @@ public class FBObject {
bound = false;
}
- /**
+ /**
* Returns true
if framebuffer object is bound via {@link #bind(GL)}, otherwise false
.
*
* Method verifies the bound state via {@link GL#getBoundFramebuffer(int)}. *
* @param gl the current GL context */ - public final boolean isBound(GL gl) { + public final boolean isBound(GL gl) { bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER) ; return bound; } - + /** Returnstrue
if framebuffer object is bound via {@link #bind(GL)}, otherwise false
. */
public final boolean isBound() { return bound; }
-
- /**
+
+ /**
* If multisampling is being used and flagged dirty by a previous call of {@link #bind(GL)} or after initialization,
* the msaa-buffers are sampled to it's sink {@link #getSamplingSink()}.
* @@ -2147,7 +2147,7 @@ public class FBObject { *
** Method always resets the framebuffer binding to default in the end. - * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing + * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()} *
*@@ -2155,10 +2155,10 @@ public class FBObject { * you may want to call {@link GL#glBindFramebuffer(int, int) glBindFramebuffer}({@link GL2GL3#GL_READ_FRAMEBUFFER}, {@link #getReadFramebuffer()}); *
*Leaves the FBO unbound.
- * + * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} - * @throws IllegalArgumentException + * @throws IllegalArgumentException */ public final void syncSamplingSink(GL gl) { markUnbound(); @@ -2170,30 +2170,30 @@ public class FBObject { gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, samplingSink.getWriteFramebuffer()); ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2GL3 is OK GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); - checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error + checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error } if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of + // default read/draw buffers, may utilize GLContext/GLDrawable override of // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } } - - /** + + /** * Bind the given texture colorbuffer. - * + * *If using multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!
- * + * *{@link #syncSamplingSink(GL)} is being called
- * + * *Leaves the FBO unbound!
- * + * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} - * @throws IllegalArgumentException + * @throws IllegalArgumentException */ public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { if(null == ta) { throw new IllegalArgumentException("Null TextureAttachment, this: "+toString()); } @@ -2201,26 +2201,26 @@ public class FBObject { gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } - /** + /** * Unbind texture, ie bind 'non' texture 0 - * + * *Leaves the FBO unbound.
- */ + */ public final void unuse(GL gl) { unbind(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it } - /** @see GL#hasFullFBOSupport() */ + /** @see GL#hasFullFBOSupport() */ public final boolean hasFullFBOSupport() throws GLException { checkInitialized(); return this.fullFBOSupport; } - - /** + + /** * Returnstrue
if renderbuffer accepts internal format {@link GL#GL_RGB8} and {@link GL#GL_RGBA8}, otherwise false
.
* @throws GLException if {@link #init(GL)} hasn't been called.
*/
public final boolean supportsRGBA8() throws GLException { checkInitialized(); return rgba8Avail; }
-
- /**
+
+ /**
* Returns true
if {@link GL#GL_DEPTH_COMPONENT16}, {@link GL#GL_DEPTH_COMPONENT24} or {@link GL#GL_DEPTH_COMPONENT32} is supported, otherwise false
.
* @param bits 16, 24 or 32 bits
* @throws GLException if {@link #init(GL)} hasn't been called.
@@ -2228,14 +2228,14 @@ public class FBObject {
public final boolean supportsDepth(int bits) throws GLException {
checkInitialized();
switch(bits) {
- case 16: return true;
+ case 16: return true;
case 24: return depth24Avail;
case 32: return depth32Avail;
- default: return false;
+ default: return false;
}
}
-
- /**
+
+ /**
* Returns true
if {@link GL#GL_STENCIL_INDEX1}, {@link GL#GL_STENCIL_INDEX4}, {@link GL#GL_STENCIL_INDEX8} or {@link GL2GL3#GL_STENCIL_INDEX16} is supported, otherwise false
.
* @param bits 1, 4, 8 or 16 bits
* @throws GLException if {@link #init(GL)} hasn't been called.
@@ -2243,34 +2243,34 @@ public class FBObject {
public final boolean supportsStencil(int bits) throws GLException {
checkInitialized();
switch(bits) {
- case 1: return stencil01Avail;
+ case 1: return stencil01Avail;
case 4: return stencil04Avail;
case 8: return stencil08Avail;
case 16: return stencil16Avail;
- default: return false;
+ default: return false;
}
}
-
- /**
+
+ /**
* Returns true
if {@link GL#GL_DEPTH24_STENCIL8} is supported, otherwise false
.
* @throws GLException if {@link #init(GL)} hasn't been called.
*/
public final boolean supportsPackedDepthStencil() throws GLException { checkInitialized(); return packedDepthStencilAvail; }
-
+
/**
* Returns the maximum number of colorbuffer attachments.
* @throws GLException if {@link #init(GL)} hasn't been called.
*/
public final int getMaxColorAttachments() throws GLException { checkInitialized(); return maxColorAttachments; }
-
+
public final int getMaxTextureSize() throws GLException { checkInitialized(); return this.maxTextureSize; }
public final int getMaxRenderbufferSize() throws GLException { checkInitialized(); return this.maxRenderbufferSize; }
-
+
/** @see GL#getMaxRenderbufferSamples() */
public final int getMaxSamples() throws GLException { checkInitialized(); return this.maxSamples; }
-
+
/**
- * Returns true
if this instance has been initialized with {@link #reset(GL, int, int)}
+ * Returns true
if this instance has been initialized with {@link #reset(GL, int, int)}
* or {@link #reset(GL, int, int, int, boolean)}, otherwise false
*/
public final boolean isInitialized() { return initialized; }
@@ -2283,43 +2283,43 @@ public class FBObject {
/** Returns the framebuffer name to render to. */
public final int getWriteFramebuffer() { return fbName; }
/** Returns the framebuffer name to read from. Depending on multisampling, this may be a different framebuffer. */
- public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; }
- public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
+ public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; }
+ public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
/** Return the number of color/texture attachments */
public final int getColorAttachmentCount() { return colorAttachmentCount; }
- /** Return the stencil {@link RenderAttachment} attachment, if exist. Maybe share the same {@link Attachment#getName()} as {@link #getDepthAttachment()}, if packed depth-stencil is being used. */
+ /** Return the stencil {@link RenderAttachment} attachment, if exist. Maybe share the same {@link Attachment#getName()} as {@link #getDepthAttachment()}, if packed depth-stencil is being used. */
public final RenderAttachment getStencilAttachment() { return stencil; }
- /** Return the depth {@link RenderAttachment} attachment. Maybe share the same {@link Attachment#getName()} as {@link #getStencilAttachment()}, if packed depth-stencil is being used. */
+ /** Return the depth {@link RenderAttachment} attachment. Maybe share the same {@link Attachment#getName()} as {@link #getStencilAttachment()}, if packed depth-stencil is being used. */
public final RenderAttachment getDepthAttachment() { return depth; }
-
- /** Return the complete multisampling {@link FBObject} sink, if using multisampling. */
+
+ /** Return the complete multisampling {@link FBObject} sink, if using multisampling. */
public final FBObject getSamplingSinkFBO() { return samplingSink; }
-
- /** Return the multisampling {@link TextureAttachment} sink, if using multisampling. */
+
+ /** Return the multisampling {@link TextureAttachment} sink, if using multisampling. */
public final TextureAttachment getSamplingSink() { return samplingSinkTexture; }
- /**
- * Returns true
if the multisampling colorbuffer (msaa-buffer)
+ /**
+ * Returns true
if the multisampling colorbuffer (msaa-buffer)
* has been flagged dirty by a previous call of {@link #bind(GL)},
* otherwise false
.
*/
public final boolean isSamplingBufferDirty() { return samplingSinkDirty; }
-
+
int objectHashCode() { return super.hashCode(); }
-
+
public final String toString() {
- final String caps = null != colorAttachmentPoints ? Arrays.asList(colorAttachmentPoints).toString() : null ;
+ final String caps = null != colorAttachmentPoints ? Arrays.asList(colorAttachmentPoints).toString() : null ;
return "FBO[name r/w "+fbName+"/"+getReadFramebuffer()+", init "+initialized+", bound "+bound+", size "+width+"x"+height+
", samples "+samples+"/"+maxSamples+", depth "+depth+", stencil "+stencil+
", color attachments: "+colorAttachmentCount+"/"+maxColorAttachments+
": "+caps+", msaa-sink "+samplingSinkTexture+", hasSamplesSink "+(null != samplingSink)+
", state "+getStatusString()+", obj "+toHexString(objectHashCode())+"]";
}
-
+
private final void updateStatus(GL gl) {
if( 0 == fbName ) {
vStatus = -1;
} else {
vStatus = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
}
- }
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
index bec05a0bd..ce58d29c1 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,12 +20,12 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -58,14 +58,14 @@ import jogamp.opengl.GLDrawableImpl;
*
* and setup a {@link com.jogamp.newt.Window#setWindowDestroyNotifyAction(Runnable) custom toolkit destruction} issuing {@link #windowDestroyNotifyOp()}.
*
- * + *
* See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. *
*/ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. - * @param context a valid {@link GLContext}, + * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/drawable yet,
* may be null
for lazy initialization
@@ -84,7 +84,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto
this.upstreamWidget = upstreamWidget;
this.lock = ( null != lock ) ? lock : LockFactory.createRecursiveLock() ;
}
-
+
//
// expose default methods
//
@@ -93,40 +93,40 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto
public final void windowRepaintOp() {
super.defaultWindowRepaintOp();
}
-
+
/** Implementation to handle resize events from the windowing system. All required locks are being claimed. */
public final void windowResizedOp(int newWidth, int newHeight) {
super.defaultWindowResizedOp(newWidth, newHeight);
}
-
- /**
+
+ /**
* Implementation to handle destroy notifications from the windowing system.
- *
+ *
*
- * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol}
+ * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol}
* or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default),
* a thread safe destruction is being induced.
- *
+ *
*/
public final void windowDestroyNotifyOp() {
super.defaultWindowDestroyNotifyOp();
}
-
+
//
// Complete GLAutoDrawable
//
-
+
private Object upstreamWidget;
private final RecursiveLock lock;
-
+
@Override
protected final RecursiveLock getLock() { return lock; }
-
+
@Override
public final Object getUpstreamWidget() {
return upstreamWidget;
}
-
+
/**
* Set the upstream UI toolkit object.
* @see #getUpstreamWidget()
@@ -134,7 +134,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto
public final void setUpstreamWidget(Object newUpstreamWidget) {
upstreamWidget = newUpstreamWidget;
}
-
+
/**
* {@inheritDoc}
*
@@ -142,7 +142,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto
*
*
* User still needs to destroy the upstream window, which details are hidden from this aspect.
- * This can be performed by overriding {@link #destroyImplInLock()}.
+ * This can be performed by overriding {@link #destroyImplInLock()}.
*
*/
@Override
@@ -154,29 +154,29 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto
protected void destroyImplInLock() {
super.destroyImplInLock();
}
-
+
@Override
- public void display() {
+ public void display() {
defaultDisplay();
}
-
+
//
// GLDrawable delegation
//
-
+
@Override
public final GLDrawableFactory getFactory() {
return drawable.getFactory();
}
-
+
@Override
public final void swapBuffers() throws GLException {
defaultSwapBuffers();
}
-
+
@Override
public String toString() {
return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable +
", \n\tContext: " + context + ", \n\tUpstreamWidget: "+upstreamWidget+ /** ", \n\tFactory: "+factory+ */ "]";
- }
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java
index 21dafecb1..1b4187668 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,7 +20,7 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -48,7 +48,7 @@ import jogamp.opengl.Debug;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
/**
- * GLEventListenerState is holding {@link GLAutoDrawable} components crucial
+ * GLEventListenerState is holding {@link GLAutoDrawable} components crucial
* to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc.
* The components are:
*
@@ -69,8 +69,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration;
*/
public class GLEventListenerState {
private static final boolean DEBUG = Debug.debug("GLDrawable") || Debug.debug("GLEventListenerState");
-
- private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device,
+
+ private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device,
GLCapabilitiesImmutable caps,
GLContext context, int count, GLAnimatorControl anim, boolean animStarted) {
this.upstreamDevice = upstreamDevice;
@@ -82,19 +82,19 @@ public class GLEventListenerState {
this.listenersInit = new boolean[count];
this.anim = anim;
this.animStarted = animStarted;
-
+
this.owner = true;
}
/**
- * Returns true
, if this instance is the current owner of the components,
+ * Returns true
, if this instance is the current owner of the components,
* otherwise false
.
*
* Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully
- * and all components are transferred to the new {@link GLAutoDrawable}.
+ * and all components are transferred to the new {@link GLAutoDrawable}.
*
*/
public final boolean isOwner() { return owner; }
-
+
public final int listenerCount() { return listeners.length; }
public final AbstractGraphicsDevice upstreamDevice;
@@ -103,10 +103,10 @@ public class GLEventListenerState {
public final GLCapabilitiesImmutable caps;
public final GLContext context;
public final GLEventListener[] listeners;
- public final boolean[] listenersInit;
+ public final boolean[] listenersInit;
public final GLAnimatorControl anim;
public final boolean animStarted;
-
+
private boolean owner;
/**
@@ -127,25 +127,25 @@ public class GLEventListenerState {
private static AbstractGraphicsDevice cloneDevice(AbstractGraphicsDevice aDevice) {
return (AbstractGraphicsDevice) aDevice.clone();
}
-
+
/**
- * Moves all GLEventListenerState components from the given {@link GLAutoDrawable}
+ * Moves all GLEventListenerState components from the given {@link GLAutoDrawable}
* to a newly created instance.
*
* Note that all components are removed from the {@link GLAutoDrawable},
* i.e. the {@link GLContext}, all {@link GLEventListener}.
*
- *
+ *
* If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed
* and the {@link GLAnimatorControl} added to the GLEventListenerState.
*
*
- * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}.
+ * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}.
*
- *
+ *
* @param a {@link GLAutoDrawable} source to move components from
* @return new GLEventListenerState instance {@link #isOwner() owning} moved components.
- *
+ *
* @see #moveTo(GLAutoDrawable)
*/
public static GLEventListenerState moveFrom(GLAutoDrawable a) {
@@ -154,16 +154,16 @@ public class GLEventListenerState {
if( null != aAnim ) {
aAnimStarted = aAnim.isStarted();
aAnim.remove(a); // also handles ECT
- } else {
+ } else {
aAnimStarted = false;
}
-
+
final GLEventListenerState glls;
final NativeSurface aSurface = a.getNativeSurface();
final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface();
try {
final int aSz = a.getGLEventListenerCount();
-
+
// Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable
// allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device!
final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration();
@@ -171,7 +171,7 @@ public class GLEventListenerState {
final AbstractGraphicsDevice aDevice1 = aCfg.getScreen().getDevice();
final AbstractGraphicsDevice aDevice2 = cloneDevice(aDevice1);
aDevice1.clearHandleOwner(); // don't close device handle
- if( DEBUG ) {
+ if( DEBUG ) {
System.err.println("GLEventListenerState.moveFrom.0a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1);
System.err.println("GLEventListenerState.moveFrom.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2);
System.err.println("GLEventListenerState.moveFrom.1: "+aSurface.getClass().getName()/*+", "+aSurface*/);
@@ -203,9 +203,9 @@ public class GLEventListenerState {
}
aUpDevice2 = _aUpDevice2;
}
-
- glls = new GLEventListenerState(aUpDevice2, proxyOwnsUpstreamDevice, aDevice2, caps, a.getContext(), aSz, aAnim, aAnimStarted);
-
+
+ glls = new GLEventListenerState(aUpDevice2, proxyOwnsUpstreamDevice, aDevice2, caps, a.getContext(), aSz, aAnim, aAnimStarted);
+
//
// remove and cache all GLEventListener and their init-state
//
@@ -213,41 +213,41 @@ public class GLEventListenerState {
final GLEventListener l = a.getGLEventListener(0);
glls.listenersInit[i] = a.getGLEventListenerInitState(l);
glls.listeners[i] = a.removeGLEventListener( l );
- }
-
+ }
+
//
// trigger glFinish to sync GL ctx
//
a.invoke(true, glFinish);
-
+
a.setContext( null, false );
-
+
} finally {
if( surfaceLocked ) {
aSurface.unlockSurface();
}
- }
-
+ }
+
return glls;
}
/**
- * Moves all GLEventListenerState components to the given {@link GLAutoDrawable}
+ * Moves all GLEventListenerState components to the given {@link GLAutoDrawable}
* from this instance, while loosing {@link #isOwner() ownership}.
- *
+ *
* If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)},
* the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}.
- * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance.
+ * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance.
*
*
- * Note: After this operation, the GLEventListenerState reference should be released.
+ * Note: After this operation, the GLEventListenerState reference should be released.
*
- *
+ *
* @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to
- *
+ *
*
* @throws GLException if this preserved {@link AbstractGraphicsDevice} is incompatible w/ the given destination one.
- *
+ *
* @see #moveFrom(GLAutoDrawable)
* @see #isOwner()
*/
@@ -261,22 +261,22 @@ public class GLEventListenerState {
if( aPaused ) {
aAnim.resume();
}
- } else {
+ } else {
aPaused = false;
}
-
+
final List aGLCmds = new ArrayList();
final int aSz = listenerCount();
-
+
final NativeSurface aSurface = a.getNativeSurface();
final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface();
final boolean aRealized;
try {
-
+
final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration();
/**
final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities();
- if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ||
+ if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ||
caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) {
throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps);
} */
@@ -285,8 +285,8 @@ public class GLEventListenerState {
if( !aDevice1.getUniqueID().equals( aDevice2.getUniqueID() ) ) {
throw new GLException("Incompatible devices: Preserved <"+aDevice2.getUniqueID()+">, target <"+aDevice1.getUniqueID()+">");
}
-
- // collect optional upstream surface info
+
+ // collect optional upstream surface info
final ProxySurface aProxy;
final NativeSurface aUpSurface;
if(aSurface instanceof ProxySurface) {
@@ -302,8 +302,8 @@ public class GLEventListenerState {
}
if( null==aUpSurface && null != upstreamDevice ) {
throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false");
- }
-
+ }
+
// Destroy and remove currently associated GLContext, if any (will be replaced)
a.setContext( null, true );
aRealized = a.isRealized();
@@ -311,7 +311,7 @@ public class GLEventListenerState {
// Unrealize due to device dependencies of an upstream surface, e.g. EGLUpstreamSurfaceHook
a.getDelegatedDrawable().setRealized(false);
}
-
+
// Set new Screen and close previous one
{
if( DEBUG ) {
@@ -319,13 +319,13 @@ public class GLEventListenerState {
System.err.println("GLEventListenerState.moveTo.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2);
}
DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aDevice1, aDevice2);
- aDevice2.close();
+ aDevice2.close();
if( DEBUG ) {
System.err.println("GLEventListenerState.moveTo.1a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1);
System.err.println("GLEventListenerState.moveTo.1b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2);
}
}
-
+
// If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it
if( null != aUpSurface ) {
final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration();
@@ -339,9 +339,9 @@ public class GLEventListenerState {
System.err.println("GLEventListenerState.moveTo.2a: up-orig 0x"+Integer.toHexString(aUpDevice1.hashCode())+", "+aUpDevice1);
System.err.println("GLEventListenerState.moveTo.2b: up-pres 0x"+Integer.toHexString(aUpDevice2.hashCode())+", "+aUpDevice2);
System.err.println("GLEventListenerState.moveTo.2c: "+aUpSurface.getClass().getName()/*+", "+aUpSurface+", "*/+aProxy.getUpstreamOptionBits(null).toString());
- }
+ }
DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aUpDevice1, aUpDevice2);
- aUpDevice2.close();
+ aUpDevice2.close();
if( proxyOwnsUpstreamDevice ) {
aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE );
}
@@ -354,7 +354,7 @@ public class GLEventListenerState {
throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true");
}
}
-
+
if( aRealized && null != aUpSurface ) {
a.getDelegatedDrawable().setRealized(true);
}
@@ -369,7 +369,7 @@ public class GLEventListenerState {
}
}
owner = false;
-
+
//
// Trigger GL-Viewport reset and reshape of all initialized GLEventListeners
//
@@ -389,7 +389,7 @@ public class GLEventListenerState {
a.setGLEventListenerInitState(l, listenersInit[i]);
listeners[i] = null;
}
-
+
if( hasAnimator ) {
// prefer already bound animator
aAnim.add(a);
@@ -410,7 +410,7 @@ public class GLEventListenerState {
public boolean run(GLAutoDrawable drawable) {
drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
return true;
- }
+ }
};
public static GLRunnable glFinish = new GLRunnable() {
@@ -418,7 +418,7 @@ public class GLEventListenerState {
public boolean run(GLAutoDrawable drawable) {
drawable.getGL().glFinish();
return true;
- }
+ }
};
public static class ReshapeGLEventListener implements GLRunnable {
@@ -430,6 +430,6 @@ public class GLEventListenerState {
public boolean run(GLAutoDrawable drawable) {
listener.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
return true;
- }
+ }
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java
index 14f4be96a..c7aadcd14 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java
@@ -28,17 +28,17 @@
package com.jogamp.opengl;
/**
- * Class holding OpenGL extension strings, commonly used by JOGL's implementation.
+ * Class holding OpenGL extension strings, commonly used by JOGL's implementation.
*/
public class GLExtensions {
public static final String VERSION_1_2 = "GL_VERSION_1_2";
public static final String VERSION_1_4 = "GL_VERSION_1_4";
public static final String VERSION_1_5 = "GL_VERSION_1_5";
public static final String VERSION_2_0 = "GL_VERSION_2_0";
-
+
public static final String ARB_debug_output = "GL_ARB_debug_output";
public static final String AMD_debug_output = "GL_AMD_debug_output";
-
+
public static final String ARB_framebuffer_object = "GL_ARB_framebuffer_object";
public static final String OES_framebuffer_object = "GL_OES_framebuffer_object";
public static final String EXT_framebuffer_object = "GL_EXT_framebuffer_object";
@@ -49,17 +49,17 @@ public class GLExtensions {
public static final String OES_depth32 = "GL_OES_depth32";
public static final String OES_packed_depth_stencil = "GL_OES_packed_depth_stencil";
public static final String NV_fbo_color_attachments = "GL_NV_fbo_color_attachments";
-
+
public static final String ARB_ES2_compatibility = "GL_ARB_ES2_compatibility";
public static final String ARB_ES3_compatibility = "GL_ARB_ES3_compatibility";
-
+
public static final String EXT_abgr = "GL_EXT_abgr";
public static final String OES_rgb8_rgba8 = "GL_OES_rgb8_rgba8";
public static final String OES_stencil1 = "GL_OES_stencil1";
public static final String OES_stencil4 = "GL_OES_stencil4";
public static final String OES_stencil8 = "GL_OES_stencil8";
public static final String APPLE_float_pixels = "GL_APPLE_float_pixels";
-
+
public static final String ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two";
public static final String ARB_texture_rectangle = "GL_ARB_texture_rectangle";
public static final String EXT_texture_rectangle = "GL_EXT_texture_rectangle";
@@ -72,15 +72,15 @@ public class GLExtensions {
public static final String OES_read_format = "GL_OES_read_format";
public static final String OES_single_precision = "GL_OES_single_precision";
public static final String OES_EGL_image_external = "GL_OES_EGL_image_external";
-
+
public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64";
- public static final String ARB_shader_objects = "GL_ARB_shader_objects";
+ public static final String ARB_shader_objects = "GL_ARB_shader_objects";
public static final String ARB_geometry_shader4 = "GL_ARB_geometry_shader4";
-
+
//
// Aliased GLX/WGL/.. extensions
//
-
- public static final String ARB_pixel_format = "GL_ARB_pixel_format";
+
+ public static final String ARB_pixel_format = "GL_ARB_pixel_format";
public static final String ARB_pbuffer = "GL_ARB_pbuffer";
}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 6ef1e0805..ee77f8d2d 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -29,20 +29,20 @@ package com.jogamp.opengl;
import java.util.List;
-/**
- * GLRendererQuirks contains information of known bugs of various GL renderer.
+/**
+ * GLRendererQuirks contains information of known bugs of various GL renderer.
* This information allows us to workaround them.
*
* Using centralized quirk identifier enables us to
- * locate code dealing w/ it and hence eases it's maintenance.
+ * locate code dealing w/ it and hence eases it's maintenance.
*
*
* Some GL_VENDOR
and GL_RENDERER
strings are
- * listed here .
+ * listed here .
*
*/
public class GLRendererQuirks {
- /**
+ /**
* Crashes XServer when using double buffered PBuffer with GL_RENDERER:
*
* - Mesa DRI Intel(R) Sandybridge Desktop
@@ -52,23 +52,23 @@ public class GLRendererQuirks {
* For now, it is safe to disable it w/ hw-acceleration.
*/
public static final int NoDoubleBufferedPBuffer = 0;
-
+
/** On Windows no double buffered bitmaps are guaranteed to be available. */
public static final int NoDoubleBufferedBitmap = 1;
/** Crashes application when trying to set EGL swap interval on Android 4.0.3 / Pandaboard ES / PowerVR SGX 540 */
public static final int NoSetSwapInterval = 2;
-
+
/** No offscreen bitmap available, currently true for JOGL's OSX implementation. */
public static final int NoOffscreenBitmap = 3;
-
+
/** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */
public static final int NoSetSwapIntervalPostRetarget = 4;
/** GLSL discard
command leads to undefined behavior or won't get compiled if being used. Appears to have happened on Nvidia Tegra2, but seems to be fine now. FIXME: Constrain version. */
public static final int GLSLBuggyDiscard = 5;
-
- /**
+
+ /**
* Non compliant GL context due to a buggy implementation not suitable for use.
*
* Currently, Mesa >= 9.1.3 (may extend back as far as 9.0) OpenGL 3.1 compatibility
@@ -82,19 +82,19 @@ public class GLRendererQuirks {
*
*
*
- * It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought.
+ * It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought.
*/
public static final int GLNonCompliant = 6;
-
+
/**
* The OpenGL Context needs a glFlush()
before releasing it, otherwise driver may freeze:
*
* - OSX < 10.7.3 - NVidia Driver. Bug 533 and Bug 548 @ https://jogamp.org/bugzilla/.
- *
+ *
*/
public static final int GLFlushBeforeRelease = 7;
-
- /**
+
+ /**
* Closing X11 displays may cause JVM crashes or X11 errors with some buggy drivers
* while being used in concert w/ OpenGL.
*
@@ -123,14 +123,14 @@ public class GLRendererQuirks {
*
*/
public static final int DontCloseX11Display = 8;
-
+
/**
- * Need current GL Context when calling new ARB pixel format query functions,
+ * Need current GL Context when calling new ARB pixel format query functions,
* otherwise driver crashes the VM.
*
* Drivers known exposing such bug:
*
- * - ATI proprietary Catalyst driver on Windows version ≤ XP.
+ *
- ATI proprietary Catalyst driver on Windows version ≤ XP.
* TODO: Validate if bug actually relates to 'old' ATI Windows drivers for old GPU's like X300
* regardless of the Windows version.
*
@@ -139,7 +139,7 @@ public class GLRendererQuirks {
*
*/
public static final int NeedCurrCtx4ARBPixFmtQueries = 9;
-
+
/**
* Need current GL Context when calling new ARB CreateContext function,
* otherwise driver crashes the VM.
@@ -159,14 +159,14 @@ public class GLRendererQuirks {
*
*/
public static final int NeedCurrCtx4ARBCreateContext = 10;
-
+
/**
* No full FBO support, i.e. not compliant w/
- *
+ *
* - GL_ARB_framebuffer_object
- * - EXT_framebuffer_object
- * - EXT_framebuffer_multisample
- * - EXT_framebuffer_blit
+ * - EXT_framebuffer_object
+ * - EXT_framebuffer_multisample
+ * - EXT_framebuffer_blit
* - EXT_packed_depth_stencil
*
.
* Drivers known exposing such bug:
@@ -180,18 +180,18 @@ public class GLRendererQuirks {
* Quirk can also be enabled via property: jogl.fbo.force.min
.
*/
public static final int NoFullFBOSupport = 11;
-
+
/**
* GLSL is not compliant or even not stable (crash)
*
* - OSX < 10.7.0 (?) - NVidia Driver. Bug 818 @ https://jogamp.org/bugzilla/.
- *
+ *
*/
public static final int GLSLNonCompliant = 12;
-
+
/** Number of quirks known. */
public static final int COUNT = 13;
-
+
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
"GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
@@ -218,7 +218,7 @@ public class GLRendererQuirks {
bitmask |= 1 << quirk;
}
_bitmask = bitmask;
- }
+ }
/**
* @param quirks a list of valid quirks
@@ -233,7 +233,7 @@ public class GLRendererQuirks {
}
_bitmask = bitmask;
}
-
+
/**
* @param quirk the quirk to be tested
* @return true if quirk exist, otherwise false
@@ -261,7 +261,7 @@ public class GLRendererQuirks {
sb.append("]");
return sb;
}
-
+
public final String toString() {
return toString(null).toString();
}
@@ -273,7 +273,7 @@ public class GLRendererQuirks {
public static void validateQuirk(int quirk) throws IllegalArgumentException {
if( !( 0 <= quirk && quirk < COUNT ) ) {
throw new IllegalArgumentException("Quirks must be in range [0.."+COUNT+"[, but quirk: "+quirk);
- }
+ }
}
/**
diff --git a/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java b/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java
index 321d4ee57..b98c4431d 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,7 +20,7 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -31,12 +31,12 @@ package com.jogamp.opengl;
* Interface adding a {@link GLEventListenerState} protocol to {@link GLAutoDrawable}s
* or other self-contained compound types combining {@link GLDrawable}, {@link GLContext} and {@link GLEventListener}.
*
- * Implementing classes {@link #isGLStatePreservationSupported() may support} preservation
- * of the {@link GLContext} state and it's associated {@link GLEventListener}.
- *
+ * Implementing classes {@link #isGLStatePreservationSupported() may support} preservation
+ * of the {@link GLContext} state and it's associated {@link GLEventListener}.
+ *
*/
public interface GLStateKeeper {
-
+
/** Listener for preserve and restore notifications. */
public static interface Listener {
/** Invoked before preservation. */
@@ -44,14 +44,14 @@ public interface GLStateKeeper {
/** Invoked after restoration. */
void glStateRestored(GLStateKeeper glsk);
}
-
- /**
+
+ /**
* Sets a {@link Listener}, overriding the old one.
* @param l the new {@link Listener}.
* @return the previous {@link Listener}.
*/
public Listener setGLStateKeeperListener(Listener l);
-
+
/**
* @return true
if GL state preservation is supported in implementation and on current platform, false
otherwise.
* @see #preserveGLStateAtDestroy(boolean)
@@ -59,7 +59,7 @@ public interface GLStateKeeper {
* @see #clearPreservedGLState()
*/
public boolean isGLStatePreservationSupported();
-
+
/**
* If set to true
, the next {@link GLAutoDrawable#destroy()} operation will
* {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}.
@@ -68,8 +68,8 @@ public interface GLStateKeeper {
* the flag is cleared.
*
*
- * A preserved {@link GLEventListenerState} will be {@link #pushGLEventListenerState() pushed}
- * if realized again.
+ * A preserved {@link GLEventListenerState} will be {@link #pushGLEventListenerState() pushed}
+ * if realized again.
*
* @return true
if supported and successful, false
otherwise.
* @see #isGLStatePreservationSupported()
@@ -77,21 +77,21 @@ public interface GLStateKeeper {
* @see #clearPreservedGLState()
*/
public boolean preserveGLStateAtDestroy(boolean value);
-
+
/**
* Returns the preserved {@link GLEventListenerState} if preservation was performed,
- * otherwise null
.
+ * otherwise null
.
* @see #isGLStatePreservationSupported()
* @see #preserveGLStateAtDestroy(boolean)
* @see #clearPreservedGLState()
*/
public GLEventListenerState getPreservedGLState();
-
+
/**
* Clears the preserved {@link GLEventListenerState} from this {@link GLStateKeeper}, without destroying it.
- *
+ *
* @return the preserved and cleared {@link GLEventListenerState} if preservation was performed,
- * otherwise null
.
+ * otherwise null
.
* @see #isGLStatePreservationSupported()
* @see #preserveGLStateAtDestroy(boolean)
* @see #getPreservedGLState()
diff --git a/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java b/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java
index 73ec10886..3693f647a 100644
--- a/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java
+++ b/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,7 +20,7 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -37,7 +37,7 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser;
* otherwise uses {@link DefaultGLCapabilitiesChooser} implementation.
*/
public class GenericGLCapabilitiesChooser extends DefaultGLCapabilitiesChooser {
-
+
@Override
public int chooseCapabilities(final CapabilitiesImmutable desired,
final List extends CapabilitiesImmutable> available,
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
index 1f0189aa3..1f715c21a 100644
--- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
+++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,12 +20,12 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl;
import com.jogamp.common.GlueGenVersion;
@@ -90,16 +90,16 @@ public class JoglVersion extends JogampVersion {
sb.append("\tnone").append(Platform.getNewline());
}
sb.append(Platform.getNewline());
- return sb;
+ return sb;
}
-
+
public static StringBuilder getAllAvailableCapabilitiesInfo(AbstractGraphicsDevice device, StringBuilder sb) {
if(null==sb) {
sb = new StringBuilder();
}
if(null == device) {
device = GLProfile.getDefaultDevice();
- }
+ }
sb.append(Platform.getNewline()).append(Platform.getNewline());
sb.append("Desktop Capabilities: ").append(Platform.getNewline());
getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb);
@@ -107,7 +107,7 @@ public class JoglVersion extends JogampVersion {
getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb);
return sb;
}
-
+
public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, boolean withCapabilitiesInfo) {
if(null==sb) {
sb = new StringBuilder();
@@ -126,7 +126,7 @@ public class JoglVersion extends JogampVersion {
}
return sb;
}
-
+
public static StringBuilder getGLInfo(GL gl, StringBuilder sb) {
return getGLInfo(gl, sb, false);
}
@@ -136,26 +136,26 @@ public class JoglVersion extends JogampVersion {
if(null==sb) {
sb = new StringBuilder();
}
-
+
sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline());
sb.append(device.getClass().getSimpleName()).append("[type ")
.append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ").append(Platform.getNewline());
- GLProfile.glAvailabilityToString(device, sb, "\t", 1);
+ GLProfile.glAvailabilityToString(device, sb, "\t", 1);
sb.append(Platform.getNewline());
sb = getGLStrings(gl, sb, withCapabilitiesAndExtensionInfo);
-
+
if( withCapabilitiesAndExtensionInfo ) {
- sb = getAllAvailableCapabilitiesInfo(device, sb);
+ sb = getAllAvailableCapabilitiesInfo(device, sb);
}
return sb;
}
-
+
public static StringBuilder getGLStrings(GL gl, StringBuilder sb) {
return getGLStrings(gl, sb, true);
}
-
- public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) {
+
+ public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) {
if(null==sb) {
sb = new StringBuilder();
}
@@ -175,7 +175,7 @@ public class JoglVersion extends JogampVersion {
sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER));
sb.append(Platform.getNewline());
sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION));
- sb.append(Platform.getNewline());
+ sb.append(Platform.getNewline());
sb.append("GLSL ").append(gl.hasGLSL()).append(", has-compiler-func: ").append(gl.isFunctionAvailable("glCompileShader"));
if(gl.hasGLSL()) {
sb.append(", version: ").append(gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)).append(" / ").append(ctx.getGLSLVersionNumber());
@@ -200,7 +200,7 @@ public class JoglVersion extends JogampVersion {
return sb;
}
- public StringBuilder getBriefOSGLBuildInfo(GL gl, StringBuilder sb) {
+ public StringBuilder getBriefOSGLBuildInfo(GL gl, StringBuilder sb) {
if(null==sb) {
sb = new StringBuilder();
}
@@ -216,7 +216,7 @@ public class JoglVersion extends JogampVersion {
sb.append(Platform.getNewline());
return sb;
}
-
+
public static void main(String args[]) {
System.err.println(VersionUtil.getPlatformInfo());
System.err.println(GlueGenVersion.getInstance());
diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
index ca4846939..8d2d07d58 100644
--- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. 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.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
@@ -20,12 +20,12 @@
* 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.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.opengl.cg;
import com.jogamp.common.jvm.JNILibLoaderBase;
@@ -45,15 +45,15 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf
AccessController.doPrivileged(new PrivilegedAction
's current position
@@ -469,14 +469,14 @@ public class FloatUtil {
for(int i=0; ia
's current position
@@ -493,14 +493,14 @@ public class FloatUtil {
for(int i=0; ia
's current position
@@ -549,11 +549,11 @@ public class FloatUtil {
matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i);
sb.append("=?= ");
matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i);
- sb.append("]").append(Platform.getNewline());
+ sb.append("]").append(Platform.getNewline());
}
return sb;
}
-
+
public static final float E = 2.7182818284590452354f;
public static final float PI = 3.14159265358979323846f;
@@ -569,5 +569,5 @@ public class FloatUtil {
public static float acos(float a) { return (float) java.lang.Math.acos(a); }
public static float sqrt(float a) { return (float) java.lang.Math.sqrt(a); }
-
+
}
\ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
index c6bf44f6d..78cbb18cf 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java
@@ -33,7 +33,7 @@ public class Quaternion {
public Quaternion() {
setIdentity();
}
-
+
public Quaternion(Quaternion q) {
x = q.x;
y = q.y;
@@ -50,7 +50,7 @@ public class Quaternion {
/**
* Constructor to create a rotation based quaternion from two vectors
- *
+ *
* @param vector1
* @param vector2
*/
@@ -59,7 +59,7 @@ public class Quaternion {
final float[] cross = VectorUtil.cross(vector1, vector2);
fromAxis(cross, theta);
}
-
+
/***
* Constructor to create a rotation based quaternion from axis vector and angle
* @param vector axis vector
@@ -69,10 +69,10 @@ public class Quaternion {
public Quaternion(float[] vector, float angle) {
fromAxis(vector, angle);
}
-
+
/***
* Initialize this quaternion with given axis vector and rotation angle
- *
+ *
* @param vector axis vector
* @param angle rotation angle (rads)
*/
@@ -88,7 +88,7 @@ public class Quaternion {
/**
* Transform the rotational quaternion to axis based rotation angles
- *
+ *
* @return new float[4] with ,theta,Rx,Ry,Rz
*/
public float[] toAxis() {
@@ -135,7 +135,7 @@ public class Quaternion {
/**
* Add a quaternion
- *
+ *
* @param q quaternion
*/
public void add(Quaternion q) {
@@ -146,7 +146,7 @@ public class Quaternion {
/**
* Subtract a quaternion
- *
+ *
* @param q quaternion
*/
public void subtract(Quaternion q) {
@@ -157,7 +157,7 @@ public class Quaternion {
/**
* Divide a quaternion by a constant
- *
+ *
* @param n a float to divide by
*/
public void divide(float n) {
@@ -168,7 +168,7 @@ public class Quaternion {
/**
* Multiply this quaternion by the param quaternion
- *
+ *
* @param q a quaternion to multiply with
*/
public void mult(Quaternion q) {
@@ -186,7 +186,7 @@ public class Quaternion {
/**
* Multiply a quaternion by a constant
- *
+ *
* @param n a float constant
*/
public void mult(float n) {
@@ -194,10 +194,10 @@ public class Quaternion {
y *= n;
z *= n;
}
-
+
/***
* Rotate given vector by this quaternion
- *
+ *
* @param vector input vector
* @return rotated vector
*/
@@ -250,7 +250,7 @@ public class Quaternion {
/**
* Transform this quaternion to a 4x4 column matrix representing the
* rotation
- *
+ *
* @return new float[16] column matrix 4x4
*/
public float[] toMatrix() {
@@ -287,7 +287,7 @@ public class Quaternion {
* See http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/
* quaternions/slerp/
*
- *
+ *
* @param a initial quaternion
* @param b target quaternion
* @param t float between 0 and 1 representing interp.
@@ -332,13 +332,13 @@ public class Quaternion {
/**
* Check if this quaternion represents an identity matrix for rotation,
* , ie (0,0,0,1).
- *
+ *
* @return true if it is an identity rep., false otherwise
*/
public boolean isIdentity() {
return w == 1 && x == 0 && y == 0 && z == 0;
}
-
+
/***
* Set this quaternion to identity (x=0,y=0,z=0,w=1)
*/
@@ -349,7 +349,7 @@ public class Quaternion {
/**
* compute the quaternion from a 3x3 column matrix
- *
+ *
* @param m 3x3 column matrix
*/
public void setFromMatrix(float[] m) {
@@ -386,7 +386,7 @@ public class Quaternion {
/**
* Check if the the 3x3 matrix (param) is in fact an affine rotational
* matrix
- *
+ *
* @param m 3x3 column matrix
* @return true if representing a rotational matrix, false otherwise
*/
diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java
index 0033afeaa..508f1aafd 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java
@@ -39,7 +39,7 @@ public class VectorUtil {
Winding(int dir) {
this.dir = dir;
}
- }
+ }
public static final int COLLINEAR = 0;
@@ -119,15 +119,15 @@ public class VectorUtil {
/** Column Matrix Vector multiplication
* @param colMatrix column matrix (4x4)
* @param vec vector(x,y,z)
- * @return result new float[3]
+ * @return result new float[3]
*/
public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec)
{
final float[] out = new float[3];
- out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12];
- out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13];
- out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14];
+ out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12];
+ out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13];
+ out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14];
return out;
}
@@ -135,15 +135,15 @@ public class VectorUtil {
/** Matrix Vector multiplication
* @param rawMatrix column matrix (4x4)
* @param vec vector(x,y,z)
- * @return result new float[3]
+ * @return result new float[3]
*/
public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec)
{
final float[] out = new float[3];
- out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3];
- out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7];
- out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11];
+ out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3];
+ out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7];
+ out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11];
return out;
}
@@ -157,7 +157,7 @@ public class VectorUtil {
{
return (p1+p2)/2.0f;
}
-
+
/** Calculate the midpoint of two points
* @param p1 first point
* @param p2 second point
@@ -172,7 +172,7 @@ public class VectorUtil {
return midPoint;
}
-
+
/** Compute the norm of a vector
* @param vec vector
* @return vorm
@@ -181,7 +181,7 @@ public class VectorUtil {
{
return FloatUtil.sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
}
-
+
/** Compute distance between 2 points
* @param p0 a ref point on the line
* @param vec vector representing the direction of the line
@@ -216,7 +216,7 @@ public class VectorUtil {
*/
public static boolean checkEqualityVec2(float[] v1, float[] v2)
{
- return Float.compare(v1[0], v2[0]) == 0 &&
+ return Float.compare(v1[0], v2[0]) == 0 &&
Float.compare(v1[1], v2[1]) == 0 ;
}
@@ -261,7 +261,7 @@ public class VectorUtil {
* @param b triangle vertex 2
* @param c triangle vertex 3
* @param d vertex in question
- * @return true if the vertex d is inside the circle defined by the
+ * @return true if the vertex d is inside the circle defined by the
* vertices a, b, c. from paper by Guibas and Stolfi (1985).
*/
public static boolean inCircle(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d){
@@ -282,8 +282,8 @@ public class VectorUtil {
return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX());
}
- /** Check if a vertex is in triangle using
- * barycentric coordinates computation.
+ /** Check if a vertex is in triangle using
+ * barycentric coordinates computation.
* @param a first triangle vertex
* @param b second triangle vertex
* @param c third triangle vertex
@@ -291,7 +291,7 @@ public class VectorUtil {
* @return true if p is in triangle (a, b, c), false otherwise.
*/
public static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p){
- // Compute vectors
+ // Compute vectors
final float[] ac = computeVector(a, c); //v0
final float[] ab = computeVector(a, b); //v1
final float[] ap = computeVector(a, p); //v2
@@ -362,13 +362,13 @@ public class VectorUtil {
* @param b vertex 2 of first segment
* @param c vertex 1 of second segment
* @param d vertex 2 of second segment
- * @return the intersection coordinates if the segments intersect, otherwise
- * returns null
+ * @return the intersection coordinates if the segments intersect, otherwise
+ * returns null
*/
public static float[] seg2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) {
final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
- if (determinant == 0)
+ if (determinant == 0)
return null;
final float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
@@ -389,13 +389,13 @@ public class VectorUtil {
* @param b vertex 2 of first line
* @param c vertex 1 of second line
* @param d vertex 2 of second line
- * @return the intersection coordinates if the lines intersect, otherwise
- * returns null
+ * @return the intersection coordinates if the lines intersect, otherwise
+ * returns null
*/
public static float[] line2lineIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) {
final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
- if (determinant == 0)
+ if (determinant == 0)
return null;
final float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java
index 13349884c..ec90b401f 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java
@@ -33,7 +33,7 @@ public interface Vert2fImmutable {
float getY();
int getCoordCount();
-
+
float[] getCoord();
-
+
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
index b6e8ede2e..f1880a61b 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
@@ -32,23 +32,23 @@ import com.jogamp.opengl.math.VectorUtil;
/**
* Axis Aligned Bounding Box. Defined by two 3D coordinates (low and high)
- * The low being the the lower left corner of the box, and the high being the upper
+ * The low being the the lower left corner of the box, and the high being the upper
* right corner of the box.
- *
+ *
*/
public class AABBox implements Cloneable {
private float[] low = new float[3];
private float[] high = new float[3];
private float[] center = new float[3];
- /** Create a Axis Aligned bounding box (AABBox)
+ /** Create a Axis Aligned bounding box (AABBox)
* where the low and and high MAX float Values.
*/
public AABBox() {
reset();
}
- /** Create an AABBox specifying the coordinates
+ /** Create an AABBox specifying the coordinates
* of the low and high
* @param lx min x-coordinate
* @param ly min y-coordnate
@@ -61,7 +61,7 @@ public class AABBox implements Cloneable {
float hx, float hy, float hz) {
setSize(lx, ly, lz, hx, hy, hz);
}
-
+
/** Create a AABBox defining the low and high
* @param low min xyz-coordinates
* @param high max xyz-coordinates
@@ -78,27 +78,27 @@ public class AABBox implements Cloneable {
center[1] = 0f;
center[2] = 0f;
}
-
+
/** Get the max xyz-coordinates
* @return a float array containing the max xyz coordinates
*/
public final float[] getHigh() {
return high;
}
-
+
private final void setHigh(float hx, float hy, float hz) {
this.high[0] = hx;
this.high[1] = hy;
this.high[2] = hz;
}
-
+
/** Get the min xyz-coordinates
* @return a float array containing the min xyz coordinates
*/
public final float[] getLow() {
return low;
}
-
+
private final void setLow(float lx, float ly, float lz) {
this.low[0] = lx;
this.low[1] = ly;
@@ -111,10 +111,10 @@ public class AABBox implements Cloneable {
center[2] = (high[2] + low[2])/2;
}
- /**
- * Set size of the AABBox specifying the coordinates
+ /**
+ * Set size of the AABBox specifying the coordinates
* of the low and high.
- *
+ *
* @param lx min x-coordinate
* @param ly min y-coordnate
* @param lz min z-coordinate
@@ -123,7 +123,7 @@ public class AABBox implements Cloneable {
* @param hz max z-coordinate
*/
public final void setSize(float lx, float ly, float lz,
- float hx, float hy, float hz) {
+ float hx, float hy, float hz) {
this.low[0] = lx;
this.low[1] = ly;
this.low[2] = lz;
@@ -132,7 +132,7 @@ public class AABBox implements Cloneable {
this.high[2] = hz;
computeCenter();
}
-
+
/** Resize the AABBox to encapsulate another AABox
* @param newBox AABBox to be encapsulated in
*/
@@ -160,12 +160,12 @@ public class AABBox implements Cloneable {
}
/** Resize the AABBox to encapsulate the passed
- * xyz-coordinates.
+ * xyz-coordinates.
* @param x x-axis coordinate value
* @param y y-axis coordinate value
* @param z z-axis coordinate value
*/
- public final void resize(float x, float y, float z) {
+ public final void resize(float x, float y, float z) {
/** test low */
if (x < low[0])
low[0] = x;
@@ -181,12 +181,12 @@ public class AABBox implements Cloneable {
high[1] = y;
if (z > high[2])
high[2] = z;
-
+
computeCenter();
}
/** Resize the AABBox to encapsulate the passed
- * xyz-coordinates.
+ * xyz-coordinates.
* @param xyz xyz-axis coordinate values
* @param offset of the array
*/
@@ -210,7 +210,7 @@ public class AABBox implements Cloneable {
}
return true;
}
-
+
/** Check if the xyz coordinates are bounded/contained
* by this AABBox.
* @param x x-axis coordinate value
@@ -231,7 +231,7 @@ public class AABBox implements Cloneable {
}
return true;
}
-
+
/** Check if there is a common region between this AABBox and the passed
* 2D region irrespective of z range
* @param x lower left x-coord
@@ -244,13 +244,13 @@ public class AABBox implements Cloneable {
if (w <= 0 || h <= 0) {
return false;
}
-
+
final float _w = getWidth();
- final float _h = getHeight();
+ final float _h = getHeight();
if (_w <= 0 || _h <= 0) {
return false;
}
-
+
final float x0 = getMinX();
final float y0 = getMinY();
return (x + w > x0 &&
@@ -259,8 +259,8 @@ public class AABBox implements Cloneable {
y < y0 + _h);
}
-
- /** Get the size of the Box where the size is represented by the
+
+ /** Get the size of the Box where the size is represented by the
* length of the vector between low and high.
* @return a float representing the size of the AABBox
*/
@@ -283,16 +283,16 @@ public class AABBox implements Cloneable {
diffH[0] = high[0] - center[0];
diffH[1] = high[1] - center[1];
diffH[2] = high[2] - center[2];
-
+
diffH = VectorUtil.scale(diffH, size);
-
+
float[] diffL = new float[3];
diffL[0] = low[0] - center[0];
diffL[1] = low[1] - center[1];
diffL[2] = low[2] - center[2];
-
+
diffL = VectorUtil.scale(diffL, size);
-
+
high = VectorUtil.vectorAdd(center, diffH);
low = VectorUtil.vectorAdd(center, diffL);
}
@@ -300,43 +300,43 @@ public class AABBox implements Cloneable {
public final float getMinX() {
return low[0];
}
-
+
public final float getMinY() {
return low[1];
}
-
+
public final float getMinZ() {
return low[2];
}
-
+
public final float getMaxX() {
return high[0];
}
-
+
public final float getMaxY() {
return high[1];
}
-
+
public final float getMaxZ() {
return high[2];
}
-
+
public final float getWidth(){
return high[0] - low[0];
}
-
+
public final float getHeight() {
return high[1] - low[1];
}
-
+
public final float getDepth() {
return high[2] - low[2];
}
-
+
public final AABBox clone() {
return new AABBox(this.low, this.high);
}
-
+
public final boolean equals(Object obj) {
if( obj == this ) {
return true;
@@ -344,11 +344,11 @@ public class AABBox implements Cloneable {
if( null == obj || !(obj instanceof AABBox) ) {
return false;
}
- final AABBox other = (AABBox) obj;
- return VectorUtil.checkEquality(low, other.low) &&
+ final AABBox other = (AABBox) obj;
+ return VectorUtil.checkEquality(low, other.low) &&
VectorUtil.checkEquality(high, other.high) ;
}
-
+
public final String toString() {
return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+
center[0]+"/"+center[1]+"/"+center[1]+" ]";
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
index 93e68a1d6..fb311083f 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
@@ -30,11 +30,11 @@ package com.jogamp.opengl.math.geom;
import com.jogamp.common.os.Platform;
/**
- * Providing frustum {@link #getPlanes() planes} derived by different inputs
+ * Providing frustum {@link #getPlanes() planes} derived by different inputs
* ({@link #updateByPMV(float[], int) P*MV}, ..)
- * used to {@link #classifySphere(float[], float) classify objects} and to test
+ * used to {@link #classifySphere(float[], float) classify objects} and to test
* whether they are {@link #isOutside(AABBox) outside}.
- *
+ *
* * Extracting the world-frustum planes from the P*Mv: *
@@ -54,7 +54,7 @@ import com.jogamp.common.os.Platform; * Lighthouse3d.com * http://www.lighthouse3d.com/tutorials/view-frustum-culling/ *- * + * * Fundamentals about Planes, Half-Spaces and Frustum-Culling:
* Planes and Half-Spaces, Max Wagner*@@ -69,7 +69,7 @@ import com.jogamp.common.os.Platform; public class Frustum { /** Normalized planes[l, r, b, t, n, f] */ protected Plane[] planes = new Plane[6]; - + /** * Creates an undefined instance w/o calculating the frustum. * @@ -83,35 +83,35 @@ public class Frustum { planes[i] = new Plane(); } } - - /** + + /** * Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0 *
* In order to work w/ {@link Frustum#isOutside(AABBox) isOutside(..)} methods, * the normals have to point to the inside of the frustum. - *
+ * */ public static class Plane { /** Normal of the plane */ public final float[] n = new float[3]; - + /** Distance to origin */ public float d; - /** + /** * Return signed distance of plane to given point. **
+ * * A plane cuts 3D space into 2 half spaces. *- If dist < 0 , then the point p lies in the negative halfspace.
*- If dist = 0 , then the point p lies in the plane.
*- If dist > 0 , then the point p lies in the positive halfspace.
- ** Positive halfspace is where the plane’s normals vector points into. - *
+ * ** Negative halfspace is the other side of the plane, i.e. *-1 - *
+ * **/ public final float distanceTo(float x, float y, float z) { return n[0] * x + n[1] * y + n[2] * z + d; @@ -121,13 +121,13 @@ public class Frustum { public final float distanceTo(float[] p) { return n[0] * p[0] + n[1] * p[1] + n[2] * p[2] + d; } - + @Override public String toString() { return "Plane[ [ " + n[0] + ", " + n[1] + ", " + n[2] + " ], " + d + "]"; } } - + /** Index for left plane: {@value} */ public static final int LEFT = 0; /** Index for right plane: {@value} */ @@ -140,7 +140,7 @@ public class Frustum { public static final int NEAR = 4; /** Index for far plane: {@value} */ public static final int FAR = 5; - + /** * {@link Plane}s are ordered in the returned array as follows: *@@ -154,17 +154,17 @@ public class Frustum { *
* - * The current thread seems to be valid for all platforms, + * The current thread seems to be valid for all platforms, * since no SWT lifecycle tasks are being performed w/ this call. * Only GL task, which are independent from the SWT threading model. - * + * * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() */ @@ -854,8 +854,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } */ action.run(); } - - private void runOnEDTIfAvail(boolean wait, final Runnable action) { + + private void runOnEDTIfAvail(boolean wait, final Runnable action) { final Display d = isDisposed() ? null : getDisplay(); if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) { action.run(); @@ -879,7 +879,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; } - + public static void main(final String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index 8de178e49..80289acf3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 80d980492..cdfb73b21 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -57,7 +57,7 @@ import javax.media.opengl.GLException; * Call {@link #stop() } to terminate the animation and it's execution thread. * */ -public class Animator extends AnimatorBase { +public class Animator extends AnimatorBase { protected ThreadGroup threadGroup; private Runnable runnable; private boolean runAsFastAsPossible; @@ -75,7 +75,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator w/ an associated ThreadGroup. */ public Animator(ThreadGroup tg) { @@ -86,7 +86,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator for a particular drawable. */ public Animator(GLAutoDrawable drawable) { @@ -97,7 +97,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. */ public Animator(ThreadGroup tg, GLAutoDrawable drawable) { @@ -127,7 +127,7 @@ public class Animator extends AnimatorBase { stateSync.unlock(); } } - + private final void setIsAnimatingSynced(boolean v) { stateSync.lock(); try { @@ -185,7 +185,7 @@ public class Animator extends AnimatorBase { } if (!stopIssued && !isAnimating) { // Wakes up 'waitForStartedCondition' sync - // - and - + // - and - // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty setIsAnimatingSynced(true); // barrier @@ -251,7 +251,7 @@ public class Animator extends AnimatorBase { /** * Set a {@link ThreadGroup} for the {@link #getThread() animation thread}. - * + * * @param tg the {@link ThreadGroup} * @throws GLException if the animator has already been started */ @@ -261,7 +261,7 @@ public class Animator extends AnimatorBase { } threadGroup = tg; } - + public synchronized boolean start() { if ( isStartedImpl() ) { return false; @@ -277,7 +277,7 @@ public class Animator extends AnimatorBase { } else { thread = new Thread(threadGroup, runnable, threadName); } - thread.setDaemon(false); // force to be non daemon, regardless of parent thread + thread.setDaemon(false); // force to be non daemon, regardless of parent thread if(DEBUG) { final Thread ct = Thread.currentThread(); System.err.println("Animator "+ct.getName()+"[daemon "+ct.isDaemon()+"]: starting "+thread.getName()+"[daemon "+thread.isDaemon()+"]"); @@ -288,7 +288,7 @@ public class Animator extends AnimatorBase { private final Condition waitForStartedCondition = new Condition() { public boolean eval() { return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; - } }; + } }; public synchronized boolean stop() { if ( !isStartedImpl() ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index ef92100ad..b447a339b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -52,14 +52,14 @@ import javax.media.opengl.GLProfile; */ public abstract class AnimatorBase implements GLAnimatorControl { protected static final boolean DEBUG = Debug.debug("Animator"); - + /** A 1s timeout while waiting for a native action response, limiting {@link #finishLifecycleAction(Condition, long)} */ protected static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 1000; - + protected static final long POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 32; // 2 frames @ 60Hz - + /** - * If present in* {@link Plane}'s normals are pointing to the inside of the frustum * in order to work w/ {@link #isOutside(AABBox) isOutside(..)} methods. - *
- * - * @return array of normalized {@link Plane}s, order see above. + * + * + * @return array of normalized {@link Plane}s, order see above. */ public final Plane[] getPlanes() { return planes; } - + /** * Copy the givensrc
planes into this this instance's planes. * @param src the 6 source planes */ - public final void updateByPlanes(Plane[] src) { + public final void updateByPlanes(Plane[] src) { for (int i = 0; i < 6; ++i) { final Plane p0 = planes[i]; final float[] p0_n = p0.n; @@ -176,7 +176,7 @@ public class Frustum { p0.d = p1.d; } } - + /** * Calculate the frustum planes in world coordinates * using the passed float[16] as premultiplied P*MV (column major order). @@ -185,7 +185,7 @@ public class Frustum { * as required by this class. * */ - public void updateByPMV(float[] pmv, int pmv_off) { + public void updateByPMV(float[] pmv, int pmv_off) { // Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] row-major // Left: a = m30 + m00, b = m31 + m01, c = m32 + m02, d = m33 + m03 - [0..3] row-major { @@ -264,11 +264,11 @@ public class Frustum { p.d /= invl; } } - + private static final boolean isOutsideImpl(Plane p, AABBox box) { final float[] low = box.getLow(); final float[] high = box.getHigh(); - + if ( p.distanceTo(low[0], low[1], low[2]) > 0.0f || p.distanceTo(high[0], low[1], low[2]) > 0.0f || p.distanceTo(low[0], high[1], low[2]) > 0.0f || @@ -298,19 +298,19 @@ public class Frustum { // We make no attempt to determine whether it's fully inside or not. return false; } - - + + public static enum Location { OUTSIDE, INSIDE, INTERSECT }; - + /** * Check to see if a point is outside, inside or on a plane of the frustum. - * + * * @param p the point * @return {@link Location} of point related to frustum planes */ public final Location classifyPoint(float[] p) { Location res = Location.INSIDE; - + for (int i = 0; i < 6; ++i) { final float d = planes[i].distanceTo(p); if ( d < 0.0f ) { @@ -321,43 +321,43 @@ public class Frustum { } return res; } - + /** * Check to see if a point is outside of the frustum. - * + * * @param p the point * @return true if outside of the frustum, otherwise inside or on a plane */ public final boolean isPointOutside(float[] p) { return Location.OUTSIDE == classifyPoint(p); } - + /** * Check to see if a sphere is outside, intersecting or inside of the frustum. - * + * * @param p center of the sphere * @param radius radius of the sphere * @return {@link Location} of point related to frustum planes */ public final Location classifySphere(float[] p, float radius) { Location res = Location.INSIDE; // fully inside - + for (int i = 0; i < 6; ++i) { final float d = planes[i].distanceTo(p); - if ( d < -radius ) { + if ( d < -radius ) { // fully outside return Location.OUTSIDE; } else if (d < radius ) { // intersecting res = Location.INTERSECT; } - } + } return res; } - + /** * Check to see if a sphere is outside of the frustum. - * + * * @param p center of the sphere * @param radius radius of the sphere * @return true if outside of the frustum, otherwise inside or intersecting @@ -365,7 +365,7 @@ public class Frustum { public final boolean isSphereOutside(float[] p, float radius) { return Location.OUTSIDE == classifySphere(p, radius); } - + public StringBuilder toString(StringBuilder sb) { if( null == sb ) { sb = new StringBuilder(); @@ -380,7 +380,7 @@ public class Frustum { .append("]"); return sb; } - + @Override public String toString() { return toString(null).toString(); diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index ff764d849..33941a407 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -102,11 +102,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* GL Stuff */ private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); - + private final GLContext shareWith; private final GLCapabilitiesImmutable capsRequested; - private final GLCapabilitiesChooser capsChooser; - + private final GLCapabilitiesChooser capsChooser; + private volatile Rectangle clientArea; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile GLContextImpl context; @@ -156,7 +156,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public void run() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { if( !GLCanvas.this.isDisposed() ) { helper.invokeGL(drawable, context, displayAction, initAction); } @@ -215,7 +215,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { gle.printStackTrace(); } } - context = null; + context = null; } if ( null != drawable ) { drawable.setRealized(false); @@ -261,11 +261,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } }; - - /** - * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} + + /** + * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} * on the SWT thread. - * + * * @param parent * Required (non-null) parent Composite. * @param style @@ -284,7 +284,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { */ public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, final GLCapabilitiesChooser chooser, final GLContext shareWith) { - final GLCanvas[] res = new GLCanvas[] { null }; + final GLCanvas[] res = new GLCanvas[] { null }; parent.getDisplay().syncExec(new Runnable() { public void run() { res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); @@ -319,22 +319,22 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { GLProfile.initSingleton(); // ensure JOGL is completly initialized SWTAccessor.setRealized(this, true); - + clientArea = GLCanvas.this.getClientArea(); - /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence closing operation will be a NOP. */ final AbstractGraphicsDevice swtDevice = SWTAccessor.getDevice(this); - + useX11GTK = SWTAccessor.useX11GTK(); if(useX11GTK) { - // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering final long x11DeviceHandle = X11Util.openDisplay(swtDevice.getConnection()); if( 0 == x11DeviceHandle ) { throw new RuntimeException("Error creating display(EDT): "+swtDevice.getConnection()); } final AbstractGraphicsDevice x11Device = new X11GraphicsDevice(x11DeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); - screen = SWTAccessor.getScreen(x11Device, -1 /* default */); + screen = SWTAccessor.getScreen(x11Device, -1 /* default */); } else { screen = SWTAccessor.getScreen(swtDevice, -1 /* default */); } @@ -343,7 +343,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(null == capsReqUser) { capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); } - + this.capsRequested = capsReqUser; this.capsChooser = capsChooser; this.shareWith = shareWith; @@ -353,7 +353,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { x11Window = 0; drawable = null; context = null; - + final Listener listener = new Listener () { @Override public void handleEvent (Event event) { @@ -374,7 +374,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -401,11 +401,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { protected final void updateSizeCheck() { final Rectangle oClientArea = clientArea; final Rectangle nClientArea = GLCanvas.this.getClientArea(); - if ( nClientArea != null && + if ( nClientArea != null && ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value - + final GLDrawableImpl _drawable = drawable; final boolean drawableOK = null != _drawable && _drawable.isRealized(); if(DEBUG) { @@ -419,14 +419,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { try { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, nClientArea.width, nClientArea.height); if(_drawable != _drawableNew) { - // write back + // write back drawable = _drawableNew; } } finally { _lock.unlock(); } - } - } + } + } if(0 != x11Window) { SWTAccessor.resizeX11Window(screen.getDevice(), clientArea, x11Window); } else if(0 != gdkWindow) { @@ -435,36 +435,36 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock } } - + private boolean isValidAndVisibleOnEDTActionResult; private final Runnable isValidAndVisibleOnEDTAction = new Runnable() { @Override - public void run() { + public void run() { isValidAndVisibleOnEDTActionResult = !GLCanvas.this.isDisposed() && GLCanvas.this.isVisible(); } }; - + private final boolean isValidAndVisibleOnEDT() { synchronized(isValidAndVisibleOnEDTAction) { runOnEDTIfAvail(true, isValidAndVisibleOnEDTAction); return isValidAndVisibleOnEDTActionResult; } } - + /** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */ protected final boolean validateDrawableAndContextWithCheck() { if( !isValidAndVisibleOnEDT() ) { return false; } - return validateDrawableAndContextPostCheck(); + return validateDrawableAndContextPostCheck(); } - + /** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */ protected final boolean validateDrawableAndContextPostCheck() { final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } - + final boolean res; final RecursiveLock _lock = lock; _lock.lock(); @@ -480,18 +480,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } finally { _lock.unlock(); - } - + } + if(res) { sendReshape = true; if(DEBUG) { System.err.println("SWT GLCanvas realized! "+this+", "+drawable); // Thread.dumpStack(); - } + } } - return res; + return res; } - + private final void createDrawableAndContext() { final AbstractGraphicsDevice device = screen.getDevice(); device.open(); @@ -503,14 +503,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED); if(DEBUG) { System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg); - } + } if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } final int visualID = cfg.getVisualID(VIDType.NATIVE); if( VisualIDHolder.VID_UNDEFINED != visualID ) { // gdkWindow = SWTAccessor.createCompatibleGDKChildWindow(this, visualID, clientArea.width, clientArea.height); - // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); + // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height); nativeWindowHandle = x11Window; } else { @@ -520,16 +520,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { nativeWindowHandle = SWTAccessor.getWindowHandle(this); } final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); - + // Create a NativeWindow proxy for the SWT canvas - ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, + ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, capsRequested, capsChooser, swtCanvasUpStreamHook); // Associate a GL surface with the proxy drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); + context.setContextCreationFlags(additionalCtxCreationFlags); } - + @Override public void update() { // don't paint background etc .. nop avoids flickering @@ -543,13 +543,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(r && 0 != gdkWindow) { SWTGTKUtil.focusGDKWindow(gdkWindow); } - return r; + return r; } */ - + @Override public void dispose() { runInGLThread(disposeOnEDTGLAction); - super.dispose(); + super.dispose(); } private final void displayIfNoAnimatorNoCheck() { @@ -557,14 +557,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final boolean drawableOK = null != drawable && drawable.isRealized(); if( drawableOK || validateDrawableAndContextPostCheck() ) { runInGLThread(makeCurrentAndDisplayOnGLAction); - } + } } } - + // // GL[Auto]Drawable // - + @Override public void display() { final boolean drawableOK = null != drawable && drawable.isRealized(); @@ -577,7 +577,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public final Object getUpstreamWidget() { return this; } - + @Override public int getWidth() { return clientArea.width; @@ -593,7 +593,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.isGLOriented() : true; } - + @Override public void addGLEventListener(final GLEventListener listener) { helper.addGLEventListener(listener); @@ -608,29 +608,29 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public int getGLEventListenerCount() { return helper.getGLEventListenerCount(); } - + @Override public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { return helper.getGLEventListener(index); } - + @Override public boolean getGLEventListenerInitState(GLEventListener listener) { return helper.getGLEventListenerInitState(listener); } - + @Override public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } - + @Override public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); runInGLThread(r); return r.listener; } - + @Override public GLEventListener removeGLEventListener(final GLEventListener listener) { return helper.removeGLEventListener(listener); @@ -673,7 +673,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public final GLDrawable getDelegatedDrawable() { return drawable; } - + @Override public GLContext getContext() { return null != drawable ? context : null; @@ -694,12 +694,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public boolean invoke(final boolean wait, final GLRunnable runnable) { return helper.invoke(this, wait, runnable); } - + @Override public boolean invoke(final boolean wait, final Listrunnables) { return helper.invoke(this, wait, runnables); } - + @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { helper.setAnimator(arg0); @@ -714,7 +714,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { final GLContext oldCtx = context; GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; @@ -761,7 +761,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getChosenGLCapabilities() : null; } @@ -771,7 +771,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @return Non-null GLCapabilities. */ public GLCapabilitiesImmutable getRequestedGLCapabilities() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities() : null; } @@ -788,7 +788,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public long getHandle() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return (_drawable != null) ? _drawable.getHandle() : 0; } @@ -827,12 +827,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * * *
+ *- Current thread
- *modeBits
field and + * If present inmodeBits
field and * {@link GLProfile#isAWTAvailable() AWT is available}, * implementation is aware of the AWT EDT, otherwise not. *@@ -67,8 +67,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { *
* @see #setModeBits(boolean, int) */ - public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; - + public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; + public interface AnimatorImpl { void display(ArrayListdrawables, boolean ignoreExceptions, boolean printExceptions); boolean blockUntilDone(Thread thread); @@ -77,7 +77,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected int modeBits; protected AnimatorImpl impl; protected String baseName; - + protected ArrayList drawables = new ArrayList (); protected boolean drawablesEmpty; protected Thread animThread; @@ -85,10 +85,10 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected boolean printExceptions; protected boolean exclusiveContext; protected Thread userExclusiveContextThread; - protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); + protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected RecursiveLock stateSync = LockFactory.createRecursiveLock(); - - private final static Class> awtAnimatorImplClazz; + + private final static Class> awtAnimatorImplClazz; static { GLProfile.initSingleton(); if( GLProfile.isAWTAvailable() ) { @@ -96,7 +96,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { try { clazz = Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl"); } catch (Exception e) { - clazz = null; + clazz = null; } awtAnimatorImplClazz = clazz; } else { @@ -105,29 +105,29 @@ public abstract class AnimatorBase implements GLAnimatorControl { } /** - * Creates a new, empty Animator instance + * Creates a new, empty Animator instance * while expecting an AWT rendering thread if AWT is available. - * + * * @see GLProfile#isAWTAvailable() */ public AnimatorBase() { - modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! + modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! drawablesEmpty = true; } - + private static final boolean useAWTAnimatorImpl(int modeBits) { return 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz; } - + /** * Initializes implementation details post setup, * invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, .. * - * Operation is a NOP if
- * - * @throws GLException if Animator is {@link #isStarted()} + * + * + * @throws GLException if Animator is {@link #isStarted()} */ protected synchronized void initImpl(boolean force) { if( force || null == impl ) { @@ -153,8 +153,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { * in this Animatorsforce
isfalse
+ * Operation is a NOP ifforce
isfalse
* and this instance is already initialized. - *modeBits
. * @param enable * @param bitValues - * - * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change + * + * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD */ public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { @@ -172,8 +172,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { } } public synchronized int getModeBits() { return modeBits; } - - + + @Override public synchronized void add(final GLAutoDrawable drawable) { if(DEBUG) { @@ -190,7 +190,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { drawables.add(drawable); drawablesEmpty = drawables.size() == 0; drawable.setAnimator(this); - if( isPaused() ) { // either paused by pause() above, or if previously drawablesEmpty==true + if( isPaused() ) { // either paused by pause() above, or if previously drawablesEmpty==true resume(); } final Condition waitForAnimatingAndECTCondition = new Condition() { @@ -213,7 +213,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( !drawables.contains(drawable) ) { throw new IllegalArgumentException("Drawable not added to animator: "+this+", "+drawable); } - + if( exclusiveContext && isAnimating() ) { drawable.setExclusiveContextThread( null ); final Condition waitForNullECTCondition = new Condition() { @@ -244,7 +244,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { return isStarted() && drawablesEmpty && isAnimating(); } }; - + /** * Dedicate all {@link GLAutoDrawable}'s context to the given exclusive context thread. *@@ -252,14 +252,14 @@ public abstract class AnimatorBase implements GLAnimatorControl { *
** If already started and disabling, method waits - * until change is propagated to all {@link GLAutoDrawable} if not + * until change is propagated to all {@link GLAutoDrawable} if not * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. *
** Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. *
- * + * * @param enable * @return previous value * @see #setExclusiveContext(boolean) @@ -272,7 +272,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { final boolean enable = null != t; stateSync.lock(); try { - old = userExclusiveContextThread; + old = userExclusiveContextThread; if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae userExclusiveContextThread=t; } @@ -282,7 +282,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { setExclusiveContext(enable); return old; } - + /** * Dedicate all {@link GLAutoDrawable}'s context to this animator thread. *@@ -290,14 +290,14 @@ public abstract class AnimatorBase implements GLAnimatorControl { *
** If already started and disabling, method waits - * until change is propagated to all {@link GLAutoDrawable} if not + * until change is propagated to all {@link GLAutoDrawable} if not * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. *
** Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. *
- * + * * @param enable * @return previous value * @see #setExclusiveContext(Thread) @@ -349,24 +349,24 @@ public abstract class AnimatorBase implements GLAnimatorControl { System.err.println("AnimatorBase.setExclusiveContextThread: all-GLAD Ok: "+validateDrawablesExclCtxState(dECT)+", "+this); } return oldExclusiveContext; - } - + } + /** * Returnstrue
, if the exclusive context thread is enabled, otherwisefalse
. - * + * * @see #setExclusiveContext(boolean) * @see #setExclusiveContext(Thread) */ // @Override - public final boolean isExclusiveContextEnabled() { + public final boolean isExclusiveContextEnabled() { stateSync.lock(); try { - return exclusiveContext; + return exclusiveContext; } finally { stateSync.unlock(); } } - + /** * Returns the exclusive context thread if {@link #isExclusiveContextEnabled()} and {@link #isStarted()}, otherwisenull
. *@@ -381,7 +381,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #setExclusiveContext(Thread) */ // @Override - public final Thread getExclusiveContextThread() { + public final Thread getExclusiveContextThread() { stateSync.lock(); try { return ( isStartedImpl() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; @@ -389,7 +389,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { stateSync.unlock(); } } - + /** * Should be called at {@link #start()} and {@link #stop()} * from within the animator thread. @@ -407,7 +407,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { for (int i=0; i
*false. - * @param pollPeriod if 0
, method will wait until TO is reached or being notified. + * @param pollPeriod if0
, method will wait until TO is reached or being notified. * if >0
, method will wait for the givenpollPeriod
in milliseconds. * @returntrue
if {@link Condition#eval() waitCondition.eval()} returnedfalse
, otherwisefalse
. */ @@ -545,11 +545,11 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( remaining<=0 && nok ) { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName()); } - stateSync.lock(); // avoid too many lock/unlock ops + stateSync.lock(); // avoid too many lock/unlock ops try { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ "- pollPeriod "+pollPeriod+", blocking "+blocking+ - ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + + ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + " - " + getThreadName()); System.err.println(" - "+toString()); } finally { diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index bbd2951b9..0477e1903 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 7613efec6..b48169c27 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -45,10 +45,10 @@ import java.util.TimerTask; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLException; -/** +/** * An Animator subclass which attempts to achieve a target * frames-per-second rate to avoid using all CPU time. The target FPS - * is only an estimate and is not guaranteed. + * is only an estimate and is not guaranteed. ** The Animator execution thread does not run as a daemon thread, * so it is able to keep an application from terminating.
* * @see #seal(boolean) - */ + */ public void seal(boolean seal); public void rewind(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index 7e7d27b36..80639c5c7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -57,13 +57,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * and starting with a given Buffer object incl it's stride * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -90,13 +90,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * and starting with a new created Buffer object with initialElementCount size * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -106,7 +106,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -120,7 +120,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE /** * Create a VBO, using a custom GLSL array attribute name * and starting with a new created Buffer object with initialElementCount size - * @param name The custom name for the GL attribute + * @param name The custom name for the GL attribute * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -128,20 +128,20 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ public static GLArrayDataServer createGLSL(String name, int comps, - int dataType, boolean normalized, int initialElementCount, int vboUsage) - throws GLException + int dataType, boolean normalized, int initialElementCount, int vboUsage) + throws GLException { GLArrayDataServer ads = new GLArrayDataServer(); GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); ads.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; - } - + } + /** * Create a VBO, using a custom GLSL array attribute name * and starting with a given Buffer object incl it's stride - * @param name The custom name for the GL attribute + * @param name The custom name for the GL attribute * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -151,7 +151,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE */ public static GLArrayDataServer createGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer, - int vboUsage) + int vboUsage) throws GLException { GLArrayDataServer ads = new GLArrayDataServer(); @@ -160,12 +160,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; } - + /** * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}. - * + * * Hence no index, name for a fixed function pipeline nor vertex attribute is given. - * + * * @param comps The array component number * @param dataType The array index GL data type * @param stride @@ -187,16 +187,16 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE /** * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}. - * + * * Hence no index, name for a fixed function pipeline nor vertex attribute is given. - * + * * @param comps The array component number * @param dataType The array index GL data type * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, .. */ - public static GLArrayDataServer createData(int comps, int dataType, int initialElementCount, + public static GLArrayDataServer createData(int comps, int dataType, int initialElementCount, int vboUsage, int vboTarget) throws GLException { @@ -207,19 +207,19 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } - + /** * Create a VBO for fixed function interleaved array data * starting with a new created Buffer object with initialElementCount size. *
@@ -105,45 +105,45 @@ public class FPSAnimator extends AnimatorBase { * @param fps * @throws GLException if the animator has already been started */ - public final synchronized void setFPS(int fps) throws GLException { + public final synchronized void setFPS(int fps) throws GLException { if ( isStartedImpl() ) { throw new GLException("Animator already started."); } - this.fps = fps; + this.fps = fps; } public final int getFPS() { return fps; } - + class MainTask extends TimerTask { private boolean justStarted; private boolean alreadyStopped; private boolean alreadyPaused; - + public MainTask() { } - + public void start(Timer timer) { fpsCounter.resetFPSCounter(); shouldRun = true; shouldStop = false; - + justStarted = true; alreadyStopped = false; alreadyPaused = false; - final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period + final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period if (scheduleAtFixedRate) { timer.scheduleAtFixedRate(this, 0, period); } else { timer.schedule(this, 0, period); } } - + public boolean isActive() { return !alreadyStopped && !alreadyPaused; } - + public String toString() { return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } - + public void run() { if( justStarted ) { justStarted = false; @@ -167,8 +167,8 @@ public class FPSAnimator extends AnimatorBase { display(); } else if( shouldStop ) { // STOP System.err.println("FPSAnimator P4: "+alreadyStopped+", "+ Thread.currentThread() + ": " + toString()); - this.cancel(); - + this.cancel(); + if( !alreadyStopped ) { alreadyStopped = true; if( exclusiveContext && !drawablesEmpty ) { @@ -184,23 +184,23 @@ public class FPSAnimator extends AnimatorBase { FPSAnimator.this.notifyAll(); } } - } else { + } else { System.err.println("FPSAnimator P5: "+alreadyPaused+", "+ Thread.currentThread() + ": " + toString()); this.cancel(); - + if( !alreadyPaused ) { // PAUSE alreadyPaused = true; if( exclusiveContext && !drawablesEmpty ) { setDrawablesExclCtxState(false); display(); // propagate exclusive change! } - synchronized (FPSAnimator.this) { + synchronized (FPSAnimator.this) { if(DEBUG) { System.err.println("FPSAnimator pause " + Thread.currentThread() + ": " + toString()); } isAnimating = false; FPSAnimator.this.notifyAll(); - } + } } } } @@ -230,7 +230,7 @@ public class FPSAnimator extends AnimatorBase { } static int timerNo = 0; - + public synchronized boolean start() { if ( null != timer || null != task || isStartedImpl() ) { return false; @@ -241,8 +241,8 @@ public class FPSAnimator extends AnimatorBase { System.err.println("FPSAnimator.start() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } task.start(timer); - - final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, + + final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); if(DEBUG) { System.err.println("FPSAnimator.start() END: "+task+", "+ Thread.currentThread() + ": " + toString()); @@ -256,11 +256,11 @@ public class FPSAnimator extends AnimatorBase { private final Condition waitForStartedAddedCondition = new Condition() { public boolean eval() { return !isStartedImpl() || !isAnimating ; - } }; + } }; private final Condition waitForStartedEmptyCondition = new Condition() { public boolean eval() { return !isStartedImpl() || isAnimating ; - } }; + } }; /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be @@ -268,7 +268,7 @@ public class FPSAnimator extends AnimatorBase { public synchronized boolean stop() { if ( null == timer || !isStartedImpl() ) { return false; - } + } if(DEBUG) { System.err.println("FPSAnimator.stop() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } @@ -281,7 +281,7 @@ public class FPSAnimator extends AnimatorBase { shouldStop = true; res = finishLifecycleAction(waitForStoppedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); } - + if(DEBUG) { System.err.println("FPSAnimator.stop() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } @@ -316,7 +316,7 @@ public class FPSAnimator extends AnimatorBase { shouldRun = false; res = finishLifecycleAction(waitForPausedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); } - + if(DEBUG) { System.err.println("FPSAnimator.pause() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index e0bbbc33c..2d685a1a8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -53,13 +53,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * and starting with a new created Buffer object with initialElementCount size * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -67,7 +67,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param initialElementCount * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) - */ + */ public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException { @@ -82,13 +82,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * and starting with a given Buffer object incl it's stride * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -97,8 +97,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param buffer the user define data * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) - */ - public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, + */ + public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer) throws GLException { @@ -111,13 +111,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData /** * Create a client side buffer object, using a custom GLSL array attribute name * and starting with a new created Buffer object with initialElementCount size - * @param name The custom name for the GL attribute. + * @param name The custom name for the GL attribute. * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized * @param initialElementCount */ - public static GLArrayDataClient createGLSL(String name, int comps, + public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException { @@ -130,7 +130,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData /** * Create a client side buffer object, using a custom GLSL array attribute name * and starting with a given Buffer object incl it's stride - * @param name The custom name for the GL attribute. + * @param name The custom name for the GL attribute. * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -157,8 +157,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } } } - - // + + // // Data read access // @@ -167,7 +167,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData @Override public final boolean sealed() { return sealed; } - + @Override public final boolean enabled() { return bufferEnabled; } @@ -195,10 +195,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData seal(seal); enableBuffer(gl, seal); } - + @Override public void enableBuffer(GL gl, boolean enable) { - if( enableBufferAlways || bufferEnabled != enable ) { + if( enableBufferAlways || bufferEnabled != enable ) { if(enable) { checkSeal(true); // init/generate VBO name if not done yet @@ -208,7 +208,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData bufferEnabled = enable; } } - + @Override public boolean bindBuffer(GL gl, boolean bind) { if(bind) { @@ -218,7 +218,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } return glArrayHandler.bindBuffer(gl, bind); } - + @Override public void setEnableAlways(boolean always) { enableBufferAlways = always; @@ -328,15 +328,15 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData ", isVertexAttribute "+isVertexAttribute+ ", usesGLSL "+usesGLSL+ ", usesShaderState "+(null!=shaderState)+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ - ", initialElementCount "+initialElementCount+ - ", sealed "+sealed+ - ", bufferEnabled "+bufferEnabled+ - ", bufferWritten "+bufferWritten+ + ", initialElementCount "+initialElementCount+ + ", sealed "+sealed+ + ", bufferEnabled "+bufferEnabled+ + ", bufferWritten "+bufferWritten+ ", buffer "+buffer+ ", alive "+alive+ "]"; @@ -345,16 +345,16 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData // non public matters protected final boolean growBufferIfNecessary(int spare) { - if(buffer==null || buffer.remaining()enable is true
, + * Enables the buffer ifenable
istrue
, * and transfers the data if required. * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and association, * i.e. it issued {@link #bindBuffer(GL, boolean)}. - * The VBO buffer is unbound when the method returns. + * The VBO buffer is unbound when the method returns. *- * Disables the buffer if
- * + * *enable
isfalse
. + * Disables the buffer ifenable
isfalse
. *The action will only be executed, - * if the internal enable state differs, + * if the internal enable state differs, * or 'setEnableAlways' was called with 'true'. - * + * *
It is up to the user to enable/disable the array properly, * ie in case of multiple data sets for the same vertex attribute (VA). * Meaning in such case usage of one set while expecting another one @@ -68,7 +68,7 @@ public interface GLArrayDataEditable extends GLArrayData { public void enableBuffer(GL gl, boolean enable); /** - * if
bind
is true and the data uses {@link #isVBO() VBO}, + * ifbind
is true and the data uses {@link #isVBO() VBO}, * the latter will be bound and data written to the GPU if required. ** If
- * + * * @param gl current GL object - * @param bind true if VBO shall be bound and data written, - * otherwise clear VBO binding. - * @return true if data uses VBO and action was performed, otherwise false + * @param bind true if VBO shall be bound and data written, + * otherwise clear VBO binding. + * @return true if data uses VBO and action was performed, otherwise false */ public boolean bindBuffer(GL gl, boolean bind); @@ -92,7 +92,7 @@ public interface GLArrayDataEditable extends GLArrayData { * * The default is 'false' * - * This is useful when you mix up + * This is useful when you mix up * GLArrayData usage with conventional GL array calls * or in case of a buggy GL VBO implementation. * @@ -117,7 +117,7 @@ public interface GLArrayDataEditable extends GLArrayData { * ie position:=limit and limit:=capacity.bind
is false and the data uses {@link #isVBO() VBO}, @@ -79,11 +79,11 @@ public interface GLArrayDataEditable extends GLArrayData { * to be bounded and written while keeping the VBO bound. The latter is in contrast to {@link #enableBuffer(GL, boolean)}, * which leaves the VBO unbound, since it's not required for vertex attributes or pointers. *User needs to configure the interleaved segments via {@link #addFixedSubArray(int, int, int)}.
- * + * * @param comps The total number of all interleaved components. * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized - * @param initialElementCount + * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -239,7 +239,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * The memory of the the interleaved array is being used.* Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, ..
- * + * * @param index The GL array index, maybe -1 if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @param comps This interleaved array segment's component number * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} @@ -250,32 +250,32 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); } if(usesGLSL) { - throw new GLException("buffer uses GLSL"); + throw new GLException("buffer uses GLSL"); } final GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed( - index, comps, getComponentType(), - getNormalized(), getStride(), getBuffer(), + index, comps, getComponentType(), + getNormalized(), getStride(), getBuffer(), getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); ad.setVBOEnabled(isVBO()); interleavedOffset += comps * getComponentSizeInBytes(); - if(GL.GL_ARRAY_BUFFER == vboTarget) { + if(GL.GL_ARRAY_BUFFER == vboTarget) { glArrayHandler.addSubHandler(new GLFixedArrayHandlerFlat(ad)); } return ad; } - + /** * Create a VBO for GLSL interleaved array data * starting with a new created Buffer object with initialElementCount size. *User needs to configure the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.
- * + * * @param comps The total number of all interleaved components. * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized - * @param initialElementCount + * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -285,7 +285,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; } - + /** * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}). *@@ -305,20 +305,20 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); } if(!usesGLSL) { - throw new GLException("buffer uses fixed function"); + throw new GLException("buffer uses fixed function"); } final GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL( - name, comps, getComponentType(), - getNormalized(), getStride(), getBuffer(), - getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); + name, comps, getComponentType(), + getNormalized(), getStride(), getBuffer(), + getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); ad.setVBOEnabled(isVBO()); interleavedOffset += comps * getComponentSizeInBytes(); - if(GL.GL_ARRAY_BUFFER == vboTarget) { + if(GL.GL_ARRAY_BUFFER == vboTarget) { glArrayHandler.addSubHandler(new GLSLArrayHandlerFlat(ad)); } return ad; } - + // // Data matters GLArrayData // @@ -341,15 +341,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } // - // data matters + // data matters // /** - * Convenient way do disable the VBO behavior and + * Convenient way do disable the VBO behavior and * switch to client side data one * Only possible if buffer is defined. */ - public void setVBOEnabled(boolean vboUsage) { + public void setVBOEnabled(boolean vboUsage) { checkSeal(false); super.setVBOEnabled(vboUsage); } @@ -361,22 +361,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE ", isVertexAttribute "+isVertexAttribute+ ", usesGLSL "+usesGLSL+ ", usesShaderState "+(null!=shaderState)+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ ", initialElementCount "+initialElementCount+ - ", vboEnabled "+vboEnabled+ - ", vboName "+vboName+ - ", vboUsage 0x"+Integer.toHexString(vboUsage)+ - ", vboTarget 0x"+Integer.toHexString(vboTarget)+ - ", vboOffset "+vboOffset+ - ", sealed "+sealed+ - ", bufferEnabled "+bufferEnabled+ - ", bufferWritten "+bufferWritten+ - ", buffer "+buffer+ - ", alive "+alive+ + ", vboEnabled "+vboEnabled+ + ", vboName "+vboName+ + ", vboUsage 0x"+Integer.toHexString(vboUsage)+ + ", vboTarget 0x"+Integer.toHexString(vboTarget)+ + ", vboOffset "+vboOffset+ + ", sealed "+sealed+ + ", bufferEnabled "+bufferEnabled+ + ", bufferWritten "+bufferWritten+ + ", buffer "+buffer+ + ", alive "+alive+ "]"; } @@ -384,7 +384,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // non public matters .. // - protected void init(String name, int index, int comps, int dataType, boolean normalized, + protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data, int initialElementCount, boolean isVertexAttribute, GLArrayHandler glArrayHandler, int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL) @@ -407,7 +407,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } } } - - private int interleavedOffset = 0; + + private int interleavedOffset = 0; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java index f8b17501e..290f47a6d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java @@ -49,7 +49,7 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Create a VBO, using a predefined fixed function array index, wrapping the given data. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -61,23 +61,23 @@ public class GLArrayDataWrapper implements GLArrayData { * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @return the new create instance - * + * * @throws GLException */ - public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, + public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { GLArrayDataWrapper adc = new GLArrayDataWrapper(); - adc.init(null, index, comps, dataType, normalized, stride, buffer, false, + adc.init(null, index, comps, dataType, normalized, stride, buffer, false, vboName, vboOffset, vboUsage, vboTarget); return adc; } /** * Create a VBO, using a custom GLSL array attribute name, wrapping the given data. - * - * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} + * + * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -90,7 +90,7 @@ public class GLArrayDataWrapper implements GLArrayData { * @return the new create instance * @throws GLException */ - public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, + public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { @@ -102,8 +102,8 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Validates this instance's parameter. Called automatically by {@link GLArrayDataClient} and {@link GLArrayDataServer}. - * {@link GLArrayDataWrapper} does not validate it's instance by itself. - * + * {@link GLArrayDataWrapper} does not validate it's instance by itself. + * * @param glp the GLProfile to use * @param throwException whether to throw an exception if this instance has invalid parameter or not * @return true if this instance has invalid parameter, otherwise false @@ -113,7 +113,7 @@ public class GLArrayDataWrapper implements GLArrayData { if(throwException) { throw new GLException("Instance !alive "+this); } - return false; + return false; } if(this.isVertexAttribute() && !glp.hasGLSL()) { if(throwException) { @@ -123,13 +123,13 @@ public class GLArrayDataWrapper implements GLArrayData { } return glp.isValidArrayDataType(getIndex(), getComponentCount(), getComponentType(), isVertexAttribute(), throwException); } - + @Override public void associate(Object obj, boolean enable) { // nop } - - // + + // // Data read access // @@ -150,14 +150,14 @@ public class GLArrayDataWrapper implements GLArrayData { location = gl.glGetAttribLocation(program, name); return location; } - + @Override public final int setLocation(GL2ES2 gl, int program, int location) { this.location = location; gl.glBindAttribLocation(program, location, name); return location; } - + @Override public final String getName() { return name; } @@ -172,10 +172,10 @@ public class GLArrayDataWrapper implements GLArrayData { @Override public final int getVBOUsage() { return vboEnabled?vboUsage:0; } - + @Override public final int getVBOTarget() { return vboEnabled?vboTarget:0; } - + @Override public final Buffer getBuffer() { return buffer; } @@ -187,19 +187,19 @@ public class GLArrayDataWrapper implements GLArrayData { @Override public final int getComponentSizeInBytes() { return componentByteSize; } - + @Override public final int getElementCount() { if(null==buffer) return 0; return ( buffer.position()==0 ) ? ( buffer.limit() / components ) : ( buffer.position() / components ) ; } - + @Override public final int getSizeInBytes() { if(null==buffer) return 0; - return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ; + return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ; } - + @Override public final boolean getNormalized() { return normalized; } @@ -223,18 +223,18 @@ public class GLArrayDataWrapper implements GLArrayData { ", index "+index+ ", location "+location+ ", isVertexAttribute "+isVertexAttribute+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ - ", buffer "+buffer+ - ", vboEnabled "+vboEnabled+ - ", vboName "+vboName+ - ", vboUsage 0x"+Integer.toHexString(vboUsage)+ - ", vboTarget 0x"+Integer.toHexString(vboTarget)+ - ", vboOffset "+vboOffset+ - ", alive "+alive+ + ", buffer "+buffer+ + ", vboEnabled "+vboEnabled+ + ", vboName "+vboName+ + ", vboUsage 0x"+Integer.toHexString(vboUsage)+ + ", vboTarget 0x"+Integer.toHexString(vboTarget)+ + ", vboOffset "+vboOffset+ + ", alive "+alive+ "]"; } @@ -252,12 +252,12 @@ public class GLArrayDataWrapper implements GLArrayData { return IntBuffer.class; case GL.GL_FLOAT: return FloatBuffer.class; - default: + default: throw new GLException("Given OpenGL data type not supported: "+dataType); } } - @Override + @Override public void setName(String newName) { location = -1; name = newName; @@ -267,7 +267,7 @@ public class GLArrayDataWrapper implements GLArrayData { * Enable or disable use of VBO. * Only possible if a VBO buffer name is defined. * @see #setVBOName(int) - */ + */ public void setVBOEnabled(boolean vboEnabled) { this.vboEnabled=vboEnabled; } @@ -275,31 +275,31 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Set the VBO buffer name, if valid (!= 0) enable use of VBO, * otherwise (==0) disable VBO usage. - * + * * @see #setVBOEnabled(boolean) - */ + */ public void setVBOName(int vboName) { this.vboName=vboName; setVBOEnabled(0!=vboName); } - /** + /** * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} - */ - public void setVBOUsage(int vboUsage) { - this.vboUsage = vboUsage; + */ + public void setVBOUsage(int vboUsage) { + this.vboUsage = vboUsage; } - - /** + + /** * @param vboTarget either {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} - */ + */ public void setVBOTarget(int vboTarget) { this.vboTarget = vboTarget; - } + } - protected void init(String name, int index, int components, int componentType, - boolean normalized, int stride, Buffer data, - boolean isVertexAttribute, + protected void init(String name, int index, int components, int componentType, + boolean normalized, int stride, Buffer data, + boolean isVertexAttribute, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { @@ -307,19 +307,19 @@ public class GLArrayDataWrapper implements GLArrayData { this.index = index; this.location = -1; // We can't have any dependence on the FixedFuncUtil class here for build bootstrapping reasons - + if( GL.GL_ELEMENT_ARRAY_BUFFER == vboTarget ) { // OK .. } else if( ( 0 == vboUsage && 0 == vboTarget ) || GL.GL_ARRAY_BUFFER == vboTarget ) { - // Set/Check name .. - Required for GLSL case. Validation and debug-name for FFP. + // Set/Check name .. - Required for GLSL case. Validation and debug-name for FFP. this.name = ( null == name ) ? GLPointerFuncUtil.getPredefinedArrayIndexName(index) : name ; if(null == this.name ) { throw new GLException("Not a valid array buffer index: "+index); - } + } } else if( 0 < vboTarget ) { throw new GLException("Invalid GPUBuffer target: 0x"+Integer.toHexString(vboTarget)); } - + this.componentType = componentType; componentClazz = getBufferClass(componentType); if( GLBuffers.isGLTypeFixedPoint(componentType) ) { @@ -329,7 +329,7 @@ public class GLArrayDataWrapper implements GLArrayData { } componentByteSize = GLBuffers.sizeOfGLType(componentType); if(0 > componentByteSize) { - throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this); + throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this); } if(0 >= components) { throw new GLException("Invalid number of components: " + components); @@ -348,7 +348,7 @@ public class GLArrayDataWrapper implements GLArrayData { this.vboName= vboName; this.vboEnabled= 0 != vboName ; this.vboOffset=vboOffset; - + switch(vboUsage) { case 0: // nop case GL.GL_STATIC_DRAW: @@ -356,7 +356,7 @@ public class GLArrayDataWrapper implements GLArrayData { case GL2ES2.GL_STREAM_DRAW: break; default: - throw new GLException("invalid gpuBufferUsage: "+vboUsage+":\n\t"+this); + throw new GLException("invalid gpuBufferUsage: "+vboUsage+":\n\t"+this); } switch(vboTarget) { case 0: // nop @@ -367,7 +367,7 @@ public class GLArrayDataWrapper implements GLArrayData { throw new GLException("invalid gpuBufferTarget: "+vboTarget+":\n\t"+this); } this.vboUsage=vboUsage; - this.vboTarget=vboTarget; + this.vboTarget=vboTarget; this.alive=true; } @@ -390,6 +390,6 @@ public class GLArrayDataWrapper implements GLArrayData { protected int vboName; protected boolean vboEnabled; protected int vboUsage; - protected int vboTarget; + protected int vboTarget; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java index 6bdea4518..418d7fa81 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2008 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 @@ -28,11 +28,11 @@ * 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. */ @@ -52,7 +52,7 @@ import com.jogamp.common.nio.Buffers; /** * Utility routines for dealing with direct buffers. - * + * * @author Kenneth Russel, et.al. */ public class GLBuffers extends Buffers { @@ -72,11 +72,11 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_INT: case GL2.GL_HILO16_NV: return false; - + } return true; } - + /** * @param glType GL primitive type * @return false if one of GL primitive floating point types, otherwise true @@ -92,19 +92,19 @@ public class GLBuffers extends Buffers { case GLES2.GL_HALF_FLOAT_OES: case GL2GL3.GL_DOUBLE: return false; - + default: return true; - } + } } - + /** * @param glType shall be one of (31)
* GL_BYTE, GL_UNSIGNED_BYTE,
* GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
*
* GL_SHORT, GL_UNSIGNED_SHORT,
- * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
* GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
* GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
* GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
@@ -112,16 +112,16 @@ public class GLBuffers extends Buffers { *
* GL_FIXED, GL_INT
* GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
- * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
+ * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
* GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
- * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
+ * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
* GL_HILO16_NV, GL_SIGNED_HILO16_NV
*
* GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV
*
- * GL_FLOAT, GL_DOUBLE
- * - * @return -1 if glType is unhandled, otherwise the actual value > 0 + * GL_FLOAT, GL_DOUBLE
+ * + * @return -1 if glType is unhandled, otherwise the actual value > 0 */ public static final int sizeOfGLType(int glType) { switch (glType) { // 29 @@ -131,7 +131,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: return SIZEOF_BYTE; - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -145,40 +145,40 @@ public class GLBuffers extends Buffers { case GL.GL_HALF_FLOAT: case GLES2.GL_HALF_FLOAT_OES: return SIZEOF_SHORT; - + case GL.GL_FIXED: case GL2ES2.GL_INT: case GL.GL_UNSIGNED_INT: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: case GL2GL3.GL_UNSIGNED_INT_24_8: case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return SIZEOF_INT; - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return SIZEOF_LONG; - + case GL.GL_FLOAT: return SIZEOF_FLOAT; - + case GL2GL3.GL_DOUBLE: return SIZEOF_DOUBLE; } return -1; } - + /** * @param glType shall be one of (31)
* GL_BYTE, GL_UNSIGNED_BYTE,
* GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
*
* GL_SHORT, GL_UNSIGNED_SHORT,
- * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
* GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
* GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
* GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
@@ -186,16 +186,16 @@ public class GLBuffers extends Buffers { *
* GL_FIXED, GL_INT
* GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
- * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
+ * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
* GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
- * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
+ * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
* GL_HILO16_NV, GL_SIGNED_HILO16_NV
*
* GL_FLOAT_32_UNSIGNED_INT_24_8_REV
*
- * GL_FLOAT, GL_DOUBLE
- * - * @return null if glType is unhandled, otherwise the new Buffer object + * GL_FLOAT, GL_DOUBLE
+ * + * @return null if glType is unhandled, otherwise the new Buffer object */ public static final Buffer newDirectGLBuffer(int glType, int numElements) { switch (glType) { // 29 @@ -204,7 +204,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: return newDirectByteBuffer(numElements); - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -218,7 +218,7 @@ public class GLBuffers extends Buffers { case GL.GL_HALF_FLOAT: case GLES2.GL_HALF_FLOAT_OES: return newDirectShortBuffer(numElements); - + case GL.GL_FIXED: case GL2ES2.GL_INT: case GL.GL_UNSIGNED_INT: @@ -232,13 +232,13 @@ public class GLBuffers extends Buffers { case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return newDirectIntBuffer(numElements); - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return newDirectLongBuffer(numElements); - + case GL.GL_FLOAT: return newDirectFloatBuffer(numElements); - + case GL2.GL_DOUBLE: return newDirectDoubleBuffer(numElements); } @@ -251,7 +251,7 @@ public class GLBuffers extends Buffers { * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
*
* GL_SHORT, GL_UNSIGNED_SHORT,
- * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
* GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
* GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
* GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
@@ -259,15 +259,15 @@ public class GLBuffers extends Buffers { *
* GL_FIXED, GL_INT
* GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
- * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
+ * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
* GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
- * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
+ * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
* GL_HILO16_NV, GL_SIGNED_HILO16_NV
*
* GL_FLOAT_32_UNSIGNED_INT_24_8_REV
*
- * GL_FLOAT, GL_DOUBLE
- * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object + * GL_FLOAT, GL_DOUBLE
+ * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object */ public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) { if (parent == null || byteLen == 0) { @@ -275,11 +275,11 @@ public class GLBuffers extends Buffers { } final int parentPos = parent.position(); final int parentLimit = parent.limit(); - + parent.position(bytePos); parent.limit(bytePos + byteLen); Buffer res = null; - + switch (glType) { // 29 case GL.GL_BYTE: case GL.GL_UNSIGNED_BYTE: @@ -287,7 +287,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: res = parent.slice().order(parent.order()); // slice and duplicate may change byte order break; - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -302,7 +302,7 @@ public class GLBuffers extends Buffers { case GLES2.GL_HALF_FLOAT_OES: res = parent.slice().order(parent.order()).asShortBuffer(); // slice and duplicate may change byte order break; - + case GL.GL_FIXED: case GL2GL3.GL_INT: case GL2ES2.GL_UNSIGNED_INT: @@ -317,15 +317,15 @@ public class GLBuffers extends Buffers { case GL2.GL_SIGNED_HILO16_NV: res = parent.slice().order(parent.order()).asIntBuffer(); // slice and duplicate may change byte order break; - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: res = parent.slice().order(parent.order()).asLongBuffer(); // slice and duplicate may change byte order break; - + case GL.GL_FLOAT: res = parent.slice().order(parent.order()).asFloatBuffer(); // slice and duplicate may change byte order break; - + case GL2.GL_DOUBLE: res = parent.slice().order(parent.order()).asDoubleBuffer(); // slice and duplicate may change byte order break; @@ -338,29 +338,29 @@ public class GLBuffers extends Buffers { gl.glGetIntegerv(pname, tmp, 0); return tmp[0]; } - - /** + + /** * Returns the number of bytes required to read/write a memory buffer via OpenGL * using the current GL pixel storage state and the given parameters. - * + * *This method is security critical, hence it throws an exception (fail-fast) - * in case of an invalid alignment. In case we forgot to handle - * proper values, please contact the maintainer.
- * + * in case of an invalid alignment. In case we forgot to handle + * proper values, please contact the maintainer. + * * @param gl the current GL object - * + * * @param tmp a pass through integer array of size >= 1 used to store temp data (performance) - * + * * @param bytesPerPixel bytes per pixel, i.e. via {@link #bytesPerPixel(int, int)}. * @param width in pixels * @param height in pixels * @param depth in pixels - * @param pack true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack) + * @param pack true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack) * @return required minimum size of the buffer in bytes * @throws GLException if alignment is invalid. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], - int bytesPerPixel, int width, int height, int depth, + public static final int sizeof(GL gl, int tmp[], + int bytesPerPixel, int width, int height, int depth, boolean pack) { int rowLength = 0; int skipRows = 0; @@ -368,31 +368,31 @@ public class GLBuffers extends Buffers { int alignment = 1; int imageHeight = 0; int skipImages = 0; - - if (pack) { + + if (pack) { alignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT, tmp); if(gl.isGL2GL3()) { rowLength = glGetInteger(gl, GL2GL3.GL_PACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp); + skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp); skipPixels = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_PIXELS, tmp); - if (depth > 1) { - imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp); + if (depth > 1) { + imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp); skipImages = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_IMAGES, tmp); } } - } else { + } else { alignment = glGetInteger(gl, GL.GL_UNPACK_ALIGNMENT, tmp); - if(gl.isGL2GL3 ()) { - rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp); + if(gl.isGL2GL3 ()) { + rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp); + skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp); skipPixels = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_PIXELS, tmp); - if (depth > 1) { - imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp); + if (depth > 1) { + imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp); skipImages = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_IMAGES, tmp); } } } - + // Try to deal somewhat correctly with potentially invalid values width = Math.max(0, width ); height = Math.max(1, height); // min 1D @@ -401,13 +401,13 @@ public class GLBuffers extends Buffers { skipPixels = Math.max(0, skipPixels); alignment = Math.max(1, alignment); skipImages = Math.max(0, skipImages); - + imageHeight = ( imageHeight > 0 ) ? imageHeight : height; rowLength = ( rowLength > 0 ) ? rowLength : width; - + int rowLengthInBytes = rowLength * bytesPerPixel; int skipBytes = skipPixels * bytesPerPixel; - + switch(alignment) { case 1: break; @@ -423,71 +423,71 @@ public class GLBuffers extends Buffers { if (remainder > 0) { skipBytes += alignment - remainder; } - } + } break; default: - throw new GLException("Invalid alignment "+alignment+", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug."); + throw new GLException("Invalid alignment "+alignment+", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug."); } - + /** * skipImages, depth, skipPixels and skipRows are static offsets. * * skipImages and depth are in multiples of image size. * * skipBytes and rowLengthInBytes are aligned - * - * rowLengthInBytes is the aligned byte offset + * + * rowLengthInBytes is the aligned byte offset * from line n to line n+1 at the same x-axis position. */ return skipBytes + // aligned skipPixels * bpp - ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // aligned whole images + ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // aligned whole images ( skipRows + height - 1 ) * rowLengthInBytes + // aligned lines - width * bytesPerPixel; // last line + width * bytesPerPixel; // last line } - - /** + + /** * Returns the number of bytes required to read/write a memory buffer via OpenGL * using the current GL pixel storage state and the given parameters. - * + * *This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.
- * + * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer. + * *See {@link #bytesPerPixel(int, int)}.
- * + * * @param gl the current GL object - * + * * @param tmp a pass through integer array of size >= 1 used to store temp data (performance) - * - * @param format must be one of (27)
- * GL_COLOR_INDEX GL_STENCIL_INDEX
- * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
- * GL_RED GL_RED_INTEGER
- * GL_GREEN GL_GREEN_INTEGER
- * GL_BLUE GL_BLUE_INTEGER
- * GL_ALPHA GL_LUMINANCE (12)
- *
+ * + * @param format must be one of (27)
+ * GL_COLOR_INDEX GL_STENCIL_INDEX
+ * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
+ * GL_RED GL_RED_INTEGER
+ * GL_GREEN GL_GREEN_INTEGER
+ * GL_BLUE GL_BLUE_INTEGER
+ * GL_ALPHA GL_LUMINANCE (12)
+ *
* GL_LUMINANCE_ALPHA GL_RG
- * GL_RG_INTEGER GL_HILO_NV
- * GL_SIGNED_HILO_NV (5)
- *
- * GL_YCBCR_422_APPLE
- *
- * GL_RGB GL_RGB_INTEGER
- * GL_BGR GL_BGR_INTEGER (4)
- *
- * GL_RGBA GL_RGBA_INTEGER
+ * GL_RG_INTEGER GL_HILO_NV
+ * GL_SIGNED_HILO_NV (5)
+ *
+ * GL_YCBCR_422_APPLE
+ *
+ * GL_RGB GL_RGB_INTEGER
+ * GL_BGR GL_BGR_INTEGER (4)
+ *
+ * GL_RGBA GL_RGBA_INTEGER
* GL_BGRA GL_BGRA_INTEGER
- * GL_ABGR_EXT (5)
- * - * @param type must be one of (32)
- * GL_BITMAP,
+ * GL_ABGR_EXT (5)
+ * + * @param type must be one of (32)
+ * GL_BITMAP,
* GL_BYTE, GL_UNSIGNED_BYTE,
* GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
*
* GL_SHORT, GL_UNSIGNED_SHORT,
- * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
* GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
* GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
* GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
@@ -495,70 +495,70 @@ public class GLBuffers extends Buffers { *
* GL_FIXED, GL_INT
* GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
- * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
+ * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
* GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
- * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
+ * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
* GL_HILO16_NV, GL_SIGNED_HILO16_NV
*
* GL_FLOAT_32_UNSIGNED_INT_24_8_REV
*
- * GL_FLOAT, GL_DOUBLE
- * + * GL_FLOAT, GL_DOUBLE
+ * * @param width in pixels * @param height in pixels * @param depth in pixels - * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU + * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU * @return required minimum size of the buffer in bytes * @throws GLException if format, type or alignment is not handled. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], + public static final int sizeof(GL gl, int tmp[], int format, int type, int width, int height, int depth, boolean pack) throws GLException { if (width < 0) return 0; if (height < 0) return 0; if (depth < 0) return 0; - + final int bytesPerPixel = bytesPerPixel(format, type); return sizeof(gl, tmp, bytesPerPixel, width, height, depth, pack); } - - /** + + /** * Returns the number of bytes required for one pixel with the the given OpenGL format and type. - * + * *This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.
- * + * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer. + * *See {@link #componentCount(int)}.
- * - * @param format must be one of (27)
- * GL_COLOR_INDEX GL_STENCIL_INDEX
- * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
- * GL_RED GL_RED_INTEGER
- * GL_GREEN GL_GREEN_INTEGER
- * GL_BLUE GL_BLUE_INTEGER
- * GL_ALPHA GL_LUMINANCE (12)
- *
+ * + * @param format must be one of (27)
+ * GL_COLOR_INDEX GL_STENCIL_INDEX
+ * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
+ * GL_RED GL_RED_INTEGER
+ * GL_GREEN GL_GREEN_INTEGER
+ * GL_BLUE GL_BLUE_INTEGER
+ * GL_ALPHA GL_LUMINANCE (12)
+ *
* GL_LUMINANCE_ALPHA GL_RG
- * GL_RG_INTEGER GL_HILO_NV
- * GL_SIGNED_HILO_NV (5)
- *
- * GL_YCBCR_422_APPLE
- *
- * GL_RGB GL_RGB_INTEGER
- * GL_BGR GL_BGR_INTEGER (4)
- *
- * GL_RGBA GL_RGBA_INTEGER
+ * GL_RG_INTEGER GL_HILO_NV
+ * GL_SIGNED_HILO_NV (5)
+ *
+ * GL_YCBCR_422_APPLE
+ *
+ * GL_RGB GL_RGB_INTEGER
+ * GL_BGR GL_BGR_INTEGER (4)
+ *
+ * GL_RGBA GL_RGBA_INTEGER
* GL_BGRA GL_BGRA_INTEGER
- * GL_ABGR_EXT (5)
- * - * @param type must be one of (32)
- * GL_BITMAP,
+ * GL_ABGR_EXT (5)
+ * + * @param type must be one of (32)
+ * GL_BITMAP,
* GL_BYTE, GL_UNSIGNED_BYTE,
* GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
*
* GL_SHORT, GL_UNSIGNED_SHORT,
- * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
* GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
* GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
* GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
@@ -566,15 +566,15 @@ public class GLBuffers extends Buffers { *
* GL_FIXED, GL_INT
* GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
- * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
+ * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
* GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
- * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
+ * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
* GL_HILO16_NV, GL_SIGNED_HILO16_NV
*
* GL_FLOAT_32_UNSIGNED_INT_24_8_REV
*
- * GL_FLOAT, GL_DOUBLE
- * + * GL_FLOAT, GL_DOUBLE
+ * * @return required size of one pixel in bytes * @throws GLException if format or type alignment is not handled. Please contact the maintainer if this is our bug. */ @@ -582,14 +582,14 @@ public class GLBuffers extends Buffers { int compSize = 0; int compCount = componentCount(format); - + switch (type) /* 30 */ { case GL2.GL_BITMAP: if (GL2.GL_COLOR_INDEX == format || GL2GL3.GL_STENCIL_INDEX == format) { compSize = 1; } case GL.GL_BYTE: - case GL.GL_UNSIGNED_BYTE: + case GL.GL_UNSIGNED_BYTE: compSize = 1; break; case GL.GL_SHORT: @@ -607,7 +607,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_DOUBLE: compSize = 8; break; - + case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: compSize = 1; @@ -630,7 +630,7 @@ public class GLBuffers extends Buffers { case GL2.GL_SIGNED_HILO16_NV: compSize = 2; compCount = 2; - break; + break; case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: @@ -640,52 +640,52 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: compSize = 4; compCount = 1; - break; + break; case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: compSize = 8; compCount = 1; - break; - + break; + default: throw new GLException("type 0x"+Integer.toHexString(type)+"/"+"format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug."); - } + } return compCount * compSize; } - - /** + + /** * Returns the number of components required for the given OpenGL format. - * + * *This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.
- * - * @param format must be one of (27)
- * GL_COLOR_INDEX GL_STENCIL_INDEX
- * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
- * GL_RED GL_RED_INTEGER
- * GL_GREEN GL_GREEN_INTEGER
- * GL_BLUE GL_BLUE_INTEGER
- * GL_ALPHA GL_LUMINANCE (12)
- *
+ * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer. + * + * @param format must be one of (27)
+ * GL_COLOR_INDEX GL_STENCIL_INDEX
+ * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
+ * GL_RED GL_RED_INTEGER
+ * GL_GREEN GL_GREEN_INTEGER
+ * GL_BLUE GL_BLUE_INTEGER
+ * GL_ALPHA GL_LUMINANCE (12)
+ *
* GL_LUMINANCE_ALPHA GL_RG
- * GL_RG_INTEGER GL_HILO_NV
- * GL_SIGNED_HILO_NV (5)
- *
- * GL_YCBCR_422_APPLE
- *
- * GL_RGB GL_RGB_INTEGER
- * GL_BGR GL_BGR_INTEGER (4)
- *
- * GL_RGBA GL_RGBA_INTEGER
+ * GL_RG_INTEGER GL_HILO_NV
+ * GL_SIGNED_HILO_NV (5)
+ *
+ * GL_YCBCR_422_APPLE
+ *
+ * GL_RGB GL_RGB_INTEGER
+ * GL_BGR GL_BGR_INTEGER (4)
+ *
+ * GL_RGBA GL_RGBA_INTEGER
* GL_BGRA GL_BGRA_INTEGER
- * GL_ABGR_EXT (5)
- * + * GL_ABGR_EXT (5)
+ * * @return number of components required for the given OpenGL format * @throws GLException if format is not handled. Please contact the maintainer if this is our bug. */ public static final int componentCount(int format) throws GLException { final int compCount; - + switch (format) /* 26 */ { case GL2.GL_COLOR_INDEX: case GL2GL3.GL_STENCIL_INDEX: @@ -711,10 +711,10 @@ public class GLBuffers extends Buffers { case GL.GL_RGB: case GL2GL3.GL_RGB_INTEGER: case GL2GL3.GL_BGR: - case GL2GL3.GL_BGR_INTEGER: + case GL2GL3.GL_BGR_INTEGER: compCount = 3; break; - case GL2.GL_YCBCR_422_APPLE: + case GL2.GL_YCBCR_422_APPLE: compCount = 3; break; case GL.GL_RGBA: @@ -724,16 +724,16 @@ public class GLBuffers extends Buffers { case GL2.GL_ABGR_EXT: compCount = 4; break; - /* FIXME ?? + /* FIXME ?? case GL.GL_HILO_NV: elements = 2; - break; */ + break; */ default: throw new GLException("format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug."); } return compCount; } - + public static final int getNextPowerOf2(int number) { if (((number-1) & number) == 0) { //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0 @@ -745,8 +745,8 @@ public class GLBuffers extends Buffers { power++; } return (1<src to dest
. * IfpreserveInitState
istrue
, it's initialized state is preserved @@ -86,7 +86,7 @@ public class GLDrawableUtil { dest.invoke(false, new GLEventListenerState.ReshapeGLEventListener(listener)); } // else .. !init state is default } - + /** * Moves all {@link GLEventListener} from {@link GLAutoDrawable}src
todest
. * IfpreserveInitState
istrue
, it's initialized state is preserved @@ -113,12 +113,12 @@ public class GLDrawableUtil { /** * Swaps the {@link GLContext} and all {@link GLEventListener} between {@link GLAutoDrawable}a
andb
, * while preserving it's initialized state, resets the GL-Viewport and issuing {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)}. - *- * The {@link GLAutoDrawable} to {@link GLAnimatorControl} association - * is also swapped. + *
+ * The {@link GLAutoDrawable} to {@link GLAnimatorControl} association + * is also swapped. *
*- * If an {@link GLAnimatorControl} is being attached to {@link GLAutoDrawable}
* @param a @@ -128,31 +128,31 @@ public class GLDrawableUtil { public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { final GLEventListenerState gllsA = GLEventListenerState.moveFrom(a); final GLEventListenerState gllsB = GLEventListenerState.moveFrom(b); - + gllsA.moveTo(b); gllsB.moveTo(a); } - - /** - * Swaps the {@link GLContext} of given {@link GLAutoDrawable} - * and {@link GLAutoDrawable#disposeGLEventListener(GLEventListener, boolean) disposes} + + /** + * Swaps the {@link GLContext} of given {@link GLAutoDrawable} + * and {@link GLAutoDrawable#disposeGLEventListener(GLEventListener, boolean) disposes} * each {@link GLEventListener} w/o removing it. *a
orb
+ * If an {@link GLAnimatorControl} is being attached to {@link GLAutoDrawable}a
orb
* and the current thread is different than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. ** The GL-Viewport is reset and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued implicit. - *
+ * *- * If an {@link GLAnimatorControl} is being attached to GLAutoDrawable src or dest and the current thread is different + * If an {@link GLAnimatorControl} is being attached to GLAutoDrawable src or dest and the current thread is different * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *
* @param src * @param dest */ - public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { + public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { final GLAnimatorControl aAnim = src.getAnimator(); - final GLAnimatorControl bAnim = dest.getAnimator(); + final GLAnimatorControl bAnim = dest.getAnimator(); final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); - + for(int i = src.getGLEventListenerCount() - 1; 0 <= i; i--) { src.disposeGLEventListener(src.getGLEventListener(i), false); } @@ -160,12 +160,12 @@ public class GLDrawableUtil { dest.disposeGLEventListener(dest.getGLEventListener(i), false); } dest.setContext( src.setContext( dest.getContext(), false ), false ); - + src.invoke(true, GLEventListenerState.setViewport); dest.invoke(true, GLEventListenerState.setViewport); - + if(aIsPaused) { aAnim.resume(); } if(bIsPaused) { bAnim.resume(); } } - + } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index 71e284101..f0c6be44f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,78 +39,78 @@ import javax.media.opengl.GLException; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.TextureData; -/** +/** * OpenGL pixel data buffer, allowing user to provide buffers via their {@link GLPixelBufferProvider} implementation. ** {@link GLPixelBufferProvider} produces a {@link GLPixelBuffer}. - *
+ * ** You may use {@link #defaultProviderNoRowStride}. *
*/ public class GLPixelBuffer { - - /** Allows user to interface with another toolkit to define {@link GLPixelAttributes} and memory buffer to produce {@link TextureData}. */ + + /** Allows user to interface with another toolkit to define {@link GLPixelAttributes} and memory buffer to produce {@link TextureData}. */ public static interface GLPixelBufferProvider { /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. */ boolean getAllowRowStride(); - + /** Called first to determine {@link GLPixelAttributes}. */ GLPixelAttributes getAttributes(GL gl, int componentCount); - - /** + + /** * Allocates a new {@link GLPixelBuffer} object. ** Being called to gather the initial {@link GLPixelBuffer}, * or a new replacement {@link GLPixelBuffer} if {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. *
*- * The minimum required {@link Buffer#remaining() remaining} byte size equals to
- * + * * @param gl the corresponding current GL context object * @param pixelAttributes the desired {@link GLPixelAttributes} * @param width in pixels * @param height in pixels * @param depth in pixels * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU - * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. */ GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize); } - /** Single {@link GLPixelBuffer} provider. */ + /** Single {@link GLPixelBuffer} provider. */ public static interface SingletonGLPixelBufferProvider extends GLPixelBufferProvider { - /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link GLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link GLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ GLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes); - /** + /** * Initializes the single {@link GLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. * @return the newly initialized single {@link GLPixelBuffer}, or null if already allocated. */ - GLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack); + GLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack); } public static class DefaultGLPixelBufferProvider implements GLPixelBufferProvider { private final boolean allowRowStride; - + /** - * @param allowRowStride IfminByteSize
, if > 0, + * The minimum required {@link Buffer#remaining() remaining} byte size equals tominByteSize
, if > 0, * otherwise utilize {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean)} * to calculate it. *true
, allow row-stride, otherwise not. + * @param allowRowStride Iftrue
, allow row-stride, otherwise not. * See {@link #getAllowRowStride()} and {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. */ public DefaultGLPixelBufferProvider(boolean allowRowStride) { - this.allowRowStride = allowRowStride; + this.allowRowStride = allowRowStride; } - + @Override public boolean getAllowRowStride() { return allowRowStride; } - + @Override public GLPixelAttributes getAttributes(GL gl, int componentCount) { final GLContext ctx = gl.getContext(); final int dFormat, dType; - + if( 1 == componentCount ) { if( gl.isGL3ES3() ) { // RED is supported on ES3 and >= GL3 [core]; ALPHA is deprecated on core @@ -122,7 +122,7 @@ public class GLPixelBuffer { dType = GL.GL_UNSIGNED_BYTE; } else if( 3 == componentCount ) { dFormat = GL.GL_RGB; - dType = GL.GL_UNSIGNED_BYTE; + dType = GL.GL_UNSIGNED_BYTE; } else if( 4 == componentCount ) { int _dFormat = ctx.getDefaultPixelDataFormat(); final int dComps = GLBuffers.componentCount(_dFormat); @@ -131,14 +131,14 @@ public class GLPixelBuffer { dType = ctx.getDefaultPixelDataType(); } else { dFormat = GL.GL_RGBA; - dType = GL.GL_UNSIGNED_BYTE; + dType = GL.GL_UNSIGNED_BYTE; } } else { throw new GLException("Unsupported componentCount "+componentCount+", contact maintainer to enhance"); } return new GLPixelAttributes(componentCount, dFormat, dType); } - + /** * {@inheritDoc} *@@ -148,7 +148,7 @@ public class GLPixelBuffer { @Override public GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { if( minByteSize > 0 ) { - return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize), getAllowRowStride()); + return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize), getAllowRowStride()); } else { int[] tmp = { 0 }; final int byteSize = GLBuffers.sizeof(gl, tmp, pixelAttributes.bytesPerPixel, width, height, depth, pack); @@ -156,26 +156,26 @@ public class GLPixelBuffer { } } } - - /** + + /** * Default {@link GLPixelBufferProvider} with {@link GLPixelBufferProvider#getAllowRowStride()} ==
false
, * utilizing best match for {@link GLPixelAttributes} * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. */ public static GLPixelBufferProvider defaultProviderNoRowStride = new DefaultGLPixelBufferProvider(false); - - /** + + /** * Default {@link GLPixelBufferProvider} with {@link GLPixelBufferProvider#getAllowRowStride()} ==true
, * utilizing best match for {@link GLPixelAttributes} * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. */ public static GLPixelBufferProvider defaultProviderWithRowStride = new DefaultGLPixelBufferProvider(true); - - /** Pixel attributes. */ + + /** Pixel attributes. */ public static class GLPixelAttributes { - /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ + /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0, false); - + /** Pixel source component count, i.e. number of meaningful components. */ public final int componentCount; /** The OpenGL pixel data format */ @@ -184,7 +184,7 @@ public class GLPixelBuffer { public final int type; /** The OpenGL pixel size in bytes */ public final int bytesPerPixel; - + /** * Deriving {@link #componentCount} via GLdataFormat
, i.e. {@link GLBuffers#componentCount(int)} if > 0. * @param dataFormat GL data format @@ -194,7 +194,7 @@ public class GLPixelBuffer { this(0 < dataFormat ? GLBuffers.componentCount(dataFormat) : 0, dataFormat, dataType); } /** - * Using user specified source {@link #componentCount}. + * Using user specified source {@link #componentCount}. * @param componentCount source component count * @param dataFormat GL data format * @param dataType GL data type @@ -220,7 +220,7 @@ public class GLPixelBuffer { return "PixelAttributes[comp "+componentCount+", fmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+", bytesPerPixel "+bytesPerPixel+"]"; } } - + /** The {@link GLPixelAttributes}. */ public final GLPixelAttributes pixelAttributes; /** Width in pixels. */ @@ -233,22 +233,22 @@ public class GLPixelBuffer { public final boolean pack; /** Byte size of the buffer. Actually the number of {@link Buffer#remaining()} bytes when passed in ctor. */ public final int byteSize; - /** - * Buffer holding the pixel data. If {@link #rewind()}, it holdsbyteSize
{@link Buffer#remaining()} bytes. + /** + * Buffer holding the pixel data. If {@link #rewind()}, it holdsbyteSize
{@link Buffer#remaining()} bytes. ** By default the {@link Buffer} is a {@link ByteBuffer}, due to {@link DefProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int)}. * However, other {@link GLPixelBufferProvider} may utilize different {@link Buffer} types. *
- */ + */ public final Buffer buffer; /** Buffer element size in bytes. */ public final int bufferElemSize; - + /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. See {@link #requiresNewBuffer(GL, int, int, int)}. */ public final boolean allowRowStride; - + private boolean disposed = false; - + public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); @@ -272,7 +272,7 @@ public class GLPixelBuffer { * @param allowRowStride Iftrue
, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. */ public GLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, Buffer buffer, boolean allowRowStride) { - this.pixelAttributes = pixelAttributes; + this.pixelAttributes = pixelAttributes; this.width = width; this.height = height; this.depth = depth; @@ -282,15 +282,15 @@ public class GLPixelBuffer { this.bufferElemSize = Buffers.sizeOfBufferElem(buffer); this.allowRowStride = allowRowStride; } - + /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. */ public final boolean getAllowRowStride() { return allowRowStride; } - + /** Is not {@link #dispose() disposed} and has {@link #byteSize} > 0. */ public boolean isValid() { return !disposed && 0 < byteSize; } - + /** See {@link Buffer#rewind()}. */ public Buffer rewind() { return buffer.rewind(); @@ -300,40 +300,40 @@ public class GLPixelBuffer { public int position() { return buffer.position() * bufferElemSize; } - + /** Sets the byte position of the {@link #buffer}. */ public Buffer position(int bytePos) { return buffer.position( bytePos / bufferElemSize ); } - + /** Returns the byte capacity of the {@link #buffer}. */ public int capacity() { return buffer.capacity() * bufferElemSize; } - + /** Returns the byte limit of the {@link #buffer}. */ public int limit() { return buffer.limit() * bufferElemSize; } - + /** See {@link Buffer#flip()}. */ public Buffer flip() { - return buffer.flip(); + return buffer.flip(); } - + /** See {@link Buffer#clear()}. */ public Buffer clear() { - return buffer.clear(); + return buffer.clear(); } - - /** + + /** * Returns true, if {@link #isValid() invalid} or implementation requires a new buffer based on the new size * due to pixel alignment or byte size, otherwise false. ** It is assumed that
*pixelAttributes
,depth
andpack
stays the same! *- * The minimum required byte size equals to
@@ -341,16 +341,16 @@ public class GLPixelBuffer { * IfminByteSize
, if > 0, + * The minimum required byte size equals tominByteSize
, if > 0, * otherwise {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) GLBuffers.sizeof(..)} * is being used to calculate it. This value is referred to newByteSize. *{@link #allowRowStride} = false
, * method returnstrue
if the newByteSize > currentByteSize * or thenewWidth
!=currentWidth
. - * + * ** If
* @param gl the corresponding current GL context object * @param newWidth new width in pixels * @param newHeight new height in pixels - * @param newByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + * @param newByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) */ public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize) { @@ -366,7 +366,7 @@ public class GLPixelBuffer { } return byteSize < newByteSize || width != newWidth; } - + /** Dispose resources. See {@link #isValid()}. */ public void dispose() { disposed = true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java index f512a3aae..1c6e97450 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java @@ -46,35 +46,35 @@ public class GLPixelStorageModes { /** Create instance w/o {@link #save(GL)} */ public GLPixelStorageModes() {} - + /** Create instance w/ {@link #save(GL)} */ public GLPixelStorageModes(GL gl) { save(gl); } - + /** * Sets the {@link GL#GL_PACK_ALIGNMENT}. - *{@link #allowRowStride} = true
, see {@link GLPixelBufferProvider#getAllowRowStride()}, - * method returnstrue
only if the newByteSize > currentByteSize. + * method returnstrue
only if the newByteSize > currentByteSize. * Assuming user utilizes the row-stride when dealing w/ the data, i.e. {@link GL2ES3#GL_PACK_ROW_LENGTH}. *+ *
* Saves the pixel storage modes if not saved yet. *
*/ public final void setPackAlignment(GL gl, int packAlignment) { save(gl); - gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); } /** * Sets the {@link GL#GL_UNPACK_ALIGNMENT}. - *+ *
* Saves the pixel storage modes if not saved yet. *
*/ public final void setUnpackAlignment(GL gl, int unpackAlignment) { save(gl); - gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, unpackAlignment); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, unpackAlignment); } - + /** - * Sets the {@link GL#GL_PACK_ALIGNMENT} and {@link GL#GL_UNPACK_ALIGNMENT}. - *+ * Sets the {@link GL#GL_PACK_ALIGNMENT} and {@link GL#GL_UNPACK_ALIGNMENT}. + *
* Saves the pixel storage modes if not saved yet. *
*/ @@ -82,32 +82,32 @@ public class GLPixelStorageModes { setPackAlignment(gl, packAlignment); setUnpackAlignment(gl, unpackAlignment); } - + /** * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH}. - *+ *
* Saves the pixel storage modes if not saved yet. *
*/ public final void setPackRowLength(GL2ES3 gl, int packRowLength) { save(gl); - gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength); + gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength); } /** * Sets the {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. - *+ *
* Saves the pixel storage modes if not saved yet. *
*/ public final void setUnpackRowLength(GL2ES2 gl, int unpackRowLength) { save(gl); - gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, unpackRowLength); + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, unpackRowLength); } - + /** * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH} and {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. - *+ *
* Saves the pixel storage modes if not saved yet. *
*/ @@ -115,7 +115,7 @@ public class GLPixelStorageModes { setPackRowLength(gl, packRowLength); setUnpackRowLength(gl, unpackRowLength); } - + /** * Save the pixel storage mode, if not saved yet. *@@ -126,8 +126,8 @@ public class GLPixelStorageModes { if(saved) { return; } - - if(gl.isGL2GL3()) { + + if(gl.isGL2GL3()) { if(gl.isGL2()) { gl.getGL2().glPushClientAttrib(GL2.GL_CLIENT_PIXEL_STORE_BIT); } else { @@ -154,7 +154,7 @@ public class GLPixelStorageModes { // embedded deals with pack/unpack alignment only gl.glGetIntegerv(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment, 0); gl.glGetIntegerv(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment, 1); - } + } saved = true; } @@ -166,8 +166,8 @@ public class GLPixelStorageModes { if(!saved) { throw new GLException("pixel storage modes not saved"); } - - if(gl.isGL2GL3()) { + + if(gl.isGL2GL3()) { if(gl.isGL2()) { gl.getGL2().glPopClientAttrib(); } else { @@ -186,9 +186,9 @@ public class GLPixelStorageModes { // embedded deals with pack/unpack alignment only gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment[0]); gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment[1]); - } + } saved = false; - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 65d1b6906..b942c9ab2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,12 +20,12 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.util; import java.io.File; @@ -51,45 +51,45 @@ import com.jogamp.opengl.util.texture.TextureIO; */ public class GLReadBufferUtil { protected final GLPixelBufferProvider pixelBufferProvider; - protected final int componentCount, alignment; + protected final int componentCount, alignment; protected final Texture readTexture; - protected final GLPixelStorageModes psm; - + protected final GLPixelStorageModes psm; + protected GLPixelBuffer readPixelBuffer = null; protected TextureData readTextureData = null; /** - * @param alpha true for RGBA readPixels, otherwise RGB readPixels. Disclaimer: Alpha maybe forced on ES platforms! + * @param alpha true for RGBA readPixels, otherwise RGB readPixels. Disclaimer: Alpha maybe forced on ES platforms! * @param write2Texture true if readPixel's TextureData shall be written to a 2d Texture */ public GLReadBufferUtil(boolean alpha, boolean write2Texture) { this(GLPixelBuffer.defaultProviderNoRowStride, alpha, write2Texture); } - + public GLReadBufferUtil(GLPixelBufferProvider pixelBufferProvider, boolean alpha, boolean write2Texture) { this.pixelBufferProvider = pixelBufferProvider; this.componentCount = alpha ? 4 : 3 ; - this.alignment = alpha ? 4 : 1 ; + this.alignment = alpha ? 4 : 1 ; this.readTexture = write2Texture ? new Texture(GL.GL_TEXTURE_2D) : null ; this.psm = new GLPixelStorageModes(); } - + /** Returns the {@link GLPixelBufferProvider} used by this instance. */ public GLPixelBufferProvider getPixelBufferProvider() { return pixelBufferProvider; } - + public boolean isValid() { return null!=readTextureData && null!=readPixelBuffer && readPixelBuffer.isValid(); } - + public boolean hasAlpha() { return 4 == componentCount ? true : false ; } - + public GLPixelStorageModes getGLPixelStorageModes() { return psm; } - + /** * Returns the {@link GLPixelBuffer}, created and filled by {@link #readPixels(GLAutoDrawable, boolean)}. */ public GLPixelBuffer getPixelBuffer() { return readPixelBuffer; } - + /** * rewind the raw pixel ByteBuffer */ @@ -99,7 +99,7 @@ public class GLReadBufferUtil { * @return the resulting TextureData, filled by {@link #readPixels(GLAutoDrawable, boolean)} */ public TextureData getTextureData() { return readTextureData; } - + /** * @return the Texture object filled by {@link #readPixels(GLAutoDrawable, boolean)}, * if this instance writes to a 2d Texture, otherwise null. @@ -121,27 +121,27 @@ public class GLReadBufferUtil { /** * Read the drawable's pixels to TextureData and Texture, if requested at construction. - * + * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param mustFlipVertically indicates whether to flip the data vertically or not. * The context's drawable {@link GLDrawable#isGLOriented()} state * is taken into account. * Vertical flipping is propagated to TextureData * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). - * + * * @see #GLReadBufferUtil(boolean, boolean) */ public boolean readPixels(GL gl, boolean mustFlipVertically) { return readPixels(gl, 0, 0, 0, 0, mustFlipVertically); } - + /** * Read the drawable's pixels to TextureData and Texture, if requested at construction. - * + * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param inX readPixel x offset * @param inY readPixel y offset - * @param inWidth optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width + * @param inWidth optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width * @param inHeight optional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height * @param mustFlipVertically indicates whether to flip the data vertically or not. * The context's drawable {@link GLDrawable#isGLOriented()} state @@ -174,17 +174,17 @@ public class GLReadBufferUtil { } else { height= inHeight; } - + final boolean flipVertically; if( drawable.isGLOriented() ) { flipVertically = mustFlipVertically; } else { flipVertically = !mustFlipVertically; } - + final int tmp[] = new int[1]; final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, width, height, 1, true); - + boolean newData = false; if( null == readPixelBuffer || readPixelBuffer.requiresNewBuffer(gl, width, height, readPixelSize) ) { readPixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, width, height, 1, true, readPixelSize); @@ -194,9 +194,9 @@ public class GLReadBufferUtil { gl.getGLProfile(), internalFormat, width, height, - 0, + 0, pixelAttribs, - false, false, + false, false, flipVertically, readPixelBuffer.buffer, null /* Flusher */); @@ -230,13 +230,13 @@ public class GLReadBufferUtil { " "+width+"x"+height+ ", "+pixelAttribs+ ", "+readPixelBuffer+", sz "+readPixelSize); - res = false; + res = false; } if(res && null != readTexture) { if(newData) { readTexture.updateImage(gl, readTextureData); } else { - readTexture.updateSubImage(gl, readTextureData, 0, + readTexture.updateSubImage(gl, readTextureData, 0, 0, 0, // src offset 0, 0, // dst offset width, height); @@ -248,7 +248,7 @@ public class GLReadBufferUtil { return res; } - public void dispose(GL gl) { + public void dispose(GL gl) { if(null != readTexture) { readTexture.destroy(gl); readTextureData = null; diff --git a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java index c649d1c6a..966781906 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java @@ -1,21 +1,21 @@ /* * Copyright (c) 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 @@ -28,11 +28,11 @@ * 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. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 111e2509e..697b7cca0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -34,28 +34,28 @@ import com.jogamp.opengl.util.glsl.ShaderState; * to be either rendered directly via {@link #glEnd(GL)} or to be added to an internal display list * via {@link #glEnd(GL, boolean) glEnd(gl, false)} for deferred rendering via {@link #draw(GL, boolean)}. *
- *Buffer storage and it's creation via {@link #createFixed(int, int, int, int, int, int, int, int, int, int) createFixed(..)} - * and {@link #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) createGLSL(..)}
+ *Buffer storage and it's creation via {@link #createFixed(int, int, int, int, int, int, int, int, int, int) createFixed(..)} + * and {@link #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) createGLSL(..)}
*- * If unsure whether colors, normals and textures will be used, + * If unsure whether colors, normals and textures will be used, * simply add them with an expected component count. * This implementation will only render buffers which are being filled.
*
* The buffer growing implementation will only grow the exceeded buffers, unused buffers are not resized. *- * Note: Optional types, i.e. color, must be either not used or used w/ the same element count as vertex, etc. + * Note: Optional types, i.e. color, must be either not used or used w/ the same element count as vertex, etc. * This is a semantic constraint, same as in the original OpenGL spec. *
*/ public class ImmModeSink { protected static final boolean DEBUG_BEGIN_END; - protected static final boolean DEBUG_DRAW; + protected static final boolean DEBUG_DRAW; protected static final boolean DEBUG_BUFFER; - + static { Debug.initSingleton(); DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); - DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); + DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); } @@ -68,7 +68,7 @@ public class ImmModeSink { ** See buffer storage details. *
- * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -78,17 +78,17 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to0
for no VBO usage */ - public static ImmModeSink createFixed(int initialElementCount, + public static ImmModeSink createFixed(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, false, glBufferUsage, null, 0); } @@ -97,7 +97,7 @@ public class ImmModeSink { ** See buffer storage details. *
- * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -107,21 +107,21 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to0
for no VBO usage * @param st ShaderState to locate the vertex attributes * @see #draw(GL, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, + public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage, ShaderState st) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, st, 0); } @@ -130,7 +130,7 @@ public class ImmModeSink { ** See buffer storage details. *
- * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -140,24 +140,24 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBOusage
parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to0
for no VBO usage * @param shaderProgram shader-program name to locate the vertex attributes * @see #draw(GL, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, + public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage, int shaderProgram) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, null, shaderProgram); } - + public void destroy(GL gl) { destroyList(gl); @@ -346,7 +346,7 @@ public class ImmModeSink { public final void glColor3ub(byte x, byte y, byte z) { vboSet.glColor3ub(x,y,z); } - + public final void glColor4b(byte x, byte y, byte z, byte a) { vboSet.glColor4b(x,y,z,a); } @@ -354,7 +354,7 @@ public class ImmModeSink { public final void glColor4ub(byte x, byte y, byte z, byte a) { vboSet.glColor4ub(x,y,z,a); } - + public final void glTexCoord2b(byte x, byte y) { vboSet.glTexCoord2b(x,y); } @@ -363,26 +363,26 @@ public class ImmModeSink { vboSet.glTexCoord3b(x,y,z); } - protected ImmModeSink(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + protected ImmModeSink(int initialElementCount, + int vComps, int vDataType, + int cComps, int cDataType, + int nComps, int nDataType, + int tComps, int tDataType, boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { - vboSet = new VBOSet(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + vboSet = new VBOSet(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, st, shaderProgram); this.vboSetList = new ArrayList(); } - + public boolean getUseVBO() { return vboSet.getUseVBO(); } - + /** * Returns the additional element count if buffer resize is required. * @see #setResizeElementCount(int) */ public int getResizeElementCount() { return vboSet.getResizeElementCount(); } - + /** * Sets the additional element count if buffer resize is required, * defaults to initialElementCount
of factory method. @@ -390,7 +390,7 @@ public class ImmModeSink { * @see #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) */ public void setResizeElementCount(int v) { vboSet.setResizeElementCount(v); } - + private void destroyList(GL gl) { for(int i=0; ivboSetList; protected static class VBOSet { - protected VBOSet (int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + protected VBOSet (int initialElementCount, + int vComps, int vDataType, + int cComps, int cDataType, + int nComps, int nDataType, + int tComps, int tDataType, boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { // final .. this.glBufferUsage=glBufferUsage; @@ -415,7 +415,7 @@ public class ImmModeSink { this.useGLSL=useGLSL; this.shaderState = st; this.shaderProgram = shaderProgram; - + if(useGLSL && null == shaderState && 0 == shaderProgram) { throw new IllegalArgumentException("Using GLSL but neither a valid shader-program nor ShaderState has been passed!"); } @@ -436,9 +436,9 @@ public class ImmModeSink { this.tDataType=tDataType; this.tDataTypeSigned=GLBuffers.isSignedGLType(tDataType); this.tComps=tComps; - this.tCompsBytes=tComps * GLBuffers.sizeOfGLType(tDataType); + this.tCompsBytes=tComps * GLBuffers.sizeOfGLType(tDataType); this.vboName = 0; - + this.vCount=0; this.cCount=0; this.nCount=0; @@ -447,9 +447,9 @@ public class ImmModeSink { this.cElems=0; this.nElems=0; this.tElems=0; - + this.pageSize = Platform.getMachineDescription().pageSizeInBytes(); - + reallocateBuffer(initialElementCount); rewind(); @@ -465,30 +465,30 @@ public class ImmModeSink { protected int getResizeElementCount() { return resizeElementCount; } protected void setResizeElementCount(int v) { resizeElementCount=v; } - + protected boolean getUseVBO() { return useVBO; } - + protected final VBOSet regenerate(GL gl) { - return new VBOSet(initialElementCount, vComps, - vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new VBOSet(initialElementCount, vComps, + vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, shaderState, shaderProgram); } protected void checkSeal(boolean test) throws GLException { if(0==mode) { - throw new GLException("No mode set yet, call glBegin(mode) first:\n\t"+this); + throw new GLException("No mode set yet, call glBegin(mode) first:\n\t"+this); } if(sealed!=test) { if(test) { - throw new GLException("Not Sealed yet, call glEnd() first:\n\t"+this); + throw new GLException("Not Sealed yet, call glEnd() first:\n\t"+this); } else { - throw new GLException("Already Sealed, can't modify VBO after glEnd():\n\t"+this); + throw new GLException("Already Sealed, can't modify VBO after glEnd():\n\t"+this); } } } private boolean usingShaderProgram = false; - + protected void useShaderProgram(GL2ES2 gl, boolean force) { if( force || !usingShaderProgram ) { if(null != shaderState) { @@ -499,19 +499,19 @@ public class ImmModeSink { usingShaderProgram = true; } } - + protected void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw, int i) { enableBuffer(gl, true); - + if(null != shaderState || 0 != shaderProgram) { useShaderProgram(gl.getGL2ES2(), false); } - + if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw["+i+"].0 (disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this); } - + if (buffer!=null) { if(null==indices) { if ( GL_QUADS == mode && !gl.isGL2() ) { @@ -523,7 +523,7 @@ public class ImmModeSink { } } else { // FIXME: Impl. VBO usage .. or unroll. - if( !gl.getContext().isCPUDataSourcingAvail() ) { + if( !gl.getContext().isCPUDataSourcingAvail() ) { throw new GLException("CPU data sourcing n/a w/ "+gl.getContext()); } final int type; @@ -538,23 +538,23 @@ public class ImmModeSink { } final int idxLen = indices.remaining(); final int idx0 = indices.position(); - + if ( GL_QUADS == mode && !gl.isGL2() ) { if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(idx0+j)), 4); - } + } } else if( GL.GL_UNSIGNED_SHORT == type ){ final ShortBuffer b = (ShortBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(idx0+j)), 4); - } + } } else { final IntBuffer b = (IntBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4); - } + } } } else { ((GL2ES1)gl).glDrawElements(mode, idxLen, type, indices); @@ -566,7 +566,7 @@ public class ImmModeSink { if(disableBufferAfterDraw) { enableBuffer(gl, false); } - + if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw["+i+"].X (disableBufferAfterDraw: "+disableBufferAfterDraw+")"); } @@ -592,7 +592,7 @@ public class ImmModeSink { public void glVertex2b(byte x, byte y) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNb(vertexArray, vDataTypeSigned, x, true); if(vComps>1) Buffers.putNb(vertexArray, vDataTypeSigned, y, true); @@ -614,7 +614,7 @@ public class ImmModeSink { growBuffer(VERTEX); if(vComps>0) Buffers.putNs(vertexArray, vDataTypeSigned, x, true); - if(vComps>1) + if(vComps>1) Buffers.putNs(vertexArray, vDataTypeSigned, y, true); countAndPadding(VERTEX, vComps-2); } @@ -623,16 +623,16 @@ public class ImmModeSink { growBuffer(VERTEX); if(vComps>0) Buffers.putNs(vertexArray, vDataTypeSigned, x, true); - if(vComps>1) + if(vComps>1) Buffers.putNs(vertexArray, vDataTypeSigned, y, true); - if(vComps>2) + if(vComps>2) Buffers.putNs(vertexArray, vDataTypeSigned, z, true); countAndPadding(VERTEX, vComps-3); } public void glVertex2f(float x, float y) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNf(vertexArray, vDataTypeSigned, x); if(vComps>1) Buffers.putNf(vertexArray, vDataTypeSigned, y); @@ -641,11 +641,11 @@ public class ImmModeSink { public void glVertex3f(float x, float y, float z) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNf(vertexArray, vDataTypeSigned, x); if(vComps>1) Buffers.putNf(vertexArray, vDataTypeSigned, y); - if(vComps>2) + if(vComps>2) Buffers.putNf(vertexArray, vDataTypeSigned, z); countAndPadding(VERTEX, vComps-3); } @@ -653,33 +653,33 @@ public class ImmModeSink { public void glNormal3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNb(normalArray, nDataTypeSigned, x, true); - if(nComps>1) + if(nComps>1) Buffers.putNb(normalArray, nDataTypeSigned, y, true); - if(nComps>2) + if(nComps>2) Buffers.putNb(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } public void glNormal3s(short x, short y, short z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNs(normalArray, nDataTypeSigned, x, true); - if(nComps>1) + if(nComps>1) Buffers.putNs(normalArray, nDataTypeSigned, y, true); - if(nComps>2) + if(nComps>2) Buffers.putNs(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } public void glNormal3f(float x, float y, float z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNf(normalArray, nDataTypeSigned, x); if(nComps>1) Buffers.putNf(normalArray, nDataTypeSigned, y); - if(nComps>2) + if(nComps>2) Buffers.putNf(normalArray, nDataTypeSigned, z); countAndPadding(NORMAL, nComps-3); } @@ -687,96 +687,96 @@ public class ImmModeSink { public void glColor3b(byte r, byte g, byte b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } public void glColor3ub(byte r, byte g, byte b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, false); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, false); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, false); countAndPadding(COLOR, cComps-3); } public void glColor4b(byte r, byte g, byte b, byte a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, true); - if(cComps>3) + if(cComps>3) Buffers.putNb(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } public void glColor4ub(byte r, byte g, byte b, byte a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, false); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, false); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, false); - if(cComps>3) + if(cComps>3) Buffers.putNb(colorArray, cDataTypeSigned, a, false); countAndPadding(COLOR, cComps-4); } public void glColor3s(short r, short g, short b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNs(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNs(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNs(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } public void glColor4s(short r, short g, short b, short a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNs(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNs(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNs(colorArray, cDataTypeSigned, b, true); - if(cComps>3) + if(cComps>3) Buffers.putNs(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } public void glColor3f(float r, float g, float b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNf(colorArray, cDataTypeSigned, r); - if(cComps>1) + if(cComps>1) Buffers.putNf(colorArray, cDataTypeSigned, g); - if(cComps>2) + if(cComps>2) Buffers.putNf(colorArray, cDataTypeSigned, b); countAndPadding(COLOR, cComps-3); } public void glColor4f(float r, float g, float b, float a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNf(colorArray, cDataTypeSigned, r); - if(cComps>1) + if(cComps>1) Buffers.putNf(colorArray, cDataTypeSigned, g); - if(cComps>2) + if(cComps>2) Buffers.putNf(colorArray, cDataTypeSigned, b); - if(cComps>3) + if(cComps>3) Buffers.putNf(colorArray, cDataTypeSigned, a); countAndPadding(COLOR, cComps-4); } @@ -784,60 +784,60 @@ public class ImmModeSink { public void glTexCoord2b(byte x, byte y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); - if(tComps>2) + if(tComps>2) Buffers.putNb(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } public void glTexCoord2s(short x, short y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3s(short x, short y, short z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); - if(tComps>2) + if(tComps>2) Buffers.putNs(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } public void glTexCoord2f(float x, float y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNf(textCoordArray, tDataTypeSigned, x); - if(tComps>1) + if(tComps>1) Buffers.putNf(textCoordArray, tDataTypeSigned, y); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3f(float x, float y, float z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNf(textCoordArray, tDataTypeSigned, x); - if(tComps>1) + if(tComps>1) Buffers.putNf(textCoordArray, tDataTypeSigned, y); - if(tComps>2) + if(tComps>2) Buffers.putNf(textCoordArray, tDataTypeSigned, z); countAndPadding(TEXTCOORD, tComps-3); } @@ -864,20 +864,20 @@ public class ImmModeSink { shaderProgram = program; glslLocationSet = false; // enforce location reset! } - + /** * @param gl * @return true if all locations for all used arrays are found (min 1 array), otherwise false. - * Also sets 'glslLocationSet' to the return value! + * Also sets 'glslLocationSet' to the return value! */ private boolean resetGLSLArrayLocation(GL2ES2 gl) { int iA = 0; int iL = 0; - + if(null != vArrayData) { iA++; if( vArrayData.setLocation(gl, shaderProgram) >= 0 ) { - iL++; + iL++; } } if(null != cArrayData) { @@ -901,7 +901,7 @@ public class ImmModeSink { glslLocationSet = iA == iL; return glslLocationSet; } - + public void destroy(GL gl) { reset(gl); @@ -931,7 +931,7 @@ public class ImmModeSink { this.vElems=0; this.cElems=0; this.nElems=0; - this.tElems=0; + this.tElems=0; } public void seal(GL glObj, boolean seal) @@ -1016,20 +1016,20 @@ public class ImmModeSink { } } else { gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit(), buffer, glBufferUsage); - bufferWrittenOnce = true; - } + bufferWrittenOnce = true; + } } - + private void enableBufferFixed(GL gl, boolean enable) { GL2ES1 glf = gl.getGL2ES1(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } if(enable) { @@ -1038,7 +1038,7 @@ public class ImmModeSink { throw new InternalError("Using VBO but no vboName"); } glf.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName); - + if(!bufferWritten) { writeBuffer(gl); } @@ -1051,7 +1051,7 @@ public class ImmModeSink { glf.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); glf.glVertexPointer(vArrayData); } else { - glf.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); + glf.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); } } if(useC) { @@ -1082,24 +1082,24 @@ public class ImmModeSink { if(enable && useVBO) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableFixed.X "); + System.err.println("ImmModeSink.enableFixed.X "); } } private void enableBufferGLSLShaderState(GL gl, boolean enable) { GL2ES2 glsl = gl.getGL2ES2(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.A.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableGLSL.A.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } - + if(enable) { if(useVBO) { if(0 == vboName) { @@ -1110,9 +1110,9 @@ public class ImmModeSink { writeBuffer(gl); } } - bufferWritten=true; + bufferWritten=true; } - + if(useV) { if(enable) { shaderState.enableVertexAttribArray(glsl, vArrayData); @@ -1144,30 +1144,30 @@ public class ImmModeSink { } else { shaderState.disableVertexAttribArray(glsl, tArrayData); } - } + } glslLocationSet = true; // ShaderState does set the location implicit - + if(enable && useVBO) { glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.A.X "); + System.err.println("ImmModeSink.enableGLSL.A.X "); } } private void enableBufferGLSLSimple(GL gl, boolean enable) { GL2ES2 glsl = gl.getGL2ES2(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.B.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableGLSL.B.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } - + if(!glslLocationSet) { if( !resetGLSLArrayLocation(glsl) ) { if(DEBUG_DRAW) { @@ -1180,7 +1180,7 @@ public class ImmModeSink { return; } } - + if(enable) { if(useVBO) { if(0 == vboName) { @@ -1226,28 +1226,28 @@ public class ImmModeSink { glsl.glDisableVertexAttribArray(tArrayData.getLocation()); } } - + if(enable && useVBO) { glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.B.X "); + System.err.println("ImmModeSink.enableGLSL.B.X "); } } - + public String toString() { - final String glslS = useGLSL ? + final String glslS = useGLSL ? ", useShaderState "+(null!=shaderState)+ ", shaderProgram "+shaderProgram+ ", glslLocationSet "+glslLocationSet : ""; - - return "VBOSet[mode "+mode+ - ", modeOrig "+modeOrig+ + + return "VBOSet[mode "+mode+ + ", modeOrig "+modeOrig+ ", use/count "+getElemUseCountStr()+ - ", sealed "+sealed+ + ", sealed "+sealed+ ", sealedGL "+sealedGL+ - ", bufferEnabled "+bufferEnabled+ + ", bufferEnabled "+bufferEnabled+ ", bufferWritten "+bufferWritten+" (once "+bufferWrittenOnce+")"+ ", useVBO "+useVBO+", vboName "+vboName+ ", useGLSL "+useGLSL+ @@ -1264,7 +1264,7 @@ public class ImmModeSink { protected String getElemUseCountStr() { return "[v "+vElems+"/"+vCount+", c "+cElems+"/"+cCount+", n "+nElems+"/"+nCount+", t "+tElems+"/"+tCount+"]"; } - + protected boolean fitElementInBuffer(int type) { final int addElems = 1; switch (type) { @@ -1280,20 +1280,20 @@ public class ImmModeSink { throw new InternalError("XXX"); } } - + protected boolean reallocateBuffer(int addElems) { final int vAdd = addElems - ( vCount - vElems ); final int cAdd = addElems - ( cCount - cElems ); final int nAdd = addElems - ( nCount - nElems ); final int tAdd = addElems - ( tCount - tElems ); - + if( 0>=vAdd && 0>=cAdd && 0>=nAdd && 0>=tAdd) { if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc: "+getElemUseCountStr()+" + "+addElems+" -> NOP"); } return false; } - + if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc: "+getElemUseCountStr()+" + "+addElems); } @@ -1301,20 +1301,20 @@ public class ImmModeSink { cCount += cAdd; nCount += nAdd; tCount += tAdd; - + final int vBytes = vCount * vCompsBytes; final int cBytes = cCount * cCompsBytes; final int nBytes = nCount * nCompsBytes; final int tBytes = tCount * tCompsBytes; - + buffer = Buffers.newDirectByteBuffer( vBytes + cBytes + nBytes + tBytes ); vOffset = 0; - + if(vBytes>0) { vertexArray = GLBuffers.sliceGLBuffer(buffer, vOffset, vBytes, vDataType); } else { vertexArray = null; - } + } cOffset=vOffset+vBytes; if(cBytes>0) { @@ -1341,36 +1341,36 @@ public class ImmModeSink { buffer.flip(); if(vComps>0) { - vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, + vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, vDataType, GLBuffers.isGLTypeFixedPoint(vDataType), 0, vertexArray, 0, vOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { vArrayData = null; } if(cComps>0) { - cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, + cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, cDataType, GLBuffers.isGLTypeFixedPoint(cDataType), 0, colorArray, 0, cOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { cArrayData = null; } if(nComps>0) { - nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, + nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, nDataType, GLBuffers.isGLTypeFixedPoint(nDataType), 0, normalArray, 0, nOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { nArrayData = null; } if(tComps>0) { - tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, + tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, tDataType, GLBuffers.isGLTypeFixedPoint(tDataType), 0, textCoordArray, 0, tOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { tArrayData = null; } - + bufferWrittenOnce = false; // new buffer data storage size! - + if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc.X: "+this.toString()); Thread.dumpStack(); @@ -1384,7 +1384,7 @@ public class ImmModeSink { if( !fitElementInBuffer(type) ) { // save olde values .. final Buffer _vertexArray=vertexArray, _colorArray=colorArray, _normalArray=normalArray, _textCoordArray=textCoordArray; - + if ( reallocateBuffer(resizeElementCount) ) { if(null!=_vertexArray) { _vertexArray.flip(); @@ -1416,7 +1416,7 @@ public class ImmModeSink { * vec4 v = vec4(0, 0, 0, 1); * vec4 c = vec4(0, 0, 0, 1); * - * + * * @param type * @param fill */ @@ -1426,7 +1426,7 @@ public class ImmModeSink { final Buffer dest; final boolean dSigned; final int e; // either 0 or 1 - + switch (type) { case VERTEX: dest = vertexArray; @@ -1459,7 +1459,7 @@ public class ImmModeSink { while( fill > e ) { fill--; - Buffers.putNf(dest, dSigned, 0f); + Buffers.putNf(dest, dSigned, 0f); } if( fill > 0 ) { // e == 1, add missing '1f end component' Buffers.putNf(dest, dSigned, 1f); @@ -1480,18 +1480,18 @@ public class ImmModeSink { private static final int NORMAL = 2; private static final int TEXTCOORD = 3; - private int vCount, cCount, nCount, tCount; // number of elements fit in each buffer + private int vCount, cCount, nCount, tCount; // number of elements fit in each buffer private int vOffset, cOffset, nOffset, tOffset; // offset of specific array in common buffer private int vElems, cElems, nElems, tElems; // number of used elements in each buffer - private final int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] - private final int vCompsBytes, cCompsBytes, nCompsBytes, tCompsBytes; // byte size of all components + private final int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] + private final int vCompsBytes, cCompsBytes, nCompsBytes, tCompsBytes; // byte size of all components private final int vDataType, cDataType, nDataType, tDataType; private final boolean vDataTypeSigned, cDataTypeSigned, nDataTypeSigned, tDataTypeSigned; private final int pageSize; private Buffer vertexArray, colorArray, normalArray, textCoordArray; private GLArrayDataWrapper vArrayData, cArrayData, nArrayData, tArrayData; - private boolean sealed, sealedGL; + private boolean sealed, sealedGL; private boolean bufferEnabled, bufferWritten, bufferWrittenOnce; private boolean glslLocationSet; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 58151856f..b4a0156e9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. - * + * */ package com.jogamp.opengl.util; @@ -55,22 +55,22 @@ import com.jogamp.opengl.math.geom.Frustum; * regarding the projection (P), modelview (Mv) matrix operation * which is specified in {@link GLMatrixFunc}. * - * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and + * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and * {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. * {@link Frustum} is also provided by {@link #glGetFrustum()}. * To keep these derived values synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} - * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), - * users have to call {@link #update()} before using Mvi and Mvit. + * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), + * users have to call {@link #update()} before using Mvi and Mvit. *
*- * All matrices are provided in column-major order, - * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. + * All matrices are provided in column-major order, + * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. *
*- * PMVMatrix can supplement {@link GL2ES2} applications w/ the + * PMVMatrix can supplement {@link GL2ES2} applications w/ the * lack of the described matrix functionality. *
- *Matrix storage details
+ *Matrix storage details
** All matrices use a common FloatBuffer storage * and are a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced} representation of it. @@ -78,11 +78,11 @@ import com.jogamp.opengl.math.geom.Frustum; * depending how the instance if {@link #PMVMatrix(boolean) being constructed}. *
*- * Note: - *
+ * Note: + *
*
* */ @@ -96,20 +96,20 @@ public class PMVMatrix implements GLMatrixFunc { public static final int MODIFIED_TEXTURE = 1 << 2; /** Bit value stating all is modified */ public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; - + /** Bit value stating a dirty {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)}. */ public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0; /** Bit value stating a dirty {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. */ - public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; + public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; /** Bit value stating a dirty {@link #glGetFrustum() frustum}. */ - public static final int DIRTY_FRUSTUM = 1 << 2; + public static final int DIRTY_FRUSTUM = 1 << 2; /** Bit value stating all is dirty */ public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM; - + /** - * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} * @return true if the given matrix-mode name is valid, otherwise false. - */ + */ public static final boolean isMatrixModeName(final int matrixModeName) { switch(matrixModeName) { case GL_MODELVIEW_MATRIX: @@ -121,9 +121,9 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} * @return The corresponding matrix-get name, one of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} - */ + */ public static final int matrixModeName2MatrixGetName(final int matrixModeName) { switch(matrixModeName) { case GL_MODELVIEW: @@ -138,9 +138,9 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} + * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} * @return true if the given matrix-get name is valid, otherwise false. - */ + */ public static final boolean isMatrixGetName(final int matrixGetName) { switch(matrixGetName) { case GL_MATRIX_MODE: @@ -155,7 +155,7 @@ public class PMVMatrix implements GLMatrixFunc { /** * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} * @return The corresponding matrix-mode name, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} - */ + */ public static final int matrixGetName2MatrixModeName(final int matrixGetName) { switch(matrixGetName) { case GL_MODELVIEW_MATRIX: @@ -168,18 +168,18 @@ public class PMVMatrix implements GLMatrixFunc { throw new GLException("unsupported matrixGetName: "+matrixGetName); } } - - /** + + /** * @param sb optional passed StringBuilder instance to be used * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) * @return matrix string representation */ public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a) { - return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false); + return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false); } - - /** + + /** * @param sb optional passed StringBuilder instance to be used * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) @@ -187,33 +187,33 @@ public class PMVMatrix implements GLMatrixFunc { * @return side by side representation */ public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a, FloatBuffer b) { - return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false); + return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false); } - + /** * Creates an instance of PMVMatrix {@link #PMVMatrix(boolean) PMVMatrix(boolean useBackingArray)}, - * with- The matrix is a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.
*- Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.
- *- If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.
+ *- If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.
*useBackingArray = true
. + * withuseBackingArray = true
. */ public PMVMatrix() { this(true); } - + /** * Creates an instance of PMVMatrix. - * + * * @param useBackingArraytrue
for non direct NIO Buffers with guaranteed backing array, * which allows faster access in Java computation. *+ * and hence the Java computation will be throttled down by direct IO get/put + * operations. *
false
for direct NIO buffers w/o a guaranteed backing array. * In most Java implementations, direct NIO buffers have no backing array - * and hence the Java computation will be throttled down by direct IO get/put - * operations.Depending on the application, ie. whether the Java computation or - * JNI invocation and hence native data transfer part is heavier, + * JNI invocation and hence native data transfer part is heavier, * this flag shall be set to
. */ public PMVMatrix(boolean useBackingArray) { this.usesBackingArray = useBackingArray; - + // I Identity // T Texture // P Projection @@ -228,24 +228,24 @@ public class PMVMatrix implements GLMatrixFunc { matrixBuffer = Buffers.newDirectByteBuffer( ( 6*16 + ProjectFloat.getRequiredFloatBufferSize() ) * Buffers.SIZEOF_FLOAT ); matrixBuffer.mark(); } - + matrixIdent = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 0*16, 1*16); // I matrixTex = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 1*16, 1*16); // T - matrixPMvMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 4*16); // P + Mv + Mvi + Mvit + matrixPMvMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 4*16); // P + Mv + Mvi + Mvit matrixPMvMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 3*16); // P + Mv + Mvi matrixPMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 2*16); // P + Mv matrixP = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 1*16); // P matrixMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 3*16, 1*16); // Mv matrixMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 4*16, 1*16); // Mvi matrixMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 5*16, 1*16); // Mvit - + projectFloat = new ProjectFloat(matrixBuffer, matrixBufferArray, 6*16); - + if(null != matrixBuffer) { matrixBuffer.reset(); - } + } FloatUtil.makeIdentityf(matrixIdent); - + vec3f = new float[3]; matrixMult = new float[16]; matrixTrans = new float[16]; @@ -263,7 +263,7 @@ public class PMVMatrix implements GLMatrixFunc { matrixTStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixPStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixMvStack= new FloatStack( 0, 16*16); // growSize: half GL-min size (32) - + // default values and mode glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -275,22 +275,22 @@ public class PMVMatrix implements GLMatrixFunc { dirtyBits = DIRTY_ALL; requestMask = 0; matrixMode = GL_MODELVIEW; - + mulPMV = null; frustum = null; } /** @see #PMVMatrix(boolean) */ - public final boolean usesBackingArray() { return usesBackingArray; } - + public final boolean usesBackingArray() { return usesBackingArray; } + public final void destroy() { if(null!=projectFloat) { projectFloat.destroy(); projectFloat=null; } matrixBuffer=null; - matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; - matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null; + matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; + matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null; vec3f = null; matrixMult = null; @@ -299,7 +299,7 @@ public class PMVMatrix implements GLMatrixFunc { matrixScale = null; matrixOrtho = null; matrixFrustum = null; - + if(null!=matrixPStack) { matrixPStack=null; } @@ -314,13 +314,13 @@ public class PMVMatrix implements GLMatrixFunc { } } - + /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ public final int glGetMatrixMode() { return matrixMode; } - /** + /** * Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). *true
orfalse
* See matrix storage details. @@ -330,7 +330,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixTex; } - /** + /** * Returns the {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). *
* See matrix storage details. @@ -340,7 +340,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixP; } - /** + /** * Returns the {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). *
* See matrix storage details. @@ -350,7 +350,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixMv; } - /** + /** * Returns the inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi). *
* Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. @@ -367,7 +367,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixMvi; } - /** + /** * Returns the inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit). *
* Method enables the Mvit matrix update, and performs it's update w/o clearing the modified bits. @@ -383,9 +383,9 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixMvit; } - - /** - * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}. + + /** + * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}. *
* See matrix storage details. *
@@ -393,9 +393,9 @@ public class PMVMatrix implements GLMatrixFunc { public final FloatBuffer glGetPMvMatrixf() { return matrixPMv; } - - /** - * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. + + /** + * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. ** Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. *
@@ -410,9 +410,9 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixPMvMvi; } - - /** - * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}. + + /** + * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}. ** Method enables the Mvi and Mvit matrix update, and performs it's update w/o clearing the modified bits. *
@@ -427,14 +427,14 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixPMvMvit; } - + /** Returns the frustum, derived from projection * modelview */ public Frustum glGetFrustum() { requestMask |= DIRTY_FRUSTUM; updateImpl(false); return frustum; } - + /* * @return the matrix of the current matrix-mode */ @@ -443,7 +443,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixName Either a matrix-get-name, i.e. + * @param matrixName Either a matrix-get-name, i.e. * {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX}, * or a matrix-mode-name, i.e. * {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} @@ -462,10 +462,10 @@ public class PMVMatrix implements GLMatrixFunc { return matrixTex; default: throw new GLException("unsupported matrixName: "+matrixName); - } + } } - // + // // GLMatrixFunc implementation // @@ -494,7 +494,7 @@ public class PMVMatrix implements GLMatrixFunc { } params.position(pos); } - + @Override public final void glGetFloatv(int matrixGetName, float[] params, int params_offset) { if(matrixGetName==GL_MATRIX_MODE) { @@ -505,7 +505,7 @@ public class PMVMatrix implements GLMatrixFunc { matrix.reset(); } } - + @Override public final void glGetIntegerv(int pname, IntBuffer params) { int pos = params.position(); @@ -516,7 +516,7 @@ public class PMVMatrix implements GLMatrixFunc { } params.position(pos); } - + @Override public final void glGetIntegerv(int pname, int[] params, int params_offset) { if(pname==GL_MATRIX_MODE) { @@ -537,12 +537,12 @@ public class PMVMatrix implements GLMatrixFunc { matrixP.put(values, offset, 16); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; - modifiedBits |= MODIFIED_PROJECTION; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(values, offset, 16); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override @@ -557,12 +557,12 @@ public class PMVMatrix implements GLMatrixFunc { matrixP.put(m); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; - modifiedBits |= MODIFIED_PROJECTION; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(m); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } + } m.position(spos); } @@ -584,9 +584,9 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glPushMatrix() { - if(matrixMode==GL_MODELVIEW) { + if(matrixMode==GL_MODELVIEW) { matrixMvStack.putOnTop(matrixMv, 16); - matrixMv.reset(); + matrixMv.reset(); } else if(matrixMode==GL_PROJECTION) { matrixPStack.putOnTop(matrixP, 16); matrixP.reset(); @@ -612,8 +612,8 @@ public class PMVMatrix implements GLMatrixFunc { matrixTex.put(matrixIdent); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } - matrixIdent.reset(); + } + matrixIdent.reset(); } @Override @@ -629,7 +629,7 @@ public class PMVMatrix implements GLMatrixFunc { } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override @@ -645,12 +645,12 @@ public class PMVMatrix implements GLMatrixFunc { } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, m_offset); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override public final void glTranslatef(final float x, final float y, final float z) { - // Translation matrix: + // Translation matrix: // 1 0 0 x // 0 1 0 y // 0 0 1 z @@ -665,7 +665,7 @@ public class PMVMatrix implements GLMatrixFunc { public final void glRotatef(final float angdeg, float x, float y, float z) { final float angrad = angdeg * (float) Math.PI / 180.0f; final float c = (float)Math.cos(angrad); - final float ic= 1.0f - c; + final float ic= 1.0f - c; final float s = (float)Math.sin(angrad); vec3f[0]=x; vec3f[1]=y; vec3f[2]=z; @@ -700,7 +700,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glScalef(final float x, final float y, final float z) { - // Scale matrix: + // Scale matrix: // x 0 0 0 // 0 y 0 0 // 0 0 z 0 @@ -714,7 +714,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { - // Ortho matrix: + // Ortho matrix: // 2/dx 0 0 tx // 0 2/dy 0 ty // 0 0 2/dz tz @@ -744,7 +744,7 @@ public class PMVMatrix implements GLMatrixFunc { if(left==right || top==bottom) { throw new GLException("GL_INVALID_VALUE: top,bottom and left,right must not be equal"); } - // Frustum matrix: + // Frustum matrix: // 2*zNear/dx 0 A 0 // 0 2*zNear/dy B 0 // 0 0 C D @@ -774,7 +774,7 @@ public class PMVMatrix implements GLMatrixFunc { // // Extra functionality // - + /** * {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} with the perspective/frustum matrix. */ @@ -787,7 +787,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} + * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} * with the eye, object and orientation. */ public final void gluLookAt(float eyex, float eyey, float eyez, @@ -798,7 +798,7 @@ public class PMVMatrix implements GLMatrixFunc { /** * Map object coordinates to window coordinates. - * + * * @param objx * @param objy * @param objz @@ -815,20 +815,20 @@ public class PMVMatrix implements GLMatrixFunc { return projectFloat.gluProject(objx, objy, objz, matrixMv.array(), matrixMv.position(), matrixP.array(), matrixP.position(), - viewport, viewport_offset, + viewport, viewport_offset, win_pos, win_pos_offset); } else { return projectFloat.gluProject(objx, objy, objz, matrixMv, matrixP, - viewport, viewport_offset, + viewport, viewport_offset, win_pos, win_pos_offset); } } /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -845,23 +845,23 @@ public class PMVMatrix implements GLMatrixFunc { return projectFloat.gluUnProject(winx, winy, winz, matrixMv.array(), matrixMv.position(), matrixP.array(), matrixP.position(), - viewport, viewport_offset, + viewport, viewport_offset, obj_pos, obj_pos_offset); } else { return projectFloat.gluUnProject(winx, winy, winz, matrixMv, matrixP, - viewport, viewport_offset, + viewport, viewport_offset, obj_pos, obj_pos_offset); - } + } } - + public final void gluPickMatrix(float x, float y, float deltaX, float deltaY, int[] viewport, int viewport_offset) { projectFloat.gluPickMatrix(this, x, y, deltaX, deltaY, viewport, viewport_offset); } - + public StringBuilder toString(StringBuilder sb, String f) { if(null == sb) { sb = new StringBuilder(); @@ -874,8 +874,8 @@ public class PMVMatrix implements GLMatrixFunc { final boolean frustumReq = 0 != (DIRTY_FRUSTUM & requestMask); final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); - final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); - + final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); + sb.append("PMVMatrix[backingArray ").append(this.usesBackingArray()); sb.append(", modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq); @@ -887,28 +887,28 @@ public class PMVMatrix implements GLMatrixFunc { matrixToString(sb, f, matrixTex); if( 0 != ( requestMask & DIRTY_INVERSE_MODELVIEW ) ) { sb.append(", Inverse Modelview").append(Platform.NEWLINE); - matrixToString(sb, f, matrixMvi); + matrixToString(sb, f, matrixMvi); } if( 0 != ( requestMask & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) { sb.append(", Inverse Transposed Modelview").append(Platform.NEWLINE); - matrixToString(sb, f, matrixMvit); + matrixToString(sb, f, matrixMvit); } sb.append("]"); return sb; } - + public String toString() { return toString(null, "%10.5f").toString(); } - /** + /** * Returns the modified bits due to mutable operations.. ** A modified bit is set, if the corresponding matrix had been modified by a mutable operation * since last {@link #update()} or {@link #getModifiedBits(boolean) getModifiedBits(true)} call. *
* @param clear if true, clears the modified bits, otherwise leaves them untouched. - * + * * @see #MODIFIED_PROJECTION * @see #MODIFIED_MODELVIEW * @see #MODIFIED_TEXTURE @@ -920,16 +920,16 @@ public class PMVMatrix implements GLMatrixFunc { } return r; } - - /** + + /** * Returns the dirty bits due to mutable operations. ** A dirty bit is set , if the corresponding matrix had been modified by a mutable operation * since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) or {@link Frustum} - * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. *
- * + * * @deprecated Function is exposed for debugging purposes only. * @see #DIRTY_INVERSE_MODELVIEW * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW @@ -944,12 +944,12 @@ public class PMVMatrix implements GLMatrixFunc { return dirtyBits; } - /** + /** * Returns the request bit mask, which uses bit values equal to the dirty mask. *- * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. - *
+ * * * @deprecated Function is exposed for debugging purposes only. * @see #clearAllUpdateRequests() @@ -965,16 +965,16 @@ public class PMVMatrix implements GLMatrixFunc { public final int getRequestMask() { return requestMask; } - - + + /** * Clears all {@link #update()} requests of the Mvi and Mvit matrix and Frustum - * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. ** Allows user to disable subsequent Mvi, Mvit and {@link Frustum} updates if no more required. - *
- * + * + * * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() @@ -983,14 +983,14 @@ public class PMVMatrix implements GLMatrixFunc { * @see #getRequestMask() */ public final void clearAllUpdateRequests() { - requestMask &= ~DIRTY_ALL; + requestMask &= ~DIRTY_ALL; } - + /** * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)}, - * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum} - * if they are dirty and they were requested - * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum} + * if they are dirty and they were requested + * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. ** The Mvi and Mvit matrices and {@link Frustum} are considered dirty, if their corresponding @@ -999,7 +999,7 @@ public class PMVMatrix implements GLMatrixFunc { *
* Method should be called manually in case mutable operations has been called * and caller operates on already fetched references, i.e. not calling - * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} etc anymore. *
*@@ -1007,12 +1007,12 @@ public class PMVMatrix implements GLMatrixFunc { * which are set by any mutable operation. The modified bits have no impact * on this method, but the return value. *
- * - * @return true if any matrix has been modified since last update call or + * + * @return true if any matrix has been modified since last update call or * if the derived matrices Mvi and Mvit or {@link Frustum} were updated, otherwise false. * In other words, method returns true if any matrix used by the caller must be updated, * e.g. uniforms in a shader program. - * + * * @see #getModifiedBits(boolean) * @see #MODIFIED_PROJECTION * @see #MODIFIED_MODELVIEW @@ -1035,7 +1035,7 @@ public class PMVMatrix implements GLMatrixFunc { if(clearModBits) { modifiedBits = 0; } - + if( 0 != ( dirtyBits & ( DIRTY_FRUSTUM & requestMask ) ) ) { if( null == frustum ) { frustum = new Frustum(); @@ -1046,7 +1046,7 @@ public class PMVMatrix implements GLMatrixFunc { dirtyBits &= ~DIRTY_FRUSTUM; mod = true; } - + if( 0 == ( dirtyBits & requestMask ) ) { return mod; // nothing more requested which may have been dirty } @@ -1061,9 +1061,9 @@ public class PMVMatrix implements GLMatrixFunc { } return setMviMvitNIODirectAccess() || mod; } - + // - // private + // private // private int nioBackupArraySupported = 0; // -1 not supported, 0 - TBD, 1 - supported private final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; @@ -1080,7 +1080,7 @@ public class PMVMatrix implements GLMatrixFunc { res = true; } if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix + // transpose matrix final float[] _matrixMvit = matrixMvit.array(); final int _matrixMvitOffset = matrixMvit.position(); for (int i = 0; i < 4; i++) { @@ -1093,7 +1093,7 @@ public class PMVMatrix implements GLMatrixFunc { } return res; } - + private final boolean setMviMvitNIODirectAccess() { boolean res = false; if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() @@ -1104,7 +1104,7 @@ public class PMVMatrix implements GLMatrixFunc { res = true; } if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix + // transpose matrix for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrixMvit.put(j+i*4, matrixMvi.get(i+j*4)); diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index a2b7ba343..b00866dd9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -35,14 +35,14 @@ import javax.media.opengl.GLException; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** - * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. + * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. ** See {@link TileRendererBase} for details. *
*/ public class RandomTileRenderer extends TileRendererBase { private boolean tileRectSet = false; - + /** * Creates a new TileRenderer object */ @@ -72,15 +72,15 @@ public class RandomTileRenderer extends TileRendererBase { /** * Set the tile rectangle for the subsequent rendering calls. - * - * @throws IllegalArgumentException is tile x/y are < 0 or tile size is <= 0x0 + * + * @throws IllegalArgumentException is tile x/y are < 0 or tile size is <= 0x0 */ public void setTileRect(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException, IllegalArgumentException { if( 0 > tX || 0 > tX ) { - throw new IllegalArgumentException("Tile pos must be >= 0/0"); + throw new IllegalArgumentException("Tile pos must be >= 0/0"); } if( 0 >= tWidth || 0 >= tHeight ) { - throw new IllegalArgumentException("Tile size must be > 0x0"); + throw new IllegalArgumentException("Tile size must be > 0x0"); } this.currentTileXPos = tX; this.currentTileYPos = tY; @@ -88,57 +88,57 @@ public class RandomTileRenderer extends TileRendererBase { this.currentTileHeight = tHeight; tileRectSet = true; } - + @Override public final boolean isSetup() { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight() && tileRectSet; } - + /** * {@inheritDoc} - * - *+ * + *
* end of tiling is never reached w/ {@link RandomRileRenderer}, * i.e. method always returns false. *
*/ @Override public final boolean eot() { return false; } - + /** * {@inheritDoc} - * + * * Reset internal states of {@link RandomTileRenderer} are: none. */ @Override public final void reset() { } - + /** * {@inheritDoc} - * - * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override public final void beginTile(GL gl) throws IllegalStateException, GLException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { - throw new IllegalStateException("Image size has not been set"); + throw new IllegalStateException("Image size has not been set"); } if( !tileRectSet ) { throw new IllegalStateException("tileRect has not been set"); } validateGL(gl); - + gl.glViewport( 0, 0, currentTileWidth, currentTileHeight ); - + if( DEBUG ) { System.err.println("TileRenderer.begin.X: "+this.toString()); } - + // Do not forget to issue: // reshape( 0, 0, tW, tH ); // which shall reflect tile renderer fileds: currentTileXPos, currentTileYPos and imageSize - + beginCalled = true; } @@ -148,7 +148,7 @@ public class RandomTileRenderer extends TileRendererBase { throw new IllegalStateException("beginTile(..) has not been called"); } validateGL(gl); - + // be sure OpenGL rendering is finished gl.glFlush(); @@ -220,13 +220,13 @@ public class RandomTileRenderer extends TileRendererBase { /* restore previous glPixelStore values */ psm.restore(gl); - + beginCalled = false; } - + /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. - * + * * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java index b949f0e39..47d56bcb1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java @@ -1,21 +1,21 @@ /* * Copyright (c) 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 @@ -28,7 +28,7 @@ * 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. @@ -46,7 +46,7 @@ import java.nio.channels.*; * class; can also be used in conjunction with the {@link com.jogamp.opengl.util.gl2.TileRenderer} class. */ public class TGAWriter { - + private static final int TARGA_HEADER_SIZE = 18; private FileChannel ch; @@ -91,7 +91,7 @@ public class TGAWriter { image.put(14, (byte) (height & 0xFF)); // height image.put(15, (byte) (height >> 8)); // height image.put(16, (byte) pixelSize); // pixel size - + // go to image data position image.position(TARGA_HEADER_SIZE); // jogl needs a sliced buffer diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 999db77a9..7f86b14c6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,18 +20,18 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. - * + * * --------------------- - * + * * Based on Brian Paul's tile rendering library, found * at http://www.mesa3d.org/brianp/TR.html. - * - * Copyright (C) 1997-2005 Brian Paul. - * Licensed under BSD-compatible terms with permission of the author. + * + * Copyright (C) 1997-2005 Brian Paul. + * Licensed under BSD-compatible terms with permission of the author. * See LICENSE.txt for license information. */ package com.jogamp.opengl.util; @@ -60,7 +60,7 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; ** See {@link TileRendererBase} for details. *
- * + * * @author ryanm, sgothel */ public class TileRenderer extends TileRendererBase { @@ -150,7 +150,7 @@ public class TileRenderer extends TileRendererBase { .append("rowOrder "+rowOrder+", offset/size "+offsetX+"/"+offsetY+" "+tileSize.getWidth()+"x"+tileSize.getHeight()+" brd "+tileBorder+", "); return super.tileDetails(sb); } - + /** * Creates a new TileRenderer object */ @@ -169,7 +169,7 @@ public class TileRenderer extends TileRendererBase { super.setImageSize(width, height); reset(); } - + /** * Clips the image-size this tile-renderer iterates through, * which can be retrieved via {@link #getClippedImageSize()}. @@ -179,7 +179,7 @@ public class TileRenderer extends TileRendererBase { ** Implementation {@link #reset()} internal states. *
- * + * * @param width The image-clipping.width * @param height The image-clipping.height * @see #getClippedImageSize() @@ -208,7 +208,7 @@ public class TileRenderer extends TileRendererBase { * {@link #TR_IMAGE_CLIPPING_HEIGHT}. * */ - public final DimensionImmutable getClippedImageSize() { + public final DimensionImmutable getClippedImageSize() { if( null != imageClippingDim ) { return new Dimension(Math.min(imageClippingDim.getWidth(), imageSize.getWidth()), Math.min(imageClippingDim.getHeight(), imageSize.getHeight()) ); @@ -224,7 +224,7 @@ public class TileRenderer extends TileRendererBase { ** Implementation {@link #reset()} internal states. *
- * + * * @param width * The width of the tiles. Must not be larger than the GL * context @@ -238,10 +238,10 @@ public class TileRenderer extends TileRendererBase { */ public final void setTileSize(int width, int height, int border) { if( 0 > border ) { - throw new IllegalArgumentException("Tile border must be >= 0"); + throw new IllegalArgumentException("Tile border must be >= 0"); } if( 2 * border >= width || 2 * border >= height ) { - throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); + throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); } tileBorder = border; tileSize.set( width, height ); @@ -249,7 +249,7 @@ public class TileRenderer extends TileRendererBase { reset(); } - /** + /** * Sets an xy offset for the resulting tiles * {@link TileRendererBase#TR_CURRENT_TILE_X_POS x-pos} and {@link TileRendererBase#TR_CURRENT_TILE_Y_POS y-pos}. * @see #TR_TILE_X_OFFSET @@ -259,12 +259,12 @@ public class TileRenderer extends TileRendererBase { offsetX = xoff; offsetY = yoff; } - + /** * {@inheritDoc} - * + * * Reset internal states of {@link TileRenderer} are: - *+ *
*
- {@link #TR_ROWS}
*- {@link #TR_COLUMNS}
*- {@link #TR_CURRENT_COLUMN}
@@ -291,13 +291,13 @@ public class TileRenderer extends TileRendererBase { assert columns >= 0; assert rows >= 0; - + beginCalled = false; isInit = true; } /* pp */ final int getCurrentTile() { return currentTile; } - + @Override public final int getParam(int pname) { switch (pname) { @@ -346,7 +346,7 @@ public class TileRenderer extends TileRendererBase { /** * Sets the order of row traversal, default is {@link #TR_BOTTOM_TO_TOP}. - * + * * @param order The row traversal order, must be either {@link #TR_TOP_TO_BOTTOM} or {@link #TR_BOTTOM_TO_TOP}. */ public final void setRowOrder(int order) { @@ -361,11 +361,11 @@ public class TileRenderer extends TileRendererBase { public final boolean isSetup() { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight(); } - + /** * {@inheritDoc} - * - *+ * + *
* end of tiling is reached w/ {@link TileRenderer}, if at least one of the following is true: *
*
- all tiles have been rendered, i.e. {@link #TR_CURRENT_TILE_NUM} is -1
@@ -378,13 +378,13 @@ public class TileRenderer extends TileRendererBase { if ( !isInit ) { // ensure at least one reset-call reset(); } - return 0 > currentTile || 0 >= columns*rows; + return 0 > currentTile || 0 >= columns*rows; } - + /** * {@inheritDoc} - * - * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or * {@link #eot() end-of-tiling} has been reached. */ @Override @@ -396,7 +396,7 @@ public class TileRenderer extends TileRendererBase { throw new IllegalStateException("EOT reached: "+this); } validateGL(gl); - + /* which tile (by row and column) we're about to render */ if (rowOrder == TR_BOTTOM_TO_TOP) { currentRow = currentTile / columns; @@ -434,11 +434,11 @@ public class TileRenderer extends TileRendererBase { currentTileHeight = tH; gl.glViewport( 0, 0, tW, tH ); - + if( DEBUG ) { System.err.println("TileRenderer.begin: "+this.toString()); } - + // Do not forget to issue: // reshape( 0, 0, tW, tH ); // which shall reflect tile renderer tiles: currentTileXPos, currentTileYPos and imageSize @@ -454,7 +454,7 @@ public class TileRenderer extends TileRendererBase { // be sure OpenGL rendering is finished gl.glFlush(); - + // save current glPixelStore values psm.save(gl); psm.setPackAlignment(gl, 1); @@ -467,13 +467,13 @@ public class TileRenderer extends TileRendererBase { } else { gl2es3 = null; readBuffer = 0; // undef. probably default: GL_FRONT (single buffering) GL_BACK (double buffering) - } + } if( DEBUG ) { System.err.println("TileRenderer.end.0: readBuffer 0x"+Integer.toHexString(readBuffer)+", "+this.toString()); } - + final int tmp[] = new int[1]; - + if( tileBuffer != null ) { final GLPixelAttributes pixelAttribs = tileBuffer.pixelAttributes; final int srcX = tileBorder; @@ -527,7 +527,7 @@ public class TileRenderer extends TileRendererBase { psm.restore(gl); beginCalled = false; - + /* increment tile counter, return 1 if more tiles left to render */ currentTile++; if( currentTile >= rows * columns ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index 0553d5673..ff7cc5516 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,18 +20,18 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. - * + * * --------------------- - * + * * Based on Brian Paul's tile rendering library, found * at http://www.mesa3d.org/brianp/TR.html. - * - * Copyright (C) 1997-2005 Brian Paul. - * Licensed under BSD-compatible terms with permission of the author. + * + * Copyright (C) 1997-2005 Brian Paul. + * Licensed under BSD-compatible terms with permission of the author. * See LICENSE.txt for license information. */ package com.jogamp.opengl.util; @@ -66,17 +66,17 @@ import jogamp.opengl.Debug; * The PMV matrix needs to be reshaped in user code * after calling {@link #beginTile(GL)}, See {@link #beginTile(GL)}. * - *+ *
* If {@link #attachAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, * the {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int)} method * is being called after {@link #beginTile(GL)} for each rendered tile. - * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. + * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. *
*GL Profile Requirement
*- * Note that {@link #setImageBuffer(GLPixelBuffer) image buffer} can only be used + * Note that {@link #setImageBuffer(GLPixelBuffer) image buffer} can only be used * in conjunction w/ a {@link GL} instance ≥ {@link GL2ES3} passed to {@link #beginTile(GL)} and {@link #endTile(GL)}.
- * + * * @author ryanm, sgothel */ public abstract class TileRendererBase { @@ -114,16 +114,16 @@ public abstract class TileRendererBase { * The height of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_HEIGHT = 6; - + /* pp */ static final boolean DEBUG = Debug.debug("TileRenderer"); - - /** + + /** * Listener for tile renderer events, intended to extend {@link GLEventListener} implementations, * enabling tile rendering via {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable)}. */ public static interface TileRendererListener { - /** - * The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable) attached} + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable) attached} * to the given {@link TileRendererBase} instance. *
- * This is due to setting up the {@link GL2ES3#GL_PACK_ROW_LENGTH pack row length} + * This is due to setting up the {@link GL2ES3#GL_PACK_ROW_LENGTH pack row length} * for an {@link #setImageSize(int, int) image width} != tile-width, which usually is the case.
* Hence a {@link GLException} is thrown in both methods, * if using an {@link #setImageBuffer(GLPixelBuffer) image buffer} @@ -86,7 +86,7 @@ import jogamp.opengl.Debug; * Further more, reading back of MSAA buffers is only supported since {@link GL2ES3} * since it requires to set the {@link GL2ES3#glReadBuffer(int) read-buffer}. ** The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} @@ -133,9 +133,9 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void addTileRendererNotify(TileRendererBase tr); - - /** - * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} + + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} * from the given {@link TileRendererBase} instance. *
* The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} @@ -145,10 +145,10 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void removeTileRendererNotify(TileRendererBase tr); - - /** + + /** * Called by the {@link TileRendererBase} during tile-rendering via an - * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s + * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s * {@link GLAutoDrawable#display()} call for each tile before {@link #display(GLAutoDrawable)}. *
* The PMV Matrix shall be reshaped @@ -175,14 +175,14 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void reshapeTile(TileRendererBase tr, - int tileX, int tileY, int tileWidth, int tileHeight, + int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); /** - * Called by the {@link TileRendererBase} during tile-rendering + * Called by the {@link TileRendererBase} during tile-rendering * after {@link TileRendererBase#beginTile(GL)} and before {@link #reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(..)}. *
- * If {@link TileRendererBase} is of type {@link TileRenderer}, + * If {@link TileRendererBase} is of type {@link TileRenderer}, * method is called for the first tile of all tiles.
@@ -193,12 +193,12 @@ public abstract class TileRendererBase { * @param tr the issuing {@link TileRendererBase} */ public void startTileRendering(TileRendererBase tr); - + /** * Called by the {@link TileRenderer} during tile-rendering * after {@link TileRendererBase#endTile(GL)} and {@link GLAutoDrawable#swapBuffers()}. *
* Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. *- * If {@link TileRendererBase} is of type {@link TileRenderer}, + * If {@link TileRendererBase} is of type {@link TileRenderer}, * method is called for the last tile of all tiles.
@@ -210,7 +210,7 @@ public abstract class TileRendererBase { */ public void endTileRendering(TileRendererBase tr); } - + protected final Dimension imageSize = new Dimension(0, 0); protected final GLPixelStorageModes psm = new GLPixelStorageModes(); protected GLPixelBuffer imageBuffer; @@ -249,24 +249,24 @@ public abstract class TileRendererBase { return getClass().getSimpleName()+ "["+toString(sb).toString()+"]"; } - + protected TileRendererBase() { } /** * Gets the parameters of this TileRenderer object - * + * * @param pname The parameter name that is to be retrieved * @return the value of the parameter * @throws IllegalArgumentException if
* Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. *pname
is not handled */ public abstract int getParam(int pname) throws IllegalArgumentException; - + /** * Specify a buffer the tiles to be copied to. This is not * necessary for the creation of the final image, but useful if you * want to inspect each tile in turn. - * + * * @param buffer The buffer itself. Must be large enough to contain a random tile */ public final void setTileBuffer(GLPixelBuffer buffer) { @@ -281,7 +281,7 @@ public abstract class TileRendererBase { /** * Sets the desired size of the final image - * + * * @param width The width of the final image * @param height The height of the final image */ @@ -294,7 +294,7 @@ public abstract class TileRendererBase { /** * Sets the buffer in which to store the final image - * + * * @param buffer the buffer itself, must be large enough to hold the final image */ public final void setImageBuffer(GLPixelBuffer buffer) { @@ -310,16 +310,16 @@ public abstract class TileRendererBase { /* pp */ final void validateGL(GL gl) throws GLException { if( imageBuffer != null && !gl.isGL2ES3()) { throw new GLException("Using image-buffer w/ inssufficient GL context: "+gl.getContext().getGLVersion()+", "+gl.getGLProfile()); - } + } } - - /** + + /** * Returns true if this instance is setup properly, i.e. {@link #setImageSize(int, int)} .., * and ready for {@link #beginTile(GL)}. * Otherwise returns false. */ public abstract boolean isSetup(); - + /** * Returns true if end of tiling has been reached, otherwise false. *@@ -331,7 +331,7 @@ public abstract class TileRendererBase { *
*/ public abstract boolean eot(); - + /** * Method resets implementation's internal state to start of tiling * as required for {@link #beginTile(GL)} if {@link #eot() end of tiling} has been reached. @@ -340,7 +340,7 @@ public abstract class TileRendererBase { * */ public abstract void reset(); - + /** * Begins rendering a tile. *@@ -367,7 +367,7 @@ public abstract class TileRendererBase { *
** Use shall render the scene afterwards, concluded with a call to - * this renderer {@link #endTile(GL)}. + * this renderer {@link #endTile(GL)}. *
** User has to comply with the GL profile requirement. @@ -376,10 +376,10 @@ public abstract class TileRendererBase { * If {@link #eot() end of tiling} has been reached, * user needs to {@link #reset()} tiling before calling this method. *
- * + * * @param gl The gl context * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} is undefined, - * an {@link #isSetup() implementation related setup} has not be performed + * an {@link #isSetup() implementation related setup} has not be performed * or {@ link #eot()} has been reached. See implementing classes. * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used butgl
instance is < {@link GL2ES3} * @see #isSetup() @@ -387,7 +387,7 @@ public abstract class TileRendererBase { * @see #reset() */ public abstract void beginTile(GL gl) throws IllegalStateException, GLException; - + /** * Must be called after rendering the scene, * see {@link #beginTile(GL)}. @@ -399,13 +399,13 @@ public abstract class TileRendererBase { ** User has to comply with the GL profile requirement. *
- * + * * @param gl the gl context * @throws IllegalStateException if beginTile(gl) has not been called * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used butgl
instance is < {@link GL2ES3} */ public abstract void endTile( GL gl ) throws IllegalStateException, GLException; - + /** * Determines whether the chosen {@link GLCapabilitiesImmutable} * requires a pre-{@link GLDrawable#swapBuffers() swap-buffers} @@ -417,18 +417,18 @@ public abstract class TileRendererBase { * Here {@link GLDrawable#swapBuffers() swap-buffers} shall happen after calling {@link #endTile(GL)}, the default. * *- * However, multisampling offscreen {@link GLFBODrawable}s + * However, multisampling offscreen {@link GLFBODrawable}s * utilize {@link GLDrawable#swapBuffers() swap-buffers} to downsample * the multisamples into the readable sampling sink. - * In this case, we require a {@link GLDrawable#swapBuffers() swap-buffers} before calling {@link #endTile(GL)}. - *
- * @param chosenCaps the chosen {@link GLCapabilitiesImmutable} + * In this case, we require a {@link GLDrawable#swapBuffers() swap-buffers} before calling {@link #endTile(GL)}. + * + * @param chosenCaps the chosen {@link GLCapabilitiesImmutable} * @return chosenCaps.isFBO() && chosenCaps.getSampleBuffers() */ public final boolean reqPreSwapBuffers(GLCapabilitiesImmutable chosenCaps) { return chosenCaps.isFBO() && chosenCaps.getSampleBuffers(); } - + /** * Attaches the given {@link GLAutoDrawable} to this tile renderer. *@@ -440,17 +440,17 @@ public abstract class TileRendererBase { *
* The {@link GLAutoDrawable}'s {@link GLAutoDrawable#getAutoSwapBufferMode() auto-swap mode} is cached * and set to
*false
, since {@link GLAutoDrawable#swapBuffers() swapBuffers()} maybe issued before {@link #endTile(GL)}, - * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. + * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. *- * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable} + * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable} * to handle the tile rendering, replacing the original {@link GLEventListener}.
* It's {@link GLEventListener#display(GLAutoDrawable) display} implementations issues: **
- Optional {@link #setGLEventListener(GLEventListener, GLEventListener) pre-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
*- {@link #beginTile(GL)}
*- for all original {@link TileRendererListener}: - *
@@ -468,7 +468,7 @@ public abstract class TileRendererBase { * since it's called after {@link #endTile(GL)}. * *+ *
*
- {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight)}
*- {@link GLEventListener#display(GLAutoDrawable) display(autoDrawable)}
*- * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer + * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer * and to restore it's original {@link GLEventListener}. *
* @param glad the {@link GLAutoDrawable} to attach. @@ -481,7 +481,7 @@ public abstract class TileRendererBase { throw new IllegalStateException("GLAutoDrawable already attached"); } this.glad = glad; - + final int aSz = glad.getGLEventListenerCount(); listeners = new GLEventListener[aSz]; listenersInit = new boolean[aSz]; @@ -510,11 +510,11 @@ public abstract class TileRendererBase { } } - /** - * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, + /** + * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, *null
if none is attached. *- * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} + * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} * or {@link TileRendererListener#removeTileRendererNotify(TileRendererBase)}, method returns the * just attached or soon to be detached {@link GLAutoDrawable}. *
@@ -522,9 +522,9 @@ public abstract class TileRendererBase { * @see #detachAutoDrawable() */ public final GLAutoDrawable getAttachedDrawable() { - return glad; + return glad; } - + /** * Detaches the given {@link GLAutoDrawable} from this tile renderer. * @see #attachAutoDrawable(GLAutoDrawable) @@ -547,16 +547,16 @@ public abstract class TileRendererBase { System.err.println("TileRenderer: detached: "+glad); System.err.println("TileRenderer: "+glad.getChosenGLCapabilities()); } - + listeners = null; listenersInit = null; glad = null; } } - + /** * Set {@link GLEventListener} for pre- and post operations when used w/ - * {@link #attachAutoDrawable(GLAutoDrawable)} + * {@link #attachAutoDrawable(GLAutoDrawable)} * for each {@link GLEventListener} callback. * @param preTile the pre operations * @param postTile the post operations @@ -565,10 +565,10 @@ public abstract class TileRendererBase { glEventListenerPre = preTile; glEventListenerPost = postTile; } - + /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. - * + * * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ @@ -578,10 +578,10 @@ public abstract class TileRendererBase { } glad.display(); } - + private final GLEventListener tiledGLEL = new GLEventListener() { final TileRenderer tileRenderer = TileRendererBase.this instanceof TileRenderer ? (TileRenderer) TileRendererBase.this : null; - + @Override public void init(GLAutoDrawable drawable) { if( null != glEventListenerPre ) { @@ -642,13 +642,13 @@ public abstract class TileRendererBase { if( null == tileRenderer || 0 == tileRenderer.getCurrentTile() ) { tl.startTileRendering(TileRendererBase.this); } - tl.reshapeTile(TileRendererBase.this, + tl.reshapeTile(TileRendererBase.this, currentTileXPos, currentTileYPos, currentTileWidth, currentTileHeight, imageSize.getWidth(), imageSize.getHeight()); l.display(drawable); } } - + if( gladRequiresPreSwap ) { glad.swapBuffers(); endTile(gl); @@ -662,7 +662,7 @@ public abstract class TileRendererBase { if( l instanceof TileRendererListener ) { ((TileRendererListener)l).endTileRendering(TileRendererBase.this); } - } + } } if( null != glEventListenerPost ) { glEventListenerPost.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); diff --git a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java index e2bca010c..45f5d2694 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,51 +20,51 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ package com.jogamp.opengl.util; -/** +/** * Integer time frame in milliseconds, maybe specialized for texture/video, audio, .. animated content. ** Type and value range has been chosen to suit embedded CPUs * and characteristics of audio / video streaming and animations. - * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} + * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} * will allow tracking time up 2,147,483.647 seconds or * 24 days 20 hours 31 minutes and 23 seconds. *
** Milliseconds granularity is also more than enough to deal with A-V synchronization, * where the threshold usually lies within 22ms. - *
+ * ** Milliseconds granularity for displaying video frames might seem inaccurate * for each single frame, i.e. 60Hz != 16ms, however, accumulated values diminish - * this error and vertical sync is achieved by build-in V-Sync of the video drivers. + * this error and vertical sync is achieved by build-in V-Sync of the video drivers. *
*/ public class TimeFrameI { /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ native code. */ public static final int INVALID_PTS = 0x80000000; - + /** Constant marking the end of the stream PTS, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ native code. */ - public static final int END_OF_STREAM_PTS = 0x7FFFFFFF; + public static final int END_OF_STREAM_PTS = 0x7FFFFFFF; protected int pts; protected int duration; - + public TimeFrameI() { pts = INVALID_PTS; - duration = 0; + duration = 0; } public TimeFrameI(int pts, int duration) { this.pts = pts; - this.duration = duration; + this.duration = duration; } - + /** Get this frame's presentation timestamp (PTS) in milliseconds. */ public final int getPTS() { return pts; } /** Set this frame's presentation timestamp (PTS) in milliseconds. */ @@ -73,7 +73,7 @@ public class TimeFrameI { public final int getDuration() { return duration; } /** Set this frame's duration in milliseconds. */ public final void setDuration(int duration) { this.duration = duration; } - + public String toString() { return "TimeFrame[pts " + pts + " ms, l " + duration + " ms]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index 8751fc816..dffdfae8e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -35,10 +35,10 @@ import jogamp.opengl.Debug; public interface AudioSink { public static final boolean DEBUG = Debug.debug("AudioSink"); - + /** Default frame duration in millisecond, i.e. 1 frame per {@value} ms. */ public static final int DefaultFrameDuration = 32; - + /** Initial audio queue size in milliseconds. {@value} ms, i.e. 16 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ public static final int DefaultInitialQueueSize = 16 * 32; // 512 ms /** Audio queue grow size in milliseconds. {@value} ms, i.e. 16 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ @@ -47,7 +47,7 @@ public interface AudioSink { public static final int DefaultQueueLimitWithVideo = 96 * 32; // 3072 ms /** Audio queue limit w/o video in milliseconds. {@value} ms, i.e. 32 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ public static final int DefaultQueueLimitAudioOnly = 32 * 32; // 1024 ms - + /** * Specifies the linear audio PCM format. */ @@ -78,7 +78,7 @@ public interface AudioSink { } } } - + /** Sample rate in Hz (1/s). */ public final int sampleRate; /** Sample size in bits. */ @@ -91,36 +91,36 @@ public interface AudioSink { /** Planar or packed samples. If planar, each channel has their own data buffer. If packed, channel data is interleaved in one buffer. */ public final boolean planar; public final boolean littleEndian; - - + + // // Time <-> Bytes // - - /** - * Returns the byte size of the given milliseconds + + /** + * Returns the byte size of the given milliseconds * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. ** Time -> Byte Count - *
+ * */ public final int getDurationsByteSize(int millisecs) { final int bytesPerSample = sampleSize >>> 3; // /8 return millisecs * ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } - - /** - * Returns the duration in milliseconds of the given byte count - * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. + + /** + * Returns the duration in milliseconds of the given byte count + * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. ** Byte Count -> Time - *
+ * */ public final int getBytesDuration(int byteCount) { final int bytesPerSample = sampleSize >>> 3; // /8 - return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); + return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } - + /** * Returns the duration in milliseconds of the given sample count per frame and channel * according to the {@link #sampleRate}, i.e. @@ -129,13 +129,13 @@ public interface AudioSink { *
* Sample Count -> Time - *
+ * * @param sampleCount sample count per frame and channel */ public final float getSamplesDuration(int sampleCount) { return ( 1000f * (float) sampleCount ) / (float)sampleRate; } - + /** * Returns the rounded frame count of the given milliseconds and frame duration. *@@ -147,36 +147,36 @@ public interface AudioSink { * ** Frame Time -> Frame Count - *
+ * * @param millisecs time in milliseconds * @param frameDuration duration per frame in milliseconds. */ public final int getFrameCount(int millisecs, float frameDuration) { return Math.max(1, (int) ( (float)millisecs / frameDuration + 0.5f )); } - + /** * Returns the byte size of given sample count - * according to the {@link #sampleSize}, i.e.: + * according to the {@link #sampleSize}, i.e.: ** sampleCount * ( sampleSize / 8 ) **- * Note: To retrieve the byte size for all channels, + * Note: To retrieve the byte size for all channels, * you need to pre-multiply
*sampleCount
with {@link #channelCount}. ** Sample Count -> Byte Count - *
+ * * @param sampleCount sample count */ public final int getSamplesByteCount(int sampleCount) { return sampleCount * ( sampleSize >>> 3 ); } - + /** * Returns the sample count of given byte count - * according to the {@link #sampleSize}, i.e.: + * according to the {@link #sampleSize}, i.e.: ** ( byteCount * 8 ) / sampleSize *@@ -186,24 +186,24 @@ public interface AudioSink { * ** Byte Count -> Sample Count - *
+ * * @param sampleCount sample count */ public final int getBytesSampleCount(int byteCount) { return ( byteCount << 3 ) / sampleSize; } - - public String toString() { + + public String toString() { return "AudioDataFormat[sampleRate "+sampleRate+", sampleSize "+sampleSize+", channelCount "+channelCount+ ", signed "+signed+", fixedP "+fixedP+", "+(planar?"planar":"packed")+", "+(littleEndian?"little":"big")+"-endian]"; } } - /** Default {@link AudioFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. */ - public static final AudioFormat DefaultFormat = new AudioFormat(44100, 16, 2, true /* signed */, + /** Default {@link AudioFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. */ + public static final AudioFormat DefaultFormat = new AudioFormat(44100, 16, 2, true /* signed */, true /* fixed point */, false /* planar */, true /* littleEndian */); - + public static abstract class AudioFrame extends TimeFrameI { protected int byteSize; - + public AudioFrame() { this.byteSize = 0; } @@ -211,19 +211,19 @@ public interface AudioSink { super(pts, duration); this.byteSize=byteCount; } - + /** Get this frame's size in bytes. */ public final int getByteSize() { return byteSize; } /** Set this frame's size in bytes. */ public final void setByteSize(int size) { this.byteSize=size; } - - public String toString() { + + public String toString() { return "AudioFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes]"; } } public static class AudioDataFrame extends AudioFrame { protected final ByteBuffer data; - + public AudioDataFrame(int pts, int duration, ByteBuffer bytes, int byteCount) { super(pts, duration, byteCount); if( byteCount > bytes.remaining() ) { @@ -231,62 +231,62 @@ public interface AudioSink { } this.data=bytes; } - + /** Get this frame's data. */ public final ByteBuffer getData() { return data; } - - public String toString() { + + public String toString() { return "AudioDataFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes, " + data + "]"; } } - - /** + + /** * Returns theinitialized state
of this instance. ** The
+ * */ public boolean isInitialized(); /** Returns the playback speed. */ public float getPlaySpeed(); - - /** + + /** * Sets the playback speed. *initialized state
is affected by this instance * overall availability, i.e. after instantiation, * as well as by {@link #destroy()}. - ** To simplify test, play speed is normalized, i.e. - *
1.0f
: if Math.abs(1.0f - rate) < 0.01f
1.0f
: if Math.abs(1.0f - rate) < 0.01f
* To simplify test, volume is normalized, i.e. - *
0.0f
: if Math.abs(v) < 0.01f
1.0f
: if Math.abs(1.0f - v) < 0.01f
0.0f
: if Math.abs(v) < 0.01f
1.0f
: if Math.abs(1.0f - v) < 0.01f
- * The preferred format is guaranteed to be supported + * The preferred format is guaranteed to be supported * and shall reflect this sinks most native format, - * i.e. best performance w/o data conversion. + * i.e. best performance w/o data conversion. *
** Known {@link #AudioFormat} attributes considered by implementations: @@ -295,20 +295,20 @@ public interface AudioSink { *
@@ -319,7 +319,7 @@ public interface AudioSink { * beforehand and try to find a suitable supported one. * {@link #getPreferredFormat()} and {@link #getMaxSupportedChannels()} may help. *
- * @param requestedFormat the requested {@link AudioFormat}. + * @param requestedFormat the requested {@link AudioFormat}. * @param frameDuration average or fixed frame duration in milliseconds * helping a caching {@link AudioFrame} based implementation to determine the frame count in the queue. * See {@link #DefaultFrameDuration}. @@ -328,31 +328,31 @@ public interface AudioSink { * @param queueLimit maximum time in milliseconds the queue can hold (and grow), see {@link #DefaultQueueLimitWithVideo} and {@link #DefaultQueueLimitAudioOnly}. * @return true if successful, otherwise false */ - public boolean init(AudioFormat requestedFormat, float frameDuration, + public boolean init(AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit); - + /** * Returns true, if {@link #play()} has been requested and the sink is still playing, * otherwise false. */ public boolean isPlaying(); - - /** + + /** * Play buffers queued via {@link #enqueueData(AudioFrame)} from current internal position. * If no buffers are yet queued or the queue runs empty, playback is being continued when buffers are enqueued later on. * @see #enqueueData(AudioFrame) - * @see #pause() + * @see #pause() */ public void play(); - - /** + + /** * Pause playing buffers while keeping enqueued data incl. it's internal position. * @see #play() * @see #flush() * @see #enqueueData(AudioFrame) */ public void pause(); - + /** * Flush all queued buffers, implies {@link #pause()}. *@@ -363,28 +363,28 @@ public interface AudioSink { * @see #enqueueData(AudioFrame) */ public void flush(); - + /** Destroys this instance, i.e. closes all streams and devices allocated. */ public void destroy(); - - /** - * Returns the number of allocated buffers as requested by + + /** + * Returns the number of allocated buffers as requested by * {@link #init(AudioFormat, float, int, int, int)}. */ public int getFrameCount(); /** @return the current enqueued frames count since {@link #init(AudioFormat, float, int, int, int)}. */ public int getEnqueuedFrameCount(); - - /** + + /** * Returns the current number of frames queued for playing. *
* {@link #init(AudioFormat, float, int, int, int)} must be called first. *
*/ public int getQueuedFrameCount(); - - /** + + /** * Returns the current number of bytes queued for playing. ** {@link #init(AudioFormat, float, int, int, int)} must be called first. @@ -392,28 +392,28 @@ public interface AudioSink { */ public int getQueuedByteCount(); - /** + /** * Returns the current queued frame time in milliseconds for playing. *
* {@link #init(AudioFormat, float, int, int, int)} must be called first. *
*/ public int getQueuedTime(); - - /** + + /** * Return the current audio presentation timestamp (PTS) in milliseconds. */ public int getPTS(); - - /** + + /** * Returns the current number of frames in the sink available for writing. ** {@link #init(AudioFormat, float, int, int, int)} must be called first. *
*/ public int getFreeFrameCount(); - - /** + + /** * Enqueue the remaining bytes of the given {@link AudioDataFrame}'s direct ByteBuffer to this sink. *
* The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}.
@@ -426,8 +426,8 @@ public interface AudioSink {
* to reuse specialized {@link AudioFrame} instances.
*/
public AudioFrame enqueueData(AudioDataFrame audioDataFrame);
-
- /**
+
+ /**
* Enqueue byteCount
bytes of the remaining bytes of the given NIO {@link ByteBuffer} to this sink.
*
* The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}. diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java index a6a14f7dd..2cfd40df7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -58,7 +58,7 @@ public class AudioSinkFactory { if( audioSink.isInitialized() ) { return audioSink; } - } catch (Throwable t) { + } catch (Throwable t) { if(AudioSink.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 74036a3f7..db6f5fdee 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -49,9 +49,9 @@ import com.jogamp.opengl.util.TimeFrameI; * using the appropriate stream id's. *
*- * Camera input can be selected using the {@link #CameraInputScheme} URI. + * Camera input can be selected using the {@link #CameraInputScheme} URI. *
- * + * ** Most of the stream processing is performed on the decoding thread, a.k.a. StreamWorker: @@ -61,7 +61,7 @@ import com.jogamp.opengl.util.TimeFrameI; *
* An occurring {@link StreamException} triggers a {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} event, - * which can be listened to via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long)}. + * which can be listened to via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long)}. *
*- * An occurred {@link StreamException} can be read via {@link #getStreamException()}. + * An occurred {@link StreamException} can be read via {@link #getStreamException()}. *
- * + * * *@@ -94,7 +94,7 @@ import com.jogamp.opengl.util.TimeFrameI; *
*
Toolkit | GLAutoDrawable Implementation | ~ | Return Type of getUpstreamWidget() | *
NEWT | {@link com.jogamp.newt.opengl.GLWindow} | has a | {@link com.jogamp.newt.Window} | @@ -536,7 +536,7 @@ public interface GLAutoDrawable extends GLDrawable { *
AWT | {@link javax.media.opengl.awt.GLCanvas} | is a | {@link java.awt.Canvas} | *
AWT | {@link javax.media.opengl.awt.GLJPanel} | is a | {@link javax.swing.JPanel} | *
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 1f75a7b4a..e84dd7be9 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -32,7 +32,7 @@ package javax.media.opengl; /** *
The base interface from which all GL profiles derive, providing * checked conversion down to concrete profiles, access to the - * OpenGL context associated with the GL and extension/function + * OpenGL context associated with the GL and extension/function * availability queries as described below.
* *While the APIs for vendor extensions are unconditionally @@ -79,7 +79,7 @@ package javax.media.opengl; * */ public interface GLBase { - + /** * Indicates whether this GL object conforms to any of the OpenGL profiles. */ @@ -131,7 +131,7 @@ public interface GLBase { *
* Remark: ES2 compatible desktop profiles are not included. * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}. - *
+ * * @see #isGLES2Compatible() * @see GLContext#isGLES2() */ @@ -142,12 +142,12 @@ public interface GLBase { ** Remark: ES3 compatible desktop profiles are not included. * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}. - *
+ * * @see #isGLES3Compatible() * @see GLContext#isGLES3() */ public boolean isGLES3(); - + /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, * see {@link #isGLES1()} and {@link #isGLES2()}. @@ -180,7 +180,7 @@ public interface GLBase { public boolean isGL3ES3(); /** - * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true. + * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true. *Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
* @see GLContext#isGL4ES3() */ @@ -192,29 +192,29 @@ public interface GLBase { */ public boolean isGL2GL3(); - /** + /** * Indicates whether this GL object uses a GL4 core profile.Includes [ GL4 ].
* @see GLContext#isGL4core() */ public boolean isGL4core(); - - /** + + /** * Indicates whether this GL object uses a GL3 core profile.Includes [ GL4, GL3 ].
* @see GLContext#isGL3core() */ public boolean isGL3core(); - - /** + + /** * Indicates whether this GL object uses a GL core profile.Includes [ GL4, GL3, GLES3, GL2ES2 ].
* @see GLContext#isGLcore() */ public boolean isGLcore(); - + /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. - * @return true if this context is an ES2 context or implements + * @return true if this context is an ES2 context or implements * the extensionGL_ARB_ES2_compatibility
, otherwise false
- * @see GLContext#isGLES2Compatible()
+ * @see GLContext#isGLES2Compatible()
*/
public boolean isGLES2Compatible();
@@ -227,26 +227,26 @@ public interface GLBase {
* * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] *
- * @see GLContext#isGLES3Compatible() + * @see GLContext#isGLES3Compatible() */ public boolean isGLES3Compatible(); - /** - * Indicates whether this GL object supports GLSL. - * @see GLContext#hasGLSL() + /** + * Indicates whether this GL object supports GLSL. + * @see GLContext#hasGLSL() */ public boolean hasGLSL(); /** * Returns the downstream GL instance in case this is a wrapping pipeline, otherwisenull
.
* - * See {@link #getRootGL()} for retrieving the implementing root instance. + * See {@link #getRootGL()} for retrieving the implementing root instance. *
* @throws GLException if the downstream instance is not null and not a GL implementation * @see #getRootGL() */ public GL getDownstreamGL() throws GLException; - + /** * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}. *@@ -256,7 +256,7 @@ public interface GLBase { * @throws GLException if the root instance is not a GL implementation */ public GL getRootGL() throws GLException; - + /** * Casts this object to the GL interface. * @throws GLException if this object is not a GL implementation @@ -360,14 +360,14 @@ public interface GLBase { /** * Returns true if the specified OpenGL core- or extension-function can be * used successfully through this GL instance given the current host (OpenGL - * client) and display (OpenGL server) configuration.
- * By "successfully" we mean that the function is both callable - * on the machine running the program and available on the current - * display.
+ * client) and display (OpenGL server) configuration.
+ * By "successfully" we mean that the function is both callable + * on the machine running the program and available on the current + * display.
* * In order to call a function successfully, the function must be both - * callable on the machine running the program and available on - * the display device that is rendering the output (note: on non-networked, + * callable on the machine running the program and available on + * the display device that is rendering the output (note: on non-networked, * single-display machines these two conditions are identical; on networked and/or * multi-display machines this becomes more complicated). These conditions are * met if the function is either part of the core OpenGL version supported by @@ -376,7 +376,7 @@ public interface GLBase { * * A GL function is callable if it is successfully linked at runtime, * hence the GLContext must be made current at least once. - * + * * @param glFunctionName the name of the OpenGL function (e.g., use * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link * GL#glBindRenderbuffer(int,int)} is available). @@ -386,14 +386,14 @@ public interface GLBase { /** * Returns true if the specified OpenGL extension can be * used successfully through this GL instance given the current host (OpenGL - * client) and display (OpenGL server) configuration.
+ * client) and display (OpenGL server) configuration.
*
* @param glExtensionName the name of the OpenGL extension (e.g.,
* "GL_ARB_vertex_program").
*/
public boolean isExtensionAvailable(String glExtensionName);
- /**
+ /**
* Returns true
if basic FBO support is available, otherwise false
.
*
* Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions
@@ -407,12 +407,12 @@ public interface GLBase {
*/
public boolean hasBasicFBOSupport();
- /**
+ /**
* Returns true
if full FBO support is available, otherwise false
.
*
* Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions
* ARB_framebuffer_object
, or all of
- * EXT_framebuffer_object
, EXT_framebuffer_multisample
,
+ * EXT_framebuffer_object
, EXT_framebuffer_multisample
,
* EXT_framebuffer_blit
, GL_EXT_packed_depth_stencil
.
*
@@ -424,7 +424,7 @@ public interface GLBase {
/**
* Returns the maximum number of FBO RENDERBUFFER samples
- * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
+ * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
* @see GLContext#getMaxRenderbufferSamples()
*/
public int getMaxRenderbufferSamples();
@@ -440,7 +440,7 @@ public interface GLBase {
public boolean isNPOTTextureAvailable();
public boolean isTextureFormatBGRA8888Available();
-
+
/** Provides a platform-independent way to specify the minimum swap
interval for buffer swaps. An argument of 0 disables
sync-to-vertical-refresh completely, while an argument of 1
@@ -449,7 +449,7 @@ public interface GLBase {
is usually either 0 or 1. This function is not guaranteed to
have an effect, and in particular only affects heavyweight
onscreen components.
-
+
@see #getSwapInterval
@throws GLException if this context is not the current
*/
@@ -458,8 +458,8 @@ public interface GLBase {
/** Provides a platform-independent way to get the swap
interval set by {@link #setSwapInterval}.
- If the interval is not set by {@link #setSwapInterval} yet,
- -1 is returned, indicating that the platforms default
+ If the interval is not set by {@link #setSwapInterval} yet,
+ -1 is returned, indicating that the platforms default
is being used.
@see #setSwapInterval
@@ -498,10 +498,10 @@ public interface GLBase {
*/
public Object getExtension(String extensionName);
- /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth);
and void {@native glClearDepthf}(GLclampf depth);
. */
+ /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth);
and void {@native glClearDepthf}(GLclampf depth);
. */
public void glClearDepth( double depth );
- /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth);
and void {@native glDepthRangef}(GLclampf depth);
. */
+ /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth);
and void {@native glDepthRangef}(GLclampf depth);
. */
public void glDepthRange(double zNear, double zFar);
/**
@@ -526,44 +526,44 @@ public interface GLBase {
*/
public boolean glIsVBOElementArrayBound();
- /**
- * Return the framebuffer name bound to this context,
+ /**
+ * Return the framebuffer name bound to this context,
* see {@link GL#glBindFramebuffer(int, int)}.
*/
public int getBoundFramebuffer(int target);
- /**
+ /**
* Return the default draw framebuffer name.
- *
+ *
* May differ from it's default zero
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
- *
+ *
* May differ from it's default zero
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
- *
* For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, - * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations * and {@link GL#GL_BACK} for double buffer configurations. - *
+ * */ public int getDefaultReadBuffer(); - + } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 872069fb8..b825d6388 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -99,7 +99,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } /** - * Copies all {@link GLCapabilities} and {@link Capabilities} values + * Copies all {@link GLCapabilities} and {@link Capabilities} values * fromsource
into this instance.
* @return this instance
*/
@@ -122,11 +122,11 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
sampleExtension = source.getSampleExtension();
return this;
}
-
+
@Override
public int hashCode() {
// 31 * x == (x << 5) - x
- int hash = super.hashCode();
+ int hash = super.hashCode();
hash = ((hash << 5) - hash) + this.glProfile.hashCode() ;
hash = ((hash << 5) - hash) + ( this.hardwareAccelerated ? 1 : 0 );
hash = ((hash << 5) - hash) + ( this.stereo ? 1 : 0 );
@@ -238,7 +238,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
public void setGLProfile(GLProfile profile) {
glProfile=profile;
}
-
+
@Override
public final boolean isPBuffer() {
return isPBuffer;
@@ -255,7 +255,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
* * Requesting offscreen pbuffer mode disables the offscreen auto selection. *
- */ + */ public void setPBuffer(boolean enable) { if(enable) { setOnscreen(false); @@ -267,7 +267,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil public final boolean isFBO() { return isFBO; } - + /** * Requesting offscreen FBO mode. *
@@ -422,7 +422,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
return sampleBuffers;
}
- /**
+ /**
* If sample buffers are enabled, indicates the number of buffers
* to be allocated. Defaults to 2.
* @see #getNumSamples()
@@ -491,7 +491,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil
if(isOnscreen()) {
sink.append("."); // no additional off-screen modes besides on-screen
} else {
- sink.append("auto-cfg"); // auto-config off-screen mode
+ sink.append("auto-cfg"); // auto-config off-screen mode
}
}
sink.append("]");
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
index 5d575c2ee..2e0bec1f9 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. 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
@@ -29,11 +29,11 @@
* 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.
*/
@@ -53,7 +53,7 @@ import javax.media.opengl.GLCapabilitiesImmutable;
the appropriate method of {@link GLDrawableFactory}; the chooser
will be called during the OpenGL context creation process. Note
that this is only a marker interface; its signature is the same as
- {@link CapabilitiesChooser} and the {@link List} of
+ {@link CapabilitiesChooser} and the {@link List} of
objects extending {@link CapabilitiesImmutable}
passed to {@link #chooseCapabilities chooseCapabilities}
is actually a {@link List} of type {@link GLCapabilitiesImmutable}. */
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
index 6af35021f..dc28539a0 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
@@ -37,13 +37,13 @@ import javax.media.nativewindow.CapabilitiesImmutable;
* @see javax.media.nativewindow.CapabilitiesImmutable
*/
public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
- /**
- * One of the platform's default sample extension
+ /**
+ * One of the platform's default sample extension
* EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB
* if available, or any other known fallback one, ie EGLExt.EGL_COVERAGE_SAMPLES_NV
*/
public static final String DEFAULT_SAMPLE_EXTENSION = "default" ;
-
+
/**
* Returns the GL profile you desire or used by the drawable.
*/
@@ -110,10 +110,10 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
*
* Default is false. *
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index f4dbde6b2..bd6867359 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -72,14 +72,14 @@ import com.jogamp.opengl.GLRendererQuirks; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { - + public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); - public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; + public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; - /** - * Iftrue
(default), bootstrapping the available GL profiles
- * will use the highest compatible GL context for each profile,
+ /**
+ * If true
(default), bootstrapping the available GL profiles
+ * will use the highest compatible GL context for each profile,
* hence skipping querying lower profiles if a compatible higher one is found:
*
* Can be turned off with property jogl.debug.GLContext.NoProfileAliasing
.
*
GL_ARB_ES3_compatibility
*/
public static final VersionNumber Version430 = new VersionNumber(4, 3, 0);
-
+
protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0);
//
// Cached keys, bits [0..15]
//
-
+
/** Context option bits, full bit mask covering bits [0..15], i.e. 0x0000FFFF
, {@value}. */
protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
-
+
/** Context option bits, cached bit mask covering 9 bits [0..8], i.e. 0x000001FF
, {@value}. Leaving 7 bits for non cached options, i.e. 9:7. */
protected static final int CTX_IMPL_CACHE_MASK = 0x000001FF;
-
+
/** ARB_create_context
related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
protected static final int CTX_IS_ARB_CREATED = 1 << 0;
/** ARB_create_context
related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
@@ -173,14 +173,14 @@ public abstract class GLContext {
//
// Non cached keys, bits [9..15]
//
-
+
/** GL_ARB_ES2_compatibility
implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
protected static final int CTX_IMPL_ES2_COMPAT = 1 << 9;
/** GL_ARB_ES3_compatibility
implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
protected static final int CTX_IMPL_ES3_COMPAT = 1 << 10;
-
- /**
+
+ /**
* Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
* Not a cache key.
* @see #hasBasicFBOSupport()
@@ -188,15 +188,15 @@ public abstract class GLContext {
*/
protected static final int CTX_IMPL_FBO = 1 << 11;
- /**
- * Context supports OES_single_precision
, fp32, fixed function point (FFP) compatibility entry points,
+ /**
+ * Context supports OES_single_precision
, fp32, fixed function point (FFP) compatibility entry points,
* see {@link #hasFP32CompatAPI()}.
* Not a cache key.
* @see #hasFP32CompatAPI()
* @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
*/
protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 12;
-
+
private static final ThreadLocalnull
.
*/
public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; }
-
+
/**
* Returns true if the quirk
exist in {@link #getRendererQuirks()}, otherwise false.
* @@ -260,10 +260,10 @@ public abstract class GLContext { * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. * @throws IllegalArgumentException if the quirk is out of range */ - public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { - return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; + public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { + return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; } - + /** * Sets the read/write drawable for framebuffer operations. *
@@ -276,13 +276,13 @@ public abstract class GLContext { * attempts to make this context current. Otherwise a race condition may happen. *
* @param readWrite The read/write drawable for framebuffer operations, maybenull
to remove association.
- * @param setWriteOnly Only change the write-drawable, if setWriteOnly
is true
and
- * if the {@link #getGLReadDrawable() read-drawable} differs
- * from the {@link #getGLDrawable() write-drawable}.
+ * @param setWriteOnly Only change the write-drawable, if setWriteOnly
is true
and
+ * if the {@link #getGLReadDrawable() read-drawable} differs
+ * from the {@link #getGLDrawable() write-drawable}.
* Otherwise set both drawables, read and write.
* @return The previous read/write drawable
*
- * @throws GLException in case null
is being passed or
+ * @throws GLException in case null
is being passed or
* this context is made current on another thread.
*
* @see #isGLReadDrawableAvailable()
@@ -292,13 +292,13 @@ public abstract class GLContext {
* @see #getGLDrawable()
*/
public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly);
-
+
/**
* Returns the write-drawable this context uses for framebuffer operations.
* * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - *
+ * * @see #setGLDrawable(GLDrawable, boolean) * @see #setGLReadDrawable(GLDrawable) */ @@ -336,10 +336,10 @@ public abstract class GLContext { ** If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - *
+ * * @see #isGLReadDrawableAvailable() * @see #setGLReadDrawable(GLDrawable) - * @see #getGLReadDrawable() + * @see #getGLReadDrawable() */ public abstract GLDrawable getGLReadDrawable(); @@ -354,9 +354,9 @@ public abstract class GLContext { * ** A return value of {@link #CONTEXT_CURRENT_NEW} - * indicates that that context has been made current for the 1st time, + * indicates that that context has been made current for the 1st time, * or that the state of the underlying context or drawable has - * changed since the last time this context was current. + * changed since the last time this context was current. * In this case, the application may wish to initialize the render state. *
*@@ -378,7 +378,7 @@ public abstract class GLContext { *
* * @returnGL_VERSION
not being the GL version.
*
- * In case no such version exists within GL_VERSION
,
+ * In case no such version exists within GL_VERSION
,
* the {@link VersionNumberString#zeroVersion zero version} instance is returned.
- *
* The vendor's version is usually the vendor's OpenGL driver version. *
@@ -743,31 +743,31 @@ public abstract class GLContext { * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0, * otherwise a static match is being utilized. *- * The context must have been current once, - * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. + * The context must have been current once, + * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. *
*
- * Examples w/ major.minor
:
+ * Examples w/ major.minor
:
*
- * 1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2), + * 1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2), * 3.30 (GL 3.3), 4.00 (GL 4.0), 4.10 (GL 4.1), 4.20 (GL 4.2) ** *
* Matching could also refer to the maximum GLSL version usable by this context * since normal GL implementations are capable of using a lower GLSL version as well. - * The latter is not true on OSX w/ a GL3 context. + * The latter is not true on OSX w/ a GL3 context. *
- * - * @return GLSL version number if context has been made current at least once, + * + * @return GLSL version number if context has been made current at least once, * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. - * + * * @see #getGLVersionNumber() */ public final VersionNumber getGLSLVersionNumber() { return ctxGLSLVersion; } - + /** * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n', * i.e. for desktop @@ -794,10 +794,10 @@ public abstract class GLContext { return ""; } final int minor = ctxGLSLVersion.getMinor(); - final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : ""; + final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : ""; return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ; } - + protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) { if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) { if( 3 > glMajorVersion ) { @@ -814,13 +814,13 @@ public abstract class GLContext { switch ( glMinorVersion ) { case 0: return Version130; // GL 3.0 -> GLSL 1.30 case 1: return Version140; // GL 3.1 -> GLSL 1.40 - default: return Version150; // GL 3.2 -> GLSL 1.50 + default: return Version150; // GL 3.2 -> GLSL 1.50 } } // The new default: GL >= 3.3, ES >= 3.0 return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } - + /** * @return true if this context is an ES2 context or implements * the extensionGL_ARB_ES3_compatibility
or GL_ARB_ES2_compatibility
, otherwise false
@@ -840,18 +840,18 @@ public abstract class GLContext {
return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ;
}
- /**
+ /**
* @return true if impl. is a hardware rasterizer, otherwise false.
* @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile)
- * @see GLProfile#isHardwareRasterizer()
+ * @see GLProfile#isHardwareRasterizer()
*/
public final boolean isHardwareRasterizer() {
return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ;
}
-
+
/**
* @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1.
- * @see GLProfile#hasGLSL()
+ * @see GLProfile#hasGLSL()
*/
public final boolean hasGLSL() {
return isGLES2() ||
@@ -859,7 +859,7 @@ public abstract class GLContext {
isGL2() && ctxVersion.getMajor()>1 ;
}
- /**
+ /**
* Returns true
if basic FBO support is available, otherwise false
.
*
* Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions
@@ -875,30 +875,30 @@ public abstract class GLContext {
return 0 != ( ctxOptions & CTX_IMPL_FBO ) ;
}
- /**
- * Returns true
if OES_single_precision
, fp32, fixed function point (FFP) compatibility entry points available,
+ /**
+ * Returns true
if OES_single_precision
, fp32, fixed function point (FFP) compatibility entry points available,
* otherwise false
.
* @see #CTX_IMPL_FP32_COMPAT_API
*/
public final boolean hasFP32CompatAPI() {
return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ;
}
-
- /**
+
+ /**
* Returns true
if full FBO support is available, otherwise false
.
*
* Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions
* ARB_framebuffer_object
, or all of
- * EXT_framebuffer_object
, EXT_framebuffer_multisample
,
+ * EXT_framebuffer_object
, EXT_framebuffer_multisample
,
* EXT_framebuffer_blit
, GL_EXT_packed_depth_stencil
.
*
* Full FBO support includes multiple color attachments and multisampling. *
*/ - public final boolean hasFullFBOSupport() { + public final boolean hasFullFBOSupport() { return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) && - ( isGL3() || // GL >= 3.0 + ( isGL3() || // GL >= 3.0 isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && @@ -907,10 +907,10 @@ public abstract class GLContext { ) ) ; } - + /** * Returns the maximum number of FBO RENDERBUFFER samples - * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ public final int getMaxRenderbufferSamples() { if( hasFullFBOSupport() ) { @@ -928,7 +928,7 @@ public abstract class GLContext { } return 0; } - + /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returnstrue
. */
public boolean isNPOTTextureAvailable() {
return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two);
@@ -940,9 +940,9 @@ public abstract class GLContext {
isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ;
}
- /**
+ /**
* Indicates whether this GLContext is capable of GL4bc. Includes [ GL4bc ].
- * @see GLProfile#isGL4bc() + * @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -950,9 +950,9 @@ public abstract class GLContext { ctxVersion.getMajor() >= 4; } - /** + /** * Indicates whether this GLContext is capable of GL4.Includes [ GL4bc, GL4 ].
- * @see GLProfile#isGL4() + * @see GLProfile#isGL4() */ public final boolean isGL4() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -960,7 +960,7 @@ public abstract class GLContext { ctxVersion.getMajor() >= 4; } - /** + /** * Indicates whether this GLContext uses a GL4 core profile.Includes [ GL4 ].
*/ public final boolean isGL4core() { @@ -968,10 +968,10 @@ public abstract class GLContext { 0 != ( ctxOptions & CTX_PROFILE_CORE ) && ctxVersion.getMajor() >= 4; } - - /** + + /** * Indicates whether this GLContext is capable of GL3bc.Includes [ GL4bc, GL3bc ].
- * @see GLProfile#isGL3bc() + * @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -979,17 +979,17 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0 ; } - /** + /** * Indicates whether this GLContext is capable of GL3.Includes [ GL4bc, GL4, GL3bc, GL3 ].
- * @see GLProfile#isGL3() + * @see GLProfile#isGL3() */ public final boolean isGL3() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && ctxVersion.compareTo(Version310) >= 0 ; - } - - /** + } + + /** * Indicates whether this GLContext uses a GL3 core profile.Includes [ GL4, GL3 ].
*/ public final boolean isGL3core() { @@ -997,8 +997,8 @@ public abstract class GLContext { 0 != ( ctxOptions & CTX_PROFILE_CORE ) && ctxVersion.compareTo(Version310) >= 0; } - - /** + + /** * Indicates whether this GLContext uses a GL core profile.Includes [ GL4, GL3, GLES3, GLES2 ].
*/ public final boolean isGLcore() { @@ -1008,26 +1008,26 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0 ) ; } - + /** * Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using a GPU buffer source (VBO), - * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}. + * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}. *Includes [GL2ES1, GLES2] == [ GL4bc, GL3bc, GL2, GLES1, GL2ES1, GLES2 ].
*See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852
*/ public final boolean isCPUDataSourcingAvail() { return isGL2ES1() || isGLES2(); } - - /** - * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), + + /** + * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), * starting w/ OpenGL 3.1 core and GLES3. *Includes [ GL4, GL3, GLES3 ].
*Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) there is no more default VAO buffer 0 bound, hence generating and binding one - to avoid INVALID_OPERATION at VertexAttribPointer. + to avoid INVALID_OPERATION at VertexAttribPointer. More clear is GL 4.3 core spec: 10.4 (p 307). **
@@ -1047,87 +1047,87 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0 ) ; } - + /** * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()}, * an own default VAO will be created and bound at context creation. ** - * + * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be* If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()} * returns
+ * *false
, this method returns0
. - ** Otherwise this method returns the VAO object name - * representing this GLContext's own default VAO. - *
+ * representing this GLContext's own default VAO. + * * @see #hasNoDefaultVAO() */ public abstract int getDefaultVAO(); - /** + /** * Indicates whether this GLContext is capable of GL2.Includes [ GL4bc, GL3bc, GL2 ].
- * @see GLProfile#isGL2() + * @see GLProfile#isGL2() */ public final boolean isGL2() { return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ; } - /** + /** * Indicates whether this GLContext is capable of GL2GL3.Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
- * @see GLProfile#isGL2GL3() - */ + * @see GLProfile#isGL2GL3() + */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } - /** + /** * Indicates whether this GLContext is capable of GLES1.Includes [ GLES1 ].
- * @see GLProfile#isGLES1() + * @see GLProfile#isGLES1() */ public final boolean isGLES1() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } /** - * Indicates whether this GLContext is capable of GLES2.Includes [ GLES2 ].
- * @see GLProfile#isGLES2() + * Indicates whether this GLContext is capable of GLES2.Includes [ GLES2 ].
+ * @see GLProfile#isGLES2() */ public final boolean isGLES2() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 2 ; } - /** + /** * Indicates whether this GLContext is capable of GLES3.Includes [ GLES3 ].
- * @see GLProfile#isGLES3() + * @see GLProfile#isGLES3() */ public final boolean isGLES3() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; } - /** + /** * Indicates whether this GLContext is capable of GLES.Includes [ GLES3, GLES1, GLES2 ].
- * @see GLProfile#isGLES() + * @see GLProfile#isGLES() */ public final boolean isGLES() { return 0 != ( CTX_PROFILE_ES & ctxOptions ) ; } - /** + /** * Indicates whether this GLContext is capable of GL2ES1.Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
- * @see GLProfile#isGL2ES1() + * @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { return isGLES1() || isGL2(); } - /** + /** * Indicates whether this GLContext is capable of GL2ES2.Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].
- * @see GLProfile#isGL2ES2() + * @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { return isGLES2() || isGL2GL3(); } - /** + /** * Indicates whether this GLContext is capable of GL2ES3.Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].
* @see GLProfile#isGL2ES3() * @see #isGL3ES3() @@ -1137,16 +1137,16 @@ public abstract class GLContext { return isGL3ES3() || isGL2GL3(); } - /** + /** * Indicates whether this GLContext is capable of GL3ES3.Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
- * @see GLProfile#isGL3ES3() + * @see GLProfile#isGL3ES3() */ public final boolean isGL3ES3() { return isGL4ES3() || isGL3(); } - /** - * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. + /** + * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. *Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
* @see GLProfile#isGL4ES3() */ @@ -1185,7 +1185,7 @@ public abstract class GLContext { * ** For a valid context the default value is
*/ @@ -1222,51 +1222,51 @@ public abstract class GLContext { } protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; } - /** - * Return the framebuffer name bound to this context, + /** + * Return the framebuffer name bound to this context, * see {@link GL#glBindFramebuffer(int, int)}. */ public abstract int getBoundFramebuffer(int target); - - /** + + /** * Return the default draw framebuffer name. - *1
- * in case of an EGL based profile (ES1 or ES2) and-1
+ * in case of an EGL based profile (ES1 or ES2) and-1
* (undefined) for desktop. *+ *
* May differ from it's default
+ * */ public abstract int getDefaultDrawFramebuffer(); - - /** + + /** * Return the default read framebuffer name. - *zero
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - *+ *
* May differ from it's default
+ * */ public abstract int getDefaultReadFramebuffer(); - - /** - * Returns the default color buffer within the current bound - * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, - * which will be used as the source for pixel reading commands, + + /** + * Returns the default color buffer within the current bound + * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, + * which will be used as the source for pixel reading commands, * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. *zero
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - ** For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, - * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations * and {@link GL#GL_BACK} for double buffer configurations. - *
+ * */ public abstract int getDefaultReadBuffer(); - + /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataType(); - + /** Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataFormat(); - + /** * @return The extension implementing the GLDebugOutput feature, * either {@link GLExtensions#ARB_debug_output} or {@link GLExtensions#AMD_debug_output}. @@ -1486,13 +1486,13 @@ public abstract class GLContext { } if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey); - System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } } - /** - * Returns a unique String object using {@link String#intern()} for the given arguments, + /** + * Returns a unique String object using {@link String#intern()} for the given arguments, * which object reference itself can be used as a key. */ protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { @@ -1575,7 +1575,7 @@ public abstract class GLContext { } return val; } - + /** * @param reqMajor Key Value either 1, 2, 3 or 4 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} @@ -1647,7 +1647,7 @@ public abstract class GLContext { reqMajorCTP[1]=CTX_PROFILE_CORE; } } - + /** * @param device the device the context profile is being requested for * @param GLProfile the GLProfile the context profile is being requested for @@ -1656,7 +1656,7 @@ public abstract class GLContext { protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) { final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glp, reqMajorCTP); - + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -1702,7 +1702,7 @@ public abstract class GLContext { * Returns true if it is possible to create an framebuffer object (FBO). ** FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *
+ * ** FBO support is queried as described in {@link #hasBasicFBOSupport()}. *
@@ -1714,16 +1714,16 @@ public abstract class GLContext { public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); } - + /** - * @return1
if using a hardware rasterizer,0
if using a software rasterizer and-1
if not determined yet. + * @return1
if using a hardware rasterizer,0
if using a software rasterizer and-1
if not determined yet. * @see GLContext#isHardwareRasterizer() - * @see GLProfile#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() */ public static final int isHardwareRasterizer(AbstractGraphicsDevice device, GLProfile glp) { final int r; final int ctp = getAvailableContextProperties(device, glp); - if(0 == ctp) { + if(0 == ctp) { r = -1; } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { r = 1; @@ -1732,7 +1732,7 @@ public abstract class GLContext { } return r; } - + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 @@ -1774,7 +1774,7 @@ public abstract class GLContext { int minor[] = { 0 }; int ctp[] = { 0 }; boolean ok; - + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp); if( !ok ) { ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp); @@ -1784,7 +1784,7 @@ public abstract class GLContext { } return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT ); } - + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } @@ -1859,6 +1859,6 @@ public abstract class GLContext { } protected static String getThreadName() { return Thread.currentThread().getName(); } - + } diff --git a/src/jogl/classes/javax/media/opengl/GLDebugListener.java b/src/jogl/classes/javax/media/opengl/GLDebugListener.java index 8887d022a..ec7f7cec1 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugListener.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugListener.java @@ -29,16 +29,16 @@ package javax.media.opengl; /** * Listener for {@link GLDebugMessage}s. - * + * *One can enable GLDebugOutput via {@link GLContext#enableGLDebugMessage(boolean)} * and add listeners via {@link GLContext#addGLDebugListener(GLDebugListener)}. */ public interface GLDebugListener { - /** + /** * Handle {@link GLDebugMessage} message sent from native GL implementation. - * + * *
Since this method is invoked directly by the GL implementation, it shall * return as fast as possible.
*/ - void messageSent(GLDebugMessage event); + void messageSent(GLDebugMessage event); } diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java index 4b8d62898..1032cf929 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -30,18 +30,18 @@ package javax.media.opengl; import com.jogamp.common.os.Platform; /** - * OpenGL debug message generated by the driver + * OpenGL debug message generated by the driver * and delivered via {@link GLDebugListener}. */ public class GLDebugMessage { final GLContext source; - final long when; + final long when; final int dbgSource; final int dbgType; final int dbgId; final int dbgSeverity; final String dbgMsg; - + /** * @param source The source of the event * @param when The time of the event @@ -60,9 +60,9 @@ public class GLDebugMessage { this.dbgSeverity = dbgSeverity; this.dbgMsg = dbgMsg; } - + /** - * + * * @param source * @param when * @param dbgId @@ -73,88 +73,88 @@ public class GLDebugMessage { */ public static GLDebugMessage translateAMDEvent(GLContext source, long when, int dbgId, int amdDbgCategory, int dbgSeverity, String dbgMsg) { int dbgSource, dbgType; - + // AMD category == ARB source/type switch(amdDbgCategory) { - case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: + case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_API; - dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; + dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; break; // // def source / other type // - - case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: + + case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - + case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - + case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION; dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - - + + // // other source / def type // - + case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; + dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; break; - + case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; + dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; break; - + case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; + dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; break; - - case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: + + case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: default: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; } - - return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); + + return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); } public static int translateARB2AMDCategory(int dbgSource, int dbgType) { switch (dbgSource) { case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: - return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; - + return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD; - + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD; } - + switch(dbgType) { case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD; - + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD; - - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: + + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD; } - - return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD; + + return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD; } - + public GLContext getSource() { return source; } @@ -162,7 +162,7 @@ public class GLDebugMessage { public long getWhen() { return when; } - + public int getDbgSource() { return dbgSource; } @@ -182,14 +182,14 @@ public class GLDebugMessage { public String getDbgMsg() { return dbgMsg; } - + public StringBuilder toString(StringBuilder sb) { - final String crtab = Platform.getNewline()+"\t"; + final String crtab = Platform.getNewline()+"\t"; if(null==sb) { sb = new StringBuilder(); - } + } sb.append("GLDebugEvent[ id "); - toHexString(sb, dbgId) + toHexString(sb, dbgId) .append(crtab).append("type ").append(getDbgTypeString(dbgType)) .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity)) .append(crtab).append("source ").append(getDbgSourceString(dbgSource)) @@ -199,46 +199,46 @@ public class GLDebugMessage { sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode())); } sb.append("]"); - return sb; + return sb; } public String toString() { return toString(null).toString(); } - + public static String getDbgSourceString(int dbgSource) { switch(dbgSource) { case GL2GL3.GL_DEBUG_SOURCE_API: return "GL API"; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party"; case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return "Application"; case GL2GL3.GL_DEBUG_SOURCE_OTHER: return "generic"; default: return "Unknown (" + toHexString(dbgSource) + ")"; } } - + public static String getDbgTypeString(int dbgType) { switch(dbgType) { case GL2GL3.GL_DEBUG_TYPE_ERROR: return "Error"; - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior"; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; - case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; - case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; + case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; + case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; default: return "Unknown (" + toHexString(dbgType) + ")"; } } - + public static String getDbgSeverityString(int dbgSeverity) { switch(dbgSeverity) { - case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; - case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; - case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; + case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; + case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; + case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; default: return "Unknown (" + toHexString(dbgSeverity) + ")"; } } - + public static StringBuilder toHexString(StringBuilder sb, int i) { if(null==sb) { sb = new StringBuilder(); @@ -247,6 +247,6 @@ public class GLDebugMessage { } public static String toHexString(int i) { return "0x"+Integer.toHexString(i); - } - + } + } diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index 46fa923ad..5a032db29 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -73,13 +73,13 @@ public interface GLDrawable { * ** End users do not need to call this method; it is not necessary to - * call
*setRealized
on a {@link GLAutoDrawable} + * callsetRealized
on a {@link GLAutoDrawable} * as these perform the appropriate calls on their underlying GLDrawables internally. ** Developers implementing new OpenGL components for various window * toolkits need to call this method against GLDrawables obtained - * from the GLDrawableFactory via the + * from the GLDrawableFactory via the * {@link GLDrawableFactory#createGLDrawable(NativeSurface)} method. * It must typically be * called with an argument of
- *true
when the component @@ -89,7 +89,7 @@ public interface GLDrawable { * theaddNotify
method and with an argument of *false
in theremoveNotify
method. *+ *
*
- *GLDrawable
implementations should handle multiple * cycles ofsetRealized(true)
/ *setRealized(false)
calls. Most, if not all, Java @@ -104,7 +104,7 @@ public interface GLDrawable { * associated resources as the component becomes realized and * unrealized, respectively. *+ *
* With an argument of
- *true
, * the minimum implementation shall call * {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} and if successful: @@ -117,7 +117,7 @@ public interface GLDrawable { * ensures resolving the window/surface handles, and the drawable's {@link GLCapabilities} * might have changed. *+ *
* Calling this method has no other effects. For example, if *
removeNotify
is called on a Canvas implementation * for which a GLDrawable has been created, it is also necessary to @@ -130,7 +130,7 @@ public interface GLDrawable { */ public void setRealized(boolean realized); - /** + /** * Returnstrue
if this drawable is realized, otherwisetrue
. ** A drawable can be realized and unrealized via {@link #setRealized(boolean)}. @@ -146,19 +146,19 @@ public interface GLDrawable { public int getHeight(); /** - * Returns
true
if the drawable is rendered in + * Returnstrue
if the drawable is rendered in * OpenGL's coordinate system, origin at bottom left. * Otherwise returnsfalse
, i.e. origin at top left. ** Default impl. is
+ * *true
, i.e. OpenGL coordinate system. - ** Currently only MS-Windows bitmap offscreen drawable uses a non OpenGL orientation and hence returns
*/ public boolean isGLOriented(); - + /** Swaps the front and back buffers of this drawable. For {@link GLAutoDrawable} implementations, when automatic buffer swapping is enabled (as is the default), this method is called @@ -191,11 +191,11 @@ public interface GLDrawable { public NativeSurface getNativeSurface(); /** - * Returns the GL drawable handle, + * Returns the GL drawable handle, * guaranteed to be valid after {@link #setRealized(boolean) realization} * and while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}. *false
.
* This removes the need of a vertical flip when used in AWT or Windows applications. *- * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s + * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s * {@link javax.media.nativewindow.NativeSurface#getSurfaceHandle() handle} * or an intermediate layer to suite GL, e.g. an EGL surface. *
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 7c3c42e45..e486e2bfd 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -83,7 +83,7 @@ import jogamp.opengl.Debug; during the first repaint of the {@link javax.media.opengl.awt.GLCanvas} or {@link javax.media.opengl.awt.GLJPanel} if the capabilities can not be met.
{@link javax.media.opengl.GLPbuffer} are always - created immediately and their creation will fail with a + created immediately and their creation will fail with a {@link javax.media.opengl.GLException} if errors occur.The concrete GLDrawableFactory subclass instantiated by {@link @@ -94,21 +94,21 @@ import jogamp.opengl.Debug; public abstract class GLDrawableFactory { protected static final boolean DEBUG = Debug.debug("GLDrawable"); - - /** - * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. + + /** + * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. * When run in the mentioned browsers, the eglInitialize(..) implementation crashes. *
* This can be overridden by explicitly enabling ANGLE on Windows by setting the property *
+ * */ protected static final boolean enableANGLE = Debug.isPropertyDefined("jogl.enable.ANGLE", true); - /** + /** * In case no OpenGL ES implementation is required * and if the running platform may have a buggy implementation, - * setting the propertyjogl.enable.ANGLE
. - *jogl.disable.opengles
disables querying a possible existing OpenGL ES implementation. + * setting the propertyjogl.disable.opengles
disables querying a possible existing OpenGL ES implementation. */ protected static final boolean disableOpenGLES = Debug.isPropertyDefined("jogl.disable.opengles", true); @@ -117,11 +117,11 @@ public abstract class GLDrawableFactory { private static GLDrawableFactory nativeOSFactory; private static ArrayListglDrawableFactories = new ArrayList (); - + /** * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones. */ - public static final void initSingleton() { + public static final void initSingleton() { if (!isInit) { // volatile: ok synchronized (GLDrawableFactory.class) { if (!isInit) { @@ -130,7 +130,7 @@ public abstract class GLDrawableFactory { } } } - } + } private static final void initSingletonImpl() { NativeWindowFactory.initSingleton(); NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() { @@ -138,7 +138,7 @@ public abstract class GLDrawableFactory { shutdown0(); } }); - + final String nwt = NativeWindowFactory.getNativeWindowType(true); GLDrawableFactory tmp = null; String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true); @@ -163,7 +163,7 @@ public abstract class GLDrawableFactory { } try { tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl); - } catch (Exception jre) { + } catch (Exception jre) { if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nwt+" - not available: "+factoryClassName); jre.printStackTrace(); @@ -202,7 +202,7 @@ public abstract class GLDrawableFactory { } } } - + private static void shutdown0() { // Following code will _always_ remain in shutdown hook // due to special semantics of native utils, i.e. X11Utils. @@ -228,22 +228,22 @@ public abstract class GLDrawableFactory { } } glDrawableFactories.clear(); - - // both were members of glDrawableFactories and are shutdown already + + // both were members of glDrawableFactories and are shutdown already nativeOSFactory = null; eglFactory = null; } GLContext.shutdown(); } - + protected GLDrawableFactory() { synchronized(glDrawableFactories) { glDrawableFactories.add(this); } } - + protected static String getThreadName() { return Thread.currentThread().getName(); } - + /** Returns true if this factory is complete, i.e. ready to be used. Otherwise return false. */ protected abstract boolean isComplete(); @@ -253,14 +253,14 @@ public abstract class GLDrawableFactory { protected abstract void destroy(); public abstract void resetDisplayGamma(); - + /** * Retrieve the default device
{@link AbstractGraphicsDevice#getConnection() connection}, * {@link AbstractGraphicsDevice#getUnitID() unit ID} and {@link AbstractGraphicsDevice#getUniqueID() unique ID name}. for this factory
* The implementation must return a nonnull
default device, which must not be opened, ie. it's native handle isnull
. ** This method shall return the default device if available - * even if the GLDrawableFactory is not functional and hence not compatible. + * even if the GLDrawableFactory is not functional and hence not compatible. * The latter situation may happen because no native OpenGL implementation is available for the specific implementation. *
* @return the default shared device for this factory, eg. :0.0 on X11 desktop. @@ -272,7 +272,7 @@ public abstract class GLDrawableFactory { * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may benull
for the platform's default device. * @return true if the device is compatible with this factory, ie. if it can be used for GLDrawable creation. Otherwise false. * This implies validation whether the implementation is functional. - * + * * @see #getDefaultDevice() */ public abstract boolean getIsDeviceCompatible(AbstractGraphicsDevice device); @@ -287,8 +287,8 @@ public abstract class GLDrawableFactory { System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: using default device : "+device); } } - - // Always validate the device, + + // Always validate the device, // since even the default device may not be used by this factory. if( !getIsDeviceCompatible(device) ) { if (GLProfile.DEBUG) { @@ -300,29 +300,29 @@ public abstract class GLDrawableFactory { } /** - * Validate and start the shared resource runner thread if necessary and + * Validate and start the shared resource runner thread if necessary and * if the implementation uses it. - * + * * @return the shared resource runner thread, if implementation uses it. */ protected abstract Thread getSharedResourceThread(); - + /** * Create the shared resource used internally as a reference for capabilities etc. *- * Returns true if a shared resource could be created + * Returns true if a shared resource could be created * for the
* * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may bedevice
{@link AbstractGraphicsDevice#getConnection()}.
* This does not imply a shared resource is mapped (ie. made persistent), but is available in general
. *null
for the platform's default device. - * @return true if a shared resource could been created, otherwise false. + * @return true if a shared resource could been created, otherwise false. */ protected final boolean createSharedResource(AbstractGraphicsDevice device) { return createSharedResourceImpl(device); - } + } protected abstract boolean createSharedResourceImpl(AbstractGraphicsDevice device); - + /** * Returns true if thequirk
exist in the shared resource's context {@link GLRendererQuirks}. *@@ -332,7 +332,7 @@ public abstract class GLDrawableFactory { return null != glrq ? glrq.exist(quirk) : false; *
null
for the platform's default device.
* @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
* @throws IllegalArgumentException if the quirk is out of range
@@ -343,7 +343,7 @@ public abstract class GLDrawableFactory {
final GLRendererQuirks glrq = getRendererQuirks(device);
return null != glrq ? glrq.exist(quirk) : false;
}
-
+
/**
* Returns the shared resource's context {@link GLRendererQuirks}.
* @@ -358,12 +358,12 @@ public abstract class GLDrawableFactory { * @see GLRendererQuirks */ public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device); - + /** * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null */ public static GLDrawableFactory getDesktopFactory() { - GLProfile.initSingleton(); + GLProfile.initSingleton(); return nativeOSFactory; } @@ -371,14 +371,14 @@ public abstract class GLDrawableFactory { * Returns the sole GLDrawableFactory instance for EGL if exist or null */ public static GLDrawableFactory getEGLFactory() { - GLProfile.initSingleton(); + GLProfile.initSingleton(); return eglFactory; } - /** - * Returns the sole GLDrawableFactory instance. - * - * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory, + /** + * Returns the sole GLDrawableFactory instance. + * + * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory, * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL. */ public static GLDrawableFactory getFactory(GLProfile glProfile) throws GLException { @@ -387,7 +387,7 @@ public abstract class GLDrawableFactory { protected static GLDrawableFactory getFactoryImpl(String glProfileImplName) throws GLException { if ( GLProfile.usesNativeGLES(glProfileImplName) ) { - if(null!=eglFactory) { + if(null!=eglFactory) { return eglFactory; } } else if(null!=nativeOSFactory) { @@ -446,10 +446,10 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *
*- * If not onscreen and neither FBO nor Pbuffer is available, + * If not onscreen and neither FBO nor Pbuffer is available, * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. *
- * + * * @throws IllegalArgumentException if the passed target is null * @throws GLException if any window system-specific errors caused * the creation of the GLDrawable to fail. @@ -463,12 +463,12 @@ public abstract class GLDrawableFactory { */ public abstract GLDrawable createGLDrawable(NativeSurface target) throws IllegalArgumentException, GLException; - + /** - * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} + * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *- * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} * and it's {@link GLContext} assigned but not yet made current. *
*@@ -485,7 +485,7 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *
*- * If neither FBO nor Pbuffer is available, + * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *
* @@ -498,7 +498,7 @@ public abstract class GLDrawableFactory { * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. - * + * * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) */ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, @@ -507,7 +507,7 @@ public abstract class GLDrawableFactory { int width, int height, GLContext shareWith) throws GLException; /** - * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} + * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. ** In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. @@ -523,7 +523,7 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *
*- * If neither FBO nor Pbuffer is available, + * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated. *
* @@ -537,7 +537,7 @@ public abstract class GLDrawableFactory { * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. - * + * * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) */ public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device, @@ -546,7 +546,7 @@ public abstract class GLDrawableFactory { int width, int height) throws GLException; /** - * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}. + * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}. * A dummy drawable is not visible on screen and will not be used to render directly to, it maybe on- or offscreen. ** It is used to allow the creation of a {@link GLContext} to query information. @@ -558,26 +558,26 @@ public abstract class GLDrawableFactory { * @return the created dummy {@link GLDrawable} */ public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp); - + /** - * Creates a proxy {@link NativeSurface} w/ defined surface handle, - * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance. + * Creates a proxy {@link NativeSurface} w/ defined surface handle, + * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance. *
- * It's {@link AbstractGraphicsConfiguration} is properly set according to the given
+ * It's {@link AbstractGraphicsConfiguration} is properly set according to the given
* windowHandle
's native visualID if set or the given {@link GLCapabilitiesImmutable}.
*
* Lifecycle (creation and destruction) of the given surface handle shall be handled by the caller - * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}. + * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}. *
** Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate} - * you will be able to implement a new native windowing system binding almost on-the-fly, - * see {@link com.jogamp.opengl.swt.GLCanvas}. + * you will be able to implement a new native windowing system binding almost on-the-fly, + * see {@link com.jogamp.opengl.swt.GLCanvas}. *
- * + * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may benull
for the platform's default device.
- * Caller has to ensure it is compatible w/ the given windowHandle
+ * Caller has to ensure it is compatible w/ the given windowHandle
* @param screenIdx matching screen index of given windowHandle
* @param windowHandle the native window handle
* @param caps the requested GLCapabilties
@@ -586,15 +586,15 @@ public abstract class GLDrawableFactory {
* @return the created {@link ProxySurface} instance w/ defined surface handle.
*/
public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device,
- int screenIdx,
- long windowHandle,
+ int screenIdx,
+ long windowHandle,
GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream);
-
+
/**
* Returns true if it is possible to create an framebuffer object (FBO).
* * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *
+ * ** FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}. *
@@ -607,9 +607,9 @@ public abstract class GLDrawableFactory { /** * Returns true if it is possible to create an pbuffer surface. - *- * Some older graphics cards do not have this capability, - * as well as some new GL implementation, i.e. OpenGL 3 core on OSX. + *
+ * Some older graphics cards do not have this capability, + * as well as some new GL implementation, i.e. OpenGL 3 core on OSX. *
* * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may benull
for the platform's default device.
@@ -637,7 +637,7 @@ public abstract class GLDrawableFactory {
*
* @throws GLException if any window system-specific errors caused
* the creation of the GLPbuffer to fail.
- *
+ *
* @deprecated {@link GLPbuffer} is deprecated, use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)}
*/
public abstract GLPbuffer createGLPbuffer(AbstractGraphicsDevice device,
@@ -648,7 +648,7 @@ public abstract class GLDrawableFactory {
GLContext shareWith)
throws GLException;
-
+
//----------------------------------------------------------------------
// Methods for interacting with third-party OpenGL libraries
diff --git a/src/jogl/classes/javax/media/opengl/GLEventListener.java b/src/jogl/classes/javax/media/opengl/GLEventListener.java
index 15fae4a39..c8c3440b5 100644
--- a/src/jogl/classes/javax/media/opengl/GLEventListener.java
+++ b/src/jogl/classes/javax/media/opengl/GLEventListener.java
@@ -1,21 +1,21 @@
/*
* 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
@@ -28,11 +28,11 @@
* 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.
*/
@@ -49,7 +49,7 @@ import java.util.EventListener;
public interface GLEventListener extends EventListener {
/** Called by the drawable immediately after the OpenGL context is
initialized. Can be used to perform one-time OpenGL
- initialization per GLContext, such as setup of lights and display lists.+ initialization per GLContext, such as setup of lights and display lists.
Note that this method may be called more than once if the underlying OpenGL context for the GLAutoDrawable is destroyed and @@ -57,7 +57,7 @@ public interface GLEventListener extends EventListener { hierarchy and later added again. */ public void init(GLAutoDrawable drawable); - + /** Notifies the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL programs.
@@ -68,11 +68,11 @@ public interface GLEventListener extends EventListener { Note that this event does not imply the end of life of the application. It could be produced with a followup call to {@link #init(GLAutoDrawable)} - in case the GLContext has been recreated, + in case the GLContext has been recreated, e.g. due to a pixel configuration change in a multihead environment. */ public void dispose(GLAutoDrawable drawable); - + /** Called by the drawable to initiate OpenGL rendering by the client. After all GLEventListeners have been notified of a display event, the drawable will swap its buffers if {@link diff --git a/src/jogl/classes/javax/media/opengl/GLException.java b/src/jogl/classes/javax/media/opengl/GLException.java index 644042e15..460f17be9 100644 --- a/src/jogl/classes/javax/media/opengl/GLException.java +++ b/src/jogl/classes/javax/media/opengl/GLException.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * 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. */ diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java index df38745d5..052b08a4b 100644 --- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -33,17 +33,17 @@ import javax.media.nativewindow.NativeWindowException; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.TextureAttachment; -/** +/** * Platform-independent {@link GLDrawable} specialization, * exposing {@link FBObject} functionality. * *
- * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound + * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound * and made current the first time, hence only then it's capabilities fully reflect expectations, * i.e. color, depth, stencil and MSAA bits will be valid only after the first {@link GLContext#makeCurrent() makeCurrent()} call. * On-/offscreen bits are valid after {@link #setRealized(boolean) setRealized(true)}. *
- * + * ** MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}. *
@@ -51,7 +51,7 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}. * *- * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. + * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. * Hence double buffering is always the case w/ MSAA. *
*@@ -61,7 +61,7 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * This method also allows usage of both textures seperately. *
*- * It would be possible to implement double buffering simply using + * It would be possible to implement double buffering simply using * {@link TextureAttachment}s with one {@link FBObject framebuffer}. * This would require mode selection and hence complicate the API. Besides, it would * not support differentiation of read and write framebuffer and hence not be spec compliant. @@ -71,50 +71,50 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * is performed either in the {@link jogamp.opengl.GLContextImpl#contextMadeCurrent(boolean) context current hook} * or when {@link jogamp.opengl.GLDrawableImpl#swapBuffersImpl(boolean) swapping buffers}, whatever comes first. *
- */ + */ public interface GLFBODrawable extends GLDrawable { // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - + /** * @returntrue
if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false
.
*/
public boolean isInitialized();
-
+
/**
* Notify this instance about upstream size change
* to reconfigure the {@link FBObject}.
- * @param gl GL context object bound to this drawable, will be made current during operation.
- * A prev. current context will be make current after operation.
+ * @param gl GL context object bound to this drawable, will be made current during operation.
+ * A prev. current context will be make current after operation.
* @throws GLException if resize operation failed
*/
void resetSize(GL gl) throws GLException;
-
+
/**
* @return the used texture unit
*/
int getTextureUnit();
-
+
/**
- *
+ *
* @param unit the texture unit to be used
*/
void setTextureUnit(int unit);
-
+
/**
* Set the number of sample buffers if using MSAA
- *
- * @param gl GL context object bound to this drawable, will be made current during operation.
- * A prev. current context will be make current after operation.
+ *
+ * @param gl GL context object bound to this drawable, will be made current during operation.
+ * A prev. current context will be make current after operation.
* @param newSamples new sample size
* @throws GLException if resetting the FBO failed
*/
void setNumSamples(GL gl, int newSamples) throws GLException;
-
+
/**
* @return the number of sample buffers if using MSAA, otherwise 0
*/
int getNumSamples();
-
+
/**
* Sets the number of buffers (FBO) being used if using {@link GLCapabilities#getDoubleBuffered() double buffering}.
* @@ -123,22 +123,22 @@ public interface GLFBODrawable extends GLDrawable { *
* Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown. *
- * @return the new number of buffers (FBO) used, maybe different than the requestedbufferCount
(see above)
+ * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount
(see above)
* @throws GLException if already initialized, see {@link #isInitialized()}.
*/
int setNumBuffers(int bufferCount) throws GLException;
-
- /**
+
+ /**
* @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering},
- * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}.
+ * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}.
*/
int getNumBuffers();
-
+
/**
- * @return the used {@link DoubleBufferMode}
+ * @return the used {@link DoubleBufferMode}
*/
// DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
-
+
/**
* Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization},
* otherwise an exception is thrown.
@@ -153,11 +153,11 @@ public interface GLFBODrawable extends GLDrawable {
* @throws GLException if already initialized, see {@link #isInitialized()}.
*/
// void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
-
+
/**
* If MSAA is being used and {@link GL#GL_FRONT} is requested,
- * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned.
- *
+ * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned.
+ *
* @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
* @return the named {@link FBObject}
* @throws IllegalArgumentException if an illegal buffer name is being used
@@ -167,7 +167,7 @@ public interface GLFBODrawable extends GLDrawable {
/**
* Returns the named texture buffer.
* - * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible + * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible * and an exception is being thrown if {@link GL#GL_BACK} is being requested. *
* @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names @@ -176,20 +176,20 @@ public interface GLFBODrawable extends GLDrawable { */ FBObject.TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException; - /** Resizeable {@link GLFBODrawable} specialization */ + /** Resizeable {@link GLFBODrawable} specialization */ public interface Resizeable extends GLFBODrawable { /** * Resize this drawable. ** This drawable is being locked during operation. *
- * @param context the {@link GLContext} bound to this drawable, will be made current during operation - * A prev. current context will be make current after operation. + * @param context the {@link GLContext} bound to this drawable, will be made current during operation + * A prev. current context will be make current after operation. * @param newWidth * @param newHeight * @throws NativeWindowException in case the surface could no be locked * @throws GLException in case an error during the resize operation occurred */ - void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; + void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; } } diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java index 6fe76a3f4..be90d935f 100644 --- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR @@ -20,7 +20,7 @@ * 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. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -32,7 +32,7 @@ import javax.media.nativewindow.NativeWindowException; import com.jogamp.opengl.FBObject; -/** +/** * Platform-independent {@link GLAutoDrawable} specialization, * exposing offscreen functionality. *@@ -41,7 +41,7 @@ import com.jogamp.opengl.FBObject; *
*/ public interface GLOffscreenAutoDrawable extends GLAutoDrawable { - + /** * Resize this auto drawable. * @param newWidth @@ -56,8 +56,8 @@ public interface GLOffscreenAutoDrawable extends GLAutoDrawable { * @see #getUpstreamWidget() */ void setUpstreamWidget(Object newUpstreamWidget); - - /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ - public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { - } + + /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ + public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { + } } diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java index 12f57fcd8..f36a4bf29 100644 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ b/src/jogl/classes/javax/media/opengl/GLPbuffer.java @@ -46,8 +46,8 @@ package javax.media.opengl; as a texture map and enabling rendering to floating-point frame buffers. These methods are not guaranteed to be supported on all platforms and may be deprecated in a future release. - - @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} + + @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} via {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) GLDrawableFactory.createOffscreenAutoDrawable(..)}. */ public interface GLPbuffer extends GLAutoDrawable { diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java index c6bf26235..d947bada2 100644 --- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,7 +28,7 @@ * 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. @@ -49,7 +49,7 @@ import jogamp.opengl.*; public class GLPipelineFactory { public static final boolean DEBUG = Debug.debug("GLPipelineFactory"); - /** + /** * Creates a pipelined GL instance using the given downstreamdownstream
* and optional arguments additionalArgs
for the constructor.
*
@@ -66,7 +66,7 @@ public class GLPipelineFactory {
* gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) );
*
*
- *
+ *
* * The upstream GL instance is determined as follows: *
downstream
class and superclass interfaces, do:reqInterface
is not null and the interface is unequal, continue loop.downstream
is not instance of interface, continue loop.downstream
is not instance of interface, continue loop.* This method shall not need to be called for other reasons than having a defined initialization sequence. *
- * + * ** In case this method is not invoked, GLProfile is initialized implicit by * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}. *
- * + * *
- * To initialize JOGL at startup ASAP, this method may be invoked in the main class's + * To initialize JOGL at startup ASAP, this method may be invoked in the main class's * static initializer block, in the static main() method or in the Applet init() method. *
- * + * ** Since JOGL's initialization is complex and involves multi threading, it is not recommended - * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed + * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed * on the AWT EDT, invoke this method outside the AWT EDT - see above. *
- * + * */ public static void initSingleton() { - final boolean justInitialized; + final boolean justInitialized; initLock.lock(); try { if(!initialized) { // volatile: ok @@ -117,13 +117,13 @@ public class GLProfile { System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName()); Thread.dumpStack(); } - + // run the whole static initialization privileged to speed up, // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction