aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-16 03:35:06 +0200
committerSven Gothel <[email protected]>2013-08-16 03:35:06 +0200
commit65833bbcec423f9741116dc9b785e6954f2fcec7 (patch)
tree4dc1d1b803389c8db61b4ef67e66b621e7971fe5 /src
parentbab13046729d8283876e4d2f8855a38ff311d375 (diff)
Fix Bug 817 (1/2): GLPixelAttributes checks arguments and queried bytesPerPixel
GLPixelAttributes checks arguments (componentCount, format / type) and the queried bytesPerPixel.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
index 2bd45e3e4..e9853cc31 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.util.texture.TextureData;
@@ -128,7 +129,7 @@ public class GLPixelBuffer {
/** Pixel attributes. */
public static class GLPixelAttributes {
/** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */
- public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0);
+ public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0, false);
/** Pixel <i>source</i> component count, i.e. number of meaningful components. */
public final int componentCount;
@@ -154,10 +155,21 @@ public class GLPixelBuffer {
* @param dataType GL data type
*/
public GLPixelAttributes(int componentCount, int dataFormat, int dataType) {
+ this(componentCount, dataFormat, dataType, true);
+ }
+ private GLPixelAttributes(int componentCount, int dataFormat, int dataType, boolean checkArgs) {
this.componentCount = componentCount;
this.format = dataFormat;
this.type = dataType;
this.bytesPerPixel = ( 0 < dataFormat && 0 < dataType ) ? GLBuffers.bytesPerPixel(dataFormat, dataType) : 0;
+ if( checkArgs ) {
+ if( 0 == componentCount || 0 == format || 0 == type ) {
+ throw new GLException("Zero components, format and/or type: "+this);
+ }
+ if( 0 == bytesPerPixel ) {
+ throw new GLException("Zero bytesPerPixel: "+this);
+ }
+ }
}
public String toString() {
return "PixelAttributes[comp "+componentCount+", fmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+", bytesPerPixel "+bytesPerPixel+"]";