diff options
author | Carsten Weisse <[email protected]> | 2005-05-07 19:49:38 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-05-07 19:49:38 +0000 |
commit | 6f3e2d41bd7d2fdbddb3c7f3e859feb5ed9381d2 (patch) | |
tree | 4d94c0336fe94ff15f9da8d5efe1279e6c3b764f /src/jake2/render/lwjgl | |
parent | 79288e2165c844ff6435a868ea52a961f4aecbf7 (diff) |
better string handling and error messages
Diffstat (limited to 'src/jake2/render/lwjgl')
-rw-r--r-- | src/jake2/render/lwjgl/Misc.java | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/jake2/render/lwjgl/Misc.java b/src/jake2/render/lwjgl/Misc.java index 2d52345..c06cc6e 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.6 2005-05-06 23:22:04 cawe Exp $ + * $Id: Misc.java,v 1.7 2005-05-07 19:49:38 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -29,12 +29,13 @@ import jake2.Defines; import jake2.client.VID; import jake2.qcommon.FS; -import java.io.File; -import java.io.RandomAccessFile; +import java.io.*; 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.*; @@ -122,17 +123,19 @@ public abstract class Misc extends Mesh { GL_ScreenShot_f ================== */ - void GL_ScreenShot_f() - { - FS.CreatePath(FS.Gamedir() + "/scrshot/jake00.tga"); - File file = new File(FS.Gamedir() + "/scrshot/jake00.tga"); + void GL_ScreenShot_f() { + StringBuffer sb = new StringBuffer(FS.Gamedir() + "/scrshot/jake00.tga"); + FS.CreatePath(sb.toString()); + File file = new File(sb.toString()); // find a valid file name - int i = 0; + int i = 0; int offset = sb.length() - 6; while (file.exists() && i++ < 100) { - file = new File(FS.Gamedir() + "/scrshot/jake" + (i/10) + (i%10) + ".tga"); + sb.setCharAt(offset, (char) ((i/10) + '0')); + sb.setCharAt(offset + 1, (char) ((i%10) + '0')); + file = new File(sb.toString()); } if (i == 100) { - VID.Printf(Defines.PRINT_ALL, "Couldn't create a new screenshot file\n"); + VID.Printf(Defines.PRINT_ALL, "Clean up your screenshots\n"); return; } @@ -159,12 +162,12 @@ public abstract class Misc extends Mesh { // 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) { + if (gl_config.getOpenGLVersion() >= 1.2f) { + // read the BGR values into the image buffer + gl.glReadPixels(0, 0, vid.width, vid.height, GL12.GL_BGR, GL.GL_UNSIGNED_BYTE, image); + } else { + // read the RGB values into the image buffer + gl.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, GL.GL_UNSIGNED_BYTE, image); // flip RGB to BGR byte tmp; for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { @@ -175,9 +178,8 @@ public abstract class Misc extends Mesh { } // close the file channel ch.close(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (IOException e) { + VID.Printf(Defines.PRINT_ALL, e.getMessage() + '\n'); } VID.Printf(Defines.PRINT_ALL, "Wrote " + file + '\n'); |