diff options
author | cvs2svn <[email protected]> | 2005-06-24 06:24:35 +0000 |
---|---|---|
committer | cvs2svn <[email protected]> | 2005-06-24 06:24:35 +0000 |
commit | 700acf9d7d091e8f3d82585862e08a5f95cfafac (patch) | |
tree | 9080c68ccfd4ac3c78b565f629835e00ca9435a3 | |
parent | bb599a231b9bdbc08aa6df9a5bce81ebcea840b1 (diff) | |
parent | 432c46b0e76b2a68d275b674311dbe27714f471b (diff) |
This commit was manufactured by cvs2svn to create branch 'hoz'.
38 files changed, 1505 insertions, 1700 deletions
@@ -1,4 +1,4 @@ -0.9.4 +0.9.4 2005-05-26 - multiplayer client and server functionality - Mac OS X support @@ -7,6 +7,8 @@ - standalone installer - online installation of Quake2 demo data files - mouse wheel support + - very fast screenshot function + - memory footprint reduced - bugfixes 0.9.3 2004-09-09 @@ -6,7 +6,7 @@ distributed under the terms of the GPL (see LICENSE). The port was done completely in Java. No native libraries are used for the game functionality. We use the jogl Java OpenGL bindings for graphics rendering -and Java OpenAL (joal) for sound. The latest release comes with an lwjgl driver +and Java OpenAL (joal) for sound. The 0.9.4 release comes with an lwjgl driver as an alternative for the jogl/joal combination. Jake2 is still under development. Send bug reports and feedback to @@ -23,10 +23,12 @@ Installation ------------ from binary distribution: -- run the installer with "java -jar Jake2-Install.jar" +- run the installer with "java -jar Jake2-0.9.4-install.jar" - follow the instructions - change to the installation directory - run the game with Jake2.sh or Jake2.bat +- to run Jake2 with the lwjgl OpenGL/OpenAL driver use Jake2_lwjgl.sh + or Jake2_lwjgl.bat build from source: - unpack jake2src-version.tar.gz or jake2-version.zip @@ -43,7 +45,7 @@ Jake2 sources from CVS. - "cvs -d:pserver:[email protected]:/cvsroot/jake2 login" - when askesd for password simply press the Enter key - "cvs -d:pserver:[email protected]:/cvsroot/jake2 co jake2" -- procced with the build from source instructions +- proceed with the build from source instructions 3rd party components -------------------- @@ -60,14 +62,16 @@ ant build tool http://ant.apache.org xerces XML library http://xml.apache.org proguard obfuscator http://proguard.sourceforge.net - +Use <[email protected]> for bug reports and feedback. have fun! bytonic Software - +---------------- Holger Zickner <[email protected]> Carsten Weisse <[email protected]> Rene Stoeckel <[email protected]> -Use <[email protected]> for bug reports and feedback.
\ No newline at end of file +Contributors +------------ +David Sanders lwjgl support @@ -8,8 +8,9 @@ lizensiert. Jake2 ist eine reine Java Anwendung. Als native Library kommen im Moment nur jogl f�r die OpenGL Anbindung und joal f�r OpenAudio Soundunterst�tzung zum -Einsatz. Die komplette Funktionalit�t der Engine wurde ausschliesslich mit Java -realisiert. +Einsatz. Seit Version 0.9.4 ist auch ein lwjgl Treiber als Alternative zur +jogl/joal Kombination enthalten. Die komplette Funktionalit�t der Engine wurde +ausschliesslich mit Java realisiert. Jake2 befindet sich noch im Entwicklungsstadium. Die Kontaktaddresse f�r Bugreports und R�ckmeldungen ist [email protected]. @@ -27,10 +28,12 @@ Installation ------------ ausgehend von der Bin�rdistribution: -- Installationsprogramm mit "java -jar Jake2-Install.jar" starten +- Installationsprogramm mit "java -jar Jake2-0.9.4-install.jar" starten - den Anweisungen folgen - ins Installationsverzeichnis wechseln - Jake2 mit "jake2.sh" oder "jake2.bat" aus dem Installationsverzeichnis starten +- um den lwjgl OpenGL/OpenAL Treiber zu nutzen Jake2 mit "jake2_lwjgl.sh" oder + "jake2_lwjgl.bat" aus dem Installationsverzeichnis starten ausgehend von Sourcedistribution: - jake2src-version.tar.gz oder jake2src-version.zip entpacken @@ -54,24 +57,27 @@ externe Komponenten ------------------- Jake2 benutzt: -jogl OpenGL bindings https://jogl.dev.java.net -joal OpenAL bindings https://joal.dev.java.net -openal Audio library http://www.openal.org -izpack Installer http://www.izforge.com/ +jogl OpenGL bindings https://jogl.dev.java.net +joal OpenAL bindings https://joal.dev.java.net +lwjgl Light Weight Java Game Library http://www.lwjgl.org +openal Audio library http://www.openal.org +izpack Installer http://www.izforge.com/ the source distribution comes with: -ant build tool http://ant.apache.org -xerces XML library http://xml.apache.org -proguard obfuscator http://proguard.sourceforge.net +ant build tool http://ant.apache.org +xerces XML library http://xml.apache.org +proguard obfuscator http://proguard.sourceforge.net +<[email protected]> f�r Bugreports und R�ckmeldungen. - -viel Spass! +have fun! bytonic Software - +---------------- Holger Zickner <[email protected]> Carsten Weisse <[email protected]> Rene Stoeckel <[email protected]> -<[email protected]> f�r Bugreports und R�ckmeldungen.
\ No newline at end of file +Contributors +------------ +David Sanders lwjgl Unterst�tzung @@ -112,7 +112,7 @@ </copy> <copy todir="${dist}"> <fileset dir="scripts"> - <include name="Jake2.*"/> + <include name="Jake2*"/> </fileset> <fileset dir="."> <include name="ChangeLog"/> @@ -138,12 +138,12 @@ <!-- jar --> <target name="jar" depends="compile,copyres"> - <jar destfile="jake2.jar" basedir="${build}"> + <jar destfile="${dist}/lib/jake2.jar" basedir="${build}"> <include name="jake2/**"/> <include name="*.png"/> <include name="mirrors"/> </jar> - <proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar" + <!-- proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar" defaultpackage="" overloadaggressively="off" printmapping="jake2.map"> <injar name="jake2.jar"/> <libraryjar name="lib/jogl/jogl.jar"/> @@ -152,7 +152,7 @@ <keep access="public" name="jake2.Jake2"> <method name="main(java.lang.String[])"/> </keep> - </proguard> + </proguard --> </target> <!-- everything --> @@ -190,18 +190,23 @@ </tarfileset> <tarfileset dir="." prefix="Jake2"> <include name="src/jake2/**"/> + <include name="patch/**"/> + <include name="resources/**"/> <include name="lib/**"/> <include name="build.xml"/> <include name="build.bat"/> <include name="ChangeLog"/> <include name="LICENSE"/> - <include name="README"/> + <include name="README*"/> + <include name="install.xml"/> <include name="readme.id"/> </tarfileset> </tar> <zip destfile="jake2src-${version}.zip"> <zipfileset dir="." prefix="Jake2"> <include name="src/jake2/**"/> + <include name="patch/**"/> + <include name="resources/**"/> <include name="scripts/*.*"/> <include name="lib/**"/> <include name="build.xml"/> @@ -209,7 +214,8 @@ <include name="build.bat"/> <include name="ChangeLog"/> <include name="LICENSE"/> - <include name="README"/> + <include name="README*"/> + <include name="install.xml"/> <include name="readme.id"/> </zipfileset> </zip> @@ -218,7 +224,7 @@ <!-- standalone installer --> <target name="installer" depends="dist"> <izpack input="${basedir}/install.xml" - output="${basedir}/Jake2-install.jar" + output="${basedir}/Jake2-${version}-install.jar" installerType="standard" basedir="${dist}" izPackDir="${basedir}/lib/izpack"/> @@ -230,12 +236,10 @@ <copy todir="webstart/lib"> <fileset dir="${dist}/lib"> <include name="**/*.jar"/> - <exclude name="jake2.jar"/> <exclude name="jogl.jar"/> </fileset> <fileset dir="."> <include name="patch.jar"/> - <include name="jake2.jar"/> </fileset> </copy> diff --git a/install.xml b/install.xml index e1edf6e..871b787 100644 --- a/install.xml +++ b/install.xml @@ -21,7 +21,7 @@ <resources> <res id="LicencePanel.licence" src="LICENSE"/> <res id="InfoPanel.info" src="README"/> - <res src="../shortcutSpec.xml" id="shortcutSpec.xml" /> + <!-- res src="../shortcutSpec.xml" id="shortcutSpec.xml" / --> <!-- res id="Installer.image" src="../resources/icon.png"/ --> </resources> @@ -39,78 +39,124 @@ <packs> <pack name="Jake2" required="yes"> <description>Jake2 files</description> + <os family="windows"/> <fileset dir="." targetdir="$INSTALL_PATH"> <include name="*"/> <include name="lib/jake2.jar"/> - <exclude name="*.bat"/> <exclude name="*.sh"/> + <exclude name="*lwjgl.bat"/> </fileset> + </pack> + <pack name="Jake2" required="yes"> + <description>Jake2 files</description> + <os name="Linux"/> <fileset dir="." targetdir="$INSTALL_PATH"> - <os family="windows"/> - <include name="*.bat"/> + <include name="*"/> + <include name="lib/jake2.jar"/> + <exclude name="*.bat"/> + <exclude name="*mac.sh"/> + <exclude name="*lwjgl.sh"/> </fileset> - <fileset dir="." targetdir="$INSTALL_PATH"> - <os name="Linux"/> - <include name="*.sh"/> - </fileset> + <executable targetfile="$INSTALL_PATH/Jake2.sh"/> </pack> + <pack name="Jake2" required="yes"> + <description>Jake2 files</description> + <os name="Mac OS X"/> + <fileset dir="." targetdir="$INSTALL_PATH"> + <include name="*"/> + <include name="lib/jake2.jar"/> + <exclude name="*.bat"/> + <exclude name="*.sh"/> + <include name="*mac.sh"/> + </fileset> + <executable targetfile="$INSTALL_PATH/Jake2_mac.sh"/> + </pack> <pack name="jogl OpenGL library" required="yes"> <description>default OpenGL library</description> + <os family="windows"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os family="windows"/> <include name="windows/jogl*"/> <include name="jogl.jar"/> </fileset> - <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Linux"/> + </pack> + <pack name="jogl OpenGL library" required="yes"> + <description>default OpenGL library</description> + <os name="Linux"/> + <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> <include name="linux/*jogl*"/> <include name="jogl.jar"/> </fileset> - <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Mac OS X"/> - <include name="osx/*jogl*"/> + </pack> + <pack name="jogl OpenGL library" required="yes"> + <description>default OpenGL library</description> + <os name="Mac OS X"/> + <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> + <include name="osx/*jogl*"/> <include name="jogl.jar"/> </fileset> - </pack> - + </pack> + <pack name="joal sound library" required="no"> <description>default sound library</description> + <os family="windows"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os family="windows"/> <include name="windows/joal*"/> <include name="windows/OpenAL*"/> </fileset> + </pack> + <pack name="joal sound library" required="no"> + <description>default sound library</description> + <os name="Linux"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Linux"/> <include name="linux/*joal*"/> <include name="linux/*openal*"/> </fileset> + </pack> + <pack name="joal sound library" required="no"> + <description>default sound library</description> + <os name="Mac OS X"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Mac OS X"/> <include name="osx/*joal*"/> <include name="osx/*openal*"/> </fileset> </pack> - + <pack name="lwjgl library" required="no"> <description>alternative OpenGL and sound driver</description> - <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os family="windows"/> + <os family="windows"/> + <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> <include name="windows/lwjgl*"/> <include name="lwjgl*.jar"/> </fileset> + <fileset dir="." targetdir="$INSTALL_PATH"> + <include name="*lwjgl.bat"/> + </fileset> + </pack> + <pack name="lwjgl library" required="no"> + <description>alternative OpenGL and sound driver</description> + <os name="Linux"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Linux"/> <include name="linux/lwjgl/*"/> <include name="lwjgl*.jar"/> </fileset> + <fileset dir="." targetdir="$INSTALL_PATH"> + <include name="Jake2_lwjgl.sh"/> + </fileset> + <executable targetfile="$INSTALL_PATH/Jake2_lwjgl.sh"/> + </pack> + <pack name="lwjgl library" required="no"> + <description>alternative OpenGL and sound driver</description> + <os name="Mac OS X"/> <fileset dir="lib" targetdir="$INSTALL_PATH/lib"> - <os name="Mac OS X"/> <include name="osx/lwjgl/*"/> <include name="lwjgl*.jar"/> </fileset> - </pack> + <fileset dir="." targetdir="$INSTALL_PATH"> + <include name="Jake2_mac_lwjgl.sh"/> + </fileset> + <executable targetfile="$INSTALL_PATH/Jake2_mac_lwjgl.sh"/> + </pack> </packs> <!-- native type="izpack" name="ShellLink.dll"/ --> diff --git a/scripts/Jake2.bat b/scripts/Jake2.bat index 68b691c..ed0bd82 100644 --- a/scripts/Jake2.bat +++ b/scripts/Jake2.bat @@ -1,4 +1,4 @@ @echo off SET PATH=lib\windows;%PATH% -SET CP=lib/jake2.jar;lib/jogl.jar;lib/windows/joal.jar;lib/lwjgl.jar;lib/lwjgl_util.jar -java -Xmx80M -Dsun.java2d.noddraw=true -Djava.library.path=lib/windows -cp %CP% jake2.Jake2
\ No newline at end of file +SET CP=lib/jake2.jar;lib/jogl.jar;lib/windows/joal.jar +java -Xmx100M -Dsun.java2d.noddraw=true -Djava.library.path=lib/windows -cp %CP% jake2.Jake2
\ No newline at end of file diff --git a/scripts/Jake2.sh b/scripts/Jake2.sh index 8a360ff..900e934 100644 --- a/scripts/Jake2.sh +++ b/scripts/Jake2.sh @@ -1,6 +1,6 @@ #!/bin/bash export LD_LIBRARY_PATH=lib/linux -CP=lib/jake2.jar:lib/jogl.jar:lib/linux/joal.jar:lib/lwjgl.jar:lib/lwjgl_util.jar +CP=lib/jake2.jar:lib/jogl.jar:lib/linux/joal.jar -exec java -Xmx80M -Djava.library.path=lib/linux -cp $CP jake2.Jake2 +exec java -Xmx100M -Djava.library.path=lib/linux -cp $CP jake2.Jake2 diff --git a/scripts/Jake2_lwjgl.bat b/scripts/Jake2_lwjgl.bat new file mode 100644 index 0000000..1a17719 --- /dev/null +++ b/scripts/Jake2_lwjgl.bat @@ -0,0 +1,4 @@ +@echo off +SET PATH=lib\windows;%PATH% +SET CP=lib/jake2.jar;lib/lwjgl.jar;lib/lwjgl_util.jar +java -Xmx100M -Dsun.java2d.noddraw=true -Djava.library.path=lib/windows -cp %CP% jake2.Jake2
\ No newline at end of file diff --git a/scripts/Jake2_lwjgl.sh b/scripts/Jake2_lwjgl.sh new file mode 100644 index 0000000..bd06e11 --- /dev/null +++ b/scripts/Jake2_lwjgl.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=lib/linux/lwjgl +CP=lib/jake2.jar:lib/lwjgl.jar:lib/lwjgl_util.jar + +exec java -Xmx100M -Djava.library.path=lib/linux/lwjgl -cp $CP jake2.Jake2 diff --git a/scripts/Jake2_mac.sh b/scripts/Jake2_mac.sh new file mode 100644 index 0000000..d106a05 --- /dev/null +++ b/scripts/Jake2_mac.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export LD_LIBRARY_PATH=lib/osx +CP=lib/jake2.jar:lib/jogl.jar:lib/linux/joal.jar + +exec java -Xmx100M -Djava.library.path=lib/osx -cp $CP jake2.Jake2 diff --git a/scripts/Jake2_mac_lwjgl.sh b/scripts/Jake2_mac_lwjgl.sh new file mode 100644 index 0000000..7ac46c6 --- /dev/null +++ b/scripts/Jake2_mac_lwjgl.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export LD_LIBRARY_PATH=lib/linux/osx +CP=lib/jake2.jar:lib/lwjgl.jar:lib/lwjgl_util.jar + +exec java -Xmx100M -Djava.library.path=lib/osx -cp $CP jake2.Jake2 diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java index fd1c4d0..83a1191 100644 --- a/src/jake2/client/CL.java +++ b/src/jake2/client/CL.java @@ -2,7 +2,7 @@ * CL.java * Copyright (C) 2004 * - * $Id: CL.java,v 1.21 2005-05-14 10:10:44 hzi Exp $ + * $Id: CL.java,v 1.22 2005-06-07 12:57:21 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -851,7 +851,7 @@ public final class CL { // challenge from the server we are connecting to if (c.equals("challenge")) { - Globals.cls.challenge = Integer.parseInt(Cmd.Argv(1)); + Globals.cls.challenge = Lib.atoi(Cmd.Argv(1)); SendConnectPacket(); return; } diff --git a/src/jake2/client/CL_input.java b/src/jake2/client/CL_input.java index 5c47e61..3e5e4de 100644 --- a/src/jake2/client/CL_input.java +++ b/src/jake2/client/CL_input.java @@ -2,7 +2,7 @@ * java * Copyright (C) 2004 * - * $Id: CL_input.java,v 1.5 2005-01-21 01:10:09 cawe Exp $ + * $Id: CL_input.java,v 1.6 2005-06-07 12:57:21 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -32,6 +32,7 @@ import jake2.game.cvar_t; import jake2.game.usercmd_t; import jake2.qcommon.*; import jake2.sys.IN; +import jake2.util.Lib; import jake2.util.Math3D; /** @@ -109,7 +110,7 @@ public class CL_input { c = Cmd.Argv(1); if (c.length() > 0) - k = Integer.parseInt(c); + k = Lib.atoi(c); else k = -1; // typed manually at the console for continuous down @@ -130,7 +131,7 @@ public class CL_input { // save timestamp c = Cmd.Argv(2); - b.downtime = Long.parseLong(c); + b.downtime = Lib.atoi(c); if (b.downtime == 0) b.downtime = Globals.sys_frame_time - 100; @@ -144,7 +145,7 @@ public class CL_input { c = Cmd.Argv(1); if (c.length() > 0) - k = Integer.parseInt(c); + k = Lib.atoi(c); else { // typed manually at the console, assume for unsticking, so clear // all @@ -298,7 +299,7 @@ public class CL_input { } static void IN_Impulse() { - in_impulse = Integer.parseInt(Cmd.Argv(1)); + in_impulse = Lib.atoi(Cmd.Argv(1)); } /* diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java index 087aec1..1787262 100644 --- a/src/jake2/client/Key.java +++ b/src/jake2/client/Key.java @@ -2,7 +2,7 @@ * Key.java * Copyright (C) 2003 * - * $Id: Key.java,v 1.7 2004-10-28 18:15:25 cawe Exp $ + * $Id: Key.java,v 1.11 2005-06-07 12:57:21 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -287,7 +287,7 @@ public class Key extends Globals { /** * Called by the system between frames for both key up and key down events. */ - public static void Event(int key, boolean down, long time) { + public static void Event(int key, boolean down, int time) { String kb; String cmd; @@ -301,13 +301,9 @@ public class Key extends Globals { // update auto-repeat status if (down) { key_repeats[key]++; - if (key != K_BACKSPACE - && key != K_PAUSE - && key != K_PGUP - && key != K_KP_PGUP - && key != K_PGDN - && key != K_KP_PGDN - && key_repeats[key] > 1) + if (key_repeats[key] > 1 + && Globals.cls.key_dest == Defines.key_game + && !(Globals.cls.state == Defines.ca_disconnected)) return; // ignore most autorepeats if (key >= 200 && Globals.keybindings[key] == null) diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java index b095e74..4b39403 100644 --- a/src/jake2/client/VID.java +++ b/src/jake2/client/VID.java @@ -2,7 +2,7 @@ * VID.java * Copyright (C) 2003 * - * $Id: VID.java,v 1.15 2005-04-07 15:29:21 cawe Exp $ + * $Id: VID.java,v 1.16 2005-05-26 16:56:33 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -255,23 +255,31 @@ public class VID extends Globals { Globals.cl.refresh_prepped = false; Globals.cls.disable_screen = 1.0f; // true; - String defaultName = Renderer.getDefaultName(); if ( !LoadRefresh( vid_ref.string ) ) { - if ( vid_ref.string.equals(defaultName) ) { + String renderer; + if (vid_ref.string.equals(Renderer.getPreferedName())) { + // try the default renderer as fallback after prefered + renderer = Renderer.getDefaultName(); + } else { + // try the prefered renderer as first fallback + renderer = Renderer.getPreferedName(); + } + if ( vid_ref.string.equals(Renderer.getDefaultName())) { + renderer = vid_ref.string; Com.Printf("Refresh failed\n"); gl_mode = Cvar.Get( "gl_mode", "0", 0 ); if (gl_mode.value != 0.0f) { Com.Printf("Trying mode 0\n"); Cvar.SetValue("gl_mode", 0); if ( !LoadRefresh( vid_ref.string ) ) - Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + defaultName +" refresh!"); + Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); } else - Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + defaultName +" refresh!"); + Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); } - Cvar.Set("vid_ref", defaultName); + Cvar.Set("vid_ref", renderer); /* * drop the console if we fail to load a refresh diff --git a/src/jake2/game/entity_state_t.java b/src/jake2/game/entity_state_t.java index abba83e..75ce803 100644 --- a/src/jake2/game/entity_state_t.java +++ b/src/jake2/game/entity_state_t.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 08.11.2003 by RST. -// $Id: entity_state_t.java,v 1.4 2005-01-23 19:06:10 cawe Exp $ +// $Id: entity_state_t.java,v 1.5 2005-06-05 15:21:47 salomo Exp $ package jake2.game; @@ -37,10 +37,13 @@ public class entity_state_t implements Cloneable public entity_state_t(edict_t ent) { this.surrounding_ent = ent; + if (ent != null) + number = ent.index; } - /** edict index. */ - public int number = -99999; + /** edict index. TODO: this is critical. The index has to be proper managed. */ + public int number = 0; + // TODO: why was this introduced? public edict_t surrounding_ent = null; public float[] origin = { 0, 0, 0 }; public float[] angles = { 0, 0, 0 }; @@ -148,7 +151,8 @@ public class entity_state_t implements Cloneable public void clear() { - number = -99999; + //TODO: this is critical. The index has to be proper managed. + number = 0; surrounding_ent = null; Math3D.VectorClear(origin); Math3D.VectorClear(angles); diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index d3386d2..9ff3a99 100644 --- a/src/jake2/qcommon/Com.java +++ b/src/jake2/qcommon/Com.java @@ -2,7 +2,7 @@ * Com.java * Copyright (C) 2003 * - * $Id: Com.java,v 1.11 2005-02-06 19:25:55 salomo Exp $ + * $Id: Com.java,v 1.12 2005-06-11 17:21:21 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -400,9 +400,10 @@ public final class Com if (Globals.logfile_active.value > 2) try { - Globals.logfile= new RandomAccessFile(name, "a"); + Globals.logfile = new RandomAccessFile(name, "rw"); + Globals.logfile.seek(Globals.logfile.length()); } - catch (FileNotFoundException e) + catch (Exception e) { // TODO: do quake2 error handling! e.printStackTrace(); diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index d14cadd..c0aa6ab 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.7 2005-02-08 18:00:02 cawe Exp $ + * $Id: Cvar.java,v 1.8 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -294,10 +294,21 @@ public class Cvar extends Globals { /* * ============ Cvar_SetValue ============ */ - public static void SetValue(String var_name, float value) { + // the overloading is very important + // there was a problem with networt "rate" string + // 10000 became "10000.0" and that wasn't right + public static void SetValue(String var_name, int value) { Cvar.Set(var_name, "" + value); } + public static void SetValue(String var_name, float value) { + if (value == (int)value) { + Cvar.Set(var_name, "" + (int)value); + } else { + Cvar.Set(var_name, "" + value); + } + } + /* * ============ Cvar_VariableValue ============ */ diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index 5bab93e..0bea72b 100644 --- a/src/jake2/qcommon/FS.java +++ b/src/jake2/qcommon/FS.java @@ -2,7 +2,7 @@ * FS.java * Copyright (C) 2003 * - * $Id: FS.java,v 1.12 2004-11-10 20:41:40 cawe Exp $ + * $Id: FS.java,v 1.14 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -36,8 +36,6 @@ import java.nio.ByteOrder; import java.nio.channels.FileChannel; import java.util.*; -import javax.imageio.stream.FileImageInputStream; - /** * FS * @@ -527,24 +525,26 @@ public final class FS extends Globals { dpackheader_t header; Hashtable newfiles; + RandomAccessFile file; int numpackfiles = 0; pack_t pack = null; - RandomAccessFile file; - FileImageInputStream packhandle; // unsigned checksum; // try { - packhandle = new FileImageInputStream(file = new RandomAccessFile( - packfile, "r")); - packhandle.setByteOrder(ByteOrder.LITTLE_ENDIAN); - - if (packhandle.length() < 1) + file = new RandomAccessFile(packfile, "r"); + FileChannel fc = file.getChannel(); + ByteBuffer packhandle = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); + packhandle.order(ByteOrder.LITTLE_ENDIAN); + + fc.close(); + + if (packhandle == null || packhandle.limit() < 1) return null; // header = new dpackheader_t(); - header.ident = packhandle.readInt(); - header.dirofs = packhandle.readInt(); - header.dirlen = packhandle.readInt(); + header.ident = packhandle.getInt(); + header.dirofs = packhandle.getInt(); + header.dirlen = packhandle.getInt(); if (header.ident != IDPAKHEADER) Com.Error(Globals.ERR_FATAL, packfile + " is not a packfile"); @@ -557,18 +557,18 @@ public final class FS extends Globals { newfiles = new Hashtable(numpackfiles); - packhandle.seek(header.dirofs); + packhandle.position(header.dirofs); // parse the directory packfile_t entry = null; for (int i = 0; i < numpackfiles; i++) { - packhandle.readFully(tmpText); + packhandle.get(tmpText); entry = new packfile_t(); entry.name = new String(tmpText).trim(); - entry.filepos = packhandle.readInt(); - entry.filelen = packhandle.readInt(); + entry.filepos = packhandle.getInt(); + entry.filelen = packhandle.getInt(); newfiles.put(entry.name.toLowerCase(), entry); } @@ -659,14 +659,11 @@ public final class FS extends Globals { * ExecAutoexec */ public static void ExecAutoexec() { + String dir = fs_userdir; - String dir; String name; - - dir = Cvar.VariableString("gamedir"); - if (dir != null && dir.length() > 0) { - name = fs_basedir.string + '/' + dir + "/autoexec.cfg"; + name = dir + "/autoexec.cfg"; } else { name = fs_basedir.string + '/' + Globals.BASEDIRNAME + "/autoexec.cfg"; diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java index 16c1bf5..2d28629 100644 --- a/src/jake2/qcommon/Q2DataDialog.java +++ b/src/jake2/qcommon/Q2DataDialog.java @@ -2,7 +2,7 @@ * Q2DataDialog.java * Copyright (C) 2003 * - * $Id: Q2DataDialog.java,v 1.13 2005-05-12 12:52:50 hzi Exp $ + * $Id: Q2DataDialog.java,v 1.14 2005-05-26 16:56:32 hzi Exp $ */ package jake2.qcommon; @@ -35,7 +35,7 @@ public class Q2DataDialog extends javax.swing.JDialog { int x = (mode.getWidth() - getWidth()) / 2; int y = (mode.getHeight() - getHeight()) / 2; setLocation(x, y); - dir = home + sep + "jake2" + sep + "baseq2"; + dir = home + sep + "Jake2" + sep + "baseq2"; jTextField1.setText(dir); } @@ -183,7 +183,7 @@ public class Q2DataDialog extends javax.swing.JDialog { } private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { - + dir = jTextField1.getText(); if (dir != null) { Cvar.Set("cddir", dir); FS.setCDDir(); @@ -227,7 +227,7 @@ public class Q2DataDialog extends javax.swing.JDialog { private InstallPanel installPanel; private NotFoundPanel notFoundPanel; private JLabel status; - private javax.swing.JTextField jTextField1; + javax.swing.JTextField jTextField1; private javax.swing.JButton okButton; // End of variables declaration//GEN-END:variables @@ -441,7 +441,7 @@ public class Q2DataDialog extends javax.swing.JDialog { public InstallPanel(Q2DataDialog d) { initComponents(); - String dir = Q2DataDialog.home + Q2DataDialog.sep + "jake2"; + String dir = Q2DataDialog.home + Q2DataDialog.sep + "Jake2"; destDir.setText(dir); initMirrors(); parent = d; @@ -760,7 +760,7 @@ public class Q2DataDialog extends javax.swing.JDialog { void endInstall(String message) { parent.notFoundPanel.message.setText(message); - parent.dir = destDir + "/baseq2"; + parent.jTextField1.setText(destDir + "/baseq2"); parent.showChooseDialog(); parent.okButtonActionPerformed(null); } diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java index ed81b71..1035b73 100644 --- a/src/jake2/qcommon/Qcommon.java +++ b/src/jake2/qcommon/Qcommon.java @@ -2,7 +2,7 @@ * Qcommon.java * Copyright 2003 * - * $Id: Qcommon.java,v 1.16 2005-05-14 10:10:45 hzi Exp $ + * $Id: Qcommon.java,v 1.17 2005-05-26 16:56:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -246,6 +246,10 @@ public final class Qcommon extends Globals { Cbuf.AddText("exec default.cfg\n"); Cbuf.AddText("bind MWHEELUP weapnext\n"); Cbuf.AddText("bind MWHEELDOWN weapprev\n"); + Cbuf.AddText("bind w +forward\n"); + Cbuf.AddText("bind s +back\n"); + Cbuf.AddText("bind a +moveleft\n"); + Cbuf.AddText("bind d +moveright\n"); Cbuf.Execute(); Cvar.Set("vid_fullscreen", "0"); Cbuf.AddText("exec config.cfg\n"); diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index 075e306..32053fd 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.13 2004-12-14 00:11:09 hzi Exp $ + * $Id: JoglBase.java,v 1.14 2005-06-24 06:24:34 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render; import jake2.Defines; -import jake2.client.*; +import jake2.client.VID; +import jake2.client.viddef_t; import jake2.game.cvar_t; import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; import jake2.sys.JOGLKBD; -import jake2.sys.KBD; import java.awt.*; import java.awt.event.WindowAdapter; @@ -95,9 +95,7 @@ public abstract class JoglBase implements GLEventListener { protected static final int rserr_invalid_fullscreen = 1; protected static final int rserr_invalid_mode = 2; protected static final int rserr_unknown = 3; - - private boolean swap = false; - + public DisplayMode[] getModeList() { DisplayMode[] modes = device.getDisplayModes(); LinkedList l = new LinkedList(); @@ -209,11 +207,6 @@ public abstract class JoglBase implements GLEventListener { //canvas.setGL(new DebugGL(canvas.getGL())); canvas.setNoAutoRedrawMode(true); - - if (net.java.games.jogl.Version.getVersion().startsWith("1.1")) { - swap=true; - canvas.setAutoSwapBufferMode(false); - } canvas.addGLEventListener(this); @@ -314,9 +307,6 @@ public abstract class JoglBase implements GLEventListener { protected void GLimp_EndFrame() { gl.glFlush(); - - // swap buffer - if (swap) canvas.swapBuffers(); } protected void GLimp_BeginFrame(float camera_separation) { // do nothing diff --git a/src/jake2/render/fastjogl/Base.java b/src/jake2/render/fastjogl/Base.java index 563b16a..1e487a5 100644 --- a/src/jake2/render/fastjogl/Base.java +++ b/src/jake2/render/fastjogl/Base.java @@ -2,27 +2,27 @@ * Base.java * Copyright (C) 2003 * - * $Id: Base.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ + * $Id: Base.java,v 1.3 2005-06-08 20:43:07 cawe Exp $ */ /* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ package jake2.render.fastjogl; import jake2.render.JoglBase; @@ -30,266 +30,126 @@ import net.java.games.jogl.GL; /** * Base - * + * * @author cwei */ public abstract class Base extends JoglBase { - - static final int GL_COLOR_INDEX8_EXT = GL.GL_COLOR_INDEX; - static final String REF_VERSION = "GL 0.01"; - - // up / down - static final int PITCH = 0; - // left / right - static final int YAW = 1; - // fall over - static final int ROLL = 2; - - /* - skins will be outline flood filled and mip mapped - pics and sprites with alpha will be outline flood filled - pic won't be mip mapped - - model skin - sprite frame - wall texture - pic - */ - // enum imagetype_t - static final int it_skin = 0; - static final int it_sprite = 1; - static final int it_wall = 2; - static final int it_pic = 3; - static final int it_sky = 4; - - // enum modtype_t - static final int mod_bad = 0; - static final int mod_brush = 1; - static final int mod_sprite = 2; - static final int mod_alias = 3; - - static final int TEXNUM_LIGHTMAPS = 1024; - static final int TEXNUM_SCRAPS = 1152; - static final int TEXNUM_IMAGES = 1153; - - static final int MAX_GLTEXTURES = 1024; - -// =================================================================== - -// -// #include "gl_model.h" -// -// void GL_BeginRendering (int *x, int *y, int *width, int *height); -// void GL_EndRendering (void); -// -// void GL_SetDefaultState( void ); -// void GL_UpdateSwapInterval( void ); - - static class glvert_t { - float x, y, z; - float s, t; - float r, g, b; - } - - static final int MAX_LBM_HEIGHT = 480; - - static final float BACKFACE_EPSILON = 0.01f; - -// ==================================================== -// -// void R_TranslatePlayerSkin (int playernum); -// void GL_Bind (int texnum); -// void GL_MBind( GLenum target, int texnum ); -// void GL_TexEnv( GLenum value ); -// void GL_EnableMultitexture( qboolean enable ); -// void GL_SelectTexture( GLenum ); -// -// void R_LightPoint (vec3_t p, vec3_t color); -// void R_PushDlights (void); -// - -// ==================================================================== -// -// extern int registration_sequence; -// -// -// void V_AddBlend (float r, float g, float b, float a, float *v_blend); -// -// int R_Init( void *hinstance, void *hWnd ); -// void R_Shutdown( void ); -// -// void R_RenderView (refdef_t *fd); -// void GL_ScreenShot_f (void); -// void R_DrawAliasModel (entity_t *e); -// void R_DrawBrushModel (entity_t *e); -// void R_DrawSpriteModel (entity_t *e); -// void R_DrawBeam( entity_t *e ); -// void R_DrawWorld (void); -// void R_RenderDlights (void); -// void R_DrawAlphaSurfaces (void); -// void R_RenderBrushPoly (msurface_t *fa); -// void R_InitParticleTexture (void); -// void Draw_InitLocal (void); -// void GL_SubdivideSurface (msurface_t *fa); -// qboolean R_CullBox (vec3_t mins, vec3_t maxs); -// void R_RotateForEntity (entity_t *e); -// void R_MarkLeaves (void); -// -// glpoly_t *WaterWarpPolyVerts (glpoly_t *p); -// void EmitWaterPolys (msurface_t *fa); -// void R_AddSkySurface (msurface_t *fa); -// void R_ClearSkyBox (void); -// void R_DrawSkyBox (void); -// void R_MarkLights (dlight_t *light, int bit, mnode_t *node); -// -// -// void COM_StripExtension (char *in, char *out); -// -// void Draw_GetPicSize (int *w, int *h, char *name); -// void Draw_Pic (int x, int y, char *name); -// void Draw_StretchPic (int x, int y, int w, int h, char *name); -// void Draw_Char (int x, int y, int c); -// void Draw_TileClear (int x, int y, int w, int h, char *name); -// void Draw_Fill (int x, int y, int w, int h, int c); -// void Draw_FadeScreen (void); -// void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data); -// -// void R_BeginFrame( float camera_separation ); -// void R_SwapBuffers( int ); -// void R_SetPalette ( const unsigned char *palette); -// -// int Draw_GetPalette (void); -// -// void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight); -// -// struct image_s *R_RegisterSkin (char *name); -// -// void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height); -// image_t *GL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits); -// image_t *GL_FindImage (char *name, imagetype_t type); -// void GL_TextureMode( char *string ); -// void GL_ImageList_f (void); -// -// void GL_SetTexturePalette( unsigned palette[256] ); -// -// void GL_InitImages (void); -// void GL_ShutdownImages (void); -// -// void GL_FreeUnusedImages (void); -// -// void GL_TextureAlphaMode( char *string ); -// void GL_TextureSolidMode( char *string ); -// -// /* -// ** GL extension emulation functions -// */ -// void GL_DrawParticles( int n, const particle_t particles[], const unsigned colortable[768] ); -// - - /* - ** GL config stuff - */ - static final int GL_RENDERER_VOODOO = 0x00000001; - static final int GL_RENDERER_VOODOO2 = 0x00000002; - static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; - static final int GL_RENDERER_BANSHEE = 0x00000008; - static final int GL_RENDERER_3DFX = 0x0000000F; - - static final int GL_RENDERER_PCX1 = 0x00000010; - static final int GL_RENDERER_PCX2 = 0x00000020; - static final int GL_RENDERER_PMX = 0x00000040; - static final int GL_RENDERER_POWERVR = 0x00000070; - - static final int GL_RENDERER_PERMEDIA2 = 0x00000100; - static final int GL_RENDERER_GLINT_MX = 0x00000200; - static final int GL_RENDERER_GLINT_TX = 0x00000400; - static final int GL_RENDERER_3DLABS_MISC = 0x00000800; - static final int GL_RENDERER_3DLABS = 0x00000F00; - - static final int GL_RENDERER_REALIZM = 0x00001000; - static final int GL_RENDERER_REALIZM2 = 0x00002000; - static final int GL_RENDERER_INTERGRAPH = 0x00003000; - - static final int GL_RENDERER_3DPRO = 0x00004000; - static final int GL_RENDERER_REAL3D = 0x00008000; - static final int GL_RENDERER_RIVA128 = 0x00010000; - static final int GL_RENDERER_DYPIC = 0x00020000; - - static final int GL_RENDERER_V1000 = 0x00040000; - static final int GL_RENDERER_V2100 = 0x00080000; - static final int GL_RENDERER_V2200 = 0x00100000; - static final int GL_RENDERER_RENDITION = 0x001C0000; - - static final int GL_RENDERER_O2 = 0x00100000; - static final int GL_RENDERER_IMPACT = 0x00200000; - static final int GL_RENDERER_RE = 0x00400000; - static final int GL_RENDERER_IR = 0x00800000; - static final int GL_RENDERER_SGI = 0x00F00000; - - static final int GL_RENDERER_MCD = 0x01000000; - static final int GL_RENDERER_OTHER = 0x80000000; - - -// typedef struct -// { -// int renderer; -// const char *renderer_string; -// const char *vendor_string; -// const char *version_string; -// const char *extensions_string; -// -// qboolean allow_cds; -// } glconfig_t; -// -// typedef struct -// { -// float inverse_intensity; -// qboolean fullscreen; -// -// int prev_mode; -// -// unsigned char *d_16to8table; -// -// int lightmap_textures; -// -// int currenttextures[2]; -// int currenttmu; -// -// float camera_separation; -// qboolean stereo_enabled; -// -// unsigned char originalRedGammaTable[256]; -// unsigned char originalGreenGammaTable[256]; -// unsigned char originalBlueGammaTable[256]; -// } glstate_t; -// -// /* -// ==================================================================== -// -// IMPORTED FUNCTIONS -// -// ==================================================================== -// */ -// -// extern refimport_t ri; -// -// -// /* -// ==================================================================== -// -// IMPLEMENTATION SPECIFIC FUNCTIONS -// -// ==================================================================== -// */ -// -// void GLimp_BeginFrame( float camera_separation ); -// void GLimp_EndFrame( void ); -// int GLimp_Init( void *hinstance, void *hWnd ); -// void GLimp_Shutdown( void ); -// int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen ); -// void GLimp_AppActivate( qboolean active ); -// void GLimp_EnableLogging( qboolean enable ); -// void GLimp_LogNewFrame( void ); -// - -} + + static final int GL_COLOR_INDEX8_EXT = GL.GL_COLOR_INDEX; + + static final String REF_VERSION = "GL 0.01"; + + // up / down + static final int PITCH = 0; + + // left / right + static final int YAW = 1; + + // fall over + static final int ROLL = 2; + + /* + * skins will be outline flood filled and mip mapped pics and sprites with + * alpha will be outline flood filled pic won't be mip mapped + * + * model skin sprite frame wall texture pic + */ + // enum imagetype_t + static final int it_skin = 0; + + static final int it_sprite = 1; + + static final int it_wall = 2; + + static final int it_pic = 3; + + static final int it_sky = 4; + + // enum modtype_t + static final int mod_bad = 0; + + static final int mod_brush = 1; + + static final int mod_sprite = 2; + + static final int mod_alias = 3; + + static final int TEXNUM_LIGHTMAPS = 1024; + + static final int TEXNUM_SCRAPS = 1152; + + static final int TEXNUM_IMAGES = 1153; + + static final int MAX_GLTEXTURES = 1024; + + static final int MAX_LBM_HEIGHT = 480; + + static final float BACKFACE_EPSILON = 0.01f; + + /* + * * GL config stuff + */ + static final int GL_RENDERER_VOODOO = 0x00000001; + + static final int GL_RENDERER_VOODOO2 = 0x00000002; + + static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; + + static final int GL_RENDERER_BANSHEE = 0x00000008; + + static final int GL_RENDERER_3DFX = 0x0000000F; + + static final int GL_RENDERER_PCX1 = 0x00000010; + + static final int GL_RENDERER_PCX2 = 0x00000020; + + static final int GL_RENDERER_PMX = 0x00000040; + + static final int GL_RENDERER_POWERVR = 0x00000070; + + static final int GL_RENDERER_PERMEDIA2 = 0x00000100; + + static final int GL_RENDERER_GLINT_MX = 0x00000200; + + static final int GL_RENDERER_GLINT_TX = 0x00000400; + + static final int GL_RENDERER_3DLABS_MISC = 0x00000800; + + static final int GL_RENDERER_3DLABS = 0x00000F00; + + static final int GL_RENDERER_REALIZM = 0x00001000; + + static final int GL_RENDERER_REALIZM2 = 0x00002000; + + static final int GL_RENDERER_INTERGRAPH = 0x00003000; + + static final int GL_RENDERER_3DPRO = 0x00004000; + + static final int GL_RENDERER_REAL3D = 0x00008000; + + static final int GL_RENDERER_RIVA128 = 0x00010000; + + static final int GL_RENDERER_DYPIC = 0x00020000; + + static final int GL_RENDERER_V1000 = 0x00040000; + + static final int GL_RENDERER_V2100 = 0x00080000; + + static final int GL_RENDERER_V2200 = 0x00100000; + + static final int GL_RENDERER_RENDITION = 0x001C0000; + + static final int GL_RENDERER_O2 = 0x00100000; + + static final int GL_RENDERER_IMPACT = 0x00200000; + + static final int GL_RENDERER_RE = 0x00400000; + + static final int GL_RENDERER_IR = 0x00800000; + + static final int GL_RENDERER_SGI = 0x00F00000; + + static final int GL_RENDERER_MCD = 0x01000000; + + static final int GL_RENDERER_OTHER = 0x80000000; +}
\ No newline at end of file diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index e15e698..0b52ad8 100644 --- a/src/jake2/render/fastjogl/Mesh.java +++ b/src/jake2/render/fastjogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.10 2005-05-07 23:44:38 cawe Exp $ + * $Id: Mesh.java,v 1.12 2005-06-09 07:59:58 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -81,26 +81,28 @@ public abstract class Mesh extends Light { | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) { float[] normal; - int j = -1; + int j = 0; for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { vv = v[i]; normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; ovv = ov[i]; - lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + j += 3; } } else { - int j = -1; - for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + int j = 0; + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { ovv = ov[i]; vv = v[i]; - lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); - lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); - lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + j +=3; } } } @@ -201,10 +203,11 @@ public abstract class Mesh extends Light { float l; for (int i = 0; i < paliashdr.num_xyz; i++) { l = shadedots[(verts[i] >>> 24 ) & 0xFF]; - color.put(j++, l * shadelight[0]); - color.put(j++, l * shadelight[1]); - color.put(j++, l * shadelight[2]); - color.put(j++, alpha); + color.put(j, l * shadelight[0]); + color.put(j + 1, l * shadelight[1]); + color.put(j + 2, l * shadelight[2]); + color.put(j + 3, alpha); + j += 4; } } diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java index 08516f9..5c90ed4 100644 --- a/src/jake2/render/fastjogl/Surf.java +++ b/src/jake2/render/fastjogl/Surf.java @@ -2,7 +2,7 @@ * Surf.java * Copyright (C) 2003 * - * $Id: Surf.java,v 1.9 2005-01-17 23:50:50 cawe Exp $ + * $Id: Surf.java,v 1.10 2005-06-08 21:27:09 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -924,15 +924,15 @@ public abstract class Surf extends Draw { // memcpy (fatvis, vis, (r_worldmodel.numleafs+7)/8); System .arraycopy(vis, 0, fatvis, 0, - (r_worldmodel.numleafs + 7) / 8); + (r_worldmodel.numleafs + 7) >> 3); vis = Mod_ClusterPVS(r_viewcluster2, r_worldmodel); - c = (r_worldmodel.numleafs + 31) / 32; - int k = 0; - for (i = 0; i < c; i++) { - fatvis[k] |= vis[k++]; - fatvis[k] |= vis[k++]; - fatvis[k] |= vis[k++]; - fatvis[k] |= vis[k++]; + c = (r_worldmodel.numleafs + 31) >> 5; + c <<= 2; + for (int k = 0; k < c; k+=4) { + fatvis[k] |= vis[k]; + fatvis[k + 1] |= vis[k + 1]; + fatvis[k + 2] |= vis[k + 2]; + fatvis[k + 3] |= vis[k + 3]; } vis = fatvis; diff --git a/src/jake2/render/lwjgl/Base.java b/src/jake2/render/lwjgl/Base.java index aef39a5..b536298 100644 --- a/src/jake2/render/lwjgl/Base.java +++ b/src/jake2/render/lwjgl/Base.java @@ -2,294 +2,153 @@ * Base.java * Copyright (C) 2003 * - * $Id: Base.java,v 1.3 2004-12-16 19:53:41 cawe Exp $ + * $Id: Base.java,v 1.4 2005-06-08 21:24:52 cawe Exp $ */ /* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ package jake2.render.lwjgl; - import org.lwjgl.opengl.GL11; /** * Base - * + * * @author dsanders/cwei */ public abstract class Base extends LWJGLBase { - - static final int GL_COLOR_INDEX8_EXT = GL11.GL_COLOR_INDEX; - static final String REF_VERSION = "GL 0.01"; - - // up / down - static final int PITCH = 0; - // left / right - static final int YAW = 1; - // fall over - static final int ROLL = 2; - - /* - skins will be outline flood filled and mip mapped - pics and sprites with alpha will be outline flood filled - pic won't be mip mapped - - model skin - sprite frame - wall texture - pic - */ - // enum imagetype_t - static final int it_skin = 0; - static final int it_sprite = 1; - static final int it_wall = 2; - static final int it_pic = 3; - static final int it_sky = 4; - - // enum modtype_t - static final int mod_bad = 0; - static final int mod_brush = 1; - static final int mod_sprite = 2; - static final int mod_alias = 3; - - static final int TEXNUM_LIGHTMAPS = 1024; - static final int TEXNUM_SCRAPS = 1152; - static final int TEXNUM_IMAGES = 1153; - - static final int MAX_GLTEXTURES = 1024; - -// =================================================================== - -// -// #include "gl_model.h" -// -// void GL_BeginRendering (int *x, int *y, int *width, int *height); -// void GL_EndRendering (void); -// -// void GL_SetDefaultState( void ); -// void GL_UpdateSwapInterval( void ); - - static class glvert_t { - float x, y, z; - float s, t; - float r, g, b; - } - - static final int MAX_LBM_HEIGHT = 480; - - static final float BACKFACE_EPSILON = 0.01f; - -// ==================================================== -// -// void R_TranslatePlayerSkin (int playernum); -// void GL_Bind (int texnum); -// void GL_MBind( GLenum target, int texnum ); -// void GL_TexEnv( GLenum value ); -// void GL_EnableMultitexture( qboolean enable ); -// void GL_SelectTexture( GLenum ); -// -// void R_LightPoint (vec3_t p, vec3_t color); -// void R_PushDlights (void); -// - -// ==================================================================== -// -// extern int registration_sequence; -// -// -// void V_AddBlend (float r, float g, float b, float a, float *v_blend); -// -// int R_Init( void *hinstance, void *hWnd ); -// void R_Shutdown( void ); -// -// void R_RenderView (refdef_t *fd); -// void GL_ScreenShot_f (void); -// void R_DrawAliasModel (entity_t *e); -// void R_DrawBrushModel (entity_t *e); -// void R_DrawSpriteModel (entity_t *e); -// void R_DrawBeam( entity_t *e ); -// void R_DrawWorld (void); -// void R_RenderDlights (void); -// void R_DrawAlphaSurfaces (void); -// void R_RenderBrushPoly (msurface_t *fa); -// void R_InitParticleTexture (void); -// void Draw_InitLocal (void); -// void GL_SubdivideSurface (msurface_t *fa); -// qboolean R_CullBox (vec3_t mins, vec3_t maxs); -// void R_RotateForEntity (entity_t *e); -// void R_MarkLeaves (void); -// -// glpoly_t *WaterWarpPolyVerts (glpoly_t *p); -// void EmitWaterPolys (msurface_t *fa); -// void R_AddSkySurface (msurface_t *fa); -// void R_ClearSkyBox (void); -// void R_DrawSkyBox (void); -// void R_MarkLights (dlight_t *light, int bit, mnode_t *node); -// -// -// void COM_StripExtension (char *in, char *out); -// -// void Draw_GetPicSize (int *w, int *h, char *name); -// void Draw_Pic (int x, int y, char *name); -// void Draw_StretchPic (int x, int y, int w, int h, char *name); -// void Draw_Char (int x, int y, int c); -// void Draw_TileClear (int x, int y, int w, int h, char *name); -// void Draw_Fill (int x, int y, int w, int h, int c); -// void Draw_FadeScreen (void); -// void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data); -// -// void R_BeginFrame( float camera_separation ); -// void R_SwapBuffers( int ); -// void R_SetPalette ( const unsigned char *palette); -// -// int Draw_GetPalette (void); -// -// void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight); -// -// struct image_s *R_RegisterSkin (char *name); -// -// void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height); -// image_t *GL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits); -// image_t *GL_FindImage (char *name, imagetype_t type); -// void GL_TextureMode( char *string ); -// void GL_ImageList_f (void); -// -// void GL_SetTexturePalette( unsigned palette[256] ); -// -// void GL_InitImages (void); -// void GL_ShutdownImages (void); -// -// void GL_FreeUnusedImages (void); -// -// void GL_TextureAlphaMode( char *string ); -// void GL_TextureSolidMode( char *string ); -// -// /* -// ** GL extension emulation functions -// */ -// void GL_DrawParticles( int n, const particle_t particles[], const unsigned colortable[768] ); -// - - /* - ** GL config stuff - */ - static final int GL_RENDERER_VOODOO = 0x00000001; - static final int GL_RENDERER_VOODOO2 = 0x00000002; - static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; - static final int GL_RENDERER_BANSHEE = 0x00000008; - static final int GL_RENDERER_3DFX = 0x0000000F; - - static final int GL_RENDERER_PCX1 = 0x00000010; - static final int GL_RENDERER_PCX2 = 0x00000020; - static final int GL_RENDERER_PMX = 0x00000040; - static final int GL_RENDERER_POWERVR = 0x00000070; - - static final int GL_RENDERER_PERMEDIA2 = 0x00000100; - static final int GL_RENDERER_GLINT_MX = 0x00000200; - static final int GL_RENDERER_GLINT_TX = 0x00000400; - static final int GL_RENDERER_3DLABS_MISC = 0x00000800; - static final int GL_RENDERER_3DLABS = 0x00000F00; - - static final int GL_RENDERER_REALIZM = 0x00001000; - static final int GL_RENDERER_REALIZM2 = 0x00002000; - static final int GL_RENDERER_INTERGRAPH = 0x00003000; - - static final int GL_RENDERER_3DPRO = 0x00004000; - static final int GL_RENDERER_REAL3D = 0x00008000; - static final int GL_RENDERER_RIVA128 = 0x00010000; - static final int GL_RENDERER_DYPIC = 0x00020000; - - static final int GL_RENDERER_V1000 = 0x00040000; - static final int GL_RENDERER_V2100 = 0x00080000; - static final int GL_RENDERER_V2200 = 0x00100000; - static final int GL_RENDERER_RENDITION = 0x001C0000; - - static final int GL_RENDERER_O2 = 0x00100000; - static final int GL_RENDERER_IMPACT = 0x00200000; - static final int GL_RENDERER_RE = 0x00400000; - static final int GL_RENDERER_IR = 0x00800000; - static final int GL_RENDERER_SGI = 0x00F00000; - - static final int GL_RENDERER_MCD = 0x01000000; - static final int GL_RENDERER_OTHER = 0x80000000; - - -// typedef struct -// { -// int renderer; -// const char *renderer_string; -// const char *vendor_string; -// const char *version_string; -// const char *extensions_string; -// -// qboolean allow_cds; -// } glconfig_t; -// -// typedef struct -// { -// float inverse_intensity; -// qboolean fullscreen; -// -// int prev_mode; -// -// unsigned char *d_16to8table; -// -// int lightmap_textures; -// -// int currenttextures[2]; -// int currenttmu; -// -// float camera_separation; -// qboolean stereo_enabled; -// -// unsigned char originalRedGammaTable[256]; -// unsigned char originalGreenGammaTable[256]; -// unsigned char originalBlueGammaTable[256]; -// } glstate_t; -// -// /* -// ==================================================================== -// -// IMPORTED FUNCTIONS -// -// ==================================================================== -// */ -// -// extern refimport_t ri; -// -// -// /* -// ==================================================================== -// -// IMPLEMENTATION SPECIFIC FUNCTIONS -// -// ==================================================================== -// */ -// -// void GLimp_BeginFrame( float camera_separation ); -// void GLimp_EndFrame( void ); -// int GLimp_Init( void *hinstance, void *hWnd ); -// void GLimp_Shutdown( void ); -// int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen ); -// void GLimp_AppActivate( qboolean active ); -// void GLimp_EnableLogging( qboolean enable ); -// void GLimp_LogNewFrame( void ); -// - -} + + static final int GL_COLOR_INDEX8_EXT = GL11.GL_COLOR_INDEX; + + static final String REF_VERSION = "GL 0.01"; + + // up / down + static final int PITCH = 0; + + // left / right + static final int YAW = 1; + + // fall over + static final int ROLL = 2; + + /* + * skins will be outline flood filled and mip mapped pics and sprites with + * alpha will be outline flood filled pic won't be mip mapped + * + * model skin sprite frame wall texture pic + */ + // enum imagetype_t + static final int it_skin = 0; + + static final int it_sprite = 1; + + static final int it_wall = 2; + + static final int it_pic = 3; + + static final int it_sky = 4; + + // enum modtype_t + static final int mod_bad = 0; + + static final int mod_brush = 1; + + static final int mod_sprite = 2; + + static final int mod_alias = 3; + + static final int TEXNUM_LIGHTMAPS = 1024; + + static final int TEXNUM_SCRAPS = 1152; + + static final int TEXNUM_IMAGES = 1153; + + static final int MAX_GLTEXTURES = 1024; + + static final int MAX_LBM_HEIGHT = 480; + + static final float BACKFACE_EPSILON = 0.01f; + + /* + * * GL config stuff + */ + static final int GL_RENDERER_VOODOO = 0x00000001; + + static final int GL_RENDERER_VOODOO2 = 0x00000002; + + static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; + + static final int GL_RENDERER_BANSHEE = 0x00000008; + + static final int GL_RENDERER_3DFX = 0x0000000F; + + static final int GL_RENDERER_PCX1 = 0x00000010; + + static final int GL_RENDERER_PCX2 = 0x00000020; + + static final int GL_RENDERER_PMX = 0x00000040; + + static final int GL_RENDERER_POWERVR = 0x00000070; + + static final int GL_RENDERER_PERMEDIA2 = 0x00000100; + + static final int GL_RENDERER_GLINT_MX = 0x00000200; + + static final int GL_RENDERER_GLINT_TX = 0x00000400; + + static final int GL_RENDERER_3DLABS_MISC = 0x00000800; + + static final int GL_RENDERER_3DLABS = 0x00000F00; + + static final int GL_RENDERER_REALIZM = 0x00001000; + + static final int GL_RENDERER_REALIZM2 = 0x00002000; + + static final int GL_RENDERER_INTERGRAPH = 0x00003000; + + static final int GL_RENDERER_3DPRO = 0x00004000; + + static final int GL_RENDERER_REAL3D = 0x00008000; + + static final int GL_RENDERER_RIVA128 = 0x00010000; + + static final int GL_RENDERER_DYPIC = 0x00020000; + + static final int GL_RENDERER_V1000 = 0x00040000; + + static final int GL_RENDERER_V2100 = 0x00080000; + + static final int GL_RENDERER_V2200 = 0x00100000; + + static final int GL_RENDERER_RENDITION = 0x001C0000; + + static final int GL_RENDERER_O2 = 0x00100000; + + static final int GL_RENDERER_IMPACT = 0x00200000; + + static final int GL_RENDERER_RE = 0x00400000; + + static final int GL_RENDERER_IR = 0x00800000; + + static final int GL_RENDERER_SGI = 0x00F00000; + + static final int GL_RENDERER_MCD = 0x01000000; + + static final int GL_RENDERER_OTHER = 0x80000000; +}
\ No newline at end of file diff --git a/src/jake2/render/lwjgl/Mesh.java b/src/jake2/render/lwjgl/Mesh.java index db5faba..ab5e409 100644 --- a/src/jake2/render/lwjgl/Mesh.java +++ b/src/jake2/render/lwjgl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.7 2005-05-07 23:44:37 cawe Exp $ + * $Id: Mesh.java,v 1.8 2005-06-08 21:27:10 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -86,28 +86,30 @@ public abstract class Mesh extends Light { if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) { float[] normal; - int j = -1; + int j = 0; for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { vv = v[i]; normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; ovv = ov[i]; - lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + j += 3; } } else { - int j = -1; + int j = 0; for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ovv = ov[i]; vv = v[i]; - lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); - lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); - lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + j += 3; } } } @@ -191,16 +193,17 @@ public abstract class Mesh extends Light { // pre light everything // FloatBuffer color = colorArrayBuf; - int j = -1; float l; int size = paliashdr.num_xyz; + int j = 0; for (int i = 0; i < size; i++ ) { l = shadedots[(verts[i] >>> 24) & 0xFF]; - color.put(++j, l * shadelight[0]); - color.put(++j, l * shadelight[1]); - color.put(++j, l * shadelight[2]); - color.put(++j, alpha); + color.put(j, l * shadelight[0]); + color.put(j + 1, l * shadelight[1]); + color.put(j + 2, l * shadelight[2]); + color.put(j + 3, alpha); + j += 4; } } diff --git a/src/jake2/render/lwjgl/Surf.java b/src/jake2/render/lwjgl/Surf.java index 40e9bcf..3ab5ae7 100644 --- a/src/jake2/render/lwjgl/Surf.java +++ b/src/jake2/render/lwjgl/Surf.java @@ -2,7 +2,7 @@ * Surf.java * Copyright (C) 2003 * - * $Id: Surf.java,v 1.8 2005-02-01 16:55:28 cawe Exp $ + * $Id: Surf.java,v 1.9 2005-06-08 21:27:10 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -940,12 +940,12 @@ public abstract class Surf extends Draw { System.arraycopy(vis, 0, fatvis, 0, (r_worldmodel.numleafs+7) >> 3); vis = Mod_ClusterPVS(r_viewcluster2, r_worldmodel); c = (r_worldmodel.numleafs + 31) >> 5; - int k = -1; - for (i=0 ; i<c ; i++) { - fatvis[++k] |= vis[k]; - fatvis[++k] |= vis[k]; - fatvis[++k] |= vis[k]; - fatvis[++k] |= vis[k]; + c <<= 2; + for (int k=0 ; k<c ; k+=4) { + fatvis[k] |= vis[k]; + fatvis[k + 1] |= vis[k + 1]; + fatvis[k + 2] |= vis[k + 2]; + fatvis[k + 3] |= vis[k + 3]; } vis = fatvis; diff --git a/src/jake2/sound/S.java b/src/jake2/sound/S.java index 8295c8b..8a3e133 100644 --- a/src/jake2/sound/S.java +++ b/src/jake2/sound/S.java @@ -2,7 +2,7 @@ * S.java * Copyright (C) 2003 * - * $Id: S.java,v 1.10 2005-02-07 17:23:50 cawe Exp $ + * $Id: S.java,v 1.11 2005-05-26 16:56:33 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -92,7 +92,7 @@ public class S { } } // if driver not found use dummy - impl = (Sound)drivers.firstElement(); + impl = (Sound)drivers.lastElement(); } public static void Init() { diff --git a/src/jake2/sys/InputListener.java b/src/jake2/sys/InputListener.java index 2e2b57d..8cbe2ae 100644 --- a/src/jake2/sys/InputListener.java +++ b/src/jake2/sys/InputListener.java @@ -2,7 +2,7 @@ * InputListener.java * Copyright (C) 2004 * - * $Id: InputListener.java,v 1.4 2004-12-14 00:11:01 hzi Exp $ + * $Id: InputListener.java,v 1.6 2005-06-06 18:22:20 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -52,7 +52,9 @@ public final class InputListener implements KeyListener, MouseListener, } public void keyPressed(KeyEvent e) { - addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e)); + if (!((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0)) { + addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e)); + } } public void keyReleased(KeyEvent e) { @@ -60,6 +62,10 @@ public final class InputListener implements KeyListener, MouseListener, } public void keyTyped(KeyEvent e) { + if ((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { + addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e)); + addEvent(new Jake2InputEvent(Jake2InputEvent.KeyRelease, e)); + } } public void mouseClicked(MouseEvent e) { diff --git a/src/jake2/sys/JOGLKBD.java b/src/jake2/sys/JOGLKBD.java index 194500f..5f08133 100644 --- a/src/jake2/sys/JOGLKBD.java +++ b/src/jake2/sys/JOGLKBD.java @@ -197,11 +197,8 @@ final public class JOGLKBD extends KBD case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break; default: - if ((ev.getModifiers() & (InputEvent.ALT_MASK | InputEvent.CTRL_MASK)) != 0) { - key = ev.getKeyCode(); - } else { - key = ev.getKeyChar(); - } + key = ev.getKeyChar(); + if (key >= 'A' && key <= 'Z') key = key - 'A' + 'a'; break; diff --git a/src/jake2/sys/LWJGLKBD.java b/src/jake2/sys/LWJGLKBD.java index 2cb8e27..cdcfcca 100644 --- a/src/jake2/sys/LWJGLKBD.java +++ b/src/jake2/sys/LWJGLKBD.java @@ -1,6 +1,7 @@ package jake2.sys; import jake2.Defines; +import jake2.Globals; import jake2.client.Key; import jake2.qcommon.Cbuf; @@ -14,6 +15,7 @@ import org.lwjgl.opengl.Display; public class LWJGLKBD extends KBD { private char[] lwjglKeycodeMap = null; + private int pressed[] = null; private boolean mouseHasTwoButtons = false; @@ -29,9 +31,11 @@ public class LWJGLKBD extends KBD { if (!Mouse.isBuffered()) Mouse.enableBuffer(); if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; + if (pressed == null) pressed = new int[256]; mouseHasTwoButtons = (Mouse.getButtonCount() == 2); + lastRepeat = Sys.Milliseconds(); } catch (Exception e) {;} } @@ -45,6 +49,7 @@ public class LWJGLKBD extends KBD { Mouse.destroy(); // free the memory for GC lwjglKeycodeMap = null; + pressed = null; } private void HandleEvents() @@ -65,11 +70,18 @@ public class LWJGLKBD extends KBD { // fill the character translation table // this is needed because the getEventCharacter() returns \0 if a key is released // keycode is correct but the charachter value is not - if (down) lwjglKeycodeMap[key] = ch; - + if (down) { + lwjglKeycodeMap[key] = ch; + pressed[key] = Globals.sys_frame_time; + } else { + pressed[key] = 0; + } + Do_Key_Event(XLateKey(key,ch), down); } + generateRepeats(); + if (IN.mouse_active) { mx = Mouse.getDX() << 1; @@ -98,6 +110,18 @@ public class LWJGLKBD extends KBD { } } + private static int lastRepeat; + private void generateRepeats() { + int time = Globals.sys_frame_time; + if (time - lastRepeat > 50) { + for (int i = 0; i < pressed.length; i++) { + if (pressed[i] > 0 && time - pressed[i] > 500) + Do_Key_Event(XLateKey(i, lwjglKeycodeMap[i]), true); + } + lastRepeat = time; + } + } + private int XLateKey(int code, int ch) { int key = 0; diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java index 4f709d4..51829c1 100644 --- a/src/jake2/util/Lib.java +++ b/src/jake2/util/Lib.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.12.2003 by RST. -// $Id: Lib.java,v 1.12 2005-01-09 23:41:53 cawe Exp $ +// $Id: Lib.java,v 1.13 2005-05-26 16:56:31 hzi Exp $ package jake2.util; @@ -89,7 +89,11 @@ public class Lib { return Integer.parseInt(in); } catch (Exception e) { - return 0; + try { + return (int)Double.parseDouble(in); + } catch (Exception e1) { + return 0; + } } } public static float[] atov(String v) { diff --git a/test/jake2/render/DancingQueens.java b/test/jake2/render/DancingQueens.java index 194ee18..902a37e 100644 --- a/test/jake2/render/DancingQueens.java +++ b/test/jake2/render/DancingQueens.java @@ -2,242 +2,227 @@ * DancingQueens.java * Copyright (C) 2003 * - * $Id: DancingQueens.java,v 1.7 2005-02-09 09:21:10 cawe Exp $ + * $Id: DancingQueens.java,v 1.8 2005-06-11 19:43:48 cawe Exp $ */ /* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ package jake2.render; import jake2.Defines; import jake2.Globals; import jake2.client.*; import jake2.game.Cmd; -import jake2.game.cvar_t; import jake2.qcommon.*; import jake2.sys.IN; import jake2.sys.KBD; import jake2.util.Math3D; -import jake2.util.Vargs; -import java.awt.Dimension; import java.util.Arrays; - /** * DancingQueens - * + * * @author cwei */ -public class DancingQueens -{ - String[] args; - - refexport_t re; - viddef_t viddef; - int framecount = 0; - - public DancingQueens(String[] args) { - this.args = args; - } - - public static void main(String[] args) { - - DancingQueens test = new DancingQueens(args); - test.init(); - test.run(); - } - - KBD kbd; - - void init() { - - Qcommon.Init(new String[] {"DancingQueens", "+set", "s_initsound", "0", "+set", "vid_ref", "lwjgl"}); - // sehr wichtig !!! - VID.Shutdown(); - - String[] names = Renderer.getDriverNames(); - System.out.println("Registered Drivers: " + Arrays.asList(names)); - - this.re = Renderer.getDriver("lwjgl"); - - System.out.println("Use driver: " + re); - System.out.println(); - - re.Init(0, 0); - kbd = re.getKeyboardHandler(); - kbd.Init(); - - Cmd.AddCommand("togglemouse", togglemouse); - Cbuf.AddText("bind t togglemouse"); - Cbuf.Execute(); - Globals.cls.key_dest = Defines.key_game; - Globals.cls.state = Defines.ca_active; - - viddef = Globals.viddef; - fov_y = Math3D.CalcFov(fov_x, viddef.width, viddef.height); - } - - float fps = 0.0f; - long start = 0; - - void updateScreen() - { - re.BeginFrame(0.0f); - - if (framecount % 500 == 0) - { - long time = System.currentTimeMillis(); - fps = 500000.0f / (time - start); - start = time; - } - String text = fps + " fps"; - - testModel(); - - drawString(10, viddef.height - 16, text); - - re.EndFrame(); - framecount++; - } - - long startTime; - - void run() - { - startTime = System.currentTimeMillis(); - xcommand_t callback = new xcommand_t() { - public void execute() { - updateScreen(); - } - }; - while (true) - { - re.updateScreen(callback); - kbd.Update(); - Cbuf.Execute(); - } - } - -// =================================================================== - - private float yaw = 0; - private entity_t[] models; - - private final static String[] skinNames = { - "players/female/athena", - "players/female/lotus", - "players/female/venus", - "players/female/voodoo", - "players/female/cobalt", - "players/female/lotus", - "players/female/brianna" - }; - - private float fov_x = 50; - private float fov_y; - - private void testModel() { - - refdef_t refdef = new refdef_t(); - - refdef.x = 0; - refdef.y = 0; - refdef.width = viddef.width; - refdef.height = viddef.height; - refdef.fov_x = fov_x; - refdef.fov_y = fov_y; - refdef.time = 1.0f * 0.001f; - - if (models == null) { - models = new entity_t[12]; // model count - entity_t m = null; - for (int i = 0; i < models.length; i++) - { - m = getModel(skinNames[i % skinNames.length]); - m.origin[0] += 30 * i; - m.origin[1] += ((i % 4)) * 30 - 20; - models[i] = m; - } - } - - - yaw = time() * 0.1f; - if (yaw > 360) - yaw -= 360; - if (yaw < 0) - yaw += 360; - - for (int i = 0; i < models.length; i++) - { - models[i].frame = (time() / 70) % models[i].model.numframes; - models[i].angles[1] = yaw; - models[i].origin[0] += KBD.my; - models[i].origin[1] += KBD.mx; - - } - - refdef.areabits = null; - refdef.num_entities = models.length; - refdef.entities = models; - - refdef.lightstyles = null; - refdef.rdflags = Defines.RDF_NOWORLDMODEL; - - re.RenderFrame(refdef); - } - - private entity_t getModel(String name) { - entity_t entity = new entity_t(); - String modelName = "players/female/tris.md2"; - String modelSkin = name +".pcx"; - - entity.model = re.RegisterModel(modelName); - entity.skin = re.RegisterSkin(modelSkin); - entity.flags = Defines.RF_FULLBRIGHT; - entity.origin[0] = 80; - entity.origin[1] = 0; - entity.origin[2] = 0; - Math3D.VectorCopy(entity.origin, entity.oldorigin); - entity.frame = 0; - entity.oldframe = 0; - entity.backlerp = 0.0f; - return entity; - } - - - private void drawString(int x, int y, String text) - { - for (int i = 0; i < text.length(); i++) - { - re.DrawChar(x + 8 * i, y, (int) text.charAt(i)); - } - } - - private final int time() - { - return (int) (System.currentTimeMillis() - startTime); - } - - static xcommand_t togglemouse = new xcommand_t() { - public void execute() { - IN.toggleMouse(); - } - }; +public class DancingQueens { + String[] args; + + refexport_t re; + + viddef_t viddef; + + int framecount = 0; + + public DancingQueens(String[] args) { + this.args = args; + } + + public static void main(String[] args) { + + DancingQueens test = new DancingQueens(args); + test.init(); + test.run(); + } + + KBD kbd; + + void init() { + + Qcommon.Init(new String[] { "DancingQueens", "+set", "gl_mode", "5", + "+set", "vid_fullscreen", "0" }); + // sehr wichtig !!! + VID.Shutdown(); + + String[] names = Renderer.getDriverNames(); + System.out.println("Registered Drivers: " + Arrays.asList(names)); + + this.re = Renderer.getDriver("fastjogl"); + + System.out.println("Use driver: " + re); + System.out.println(); + + re.Init(0, 0); + kbd = re.getKeyboardHandler(); + kbd.Init(); + + Cmd.AddCommand("togglemouse", togglemouse); + Cbuf.AddText("bind t togglemouse"); + Cbuf.Execute(); + Globals.cls.key_dest = Defines.key_game; + Globals.cls.state = Defines.ca_active; + + viddef = Globals.viddef; + fov_y = Math3D.CalcFov(fov_x, viddef.width, viddef.height); + } + + float fps = 0.0f; + + long start = 0; + + void updateScreen() { + re.BeginFrame(0.0f); + + if (framecount % 500 == 0) { + long time = System.currentTimeMillis(); + fps = 500000.0f / (time - start); + start = time; + } + String text = ((int)(fps + 0.5f)) + " fps"; + + testModel(); + + drawString(10, viddef.height - 16, text); + + re.EndFrame(); + framecount++; + } + + long startTime; + + void run() { + startTime = System.currentTimeMillis(); + xcommand_t callback = new xcommand_t() { + public void execute() { + updateScreen(); + } + }; + while (true) { + re.updateScreen(callback); + kbd.Update(); + Cbuf.Execute(); + } + } + + // =================================================================== + + private float yaw = 0; + + private entity_t[] models; + + private final static String[] skinNames = { "players/female/athena", + "players/female/lotus", "players/female/venus", + "players/female/voodoo", "players/female/cobalt", + "players/female/lotus", "players/female/brianna" }; + + private float fov_x = 50; + + private float fov_y; + + private void testModel() { + + refdef_t refdef = new refdef_t(); + + refdef.x = 0; + refdef.y = 0; + refdef.width = viddef.width; + refdef.height = viddef.height; + refdef.fov_x = fov_x; + refdef.fov_y = fov_y; + refdef.time = 1.0f * 0.001f; + + if (models == null) { + models = new entity_t[12]; // model count + entity_t m = null; + for (int i = 0; i < models.length; i++) { + m = getModel(skinNames[i % skinNames.length]); + m.origin[0] += 30 * i; + m.origin[1] += ((i % 4)) * 30 - 20; + models[i] = m; + } + } + + yaw = time() * 0.1f; + if (yaw > 360) + yaw -= 360; + if (yaw < 0) + yaw += 360; + + for (int i = 0; i < models.length; i++) { + models[i].frame = (time() / 70) % models[i].model.numframes; + models[i].angles[1] = yaw; + models[i].origin[0] += KBD.my; + models[i].origin[1] += KBD.mx; + + } + + refdef.areabits = null; + refdef.num_entities = models.length; + refdef.entities = models; + + refdef.lightstyles = null; + refdef.rdflags = Defines.RDF_NOWORLDMODEL; + + re.RenderFrame(refdef); + } + + private entity_t getModel(String name) { + entity_t entity = new entity_t(); + String modelName = "players/female/tris.md2"; + String modelSkin = name + ".pcx"; + + entity.model = re.RegisterModel(modelName); + entity.skin = re.RegisterSkin(modelSkin); + entity.flags = Defines.RF_FULLBRIGHT; + entity.origin[0] = 80; + entity.origin[1] = 0; + entity.origin[2] = 0; + Math3D.VectorCopy(entity.origin, entity.oldorigin); + entity.frame = 0; + entity.oldframe = 0; + entity.backlerp = 0.0f; + return entity; + } + + private void drawString(int x, int y, String text) { + for (int i = 0; i < text.length(); i++) { + re.DrawChar(x + 8 * i, y, (int) text.charAt(i)); + } + } + + private final int time() { + return (int) (System.currentTimeMillis() - startTime); + } + + static xcommand_t togglemouse = new xcommand_t() { + public void execute() { + IN.toggleMouse(); + } + }; }
\ No newline at end of file diff --git a/test/jake2/render/TestRenderer.java b/test/jake2/render/TestRenderer.java index b138bac..870e131 100644 --- a/test/jake2/render/TestRenderer.java +++ b/test/jake2/render/TestRenderer.java @@ -2,37 +2,37 @@ * TestRenderer.java * Copyright (C) 2003 * - * $Id: TestRenderer.java,v 1.6 2004-12-14 01:08:32 cawe Exp $ + * $Id: TestRenderer.java,v 1.7 2005-06-11 19:43:48 cawe Exp $ */ /* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ + Copyright (C) 1997-2001 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ package jake2.render; import jake2.Defines; import jake2.Globals; import jake2.client.*; import jake2.game.Cmd; -import jake2.game.cvar_t; import jake2.qcommon.*; import jake2.sys.KBD; -import jake2.util.*; +import jake2.util.Lib; +import jake2.util.Math3D; import java.awt.Dimension; import java.nio.FloatBuffer; @@ -44,711 +44,679 @@ import java.util.*; * @author cwei */ public class TestRenderer { - - String[] args; - - refexport_t re; - viddef_t viddef; - int framecount = 0; - static int testnr = 0; - - public TestRenderer(String[] args) { - this.args = args; - } - - public static void main(String[] args) { - - TestRenderer test = new TestRenderer(args); - test.init(); - test.run(); - } - - void init() { - - Qcommon.Init(new String[] {"TestRenderer"}); - // sehr wichtig !!! - VID.Shutdown(); - - String[] names = Renderer.getDriverNames(); - System.out.println("Registered Drivers: " + Arrays.asList(names)); - - this.re = Renderer.getDriver("jogl"); - - System.out.println("Use driver: " + re); - System.out.println(); - - re.Init(0, 0); - -// for (int i = 0; i < raw.length; i++) { -// raw[i] = (byte)((i % 3) + 1); //((i % 4) + 20); -// } - Cmd.AddCommand("nexttest", nexttest); - Cbuf.AddText("bind n nexttest"); - Cbuf.Execute(); - Globals.cls.key_dest = Defines.key_game; - Globals.cls.state = Defines.ca_active; - } - - float fps = 0.0f; - long start = 0; - - void updateScreen() { - re.BeginFrame(0.0f); - viddef = Globals.viddef; - re.DrawStretchPic(0,0,viddef.width, viddef.height, "conback"); - - if (framecount % 500 == 0) { - long time = System.currentTimeMillis(); - fps = 500000.0f / (time - start); - start = time; - } - String text = fps + " fps"; - - for (int i = 0; i < text.length(); i++) { - re.DrawChar(10 + 8 * i, viddef.height/2, (int)text.charAt(i)); - } - - Dimension wal = new Dimension(); - re.DrawGetPicSize(wal, "/textures/e1u1/basemap.wal"); - - re.DrawPic(0, viddef.height - wal.height, "/textures/e1u1/basemap.wal"); - - switch (testnr) { - case 0 : - testParticles(); - break; - case 1 : - testModel(); - break; - case 2 : - testSprites(); - break; - case 3: - testBeam(); - } - re.EndFrame(); - framecount++; - } - - - long startTime; - - void run() { - startTime = System.currentTimeMillis(); - xcommand_t callback = new xcommand_t() { - public void execute() { - updateScreen(); - } - }; - while (true) { - re.updateScreen(callback); - re.getKeyboardHandler().Update(); - Cbuf.Execute(); - try { - Thread.sleep(5); - } catch (InterruptedException e) { - } - } - } - -// =================================================================== - - private int yaw = 0; - - private void testModel() { - - refdef_t refdef = new refdef_t(); - - refdef.x = viddef.width/ 2; - refdef.y = viddef.height / 2 - 72; - refdef.width = 144 * 2; - refdef.height = 168 * 2; - refdef.fov_x = 40; - refdef.fov_y = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); - refdef.time = 1.0f * 0.001f; - - int maxframe = 29; - entity_t entity = new entity_t(); - String modelName = "players/female/tris.md2"; - - String modelSkin = "players/female/athena.pcx"; - - String modelImage = "/players/female/athena_i.pcx"; - String modelImage1 = "/players/female/brianna_i.pcx"; - String modelImage2 = "/players/female/cobalt_i.pcx"; - String modelImage3 = "/players/female/lotus_i.pcx"; - - entity.model = re.RegisterModel(modelName); - - drawString(refdef.x, refdef.y - 20, (entity.model != null) ? modelName : "DEBUG: NullModel"); - - entity.skin = re.RegisterSkin(modelSkin); - entity.flags = Defines.RF_FULLBRIGHT; - entity.origin[0] = 80; - entity.origin[1] = 0; - entity.origin[2] = 0; - Math3D.VectorCopy(entity.origin, entity.oldorigin); - entity.frame = (framecount / 3) % ((qfiles.dmdl_t)entity.model.extradata).num_frames; - entity.oldframe = 0; - entity.backlerp = 0.0f; - yaw+=KBD.mx; - KBD.mx = 0; - if (yaw > 360) - yaw -= 360; - if (yaw < 0) - yaw += 360; - entity.angles[1] = yaw; - - - refdef.areabits = null; - refdef.num_entities = 1; - refdef.entities = new entity_t[] { entity }; - refdef.lightstyles = null; - refdef.rdflags = Defines.RDF_NOWORLDMODEL; - - // Menu_Draw(& s_player_config_menu); - - M_DrawTextBox( - (int) ((refdef.x) * (320.0F / viddef.width) - 8), - (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), - refdef.width / 8, - refdef.height / 8); - refdef.height += 4; - - re.RenderFrame(refdef); - - re.DrawPic(refdef.x - 80, refdef.y, modelImage); - re.DrawPic(refdef.x - 80, refdef.y + 47, modelImage1); - re.DrawPic(refdef.x - 80, refdef.y + 94, modelImage2); - re.DrawPic(refdef.x - 80, refdef.y + 141, modelImage3); - } - - - private String[] sprites = { - "sprites/s_bfg1.sp2", - "sprites/s_bfg2.sp2", - "sprites/s_bfg3.sp2", - "sprites/s_explod.sp2", - "sprites/s_explo2.sp2", - "sprites/s_explo3.sp2", - "sprites/s_flash.sp2", - "sprites/s_bubble.sp2", - }; - - private int spriteCount = 0; - private boolean loading = true; - - private void testSprites() { - - if (loading) { - - re.DrawPic(viddef.width / 2 - 50, viddef.height / 2, "loading"); - String name = sprites[spriteCount]; - - drawString(viddef.width / 2 - 50, viddef.height / 2 + 50, name); - - re.RegisterModel(name); - loading = ++spriteCount < sprites.length; - return; - } - - - refdef_t refdef = new refdef_t(); - - refdef.x = viddef.width/ 2; - refdef.y = viddef.height / 2 - 72; - refdef.width = 144 * 2; - refdef.height = 168 * 2; - refdef.fov_x = 40; - refdef.fov_y = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); - refdef.time = 1.0f * 0.001f; - - int maxframe = 29; - entity_t entity = new entity_t(); - - String modelName = sprites[(framecount / 30) % sprites.length]; - drawString(refdef.x, refdef.y - 20, modelName); - - entity.model = re.RegisterModel(modelName); - - entity.flags = Defines.RF_FULLBRIGHT; - entity.origin[0] = 80 - (framecount % 200) + 200; - entity.origin[1] = 0 + (float)(40 * Math.sin(Math.toRadians(framecount))); - entity.origin[2] = 0 + 20; - Math3D.VectorCopy(entity.origin, entity.oldorigin); - entity.frame = framecount / 2; - entity.oldframe = 0; - entity.backlerp = 0.0f; - - refdef.areabits = null; - refdef.num_entities = 1; - refdef.entities = new entity_t[] { entity }; - refdef.lightstyles = null; - refdef.rdflags = Defines.RDF_NOWORLDMODEL; - - M_DrawTextBox( - (int) ((refdef.x) * (320.0F / viddef.width) - 8), - (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), - refdef.width / 8, - refdef.height / 8); - refdef.height += 4; - - re.RenderFrame(refdef); - - } - - private void testBeam() { - - refdef_t refdef = new refdef_t(); - - refdef.x = viddef.width/ 2; - refdef.y = viddef.height / 2 - 72; - refdef.width = 144 * 2; - refdef.height = 168 * 2; - refdef.fov_x = 40; - refdef.fov_y = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); - refdef.time = 1.0f * 0.001f; - - int maxframe = 29; - entity_t entity = new entity_t(); - - drawString(refdef.x, refdef.y - 20, "Beam Test"); - - entity.flags = Defines.RF_BEAM; - entity.origin[0] = 200; - entity.origin[1] = 0 + (float)(80 * Math.sin(4 * Math.toRadians(framecount))); - entity.origin[2] = 20 + (float)(40 * Math.cos(4 * Math.toRadians(framecount))); - - entity.oldorigin[0] = 20; - entity.oldorigin[1] = 0; // + (float)(40 * Math.sin(Math.toRadians(framecount))); - entity.oldorigin[2] = -20; // + 20; - - entity.frame = 3; - entity.oldframe = 0; - entity.backlerp = 0.0f; - // the four beam colors are encoded in 32 bits of skinnum (hack) - entity.alpha = 0.6f; - - int[] color = { 0xd0, 0xd1, 0xe0, 0xb0 }; - - entity.skinnum = color[framecount / 2 % 4]; - entity.model = null; - - refdef.areabits = null; - refdef.num_entities = 1; - refdef.entities = new entity_t[] { entity }; - refdef.lightstyles = null; - refdef.rdflags = Defines.RDF_NOWORLDMODEL; - - M_DrawTextBox( - (int) ((refdef.x) * (320.0F / viddef.width) - 8), - (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), - refdef.width / 8, - refdef.height / 8); - refdef.height += 4; - - re.RenderFrame(refdef); - } - - private LinkedList active_particles = new LinkedList(); - private boolean explode = false; - private float[] target; - - private boolean initParticles = true; - - private void testParticles() { - - r_numparticles = 0; - - if (active_particles.size() == 0) { - if (explode) - Explosion(target); - else { - target = new float[] {150 + Lib.crand() * 80, Lib.crand() * 40, Lib.crand() * 40}; - RailTrail(new float[]{30, -20, -20}, target); - //Heatbeam(new float[]{30, 20, -20}, target); - } - explode = !explode; - } - refdef_t refdef = new refdef_t(); - - refdef.x = viddef.width/ 2; - refdef.y = viddef.height / 2 - 72; - refdef.width = 400; - refdef.height = 400; - refdef.fov_x = 50; - refdef.fov_y = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); - refdef.time = 1.0f * 0.001f; - - animateParticles(); - - drawString(refdef.x, refdef.y - 20, "active particles: " + r_numparticles); - - refdef.num_particles = r_numparticles; - - refdef.areabits = null; - refdef.num_entities = 0; - refdef.entities = null; - refdef.lightstyles = null; - refdef.rdflags = Defines.RDF_NOWORLDMODEL; - - M_DrawTextBox( - (int) ((refdef.x) * (320.0F / viddef.width) - 8), - (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), - refdef.width / 8, - refdef.height / 8); - refdef.height += 4; - - re.RenderFrame(refdef); - } - - private void drawString(int x, int y, String text) { - for (int i = 0; i < text.length(); i++) { - re.DrawChar(x + 8 * i, y, (int)text.charAt(i)); - } - } - - - private void M_DrawTextBox(int x, int y, int width, int lines) { - int cx, cy; - int n; - - // draw left side - cx = x; - cy = y; - M_DrawCharacter(cx, cy, 1); - for (n = 0; n < lines; n++) { - cy += 8; - M_DrawCharacter(cx, cy, 4); - } - M_DrawCharacter(cx, cy + 8, 7); - - // draw middle - cx += 8; - while (width > 0) { - cy = y; - M_DrawCharacter(cx, cy, 2); - for (n = 0; n < lines; n++) { - cy += 8; - M_DrawCharacter(cx, cy, 5); - } - M_DrawCharacter(cx, cy + 8, 8); - width -= 1; - cx += 8; - } - - // draw right side - cy = y; - M_DrawCharacter(cx, cy, 3); - for (n = 0; n < lines; n++) { - cy += 8; - M_DrawCharacter(cx, cy, 6); - } - M_DrawCharacter(cx, cy + 8, 9); - } - - /* - ================ - M_DrawCharacter - - Draws one solid graphics character - cx and cy are in 320*240 coordinates, and will be centered on - higher res screens. - ================ - */ - private void M_DrawCharacter(int cx, int cy, int num) { - re.DrawChar( - cx + ((viddef.width - 320) >> 1), - cy + ((viddef.height - 240) >> 1), - num); - } - - long endtime; - - private void Explosion(float[] org) { - float[] dir = {0, 0, 0}; - int i; - cparticle_t p; - - for(i=0; i<256; i++) - { - p = new cparticle_t(); - - p.time = time() * 1.0f; - p.color = /*0xe0*/ 223 - (Lib.rand() & 7); - for (int j=0 ; j<3 ; j++) - { - p.org[j] = org[j] + (float)(Lib.rand() % 32) - 16; - p.vel[j] = (float)(Lib.rand() % 384) - 192; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - - active_particles.add(p); - } - } - - static final float INSTANT_PARTICLE = -10000.0f; - static final float PARTICLE_GRAVITY = 40.0f; - - - /* - =============== - CL_AddParticles - =============== - */ - private void animateParticles() - { - cparticle_t p; - float alpha; - float time, time2; - float[] org = {0, 0, 0}; - int color; - - time = 0.0f; - - for (Iterator it = active_particles.iterator(); it.hasNext();) - { - p = (cparticle_t) it.next(); - - // PMM - added INSTANT_PARTICLE handling for heat beam - if (p.alphavel != INSTANT_PARTICLE) - { - time = (time() - p.time) * 0.001f; - alpha = p.alpha + time*p.alphavel; - if (alpha <= 0) - { // faded out - it.remove(); - continue; - } - } - else - { - alpha = p.alpha; - } - - if (alpha > 1.0) - alpha = 1; - color = (int)p.color; - - time2 = time*time; - - org[0] = p.org[0] + p.vel[0]*time + p.accel[0]*time2; - org[1] = p.org[1] + p.vel[1]*time + p.accel[1]*time2; - org[2] = p.org[2] + p.vel[2]*time + p.accel[2]*time2; - - AddParticle(org, color, alpha); - - // PMM - if (p.alphavel == INSTANT_PARTICLE) - { - p.alphavel = 0.0f; - p.alpha = 0.0f; - } - } - } - - private void Heatbeam (float[] start, float[] forward) - { - - float[] v_up = {0, 0, 10}; - float[] v_right = {0, 10, 0}; - - - float[] move = {0, 0, 0}; - float[] vec = {0, 0, 0}; - float len; - int j; - cparticle_t p; - float[] right = {0, 0, 0}; - float[] up = {0, 0, 0}; - int i; - float c, s; - float[] dir = {0, 0, 0}; - float ltime; - float step = 32.0f, rstep; - float start_pt; - float rot; - float variance; - float[] end = {0, 0, 0}; - - Math3D.VectorMA (start, 4096, forward, end); - - Math3D.VectorCopy (start, move); - Math3D.VectorSubtract (end, start, vec); - len = Math3D.VectorNormalize (vec); - - Math3D.VectorCopy (v_right, right); - Math3D.VectorCopy (v_up, up); -// if (vidref_val == VIDREF_GL) -// { // GL mode - Math3D.VectorMA (move, -0.5f, right, move); - Math3D.VectorMA (move, -0.5f, up, move); -// } -// // otherwise assume SOFT - - ltime = (float)time()/1000.0f; - start_pt = (ltime*96.0f) % step; - Math3D.VectorMA (move, start_pt, vec, move); - - Math3D.VectorScale (vec, step, vec); - - rstep = (float)Math.PI / 10.0f; - for (i=(int)start_pt ; i<len ; i+=step) - { - if (i>step*5) // don't bother after the 5th ring - break; - - for (rot = 0; rot < Math.PI * 2; rot += rstep) - { - - p = new cparticle_t(); - - p.time = time(); - Math3D.VectorClear (p.accel); - variance = 0.5f; - c = (float)Math.cos(rot)*variance; - s = (float)Math.sin(rot)*variance; - - // trim it so it looks like it's starting at the origin - if (i < 10) - { - Math3D.VectorScale (right, c*(i/10.0f), dir); - Math3D.VectorMA (dir, s*(i/10.0f), up, dir); - } - else - { - Math3D.VectorScale (right, c, dir); - Math3D.VectorMA (dir, s, up, dir); - } - - p.alpha = 0.8f; - p.alphavel = -1000.0f; - p.color = /* 223 */0x74 - (Lib.rand()&7); - for (j=0 ; j<3 ; j++) - { - p.org[j] = move[j] + dir[j]*3; - p.vel[j] = 0; - } - - active_particles.add(p); - } - Math3D.VectorAdd (move, vec, move); - } - } - - private void RailTrail(float[] start, float[] end) - { - float[] move = {0, 0, 0}; - float[] vec = {0, 0, 0}; - float len; - int j; - cparticle_t p; - float dec; - float[] right = {0, 0, 0}; - float[] up = {0, 0, 0}; - int i; - float d, c, s; - float[] dir = {0, 0, 0}; - - Math3D.VectorCopy (start, move); - Math3D.VectorSubtract (end, start, vec); - len = Math3D.VectorNormalize(vec); - - Math3D.MakeNormalVectors(vec, right, up); - - for (i=0 ; i<len ; i++) - { - - p = new cparticle_t(); - p.time = time(); - Math3D.VectorClear (p.accel); - - d = i * 0.1f; - c = (float)Math.cos(d); - s = (float)Math.sin(d); - - Math3D.VectorScale (right, c, dir); - Math3D.VectorMA (dir, s, up, dir); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.2f); - p.color = 0x74 + (Lib.rand() & 7); - for (j=0 ; j<3 ; j++) - { - p.org[j] = move[j] + dir[j]*3; - p.vel[j] = dir[j]*6; - } - - Math3D.VectorAdd (move, vec, move); - - active_particles.add(p); - } - - dec = 0.75f; - Math3D.VectorScale (vec, dec, vec); - Math3D.VectorCopy (start, move); - - while (len > 0) - { - len -= dec; - - p = new cparticle_t(); - - p.time = time(); - Math3D.VectorClear (p.accel); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0x0 + Lib.rand()&15; - - for (j=0 ; j<3 ; j++) - { - p.org[j] = move[j] + Lib.crand()*3; - p.vel[j] = Lib.crand()*3; - p.accel[j] = 0; - } - - Math3D.VectorAdd (move, vec, move); - active_particles.add(p); - } - } - - private int time() { - return (int)(System.currentTimeMillis() - startTime); - } - - static xcommand_t nexttest = new xcommand_t() { - public void execute() { - testnr++; - testnr = testnr % 3; - } - }; - - int r_numparticles = 0; - /* - ===================== - V_AddParticle - - ===================== - */ - void AddParticle(float[] org, int color, float alpha) { - if (r_numparticles >= Defines.MAX_PARTICLES) - return; - - int i = r_numparticles++; - - int c = particle_t.colorTable[color]; - c |= (int)(alpha * 255) << 24; - particle_t.colorArray.put(i, c); - - i *= 3; - FloatBuffer vertexBuf = particle_t.vertexArray; - vertexBuf.put(i++, org[0]); - vertexBuf.put(i++, org[1]); - vertexBuf.put(i++, org[2]); - } -} + + String[] args; + + refexport_t re; + + viddef_t viddef; + + int framecount = 0; + + static int testnr = 0; + + public TestRenderer(String[] args) { + this.args = args; + } + + public static void main(String[] args) { + + TestRenderer test = new TestRenderer(args); + test.init(); + test.run(); + } + + void init() { + + Qcommon.Init(new String[] { "TestRenderer", "+set", "gl_mode", "5", + "+set", "vid_fullscreen", "0" }); + + // very important + VID.Shutdown(); + + String[] names = Renderer.getDriverNames(); + System.out.println("Registered Drivers: " + Arrays.asList(names)); + + this.re = Renderer.getDriver("jogl"); + + System.out.println("Use driver: " + re); + System.out.println(); + + re.Init(0, 0); + + Cmd.AddCommand("nexttest", nexttest); + Cbuf.AddText("bind n nexttest"); + Cbuf.Execute(); + Globals.cls.key_dest = Defines.key_game; + Globals.cls.state = Defines.ca_active; + } + + float fps = 0.0f; + + long start = 0; + + void updateScreen() { + re.BeginFrame(0.0f); + viddef = Globals.viddef; + re.DrawStretchPic(0, 0, viddef.width, viddef.height, "conback"); + + if (framecount % 500 == 0) { + long time = System.currentTimeMillis(); + fps = 500000.0f / (time - start); + start = time; + } + String text = ((int)(fps +0.5f)) + " fps"; + + for (int i = 0; i < text.length(); i++) { + re.DrawChar(10 + 8 * i, viddef.height / 2, (int) text.charAt(i)); + } + + Dimension wal = new Dimension(); + re.DrawGetPicSize(wal, "/textures/e1u1/basemap.wal"); + + re.DrawPic(0, viddef.height - wal.height, "/textures/e1u1/basemap.wal"); + + switch (testnr) { + case 0: + testParticles(); + break; + case 1: + testModel(); + break; + case 2: + testSprites(); + break; + case 3: + testBeam(); + } + re.EndFrame(); + framecount++; + } + + long startTime; + + void run() { + startTime = System.currentTimeMillis(); + xcommand_t callback = new xcommand_t() { + public void execute() { + updateScreen(); + } + }; + while (true) { + re.updateScreen(callback); + re.getKeyboardHandler().Update(); + Cbuf.Execute(); + try { + Thread.sleep(5); + } catch (InterruptedException e) { + } + } + } + + // =================================================================== + + private int yaw = 0; + + private void testModel() { + + refdef_t refdef = new refdef_t(); + + refdef.x = viddef.width / 2; + refdef.y = viddef.height / 2 - 72; + refdef.width = 144 * 2; + refdef.height = 168 * 2; + refdef.fov_x = 40; + refdef.fov_y = Math3D + .CalcFov(refdef.fov_x, refdef.width, refdef.height); + refdef.time = 1.0f * 0.001f; + + int maxframe = 29; + entity_t entity = new entity_t(); + String modelName = "players/female/tris.md2"; + + String modelSkin = "players/female/athena.pcx"; + + String modelImage = "/players/female/athena_i.pcx"; + String modelImage1 = "/players/female/brianna_i.pcx"; + String modelImage2 = "/players/female/cobalt_i.pcx"; + String modelImage3 = "/players/female/lotus_i.pcx"; + + entity.model = re.RegisterModel(modelName); + + drawString(refdef.x, refdef.y - 20, (entity.model != null) ? modelName + : "DEBUG: NullModel"); + + entity.skin = re.RegisterSkin(modelSkin); + entity.flags = Defines.RF_FULLBRIGHT; + entity.origin[0] = 80; + entity.origin[1] = 0; + entity.origin[2] = 0; + Math3D.VectorCopy(entity.origin, entity.oldorigin); + entity.frame = (framecount / 3) + % ((qfiles.dmdl_t) entity.model.extradata).num_frames; + entity.oldframe = 0; + entity.backlerp = 0.0f; + yaw += KBD.mx; + KBD.mx = 0; + if (yaw > 360) + yaw -= 360; + if (yaw < 0) + yaw += 360; + entity.angles[1] = yaw; + + refdef.areabits = null; + refdef.num_entities = 1; + refdef.entities = new entity_t[] { entity }; + refdef.lightstyles = null; + refdef.rdflags = Defines.RDF_NOWORLDMODEL; + + // Menu_Draw(& s_player_config_menu); + + M_DrawTextBox((int) ((refdef.x) * (320.0F / viddef.width) - 8), + (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), + refdef.width / 8, refdef.height / 8); + refdef.height += 4; + + re.RenderFrame(refdef); + + re.DrawPic(refdef.x - 80, refdef.y, modelImage); + re.DrawPic(refdef.x - 80, refdef.y + 47, modelImage1); + re.DrawPic(refdef.x - 80, refdef.y + 94, modelImage2); + re.DrawPic(refdef.x - 80, refdef.y + 141, modelImage3); + } + + private String[] sprites = { "sprites/s_bfg1.sp2", "sprites/s_bfg2.sp2", + "sprites/s_bfg3.sp2", "sprites/s_explod.sp2", + "sprites/s_explo2.sp2", "sprites/s_explo3.sp2", + "sprites/s_flash.sp2", "sprites/s_bubble.sp2", }; + + private int spriteCount = 0; + + private boolean loading = true; + + private void testSprites() { + + if (loading) { + + re.DrawPic(viddef.width / 2 - 50, viddef.height / 2, "loading"); + String name = sprites[spriteCount]; + + drawString(viddef.width / 2 - 50, viddef.height / 2 + 50, name); + + re.RegisterModel(name); + loading = ++spriteCount < sprites.length; + return; + } + + refdef_t refdef = new refdef_t(); + + refdef.x = viddef.width / 2; + refdef.y = viddef.height / 2 - 72; + refdef.width = 144 * 2; + refdef.height = 168 * 2; + refdef.fov_x = 40; + refdef.fov_y = Math3D + .CalcFov(refdef.fov_x, refdef.width, refdef.height); + refdef.time = 1.0f * 0.001f; + + int maxframe = 29; + entity_t entity = new entity_t(); + + String modelName = sprites[(framecount / 30) % sprites.length]; + drawString(refdef.x, refdef.y - 20, modelName); + + entity.model = re.RegisterModel(modelName); + + entity.flags = Defines.RF_FULLBRIGHT; + entity.origin[0] = 80 - (framecount % 200) + 200; + entity.origin[1] = 0 + (float) (40 * Math.sin(Math + .toRadians(framecount))); + entity.origin[2] = 0 + 20; + Math3D.VectorCopy(entity.origin, entity.oldorigin); + entity.frame = framecount / 2; + entity.oldframe = 0; + entity.backlerp = 0.0f; + + refdef.areabits = null; + refdef.num_entities = 1; + refdef.entities = new entity_t[] { entity }; + refdef.lightstyles = null; + refdef.rdflags = Defines.RDF_NOWORLDMODEL; + + M_DrawTextBox((int) ((refdef.x) * (320.0F / viddef.width) - 8), + (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), + refdef.width / 8, refdef.height / 8); + refdef.height += 4; + + re.RenderFrame(refdef); + + } + + private void testBeam() { + + refdef_t refdef = new refdef_t(); + + refdef.x = viddef.width / 2; + refdef.y = viddef.height / 2 - 72; + refdef.width = 144 * 2; + refdef.height = 168 * 2; + refdef.fov_x = 40; + refdef.fov_y = Math3D + .CalcFov(refdef.fov_x, refdef.width, refdef.height); + refdef.time = 1.0f * 0.001f; + + int maxframe = 29; + entity_t entity = new entity_t(); + + drawString(refdef.x, refdef.y - 20, "Beam Test"); + + entity.flags = Defines.RF_BEAM; + entity.origin[0] = 200; + entity.origin[1] = 0 + (float) (80 * Math.sin(4 * Math + .toRadians(framecount))); + entity.origin[2] = 20 + (float) (40 * Math.cos(4 * Math + .toRadians(framecount))); + + entity.oldorigin[0] = 20; + entity.oldorigin[1] = 0; // + (float)(40 * + // Math.sin(Math.toRadians(framecount))); + entity.oldorigin[2] = -20; // + 20; + + entity.frame = 3; + entity.oldframe = 0; + entity.backlerp = 0.0f; + // the four beam colors are encoded in 32 bits of skinnum (hack) + entity.alpha = 0.6f; + + int[] color = { 0xd0, 0xd1, 0xe0, 0xb0 }; + + entity.skinnum = color[framecount / 2 % 4]; + entity.model = null; + + refdef.areabits = null; + refdef.num_entities = 1; + refdef.entities = new entity_t[] { entity }; + refdef.lightstyles = null; + refdef.rdflags = Defines.RDF_NOWORLDMODEL; + + M_DrawTextBox((int) ((refdef.x) * (320.0F / viddef.width) - 8), + (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), + refdef.width / 8, refdef.height / 8); + refdef.height += 4; + + re.RenderFrame(refdef); + } + + private LinkedList active_particles = new LinkedList(); + + private boolean explode = false; + + private float[] target; + + private boolean initParticles = true; + + private void testParticles() { + + r_numparticles = 0; + + if (active_particles.size() == 0) { + if (explode) + Explosion(target); + else { + target = new float[] { 150 + Lib.crand() * 80, + Lib.crand() * 40, Lib.crand() * 40 }; + RailTrail(new float[] { 30, -20, -20 }, target); + //Heatbeam(new float[]{30, 20, -20}, target); + } + explode = !explode; + } + refdef_t refdef = new refdef_t(); + + refdef.x = viddef.width / 2; + refdef.y = viddef.height / 2 - 72; + refdef.width = 400; + refdef.height = 400; + refdef.fov_x = 50; + refdef.fov_y = Math3D + .CalcFov(refdef.fov_x, refdef.width, refdef.height); + refdef.time = 1.0f * 0.001f; + + animateParticles(); + + drawString(refdef.x, refdef.y - 20, "active particles: " + + r_numparticles); + + refdef.num_particles = r_numparticles; + + refdef.areabits = null; + refdef.num_entities = 0; + refdef.entities = null; + refdef.lightstyles = null; + refdef.rdflags = Defines.RDF_NOWORLDMODEL; + + M_DrawTextBox((int) ((refdef.x) * (320.0F / viddef.width) - 8), + (int) ((viddef.height / 2) * (240.0F / viddef.height) - 77), + refdef.width / 8, refdef.height / 8); + refdef.height += 4; + + re.RenderFrame(refdef); + } + + private void drawString(int x, int y, String text) { + for (int i = 0; i < text.length(); i++) { + re.DrawChar(x + 8 * i, y, (int) text.charAt(i)); + } + } + + private void M_DrawTextBox(int x, int y, int width, int lines) { + int cx, cy; + int n; + + // draw left side + cx = x; + cy = y; + M_DrawCharacter(cx, cy, 1); + for (n = 0; n < lines; n++) { + cy += 8; + M_DrawCharacter(cx, cy, 4); + } + M_DrawCharacter(cx, cy + 8, 7); + + // draw middle + cx += 8; + while (width > 0) { + cy = y; + M_DrawCharacter(cx, cy, 2); + for (n = 0; n < lines; n++) { + cy += 8; + M_DrawCharacter(cx, cy, 5); + } + M_DrawCharacter(cx, cy + 8, 8); + width -= 1; + cx += 8; + } + + // draw right side + cy = y; + M_DrawCharacter(cx, cy, 3); + for (n = 0; n < lines; n++) { + cy += 8; + M_DrawCharacter(cx, cy, 6); + } + M_DrawCharacter(cx, cy + 8, 9); + } + + /** + * M_DrawCharacter + * + * Draws one solid graphics character cx and cy are in 320*240 coordinates, + * and will be centered on higher res screens. ================ + */ + private void M_DrawCharacter(int cx, int cy, int num) { + re.DrawChar(cx + ((viddef.width - 320) >> 1), cy + + ((viddef.height - 240) >> 1), num); + } + + long endtime; + + private void Explosion(float[] org) { + float[] dir = { 0, 0, 0 }; + int i; + cparticle_t p; + + for (i = 0; i < 256; i++) { + p = new cparticle_t(); + + p.time = time() * 1.0f; + p.color = /* 0xe0 */223 - (Lib.rand() & 7); + for (int j = 0; j < 3; j++) { + p.org[j] = org[j] + (float) (Lib.rand() % 32) - 16; + p.vel[j] = (float) (Lib.rand() % 384) - 192; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + + active_particles.add(p); + } + } + + static final float INSTANT_PARTICLE = -10000.0f; + + static final float PARTICLE_GRAVITY = 40.0f; + + /* + * =============== CL_AddParticles =============== + */ + private void animateParticles() { + cparticle_t p; + float alpha; + float time, time2; + float[] org = { 0, 0, 0 }; + int color; + + time = 0.0f; + + for (Iterator it = active_particles.iterator(); it.hasNext();) { + p = (cparticle_t) it.next(); + + // PMM - added INSTANT_PARTICLE handling for heat beam + if (p.alphavel != INSTANT_PARTICLE) { + time = (time() - p.time) * 0.001f; + alpha = p.alpha + time * p.alphavel; + if (alpha <= 0) { // faded out + it.remove(); + continue; + } + } else { + alpha = p.alpha; + } + + if (alpha > 1.0) + alpha = 1; + color = (int) p.color; + + time2 = time * time; + + org[0] = p.org[0] + p.vel[0] * time + p.accel[0] * time2; + org[1] = p.org[1] + p.vel[1] * time + p.accel[1] * time2; + org[2] = p.org[2] + p.vel[2] * time + p.accel[2] * time2; + + AddParticle(org, color, alpha); + + // PMM + if (p.alphavel == INSTANT_PARTICLE) { + p.alphavel = 0.0f; + p.alpha = 0.0f; + } + } + } + + private void Heatbeam(float[] start, float[] forward) { + + float[] v_up = { 0, 0, 10 }; + float[] v_right = { 0, 10, 0 }; + + float[] move = { 0, 0, 0 }; + float[] vec = { 0, 0, 0 }; + float len; + int j; + cparticle_t p; + float[] right = { 0, 0, 0 }; + float[] up = { 0, 0, 0 }; + int i; + float c, s; + float[] dir = { 0, 0, 0 }; + float ltime; + float step = 32.0f, rstep; + float start_pt; + float rot; + float variance; + float[] end = { 0, 0, 0 }; + + Math3D.VectorMA(start, 4096, forward, end); + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + Math3D.VectorCopy(v_right, right); + Math3D.VectorCopy(v_up, up); + // if (vidref_val == VIDREF_GL) + // { // GL mode + Math3D.VectorMA(move, -0.5f, right, move); + Math3D.VectorMA(move, -0.5f, up, move); + // } + // // otherwise assume SOFT + + ltime = (float) time() / 1000.0f; + start_pt = (ltime * 96.0f) % step; + Math3D.VectorMA(move, start_pt, vec, move); + + Math3D.VectorScale(vec, step, vec); + + rstep = (float) Math.PI / 10.0f; + for (i = (int) start_pt; i < len; i += step) { + if (i > step * 5) // don't bother after the 5th ring + break; + + for (rot = 0; rot < Math.PI * 2; rot += rstep) { + + p = new cparticle_t(); + + p.time = time(); + Math3D.VectorClear(p.accel); + variance = 0.5f; + c = (float) Math.cos(rot) * variance; + s = (float) Math.sin(rot) * variance; + + // trim it so it looks like it's starting at the origin + if (i < 10) { + Math3D.VectorScale(right, c * (i / 10.0f), dir); + Math3D.VectorMA(dir, s * (i / 10.0f), up, dir); + } else { + Math3D.VectorScale(right, c, dir); + Math3D.VectorMA(dir, s, up, dir); + } + + p.alpha = 0.8f; + p.alphavel = -1000.0f; + p.color = /* 223 */0x74 - (Lib.rand() & 7); + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + dir[j] * 3; + p.vel[j] = 0; + } + + active_particles.add(p); + } + Math3D.VectorAdd(move, vec, move); + } + } + + private void RailTrail(float[] start, float[] end) { + float[] move = { 0, 0, 0 }; + float[] vec = { 0, 0, 0 }; + float len; + int j; + cparticle_t p; + float dec; + float[] right = { 0, 0, 0 }; + float[] up = { 0, 0, 0 }; + int i; + float d, c, s; + float[] dir = { 0, 0, 0 }; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + Math3D.MakeNormalVectors(vec, right, up); + + for (i = 0; i < len; i++) { + + p = new cparticle_t(); + p.time = time(); + Math3D.VectorClear(p.accel); + + d = i * 0.1f; + c = (float) Math.cos(d); + s = (float) Math.sin(d); + + Math3D.VectorScale(right, c, dir); + Math3D.VectorMA(dir, s, up, dir); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.2f); + p.color = 0x74 + (Lib.rand() & 7); + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + dir[j] * 3; + p.vel[j] = dir[j] * 6; + } + + Math3D.VectorAdd(move, vec, move); + + active_particles.add(p); + } + + dec = 0.75f; + Math3D.VectorScale(vec, dec, vec); + Math3D.VectorCopy(start, move); + + while (len > 0) { + len -= dec; + + p = new cparticle_t(); + + p.time = time(); + Math3D.VectorClear(p.accel); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0x0 + Lib.rand() & 15; + + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * 3; + p.vel[j] = Lib.crand() * 3; + p.accel[j] = 0; + } + + Math3D.VectorAdd(move, vec, move); + active_particles.add(p); + } + } + + private int time() { + return (int) (System.currentTimeMillis() - startTime); + } + + static xcommand_t nexttest = new xcommand_t() { + public void execute() { + testnr++; + testnr = testnr % 3; + } + }; + + int r_numparticles = 0; + + /** + * V_AddParticle + */ + void AddParticle(float[] org, int color, float alpha) { + if (r_numparticles >= Defines.MAX_PARTICLES) + return; + + int i = r_numparticles++; + + int c = particle_t.colorTable[color]; + c |= (int) (alpha * 255) << 24; + particle_t.colorArray.put(i, c); + + i *= 3; + FloatBuffer vertexBuf = particle_t.vertexArray; + vertexBuf.put(i, org[0]); + vertexBuf.put(i + 1, org[1]); + vertexBuf.put(i + 2, org[2]); + } +}
\ No newline at end of file diff --git a/webstart/jake2_jogl11.jnlp b/webstart/jake2_jogl11.jnlp index 79a05e7..7d0b68d 100644 --- a/webstart/jake2_jogl11.jnlp +++ b/webstart/jake2_jogl11.jnlp @@ -17,7 +17,7 @@ </security> <resources> - <j2se version="1.4+" max-heap-size="80M"/> + <j2se version="1.4+" max-heap-size="100M"/> <jar href="http://jake2.sourceforge.net/lib/jake2.jar"/> <property name="sun.java2d.noddraw" value="true"/> <property name="ATI_WORKAROUND" value="false"/> diff --git a/webstart/jake2_jogl11ATI.jnlp b/webstart/jake2_jogl11ATI.jnlp index 714da22..ca6771b 100644 --- a/webstart/jake2_jogl11ATI.jnlp +++ b/webstart/jake2_jogl11ATI.jnlp @@ -17,7 +17,7 @@ </security> <resources> - <j2se version="1.4+" max-heap-size="80M"/> + <j2se version="1.4+" max-heap-size="100M"/> <jar href="http://jake2.sourceforge.net/lib/jake2.jar"/> <property name="sun.java2d.noddraw" value="true"/> <property name="ATI_WORKAROUND" value="true"/> diff --git a/webstart/jake2_lwjgl.jnlp b/webstart/jake2_lwjgl.jnlp index 1899f43..85facaf 100644 --- a/webstart/jake2_lwjgl.jnlp +++ b/webstart/jake2_lwjgl.jnlp @@ -17,7 +17,7 @@ </security> <resources> - <j2se version="1.4+" max-heap-size="80M"/> + <j2se version="1.4+" max-heap-size="100M"/> <jar href="http://jake2.sourceforge.net/lib/jake2.jar"/> <jar href="http://jake2.sourceforge.net/lib/lwjgl.jar"/> <jar href="http://jake2.sourceforge.net/lib/lwjgl_util.jar"/> |