From: Carsten W. <ca...@us...> - 2005-05-06 17:47:27
|
Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14038/src/jake2/render/fastjogl 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/fastjogl/Misc.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Misc.java 25 Apr 2005 09:23:14 -0000 1.4 --- Misc.java 6 May 2005 17:47:10 -0000 1.5 *************** *** 26,29 **** --- 26,34 ---- package jake2.render.fastjogl; + import jake2.Defines; + import jake2.client.VID; + import jake2.qcommon.FS; + import jake2.qcommon.xcommand_t; + import java.io.File; import java.io.RandomAccessFile; *************** *** 32,41 **** import java.nio.channels.FileChannel; - import org.lwjgl.opengl.GL11; - - import jake2.Defines; - import jake2.client.VID; - import jake2.qcommon.FS; - import jake2.qcommon.xcommand_t; import net.java.games.jogl.GL; import net.java.games.jogl.WGL; --- 37,40 ---- *************** *** 163,176 **** // jogl needs a sliced buffer ByteBuffer rgb = image.slice(); - // read the RGB values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, - GL11.GL_UNSIGNED_BYTE, 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 --- 162,182 ---- // jogl needs a sliced buffer ByteBuffer rgb = image.slice(); ! // 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') ? GL.GL_BGR : GL.GL_RGB; ! // read the BGR/RGB values into the image buffer ! gl.glReadPixels(0, 0, vid.width, vid.height, colorFormat, ! GL.GL_UNSIGNED_BYTE, rgb); ! ! if (colorFormat == GL.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 |