From: Carsten W. <ca...@us...> - 2005-05-06 17:47:23
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14038/src/jake2/render/lwjgl Modified Files: Misc.java Log Message: use the GL_BGR (OpenGL1.2) format if possible; then RGB to BGR flip loop isn't used. (faster) Index: Misc.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Misc.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Misc.java 25 Apr 2005 09:24:09 -0000 1.4 --- Misc.java 6 May 2005 17:47:10 -0000 1.5 *************** *** 36,43 **** import java.nio.channels.FileChannel; import org.lwjgl.BufferUtils; ! import org.lwjgl.opengl.EXTPointParameters; ! import org.lwjgl.opengl.EXTSharedTexturePalette; ! import org.lwjgl.opengl.GL11; /** --- 36,43 ---- import java.nio.channels.FileChannel; + import net.java.games.jogl.GL; + import org.lwjgl.BufferUtils; ! import org.lwjgl.opengl.*; /** *************** *** 159,172 **** image.position(TGA_HEADER_SIZE); ! // read the RGB values into the image buffer ! gl.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, 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); } // close the file channel --- 159,178 ---- image.position(TGA_HEADER_SIZE); ! // 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); ! 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 |