aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-09-09 20:02:45 +0200
committerSven Gothel <[email protected]>2014-09-09 20:02:45 +0200
commitd19bb03e3cabc9a50b63c4ce8d866efab7f34860 (patch)
tree1e4f43c69c2951afe6585fcfa63ebe1706327b9b /src/jogl
parent73a4d809f92126228b64a3bded75686db806be64 (diff)
GLPixelStorageModes: Emphasize reset*() usage; setUnpackRowLength: GL2ES2 -> GL2ES3; Better adoption of GLPixelStorageModes (GLJPanel, GLReadBufferUtil, TextureIO)
- Emphasize reset*() is being called when saving modes for 1st modification; - setUnpackRowLength: GL2ES2 -> GL2ES3; Actually GL2ES3 is required for UNPACK_ROW_LENGTH - Better adoption of GLPixelStorageModes (GLJPanel, GLReadBufferUtil, TextureIO)
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java17
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java27
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java4
4 files changed, 16 insertions, 34 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
index cef49d388..290033e99 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
@@ -33,6 +33,7 @@ import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
/**
@@ -60,7 +61,7 @@ public class GLPixelStorageModes {
/**
* Sets the {@link GL#GL_PACK_ALIGNMENT}.
* <p>
- * Saves the PACK pixel storage modes if not saved yet, see {@link #savePack(GL)}.
+ * Saves the PACK pixel storage modes and {@link #resetPack(GL) resets} them if not saved yet, see {@link #savePack(GL)}.
* </p>
*/
public final void setPackAlignment(final GL gl, final int packAlignment) {
@@ -71,7 +72,7 @@ public class GLPixelStorageModes {
/**
* Sets the {@link GL#GL_UNPACK_ALIGNMENT}.
* <p>
- * Saves the UNPACK pixel storage modes if not saved yet, see {@link #saveUnpack(GL)}.
+ * Saves the UNPACK pixel storage modes and {@link #resetUnpack(GL) resets} them if not saved yet, see {@link #saveUnpack(GL)}.
* </p>
*/
public final void setUnpackAlignment(final GL gl, final int unpackAlignment) {
@@ -82,7 +83,7 @@ public class GLPixelStorageModes {
/**
* Sets the {@link GL#GL_PACK_ALIGNMENT} and {@link GL#GL_UNPACK_ALIGNMENT}.
* <p>
- * Saves the PACK and UNPACK pixel storage modes if not saved yet, see {@link #saveAll(GL)}.
+ * Saves the PACK and UNPACK pixel storage modes and resets them if not saved yet, see {@link #saveAll(GL)}.
* </p>
*/
public final void setAlignment(final GL gl, final int packAlignment, final int unpackAlignment) {
@@ -93,7 +94,7 @@ public class GLPixelStorageModes {
/**
* Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH}.
* <p>
- * Saves the PACK pixel storage modes if not saved yet, see {@link #savePack(GL)}.
+ * Saves the PACK pixel storage modes and {@link #resetPack(GL) resets} them if not saved yet, see {@link #savePack(GL)}.
* </p>
*/
public final void setPackRowLength(final GL2ES3 gl, final int packRowLength) {
@@ -104,18 +105,18 @@ public class GLPixelStorageModes {
/**
* Sets the {@link GL2ES2#GL_UNPACK_ROW_LENGTH}.
* <p>
- * Saves the UNPACK pixel storage modes if not saved yet, see {@link #saveUnpack(GL)}.
+ * Saves the UNPACK pixel storage modes and {@link #resetUnpack(GL) resets} them if not saved yet, see {@link #saveUnpack(GL)}.
* </p>
*/
- public final void setUnpackRowLength(final GL2ES2 gl, final int unpackRowLength) {
+ public final void setUnpackRowLength(final GL2ES3 gl, final int unpackRowLength) {
saveUnpack(gl);
gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, unpackRowLength);
}
/**
- * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH} and {@link GL2ES2#GL_UNPACK_ROW_LENGTH}.
+ * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH} and {@link GL2ES2#GL_UNPACK_ROW_LENGTH} if {@link GL#isGL2ES3()}.
* <p>
- * Saves the PACK and UNPACK pixel storage modes if not saved yet, see {@link #saveAll(GL)}.
+ * Saves the PACK and UNPACK pixel storage modes and resets them if not saved yet, see {@link #saveAll(GL)}.
* </p>
*/
public final void setRowLength(final GL2ES3 gl, final int packRowLength, final int unpackRowLength) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java
index abdb7c5f9..e84a1d874 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java
@@ -223,7 +223,7 @@ public class GLReadBufferUtil {
psm.setPackAlignment(gl, alignment);
if(gl.isGL2ES3()) {
final GL2ES3 gl2es3 = gl.getGL2ES3();
- gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, width);
+ psm.setPackRowLength(gl2es3, width);
gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer());
}
readPixelBuffer.clear();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
index 1f5b2613e..6011afe7b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
@@ -60,7 +60,6 @@ import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.PixelFormat;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
-import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -69,6 +68,7 @@ import javax.media.opengl.GLProfile;
import jogamp.opengl.Debug;
import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.GLPixelStorageModes;
import com.jogamp.opengl.util.PNGPixelRect;
import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
import com.jogamp.opengl.util.texture.spi.DDSImage;
@@ -634,17 +634,8 @@ public class TextureIO {
}
// Fetch using glGetTexImage
- final int packAlignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT);
- final int packRowLength = glGetInteger(gl, GL2ES3.GL_PACK_ROW_LENGTH);
- final int packSkipRows = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_ROWS);
- final int packSkipPixels = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_PIXELS);
- final int packSwapBytes = glGetInteger(gl, GL2GL3.GL_PACK_SWAP_BYTES);
-
- gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
- gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0);
- gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0);
- gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_PIXELS, 0);
- gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, 0);
+ final GLPixelStorageModes psm = new GLPixelStorageModes();
+ psm.setPackAlignment(gl, 1);
final ByteBuffer res = ByteBuffer.allocate((width + (2 * border)) *
(height + (2 * border)) *
@@ -655,11 +646,7 @@ public class TextureIO {
}
gl.glGetTexImage(GL.GL_TEXTURE_2D, 0, fetchedFormat, GL.GL_UNSIGNED_BYTE, res);
- gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment);
- gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength);
- gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, packSkipRows);
- gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_PIXELS, packSkipPixels);
- gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, packSwapBytes);
+ psm.restore(gl);
data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE,
false, false, false, res, null);
@@ -1408,12 +1395,6 @@ public class TextureIO {
// Helper routines
//
- private static int glGetInteger(final GL gl, final int pname) {
- final int[] tmp = new int[1];
- gl.glGetIntegerv(pname, tmp, 0);
- return tmp[0];
- }
-
private static int glGetTexLevelParameteri(final GL2GL3 gl, final int target, final int level, final int pname) {
final int[] tmp = new int[1];
gl.glGetTexLevelParameteriv(target, 0, pname, tmp, 0);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index cfb11a2b0..78310c654 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -1880,9 +1880,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// Save PACK modes, reset them to defaults and set alignment
psm.setPackAlignment(gl, alignment);
- if(gl.isGL2ES3()) {
+ if( gl.isGL2ES3() ) {
final GL2ES3 gl2es3 = gl.getGL2ES3();
- gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, panelWidth);
+ psm.setPackRowLength(gl2es3, panelWidth);
gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer());
}