diff options
author | Carsten Weisse <[email protected]> | 2005-05-06 17:47:10 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-05-06 17:47:10 +0000 |
commit | 806a8b8022847f490663a489cd9bc7f5b6e71749 (patch) | |
tree | 8f960f8ba70d9f220ce9d23c150a8d51e138e5f6 /src/jake2/render/lwjgl/Misc.java | |
parent | 6d1f55ebb3f967cad054a8851ed9a6299e8b1866 (diff) |
use the GL_BGR (OpenGL1.2) format if possible;
then RGB to BGR flip loop isn't used. (faster)
Diffstat (limited to 'src/jake2/render/lwjgl/Misc.java')
-rw-r--r-- | src/jake2/render/lwjgl/Misc.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/jake2/render/lwjgl/Misc.java b/src/jake2/render/lwjgl/Misc.java index 704fd56..018f0f4 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.4 2005-04-25 09:24:09 cawe Exp $ + * $Id: Misc.java,v 1.5 2005-05-06 17:47:10 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -35,10 +35,10 @@ import java.nio.FloatBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import net.java.games.jogl.GL; + import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.EXTPointParameters; -import org.lwjgl.opengl.EXTSharedTexturePalette; -import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.*; /** * Misc @@ -158,16 +158,22 @@ public abstract class Misc extends Mesh { // go to image data position image.position(TGA_HEADER_SIZE); - // read the RGB values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, + // 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 + int colorFormat = (gl_config.version_string.charAt(2) > '1') ? GL12.GL_BGR : GL11.GL_RGB; + // read the BGR/RGB values into the image buffer + gl.glReadPixels(0, 0, vid.width, vid.height, colorFormat, GL11.GL_UNSIGNED_BYTE, image); - // flip RGB to BGR - byte tmp; - for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { - tmp = image.get(i); - image.put(i, image.get(i + 2)); - image.put(i + 2, tmp); + if (colorFormat == GL11.GL_RGB) { + // flip RGB to BGR + byte tmp; + for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { + tmp = image.get(i); + image.put(i, image.get(i + 2)); + image.put(i + 2, tmp); + } } // close the file channel ch.close(); |