aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-05-11 21:45:02 +0000
committerCarsten Weisse <[email protected]>2005-05-11 21:45:02 +0000
commit3b306d7e1b911c59908a62f4a30fa605a8dd3f06 (patch)
tree3344fb4da09314e9a5fff1eb4e2a9b059ac3c923
parentfaf6ce9bdbfc0ba8daa10933f6bc51fdee37c4d8 (diff)
the default pixel alignment in OpenGL is 4.
to store images correctly with an vid.width e.g 713 (713 isn't a multiple of 4) the alignment has to be 1 byte. see also: http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1115392413
-rw-r--r--src/jake2/render/fastjogl/Misc.java9
-rw-r--r--src/jake2/render/jogl/Misc.java9
-rw-r--r--src/jake2/render/lwjgl/Misc.java10
3 files changed, 25 insertions, 3 deletions
diff --git a/src/jake2/render/fastjogl/Misc.java b/src/jake2/render/fastjogl/Misc.java
index 00d6839..e0e78ee 100644
--- a/src/jake2/render/fastjogl/Misc.java
+++ b/src/jake2/render/fastjogl/Misc.java
@@ -2,7 +2,7 @@
* Misc.java
* Copyright (C) 2003
*
- * $Id: Misc.java,v 1.6 2005-05-07 19:49:37 cawe Exp $
+ * $Id: Misc.java,v 1.7 2005-05-11 21:44:55 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -163,6 +163,11 @@ public abstract class Misc extends Mesh {
image.position(TGA_HEADER_SIZE);
// jogl needs a sliced buffer
ByteBuffer rgb = image.slice();
+
+ // change pixel alignment for reading
+ if (vid.width % 4 != 0) {
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
+ }
// OpenGL 1.2+ supports the GL_BGR color format
// check the GL_VERSION to use the TARGA BGR order if possible
@@ -181,6 +186,8 @@ public abstract class Misc extends Mesh {
image.put(i + 2, tmp);
}
}
+ // reset to default alignment
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4);
// close the file channel
ch.close();
} catch (IOException e) {
diff --git a/src/jake2/render/jogl/Misc.java b/src/jake2/render/jogl/Misc.java
index 147eb10..5ea9a8b 100644
--- a/src/jake2/render/jogl/Misc.java
+++ b/src/jake2/render/jogl/Misc.java
@@ -2,7 +2,7 @@
* Misc.java
* Copyright (C) 2003
*
- * $Id: Misc.java,v 1.6 2005-05-07 19:49:37 cawe Exp $
+ * $Id: Misc.java,v 1.7 2005-05-11 21:44:49 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -176,6 +176,11 @@ public abstract class Misc extends Mesh {
// jogl needs a sliced buffer
ByteBuffer rgb = image.slice();
+ // change pixel alignment for reading
+ if (vid.width % 4 != 0) {
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
+ }
+
// OpenGL 1.2+ supports the GL_BGR color format
// check the GL_VERSION to use the TARGA BGR order if possible
// e.g.: 1.5.2 NVIDIA 66.29
@@ -193,6 +198,8 @@ public abstract class Misc extends Mesh {
image.put(i + 2, tmp);
}
}
+ // reset to default alignment
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4);
// close the file channel
ch.close();
} catch (IOException e) {
diff --git a/src/jake2/render/lwjgl/Misc.java b/src/jake2/render/lwjgl/Misc.java
index c06cc6e..bdce767 100644
--- a/src/jake2/render/lwjgl/Misc.java
+++ b/src/jake2/render/lwjgl/Misc.java
@@ -2,7 +2,7 @@
* Misc.java
* Copyright (C) 2003
*
- * $Id: Misc.java,v 1.7 2005-05-07 19:49:38 cawe Exp $
+ * $Id: Misc.java,v 1.8 2005-05-11 21:45:02 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -159,6 +159,12 @@ public abstract class Misc extends Mesh {
// go to image data position
image.position(TGA_HEADER_SIZE);
+
+ // change pixel alignment for reading
+ if (vid.width % 4 != 0) {
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
+ }
+
// OpenGL 1.2+ supports the GL_BGR color format
// check the GL_VERSION to use the TARGA BGR order if possible
// e.g.: 1.5.2 NVIDIA 66.29
@@ -176,6 +182,8 @@ public abstract class Misc extends Mesh {
image.put(i + 2, tmp);
}
}
+ // reset to default alignment
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4);
// close the file channel
ch.close();
} catch (IOException e) {