aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2svn <[email protected]>2004-07-09 06:50:56 +0000
committercvs2svn <[email protected]>2004-07-09 06:50:56 +0000
commitee5ff056b53618da3146f37b0e5b7395203d7b44 (patch)
treea9d434fc462417bb981b1565fd64cea5e7c82c15
parent4ac2d590b2c18728ee636c391882619bc2a642b8 (diff)
parent4f13ea26c4f47e54e66926f0700cf631e7bb3352 (diff)
This commit was manufactured by cvs2svn to create tag 'hannover'.hannover
-rw-r--r--.cvsignore1
-rw-r--r--ChangeLog11
-rw-r--r--LICENSE340
-rw-r--r--README38
-rw-r--r--README_DE55
-rw-r--r--build.bat8
-rw-r--r--build.sh8
-rw-r--r--build.xml104
-rw-r--r--readme.id29
-rw-r--r--scripts/Jake2.bat1
-rw-r--r--scripts/Jake2.sh6
-rw-r--r--src/jake2/Globals.java3
-rw-r--r--src/jake2/client/CL.java7
-rw-r--r--src/jake2/client/CL_ents.java4
-rw-r--r--src/jake2/client/CL_fx.java91
-rw-r--r--src/jake2/client/CL_newfx.java30
-rw-r--r--src/jake2/client/CL_parse.java40
-rw-r--r--src/jake2/client/CL_pred.java27
-rw-r--r--src/jake2/client/CL_tent.java9
-rw-r--r--src/jake2/client/CL_view.java14
-rw-r--r--src/jake2/client/Key.java15
-rw-r--r--src/jake2/client/M.java10
-rw-r--r--src/jake2/client/Menu.java3
-rw-r--r--src/jake2/client/S.java33
-rw-r--r--src/jake2/client/SCR.java13
-rw-r--r--src/jake2/client/SND_DMA.java1245
-rw-r--r--src/jake2/client/SND_JAVA.java168
-rw-r--r--src/jake2/client/SND_MEM.java (renamed from src/jake2/sound/WaveLoader.java)208
-rw-r--r--src/jake2/client/SND_MIX.java513
-rw-r--r--src/jake2/client/VID.java7
-rw-r--r--src/jake2/client/centity_t.java4
-rw-r--r--src/jake2/client/client_state_t.java7
-rw-r--r--src/jake2/client/frame_t.java4
-rw-r--r--src/jake2/client/refimport_t.java8
-rw-r--r--src/jake2/client/sfx_t.java (renamed from src/jake2/sound/sfx_t.java)22
-rw-r--r--src/jake2/client/sfxcache_t.java (renamed from src/jake2/sound/sfxcache_t.java)16
-rw-r--r--src/jake2/game/GameAIAdapters.java27
-rw-r--r--src/jake2/game/GameMiscAdapters.java4
-rw-r--r--src/jake2/game/PlayerClient.java4
-rw-r--r--src/jake2/game/client_persistant_t.java21
-rw-r--r--src/jake2/game/client_respawn_t.java4
-rw-r--r--src/jake2/game/cplane_t.java25
-rw-r--r--src/jake2/game/player_state_t.java4
-rw-r--r--src/jake2/game/trace_t.java28
-rw-r--r--src/jake2/qcommon/CRC.java383
-rw-r--r--src/jake2/qcommon/MSG.java16
-rw-r--r--src/jake2/qcommon/Qcommon.java7
-rw-r--r--src/jake2/qcommon/qfiles.java48
-rw-r--r--src/jake2/render/FastJoglRenderer.java306
-rw-r--r--src/jake2/render/fastjogl/Anorms.java219
-rw-r--r--src/jake2/render/fastjogl/Base.java300
-rw-r--r--src/jake2/render/fastjogl/Draw.java406
-rw-r--r--src/jake2/render/fastjogl/Image.java1673
-rw-r--r--src/jake2/render/fastjogl/Impl.java343
-rw-r--r--src/jake2/render/fastjogl/Light.java778
-rw-r--r--src/jake2/render/fastjogl/Main.java1592
-rw-r--r--src/jake2/render/fastjogl/Mesh.java753
-rw-r--r--src/jake2/render/fastjogl/Misc.java265
-rw-r--r--src/jake2/render/fastjogl/Model.java1347
-rw-r--r--src/jake2/render/fastjogl/Surf.java1464
-rw-r--r--src/jake2/render/fastjogl/Warp.java732
-rw-r--r--src/jake2/render/jogl/Image.java357
-rw-r--r--src/jake2/render/jogl/Impl.java28
-rw-r--r--src/jake2/render/jogl/Light.java258
-rw-r--r--src/jake2/render/jogl/Mesh.java6
-rw-r--r--src/jake2/render/jogl/Surf.java351
-rw-r--r--src/jake2/render/jogl/Warp.java5
-rw-r--r--src/jake2/render/msurface_t.java43
-rw-r--r--src/jake2/server/SV_GAME.java12
-rw-r--r--src/jake2/server/SV_INIT.java4
-rw-r--r--src/jake2/server/SV_SEND.java8
-rw-r--r--src/jake2/server/SV_USER.java13
-rw-r--r--src/jake2/server/SV_WORLD.java4
-rw-r--r--src/jake2/sound/DummyDriver.java111
-rw-r--r--src/jake2/sound/S.java187
-rw-r--r--src/jake2/sound/Sound.java105
-rw-r--r--src/jake2/sound/joal/Channel.java84
-rw-r--r--src/jake2/sound/joal/JOALSoundImpl.java793
-rw-r--r--src/jake2/sound/soundinfo_t.java19
-rw-r--r--src/jake2/sound/wavinfo_t.java19
-rw-r--r--src/jake2/sys/Sys.java4
-rw-r--r--src/jake2/util/Math3D.java118
-rw-r--r--test/jake2/qcommon/TestTGA.java327
-rw-r--r--test/jake2/render/DancingQueens.java9
-rw-r--r--test/jake2/render/TestMap.java11
-rw-r--r--test/jake2/render/TestRenderer.java9
86 files changed, 2937 insertions, 13799 deletions
diff --git a/.cvsignore b/.cvsignore
index d97898e..c46d6e3 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -2,4 +2,3 @@ build
baseq2
dist
*.tar.gz
-*.zip
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 8128e2a..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,11 +0,0 @@
-0.9.0 2004-04-28
-
- - initial release
- - what works so far:
- - local single player games
- - demos (at least we have the coolest Java benchmark out there)
- - console and menus 90%
- - todo until 1.0:
- - sound support
- - save games / load games
- - network games
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 5b6e7c6..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/README b/README
deleted file mode 100644
index 6142684..0000000
--- a/README
+++ /dev/null
@@ -1,38 +0,0 @@
-Jake2 README
-============
-
-Jake2 is a port of the GPL'd Quake2 engine from id Software to Java. Jake2 is
-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. For graphics rendering we use the jogl Java OpenGL bindings.
-
-Currently Jake2 supports Linux and Windows2000/XP.
-
-requirements:
-400 MHz CPU
-Geforce2 MX or better graphics accelerator
-JRE 1.4 or higher
-
-Installation
-------------
-
-from binary distribution:
-- unpack jake2-version.tar.gz or jake2-version.zip
-- copy the baseq2 directory from your full version of Quake2 or from the
- demo version to the Jake2 base directory
-- run the game with Jake2.sh or Jake2.bat
-
-build from source:
-- unpack jake2src-version.tar.gz or jake2-version.zip
-- set JAVA_HOME environment variable to Your J2SDK1.4 installation
-- run "build.sh bindist" or "build.bat bindist" to build the binary
- distribution
-
-have fun!
-
-bytonic Software
-
-Holger Zickner <[email protected]>
-Carsten Weisse <[email protected]>
-Rene Stoeckel <[email protected]>
diff --git a/README_DE b/README_DE
deleted file mode 100644
index 7fd021e..0000000
--- a/README_DE
+++ /dev/null
@@ -1,55 +0,0 @@
-Jake2 README
-============
-
-Jake2 ist eine Java Portierung der Quake2 Engine von id Software. Id Software
-hat den Sourcecode der Quake2 Engine unter den Bedingungen der GPL
-ver�ffentlicht. Dementsprechend wird auch Jake2 unter der GPL (siehe LICENSE)
-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.
-
-Jake2 befindet sich noch im Entwicklungsstadium. Die Kontaktaddresse f�r
-Bugreports und R�ckmeldungen ist [email protected].
-
-Jake2 wird von uns unter Linux und Windows2000/XP getestet. Wir haben Feedback,
-dass Jake2 richtigen plattformspezifischen jogl Bibliotheken auch auf Mac OS X
-l�uft.
-
-Mindestanforderungen:
-400 MHz CPU
-Geforce2 MX oder bessere Grafikkarte
-JRE 1.4.2
-
-Installation
-------------
-
-ausgehend von der Bin�rdistribution:
-- jake2-version.tar.gz oder jake2-version.zip entpacken
-- baseq2 Verzeichnis des Quake2 Originals oder der Demoversion in das Jake2
- Verzeichnis kopieren
-- mit Jake2.sh oder Jake2.bat starten
-
-ausgehend von Sourcedistribution:
-- jake2src-version.tar.gz oder jake2src-version.zip entpacken
-- JAVA_HOME Umgebungsvariable auf J2SDK1.4 Installationsverzeichnis setzen
-- "build.sh bindist" oder "build.bat bindist" erzeugt die Bin�rdistribution
-
-Quake2 Leveldaten installieren:
-- ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe (37 MB)
- herunterladen
-- Install\Data\baseq2\ aus q2-314-demo-x86.exe mit unzip oder Winzip
- extrahieren
-- baseq2 ins Jake2 Verzeichnis kopieren
-
-viel Spass!
-
-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
diff --git a/build.bat b/build.bat
deleted file mode 100644
index ecd87a7..0000000
--- a/build.bat
+++ /dev/null
@@ -1,8 +0,0 @@
-@echo off
-
-set CP=lib/ant/ant.jar;lib/ant/ant-launcher.jar
-set CP=%CP%;lib/xerces/xercesImpl.jar;lib/xerces/xml-apis.jar
-set CP=%CP%;lib/proguard/proguard.jar
-set CP=%CP%;%JAVA_HOME%/lib/tools.jar
-
-java -Dant.home=lib/ant -cp %CP% org.apache.tools.ant.Main -buildfile build.xml %1 %2 %3 %4 \ No newline at end of file
diff --git a/build.sh b/build.sh
deleted file mode 100644
index f5515d3..0000000
--- a/build.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-CP=lib/ant/ant.jar:lib/ant/ant-launcher.jar
-CP=$CP:lib/xerces/xercesImpl.jar:lib/xerces/xml-apis.jar
-CP=$CP:lib/proguard/proguard.jar
-CP=$CP:$JAVA_HOME/lib/tools.jar
-
-java -Dant.home=lib/ant -cp $CP org.apache.tools.ant.Main -buildfile build.xml $@ \ No newline at end of file
diff --git a/build.xml b/build.xml
index eb1f47c..de8da32 100644
--- a/build.xml
+++ b/build.xml
@@ -1,67 +1,46 @@
<!-- Buildfile -->
-<project name="jake2" default="dist" basedir=".">
+<project name="jake2" default="jar" basedir=".">
- <taskdef name="proguard" classname="proguard.ant.ProGuardTask">
- <classpath>
- <pathelement location="lib/proguard/proguard.jar"/>
- </classpath>
- </taskdef>
-
<!-- properties -->
<property name="src" location="src"/>
- <property name="test" location="test"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<!-- different classpaths -->
<path id="build.class.path">
- <pathelement location="lib/jogl/linux/jogl.jar"/>
- <pathelement location="lib/joal/linux/joal.jar"/>
+ <pathelement location="lib/jogl/jogl.jar"/>
+ </path>
+
+ <path id="test.class.path">
+ <pathelement path="${build}"/>
+ </path>
+
+ <path id="source.path">
+ <pathelement location="src"/>
</path>
<!-- initialize directories -->
<target name="init">
<mkdir dir="${build}"/>
- <mkdir dir="${dist}/lib"/>
+ <mkdir dir="${dist}"/>
</target>
<!-- compile -->
<target name="compile" depends="init">
<javac destdir="${build}" optimize="on" debug="off" source="1.4">
<src path="${src}"/>
- <include name="jake2/**"/>
+ <include name="jake2/Jake2.java"/>
<classpath refid="build.class.path"/>
</javac>
</target>
<!-- copy libs -->
<target name="copylibs">
- <copy todir="${dist}/lib/linux">
- <fileset dir="lib/jogl/linux">
- <include name="*"/>
- </fileset>
- <fileset dir="lib/joal/linux">
- <include name="*"/>
- </fileset>
- </copy>
- <copy todir="${dist}/lib/windows">
- <fileset dir="lib/jogl/windows">
- <include name="*"/>
- </fileset>
- <fileset dir="lib/joal/windows">
- <include name="*"/>
- </fileset>
- </copy>
<copy todir="${dist}">
- <fileset dir="scripts">
- <include name="Jake2.*"/>
+ <fileset dir="lib">
+ <include name="/jogl/jogl.jar"/>
</fileset>
</copy>
- <chmod perm="755">
- <fileset dir="${dist}">
- <include name="*.sh"/>
- </fileset>
- </chmod>
</target>
<!-- copy resources -->
@@ -75,22 +54,11 @@
<!-- jar -->
<target name="jar" depends="compile,copyres">
- <jar destfile="${dist}/lib/jake.jar" basedir="${build}">
+ <jar destfile="${dist}/jake2.jar" basedir="${build}">
<include name="jake2/**"/>
</jar>
- <proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar"
- defaultpackage="" overloadaggressively="off">
- <injar name="${dist}/lib/jake.jar"/>
- <libraryjar name="lib/jogl/linux/jogl.jar"/>
- <libraryjar name="lib/joal/linux/joal.jar"/>
- <libraryjar name="${java.home}/lib/rt.jar"/>
- <keep access="public" name="jake2.Jake2">
- <method name="main(java.lang.String[])"/>
- </keep>
- </proguard>
- <delete file="${dist}/lib/jake.jar"/>
</target>
-
+
<!-- everything -->
<target name="all" depends="bindist,srcdist">
</target>
@@ -102,45 +70,21 @@
<!-- binary distribution -->
<target name="bindist" depends="dist">
<tar destfile="jake2.tar.gz" compression="gzip">
- <tarfileset dir="${dist}" prefix="Jake2" mode="755">
- <include name="*.sh"/>
- </tarfileset>
- <tarfileset dir="${dist}" prefix="Jake2">
- <include name="**"/>
- <exclude name="*.sh"/>
+ <tarfileset dir=".">
+ <include name="dist/**"/>
</tarfileset>
</tar>
- <zip destfile="jake2.zip">
- <zipfileset dir="${dist}" prefix="Jake2">
- <include name="**"/>
- </zipfileset>
- </zip>
</target>
<!-- source distribution -->
<target name="srcdist" >
<tar destfile="jake2-src.tar.gz" compression="gzip">
- <tarfileset dir="." prefix="Jake2" mode="755">
- <include name="scripts/*.*"/>
- <include name="build.sh"/>
- </tarfileset>
- <tarfileset dir="." prefix="Jake2">
- <include name="src/jake2/**"/>
+ <tarfileset dir="." prefix="jake2">
+ <include name="src/**"/>
<include name="lib/**"/>
<include name="build.xml"/>
- <include name="build.bat"/>
</tarfileset>
</tar>
- <zip destfile="jake2-src.zip">
- <zipfileset dir="." prefix="Jake2">
- <include name="src/jake2/**"/>
- <include name="scripts/*.*"/>
- <include name="lib/**"/>
- <include name="build.xml"/>
- <include name="build.sh"/>
- <include name="build.bat"/>
- </zipfileset>
- </zip>
</target>
<!-- clean -->
@@ -152,11 +96,7 @@
<!-- distclean -->
<target name="distclean" depends="clean">
<delete dir="${dist}"/>
- <delete>
- <fileset dir=".">
- <include name="*.tar.gz"/>
- <include name="*.zip"/>
- </fileset>
- </delete>
+ <delete file="jake2.tar.gz"/>
+ <delete file="jake2-src.tar.gz"/>
</target>
</project> \ No newline at end of file
diff --git a/readme.id b/readme.id
deleted file mode 100644
index ff05cab..0000000
--- a/readme.id
+++ /dev/null
@@ -1,29 +0,0 @@
-
-This is the complete source code for Quake 2, version 3.21, buildable with
-visual C++ 6.0. The linux version should be buildable, but we haven't
-tested it for the release.
-
-The code is all licensed under the terms of the GPL (gnu public license).
-You should read the entire license, but the gist of it is that you can do
-anything you want with the code, including sell your new version. The catch
-is that if you distribute new binary versions, you are required to make the
-entire source code available for free to everyone.
-
-The primary intent of this release is for entertainment and educational
-purposes, but the GPL does allow commercial exploitation if you obey the
-full license. If you want to do something commercial and you just can't bear
-to have your source changes released, we could still negotiate a separate
-license agreement (for $$$), but I would encourage you to just live with the
-GPL.
-
-All of the Q2 data files remain copyrighted and licensed under the
-original terms, so you cannot redistribute data from the original game, but if
-you do a true total conversion, you can create a standalone game based on
-this code.
-
-Thanks to Robert Duffy for doing the grunt work of building this release.
-
-John Carmack
-Id Software
-
-
diff --git a/scripts/Jake2.bat b/scripts/Jake2.bat
deleted file mode 100644
index 6230d9e..0000000
--- a/scripts/Jake2.bat
+++ /dev/null
@@ -1 +0,0 @@
-@javaw -Xmx128M -Djava.library.path=lib/windows -cp lib/jake2.jar;lib/windows/jogl.jar;lib/windows/joal.jar jake2.Jake2 \ No newline at end of file
diff --git a/scripts/Jake2.sh b/scripts/Jake2.sh
deleted file mode 100644
index 11ba52f..0000000
--- a/scripts/Jake2.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-export LD_LIBRARY_PATH=lib/linux
-CP=lib/jake2.jar:lib/linux/jogl.jar:lib/linux/joal.jar
-
-exec java -Xmx128M -Djava.library.path=lib/linux -cp $CP jake2.Jake2 \ No newline at end of file
diff --git a/src/jake2/Globals.java b/src/jake2/Globals.java
index 32771bf..27b6e4a 100644
--- a/src/jake2/Globals.java
+++ b/src/jake2/Globals.java
@@ -2,7 +2,7 @@
* Globals.java
* Copyright (C) 2003
*
- * $Id: Globals.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
+ * $Id: Globals.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -84,6 +84,7 @@ public class Globals extends Defines {
public static cvar_t cl_upspeed;
public static cvar_t cl_yawspeed;
public static cvar_t dedicated;
+ public static cvar_t slomo;
public static cvar_t developer;
public static cvar_t fixedtime;
public static cvar_t freelook;
diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java
index 5b30e34..3522aa2 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.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,7 +30,6 @@ import jake2.Globals;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.server.SV_MAIN;
-import jake2.sound.*;
import jake2.sys.*;
import jake2.util.Vargs;
@@ -1541,8 +1540,8 @@ public final class CL extends CL_pred {
if (!cl.refresh_prepped && cls.state == ca_active) {
CL.PrepRefresh();
// TODO force GC after level loading
- System.gc();
- System.gc();
+ //System.gc();
+ //System.gc();
}
SCR.UpdateScreen();
diff --git a/src/jake2/client/CL_ents.java b/src/jake2/client/CL_ents.java
index d406ff2..4dc4330 100644
--- a/src/jake2/client/CL_ents.java
+++ b/src/jake2/client/CL_ents.java
@@ -2,7 +2,7 @@
* CL_ents.java
* Copyright (C) 2004
*
- * $Id: CL_ents.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL_ents.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1268,7 +1268,7 @@ public class CL_ents extends CL_inv {
Called to get the sound spatialization origin
===============
*/
- public static void GetEntitySoundOrigin(int ent, float[] org) {
+ void GetEntitySoundOrigin(int ent, float[] org) {
centity_t old;
if (ent < 0 || ent >= MAX_EDICTS)
diff --git a/src/jake2/client/CL_fx.java b/src/jake2/client/CL_fx.java
index 45e9fdd..86642ee 100644
--- a/src/jake2/client/CL_fx.java
+++ b/src/jake2/client/CL_fx.java
@@ -2,7 +2,7 @@
* CL_fx.java
* Copyright (C) 2004
*
- * $Id: CL_fx.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL_fx.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,12 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
-import jake2.Globals;
import jake2.game.M_Flash;
import jake2.game.entity_state_t;
import jake2.qcommon.Com;
import jake2.qcommon.MSG;
-import jake2.sound.*;
/**
* CL_fx
@@ -241,10 +239,11 @@ public class CL_fx extends CL_tent {
===============
*/
static void RunDLights() {
+ int i;
cdlight_t[] dl;
dl = cl_dlights;
- for (int i = 0; i < MAX_DLIGHTS; i++) {
+ for (i = 0; i < MAX_DLIGHTS; i++) {
if (dl[i].radius == 0.0f)
continue;
@@ -266,20 +265,24 @@ public class CL_fx extends CL_tent {
static void ParseMuzzleFlash() {
float[] fv = new float[3];
float[] rv = new float[3];
+ cdlight_t dl;
+ int i, weapon;
+ centity_t pl;
+ int silenced;
float volume;
String soundname;
- int i = MSG.ReadShort(net_message);
+ i = MSG.ReadShort(net_message);
if (i < 1 || i >= MAX_EDICTS)
Com.Error(ERR_DROP, "CL_ParseMuzzleFlash: bad entity");
- int weapon = MSG.ReadByte(net_message);
- int silenced = weapon & MZ_SILENCED;
+ weapon = MSG.ReadByte(net_message);
+ silenced = weapon & MZ_SILENCED;
weapon &= ~MZ_SILENCED;
- centity_t pl = cl_entities[i];
+ pl = cl_entities[i];
- cdlight_t dl = CL.AllocDlight(i);
+ dl = CL.AllocDlight(i);
VectorCopy(pl.current.origin, dl.origin);
AngleVectors(pl.current.angles, fv, rv, null);
VectorMA(dl.origin, 18, fv, dl.origin);
@@ -510,16 +513,19 @@ public class CL_fx extends CL_tent {
==============
*/
static void ParseMuzzleFlash2() {
+ int ent;
float[] origin = new float[3];
+ int flash_number;
+ cdlight_t dl;
float[] forward = new float[3];
float[] right = new float[3];
String soundname;
- int ent = MSG.ReadShort(net_message);
+ ent = MSG.ReadShort(net_message);
if (ent < 1 || ent >= MAX_EDICTS)
Com.Error(ERR_DROP, "CL_ParseMuzzleFlash2: bad entity");
- int flash_number = MSG.ReadByte(net_message);
+ flash_number = MSG.ReadByte(net_message);
// locate the origin
AngleVectors(cl_entities[ent].current.angles, forward, right, null);
@@ -537,7 +543,7 @@ public class CL_fx extends CL_tent {
+ right[2] * M_Flash.monster_flash_offset[flash_number][1]
+ M_Flash.monster_flash_offset[flash_number][2];
- cdlight_t dl = CL.AllocDlight(ent);
+ dl = CL.AllocDlight(ent);
VectorCopy(origin, dl.origin);
dl.radius = 200 + (rnd.nextInt() & 31);
dl.minlight = 32;
@@ -954,8 +960,9 @@ public class CL_fx extends CL_tent {
*/
static void AddDLights() {
int i;
-
- cdlight_t[] dl = cl_dlights;
+ cdlight_t[] dl;
+
+ dl = cl_dlights;
// =====
// PGM
@@ -1052,7 +1059,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -1087,7 +1094,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -1123,7 +1130,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -1190,9 +1197,9 @@ public class CL_fx extends CL_tent {
else
p.color = 0xe0 + (rand() & 7); // yellow
- p.org[0] = org[0] - 16 + Globals.rnd.nextFloat() * 32;
- p.org[1] = org[1] - 16 + Globals.rnd.nextFloat() * 32;
- p.org[2] = org[2] - 24 + Globals.rnd.nextFloat() * 56;
+ p.org[0] = org[0] - 16 + frand() * 32;
+ p.org[1] = org[1] - 16 + frand() * 32;
+ p.org[2] = org[2] - 24 + frand() * 56;
for (j = 0; j < 3; j++)
p.vel[j] = crand() * 20;
@@ -1201,7 +1208,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.3f);
}
}
@@ -1238,7 +1245,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY * 0.2f;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.3f);
}
}
@@ -1271,7 +1278,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
}
}
@@ -1313,7 +1320,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = PARTICLE_GRAVITY * 4;
p.alpha = 1.0f;
- p.alphavel = -0.3f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -0.3f / (0.5f + frand() * 0.3f);
}
}
@@ -1352,7 +1359,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -1392,7 +1399,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
p.color = 0xe0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
@@ -1439,7 +1446,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
p.color = 115;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -1486,7 +1493,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -1550,7 +1557,7 @@ public class CL_fx extends CL_tent {
if ((flags & EF_GIB) != 0) {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.4f);
p.color = 0xe8 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1560,7 +1567,7 @@ public class CL_fx extends CL_tent {
p.vel[2] -= PARTICLE_GRAVITY;
} else if ((flags & EF_GREENGIB) != 0) {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.4f);
p.color = 0xdb + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1570,7 +1577,7 @@ public class CL_fx extends CL_tent {
p.vel[2] -= PARTICLE_GRAVITY;
} else {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
p.color = 4 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1628,7 +1635,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
p.color = 0xdc + (rand() & 3);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 5;
@@ -1686,7 +1693,7 @@ public class CL_fx extends CL_tent {
VectorMA(dir, s, up, dir);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
p.color = clr + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + dir[j] * 3;
@@ -1714,7 +1721,7 @@ public class CL_fx extends CL_tent {
VectorClear(p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.6f + frand() * 0.2f);
p.color = 0x0 + rand() & 15;
for (j = 0; j < 3; j++) {
@@ -1762,7 +1769,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 0.5f;
- p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
p.color = 0xe4 + (rand() & 3);
for (j = 0; j < 3; j++) {
@@ -1818,7 +1825,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
p.color = 4 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 2;
@@ -2034,7 +2041,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
p.color = 0xe0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
@@ -2120,7 +2127,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
}
}
@@ -2131,14 +2138,14 @@ public class CL_fx extends CL_tent {
===============
*/
static void TeleportParticles(float[] org) {
-
+ int i, j, k;
cparticle_t p;
float vel;
float[] dir = new float[3];
- for (int i = -16; i <= 16; i += 4)
- for (int j = -16; j <= 16; j += 4)
- for (int k = -16; k <= 32; k += 4) {
+ for (i = -16; i <= 16; i += 4)
+ for (j = -16; j <= 16; j += 4)
+ for (k = -16; k <= 32; k += 4) {
if (free_particles == null)
return;
p = free_particles;
diff --git a/src/jake2/client/CL_newfx.java b/src/jake2/client/CL_newfx.java
index 5346226..67abf81 100644
--- a/src/jake2/client/CL_newfx.java
+++ b/src/jake2/client/CL_newfx.java
@@ -2,7 +2,7 @@
* CL_newfx.java
* Copyright (C) 2004
*
- * $Id: CL_newfx.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_newfx.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.client;
-import jake2.Globals;
-
/**
* CL_newfx
@@ -173,7 +171,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.5f);
+ p.alphavel = -1.0f / (1 + frand() * 0.5f);
p.color = colorStart + (rand() % colorRun);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 3;
@@ -206,7 +204,7 @@ public class CL_newfx extends CL_fx {
if (free_particles == null)
return;
- if (Globals.rnd.nextFloat() > 0.3) {
+ if (frand() > 0.3) {
p = free_particles;
free_particles = p.next;
p.next = active_particles;
@@ -216,7 +214,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (3.0f + Globals.rnd.nextFloat() * 0.5f);
+ p.alphavel = -1.0f / (3.0f + frand() * 0.5f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 3;
@@ -321,7 +319,7 @@ public class CL_newfx extends CL_fx {
// VectorCopy (accel, p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * alphavel);
+ p.alphavel = -1.0f / (0.5f + frand() * alphavel);
// p.alphavel = alphavel;
}
}
@@ -362,7 +360,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1+Globals.rnd.nextFloat()*0.1f);
+ p.alphavel = -1.0f / (1+frand()*0.1f);
p.color = 4 + (rand()&7);
for (j=0 ; j<3 ; j++)
{
@@ -512,7 +510,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY / 2;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -557,7 +555,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY / 2;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
self.nextthink += self.thinkinterval;
}
@@ -775,7 +773,7 @@ public class CL_newfx extends CL_fx {
p.accel[0] = p.accel[1] = 0;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
}
}
@@ -848,7 +846,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -889,7 +887,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.4f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -0.4f / (0.6f + frand() * 0.2f);
}
}
@@ -934,7 +932,7 @@ public class CL_newfx extends CL_fx {
p.accel[0] = p.accel[1] = p.accel[2] = 0;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat()*0.3f);
+ p.alphavel = -1.0f / (0.5f + frand()*0.3f);
}
}
@@ -973,7 +971,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
}
}
@@ -1014,7 +1012,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
p.color = 0xd0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java
index ad19960..d60de21 100644
--- a/src/jake2/client/CL_parse.java
+++ b/src/jake2/client/CL_parse.java
@@ -2,7 +2,7 @@
* CL_parse.java
* Copyright (C) 2004
*
- * $Id: CL_parse.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
+ * $Id: CL_parse.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,18 +25,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
import jake2.Defines;
import jake2.game.Cmd;
import jake2.game.entity_state_t;
-import jake2.qcommon.*;
+import jake2.qcommon.CM;
+import jake2.qcommon.Cbuf;
+import jake2.qcommon.Com;
+import jake2.qcommon.Cvar;
+import jake2.qcommon.FS;
+import jake2.qcommon.MSG;
+import jake2.qcommon.SZ;
+import jake2.qcommon.xcommand_t;
import jake2.render.model_t;
-import jake2.sound.S;
import jake2.sys.Sys;
import jake2.util.Lib;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
/**
* CL_parse
*/
@@ -191,10 +197,11 @@ public class CL_parse extends CL_view {
======================
*/
static void RegisterSounds() {
+ int i;
S.BeginRegistration();
CL.RegisterTEntSounds();
- for (int i = 1; i < MAX_SOUNDS; i++) {
- if (cl.configstrings[CS_SOUNDS + i] == null || cl.configstrings[CS_SOUNDS + i].equals("") || cl.configstrings[CS_SOUNDS + i].equals("\0"))
+ for (i = 1; i < MAX_SOUNDS; i++) {
+ if (cl.configstrings[CS_SOUNDS + i] == null || cl.configstrings[CS_SOUNDS + i] == "")
break;
cl.sound_precache[i] = S.RegisterSound(cl.configstrings[CS_SOUNDS + i]);
Sys.SendKeyEvents(); // pump message loop
@@ -210,10 +217,13 @@ public class CL_parse extends CL_view {
=====================
*/
public static void ParseDownload() {
+ int size, percent;
+ String name;
+ int r;
// read the data
- int size = MSG.ReadShort(net_message);
- int percent = MSG.ReadByte(net_message);
+ size = MSG.ReadShort(net_message);
+ percent = MSG.ReadByte(net_message);
if (size == -1) {
Com.Printf("Server does not have this file.\n");
if (cls.download != null) {
@@ -227,7 +237,7 @@ public class CL_parse extends CL_view {
// open the file if not opened yet
if (cls.download == null) {
- String name = DownloadFileName(cls.downloadtempname);
+ name = DownloadFileName(cls.downloadtempname);
FS.CreatePath(name);
@@ -267,7 +277,7 @@ public class CL_parse extends CL_view {
// rename the temp file to it's final name
oldn = DownloadFileName(cls.downloadtempname);
newn = DownloadFileName(cls.downloadname);
- int r = Lib.rename(oldn, newn);
+ r = Lib.rename(oldn, newn);
if (r != 0)
Com.Printf("failed to rename.\n");
@@ -549,7 +559,7 @@ public class CL_parse extends CL_view {
}
else if (i >= CS_SOUNDS && i < CS_SOUNDS + MAX_MODELS) {
if (cl.refresh_prepped)
- cl.sound_precache[i - CS_SOUNDS] = S.RegisterSound(cl.configstrings[i]);
+ cl.sound_precache[i - CS_SOUNDS] = SND_DMA.RegisterSound(cl.configstrings[i]);
}
else if (i >= CS_IMAGES && i < CS_IMAGES + MAX_MODELS) {
if (cl.refresh_prepped)
@@ -626,7 +636,7 @@ public class CL_parse extends CL_view {
if (null==cl.sound_precache[sound_num])
return;
- S.StartSound(pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs);
+ SND_DMA.StartSound(pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs);
}
public static void SHOWNET(String s) {
@@ -703,7 +713,7 @@ public class CL_parse extends CL_view {
case svc_print :
i = MSG.ReadByte(net_message);
if (i == PRINT_CHAT) {
- S.StartLocalSound("misc/talk.wav");
+ SND_DMA.StartLocalSound("misc/talk.wav");
con.ormask = 128;
}
Com.Printf(MSG.ReadString(net_message));
diff --git a/src/jake2/client/CL_pred.java b/src/jake2/client/CL_pred.java
index 0b0e2ab..eecf0eb 100644
--- a/src/jake2/client/CL_pred.java
+++ b/src/jake2/client/CL_pred.java
@@ -2,7 +2,7 @@
* CL_pred.java
* Copyright (C) 2004
*
- * $Id: CL_pred.java,v 1.3 2004-07-08 20:24:28 hzi Exp $
+ * $Id: CL_pred.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -203,6 +203,14 @@ public class CL_pred extends CL_parse {
=================
*/
static void PredictMovement() {
+ int ack, current;
+ int frame;
+ int oldframe;
+ usercmd_t cmd;
+ pmove_t pm;
+ int i;
+ int step;
+ int oldz;
if (cls.state != ca_active)
return;
@@ -212,14 +220,14 @@ public class CL_pred extends CL_parse {
if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) {
// just set angles
- for (int i = 0; i < 3; i++) {
+ for (i = 0; i < 3; i++) {
cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]);
}
return;
}
- int ack = cls.netchan.incoming_acknowledged;
- int current = cls.netchan.outgoing_sequence;
+ ack = cls.netchan.incoming_acknowledged;
+ current = cls.netchan.outgoing_sequence;
// if we are too far out of date, just freeze
if (current - ack >= CMD_BACKUP) {
@@ -230,7 +238,7 @@ public class CL_pred extends CL_parse {
// copy current state to pmove
//memset (pm, 0, sizeof(pm));
- pmove_t pm = new pmove_t();
+ pm = new pmove_t();
pm.trace = new pmove_t.TraceAdapter() {
public trace_t trace(float[] start, float[] mins, float[] maxs, float[] end) {
@@ -249,10 +257,9 @@ public class CL_pred extends CL_parse {
pm.s.set(cl.frame.playerstate.pmove);
// SCR_DebugGraph (current - ack - 1, 0);
- int frame = 0;
+ frame = 0;
// run frames
- usercmd_t cmd;
while (++ack < current) {
frame = ack & (CMD_BACKUP - 1);
cmd = cl.cmds[frame];
@@ -265,9 +272,9 @@ public class CL_pred extends CL_parse {
VectorCopy(pm.s.origin, cl.predicted_origins[frame]);
}
- int oldframe = (ack - 2) & (CMD_BACKUP - 1);
- int oldz = cl.predicted_origins[oldframe][2];
- int step = pm.s.origin[2] - oldz;
+ oldframe = (ack - 2) & (CMD_BACKUP - 1);
+ oldz = cl.predicted_origins[oldframe][2];
+ step = pm.s.origin[2] - oldz;
if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) {
cl.predicted_step = step * 0.125f;
cl.predicted_step_time = (int) (cls.realtime - cls.frametime * 500);
diff --git a/src/jake2/client/CL_tent.java b/src/jake2/client/CL_tent.java
index 8966e01..7430a45 100644
--- a/src/jake2/client/CL_tent.java
+++ b/src/jake2/client/CL_tent.java
@@ -2,7 +2,7 @@
* CL_tent.java
* Copyright (C) 2004
*
- * $Id: CL_tent.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL_tent.java,v 1.1 2004-07-07 19:58:40 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,7 +30,6 @@ import jake2.game.player_state_t;
import jake2.qcommon.Com;
import jake2.qcommon.MSG;
import jake2.render.model_t;
-import jake2.sound.*;
/**
* CL_tent
@@ -907,7 +906,7 @@ public class CL_tent extends Globals {
ex.lightcolor[2] = 0.5f;
ex.ent.angles[1] = rand() % 360;
ex.ent.model = cl_mod_explo4;
- if (Globals.rnd.nextFloat() < 0.5)
+ if (frand() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
CL.ExplosionParticles(pos);
@@ -935,7 +934,7 @@ public class CL_tent extends Globals {
ex.ent.model = cl_mod_explo4; // PMM
else
ex.ent.model = cl_mod_explo4_big;
- if (Globals.rnd.nextFloat() < 0.5)
+ if (frand() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
if ((type != TE_EXPLOSION1_BIG) && (type != TE_EXPLOSION1_NP)) // PMM
@@ -1108,7 +1107,7 @@ public class CL_tent extends Globals {
ex.lightcolor[2] = 0.5f;
ex.ent.angles[1] = rand() % 360;
ex.ent.model = cl_mod_explo4;
- if (Globals.rnd.nextFloat() < 0.5)
+ if (frand() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
if (type == TE_ROCKET_EXPLOSION_WATER)
diff --git a/src/jake2/client/CL_view.java b/src/jake2/client/CL_view.java
index 08e55c3..2d2e7ab 100644
--- a/src/jake2/client/CL_view.java
+++ b/src/jake2/client/CL_view.java
@@ -2,7 +2,7 @@
* CL_view.java
* Copyright (C) 2004
*
- * $Id: CL_view.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_view.java,v 1.1 2004-07-07 19:58:40 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -51,14 +51,12 @@ public class CL_view extends CL_input {
=================
*/
- private static xcommand_t prepRefreshCallback = new xcommand_t() {
- public void execute() {
- PrepRefresh2();
- }
- };
-
static void PrepRefresh() {
- re.updateScreen(prepRefreshCallback);
+ re.updateScreen(new xcommand_t() {
+ public void execute() {
+ PrepRefresh2();
+ }
+ });
}
static void PrepRefresh2() {
diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java
index 0b3e82a..2fe8ed3 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.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: Key.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -288,7 +288,9 @@ 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, long time) {
+ //System.out.println(key + " " + down);
+ //return;
String kb;
String cmd;
@@ -322,11 +324,14 @@ public class Key extends Globals {
shift_down = down;
// console key is hardcoded, so the user can never unbind it
- if (key == '#' || key == '~') {
+ if (key == '`' || key == '~') {
if (!down)
return;
-
- Console.ToggleConsole_f.execute();
+ try {
+ Console.ToggleConsole_f.execute();
+ }
+ catch (Exception e) {
+ }
return;
}
diff --git a/src/jake2/client/M.java b/src/jake2/client/M.java
index 3e076a6..86747f8 100644
--- a/src/jake2/client/M.java
+++ b/src/jake2/client/M.java
@@ -2,7 +2,7 @@
* M.java
* Copyright (C) 2003
*
- * $Id: M.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: M.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.client;
import jake2.Defines;
-import jake2.Globals;
import jake2.game.*;
+import jake2.qcommon.Com;
import jake2.server.SV;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -393,7 +393,7 @@ public final class M
if (0 == (ent.svflags & Defines.SVF_DEADMONSTER))
{
if ((ent.watertype & Defines.CONTENTS_LAVA) != 0)
- if (Globals.rnd.nextFloat() <= 0.5)
+ if (Lib.random() <= 0.5)
GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/lava1.wav"), 1, Defines.ATTN_NORM, 0);
else
GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/lava2.wav"), 1, Defines.ATTN_NORM, 0);
@@ -629,11 +629,11 @@ public final class M
if (self.waterlevel != 0)
return true;
- if (Globals.rnd.nextFloat() > 0.5)
+ if (Lib.random() > 0.5)
return true;
self.think = M_FliesOn;
- self.nextthink = GameBase.level.time + 5 + 10 * Globals.rnd.nextFloat();
+ self.nextthink = GameBase.level.time + 5 + 10 * Lib.random();
return true;
}
};
diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java
index 00944ed..8ac689f 100644
--- a/src/jake2/client/Menu.java
+++ b/src/jake2/client/Menu.java
@@ -2,7 +2,7 @@
* Menu.java
* Copyright (C) 2004
*
- * $Id: Menu.java,v 1.3 2004-07-08 20:56:49 hzi Exp $
+ * $Id: Menu.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,7 +29,6 @@ import jake2.Globals;
import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
-import jake2.sound.*;
import jake2.sys.NET;
import jake2.sys.Sys;
import jake2.util.Lib;
diff --git a/src/jake2/client/S.java b/src/jake2/client/S.java
new file mode 100644
index 0000000..302de14
--- /dev/null
+++ b/src/jake2/client/S.java
@@ -0,0 +1,33 @@
+/*
+ * S.java
+ * Copyright (C) 2003
+ *
+ * $Id: S.java,v 1.1 2004-07-07 19:58:51 hzi 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.
+
+*/
+package jake2.client;
+
+/**
+ * S
+ */
+public class S extends SND_DMA {
+
+}
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 66b5c33..8363f6e 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -2,7 +2,7 @@
* SCR.java
* Copyright (C) 2003
*
- * $Id: SCR.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
+ * $Id: SCR.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,7 +30,6 @@ import jake2.Globals;
import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
-import jake2.sound.*;
import jake2.sys.Sys;
import jake2.util.Vargs;
@@ -85,6 +84,7 @@ public final class SCR extends Globals
static cvar_t scr_graphshift;
static cvar_t scr_drawall;
static cvar_t fps;
+ static cvar_t fps_updates;
static dirty_t scr_dirty = new dirty_t();
static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t()};
@@ -436,6 +436,7 @@ public final class SCR extends Globals
scr_graphshift = Cvar.Get("graphshift", "0", 0);
scr_drawall = Cvar.Get("scr_drawall", "1", 0);
fps = Cvar.Get("fps", "0", 0);
+ fps_updates = Cvar.Get("fps_updates", "1", 0);
//
// register our commands
@@ -1420,16 +1421,10 @@ public final class SCR extends Globals
crosshair_pic);
}
- private static xcommand_t updateScreenCallback = new xcommand_t() {
- public void execute() {
- UpdateScreen2();
- }
- };
-
// wird anstelle von der richtigen UpdateScreen benoetigt
public static void UpdateScreen()
{
- Globals.re.updateScreen(updateScreenCallback);
+ Globals.re.updateScreen(null);
}
/*
diff --git a/src/jake2/client/SND_DMA.java b/src/jake2/client/SND_DMA.java
new file mode 100644
index 0000000..dc487d8
--- /dev/null
+++ b/src/jake2/client/SND_DMA.java
@@ -0,0 +1,1245 @@
+/*
+ * S_DMA.java
+ * Copyright (C) 2004
+ *
+ * $Id: SND_DMA.java,v 1.2 2004-07-08 15:58:42 hzi 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.
+
+*/
+
+// Created on 26.01.2004 by RST.
+
+package jake2.client;
+
+import jake2.game.Cmd;
+import jake2.game.cvar_t;
+import jake2.qcommon.*;
+import jake2.util.Vargs;
+
+
+
+/**
+ * SND_DMA
+ * TODO implement sound system
+ */
+public class SND_DMA extends SND_MIX {
+//// snd_dma.c -- main control for any streaming sound output device
+//
+// #include "client.h"
+// #include "snd_loc.h"
+//
+// void S_Play(void);
+// void S_SoundList(void);
+// void S_Update_();
+// void S_StopAllSounds(void);
+//
+//
+//// =======================================================================
+//// Internal sound data & structures
+//// =======================================================================
+//
+//// only begin attenuating sound volumes when outside the FULLVOLUME range
+// #define SOUND_FULLVOLUME 80
+//
+// #define SOUND_LOOPATTENUATE 0.003
+//
+ static int s_registration_sequence;
+//
+// channel_t channels[MAX_CHANNELS];
+//
+// qboolean snd_initialized = false;
+ static boolean sound_started = false;
+//
+
+
+//
+// vec3_t listener_origin;
+// vec3_t listener_forward;
+// vec3_t listener_right;
+// vec3_t listener_up;
+//
+ static boolean s_registering;
+//
+ static int soundtime; // sample PAIRS
+ static int paintedtime; // sample PAIRS
+//
+//// during registration it is possible to have more sounds
+//// than could actually be referenced during gameplay,
+//// because we don't want to free anything until we are
+//// sure we won't need it.
+ static final int MAX_SFX = (MAX_SOUNDS*2);
+ static sfx_t[] known_sfx = new sfx_t[MAX_SFX];
+ static {
+ for (int i = 0; i< known_sfx.length; i++)
+ known_sfx[i] = new sfx_t();
+ }
+ static int num_sfx;
+//
+// #define MAX_PLAYSOUNDS 128
+// playsound_t s_playsounds[MAX_PLAYSOUNDS];
+// playsound_t s_freeplays;
+// playsound_t s_pendingplays;
+//
+// int s_beginofs;
+//
+ static cvar_t s_volume;
+ static cvar_t s_testsound;
+ static cvar_t s_loadas8bit;
+ static cvar_t s_khz;
+ static cvar_t s_show;
+ static cvar_t s_mixahead;
+ static cvar_t s_primary;
+//
+//
+// int s_rawend;
+// portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
+//
+//
+// ====================================================================
+// User-setable variables
+// ====================================================================
+
+
+ static void SoundInfo_f() {
+ if (!sound_started) {
+ Com.Printf("sound system not started\n");
+ return;
+ }
+
+ Com.Printf("%5d stereo\n", new Vargs(1).add(dma.channels - 1));
+ Com.Printf("%5d samples\n", new Vargs(1).add(dma.samples));
+ Com.Printf("%5d samplepos\n", new Vargs(1).add(dma.samplepos));
+ Com.Printf("%5d samplebits\n", new Vargs(1).add(dma.samplebits));
+ Com.Printf("%5d submission_chunk\n", new Vargs(1).add(dma.submission_chunk));
+ Com.Printf("%5d speed\n", new Vargs(1).add(dma.speed));
+ }
+
+ /*
+ ================
+ S_Init
+ ================
+ */
+ public static void Init() {
+ cvar_t cv;
+
+ Com.Printf("\n------- sound initialization -------\n");
+
+ cv = Cvar.Get("s_initsound", "1", 0);
+ if (cv.value == 0.0f)
+ Com.Printf("not initializing.\n");
+ else {
+ s_volume = Cvar.Get("s_volume", "0.7", CVAR_ARCHIVE);
+ s_khz = Cvar.Get("s_khz", "11", CVAR_ARCHIVE);
+ s_loadas8bit = Cvar.Get("s_loadas8bit", "1", CVAR_ARCHIVE);
+ s_mixahead = Cvar.Get("s_mixahead", "0.2", CVAR_ARCHIVE);
+ s_show = Cvar.Get("s_show", "0", 0);
+ s_testsound = Cvar.Get("s_testsound", "0", 0);
+ s_primary = Cvar.Get("s_primary", "0", CVAR_ARCHIVE); // win32 specific
+
+ Cmd.AddCommand("play", new xcommand_t() {
+ public void execute() {
+ S.Play();
+ }
+ });
+ Cmd.AddCommand("stopsound", new xcommand_t() {
+ public void execute() {
+ S.StopAllSounds();
+ }
+ });
+ Cmd.AddCommand("soundlist", new xcommand_t() {
+ public void execute() {
+ S.SoundList();
+ }
+ });
+ Cmd.AddCommand("soundinfo", new xcommand_t() {
+ public void execute() {
+ S.SoundInfo_f();
+ }
+ });
+
+ if (!SNDDMA_Init())
+ return;
+
+ S.InitScaletable();
+
+ sound_started = true;
+ num_sfx = 0;
+
+ soundtime = 0;
+ paintedtime = 0;
+
+ Com.Printf("sound sampling rate: " + dma.speed + "\n");
+
+ S.StopAllSounds();
+ }
+S.SoundInfo_f();
+ Com.Printf("------------------------------------\n");
+ }
+
+
+// =======================================================================
+// Shutdown sound engine
+// =======================================================================
+
+ static void Shutdown()
+ {
+ int i;
+ sfx_t[] sfx;
+
+ if (!sound_started)
+ return;
+
+ SNDDMA_Shutdown();
+
+ sound_started = false;
+
+ Cmd.RemoveCommand("play");
+ Cmd.RemoveCommand("stopsound");
+ Cmd.RemoveCommand("soundlist");
+ Cmd.RemoveCommand("soundinfo");
+
+ // free all sounds
+ for (i=0, sfx=known_sfx ; i < num_sfx ; i++)
+ {
+ if (sfx[i].name == null)
+ continue;
+
+ //memset (sfx, 0, sizeof(*sfx));
+ sfx[i].clear();
+ }
+
+ num_sfx = 0;
+ }
+
+// =======================================================================
+// Load a sound
+// =======================================================================
+
+ /*
+ ==================
+ S_FindName
+
+ ==================
+ */
+ static sfx_t FindName(String name, boolean create) {
+ int i;
+ sfx_t sfx = null;
+
+ if (name == null)
+ Com.Error(ERR_FATAL, "S_FindName: NULL\n");
+ if (name.length() == 0)
+ Com.Error(ERR_FATAL, "S_FindName: empty name\n");
+
+ if (name.length() >= MAX_QPATH)
+ Com.Error(ERR_FATAL, "Sound name too long: " + name);
+
+ // see if already loaded
+ for (i = 0; i < num_sfx; i++)
+ if (name.equals(known_sfx[i].name)) {
+ return known_sfx[i];
+ }
+
+ if (!create)
+ return null;
+
+ // find a free sfx
+ for (i = 0; i < num_sfx; i++)
+ if (known_sfx[i].name == null)
+ // registration_sequence < s_registration_sequence)
+ break;
+
+ if (i == num_sfx) {
+ if (num_sfx == MAX_SFX)
+ Com.Error(ERR_FATAL, "S_FindName: out of sfx_t");
+ num_sfx++;
+ }
+
+ sfx = known_sfx[i];
+ //memset (sfx, 0, sizeof(*sfx));
+ sfx.clear();
+ sfx.name = name;
+ sfx.registration_sequence = s_registration_sequence;
+
+ return sfx;
+ }
+//
+//
+// /*
+// ==================
+// S_AliasName
+//
+// ==================
+// */
+// sfx_t *S_AliasName (char *aliasname, char *truename)
+// {
+// sfx_t *sfx;
+// char *s;
+// int i;
+//
+// s = Z_Malloc (MAX_QPATH);
+// strcpy (s, truename);
+//
+// // find a free sfx
+// for (i=0 ; i < num_sfx ; i++)
+// if (!known_sfx[i].name[0])
+// break;
+//
+// if (i == num_sfx)
+// {
+// if (num_sfx == MAX_SFX)
+// Com_Error (ERR_FATAL, "S_FindName: out of sfx_t");
+// num_sfx++;
+// }
+//
+// sfx = &known_sfx[i];
+// memset (sfx, 0, sizeof(*sfx));
+// strcpy (sfx->name, aliasname);
+// sfx->registration_sequence = s_registration_sequence;
+// sfx->truename = s;
+//
+// return sfx;
+// }
+//
+//
+ /*
+ =====================
+ S_BeginRegistration
+
+ =====================
+ */
+ static void BeginRegistration() {
+ s_registration_sequence++;
+ s_registering = true;
+ }
+
+ /*
+ ==================
+ S_RegisterSound
+
+ ==================
+ */
+ static sfx_t RegisterSound(String name) {
+ sfx_t sfx = null;
+
+// if (!sound_started)
+// return null;
+//
+// sfx = S.FindName(name, true);
+// sfx.registration_sequence = s_registration_sequence;
+//
+// if (!s_registering)
+// S.LoadSound(sfx);
+
+ return sfx;
+ }
+
+
+ /*
+ =====================
+ S_EndRegistration
+
+ =====================
+ */
+ static void EndRegistration ()
+ {
+// int i;
+// sfx_t *sfx;
+// int size;
+//
+// // free any sounds not from this registration sequence
+// for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
+// {
+// if (!sfx->name[0])
+// continue;
+// if (sfx->registration_sequence != s_registration_sequence)
+// { // don't need this sound
+// if (sfx->cache) // it is possible to have a leftover
+// Z_Free (sfx->cache); // from a server that didn't finish loading
+// memset (sfx, 0, sizeof(*sfx));
+// }
+// else
+// { // make sure it is paged in
+// if (sfx->cache)
+// {
+// size = sfx->cache->length*sfx->cache->width;
+// Com_PageInMemory ((byte *)sfx->cache, size);
+// }
+// }
+//
+// }
+//
+// // load everything in
+// for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
+// {
+// if (!sfx->name[0])
+// continue;
+// S_LoadSound (sfx);
+// }
+//
+// s_registering = false;
+ }
+//
+//
+//// =============================================================================
+//
+// /*
+// =================
+// S_PickChannel
+// =================
+// */
+// channel_t *S_PickChannel(int entnum, int entchannel)
+// {
+// int ch_idx;
+// int first_to_die;
+// int life_left;
+// channel_t *ch;
+//
+// if (entchannel<0)
+// Com_Error (ERR_DROP, "S_PickChannel: entchannel<0");
+//
+//// Check for replacement sound, or find the best one to replace
+// first_to_die = -1;
+// life_left = 0x7fffffff;
+// for (ch_idx=0 ; ch_idx < MAX_CHANNELS ; ch_idx++)
+// {
+// if (entchannel != 0 // channel 0 never overrides
+// && channels[ch_idx].entnum == entnum
+// && channels[ch_idx].entchannel == entchannel)
+// { // always override sound from same entity
+// first_to_die = ch_idx;
+// break;
+// }
+//
+// // don't let monster sounds override player sounds
+// if (channels[ch_idx].entnum == cl.playernum+1 && entnum != cl.playernum+1 && channels[ch_idx].sfx)
+// continue;
+//
+// if (channels[ch_idx].end - paintedtime < life_left)
+// {
+// life_left = channels[ch_idx].end - paintedtime;
+// first_to_die = ch_idx;
+// }
+// }
+//
+// if (first_to_die == -1)
+// return NULL;
+//
+// ch = &channels[first_to_die];
+// memset (ch, 0, sizeof(*ch));
+//
+// return ch;
+// }
+//
+// /*
+// =================
+// S_SpatializeOrigin
+//
+// Used for spatializing channels and autosounds
+// =================
+// */
+// void S_SpatializeOrigin (vec3_t origin, float master_vol, float dist_mult, int *left_vol, int *right_vol)
+// {
+// vec_t dot;
+// vec_t dist;
+// vec_t lscale, rscale, scale;
+// vec3_t source_vec;
+//
+// if (cls.state != ca_active)
+// {
+// *left_vol = *right_vol = 255;
+// return;
+// }
+//
+//// calculate stereo seperation and distance attenuation
+// VectorSubtract(origin, listener_origin, source_vec);
+//
+// dist = VectorNormalize(source_vec);
+// dist -= SOUND_FULLVOLUME;
+// if (dist < 0)
+// dist = 0; // close enough to be at full volume
+// dist *= dist_mult; // different attenuation levels
+//
+// dot = DotProduct(listener_right, source_vec);
+//
+// if (dma.channels == 1 || !dist_mult)
+// { // no attenuation = no spatialization
+// rscale = 1.0;
+// lscale = 1.0;
+// }
+// else
+// {
+// rscale = 0.5 * (1.0 + dot);
+// lscale = 0.5*(1.0 - dot);
+// }
+//
+// // add in distance effect
+// scale = (1.0 - dist) * rscale;
+// *right_vol = (int) (master_vol * scale);
+// if (*right_vol < 0)
+// *right_vol = 0;
+//
+// scale = (1.0 - dist) * lscale;
+// *left_vol = (int) (master_vol * scale);
+// if (*left_vol < 0)
+// *left_vol = 0;
+// }
+//
+// /*
+// =================
+// S_Spatialize
+// =================
+// */
+// void S_Spatialize(channel_t *ch)
+// {
+// vec3_t origin;
+//
+// // anything coming from the view entity will always be full volume
+// if (ch->entnum == cl.playernum+1)
+// {
+// ch->leftvol = ch->master_vol;
+// ch->rightvol = ch->master_vol;
+// return;
+// }
+//
+// if (ch->fixed_origin)
+// {
+// VectorCopy (ch->origin, origin);
+// }
+// else
+// CL_GetEntitySoundOrigin (ch->entnum, origin);
+//
+// S_SpatializeOrigin (origin, ch->master_vol, ch->dist_mult, &ch->leftvol, &ch->rightvol);
+// }
+//
+//
+// /*
+// =================
+// S_AllocPlaysound
+// =================
+// */
+// playsound_t *S_AllocPlaysound (void)
+// {
+// playsound_t *ps;
+//
+// ps = s_freeplays.next;
+// if (ps == &s_freeplays)
+// return NULL; // no free playsounds
+//
+// // unlink from freelist
+// ps->prev->next = ps->next;
+// ps->next->prev = ps->prev;
+//
+// return ps;
+// }
+//
+//
+// /*
+// =================
+// S_FreePlaysound
+// =================
+// */
+// void S_FreePlaysound (playsound_t *ps)
+// {
+// // unlink from channel
+// ps->prev->next = ps->next;
+// ps->next->prev = ps->prev;
+//
+// // add to free list
+// ps->next = s_freeplays.next;
+// s_freeplays.next->prev = ps;
+// ps->prev = &s_freeplays;
+// s_freeplays.next = ps;
+// }
+//
+//
+//
+// /*
+// ===============
+// S_IssuePlaysound
+//
+// Take the next playsound and begin it on the channel
+// This is never called directly by S_Play*, but only
+// by the update loop.
+// ===============
+// */
+// void S_IssuePlaysound (playsound_t *ps)
+// {
+// channel_t *ch;
+// sfxcache_t *sc;
+//
+// if (s_show->value)
+// Com_Printf ("Issue %i\n", ps->begin);
+// // pick a channel to play on
+// ch = S_PickChannel(ps->entnum, ps->entchannel);
+// if (!ch)
+// {
+// S_FreePlaysound (ps);
+// return;
+// }
+//
+// // spatialize
+// if (ps->attenuation == ATTN_STATIC)
+// ch->dist_mult = ps->attenuation * 0.001;
+// else
+// ch->dist_mult = ps->attenuation * 0.0005;
+// ch->master_vol = ps->volume;
+// ch->entnum = ps->entnum;
+// ch->entchannel = ps->entchannel;
+// ch->sfx = ps->sfx;
+// VectorCopy (ps->origin, ch->origin);
+// ch->fixed_origin = ps->fixed_origin;
+//
+// S_Spatialize(ch);
+//
+// ch->pos = 0;
+// sc = S_LoadSound (ch->sfx);
+// ch->end = paintedtime + sc->length;
+//
+// // free the playsound
+// S_FreePlaysound (ps);
+// }
+//
+// struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
+// {
+// int n;
+// char *p;
+// struct sfx_s *sfx;
+// FILE *f;
+// char model[MAX_QPATH];
+// char sexedFilename[MAX_QPATH];
+// char maleFilename[MAX_QPATH];
+//
+// // determine what model the client is using
+// model[0] = 0;
+// n = CS_PLAYERSKINS + ent->number - 1;
+// if (cl.configstrings[n][0])
+// {
+// p = strchr(cl.configstrings[n], '\\');
+// if (p)
+// {
+// p += 1;
+// strcpy(model, p);
+// p = strchr(model, '/');
+// if (p)
+// *p = 0;
+// }
+// }
+// // if we can't figure it out, they're male
+// if (!model[0])
+// strcpy(model, "male");
+//
+// // see if we already know of the model specific sound
+// Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
+// sfx = S_FindName (sexedFilename, false);
+//
+// if (!sfx)
+// {
+// // no, so see if it exists
+// FS_FOpenFile (&sexedFilename[1], &f);
+// if (f)
+// {
+// // yes, close the file and register it
+// FS_FCloseFile (f);
+// sfx = S_RegisterSound (sexedFilename);
+// }
+// else
+// {
+// // no, revert to the male sound in the pak0.pak
+// Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
+// sfx = S_AliasName (sexedFilename, maleFilename);
+// }
+// }
+//
+// return sfx;
+// }
+//
+//
+//// =======================================================================
+//// Start a sound effect
+//// =======================================================================
+//
+ /*
+ ====================
+ S_StartSound
+
+ Validates the parms and ques the sound up
+ if pos is NULL, the sound will be dynamically sourced from the entity
+ Entchannel 0 will never override a playing sound
+ ====================
+ */
+ static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs)
+ {
+// sfxcache_t *sc;
+// int vol;
+// playsound_t *ps, *sort;
+// int start;
+//
+// if (!sound_started)
+// return;
+//
+// if (!sfx)
+// return;
+//
+// if (sfx->name[0] == '*')
+// sfx = S_RegisterSexedSound(&cl_entities[entnum].current, sfx->name);
+//
+// // make sure the sound is loaded
+// sc = S_LoadSound (sfx);
+// if (!sc)
+// return; // couldn't load the sound's data
+//
+// vol = fvol*255;
+//
+// // make the playsound_t
+// ps = S_AllocPlaysound ();
+// if (!ps)
+// return;
+//
+// if (origin)
+// {
+// VectorCopy (origin, ps->origin);
+// ps->fixed_origin = true;
+// }
+// else
+// ps->fixed_origin = false;
+//
+// ps->entnum = entnum;
+// ps->entchannel = entchannel;
+// ps->attenuation = attenuation;
+// ps->volume = vol;
+// ps->sfx = sfx;
+//
+// // drift s_beginofs
+// start = cl.frame.servertime * 0.001 * dma.speed + s_beginofs;
+// if (start < paintedtime)
+// {
+// start = paintedtime;
+// s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
+// }
+// else if (start > paintedtime + 0.3 * dma.speed)
+// {
+// start = paintedtime + 0.1 * dma.speed;
+// s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
+// }
+// else
+// {
+// s_beginofs-=10;
+// }
+//
+// if (!timeofs)
+// ps->begin = paintedtime;
+// else
+// ps->begin = start + timeofs * dma.speed;
+//
+// // sort into the pending sound list
+// for (sort = s_pendingplays.next ;
+// sort != &s_pendingplays && sort->begin < ps->begin ;
+// sort = sort->next)
+// ;
+//
+// ps->next = sort;
+// ps->prev = sort->prev;
+//
+// ps->next->prev = ps;
+// ps->prev->next = ps;
+ }
+
+//
+// /*
+// ==================
+// S_StartLocalSound
+// ==================
+// */
+ static void StartLocalSound(String sound) {
+// sfx_t *sfx;
+//
+// if (!sound_started)
+// return;
+//
+// sfx = S_RegisterSound (sound);
+// if (!sfx)
+// {
+// Com_Printf ("S_StartLocalSound: can't cache %s\n", sound);
+// return;
+// }
+// S_StartSound (NULL, cl.playernum+1, 0, sfx, 1, 1, 0);
+ }
+//
+//
+// /*
+// ==================
+// S_ClearBuffer
+// ==================
+// */
+// void S_ClearBuffer (void)
+// {
+// int clear;
+//
+// if (!sound_started)
+// return;
+//
+// s_rawend = 0;
+//
+// if (dma.samplebits == 8)
+// clear = 0x80;
+// else
+// clear = 0;
+//
+// SNDDMA_BeginPainting ();
+// if (dma.buffer)
+// memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
+// SNDDMA_Submit ();
+// }
+//
+ /*
+ ==================
+ S_StopAllSounds
+ ==================
+ */
+ static void StopAllSounds()
+ {
+// int i;
+//
+// if (!sound_started)
+// return;
+//
+// // clear all the playsounds
+// memset(s_playsounds, 0, sizeof(s_playsounds));
+// s_freeplays.next = s_freeplays.prev = &s_freeplays;
+// s_pendingplays.next = s_pendingplays.prev = &s_pendingplays;
+//
+// for (i=0 ; i<MAX_PLAYSOUNDS ; i++)
+// {
+// s_playsounds[i].prev = &s_freeplays;
+// s_playsounds[i].next = s_freeplays.next;
+// s_playsounds[i].prev->next = &s_playsounds[i];
+// s_playsounds[i].next->prev = &s_playsounds[i];
+// }
+//
+// // clear all the channels
+// memset(channels, 0, sizeof(channels));
+//
+// S_ClearBuffer ();
+ }
+//
+// /*
+// ==================
+// S_AddLoopSounds
+//
+// Entities with a ->sound field will generated looped sounds
+// that are automatically started, stopped, and merged together
+// as the entities are sent to the client
+// ==================
+// */
+// void S_AddLoopSounds (void)
+// {
+// int i, j;
+// int sounds[MAX_EDICTS];
+// int left, right, left_total, right_total;
+// channel_t *ch;
+// sfx_t *sfx;
+// sfxcache_t *sc;
+// int num;
+// entity_state_t *ent;
+//
+// if (cl_paused->value)
+// return;
+//
+// if (cls.state != ca_active)
+// return;
+//
+// if (!cl.sound_prepped)
+// return;
+//
+// for (i=0 ; i<cl.frame.num_entities ; i++)
+// {
+// num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
+// ent = &cl_parse_entities[num];
+// sounds[i] = ent->sound;
+// }
+//
+// for (i=0 ; i<cl.frame.num_entities ; i++)
+// {
+// if (!sounds[i])
+// continue;
+//
+// sfx = cl.sound_precache[sounds[i]];
+// if (!sfx)
+// continue; // bad sound effect
+// sc = sfx->cache;
+// if (!sc)
+// continue;
+//
+// num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
+// ent = &cl_parse_entities[num];
+//
+// // find the total contribution of all sounds of this type
+// S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
+// &left_total, &right_total);
+// for (j=i+1 ; j<cl.frame.num_entities ; j++)
+// {
+// if (sounds[j] != sounds[i])
+// continue;
+// sounds[j] = 0; // don't check this again later
+//
+// num = (cl.frame.parse_entities + j)&(MAX_PARSE_ENTITIES-1);
+// ent = &cl_parse_entities[num];
+//
+// S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
+// &left, &right);
+// left_total += left;
+// right_total += right;
+// }
+//
+// if (left_total == 0 && right_total == 0)
+// continue; // not audible
+//
+// // allocate a channel
+// ch = S_PickChannel(0, 0);
+// if (!ch)
+// return;
+//
+// if (left_total > 255)
+// left_total = 255;
+// if (right_total > 255)
+// right_total = 255;
+// ch->leftvol = left_total;
+// ch->rightvol = right_total;
+// ch->autosound = true; // remove next frame
+// ch->sfx = sfx;
+// ch->pos = paintedtime % sc->length;
+// ch->end = paintedtime + sc->length - ch->pos;
+// }
+// }
+//
+//// =============================================================================
+//
+// /*
+// ============
+// S_RawSamples
+//
+// Cinematic streaming and voice over network
+// ============
+// */
+// void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
+// {
+// int i;
+// int src, dst;
+// float scale;
+//
+// if (!sound_started)
+// return;
+//
+// if (s_rawend < paintedtime)
+// s_rawend = paintedtime;
+// scale = (float)rate / dma.speed;
+//
+//// Com_Printf ("%i < %i < %i\n", soundtime, paintedtime, s_rawend);
+// if (channels == 2 && width == 2)
+// {
+// if (scale == 1.0)
+// { // optimized case
+// for (i=0 ; i<samples ; i++)
+// {
+// dst = s_rawend&(MAX_RAW_SAMPLES-1);
+// s_rawend++;
+// s_rawsamples[dst].left =
+// LittleShort(((short *)data)[i*2]) << 8;
+// s_rawsamples[dst].right =
+// LittleShort(((short *)data)[i*2+1]) << 8;
+// }
+// }
+// else
+// {
+// for (i=0 ; ; i++)
+// {
+// src = i*scale;
+// if (src >= samples)
+// break;
+// dst = s_rawend&(MAX_RAW_SAMPLES-1);
+// s_rawend++;
+// s_rawsamples[dst].left =
+// LittleShort(((short *)data)[src*2]) << 8;
+// s_rawsamples[dst].right =
+// LittleShort(((short *)data)[src*2+1]) << 8;
+// }
+// }
+// }
+// else if (channels == 1 && width == 2)
+// {
+// for (i=0 ; ; i++)
+// {
+// src = i*scale;
+// if (src >= samples)
+// break;
+// dst = s_rawend&(MAX_RAW_SAMPLES-1);
+// s_rawend++;
+// s_rawsamples[dst].left =
+// LittleShort(((short *)data)[src]) << 8;
+// s_rawsamples[dst].right =
+// LittleShort(((short *)data)[src]) << 8;
+// }
+// }
+// else if (channels == 2 && width == 1)
+// {
+// for (i=0 ; ; i++)
+// {
+// src = i*scale;
+// if (src >= samples)
+// break;
+// dst = s_rawend&(MAX_RAW_SAMPLES-1);
+// s_rawend++;
+// s_rawsamples[dst].left =
+// ((char *)data)[src*2] << 16;
+// s_rawsamples[dst].right =
+// ((char *)data)[src*2+1] << 16;
+// }
+// }
+// else if (channels == 1 && width == 1)
+// {
+// for (i=0 ; ; i++)
+// {
+// src = i*scale;
+// if (src >= samples)
+// break;
+// dst = s_rawend&(MAX_RAW_SAMPLES-1);
+// s_rawend++;
+// s_rawsamples[dst].left =
+// (((byte *)data)[src]-128) << 16;
+// s_rawsamples[dst].right = (((byte *)data)[src]-128) << 16;
+// }
+// }
+// }
+//
+//// =============================================================================
+//
+// /*
+// ============
+// S_Update
+//
+// Called once each time through the main loop
+// ============
+// */
+ static void Update(float[] origin, float[] forward, float[] right, float[] up) {
+// int i;
+// int total;
+// channel_t *ch;
+// channel_t *combine;
+//
+// if (!sound_started)
+// return;
+//
+// // if the laoding plaque is up, clear everything
+// // out to make sure we aren't looping a dirty
+// // dma buffer while loading
+// if (cls.disable_screen)
+// {
+// S_ClearBuffer ();
+// return;
+// }
+//
+// // rebuild scale tables if volume is modified
+// if (s_volume->modified)
+// S_InitScaletable ();
+//
+// VectorCopy(origin, listener_origin);
+// VectorCopy(forward, listener_forward);
+// VectorCopy(right, listener_right);
+// VectorCopy(up, listener_up);
+//
+// combine = NULL;
+//
+// // update spatialization for dynamic sounds
+// ch = channels;
+// for (i=0 ; i<MAX_CHANNELS; i++, ch++)
+// {
+// if (!ch->sfx)
+// continue;
+// if (ch->autosound)
+// { // autosounds are regenerated fresh each frame
+// memset (ch, 0, sizeof(*ch));
+// continue;
+// }
+// S_Spatialize(ch); // respatialize channel
+// if (!ch->leftvol && !ch->rightvol)
+// {
+// memset (ch, 0, sizeof(*ch));
+// continue;
+// }
+// }
+//
+// // add loopsounds
+// S_AddLoopSounds ();
+//
+// //
+// // debugging output
+// //
+// if (s_show->value)
+// {
+// total = 0;
+// ch = channels;
+// for (i=0 ; i<MAX_CHANNELS; i++, ch++)
+// if (ch->sfx && (ch->leftvol || ch->rightvol) )
+// {
+// Com_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name);
+// total++;
+// }
+//
+// Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
+// }
+//
+//// mix some sound
+// S_Update_();
+ }
+
+//
+// void GetSoundtime(void)
+// {
+// int samplepos;
+// static int buffers;
+// static int oldsamplepos;
+// int fullsamples;
+//
+// fullsamples = dma.samples / dma.channels;
+//
+//// it is possible to miscount buffers if it has wrapped twice between
+//// calls to S_Update. Oh well.
+// samplepos = SNDDMA_GetDMAPos();
+//
+// if (samplepos < oldsamplepos)
+// {
+// buffers++; // buffer wrapped
+//
+// if (paintedtime > 0x40000000)
+// { // time to chop things off to avoid 32 bit limits
+// buffers = 0;
+// paintedtime = fullsamples;
+// S_StopAllSounds ();
+// }
+// }
+// oldsamplepos = samplepos;
+//
+// soundtime = buffers*fullsamples + samplepos/dma.channels;
+// }
+//
+//
+// void S_Update_(void)
+// {
+// unsigned endtime;
+// int samps;
+//
+// if (!sound_started)
+// return;
+//
+// SNDDMA_BeginPainting ();
+//
+// if (!dma.buffer)
+// return;
+//
+//// Updates DMA time
+// GetSoundtime();
+//
+//// check to make sure that we haven't overshot
+// if (paintedtime < soundtime)
+// {
+// Com_DPrintf ("S_Update_ : overflow\n");
+// paintedtime = soundtime;
+// }
+//
+//// mix ahead of current position
+// endtime = soundtime + s_mixahead->value * dma.speed;
+//// endtime = (soundtime + 4096) & ~4095;
+//
+// // mix to an even submission block size
+// endtime = (endtime + dma.submission_chunk-1)
+// & ~(dma.submission_chunk-1);
+// samps = dma.samples >> (dma.channels-1);
+// if (endtime - soundtime > samps)
+// endtime = soundtime + samps;
+//
+// S_PaintChannels (endtime);
+//
+// SNDDMA_Submit ();
+// }
+//
+ /*
+ ===============================================================================
+
+ console functions
+
+ ===============================================================================
+ */
+
+ static void Play()
+ {
+// int i;
+// char name[256];
+// sfx_t *sfx;
+//
+// i = 1;
+// while (i<Cmd_Argc())
+// {
+// if (!strrchr(Cmd_Argv(i), '.'))
+// {
+// strcpy(name, Cmd_Argv(i));
+// strcat(name, ".wav");
+// }
+// else
+// strcpy(name, Cmd_Argv(i));
+// sfx = S_RegisterSound(name);
+// S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
+// i++;
+// }
+ }
+//
+ static void SoundList() {
+// int i;
+// sfx_t *sfx;
+// sfxcache_t *sc;
+// int size, total;
+//
+// total = 0;
+// for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
+// {
+// if (!sfx->registration_sequence)
+// continue;
+// sc = sfx->cache;
+// if (sc)
+// {
+// size = sc->length*sc->width*(sc->stereo+1);
+// total += size;
+// if (sc->loopstart >= 0)
+// Com_Printf ("L");
+// else
+// Com_Printf (" ");
+// Com_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
+// }
+// else
+// {
+// if (sfx->name[0] == '*')
+// Com_Printf(" placeholder : %s\n", sfx->name);
+// else
+// Com_Printf(" not loaded : %s\n", sfx->name);
+// }
+// }
+// Com_Printf ("Total resident: %i\n", total);
+ }
+
+}
diff --git a/src/jake2/client/SND_JAVA.java b/src/jake2/client/SND_JAVA.java
new file mode 100644
index 0000000..3853e09
--- /dev/null
+++ b/src/jake2/client/SND_JAVA.java
@@ -0,0 +1,168 @@
+/*
+ * SND_JAVA.java
+ * Copyright (C) 2004
+ *
+ * $Id: SND_JAVA.java,v 1.1 2004-07-07 19:58:51 hzi 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.
+
+*/
+package jake2.client;
+
+import jake2.Globals;
+import jake2.game.cvar_t;
+import jake2.qcommon.Cvar;
+import jake2.qcommon.FS;
+
+import java.io.*;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import javax.sound.sampled.*;
+
+/**
+ * SND_JAVA
+ */
+public class SND_JAVA extends Globals {
+
+ static boolean snd_inited= false;
+
+ static cvar_t sndbits;
+ static cvar_t sndspeed;
+ static cvar_t sndchannels;
+
+// static int tryrates[] = { 11025, 22051, 44100, 8000 };
+ static class dma_t {
+ int channels;
+ int samples; // mono samples in buffer
+ int submission_chunk; // don't mix less than this #
+ int samplepos; // in mono samples
+ int samplebits;
+ int speed;
+ byte[] buffer;
+ }
+ static SND_DMA.dma_t dma = new dma_t();
+
+ static SourceDataLine line;
+ static AudioFormat format;
+
+
+ static boolean SNDDMA_Init() {
+
+ if (snd_inited)
+ return true;
+
+ if (sndbits == null) {
+ sndbits = Cvar.Get("sndbits", "16", CVAR_ARCHIVE);
+ sndspeed = Cvar.Get("sndspeed", "0", CVAR_ARCHIVE);
+ sndchannels = Cvar.Get("sndchannels", "2", CVAR_ARCHIVE);
+ }
+
+ byte[] sound = FS.LoadFile("sound/misc/menu1.wav");
+ AudioInputStream stream;
+ try {
+ stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(sound));
+ } catch (UnsupportedAudioFileException e) {
+ return false;
+ } catch (IOException e) {
+ return false;
+ }
+ format = stream.getFormat();
+
+ DataLine.Info dinfo = new DataLine.Info(SourceDataLine.class, format);
+ //format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), format.getSampleSizeInBits(), 2, 2*format.getFrameSize(), format.getFrameRate(), format.isBigEndian());
+
+ try {
+ line = (SourceDataLine)AudioSystem.getLine(dinfo);
+ } catch (LineUnavailableException e4) {
+ return false;
+ }
+ dma.buffer = new byte[65536];
+// try {
+// stream.read(dma.buffer);
+// } catch (IOException e3) {
+// // TODO Auto-generated catch block
+// e3.printStackTrace();
+// }
+
+ dma.channels = format.getChannels();
+ dma.samplebits = format.getSampleSizeInBits();
+ dma.samples = dma.buffer.length / format.getFrameSize();
+ dma.speed = (int)format.getSampleRate();
+ dma.samplepos = 0;
+ dma.submission_chunk = 1;
+
+ try {
+ line.open(format, 4096);
+ } catch (LineUnavailableException e5) {
+ return false;
+ }
+
+ line.start();
+ runLine();
+
+ snd_inited = true;
+ return true;
+
+ }
+
+ static int SNDDMA_GetDMAPos() {
+ dma.samplepos = line.getFramePosition() % dma.samples;
+ return dma.samplepos;
+ }
+
+ static void SNDDMA_Shutdown() {
+ line.stop();
+ line.flush();
+ line.close();
+ line=null;
+ snd_inited = false;
+ }
+
+ /*
+ ==============
+ SNDDMA_Submit
+
+ Send sound to device if buffer isn't really the dma buffer
+ ===============
+ */
+ public static void SNDDMA_Submit() {
+ runLine();
+ }
+
+ void SNDDMA_BeginPainting() {}
+
+ private static int pos = 0;
+ static void runLine() {
+
+ int p = line.getFramePosition() * format.getFrameSize() % dma.buffer.length;
+ System.out.println("run " + p + " " + pos);
+ if (p == 0) {
+ writeLine();
+ }
+ else if (pos - p < 2048 ) writeLine();
+ }
+
+ static void writeLine() {
+ line.write(dma.buffer, pos, 4096);
+ pos+=4096;
+ if (pos>=dma.buffer.length) pos = 0;
+ }
+
+}
diff --git a/src/jake2/sound/WaveLoader.java b/src/jake2/client/SND_MEM.java
index 020ab52..85215d1 100644
--- a/src/jake2/sound/WaveLoader.java
+++ b/src/jake2/client/SND_MEM.java
@@ -2,7 +2,7 @@
* SND_MEM.java
* Copyright (C) 2004
*
- * $Id: WaveLoader.java,v 1.1 2004-07-09 06:50:48 hzi Exp $
+ * $Id: SND_MEM.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -23,31 +23,94 @@ 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.sound;
+package jake2.client;
-import jake2.Defines;
import jake2.qcommon.Com;
import jake2.qcommon.FS;
-import jake2.sys.Sys;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.*;
/**
* SND_MEM
*/
-public class WaveLoader {
+public class SND_MEM extends SND_JAVA {
+
+//// snd_mem.c: sound caching
+//
+// #include "client.h"
+// #include "snd_loc.h"
+//
+// int cache_full_cycle;
+//
+// byte *S_Alloc (int size);
+//
+ /*
+ ================
+ ResampleSfx
+ ================
+ */
+ static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte[] data, int ofs)
+ {
+ int outcount;
+ int srcsample;
+ float stepscale;
+ int i;
+ int sample, samplefrac, fracstep;
+ sfxcache_t sc;
+
+ sc = sfx.cache;
+ if (sc == null)
+ return;
+
+ stepscale = (float)inrate / dma.speed; // this is usually 0.5, 1, or 2
- private static final AudioFormat sampleFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 22050, 16, 1, 2, 22050, false);
+ outcount = (int)(sc.length / stepscale);
+ sc.length = outcount;
+ if (sc.loopstart != -1)
+ sc.loopstart = (int)(sc.loopstart / stepscale);
+ sc.speed = dma.speed;
+ if (SND_DMA.s_loadas8bit.value != 0.0f)
+ sc.width = 1;
+ else
+ sc.width = inwidth;
+ sc.stereo = 0;
+
+// resample / decimate to the current source rate
+
+ if (stepscale == 1 && inwidth == 1 && sc.width == 1)
+ {
+// fast special case
+ for (i=0 ; i<outcount ; i++)
+ sc.data[i+ofs] = (byte)((data[i+ofs] & 0xFF) - 128);
+ }
+ else
+ {
+// general case
+ samplefrac = 0;
+ fracstep = (int)(stepscale*256);
+// for (i=0 ; i<outcount ; i++)
+// {
+// srcsample = samplefrac >> 8;
+// samplefrac += fracstep;
+// if (inwidth == 2)
+// sample = LittleShort ( ((short *)data)[srcsample] );
+// else
+// sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
+// if (sc->width == 2)
+// ((short *)sc->data)[i] = sample;
+// else
+// ((signed char *)sc->data)[i] = sample >> 8;
+// }
+ }
+ }
+//
+//// =============================================================================
+//
/*
==============
S_LoadSound
==============
*/
- public static sfxcache_t LoadSound(sfx_t s) {
+ static sfxcache_t LoadSound(sfx_t s) {
String namebuffer;
byte[] data;
wavinfo_t info;
@@ -73,9 +136,10 @@ public class WaveLoader {
if (name.charAt(0) == '#')
namebuffer = name.substring(1);
-
+ //strcpy(namebuffer, &name[1]);
else
namebuffer = "sound/" + name;
+ //Com_sprintf (namebuffer, sizeof(namebuffer), "sound/%s", name);
data = FS.LoadFile(namebuffer);
@@ -86,59 +150,43 @@ public class WaveLoader {
size = data.length;
info = GetWavinfo(s.name, data, size);
-
- AudioInputStream in = null;
- AudioInputStream out = null;
- try {
- in = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data));
- if (in.getFormat().getSampleSizeInBits() == 8) {
- in = convertTo16bit(in);
- }
- out = AudioSystem.getAudioInputStream(sampleFormat, in);
- int l = (int)out.getFrameLength();
- sc = s.cache = new sfxcache_t(l*2);
- sc.length = l;
- int c = out.read(sc.data, 0, l * 2);
- out.close();
- in.close();
- } catch (Exception e) {
- Com.Printf("Couldn't load " + namebuffer + "\n");
+ if (info.channels != 1) {
+ Com.Printf(s.name + " is a stereo sample\n");
+ FS.FreeFile(data);
return null;
}
-
- sc.loopstart = info.loopstart * ((int)sampleFormat.getSampleRate() / info.rate);
- sc.speed = (int)sampleFormat.getSampleRate();
- sc.width = sampleFormat.getSampleSizeInBits() / 8;
- sc.stereo = 0;
- data = null;
+ stepscale = ((float)info.rate) / dma.speed;
+ len = (int) (info.samples / stepscale);
- return sc;
- }
+ len = len * info.width * info.channels;
- static AudioInputStream convertTo16bit(AudioInputStream in) throws IOException {
- AudioFormat format = in.getFormat();
- int length = (int)in.getFrameLength();
- byte[] samples = new byte[2*length];
-
- for (int i = 0; i < length; i++) {
- in.read(samples, 2*i+1, 1);
- samples[2*i+1] -= 128;
- }
- in.close();
+ //sc = s.cache = Z_Malloc (len + sizeof(sfxcache_t));
+ sc = s.cache = new sfxcache_t(len);
- AudioFormat newformat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), 16, format.getChannels(), 2, format.getFrameRate(), false);
- return new AudioInputStream(new ByteArrayInputStream(samples), newformat, length);
- }
-
- /*
- ===============================================================================
+ sc.length = info.samples;
+ sc.loopstart = info.loopstart;
+ sc.speed = info.rate;
+ sc.width = info.width;
+ sc.stereo = info.channels;
- WAV loading
+ ResampleSfx(s, sc.speed, sc.width, data, info.dataofs);
- ===============================================================================
- */
+ FS.FreeFile(data);
+ return sc;
+ }
+//
+//
+//
+// /*
+// ===============================================================================
+//
+// WAV loading
+//
+// ===============================================================================
+// */
+//
static byte[] data_b;
static int data_p;
static int iff_end;
@@ -148,23 +196,23 @@ public class WaveLoader {
static short GetLittleShort() {
- int val = 0;
- val = data_b[data_p] & 0xFF;
+ short val = 0;
+ val = data_b[data_p];
data_p++;
- val |= ((data_b[data_p] & 0xFF) << 8);
+ val |= (data_b[data_p] << 8);
data_p++;
- return (short)val;
+ return val;
}
static int GetLittleLong() {
int val = 0;
- val = data_b[data_p] & 0xFF;
+ val = data_b[data_p];
data_p++;
- val |= ((data_b[data_p] & 0xFF) << 8);
+ val |= (data_b[data_p] << 8);
data_p++;
- val |= ((data_b[data_p] & 0xFF) << 16);
+ val |= (data_b[data_p] << 16);
data_p++;
- val |= ((data_b[data_p] & 0xFF) << 24);
+ val |= (data_b[data_p] << 24);
data_p++;
return val;
}
@@ -179,16 +227,13 @@ public class WaveLoader {
}
data_p += 4;
-
iff_chunk_len = GetLittleLong();
-
if (iff_chunk_len < 0) {
data_p = 0;
return;
}
- if (iff_chunk_len > 1024*1024)
- Sys.Error("FindNextChunk: length is past the 1 meg sanity limit");
-
+ // if (iff_chunk_len > 1024*1024)
+ // Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
data_p -= 8;
last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1);
String s = new String(data_b, data_p, 4);
@@ -201,7 +246,24 @@ public class WaveLoader {
last_chunk = iff_data;
FindNextChunk(name);
}
-
+//
+//
+// void DumpChunks(void)
+// {
+// char str[5];
+//
+// str[4] = 0;
+// data_p=iff_data;
+// do
+// {
+// memcpy (str, data_p, 4);
+// data_p += 4;
+// iff_chunk_len = GetLittleLong();
+// Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
+// data_p += (iff_chunk_len + 1) & ~1;
+// } while (data_p < iff_end);
+// }
+//
/*
============
GetWavinfo
@@ -223,7 +285,7 @@ public class WaveLoader {
// find "RIFF" chunk
FindChunk("RIFF");
String s = new String(data_b, data_p + 8, 4);
- if (!s.equals("WAVE")) {
+ if (!((data_p != 0) && s.equals("WAVE"))) {
Com.Printf("Missing RIFF/WAVE chunks\n");
return info;
}
@@ -282,7 +344,7 @@ public class WaveLoader {
if (info.samples != 0) {
if (samples < info.samples)
- Com.Error(Defines.ERR_DROP, "Sound " + name + " has a bad loop length");
+ Com.Error(ERR_DROP, "Sound " + name + " has a bad loop length");
} else
info.samples = samples;
diff --git a/src/jake2/client/SND_MIX.java b/src/jake2/client/SND_MIX.java
new file mode 100644
index 0000000..9ba7747
--- /dev/null
+++ b/src/jake2/client/SND_MIX.java
@@ -0,0 +1,513 @@
+/*
+ * SND_MIX.java
+ * Copyright (C) 2004
+ *
+ * $Id: SND_MIX.java,v 1.1 2004-07-07 19:58:52 hzi 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.
+
+*/
+package jake2.client;
+
+/**
+ * SND_MIX
+ */
+public class SND_MIX extends SND_MEM {
+
+//// snd_mix.c -- portable code to mix sounds for snd_dma.c
+//
+// #include "client.h"
+// #include "snd_loc.h"
+//
+// #define PAINTBUFFER_SIZE 2048
+// portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
+// int snd_scaletable[32][256];
+// int *snd_p, snd_linear_count, snd_vol;
+// short *snd_out;
+//
+// void S_WriteLinearBlastStereo16 (void);
+//
+// #if !(defined __linux__ && defined __i386__)
+// #if !id386
+//
+// void S_WriteLinearBlastStereo16 (void)
+// {
+// int i;
+// int val;
+//
+// for (i=0 ; i<snd_linear_count ; i+=2)
+// {
+// val = snd_p[i]>>8;
+// if (val > 0x7fff)
+// snd_out[i] = 0x7fff;
+// else if (val < (short)0x8000)
+// snd_out[i] = (short)0x8000;
+// else
+// snd_out[i] = val;
+//
+// val = snd_p[i+1]>>8;
+// if (val > 0x7fff)
+// snd_out[i+1] = 0x7fff;
+// else if (val < (short)0x8000)
+// snd_out[i+1] = (short)0x8000;
+// else
+// snd_out[i+1] = val;
+// }
+// }
+// #else
+// __declspec( naked ) void S_WriteLinearBlastStereo16 (void)
+// {
+// __asm {
+//
+// push edi
+// push ebx
+// mov ecx,ds:dword ptr[snd_linear_count]
+// mov ebx,ds:dword ptr[snd_p]
+// mov edi,ds:dword ptr[snd_out]
+// LWLBLoopTop:
+// mov eax,ds:dword ptr[-8+ebx+ecx*4]
+// sar eax,8
+// cmp eax,07FFFh
+// jg LClampHigh
+// cmp eax,0FFFF8000h
+// jnl LClampDone
+// mov eax,0FFFF8000h
+// jmp LClampDone
+// LClampHigh:
+// mov eax,07FFFh
+// LClampDone:
+// mov edx,ds:dword ptr[-4+ebx+ecx*4]
+// sar edx,8
+// cmp edx,07FFFh
+// jg LClampHigh2
+// cmp edx,0FFFF8000h
+// jnl LClampDone2
+// mov edx,0FFFF8000h
+// jmp LClampDone2
+// LClampHigh2:
+// mov edx,07FFFh
+// LClampDone2:
+// shl edx,16
+// and eax,0FFFFh
+// or edx,eax
+// mov ds:dword ptr[-4+edi+ecx*2],edx
+// sub ecx,2
+// jnz LWLBLoopTop
+// pop ebx
+// pop edi
+// ret
+// }
+// }
+//
+// #endif
+// #endif
+//
+// void S_TransferStereo16 (unsigned long *pbuf, int endtime)
+// {
+// int lpos;
+// int lpaintedtime;
+//
+// snd_p = (int *) paintbuffer;
+// lpaintedtime = paintedtime;
+//
+// while (lpaintedtime < endtime)
+// {
+// // handle recirculating buffer issues
+// lpos = lpaintedtime & ((dma.samples>>1)-1);
+//
+// snd_out = (short *) pbuf + (lpos<<1);
+//
+// snd_linear_count = (dma.samples>>1) - lpos;
+// if (lpaintedtime + snd_linear_count > endtime)
+// snd_linear_count = endtime - lpaintedtime;
+//
+// snd_linear_count <<= 1;
+//
+// // write a linear blast of samples
+// S_WriteLinearBlastStereo16 ();
+//
+// snd_p += snd_linear_count;
+// lpaintedtime += (snd_linear_count>>1);
+// }
+// }
+//
+// /*
+// ===================
+// S_TransferPaintBuffer
+//
+// ===================
+// */
+// void S_TransferPaintBuffer(int endtime)
+// {
+// int out_idx;
+// int count;
+// int out_mask;
+// int *p;
+// int step;
+// int val;
+// unsigned long *pbuf;
+//
+// pbuf = (unsigned long *)dma.buffer;
+//
+// if (s_testsound->value)
+// {
+// int i;
+// int count;
+//
+// // write a fixed sine wave
+// count = (endtime - paintedtime);
+// for (i=0 ; i<count ; i++)
+// paintbuffer[i].left = paintbuffer[i].right = sin((paintedtime+i)*0.1)*20000*256;
+// }
+//
+//
+// if (dma.samplebits == 16 && dma.channels == 2)
+// { // optimized case
+// S_TransferStereo16 (pbuf, endtime);
+// }
+// else
+// { // general case
+// p = (int *) paintbuffer;
+// count = (endtime - paintedtime) * dma.channels;
+// out_mask = dma.samples - 1;
+// out_idx = paintedtime * dma.channels & out_mask;
+// step = 3 - dma.channels;
+//
+// if (dma.samplebits == 16)
+// {
+// short *out = (short *) pbuf;
+// while (count--)
+// {
+// val = *p >> 8;
+// p+= step;
+// if (val > 0x7fff)
+// val = 0x7fff;
+// else if (val < (short)0x8000)
+// val = (short)0x8000;
+// out[out_idx] = val;
+// out_idx = (out_idx + 1) & out_mask;
+// }
+// }
+// else if (dma.samplebits == 8)
+// {
+// unsigned char *out = (unsigned char *) pbuf;
+// while (count--)
+// {
+// val = *p >> 8;
+// p+= step;
+// if (val > 0x7fff)
+// val = 0x7fff;
+// else if (val < (short)0x8000)
+// val = (short)0x8000;
+// out[out_idx] = (val>>8) + 128;
+// out_idx = (out_idx + 1) & out_mask;
+// }
+// }
+// }
+// }
+//
+//
+// /*
+// ===============================================================================
+//
+// CHANNEL MIXING
+//
+// ===============================================================================
+// */
+//
+// void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
+// void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
+//
+// void S_PaintChannels(int endtime)
+// {
+// int i;
+// int end;
+// channel_t *ch;
+// sfxcache_t *sc;
+// int ltime, count;
+// playsound_t *ps;
+//
+// snd_vol = s_volume->value*256;
+//
+//// Com_Printf ("%i to %i\n", paintedtime, endtime);
+// while (paintedtime < endtime)
+// {
+// // if paintbuffer is smaller than DMA buffer
+// end = endtime;
+// if (endtime - paintedtime > PAINTBUFFER_SIZE)
+// end = paintedtime + PAINTBUFFER_SIZE;
+//
+// // start any playsounds
+// while (1)
+// {
+// ps = s_pendingplays.next;
+// if (ps == &s_pendingplays)
+// break; // no more pending sounds
+// if (ps->begin <= paintedtime)
+// {
+// S_IssuePlaysound (ps);
+// continue;
+// }
+//
+// if (ps->begin < end)
+// end = ps->begin; // stop here
+// break;
+// }
+//
+// // clear the paint buffer
+// if (s_rawend < paintedtime)
+// {
+//// Com_Printf ("clear\n");
+// memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
+// }
+// else
+// { // copy from the streaming sound source
+// int s;
+// int stop;
+//
+// stop = (end < s_rawend) ? end : s_rawend;
+//
+// for (i=paintedtime ; i<stop ; i++)
+// {
+// s = i&(MAX_RAW_SAMPLES-1);
+// paintbuffer[i-paintedtime] = s_rawsamples[s];
+// }
+//// if (i != end)
+//// Com_Printf ("partial stream\n");
+//// else
+//// Com_Printf ("full stream\n");
+// for ( ; i<end ; i++)
+// {
+// paintbuffer[i-paintedtime].left =
+// paintbuffer[i-paintedtime].right = 0;
+// }
+// }
+//
+//
+// // paint in the channels.
+// ch = channels;
+// for (i=0; i<MAX_CHANNELS ; i++, ch++)
+// {
+// ltime = paintedtime;
+//
+// while (ltime < end)
+// {
+// if (!ch->sfx || (!ch->leftvol && !ch->rightvol) )
+// break;
+//
+// // max painting is to the end of the buffer
+// count = end - ltime;
+//
+// // might be stopped by running out of data
+// if (ch->end - ltime < count)
+// count = ch->end - ltime;
+//
+// sc = S_LoadSound (ch->sfx);
+// if (!sc)
+// break;
+//
+// if (count > 0 && ch->sfx)
+// {
+// if (sc->width == 1)// FIXME; 8 bit asm is wrong now
+// S_PaintChannelFrom8(ch, sc, count, ltime - paintedtime);
+// else
+// S_PaintChannelFrom16(ch, sc, count, ltime - paintedtime);
+//
+// ltime += count;
+// }
+//
+// // if at end of loop, restart
+// if (ltime >= ch->end)
+// {
+// if (ch->autosound)
+// { // autolooping sounds always go back to start
+// ch->pos = 0;
+// ch->end = ltime + sc->length;
+// }
+// else if (sc->loopstart >= 0)
+// {
+// ch->pos = sc->loopstart;
+// ch->end = ltime + sc->length - ch->pos;
+// }
+// else
+// { // channel just stopped
+// ch->sfx = NULL;
+// }
+// }
+// }
+//
+// }
+//
+// // transfer out according to DMA format
+// S_TransferPaintBuffer(end);
+// paintedtime = end;
+// }
+// }
+//
+ static void InitScaletable()
+ {
+// int i, j;
+// int scale;
+//
+// s_volume->modified = false;
+// for (i=0 ; i<32 ; i++)
+// {
+// scale = i * 8 * 256 * s_volume->value;
+// for (j=0 ; j<256 ; j++)
+// snd_scaletable[i][j] = ((signed char)j) * scale;
+// }
+ }
+//
+//
+// #if !(defined __linux__ && defined __i386__)
+// #if !id386
+//
+// void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int offset)
+// {
+// int data;
+// int *lscale, *rscale;
+// unsigned char *sfx;
+// int i;
+// portable_samplepair_t *samp;
+//
+// if (ch->leftvol > 255)
+// ch->leftvol = 255;
+// if (ch->rightvol > 255)
+// ch->rightvol = 255;
+//
+// //ZOID-- >>11 has been changed to >>3, >>11 didn't make much sense
+// //as it would always be zero.
+// lscale = snd_scaletable[ ch->leftvol >> 3];
+// rscale = snd_scaletable[ ch->rightvol >> 3];
+// sfx = (signed char *)sc->data + ch->pos;
+//
+// samp = &paintbuffer[offset];
+//
+// for (i=0 ; i<count ; i++, samp++)
+// {
+// data = sfx[i];
+// samp->left += lscale[data];
+// samp->right += rscale[data];
+// }
+//
+// ch->pos += count;
+// }
+//
+// #else
+//
+// __declspec( naked ) void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int offset)
+// {
+// __asm {
+// push esi
+// push edi
+// push ebx
+// push ebp
+// mov ebx,ds:dword ptr[4+16+esp]
+// mov esi,ds:dword ptr[8+16+esp]
+// mov eax,ds:dword ptr[4+ebx]
+// mov edx,ds:dword ptr[8+ebx]
+// cmp eax,255
+// jna LLeftSet
+// mov eax,255
+// LLeftSet:
+// cmp edx,255
+// jna LRightSet
+// mov edx,255
+// LRightSet:
+// and eax,0F8h
+// add esi,20
+// and edx,0F8h
+// mov edi,ds:dword ptr[16+ebx]
+// mov ecx,ds:dword ptr[12+16+esp]
+// add esi,edi
+// shl eax,7
+// add edi,ecx
+// shl edx,7
+// mov ds:dword ptr[16+ebx],edi
+// add eax,offset snd_scaletable
+// add edx,offset snd_scaletable
+// sub ebx,ebx
+// mov bl,ds:byte ptr[-1+esi+ecx*1]
+// test ecx,1
+// jz LMix8Loop
+// mov edi,ds:dword ptr[eax+ebx*4]
+// mov ebp,ds:dword ptr[edx+ebx*4]
+// add edi,ds:dword ptr[paintbuffer+0-8+ecx*8]
+// add ebp,ds:dword ptr[paintbuffer+4-8+ecx*8]
+// mov ds:dword ptr[paintbuffer+0-8+ecx*8],edi
+// mov ds:dword ptr[paintbuffer+4-8+ecx*8],ebp
+// mov bl,ds:byte ptr[-2+esi+ecx*1]
+// dec ecx
+// jz LDone
+// LMix8Loop:
+// mov edi,ds:dword ptr[eax+ebx*4]
+// mov ebp,ds:dword ptr[edx+ebx*4]
+// add edi,ds:dword ptr[paintbuffer+0-8+ecx*8]
+// add ebp,ds:dword ptr[paintbuffer+4-8+ecx*8]
+// mov bl,ds:byte ptr[-2+esi+ecx*1]
+// mov ds:dword ptr[paintbuffer+0-8+ecx*8],edi
+// mov ds:dword ptr[paintbuffer+4-8+ecx*8],ebp
+// mov edi,ds:dword ptr[eax+ebx*4]
+// mov ebp,ds:dword ptr[edx+ebx*4]
+// mov bl,ds:byte ptr[-3+esi+ecx*1]
+// add edi,ds:dword ptr[paintbuffer+0-8*2+ecx*8]
+// add ebp,ds:dword ptr[paintbuffer+4-8*2+ecx*8]
+// mov ds:dword ptr[paintbuffer+0-8*2+ecx*8],edi
+// mov ds:dword ptr[paintbuffer+4-8*2+ecx*8],ebp
+// sub ecx,2
+// jnz LMix8Loop
+// LDone:
+// pop ebp
+// pop ebx
+// pop edi
+// pop esi
+// ret
+// }
+// }
+//
+// #endif
+// #endif
+//
+// void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int offset)
+// {
+// int data;
+// int left, right;
+// int leftvol, rightvol;
+// signed short *sfx;
+// int i;
+// portable_samplepair_t *samp;
+//
+// leftvol = ch->leftvol*snd_vol;
+// rightvol = ch->rightvol*snd_vol;
+// sfx = (signed short *)sc->data + ch->pos;
+//
+// samp = &paintbuffer[offset];
+// for (i=0 ; i<count ; i++, samp++)
+// {
+// data = sfx[i];
+// left = (data * leftvol)>>8;
+// right = (data * rightvol)>>8;
+// samp->left += left;
+// samp->right += right;
+// }
+//
+// ch->pos += count;
+// }
+
+}
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 53a943f..7b71830 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.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: VID.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,7 +31,6 @@ import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
import jake2.render.Renderer;
-import jake2.sound.*;
import jake2.sys.IN;
import jake2.sys.KBD;
import jake2.util.Vargs;
@@ -265,6 +264,10 @@ public class VID extends Globals {
public void Vid_NewWindow(int width, int height) {
VID.NewWindow(width, height);
}
+
+ public void updateScreenCallback() {
+ SCR.UpdateScreen2();
+ }
};
Globals.re = Renderer.getDriver( name, ri );
diff --git a/src/jake2/client/centity_t.java b/src/jake2/client/centity_t.java
index 0d4f822..0c26bed 100644
--- a/src/jake2/client/centity_t.java
+++ b/src/jake2/client/centity_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-// $Id: centity_t.java,v 1.2 2004-07-08 20:56:50 hzi Exp $
+// $Id: centity_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
package jake2.client;
@@ -27,7 +27,7 @@ import jake2.game.entity_state_t;
public class centity_t {
entity_state_t baseline= new entity_state_t(null); // delta from this if not from a previous frame
- public entity_state_t current= new entity_state_t(null);
+ entity_state_t current= new entity_state_t(null);
entity_state_t prev= new entity_state_t(null); // will always be valid, but might just be a copy of current
int serverframe; // if not current, this ent isn't in the frame
diff --git a/src/jake2/client/client_state_t.java b/src/jake2/client/client_state_t.java
index ff86070..3577932 100644
--- a/src/jake2/client/client_state_t.java
+++ b/src/jake2/client/client_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-//$Id: client_state_t.java,v 1.2 2004-07-08 20:56:51 hzi Exp $
+//$Id: client_state_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
package jake2.client;
@@ -28,7 +28,6 @@ import jake2.game.cmodel_t;
import jake2.game.usercmd_t;
import jake2.render.image_t;
import jake2.render.model_t;
-import jake2.sound.*;
import java.io.RandomAccessFile;
@@ -119,9 +118,9 @@ public class client_state_t {
boolean attractloop; // running the attract loop, any key will menu
int servercount; // server identification for prespawns
String gamedir ="";
- public int playernum;
+ int playernum;
- public String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS];
+ String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS];
//
// locally derived information from server state
diff --git a/src/jake2/client/frame_t.java b/src/jake2/client/frame_t.java
index 1e414dc..d493363 100644
--- a/src/jake2/client/frame_t.java
+++ b/src/jake2/client/frame_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-// $Id: frame_t.java,v 1.2 2004-07-08 20:56:50 hzi Exp $
+// $Id: frame_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
package jake2.client;
@@ -33,7 +33,7 @@ public class frame_t implements Cloneable {
boolean valid; // cleared if delta parsing was invalid
int serverframe;
- public int servertime; // server time the message is valid for (in msec)
+ int servertime; // server time the message is valid for (in msec)
int deltaframe;
byte areabits[] = new byte [MAX_MAP_AREAS/8]; // portalarea visibility bits
public player_state_t playerstate = new player_state_t(); // mem
diff --git a/src/jake2/client/refimport_t.java b/src/jake2/client/refimport_t.java
index 849b143..f465482 100644
--- a/src/jake2/client/refimport_t.java
+++ b/src/jake2/client/refimport_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: refimport_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: refimport_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
package jake2.client;
@@ -67,4 +67,10 @@ public interface refimport_t {
boolean Vid_GetModeInfo(Dimension dim /* int *w, *h */, int mode);
void Vid_MenuInit();
void Vid_NewWindow(int width, int height);
+
+ /**
+ * This is the callback for Renderer.
+ */
+ void updateScreenCallback();
+
} \ No newline at end of file
diff --git a/src/jake2/sound/sfx_t.java b/src/jake2/client/sfx_t.java
index 992c0e7..359b40f 100644
--- a/src/jake2/sound/sfx_t.java
+++ b/src/jake2/client/sfx_t.java
@@ -1,8 +1,8 @@
/*
* sfx_t.java
- * Copyright (C) 2004
+ * Copyright (C) 2003
*
- * $Id: sfx_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ * $Id: sfx_t.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,24 +26,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Created on 28.11.2003 by RST.
-package jake2.sound;
-
+package jake2.client;
public class sfx_t {
- public String name; //mem
- public int registration_sequence;
- public sfxcache_t cache; //ptr
- public String truename; //ptr
-
- // cwei
- public int id = -1;
-
+ String name; //mem
+ int registration_sequence;
+ sfxcache_t cache; //ptr
+ String truename; //ptr
public void clear() {
name = truename = null;
cache = null;
registration_sequence = 0;
-
- // cwei
- id = -1;
}
}
diff --git a/src/jake2/sound/sfxcache_t.java b/src/jake2/client/sfxcache_t.java
index 7f4428a..245d921 100644
--- a/src/jake2/sound/sfxcache_t.java
+++ b/src/jake2/client/sfxcache_t.java
@@ -19,17 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 28.11.2003 by RST.
-// $Id: sfxcache_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+// $Id: sfxcache_t.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
-package jake2.sound;
+package jake2.client;
public class sfxcache_t {
- public int length;
- public int loopstart;
- public int speed; // not needed, because converted on load?
- public int width;
- public int stereo;
- public byte data[]; // variable sized
+ int length;
+ int loopstart;
+ int speed; // not needed, because converted on load?
+ int width;
+ int stereo;
+ byte data[]; // variable sized
public sfxcache_t(int size) {
data = new byte[size];
diff --git a/src/jake2/game/GameAIAdapters.java b/src/jake2/game/GameAIAdapters.java
index 465e4a3..ea20995 100644
--- a/src/jake2/game/GameAIAdapters.java
+++ b/src/jake2/game/GameAIAdapters.java
@@ -19,12 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameAIAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: GameAIAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
import jake2.Defines;
-import jake2.Globals;
import jake2.client.M;
import jake2.qcommon.Com;
import jake2.util.*;
@@ -254,11 +253,11 @@ public class GameAIAdapters
if (self.monsterinfo.idle_time != 0)
{
self.monsterinfo.search.think(self);
- self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + 15 + Lib.random() * 15;
}
else
{
- self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + Lib.random() * 15;
}
}
}
@@ -315,11 +314,11 @@ public class GameAIAdapters
if (self.monsterinfo.idle_time != 0)
{
self.monsterinfo.idle.think(self);
- self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + 15 + Lib.random() * 15;
}
else
{
- self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + Lib.random() * 15;
}
}
}
@@ -847,14 +846,12 @@ public class GameAIAdapters
trace_t tr;
float[] dest = { 0, 0, 0 };
- //float v[];
+ float v[];
- //v = Lib.tv(-15, -15, -15);
- //Math3D.VectorCopy(v, ent.mins);
- ent.mins[0] = ent.mins[1] = ent.mins[2] = -15;
- //v = Lib.tv(15, 15, 15);
- //Math3D.VectorCopy(v, ent.maxs);
- ent.maxs[0] = ent.maxs[1] = ent.maxs[2] = 15;
+ v = Lib.tv(-15, -15, -15);
+ Math3D.VectorCopy(v, ent.mins);
+ v = Lib.tv(15, 15, 15);
+ Math3D.VectorCopy(v, ent.maxs);
if (ent.model != null)
GameBase.gi.setmodel(ent, ent.model);
@@ -864,7 +861,7 @@ public class GameAIAdapters
ent.movetype = Defines.MOVETYPE_TOSS;
ent.touch = GameUtilAdapters.Touch_Item;
- float v[] = {0, 0, -128};
+ v = Lib.tv(0, 0, -128);
Math3D.VectorAdd(ent.s.origin, v, dest);
tr = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, dest, ent, Defines.MASK_SOLID);
@@ -921,7 +918,7 @@ public class GameAIAdapters
if (self.s.frame == 10)
{
self.think = GameUtilAdapters.G_FreeEdictA;
- self.nextthink = GameBase.level.time + 8 + Globals.rnd.nextFloat() * 10;
+ self.nextthink = GameBase.level.time + 8 + Lib.random() * 10;
}
return true;
}
diff --git a/src/jake2/game/GameMiscAdapters.java b/src/jake2/game/GameMiscAdapters.java
index 56aba1a..c4322d3 100644
--- a/src/jake2/game/GameMiscAdapters.java
+++ b/src/jake2/game/GameMiscAdapters.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameMiscAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: GameMiscAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -817,7 +817,7 @@ public class GameMiscAdapters
if (e.count == 0)
continue;
n = e.count - 1;
- if (n >= l)
+ if (n > l)
{
e.s.frame = 12;
continue;
diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java
index a7d06dd..ba75cde 100644
--- a/src/jake2/game/PlayerClient.java
+++ b/src/jake2/game/PlayerClient.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerClient.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: PlayerClient.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
package jake2.game;
@@ -334,7 +334,7 @@ public class PlayerClient extends PlayerHud {
//memset(& client.resp, 0, sizeof(client.resp));
client.resp.clear(); // ok.
client.resp.enterframe = level.framenum;
- client.resp.coop_respawn.set(client.pers);
+ client.resp.coop_respawn = client.pers.getClone();
}
/*
diff --git a/src/jake2/game/client_persistant_t.java b/src/jake2/game/client_persistant_t.java
index 5014d3b..944767e 100644
--- a/src/jake2/game/client_persistant_t.java
+++ b/src/jake2/game/client_persistant_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: client_persistant_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: client_persistant_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -31,14 +31,14 @@ import java.nio.ByteBuffer;
public class client_persistant_t implements Cloneable {
-// public client_persistant_t getClone() {
-// try {
-// return (client_persistant_t) this.clone();
-// }
-// catch (CloneNotSupportedException e) {
-// return null;
-// }
-// }
+ public client_persistant_t getClone() {
+ try {
+ return (client_persistant_t) this.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
public void set(client_persistant_t from)
{
@@ -50,8 +50,7 @@ public class client_persistant_t implements Cloneable {
max_health = from.max_health;
savedFlags = from.savedFlags;
selected_item = from.selected_item;
- System.arraycopy(from.inventory, 0, inventory, 0, inventory.length);
- //inventory = Lib.clone(from.inventory);
+ inventory = Lib.clone(from.inventory);
max_bullets = from.max_bullets;
max_shells = from.max_shells;
max_rockets = from.max_rockets;
diff --git a/src/jake2/game/client_respawn_t.java b/src/jake2/game/client_respawn_t.java
index a2ed8d5..f24a15c 100644
--- a/src/jake2/game/client_respawn_t.java
+++ b/src/jake2/game/client_respawn_t.java
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: client_respawn_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: client_respawn_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -42,7 +42,7 @@ public class client_respawn_t
coop_respawn.set(from.coop_respawn);
enterframe = from.enterframe;
score = from.score;
- cmd_angles = Lib.clone(from.cmd_angles);
+ cmd_angles = Lib.clone(cmd_angles);
spectator = from.spectator;
}
diff --git a/src/jake2/game/cplane_t.java b/src/jake2/game/cplane_t.java
index 4465a76..2eb29e9 100644
--- a/src/jake2/game/cplane_t.java
+++ b/src/jake2/game/cplane_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: cplane_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: cplane_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -34,18 +34,17 @@ public class cplane_t
public byte signbits; // signx + (signy<<1) + (signz<<1)
public byte pad[] = { 0, 0 };
-// public cplane_t getClone()
-// {
-// cplane_t out = new cplane_t();
-// Math3D.set(out.normal, normal);
-// out.dist = dist;
-// out.type = type;
-// out.signbits = signbits;
-// out.pad[0] = pad[0];
-// out.pad[1] = pad[1];
-//
-// return out;
-// }
+ public cplane_t getClone()
+ {
+ cplane_t out = new cplane_t();
+ out.normal = Lib.clone(normal);
+ out.dist = dist;
+ out.type = type;
+ out.signbits = signbits;
+ out.pad = Lib.clone(pad);
+
+ return out;
+ }
public void set(cplane_t c)
{
diff --git a/src/jake2/game/player_state_t.java b/src/jake2/game/player_state_t.java
index 3ecc17d..f8d4860 100644
--- a/src/jake2/game/player_state_t.java
+++ b/src/jake2/game/player_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: player_state_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: player_state_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $
package jake2.game;
@@ -95,7 +95,7 @@ public class player_state_t {
fov = from.fov;
rdflags = from.rdflags;
- //stats = new short[Defines.MAX_STATS];
+ stats = new short[Defines.MAX_STATS];
System.arraycopy(from.stats, 0, stats,0, Defines.MAX_STATS);
return this;
diff --git a/src/jake2/game/trace_t.java b/src/jake2/game/trace_t.java
index ac6d413..efb65fb 100644
--- a/src/jake2/game/trace_t.java
+++ b/src/jake2/game/trace_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: trace_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: trace_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -44,23 +44,23 @@ public class trace_t implements Cloneable {
allsolid = from.allsolid;
startsolid = from.allsolid;
fraction = from.fraction;
- endpos = Lib.clone(from.endpos);
- plane.set(from.plane);
+ endpos = Lib.clone(endpos);
+ plane = from.plane.getClone();
surface = from.surface;
contents = from.contents;
ent = from.ent;
}
// =============
-// public trace_t getClone() {
-// trace_t out = null;
-// try {
-// out = (trace_t) this.clone();
-// out.plane = plane.getClone();
-// out.endpos = Lib.clone(endpos);
-// }
-// catch (CloneNotSupportedException e) {
-// }
-// return out;
-// }
+ public trace_t getClone() {
+ trace_t out = null;
+ try {
+ out = (trace_t) this.clone();
+ out.plane = plane.getClone();
+ endpos = Lib.clone(endpos);
+ }
+ catch (CloneNotSupportedException e) {
+ }
+ return out;
+ }
}
diff --git a/src/jake2/qcommon/CRC.java b/src/jake2/qcommon/CRC.java
deleted file mode 100644
index ca22d9b..0000000
--- a/src/jake2/qcommon/CRC.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-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.
-
-*/
-
-// Created on 25.01.2004 by RST.
-// $Id: CRC.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
-package jake2.qcommon;
-
-import jake2.util.Vargs;
-
-public class CRC
-{
-
- public final static short CRC_INIT_VALUE= (short) 0xffff;
- public final static short CRC_XOR_VALUE= (short) 0x0000;
-
- private static int crctable[]=
- {
- 0x0000,
- 0x1021,
- 0x2042,
- 0x3063,
- 0x4084,
- 0x50a5,
- 0x60c6,
- 0x70e7,
- 0x8108,
- 0x9129,
- 0xa14a,
- 0xb16b,
- 0xc18c,
- 0xd1ad,
- 0xe1ce,
- 0xf1ef,
- 0x1231,
- 0x0210,
- 0x3273,
- 0x2252,
- 0x52b5,
- 0x4294,
- 0x72f7,
- 0x62d6,
- 0x9339,
- 0x8318,
- 0xb37b,
- 0xa35a,
- 0xd3bd,
- 0xc39c,
- 0xf3ff,
- 0xe3de,
- 0x2462,
- 0x3443,
- 0x0420,
- 0x1401,
- 0x64e6,
- 0x74c7,
- 0x44a4,
- 0x5485,
- 0xa56a,
- 0xb54b,
- 0x8528,
- 0x9509,
- 0xe5ee,
- 0xf5cf,
- 0xc5ac,
- 0xd58d,
- 0x3653,
- 0x2672,
- 0x1611,
- 0x0630,
- 0x76d7,
- 0x66f6,
- 0x5695,
- 0x46b4,
- 0xb75b,
- 0xa77a,
- 0x9719,
- 0x8738,
- 0xf7df,
- 0xe7fe,
- 0xd79d,
- 0xc7bc,
- 0x48c4,
- 0x58e5,
- 0x6886,
- 0x78a7,
- 0x0840,
- 0x1861,
- 0x2802,
- 0x3823,
- 0xc9cc,
- 0xd9ed,
- 0xe98e,
- 0xf9af,
- 0x8948,
- 0x9969,
- 0xa90a,
- 0xb92b,
- 0x5af5,
- 0x4ad4,
- 0x7ab7,
- 0x6a96,
- 0x1a71,
- 0x0a50,
- 0x3a33,
- 0x2a12,
- 0xdbfd,
- 0xcbdc,
- 0xfbbf,
- 0xeb9e,
- 0x9b79,
- 0x8b58,
- 0xbb3b,
- 0xab1a,
- 0x6ca6,
- 0x7c87,
- 0x4ce4,
- 0x5cc5,
- 0x2c22,
- 0x3c03,
- 0x0c60,
- 0x1c41,
- 0xedae,
- 0xfd8f,
- 0xcdec,
- 0xddcd,
- 0xad2a,
- 0xbd0b,
- 0x8d68,
- 0x9d49,
- 0x7e97,
- 0x6eb6,
- 0x5ed5,
- 0x4ef4,
- 0x3e13,
- 0x2e32,
- 0x1e51,
- 0x0e70,
- 0xff9f,
- 0xefbe,
- 0xdfdd,
- 0xcffc,
- 0xbf1b,
- 0xaf3a,
- 0x9f59,
- 0x8f78,
- 0x9188,
- 0x81a9,
- 0xb1ca,
- 0xa1eb,
- 0xd10c,
- 0xc12d,
- 0xf14e,
- 0xe16f,
- 0x1080,
- 0x00a1,
- 0x30c2,
- 0x20e3,
- 0x5004,
- 0x4025,
- 0x7046,
- 0x6067,
- 0x83b9,
- 0x9398,
- 0xa3fb,
- 0xb3da,
- 0xc33d,
- 0xd31c,
- 0xe37f,
- 0xf35e,
- 0x02b1,
- 0x1290,
- 0x22f3,
- 0x32d2,
- 0x4235,
- 0x5214,
- 0x6277,
- 0x7256,
- 0xb5ea,
- 0xa5cb,
- 0x95a8,
- 0x8589,
- 0xf56e,
- 0xe54f,
- 0xd52c,
- 0xc50d,
- 0x34e2,
- 0x24c3,
- 0x14a0,
- 0x0481,
- 0x7466,
- 0x6447,
- 0x5424,
- 0x4405,
- 0xa7db,
- 0xb7fa,
- 0x8799,
- 0x97b8,
- 0xe75f,
- 0xf77e,
- 0xc71d,
- 0xd73c,
- 0x26d3,
- 0x36f2,
- 0x0691,
- 0x16b0,
- 0x6657,
- 0x7676,
- 0x4615,
- 0x5634,
- 0xd94c,
- 0xc96d,
- 0xf90e,
- 0xe92f,
- 0x99c8,
- 0x89e9,
- 0xb98a,
- 0xa9ab,
- 0x5844,
- 0x4865,
- 0x7806,
- 0x6827,
- 0x18c0,
- 0x08e1,
- 0x3882,
- 0x28a3,
- 0xcb7d,
- 0xdb5c,
- 0xeb3f,
- 0xfb1e,
- 0x8bf9,
- 0x9bd8,
- 0xabbb,
- 0xbb9a,
- 0x4a75,
- 0x5a54,
- 0x6a37,
- 0x7a16,
- 0x0af1,
- 0x1ad0,
- 0x2ab3,
- 0x3a92,
- 0xfd2e,
- 0xed0f,
- 0xdd6c,
- 0xcd4d,
- 0xbdaa,
- 0xad8b,
- 0x9de8,
- 0x8dc9,
- 0x7c26,
- 0x6c07,
- 0x5c64,
- 0x4c45,
- 0x3ca2,
- 0x2c83,
- 0x1ce0,
- 0x0cc1,
- 0xef1f,
- 0xff3e,
- 0xcf5d,
- 0xdf7c,
- 0xaf9b,
- 0xbfba,
- 0x8fd9,
- 0x9ff8,
- 0x6e17,
- 0x7e36,
- 0x4e55,
- 0x5e74,
- 0x2e93,
- 0x3eb2,
- 0x0ed1,
- 0x1ef0 };
-
- static short CRC_Block(byte start[], int count)
- {
- short crc= CRC_INIT_VALUE;
-
- int ndx= 0;
-
- while (count-- > 0)
- crc= (short) ((crc << 8) ^ crctable[0xff & ((crc >> 8) ^ start[ndx++])]);
-
- return crc;
- }
-
- public static void main(String[] args)
- {
- byte data[]=
- {
- (byte) 0x71,
- (byte) 0xa9,
- (byte) 0x05,
- (byte) 0xce,
- (byte) 0x8d,
- (byte) 0x75,
- (byte) 0x28,
- (byte) 0xc8,
- (byte) 0xba,
- (byte) 0x97,
-
- (byte) 0x45,
- (byte) 0xe9,
- (byte) 0x8a,
- (byte) 0xe0,
- (byte) 0x37,
- (byte) 0xbd,
- (byte) 0x6c,
- (byte) 0x6d,
- (byte) 0x67,
- (byte) 0x4a,
- (byte) 0x21 };
- System.out.println("crc:" + (CRC_Block(data, 21) & 0xffff));
- System.out.println("----");
- for (int n=0; n < 5; n++)
- System.out.println("seq:" + (Com.BlockSequenceCRCByte( data,0, 21,n*10) & 0xff));
-
- }
-
-/* c test:
- *
- * D:\Rene\gamesrc\quake2-3.21\qcommon>crc
- * crc=-12353
- * ----
- * seq:215
- * seq:252
- * seq:164
- * seq:202
- * seq:201
- *
-int main()
-{
- byte data[21] =
- {
- 0x71,
- 0xa9,
- 0x05,
- 0xce,
- 0x8d,
- 0x75,
- 0x28,
- 0xc8,
- 0xba,
- 0x97,
-
- 0x45,
- 0xe9,
- 0x8a,
- 0xe0,
- 0x37,
- 0xbd,
- 0x6c,
- 0x6d,
- 0x67,
- 0x4a, 0x21 };
- int n=0;
-
- printf("crc=%d\n", (short) CRC_Block(&data, 21));
-
- printf("----\n");
- for (n=0; n < 5; n++)
- printf("seq:%d\n", COM_BlockSequenceCRCByte( &data,21, n*10) );
-}
- */
-
-}
diff --git a/src/jake2/qcommon/MSG.java b/src/jake2/qcommon/MSG.java
index 36b1467..3d18798 100644
--- a/src/jake2/qcommon/MSG.java
+++ b/src/jake2/qcommon/MSG.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 29.11.2003 by RST.
-// $Id: MSG.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
+// $Id: MSG.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
package jake2.qcommon;
@@ -34,6 +34,9 @@ public class MSG extends GameBase {
//ok.
public static void WriteChar(sizebuf_t sb, int c) {
+// if (c < -128 || c > 127)
+// Com.Error(ERR_FATAL, "WriteChar: range error");
+
sb.data[SZ.GetSpace(sb, 1)] = (byte) (c & 0xFF);
}
@@ -45,6 +48,11 @@ public class MSG extends GameBase {
//ok.
public static void WriteByte(sizebuf_t sb, int c) {
+ byte buf;
+
+ //if (c < 0 || c > 255)
+ //Com.Error(ERR_FATAL, "WriteByte: range error");
+
sb.data[SZ.GetSpace(sb, 1)] = (byte) (c & 0xFF);
}
@@ -55,6 +63,11 @@ public class MSG extends GameBase {
public static void WriteShort(sizebuf_t sb, int c) {
+
+ // TODO brauchen wir nicht (cwei)
+ // if (c < -32768 || c > 32767)
+ // Com.Error(ERR_FATAL, "WriteShort: range error");
+
int i = SZ.GetSpace(sb, 2);
sb.data[i++] = (byte) (c & 0xff);
sb.data[i] = (byte) ((c >>> 8) & 0xFF);
@@ -62,6 +75,7 @@ public class MSG extends GameBase {
//ok.
public static void WriteInt(sizebuf_t sb, int c) {
+
int i = SZ.GetSpace(sb, 4);
sb.data[i++] = (byte) ((c & 0xff));
sb.data[i++] = (byte) ((c >>> 8) & 0xff);
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index 3da48ca..bf7771c 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.3 2004-07-08 20:24:48 hzi Exp $
+ * $Id: Qcommon.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -110,13 +110,13 @@ public final class Qcommon extends Globals {
NET.NET_Init();
Netchan.Netchan_Init();
- SV_MAIN.SV_Init();
+ //SV_MAIN.SV_Init();
CL.Init();
// add + commands from command line
if (!Cbuf.AddLateCommands()) {
// if the user didn't give any commands, run default action
- //Cbuf.AddText("d1\n");
+ Cbuf.AddText("d1\n");
Cbuf.Execute();
} else {
// the user asked for something explicit
@@ -183,6 +183,7 @@ public final class Qcommon extends Globals {
Globals.logfile_active= Cvar.Get("logfile", "0", 0);
Globals.showtrace= Cvar.Get("showtrace", "0", 0);
Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET);
+ Globals.slomo= Cvar.Get("slomo", "1", 0);
String s = Com.sprintf("%4.2f %s %s %s",
new Vargs(4)
.add(Globals.VERSION)
diff --git a/src/jake2/qcommon/qfiles.java b/src/jake2/qcommon/qfiles.java
index ae7fdf6..bda2233 100644
--- a/src/jake2/qcommon/qfiles.java
+++ b/src/jake2/qcommon/qfiles.java
@@ -2,7 +2,7 @@
* qfiles.java
* Copyright (C) 2003
*
- * $Id: qfiles.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
+ * $Id: qfiles.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -114,52 +114,6 @@ public class qfiles {
/*
========================================================================
- TGA files are used for sky planes
-
- ========================================================================
- */
- public static class tga_t {
-
- // targa header
- public int id_length, colormap_type, image_type; // unsigned char
- public int colormap_index, colormap_length; // unsigned short
- public int colormap_size; // unsigned char
- public int x_origin, y_origin, width, height; // unsigned short
- public int pixel_size, attributes; // unsigned char
-
- public ByteBuffer data; // (un)compressed data
-
- public tga_t(byte[] dataBytes) {
- this(ByteBuffer.wrap(dataBytes));
- }
-
- public tga_t(ByteBuffer b) {
- // is stored as little endian
- b.order(ByteOrder.LITTLE_ENDIAN);
-
- // fill header
- id_length = b.get() & 0xFF;
- colormap_type = b.get() & 0xFF;
- image_type = b.get() & 0xFF;
- colormap_index = b.getShort() & 0xFFFF;
- colormap_length = b.getShort() & 0xFFFF;
- colormap_size = b.get() & 0xFF;
- x_origin = b.getShort() & 0xFFFF;
- y_origin = b.getShort() & 0xFFFF;
- width = b.getShort() & 0xFFFF;
- height = b.getShort() & 0xFFFF;
- pixel_size = b.get() & 0xFF;
- attributes = b.get() & 0xFF;
-
- // fill data
- data = b.slice();
- }
-
- }
-
- /*
- ========================================================================
-
.MD2 triangle model file format
========================================================================
diff --git a/src/jake2/render/FastJoglRenderer.java b/src/jake2/render/FastJoglRenderer.java
deleted file mode 100644
index da20bfd..0000000
--- a/src/jake2/render/FastJoglRenderer.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * FastJoglRenderer.java
- * Copyright (C) 2003
- *
- * $Id: FastJoglRenderer.java,v 1.1 2004-07-09 06:50:47 hzi 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.
-
-*/
-package jake2.render;
-
-import jake2.Defines;
-import jake2.client.*;
-import jake2.qcommon.xcommand_t;
-import jake2.render.fastjogl.Impl;
-
-import java.awt.Dimension;
-
-/**
- * FastJoglRenderer
- *
- * @author cwei
- */
-final class FastJoglRenderer extends Impl implements refexport_t, Ref {
-
- static {
- Renderer.register(new FastJoglRenderer());
- };
-
- private FastJoglRenderer() {
- }
-
- // ============================================================================
- // public interface for Renderer implementations
- //
- // refexport_t (ref.h)
- // ============================================================================
-
- /**
- * @see jake2.client.refexport_t#Init()
- */
- public boolean Init(int vid_xpos, int vid_ypos) {
-
- // pre init
- if (!R_Init(vid_xpos, vid_ypos)) return false;
- // calls the R_Init2() internally
- updateScreen();
- // the result from R_Init2()
- return post_init;
- }
-
- /**
- * @see jake2.client.refexport_t#Shutdown()
- */
- public void Shutdown() {
- R_Shutdown();
- }
-
- /**
- * @see jake2.client.refexport_t#BeginRegistration(java.lang.String)
- */
- public void BeginRegistration(String map) {
- if (contextInUse) {
- R_BeginRegistration(map);
- return;
- }
- this.name = map;
-
- updateScreen(new xcommand_t() {
- public void execute() {
- R_BeginRegistration(FastJoglRenderer.this.name);
- }
- });
- }
-
-
- private model_t model = null;
- private String name = null;
-
- /**
- * @see jake2.client.refexport_t#RegisterModel(java.lang.String)
- */
- public model_t RegisterModel(String name) {
-
- if (contextInUse)
- return R_RegisterModel(name);
-
- model = null;
- this.name = name;
-
- updateScreen(new xcommand_t() {
- public void execute() {
- FastJoglRenderer.this.model = R_RegisterModel(FastJoglRenderer.this.name);
- }
- });
- return model;
- }
-
- /**
- * @see jake2.client.refexport_t#RegisterSkin(java.lang.String)
- */
- public image_t RegisterSkin(String name) {
- if (contextInUse)
- return R_RegisterSkin(name);
-
- this.image = null;
- this.name = name;
-
- updateScreen(new xcommand_t() {
- public void execute() {
- FastJoglRenderer.this.image = R_RegisterSkin(FastJoglRenderer.this.name);
- }
- });
- return image;
- }
-
- private image_t image = null;
-
- /**
- * @see jake2.client.refexport_t#RegisterPic(java.lang.String)
- */
- public image_t RegisterPic(String name) {
- if (contextInUse)
- return Draw_FindPic(name);
-
- this.image = null;
- this.name = name;
-
- updateScreen(new xcommand_t() {
- public void execute() {
- FastJoglRenderer.this.image = Draw_FindPic(FastJoglRenderer.this.name);
- }
- });
- return image;
- }
-
-
- private float[] axis;
- private float rotate;
-
- /**
- * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[])
- */
- public void SetSky(String name, float rotate, float[] axis) {
- if (contextInUse) {
- R_SetSky(name, rotate, axis);
- return;
- }
-
- this.name = name;
- this.rotate = rotate;
- this.axis = axis;
-
- updateScreen(new xcommand_t() {
- public void execute() {
- R_SetSky(FastJoglRenderer.this.name, FastJoglRenderer.this.rotate, FastJoglRenderer.this.axis);
- }
- });
-
- }
-
- /**
- * @see jake2.client.refexport_t#EndRegistration()
- */
- public void EndRegistration() {
- if (contextInUse) {
- R_EndRegistration();
- return;
- }
-
- updateScreen(new xcommand_t() {
- public void execute() {
- R_EndRegistration();
- }
- });
- }
-
- /**
- * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t)
- */
- public void RenderFrame(refdef_t fd) {
- R_RenderFrame(fd);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String)
- */
- public void DrawGetPicSize(Dimension dim, String name) {
- Draw_GetPicSize(dim, name);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String)
- */
- public void DrawPic(int x, int y, String name) {
- Draw_Pic(x, y, name);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String)
- */
- public void DrawStretchPic(int x, int y, int w, int h, String name) {
- Draw_StretchPic(x, y, w, h, name);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawChar(int, int, int)
- */
- public void DrawChar(int x, int y, int num) {
- Draw_Char(x, y, num);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String)
- */
- public void DrawTileClear(int x, int y, int w, int h, String name) {
- Draw_TileClear(x, y, w, h, name);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int)
- */
- public void DrawFill(int x, int y, int w, int h, int c) {
- Draw_Fill(x, y, w, h, c);
- }
-
- /**
- * @see jake2.client.refexport_t#DrawFadeScreen()
- */
- public void DrawFadeScreen() {
- Draw_FadeScreen();
- }
-
- /**
- * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[])
- */
- public void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) {
- Draw_StretchRaw(x, y, w, h, cols, rows, data);
- }
-
- /**
- * @see jake2.client.refexport_t#CinematicSetPalette(byte[])
- */
- public void CinematicSetPalette(byte[] palette) {
- R_SetPalette(palette);
- }
-
- /**
- * @see jake2.client.refexport_t#BeginFrame(float)
- */
- public void BeginFrame(float camera_separation) {
- R_BeginFrame(camera_separation);
- }
-
- /**
- * @see jake2.client.refexport_t#EndFrame()
- */
- public void EndFrame() {
- GLimp_EndFrame();
- }
-
- /**
- * @see jake2.client.refexport_t#AppActivate(boolean)
- */
- public void AppActivate(boolean activate) {
- GLimp_AppActivate(activate);
- }
-
- public int apiVersion() {
- return Defines.API_VERSION;
- }
-
- // ============================================================================
- // Ref interface
- // ============================================================================
-
- public String getName() {
- return DRIVER_NAME;
- }
-
- public String toString() {
- return DRIVER_NAME;
- }
-
- public refexport_t GetRefAPI(refimport_t rimp) {
- this.ri = rimp;
- return this;
- }
-
-} \ No newline at end of file
diff --git a/src/jake2/render/fastjogl/Anorms.java b/src/jake2/render/fastjogl/Anorms.java
deleted file mode 100644
index 552b305..0000000
--- a/src/jake2/render/fastjogl/Anorms.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Anorms.java
- * Copyright (C) 2003
- *
- * $Id: Anorms.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-/**
- * Anorms
- *
- * @author cwei
- */
-public interface Anorms {
-
- final float[][] VERTEXNORMALS = {
- {-0.525731f, 0.000000f, 0.850651f},
- {-0.442863f, 0.238856f, 0.864188f},
- {-0.295242f, 0.000000f, 0.955423f},
- {-0.309017f, 0.500000f, 0.809017f},
- {-0.162460f, 0.262866f, 0.951056f},
- {0.000000f, 0.000000f, 1.000000f},
- {0.000000f, 0.850651f, 0.525731f},
- {-0.147621f, 0.716567f, 0.681718f},
- {0.147621f, 0.716567f, 0.681718f},
- {0.000000f, 0.525731f, 0.850651f},
- {0.309017f, 0.500000f, 0.809017f},
- {0.525731f, 0.000000f, 0.850651f},
- {0.295242f, 0.000000f, 0.955423f},
- {0.442863f, 0.238856f, 0.864188f},
- {0.162460f, 0.262866f, 0.951056f},
- {-0.681718f, 0.147621f, 0.716567f},
- {-0.809017f, 0.309017f, 0.500000f},
- {-0.587785f, 0.425325f, 0.688191f},
- {-0.850651f, 0.525731f, 0.000000f},
- {-0.864188f, 0.442863f, 0.238856f},
- {-0.716567f, 0.681718f, 0.147621f},
- {-0.688191f, 0.587785f, 0.425325f},
- {-0.500000f, 0.809017f, 0.309017f},
- {-0.238856f, 0.864188f, 0.442863f},
- {-0.425325f, 0.688191f, 0.587785f},
- {-0.716567f, 0.681718f, -0.147621f},
- {-0.500000f, 0.809017f, -0.309017f},
- {-0.525731f, 0.850651f, 0.000000f},
- {0.000000f, 0.850651f, -0.525731f},
- {-0.238856f, 0.864188f, -0.442863f},
- {0.000000f, 0.955423f, -0.295242f},
- {-0.262866f, 0.951056f, -0.162460f},
- {0.000000f, 1.000000f, 0.000000f},
- {0.000000f, 0.955423f, 0.295242f},
- {-0.262866f, 0.951056f, 0.162460f},
- {0.238856f, 0.864188f, 0.442863f},
- {0.262866f, 0.951056f, 0.162460f},
- {0.500000f, 0.809017f, 0.309017f},
- {0.238856f, 0.864188f, -0.442863f},
- {0.262866f, 0.951056f, -0.162460f},
- {0.500000f, 0.809017f, -0.309017f},
- {0.850651f, 0.525731f, 0.000000f},
- {0.716567f, 0.681718f, 0.147621f},
- {0.716567f, 0.681718f, -0.147621f},
- {0.525731f, 0.850651f, 0.000000f},
- {0.425325f, 0.688191f, 0.587785f},
- {0.864188f, 0.442863f, 0.238856f},
- {0.688191f, 0.587785f, 0.425325f},
- {0.809017f, 0.309017f, 0.500000f},
- {0.681718f, 0.147621f, 0.716567f},
- {0.587785f, 0.425325f, 0.688191f},
- {0.955423f, 0.295242f, 0.000000f},
- {1.000000f, 0.000000f, 0.000000f},
- {0.951056f, 0.162460f, 0.262866f},
- {0.850651f, -0.525731f, 0.000000f},
- {0.955423f, -0.295242f, 0.000000f},
- {0.864188f, -0.442863f, 0.238856f},
- {0.951056f, -0.162460f, 0.262866f},
- {0.809017f, -0.309017f, 0.500000f},
- {0.681718f, -0.147621f, 0.716567f},
- {0.850651f, 0.000000f, 0.525731f},
- {0.864188f, 0.442863f, -0.238856f},
- {0.809017f, 0.309017f, -0.500000f},
- {0.951056f, 0.162460f, -0.262866f},
- {0.525731f, 0.000000f, -0.850651f},
- {0.681718f, 0.147621f, -0.716567f},
- {0.681718f, -0.147621f, -0.716567f},
- {0.850651f, 0.000000f, -0.525731f},
- {0.809017f, -0.309017f, -0.500000f},
- {0.864188f, -0.442863f, -0.238856f},
- {0.951056f, -0.162460f, -0.262866f},
- {0.147621f, 0.716567f, -0.681718f},
- {0.309017f, 0.500000f, -0.809017f},
- {0.425325f, 0.688191f, -0.587785f},
- {0.442863f, 0.238856f, -0.864188f},
- {0.587785f, 0.425325f, -0.688191f},
- {0.688191f, 0.587785f, -0.425325f},
- {-0.147621f, 0.716567f, -0.681718f},
- {-0.309017f, 0.500000f, -0.809017f},
- {0.000000f, 0.525731f, -0.850651f},
- {-0.525731f, 0.000000f, -0.850651f},
- {-0.442863f, 0.238856f, -0.864188f},
- {-0.295242f, 0.000000f, -0.955423f},
- {-0.162460f, 0.262866f, -0.951056f},
- {0.000000f, 0.000000f, -1.000000f},
- {0.295242f, 0.000000f, -0.955423f},
- {0.162460f, 0.262866f, -0.951056f},
- {-0.442863f, -0.238856f, -0.864188f},
- {-0.309017f, -0.500000f, -0.809017f},
- {-0.162460f, -0.262866f, -0.951056f},
- {0.000000f, -0.850651f, -0.525731f},
- {-0.147621f, -0.716567f, -0.681718f},
- {0.147621f, -0.716567f, -0.681718f},
- {0.000000f, -0.525731f, -0.850651f},
- {0.309017f, -0.500000f, -0.809017f},
- {0.442863f, -0.238856f, -0.864188f},
- {0.162460f, -0.262866f, -0.951056f},
- {0.238856f, -0.864188f, -0.442863f},
- {0.500000f, -0.809017f, -0.309017f},
- {0.425325f, -0.688191f, -0.587785f},
- {0.716567f, -0.681718f, -0.147621f},
- {0.688191f, -0.587785f, -0.425325f},
- {0.587785f, -0.425325f, -0.688191f},
- {0.000000f, -0.955423f, -0.295242f},
- {0.000000f, -1.000000f, 0.000000f},
- {0.262866f, -0.951056f, -0.162460f},
- {0.000000f, -0.850651f, 0.525731f},
- {0.000000f, -0.955423f, 0.295242f},
- {0.238856f, -0.864188f, 0.442863f},
- {0.262866f, -0.951056f, 0.162460f},
- {0.500000f, -0.809017f, 0.309017f},
- {0.716567f, -0.681718f, 0.147621f},
- {0.525731f, -0.850651f, 0.000000f},
- {-0.238856f, -0.864188f, -0.442863f},
- {-0.500000f, -0.809017f, -0.309017f},
- {-0.262866f, -0.951056f, -0.162460f},
- {-0.850651f, -0.525731f, 0.000000f},
- {-0.716567f, -0.681718f, -0.147621f},
- {-0.716567f, -0.681718f, 0.147621f},
- {-0.525731f, -0.850651f, 0.000000f},
- {-0.500000f, -0.809017f, 0.309017f},
- {-0.238856f, -0.864188f, 0.442863f},
- {-0.262866f, -0.951056f, 0.162460f},
- {-0.864188f, -0.442863f, 0.238856f},
- {-0.809017f, -0.309017f, 0.500000f},
- {-0.688191f, -0.587785f, 0.425325f},
- {-0.681718f, -0.147621f, 0.716567f},
- {-0.442863f, -0.238856f, 0.864188f},
- {-0.587785f, -0.425325f, 0.688191f},
- {-0.309017f, -0.500000f, 0.809017f},
- {-0.147621f, -0.716567f, 0.681718f},
- {-0.425325f, -0.688191f, 0.587785f},
- {-0.162460f, -0.262866f, 0.951056f},
- {0.442863f, -0.238856f, 0.864188f},
- {0.162460f, -0.262866f, 0.951056f},
- {0.309017f, -0.500000f, 0.809017f},
- {0.147621f, -0.716567f, 0.681718f},
- {0.000000f, -0.525731f, 0.850651f},
- {0.425325f, -0.688191f, 0.587785f},
- {0.587785f, -0.425325f, 0.688191f},
- {0.688191f, -0.587785f, 0.425325f},
- {-0.955423f, 0.295242f, 0.000000f},
- {-0.951056f, 0.162460f, 0.262866f},
- {-1.000000f, 0.000000f, 0.000000f},
- {-0.850651f, 0.000000f, 0.525731f},
- {-0.955423f, -0.295242f, 0.000000f},
- {-0.951056f, -0.162460f, 0.262866f},
- {-0.864188f, 0.442863f, -0.238856f},
- {-0.951056f, 0.162460f, -0.262866f},
- {-0.809017f, 0.309017f, -0.500000f},
- {-0.864188f, -0.442863f, -0.238856f},
- {-0.951056f, -0.162460f, -0.262866f},
- {-0.809017f, -0.309017f, -0.500000f},
- {-0.681718f, 0.147621f, -0.716567f},
- {-0.681718f, -0.147621f, -0.716567f},
- {-0.850651f, 0.000000f, -0.525731f},
- {-0.688191f, 0.587785f, -0.425325f},
- {-0.587785f, 0.425325f, -0.688191f},
- {-0.425325f, 0.688191f, -0.587785f},
- {-0.425325f, -0.688191f, -0.587785f},
- {-0.587785f, -0.425325f, -0.688191f},
- {-0.688191f, -0.587785f, -0.425325f}
- };
-
- final float[][] VERTEXNORMAL_DOTS = {
- {1.23f,1.30f,1.47f,1.35f,1.56f,1.71f,1.37f,1.38f,1.59f,1.60f,1.79f,1.97f,1.88f,1.92f,1.79f,1.02f,0.93f,1.07f,0.82f,0.87f,0.88f,0.94f,0.96f,1.14f,1.11f,0.82f,0.83f,0.89f,0.89f,0.86f,0.94f,0.91f,1.00f,1.21f,0.98f,1.48f,1.30f,1.57f,0.96f,1.07f,1.14f,1.60f,1.61f,1.40f,1.37f,1.72f,1.78f,1.79f,1.93f,1.99f,1.90f,1.68f,1.71f,1.86f,1.60f,1.68f,1.78f,1.86f,1.93f,1.99f,1.97f,1.44f,1.22f,1.49f,0.93f,0.99f,0.99f,1.23f,1.22f,1.44f,1.49f,0.89f,0.89f,0.97f,0.91f,0.98f,1.19f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.19f,0.98f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.87f,0.93f,0.94f,1.02f,1.30f,1.07f,1.35f,1.38f,1.11f,1.56f,1.92f,1.79f,1.79f,1.59f,1.60f,1.72f,1.90f,1.79f,0.80f,0.85f,0.79f,0.93f,0.80f,0.85f,0.77f,0.74f,0.72f,0.77f,0.74f,0.72f,0.70f,0.70f,0.71f,0.76f,0.73f,0.79f,0.79f,0.73f,0.76f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.26f,1.26f,1.48f,1.23f,1.50f,1.71f,1.14f,1.19f,1.38f,1.46f,1.64f,1.94f,1.87f,1.84f,1.71f,1.02f,0.92f,1.00f,0.79f,0.85f,0.84f,0.91f,0.90f,0.98f,0.99f,0.77f,0.77f,0.83f,0.82f,0.79f,0.86f,0.84f,0.92f,0.99f,0.91f,1.24f,1.03f,1.33f,0.88f,0.94f,0.97f,1.41f,1.39f,1.18f,1.11f,1.51f,1.61f,1.59f,1.80f,1.91f,1.76f,1.54f,1.65f,1.76f,1.70f,1.70f,1.85f,1.85f,1.97f,1.99f,1.93f,1.28f,1.09f,1.39f,0.92f,0.97f,0.99f,1.18f,1.26f,1.52f,1.48f,0.83f,0.85f,0.90f,0.88f,0.93f,1.00f,0.77f,0.73f,0.78f,0.72f,0.71f,0.74f,0.75f,0.79f,0.86f,0.81f,0.75f,0.81f,0.79f,0.96f,0.88f,0.94f,0.86f,0.93f,0.92f,0.85f,1.08f,1.33f,1.05f,1.55f,1.31f,1.01f,1.05f,1.27f,1.31f,1.60f,1.47f,1.70f,1.54f,1.76f,1.76f,1.57f,0.93f,0.90f,0.99f,0.88f,0.88f,0.95f,0.97f,1.11f,1.39f,1.20f,0.92f,0.97f,1.01f,1.10f,1.39f,1.22f,1.51f,1.58f,1.32f,1.64f,1.97f,1.85f,1.91f,1.77f,1.74f,1.88f,1.99f,1.91f,0.79f,0.86f,0.80f,0.94f,0.84f,0.88f,0.74f,0.74f,0.71f,0.82f,0.77f,0.76f,0.70f,0.73f,0.72f,0.73f,0.70f,0.74f,0.85f,0.77f,0.82f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.34f,1.27f,1.53f,1.17f,1.46f,1.71f,0.98f,1.05f,1.20f,1.34f,1.48f,1.86f,1.82f,1.71f,1.62f,1.09f,0.94f,0.99f,0.79f,0.85f,0.82f,0.90f,0.87f,0.93f,0.96f,0.76f,0.74f,0.79f,0.76f,0.74f,0.79f,0.78f,0.85f,0.92f,0.85f,1.00f,0.93f,1.06f,0.81f,0.86f,0.89f,1.16f,1.12f,0.97f,0.95f,1.28f,1.38f,1.35f,1.60f,1.77f,1.57f,1.33f,1.50f,1.58f,1.69f,1.63f,1.82f,1.74f,1.91f,1.92f,1.80f,1.04f,0.97f,1.21f,0.90f,0.93f,0.97f,1.05f,1.21f,1.48f,1.37f,0.77f,0.80f,0.84f,0.85f,0.88f,0.92f,0.73f,0.71f,0.74f,0.74f,0.71f,0.75f,0.73f,0.79f,0.84f,0.78f,0.79f,0.86f,0.81f,1.05f,0.94f,0.99f,0.90f,0.95f,0.92f,0.86f,1.24f,1.44f,1.14f,1.59f,1.34f,1.02f,1.27f,1.50f,1.49f,1.80f,1.69f,1.86f,1.72f,1.87f,1.80f,1.69f,1.00f,0.98f,1.23f,0.95f,0.96f,1.09f,1.16f,1.37f,1.63f,1.46f,0.99f,1.10f,1.25f,1.24f,1.51f,1.41f,1.67f,1.77f,1.55f,1.72f,1.95f,1.89f,1.98f,1.91f,1.86f,1.97f,1.99f,1.94f,0.81f,0.89f,0.85f,0.98f,0.90f,0.94f,0.75f,0.78f,0.73f,0.89f,0.83f,0.82f,0.72f,0.77f,0.76f,0.72f,0.70f,0.71f,0.91f,0.83f,0.89f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.46f,1.34f,1.60f,1.16f,1.46f,1.71f,0.94f,0.99f,1.05f,1.26f,1.33f,1.74f,1.76f,1.57f,1.54f,1.23f,0.98f,1.05f,0.83f,0.89f,0.84f,0.92f,0.87f,0.91f,0.96f,0.78f,0.74f,0.79f,0.72f,0.72f,0.75f,0.76f,0.80f,0.88f,0.83f,0.94f,0.87f,0.95f,0.76f,0.80f,0.82f,0.97f,0.96f,0.89f,0.88f,1.08f,1.11f,1.10f,1.37f,1.59f,1.37f,1.07f,1.27f,1.34f,1.57f,1.45f,1.69f,1.55f,1.77f,1.79f,1.60f,0.93f,0.90f,0.99f,0.86f,0.87f,0.93f,0.96f,1.07f,1.35f,1.18f,0.73f,0.76f,0.77f,0.81f,0.82f,0.85f,0.70f,0.71f,0.72f,0.78f,0.73f,0.77f,0.73f,0.79f,0.82f,0.76f,0.83f,0.90f,0.84f,1.18f,0.98f,1.03f,0.92f,0.95f,0.90f,0.86f,1.32f,1.45f,1.15f,1.53f,1.27f,0.99f,1.42f,1.65f,1.58f,1.93f,1.83f,1.94f,1.81f,1.88f,1.74f,1.70f,1.19f,1.17f,1.44f,1.11f,1.15f,1.36f,1.41f,1.61f,1.81f,1.67f,1.22f,1.34f,1.50f,1.42f,1.65f,1.61f,1.82f,1.91f,1.75f,1.80f,1.89f,1.89f,1.98f,1.99f,1.94f,1.98f,1.92f,1.87f,0.86f,0.95f,0.92f,1.14f,0.98f,1.03f,0.79f,0.84f,0.77f,0.97f,0.90f,0.89f,0.76f,0.82f,0.82f,0.74f,0.72f,0.71f,0.98f,0.89f,0.97f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.60f,1.44f,1.68f,1.22f,1.49f,1.71f,0.93f,0.99f,0.99f,1.23f,1.22f,1.60f,1.68f,1.44f,1.49f,1.40f,1.14f,1.19f,0.89f,0.96f,0.89f,0.97f,0.89f,0.91f,0.98f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.91f,0.83f,0.89f,0.72f,0.76f,0.76f,0.89f,0.89f,0.82f,0.82f,0.98f,0.96f,0.97f,1.14f,1.40f,1.19f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.70f,0.72f,0.73f,0.77f,0.76f,0.79f,0.70f,0.72f,0.71f,0.82f,0.77f,0.80f,0.74f,0.79f,0.80f,0.74f,0.87f,0.93f,0.85f,1.23f,1.02f,1.02f,0.93f,0.93f,0.87f,0.85f,1.30f,1.35f,1.07f,1.38f,1.11f,0.94f,1.47f,1.71f,1.56f,1.97f,1.88f,1.92f,1.79f,1.79f,1.59f,1.60f,1.30f,1.35f,1.56f,1.37f,1.38f,1.59f,1.60f,1.79f,1.92f,1.79f,1.48f,1.57f,1.72f,1.61f,1.78f,1.79f,1.93f,1.99f,1.90f,1.86f,1.78f,1.86f,1.93f,1.99f,1.97f,1.90f,1.79f,1.72f,0.94f,1.07f,1.00f,1.37f,1.21f,1.30f,0.86f,0.91f,0.83f,1.14f,0.98f,0.96f,0.82f,0.88f,0.89f,0.79f,0.76f,0.73f,1.07f,0.94f,1.11f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.74f,1.57f,1.76f,1.33f,1.54f,1.71f,0.94f,1.05f,0.99f,1.26f,1.16f,1.46f,1.60f,1.34f,1.46f,1.59f,1.37f,1.37f,0.97f,1.11f,0.96f,1.10f,0.95f,0.94f,1.08f,0.89f,0.82f,0.88f,0.72f,0.76f,0.75f,0.80f,0.80f,0.88f,0.87f,0.91f,0.83f,0.87f,0.72f,0.76f,0.74f,0.83f,0.84f,0.78f,0.79f,0.96f,0.89f,0.92f,0.98f,1.23f,1.05f,0.86f,0.92f,0.95f,1.11f,0.98f,1.22f,1.03f,1.34f,1.42f,1.14f,0.79f,0.77f,0.84f,0.78f,0.76f,0.82f,0.82f,0.89f,0.97f,0.90f,0.70f,0.71f,0.71f,0.73f,0.72f,0.74f,0.73f,0.76f,0.72f,0.86f,0.81f,0.82f,0.76f,0.79f,0.77f,0.73f,0.90f,0.95f,0.86f,1.18f,1.03f,0.98f,0.92f,0.90f,0.83f,0.84f,1.19f,1.17f,0.98f,1.15f,0.97f,0.89f,1.42f,1.65f,1.44f,1.93f,1.83f,1.81f,1.67f,1.61f,1.36f,1.41f,1.32f,1.45f,1.58f,1.57f,1.53f,1.74f,1.70f,1.88f,1.94f,1.81f,1.69f,1.77f,1.87f,1.79f,1.89f,1.92f,1.98f,1.99f,1.98f,1.89f,1.65f,1.80f,1.82f,1.91f,1.94f,1.75f,1.61f,1.50f,1.07f,1.34f,1.27f,1.60f,1.45f,1.55f,0.93f,0.99f,0.90f,1.35f,1.18f,1.07f,0.87f,0.93f,0.96f,0.85f,0.82f,0.77f,1.15f,0.99f,1.27f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.86f,1.71f,1.82f,1.48f,1.62f,1.71f,0.98f,1.20f,1.05f,1.34f,1.17f,1.34f,1.53f,1.27f,1.46f,1.77f,1.60f,1.57f,1.16f,1.38f,1.12f,1.35f,1.06f,1.00f,1.28f,0.97f,0.89f,0.95f,0.76f,0.81f,0.79f,0.86f,0.85f,0.92f,0.93f,0.93f,0.85f,0.87f,0.74f,0.78f,0.74f,0.79f,0.82f,0.76f,0.79f,0.96f,0.85f,0.90f,0.94f,1.09f,0.99f,0.81f,0.85f,0.89f,0.95f,0.90f,0.99f,0.94f,1.10f,1.24f,0.98f,0.75f,0.73f,0.78f,0.74f,0.72f,0.77f,0.76f,0.82f,0.89f,0.83f,0.73f,0.71f,0.71f,0.71f,0.70f,0.72f,0.77f,0.80f,0.74f,0.90f,0.85f,0.84f,0.78f,0.79f,0.75f,0.73f,0.92f,0.95f,0.86f,1.05f,0.99f,0.94f,0.90f,0.86f,0.79f,0.81f,1.00f,0.98f,0.91f,0.96f,0.89f,0.83f,1.27f,1.50f,1.23f,1.80f,1.69f,1.63f,1.46f,1.37f,1.09f,1.16f,1.24f,1.44f,1.49f,1.69f,1.59f,1.80f,1.69f,1.87f,1.86f,1.72f,1.82f,1.91f,1.94f,1.92f,1.95f,1.99f,1.98f,1.91f,1.97f,1.89f,1.51f,1.72f,1.67f,1.77f,1.86f,1.55f,1.41f,1.25f,1.33f,1.58f,1.50f,1.80f,1.63f,1.74f,1.04f,1.21f,0.97f,1.48f,1.37f,1.21f,0.93f,0.97f,1.05f,0.92f,0.88f,0.84f,1.14f,1.02f,1.34f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.94f,1.84f,1.87f,1.64f,1.71f,1.71f,1.14f,1.38f,1.19f,1.46f,1.23f,1.26f,1.48f,1.26f,1.50f,1.91f,1.80f,1.76f,1.41f,1.61f,1.39f,1.59f,1.33f,1.24f,1.51f,1.18f,0.97f,1.11f,0.82f,0.88f,0.86f,0.94f,0.92f,0.99f,1.03f,0.98f,0.91f,0.90f,0.79f,0.84f,0.77f,0.79f,0.84f,0.77f,0.83f,0.99f,0.85f,0.91f,0.92f,1.02f,1.00f,0.79f,0.80f,0.86f,0.88f,0.84f,0.92f,0.88f,0.97f,1.10f,0.94f,0.74f,0.71f,0.74f,0.72f,0.70f,0.73f,0.72f,0.76f,0.82f,0.77f,0.77f,0.73f,0.74f,0.71f,0.70f,0.73f,0.83f,0.85f,0.78f,0.92f,0.88f,0.86f,0.81f,0.79f,0.74f,0.75f,0.92f,0.93f,0.85f,0.96f,0.94f,0.88f,0.86f,0.81f,0.75f,0.79f,0.93f,0.90f,0.85f,0.88f,0.82f,0.77f,1.05f,1.27f,0.99f,1.60f,1.47f,1.39f,1.20f,1.11f,0.95f,0.97f,1.08f,1.33f,1.31f,1.70f,1.55f,1.76f,1.57f,1.76f,1.70f,1.54f,1.85f,1.97f,1.91f,1.99f,1.97f,1.99f,1.91f,1.77f,1.88f,1.85f,1.39f,1.64f,1.51f,1.58f,1.74f,1.32f,1.22f,1.01f,1.54f,1.76f,1.65f,1.93f,1.70f,1.85f,1.28f,1.39f,1.09f,1.52f,1.48f,1.26f,0.97f,0.99f,1.18f,1.00f,0.93f,0.90f,1.05f,1.01f,1.31f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.97f,1.92f,1.88f,1.79f,1.79f,1.71f,1.37f,1.59f,1.38f,1.60f,1.35f,1.23f,1.47f,1.30f,1.56f,1.99f,1.93f,1.90f,1.60f,1.78f,1.61f,1.79f,1.57f,1.48f,1.72f,1.40f,1.14f,1.37f,0.89f,0.96f,0.94f,1.07f,1.00f,1.21f,1.30f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.82f,0.88f,0.82f,0.89f,1.11f,0.87f,0.94f,0.93f,1.02f,1.07f,0.80f,0.79f,0.85f,0.82f,0.80f,0.87f,0.85f,0.93f,1.02f,0.93f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.82f,0.76f,0.79f,0.72f,0.73f,0.76f,0.89f,0.89f,0.82f,0.93f,0.91f,0.86f,0.83f,0.79f,0.73f,0.76f,0.91f,0.89f,0.83f,0.89f,0.89f,0.82f,0.82f,0.76f,0.72f,0.76f,0.86f,0.83f,0.79f,0.82f,0.76f,0.73f,0.94f,1.00f,0.91f,1.37f,1.21f,1.14f,0.98f,0.96f,0.88f,0.89f,0.96f,1.14f,1.07f,1.60f,1.40f,1.61f,1.37f,1.57f,1.48f,1.30f,1.78f,1.93f,1.79f,1.99f,1.92f,1.90f,1.79f,1.59f,1.72f,1.79f,1.30f,1.56f,1.35f,1.38f,1.60f,1.11f,1.07f,0.94f,1.68f,1.86f,1.71f,1.97f,1.68f,1.86f,1.44f,1.49f,1.22f,1.44f,1.49f,1.22f,0.99f,0.99f,1.23f,1.19f,0.98f,0.97f,0.97f,0.98f,1.19f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.94f,1.97f,1.87f,1.91f,1.85f,1.71f,1.60f,1.77f,1.58f,1.74f,1.51f,1.26f,1.48f,1.39f,1.64f,1.99f,1.97f,1.99f,1.70f,1.85f,1.76f,1.91f,1.76f,1.70f,1.88f,1.55f,1.33f,1.57f,0.96f,1.08f,1.05f,1.31f,1.27f,1.47f,1.54f,1.39f,1.20f,1.11f,0.93f,0.99f,0.90f,0.88f,0.95f,0.88f,0.97f,1.32f,0.92f,1.01f,0.97f,1.10f,1.22f,0.84f,0.80f,0.88f,0.79f,0.79f,0.85f,0.86f,0.92f,1.02f,0.94f,0.82f,0.76f,0.77f,0.72f,0.73f,0.70f,0.72f,0.71f,0.74f,0.74f,0.88f,0.81f,0.85f,0.75f,0.77f,0.82f,0.94f,0.93f,0.86f,0.92f,0.92f,0.86f,0.85f,0.79f,0.74f,0.79f,0.88f,0.85f,0.81f,0.82f,0.83f,0.77f,0.78f,0.73f,0.71f,0.75f,0.79f,0.77f,0.74f,0.77f,0.73f,0.70f,0.86f,0.92f,0.84f,1.14f,0.99f,0.98f,0.91f,0.90f,0.84f,0.83f,0.88f,0.97f,0.94f,1.41f,1.18f,1.39f,1.11f,1.33f,1.24f,1.03f,1.61f,1.80f,1.59f,1.91f,1.84f,1.76f,1.64f,1.38f,1.51f,1.71f,1.26f,1.50f,1.23f,1.19f,1.46f,0.99f,1.00f,0.91f,1.70f,1.85f,1.65f,1.93f,1.54f,1.76f,1.52f,1.48f,1.26f,1.28f,1.39f,1.09f,0.99f,0.97f,1.18f,1.31f,1.01f,1.05f,0.90f,0.93f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.86f,1.95f,1.82f,1.98f,1.89f,1.71f,1.80f,1.91f,1.77f,1.86f,1.67f,1.34f,1.53f,1.51f,1.72f,1.92f,1.91f,1.99f,1.69f,1.82f,1.80f,1.94f,1.87f,1.86f,1.97f,1.59f,1.44f,1.69f,1.05f,1.24f,1.27f,1.49f,1.50f,1.69f,1.72f,1.63f,1.46f,1.37f,1.00f,1.23f,0.98f,0.95f,1.09f,0.96f,1.16f,1.55f,0.99f,1.25f,1.10f,1.24f,1.41f,0.90f,0.85f,0.94f,0.79f,0.81f,0.85f,0.89f,0.94f,1.09f,0.98f,0.89f,0.82f,0.83f,0.74f,0.77f,0.72f,0.76f,0.73f,0.75f,0.78f,0.94f,0.86f,0.91f,0.79f,0.83f,0.89f,0.99f,0.95f,0.90f,0.90f,0.92f,0.84f,0.86f,0.79f,0.75f,0.81f,0.85f,0.80f,0.78f,0.76f,0.77f,0.73f,0.74f,0.71f,0.71f,0.73f,0.74f,0.74f,0.71f,0.76f,0.72f,0.70f,0.79f,0.85f,0.78f,0.98f,0.92f,0.93f,0.85f,0.87f,0.82f,0.79f,0.81f,0.89f,0.86f,1.16f,0.97f,1.12f,0.95f,1.06f,1.00f,0.93f,1.38f,1.60f,1.35f,1.77f,1.71f,1.57f,1.48f,1.20f,1.28f,1.62f,1.27f,1.46f,1.17f,1.05f,1.34f,0.96f,0.99f,0.90f,1.63f,1.74f,1.50f,1.80f,1.33f,1.58f,1.48f,1.37f,1.21f,1.04f,1.21f,0.97f,0.97f,0.93f,1.05f,1.34f,1.02f,1.14f,0.84f,0.88f,0.92f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.74f,1.89f,1.76f,1.98f,1.89f,1.71f,1.93f,1.99f,1.91f,1.94f,1.82f,1.46f,1.60f,1.65f,1.80f,1.79f,1.77f,1.92f,1.57f,1.69f,1.74f,1.87f,1.88f,1.94f,1.98f,1.53f,1.45f,1.70f,1.18f,1.32f,1.42f,1.58f,1.65f,1.83f,1.81f,1.81f,1.67f,1.61f,1.19f,1.44f,1.17f,1.11f,1.36f,1.15f,1.41f,1.75f,1.22f,1.50f,1.34f,1.42f,1.61f,0.98f,0.92f,1.03f,0.83f,0.86f,0.89f,0.95f,0.98f,1.23f,1.14f,0.97f,0.89f,0.90f,0.78f,0.82f,0.76f,0.82f,0.77f,0.79f,0.84f,0.98f,0.90f,0.98f,0.83f,0.89f,0.97f,1.03f,0.95f,0.92f,0.86f,0.90f,0.82f,0.86f,0.79f,0.77f,0.84f,0.81f,0.76f,0.76f,0.72f,0.73f,0.70f,0.72f,0.71f,0.73f,0.73f,0.72f,0.74f,0.71f,0.78f,0.74f,0.72f,0.75f,0.80f,0.76f,0.94f,0.88f,0.91f,0.83f,0.87f,0.84f,0.79f,0.76f,0.82f,0.80f,0.97f,0.89f,0.96f,0.88f,0.95f,0.94f,0.87f,1.11f,1.37f,1.10f,1.59f,1.57f,1.37f,1.33f,1.05f,1.08f,1.54f,1.34f,1.46f,1.16f,0.99f,1.26f,0.96f,1.05f,0.92f,1.45f,1.55f,1.27f,1.60f,1.07f,1.34f,1.35f,1.18f,1.07f,0.93f,0.99f,0.90f,0.93f,0.87f,0.96f,1.27f,0.99f,1.15f,0.77f,0.82f,0.85f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.60f,1.78f,1.68f,1.93f,1.86f,1.71f,1.97f,1.99f,1.99f,1.97f,1.93f,1.60f,1.68f,1.78f,1.86f,1.61f,1.57f,1.79f,1.37f,1.48f,1.59f,1.72f,1.79f,1.92f,1.90f,1.38f,1.35f,1.60f,1.23f,1.30f,1.47f,1.56f,1.71f,1.88f,1.79f,1.92f,1.79f,1.79f,1.30f,1.56f,1.35f,1.37f,1.59f,1.38f,1.60f,1.90f,1.48f,1.72f,1.57f,1.61f,1.79f,1.21f,1.00f,1.30f,0.89f,0.94f,0.96f,1.07f,1.14f,1.40f,1.37f,1.14f,0.96f,0.98f,0.82f,0.88f,0.82f,0.89f,0.83f,0.86f,0.91f,1.02f,0.93f,1.07f,0.87f,0.94f,1.11f,1.02f,0.93f,0.93f,0.82f,0.87f,0.80f,0.85f,0.79f,0.80f,0.85f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.72f,0.76f,0.73f,0.82f,0.79f,0.76f,0.73f,0.79f,0.76f,0.93f,0.86f,0.91f,0.83f,0.89f,0.89f,0.82f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.44f,1.19f,1.22f,0.99f,0.98f,1.49f,1.44f,1.49f,1.22f,0.99f,1.23f,0.98f,1.19f,0.97f,1.21f,1.30f,1.00f,1.37f,0.94f,1.07f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.88f,0.82f,0.89f,1.11f,0.94f,1.07f,0.73f,0.76f,0.79f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.46f,1.65f,1.60f,1.82f,1.80f,1.71f,1.93f,1.91f,1.99f,1.94f,1.98f,1.74f,1.76f,1.89f,1.89f,1.42f,1.34f,1.61f,1.11f,1.22f,1.36f,1.50f,1.61f,1.81f,1.75f,1.15f,1.17f,1.41f,1.18f,1.19f,1.42f,1.44f,1.65f,1.83f,1.67f,1.94f,1.81f,1.88f,1.32f,1.58f,1.45f,1.57f,1.74f,1.53f,1.70f,1.98f,1.69f,1.87f,1.77f,1.79f,1.92f,1.45f,1.27f,1.55f,0.97f,1.07f,1.11f,1.34f,1.37f,1.59f,1.60f,1.35f,1.07f,1.18f,0.86f,0.93f,0.87f,0.96f,0.90f,0.93f,0.99f,1.03f,0.95f,1.15f,0.90f,0.99f,1.27f,0.98f,0.90f,0.92f,0.78f,0.83f,0.77f,0.84f,0.79f,0.82f,0.86f,0.73f,0.71f,0.73f,0.72f,0.70f,0.73f,0.72f,0.76f,0.81f,0.76f,0.76f,0.82f,0.77f,0.89f,0.85f,0.82f,0.75f,0.80f,0.80f,0.94f,0.88f,0.94f,0.87f,0.95f,0.96f,0.88f,0.72f,0.74f,0.76f,0.83f,0.78f,0.84f,0.79f,0.87f,0.91f,0.83f,0.89f,0.98f,0.92f,1.23f,1.34f,1.05f,1.16f,0.99f,0.96f,1.46f,1.57f,1.54f,1.33f,1.05f,1.26f,1.08f,1.37f,1.10f,0.98f,1.03f,0.92f,1.14f,0.86f,0.95f,0.97f,0.90f,0.89f,0.79f,0.84f,0.77f,0.82f,0.76f,0.82f,0.97f,0.89f,0.98f,0.71f,0.72f,0.74f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.34f,1.51f,1.53f,1.67f,1.72f,1.71f,1.80f,1.77f,1.91f,1.86f,1.98f,1.86f,1.82f,1.95f,1.89f,1.24f,1.10f,1.41f,0.95f,0.99f,1.09f,1.25f,1.37f,1.63f,1.55f,0.96f,0.98f,1.16f,1.05f,1.00f,1.27f,1.23f,1.50f,1.69f,1.46f,1.86f,1.72f,1.87f,1.24f,1.49f,1.44f,1.69f,1.80f,1.59f,1.69f,1.97f,1.82f,1.94f,1.91f,1.92f,1.99f,1.63f,1.50f,1.74f,1.16f,1.33f,1.38f,1.58f,1.60f,1.77f,1.80f,1.48f,1.21f,1.37f,0.90f,0.97f,0.93f,1.05f,0.97f,1.04f,1.21f,0.99f,0.95f,1.14f,0.92f,1.02f,1.34f,0.94f,0.86f,0.90f,0.74f,0.79f,0.75f,0.81f,0.79f,0.84f,0.86f,0.71f,0.71f,0.73f,0.76f,0.73f,0.77f,0.74f,0.80f,0.85f,0.78f,0.81f,0.89f,0.84f,0.97f,0.92f,0.88f,0.79f,0.85f,0.86f,0.98f,0.92f,1.00f,0.93f,1.06f,1.12f,0.95f,0.74f,0.74f,0.78f,0.79f,0.76f,0.82f,0.79f,0.87f,0.93f,0.85f,0.85f,0.94f,0.90f,1.09f,1.27f,0.99f,1.17f,1.05f,0.96f,1.46f,1.71f,1.62f,1.48f,1.20f,1.34f,1.28f,1.57f,1.35f,0.90f,0.94f,0.85f,0.98f,0.81f,0.89f,0.89f,0.83f,0.82f,0.75f,0.78f,0.73f,0.77f,0.72f,0.76f,0.89f,0.83f,0.91f,0.71f,0.70f,0.72f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f},
- {1.26f,1.39f,1.48f,1.51f,1.64f,1.71f,1.60f,1.58f,1.77f,1.74f,1.91f,1.94f,1.87f,1.97f,1.85f,1.10f,0.97f,1.22f,0.88f,0.92f,0.95f,1.01f,1.11f,1.39f,1.32f,0.88f,0.90f,0.97f,0.96f,0.93f,1.05f,0.99f,1.27f,1.47f,1.20f,1.70f,1.54f,1.76f,1.08f,1.31f,1.33f,1.70f,1.76f,1.55f,1.57f,1.88f,1.85f,1.91f,1.97f,1.99f,1.99f,1.70f,1.65f,1.85f,1.41f,1.54f,1.61f,1.76f,1.80f,1.91f,1.93f,1.52f,1.26f,1.48f,0.92f,0.99f,0.97f,1.18f,1.09f,1.28f,1.39f,0.94f,0.93f,1.05f,0.92f,1.01f,1.31f,0.88f,0.81f,0.86f,0.72f,0.75f,0.74f,0.79f,0.79f,0.86f,0.85f,0.71f,0.73f,0.75f,0.82f,0.77f,0.83f,0.78f,0.85f,0.88f,0.81f,0.88f,0.97f,0.90f,1.18f,1.00f,0.93f,0.86f,0.92f,0.94f,1.14f,0.99f,1.24f,1.03f,1.33f,1.39f,1.11f,0.79f,0.77f,0.84f,0.79f,0.77f,0.84f,0.83f,0.90f,0.98f,0.91f,0.85f,0.92f,0.91f,1.02f,1.26f,1.00f,1.23f,1.19f,0.99f,1.50f,1.84f,1.71f,1.64f,1.38f,1.46f,1.51f,1.76f,1.59f,0.84f,0.88f,0.80f,0.94f,0.79f,0.86f,0.82f,0.77f,0.76f,0.74f,0.74f,0.71f,0.73f,0.70f,0.72f,0.82f,0.77f,0.85f,0.74f,0.70f,0.73f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}
- };
-
-}
diff --git a/src/jake2/render/fastjogl/Base.java b/src/jake2/render/fastjogl/Base.java
deleted file mode 100644
index c5cc690..0000000
--- a/src/jake2/render/fastjogl/Base.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Base.java
- * Copyright (C) 2003
- *
- * $Id: Base.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import net.java.games.jogl.GL;
-
-/**
- * Base
- *
- * @author cwei
- */
-public class Base {
-
- 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;
-
-// ===================================================================
-
- // enum rserr_t
- static final int rserr_ok = 0;
- static final int rserr_invalid_fullscreen = 1;
- static final int rserr_invalid_mode = 2;
- static final int rserr_unknown = 3;
-
-//
-// #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 );
-//
-
-}
diff --git a/src/jake2/render/fastjogl/Draw.java b/src/jake2/render/fastjogl/Draw.java
deleted file mode 100644
index fcb48b6..0000000
--- a/src/jake2/render/fastjogl/Draw.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Draw.java
- * Copyright (C) 2003
- *
- * $Id: Draw.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.render.image_t;
-
-import java.awt.Dimension;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.util.GLUT;
-
-/**
- * Draw
- * (gl_draw.c)
- *
- * @author cwei
- */
-public abstract class Draw extends Image {
-
- /*
- ===============
- Draw_InitLocal
- ===============
- */
- void Draw_InitLocal() {
- // load console characters (don't bilerp characters)
- draw_chars = GL_FindImage("pics/conchars.pcx", it_pic);
- GL_Bind(draw_chars.texnum);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
- }
-
- /*
- ================
- Draw_Char
-
- Draws one 8*8 graphics character with 0 being transparent.
- It can be clipped to the top of the screen to allow the console to be
- smoothly scrolled off.
- ================
- */
- protected void Draw_Char(int x, int y, int num) {
-
- num &= 255;
-
- if ( (num&127) == 32 ) return; // space
-
- if (y <= -8) return; // totally off screen
-
- int row = num>>4;
- int col = num&15;
-
- float frow = row*0.0625f;
- float fcol = col*0.0625f;
- float size = 0.0625f;
-
- GL_Bind(draw_chars.texnum);
-
- gl.glBegin (GL.GL_QUADS);
- gl.glTexCoord2f (fcol, frow);
- gl.glVertex2f (x, y);
- gl.glTexCoord2f (fcol + size, frow);
- gl.glVertex2f (x+8, y);
- gl.glTexCoord2f (fcol + size, frow + size);
- gl.glVertex2f (x+8, y+8);
- gl.glTexCoord2f (fcol, frow + size);
- gl.glVertex2f (x, y+8);
- gl.glEnd ();
- }
-
-
- /*
- =============
- Draw_FindPic
- =============
- */
- protected image_t Draw_FindPic(String name) {
- image_t image = null;
- String fullname;
-
- if (!name.startsWith("/") && !name.startsWith("\\"))
- {
- fullname = "pics/" + name + ".pcx";
- image = GL_FindImage(fullname, it_pic);
- } else {
- image = GL_FindImage(name.substring(1), it_pic);
- }
- return image;
- }
-
-
- /*
- =============
- Draw_GetPicSize
- =============
- */
- protected void Draw_GetPicSize(Dimension dim, String pic) {
-
- image_t image = Draw_FindPic(pic);
- dim.width = (image != null) ? image.width : -1;
- dim.height = (image != null) ? image.height : -1;
- }
-
- /*
- =============
- Draw_StretchPic
- =============
- */
- protected void Draw_StretchPic (int x, int y, int w, int h, String pic) {
-
- image_t image;
-
- image = Draw_FindPic(pic);
- if (image == null)
- {
- ri.Con_Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n');
- return;
- }
-
- if (scrap_dirty)
- Scrap_Upload();
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0) ) && !image.has_alpha)
- gl.glDisable(GL.GL_ALPHA_TEST);
-
- GL_Bind(image.texnum);
- gl.glBegin (GL.GL_QUADS);
- gl.glTexCoord2f (image.sl, image.tl);
- gl.glVertex2f (x, y);
- gl.glTexCoord2f (image.sh, image.tl);
- gl.glVertex2f (x+w, y);
- gl.glTexCoord2f (image.sh, image.th);
- gl.glVertex2f (x+w, y+h);
- gl.glTexCoord2f (image.sl, image.th);
- gl.glVertex2f (x, y+h);
- gl.glEnd ();
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) !=0 ) ) && !image.has_alpha)
- gl.glEnable(GL.GL_ALPHA_TEST);
- }
-
-
- /*
- =============
- Draw_Pic
- =============
- */
- protected void Draw_Pic(int x, int y, String pic)
- {
- image_t image;
-
- image = Draw_FindPic(pic);
- if (image == null)
- {
- ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n');
- return;
- }
- if (scrap_dirty)
- Scrap_Upload();
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha)
- gl.glDisable (GL.GL_ALPHA_TEST);
-
- GL_Bind(image.texnum);
-
- gl.glBegin (GL.GL_QUADS);
- gl.glTexCoord2f (image.sl, image.tl);
- gl.glVertex2f (x, y);
- gl.glTexCoord2f (image.sh, image.tl);
- gl.glVertex2f (x+image.width, y);
- gl.glTexCoord2f (image.sh, image.th);
- gl.glVertex2f (x+image.width, y+image.height);
- gl.glTexCoord2f (image.sl, image.th);
- gl.glVertex2f (x, y+image.height);
- gl.glEnd ();
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha)
- gl.glEnable (GL.GL_ALPHA_TEST);
- }
-
- /*
- =============
- Draw_TileClear
-
- This repeats a 64*64 tile graphic to fill the screen around a sized down
- refresh window.
- =============
- */
- protected void Draw_TileClear(int x, int y, int w, int h, String pic) {
- image_t image;
-
- image = Draw_FindPic(pic);
- if (image == null)
- {
- ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
- return;
- }
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha)
- gl.glDisable(GL.GL_ALPHA_TEST);
-
- GL_Bind(image.texnum);
- gl.glBegin (GL.GL_QUADS);
- gl.glTexCoord2f(x/64.0f, y/64.0f);
- gl.glVertex2f (x, y);
- gl.glTexCoord2f( (x+w)/64.0f, y/64.0f);
- gl.glVertex2f(x+w, y);
- gl.glTexCoord2f( (x+w)/64.0f, (y+h)/64.0f);
- gl.glVertex2f(x+w, y+h);
- gl.glTexCoord2f( x/64.0f, (y+h)/64.0f );
- gl.glVertex2f (x, y+h);
- gl.glEnd ();
-
- if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha)
- gl.glEnable(GL.GL_ALPHA_TEST);
- }
-
-
- /*
- =============
- Draw_Fill
-
- Fills a box of pixels with a single color
- =============
- */
- protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) {
-
- if ( colorIndex > 255)
- ri.Sys_Error(Defines.ERR_FATAL, "Draw_Fill: bad color");
-
- gl.glDisable(GL.GL_TEXTURE_2D);
-
- int color = d_8to24table[colorIndex];
-
- gl.glColor3ub(
- (byte)((color >> 0) & 0xff), // r
- (byte)((color >> 8) & 0xff), // g
- (byte)((color >> 16) & 0xff) // b
- );
-
- gl.glBegin (GL.GL_QUADS);
-
- gl.glVertex2f(x,y);
- gl.glVertex2f(x+w, y);
- gl.glVertex2f(x+w, y+h);
- gl.glVertex2f(x, y+h);
-
- gl.glEnd();
- gl.glColor3f(1,1,1);
- gl.glEnable(GL.GL_TEXTURE_2D);
- }
-
-// =============================================================================
-
- /*
- ================
- Draw_FadeScreen
- ================
- */
- protected void Draw_FadeScreen() {
- gl.glEnable(GL.GL_BLEND);
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glColor4f(0, 0, 0, 0.8f);
- gl.glBegin(GL.GL_QUADS);
-
- gl.glVertex2f(0,0);
- gl.glVertex2f(vid.width, 0);
- gl.glVertex2f(vid.width, vid.height);
- gl.glVertex2f(0, vid.height);
-
- gl.glEnd();
- gl.glColor4f(1,1,1,1);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glDisable(GL.GL_BLEND);
- }
-
-// ====================================================================
-
-
- /*
- =============
- Draw_StretchRaw
- =============
- */
- protected void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte[] data)
- {
- int i, j, trows;
- int sourceIndex;
- int frac, fracstep;
- float hscale;
- int row;
- float t;
-
- GL_Bind(0);
-
- if (rows<=256)
- {
- hscale = 1;
- trows = rows;
- }
- else
- {
- hscale = rows/256.0f;
- trows = 256;
- }
- t = rows*hscale / 256;
-
- if ( !qglColorTableEXT )
- {
- int[] image32 = new int[256*256];
- int destIndex = 0;
-
- for (i=0 ; i<trows ; i++)
- {
- row = (int)(i*hscale);
- if (row > rows)
- break;
- sourceIndex = cols*row;
- destIndex = i*256;
- fracstep = cols*0x10000/256;
- frac = fracstep >> 1;
- for (j=0 ; j<256 ; j++)
- {
- image32[destIndex + j] = r_rawpalette[data[sourceIndex + (frac>>16)] & 0xff];
- frac += fracstep;
- }
- }
- gl.glTexImage2D (GL.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, image32);
- }
- else
- {
- byte[] image8 = new byte[256*256];
- int destIndex = 0;;
-
- for (i=0 ; i<trows ; i++)
- {
- row = (int)(i*hscale);
- if (row > rows)
- break;
- sourceIndex = cols*row;
- destIndex = i*256;
- fracstep = cols*0x10000/256;
- frac = fracstep >> 1;
- for (j=0 ; j<256 ; j++)
- {
- image8[destIndex + j] = data[sourceIndex + (frac>>16)];
- frac += fracstep;
- }
- }
-
- gl.glTexImage2D( GL.GL_TEXTURE_2D,
- 0,
- GL_COLOR_INDEX8_EXT,
- 256, 256,
- 0,
- GL.GL_COLOR_INDEX,
- GL.GL_UNSIGNED_BYTE,
- image8 );
- }
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
-
- if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) )
- gl.glDisable (GL.GL_ALPHA_TEST);
-
- gl.glBegin (GL.GL_QUADS);
- gl.glTexCoord2f (0, 0);
- gl.glVertex2f (x, y);
- gl.glTexCoord2f (1, 0);
- gl.glVertex2f (x+w, y);
- gl.glTexCoord2f (1, t);
- gl.glVertex2f (x+w, y+h);
- gl.glTexCoord2f (0, t);
- gl.glVertex2f (x, y+h);
- gl.glEnd ();
-
- if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) )
- gl.glEnable (GL.GL_ALPHA_TEST);
- }
-
-}
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java
deleted file mode 100644
index de364c3..0000000
--- a/src/jake2/render/fastjogl/Image.java
+++ /dev/null
@@ -1,1673 +0,0 @@
-/*
- * Image.java
- * Copyright (C) 2003
- *
- * $Id: Image.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.client.particle_t;
-import jake2.game.cvar_t;
-import jake2.qcommon.longjmpException;
-import jake2.qcommon.qfiles;
-import jake2.render.image_t;
-import jake2.util.Lib;
-import jake2.util.Vargs;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import java.nio.*;
-import java.util.Arrays;
-
-import net.java.games.jogl.GL;
-
-/**
- * Image
- *
- * @author cwei
- */
-public abstract class Image extends Main {
-
- image_t draw_chars;
-
- image_t[] gltextures = new image_t[MAX_GLTEXTURES];
- //Map gltextures = new Hashtable(MAX_GLTEXTURES); // image_t
- int numgltextures;
- int base_textureid; // gltextures[i] = base_textureid+i
-
- byte[] intensitytable = new byte[256];
- byte[] gammatable = new byte[256];
-
- cvar_t intensity;
-
- //
- // qboolean GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean is_sky );
- // qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap);
- //
-
- int gl_solid_format = 3;
- int gl_alpha_format = 4;
-
- int gl_tex_solid_format = 3;
- int gl_tex_alpha_format = 4;
-
- int gl_filter_min = GL.GL_LINEAR_MIPMAP_NEAREST;
- int gl_filter_max = GL.GL_LINEAR;
-
- Image() {
- // init the texture cache
- for (int i = 0; i < gltextures.length; i++)
- {
- gltextures[i] = new image_t(i);
- }
- numgltextures = 0;
- }
-
- void GL_SetTexturePalette(int[] palette) {
-
- assert(palette != null && palette.length == 256) : "int palette[256] bug";
-
- int i;
- byte[] temptable = new byte[768];
-
- if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) {
- for (i = 0; i < 256; i++) {
- temptable[i * 3 + 0] = (byte) ((palette[i] >> 0) & 0xff);
- temptable[i * 3 + 1] = (byte) ((palette[i] >> 8) & 0xff);
- temptable[i * 3 + 2] = (byte) ((palette[i] >> 16) & 0xff);
- }
-
- gl.glColorTableEXT(GL.GL_SHARED_TEXTURE_PALETTE_EXT, GL.GL_RGB, 256, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, temptable);
- }
- }
-
- void GL_EnableMultitexture(boolean enable) {
- if (enable) {
- GL_SelectTexture(GL_TEXTURE1);
- gl.glEnable(GL.GL_TEXTURE_2D);
- GL_TexEnv(GL.GL_REPLACE);
- }
- else {
- GL_SelectTexture(GL_TEXTURE1);
- gl.glDisable(GL.GL_TEXTURE_2D);
- GL_TexEnv(GL.GL_REPLACE);
- }
- GL_SelectTexture(GL_TEXTURE0);
- GL_TexEnv(GL.GL_REPLACE);
- }
-
- void GL_SelectTexture(int texture /* GLenum */) {
- int tmu;
-
- tmu = (texture == GL_TEXTURE0) ? 0 : 1;
-
- if (tmu == gl_state.currenttmu) {
- return;
- }
-
- gl_state.currenttmu = tmu;
-
- gl.glActiveTextureARB(texture);
- gl.glClientActiveTextureARB(texture);
- }
-
- int[] lastmodes = { -1, -1 };
-
- void GL_TexEnv(int mode /* GLenum */
- ) {
-
- if (mode != lastmodes[gl_state.currenttmu]) {
- gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, mode);
- lastmodes[gl_state.currenttmu] = mode;
- }
- }
-
- void GL_Bind(int texnum) {
-
- if ((gl_nobind.value != 0) && (draw_chars != null)) {
- // performance evaluation option
- texnum = draw_chars.texnum;
- }
- if (gl_state.currenttextures[gl_state.currenttmu] == texnum)
- return;
-
- gl_state.currenttextures[gl_state.currenttmu] = texnum;
- gl.glBindTexture(GL.GL_TEXTURE_2D, texnum);
- }
-
- void GL_MBind(int target /* GLenum */, int texnum) {
- GL_SelectTexture(target);
- if (target == GL_TEXTURE0) {
- if (gl_state.currenttextures[0] == texnum)
- return;
- }
- else {
- if (gl_state.currenttextures[1] == texnum)
- return;
- }
- GL_Bind(texnum);
- }
-
- // glmode_t
- static class glmode_t {
- String name;
- int minimize, maximize;
-
- glmode_t(String name, int minimize, int maximze) {
- this.name = name;
- this.minimize = minimize;
- this.maximize = maximze;
- }
- }
-
- static final glmode_t modes[] =
- {
- new glmode_t("GL_NEAREST", GL.GL_NEAREST, GL.GL_NEAREST),
- new glmode_t("GL_LINEAR", GL.GL_LINEAR, GL.GL_LINEAR),
- new glmode_t("GL_NEAREST_MIPMAP_NEAREST", GL.GL_NEAREST_MIPMAP_NEAREST, GL.GL_NEAREST),
- new glmode_t("GL_LINEAR_MIPMAP_NEAREST", GL.GL_LINEAR_MIPMAP_NEAREST, GL.GL_LINEAR),
- new glmode_t("GL_NEAREST_MIPMAP_LINEAR", GL.GL_NEAREST_MIPMAP_LINEAR, GL.GL_NEAREST),
- new glmode_t("GL_LINEAR_MIPMAP_LINEAR", GL.GL_LINEAR_MIPMAP_LINEAR, GL.GL_LINEAR)};
-
- static final int NUM_GL_MODES = modes.length;
-
- // gltmode_t
- static class gltmode_t {
- String name;
- int mode;
-
- gltmode_t(String name, int mode) {
- this.name = name;
- this.mode = mode;
- }
- }
-
- static final gltmode_t[] gl_alpha_modes =
- {
- new gltmode_t("default", 4),
- new gltmode_t("GL_RGBA", GL.GL_RGBA),
- new gltmode_t("GL_RGBA8", GL.GL_RGBA8),
- new gltmode_t("GL_RGB5_A1", GL.GL_RGB5_A1),
- new gltmode_t("GL_RGBA4", GL.GL_RGBA4),
- new gltmode_t("GL_RGBA2", GL.GL_RGBA2),
- };
-
- static final int NUM_GL_ALPHA_MODES = gl_alpha_modes.length;
-
- static final gltmode_t[] gl_solid_modes =
- {
- new gltmode_t("default", 3),
- new gltmode_t("GL_RGB", GL.GL_RGB),
- new gltmode_t("GL_RGB8", GL.GL_RGB8),
- new gltmode_t("GL_RGB5", GL.GL_RGB5),
- new gltmode_t("GL_RGB4", GL.GL_RGB4),
- new gltmode_t("GL_R3_G3_B2", GL.GL_R3_G3_B2),
- // #ifdef GL_RGB2_EXT
- new gltmode_t("GL_RGB2", GL.GL_RGB2_EXT)
- // #endif
- };
-
- static final int NUM_GL_SOLID_MODES = gl_solid_modes.length;
-
- /*
- ===============
- GL_TextureMode
- ===============
- */
- void GL_TextureMode(String string) {
-
- int i;
- for (i = 0; i < NUM_GL_MODES; i++) {
- if (modes[i].name.equalsIgnoreCase(string))
- break;
- }
-
- if (i == NUM_GL_MODES) {
- ri.Con_Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n");
- return;
- }
-
- gl_filter_min = modes[i].minimize;
- gl_filter_max = modes[i].maximize;
-
- image_t glt;
- // change all the existing mipmap texture objects
- for (i = 0; i < numgltextures; i++) {
- glt = gltextures[i];
-
- if (glt.type != it_pic && glt.type != it_sky) {
- GL_Bind(glt.texnum);
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_min);
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- }
- }
-
- /*
- ===============
- GL_TextureAlphaMode
- ===============
- */
- void GL_TextureAlphaMode(String string) {
-
- int i;
- for (i = 0; i < NUM_GL_ALPHA_MODES; i++) {
- if (gl_alpha_modes[i].name.equalsIgnoreCase(string))
- break;
- }
-
- if (i == NUM_GL_ALPHA_MODES) {
- ri.Con_Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n");
- return;
- }
-
- gl_tex_alpha_format = gl_alpha_modes[i].mode;
- }
-
- /*
- ===============
- GL_TextureSolidMode
- ===============
- */
- void GL_TextureSolidMode(String string) {
- int i;
- for (i = 0; i < NUM_GL_SOLID_MODES; i++) {
- if (gl_solid_modes[i].name.equalsIgnoreCase(string))
- break;
- }
-
- if (i == NUM_GL_SOLID_MODES) {
- ri.Con_Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n");
- return;
- }
-
- gl_tex_solid_format = gl_solid_modes[i].mode;
- }
-
- /*
- ===============
- GL_ImageList_f
- ===============
- */
- void GL_ImageList_f() {
-
- image_t image;
- int texels;
- final String[] palstrings = { "RGB", "PAL" };
-
- ri.Con_Printf(Defines.PRINT_ALL, "------------------\n");
- texels = 0;
-
- for (int i = 0; i < numgltextures; i++) {
- image = gltextures[i];
- if (image.texnum <= 0)
- continue;
-
- texels += image.upload_width * image.upload_height;
- switch (image.type) {
- case it_skin :
- ri.Con_Printf(Defines.PRINT_ALL, "M");
- break;
- case it_sprite :
- ri.Con_Printf(Defines.PRINT_ALL, "S");
- break;
- case it_wall :
- ri.Con_Printf(Defines.PRINT_ALL, "W");
- break;
- case it_pic :
- ri.Con_Printf(Defines.PRINT_ALL, "P");
- break;
- default :
- ri.Con_Printf(Defines.PRINT_ALL, " ");
- break;
- }
-
- ri.Con_Printf(
- Defines.PRINT_ALL,
- " %3i %3i %s: %s\n",
- new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add(
- image.name));
- }
- ri.Con_Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n');
- }
-
- /*
- =============================================================================
-
- scrap allocation
-
- Allocate all the little status bar objects into a single texture
- to crutch up inefficient hardware / drivers
-
- =============================================================================
- */
-
- static final int MAX_SCRAPS = 1;
- static final int BLOCK_WIDTH = 256;
- static final int BLOCK_HEIGHT = 256;
-
- int[][] scrap_allocated = new int[MAX_SCRAPS][BLOCK_WIDTH];
- byte[][] scrap_texels = new byte[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT];
- boolean scrap_dirty;
-
- static class pos_t {
- int x, y;
-
- pos_t(int x, int y) {
- this.x = x;
- this.y = y;
- }
- }
-
- // returns a texture number and the position inside it
- int Scrap_AllocBlock(int w, int h, pos_t pos) {
- int i, j;
- int best, best2;
- int texnum;
-
- for (texnum = 0; texnum < MAX_SCRAPS; texnum++) {
- best = BLOCK_HEIGHT;
-
- for (i = 0; i < BLOCK_WIDTH - w; i++) {
- best2 = 0;
-
- for (j = 0; j < w; j++) {
- if (scrap_allocated[texnum][i + j] >= best)
- break;
- if (scrap_allocated[texnum][i + j] > best2)
- best2 = scrap_allocated[texnum][i + j];
- }
- if (j == w) { // this is a valid spot
- pos.x = i;
- pos.y = best = best2;
- }
- }
-
- if (best + h > BLOCK_HEIGHT)
- continue;
-
- for (i = 0; i < w; i++)
- scrap_allocated[texnum][pos.x + i] = best + h;
-
- return texnum;
- }
-
- return -1;
- // Sys_Error ("Scrap_AllocBlock: full");
- }
-
- int scrap_uploads = 0;
-
- void Scrap_Upload() {
- scrap_uploads++;
- GL_Bind(TEXNUM_SCRAPS);
- GL_Upload8(scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, false);
- scrap_dirty = false;
- }
-
- /*
- =================================================================
-
- PCX LOADING
-
- =================================================================
- */
-
- /*
- ==============
- LoadPCX
- ==============
- */
- byte[] LoadPCX(String filename, byte[][] palette, Dimension dim) {
- qfiles.pcx_t pcx;
-
- //
- // load the file
- //
- byte[] raw = ri.FS_LoadFile(filename);
-
- if (raw == null) {
- ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n');
- return null;
- }
-
- //
- // parse the PCX file
- //
- pcx = new qfiles.pcx_t(raw);
-
- if (pcx.manufacturer != 0x0a
- || pcx.version != 5
- || pcx.encoding != 1
- || pcx.bits_per_pixel != 8
- || pcx.xmax >= 640
- || pcx.ymax >= 480) {
-
- ri.Con_Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n');
- return null;
- }
-
- int width = pcx.xmax - pcx.xmin + 1;
- int height = pcx.ymax - pcx.ymin + 1;
-
- byte[] pix = new byte[width * height];
-
- if (palette != null) {
- palette[0] = new byte[768];
- System.arraycopy(raw, raw.length - 768, palette[0], 0, 768);
- }
-
- if (dim != null) {
- dim.width = width;
- dim.height = height;
- }
-
- //
- // decode pcx
- //
- int count = 0;
- byte dataByte = 0;
- int runLength = 0;
- int x, y;
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width;) {
-
- dataByte = pcx.data.get();
-
- if ((dataByte & 0xC0) == 0xC0) {
- runLength = dataByte & 0x3F;
- dataByte = pcx.data.get();
- // write runLength pixel
- while (runLength-- > 0) {
- pix[count++] = dataByte;
- x++;
- }
- }
- else {
- // write one pixel
- pix[count++] = dataByte;
- x++;
- }
- }
- }
- return pix;
- }
-
- // /*
- // =========================================================
- //
- // TARGA LOADING
- //
- // =========================================================
- // */
- /*
- =============
- LoadTGA
- =============
- */
- byte[] LoadTGA(String name, Dimension dim) {
- int columns, rows, numPixels;
- int pixbuf; // index into pic
- int row, column;
- byte[] raw;
- ByteBuffer buf_p;
- int length;
- qfiles.tga_t targa_header;
- byte[] pic = null;
-
- //
- // load the file
- //
- raw = ri.FS_LoadFile (name);
-
- if (raw == null)
- {
- ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n');
- return null;
- }
-
- targa_header = new qfiles.tga_t(raw);
-
- if (targa_header.image_type != 2 && targa_header.image_type != 10)
- ri.Sys_Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
-
- if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
- ri.Sys_Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
-
- columns = targa_header.width;
- rows = targa_header.height;
- numPixels = columns * rows;
-
- if (dim != null) {
- dim.width = columns;
- dim.height = rows;
- }
-
- pic = new byte[numPixels * 4]; // targa_rgba;
-
- if (targa_header.id_length != 0)
- targa_header.data.position(targa_header.id_length); // skip TARGA image comment
-
- buf_p = targa_header.data;
-
- byte red,green,blue,alphabyte;
- red = green = blue = alphabyte = 0;
- int packetHeader, packetSize, j;
-
- if (targa_header.image_type==2) { // Uncompressed, RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
-
- for(column=0; column<columns; column++) {
- switch (targa_header.pixel_size) {
- case 24:
-
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- }
- }
- }
- else if (targa_header.image_type==10) { // Runlength encoded RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
- try {
-
- for(column=0; column<columns; ) {
-
- packetHeader= buf_p.get() & 0xFF;
- packetSize = 1 + (packetHeader & 0x7f);
-
- if ((packetHeader & 0x80) != 0) { // run-length packet
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- break;
- }
-
- for(j=0;j<packetSize;j++) {
- pic[pixbuf++]=red;
- pic[pixbuf++]=green;
- pic[pixbuf++]=blue;
- pic[pixbuf++]=alphabyte;
- column++;
- if (column==columns) { // run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- else { // non run-length packet
- for(j=0;j<packetSize;j++) {
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- column++;
- if (column==columns) { // pixel packet run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- }
- } catch (longjmpException e){
- // label breakOut:
- }
- }
- }
- return pic;
- }
-
- /*
- ====================================================================
-
- IMAGE FLOOD FILLING
-
- ====================================================================
- */
-
- /*
- =================
- Mod_FloodFillSkin
-
- Fill background pixels so mipmapping doesn't have haloes
- =================
- */
-
- static class floodfill_t {
- short x, y;
- }
-
- // must be a power of 2
- static final int FLOODFILL_FIFO_SIZE = 0x1000;
- static final int FLOODFILL_FIFO_MASK = FLOODFILL_FIFO_SIZE - 1;
- //
- // #define FLOODFILL_STEP( off, dx, dy ) \
- // { \
- // if (pos[off] == fillcolor) \
- // { \
- // pos[off] = 255; \
- // fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \
- // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \
- // } \
- // else if (pos[off] != 255) fdc = pos[off]; \
- // }
-
- // void FLOODFILL_STEP( int off, int dx, int dy )
- // {
- // if (pos[off] == fillcolor)
- // {
- // pos[off] = 255;
- // fifo[inpt].x = x + dx; fifo[inpt].y = y + dy;
- // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
- // }
- // else if (pos[off] != 255) fdc = pos[off];
- // }
-
- // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight)
- void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) {
- // byte fillcolor = *skin; // assume this is the pixel to fill
- int fillcolor = skin[0] & 0xff;
- floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE];
- int inpt = 0, outpt = 0;
- int filledcolor = -1;
- int i;
-
- for (int j = 0; j < fifo.length; j++) {
- fifo[j] = new floodfill_t();
- }
-
- if (filledcolor == -1) {
- filledcolor = 0;
- // attempt to find opaque black
- for (i = 0; i < 256; ++i)
- // TODO check this
- if (d_8to24table[i] == 0xFF000000) { // alpha 1.0
- //if (d_8to24table[i] == (255 << 0)) // alpha 1.0
- filledcolor = i;
- break;
- }
- }
-
- // can't fill to filled color or to transparent color (used as visited marker)
- if ((fillcolor == filledcolor) || (fillcolor == 255)) {
- return;
- }
-
- fifo[inpt].x = 0;
- fifo[inpt].y = 0;
- inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
-
- while (outpt != inpt) {
- int x = fifo[outpt].x;
- int y = fifo[outpt].y;
- int fdc = filledcolor;
- // byte *pos = &skin[x + skinwidth * y];
- int pos = x + skinwidth * y;
- //
- outpt = (outpt + 1) & FLOODFILL_FIFO_MASK;
-
- int off, dx, dy;
-
- if (x > 0) {
- // FLOODFILL_STEP( -1, -1, 0 );
- off = -1;
- dx = -1;
- dy = 0;
- if (skin[pos + off] == (byte) fillcolor) {
- skin[pos + off] = (byte) 255;
- fifo[inpt].x = (short) (x + dx);
- fifo[inpt].y = (short) (y + dy);
- inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
- }
- else if (skin[pos + off] != (byte) 255)
- fdc = skin[pos + off] & 0xff;
- }
-
- if (x < skinwidth - 1) {
- // FLOODFILL_STEP( 1, 1, 0 );
- off = 1;
- dx = 1;
- dy = 0;
- if (skin[pos + off] == (byte) fillcolor) {
- skin[pos + off] = (byte) 255;
- fifo[inpt].x = (short) (x + dx);
- fifo[inpt].y = (short) (y + dy);
- inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
- }
- else if (skin[pos + off] != (byte) 255)
- fdc = skin[pos + off] & 0xff;
- }
-
- if (y > 0) {
- // FLOODFILL_STEP( -skinwidth, 0, -1 );
- off = -skinwidth;
- dx = 0;
- dy = -1;
- if (skin[pos + off] == (byte) fillcolor) {
- skin[pos + off] = (byte) 255;
- fifo[inpt].x = (short) (x + dx);
- fifo[inpt].y = (short) (y + dy);
- inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
- }
- else if (skin[pos + off] != (byte) 255)
- fdc = skin[pos + off] & 0xff;
- }
-
- if (y < skinheight - 1) {
- // FLOODFILL_STEP( skinwidth, 0, 1 );
- off = skinwidth;
- dx = 0;
- dy = 1;
- if (skin[pos + off] == (byte) fillcolor) {
- skin[pos + off] = (byte) 255;
- fifo[inpt].x = (short) (x + dx);
- fifo[inpt].y = (short) (y + dy);
- inpt = (inpt + 1) & FLOODFILL_FIFO_MASK;
- }
- else if (skin[pos + off] != (byte) 255)
- fdc = skin[pos + off] & 0xff;
-
- }
-
- skin[x + skinwidth * y] = (byte) fdc;
- }
- }
-
- // =======================================================
-
- /*
- ================
- GL_ResampleTexture
- ================
- */
- // cwei :-)
- void GL_ResampleTexture(int[] in, int inwidth, int inheight, int[] out, int outwidth, int outheight) {
- // int i, j;
- // unsigned *inrow, *inrow2;
- // int frac, fracstep;
- // int[] p1 = new int[1024];
- // int[] p2 = new int[1024];
- //
-
- // *** this source do the same ***
- BufferedImage image = new BufferedImage(inwidth, inheight, BufferedImage.TYPE_INT_ARGB);
-
- image.setRGB(0, 0, inwidth, inheight, in, 0, inwidth);
-
- AffineTransformOp op =
- new AffineTransformOp(
- AffineTransform.getScaleInstance(outwidth * 1.0 / inwidth, outheight * 1.0 / inheight),
- AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
- BufferedImage tmp = op.filter(image, null);
-
- tmp.getRGB(0, 0, outwidth, outheight, out, 0, outwidth);
-
- // *** end ***
-
- // byte *pix1, *pix2, *pix3, *pix4;
- //
- // fracstep = inwidth*0x10000/outwidth;
- //
- // frac = fracstep>>2;
- // for (i=0 ; i<outwidth ; i++)
- // {
- // p1[i] = 4*(frac>>16);
- // frac += fracstep;
- // }
- // frac = 3*(fracstep>>2);
- // for (i=0 ; i<outwidth ; i++)
- // {
- // p2[i] = 4*(frac>>16);
- // frac += fracstep;
- // }
- //
- // for (i=0 ; i<outheight ; i++, out += outwidth)
- // {
- // inrow = in + inwidth*(int)((i+0.25)*inheight/outheight);
- // inrow2 = in + inwidth*(int)((i+0.75)*inheight/outheight);
- // frac = fracstep >> 1;
- // for (j=0 ; j<outwidth ; j++)
- // {
- // pix1 = (byte *)inrow + p1[j];
- // pix2 = (byte *)inrow + p2[j];
- // pix3 = (byte *)inrow2 + p1[j];
- // pix4 = (byte *)inrow2 + p2[j];
- // ((byte *)(out+j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0])>>2;
- // ((byte *)(out+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2;
- // ((byte *)(out+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2;
- // ((byte *)(out+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2;
- // }
- // }
- }
-
- /*
- ================
- GL_LightScaleTexture
-
- Scale up the pixel values in a texture to increase the
- lighting range
- ================
- */
- void GL_LightScaleTexture(int[] in, int inwidth, int inheight, boolean only_gamma) {
- if (only_gamma) {
- int i, c;
- int r, g, b, color;
-
- c = inwidth * inheight;
- for (i = 0; i < c; i++) {
- color = in[i];
- r = (color >> 0) & 0xFF;
- g = (color >> 8) & 0xFF;
- b = (color >> 16) & 0xFF;
-
- r = gammatable[r] & 0xFF;
- g = gammatable[g] & 0xFF;
- b = gammatable[b] & 0xFF;
-
- in[i] = (r << 0) | (g << 8) | (b << 16) | (color & 0xFF000000);
- }
- }
- else {
- int i, c;
- int r, g, b, color;
-
- c = inwidth * inheight;
- for (i = 0; i < c; i++) {
- color = in[i];
- r = (color >> 0) & 0xFF;
- g = (color >> 8) & 0xFF;
- b = (color >> 16) & 0xFF;
-
- r = gammatable[intensitytable[r] & 0xFF] & 0xFF;
- g = gammatable[intensitytable[g] & 0xFF] & 0xFF;
- b = gammatable[intensitytable[b] & 0xFF] & 0xFF;
-
- in[i] = (r << 0) | (g << 8) | (b << 16) | (color & 0xFF000000);
- }
-
- }
- }
-
- /*
- ================
- GL_MipMap
-
- Operates in place, quartering the size of the texture
- ================
- */
- void GL_MipMap(int[] in, int width, int height) {
- int i, j;
- int[] out;
-
- out = in;
-
- int inIndex = 0;
- int outIndex = 0;
-
- int r, g, b, a;
- int p1, p2, p3, p4;
-
- for (i = 0; i < height; i += 2, inIndex += width) {
- for (j = 0; j < width; j += 2, outIndex += 1, inIndex += 2) {
-
- p1 = in[inIndex + 0];
- p2 = in[inIndex + 1];
- p3 = in[inIndex + width + 0];
- p4 = in[inIndex + width + 1];
-
- r = (((p1 >> 0) & 0xFF) + ((p2 >> 0) & 0xFF) + ((p3 >> 0) & 0xFF) + ((p4 >> 0) & 0xFF)) >> 2;
- g = (((p1 >> 8) & 0xFF) + ((p2 >> 8) & 0xFF) + ((p3 >> 8) & 0xFF) + ((p4 >> 8) & 0xFF)) >> 2;
- b = (((p1 >> 16) & 0xFF) + ((p2 >> 16) & 0xFF) + ((p3 >> 16) & 0xFF) + ((p4 >> 16) & 0xFF)) >> 2;
- a = (((p1 >> 24) & 0xFF) + ((p2 >> 24) & 0xFF) + ((p3 >> 24) & 0xFF) + ((p4 >> 24) & 0xFF)) >> 2;
-
- out[outIndex] = (r << 0) | (g << 8) | (b << 16) | (a << 24);
- }
- }
- }
-
- /*
- ===============
- GL_Upload32
-
- Returns has_alpha
- ===============
- */
- void GL_BuildPalettedTexture(byte[] paletted_texture, int[] scaled, int scaled_width, int scaled_height) {
-
- int r, g, b, c;
- int size = scaled_width * scaled_height;
-
- for (int i = 0; i < size; i++) {
-
- r = (scaled[i] >> 3) & 31;
- g = (scaled[i] >> 10) & 63;
- b = (scaled[i] >> 19) & 31;
-
- c = r | (g << 5) | (b << 11);
-
- paletted_texture[i] = gl_state.d_16to8table[c];
- }
- }
-
- int upload_width, upload_height;
- boolean uploaded_paletted;
-
- /*
- ===============
- GL_Upload32
-
- Returns has_alpha
- ===============
- */
- int[] scaled = new int[256 * 256];
- byte[] paletted_texture = new byte[256 * 256];
- IntBuffer tex = Lib.newIntBuffer(512 * 256, ByteOrder.LITTLE_ENDIAN);
-
- boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) {
- int samples;
- int scaled_width, scaled_height;
- int i, c;
- int comp;
-
- Arrays.fill(scaled, 0);
- Arrays.fill(paletted_texture, (byte)0);
-
- uploaded_paletted = false;
-
- for (scaled_width = 1; scaled_width < width; scaled_width <<= 1);
- if (gl_round_down.value > 0.0f && scaled_width > width && mipmap)
- scaled_width >>= 1;
- for (scaled_height = 1; scaled_height < height; scaled_height <<= 1);
- if (gl_round_down.value > 0.0f && scaled_height > height && mipmap)
- scaled_height >>= 1;
-
- // let people sample down the world textures for speed
- if (mipmap) {
- scaled_width >>= (int) gl_picmip.value;
- scaled_height >>= (int) gl_picmip.value;
- }
-
- // don't ever bother with >256 textures
- if (scaled_width > 256)
- scaled_width = 256;
- if (scaled_height > 256)
- scaled_height = 256;
-
- if (scaled_width < 1)
- scaled_width = 1;
- if (scaled_height < 1)
- scaled_height = 1;
-
- upload_width = scaled_width;
- upload_height = scaled_height;
-
- if (scaled_width * scaled_height > 256 * 256)
- ri.Sys_Error(Defines.ERR_DROP, "GL_Upload32: too big");
-
- // scan the texture for any non-255 alpha
- c = width * height;
- samples = gl_solid_format;
-
- for (i = 0; i < c; i++) {
- if ((data[i] & 0xff000000) != 0xff000000) {
- samples = gl_alpha_format;
- break;
- }
- }
-
- if (samples == gl_solid_format)
- comp = gl_tex_solid_format;
- else if (samples == gl_alpha_format)
- comp = gl_tex_alpha_format;
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n');
- comp = samples;
- }
-
- // simulates a goto
- try {
- if (scaled_width == width && scaled_height == height) {
- if (!mipmap) {
- if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) {
- uploaded_paletted = true;
- GL_BuildPalettedTexture(paletted_texture, data, scaled_width, scaled_height);
- gl.glTexImage2D(
- GL.GL_TEXTURE_2D,
- 0,
- GL_COLOR_INDEX8_EXT,
- scaled_width,
- scaled_height,
- 0,
- GL.GL_COLOR_INDEX,
- GL.GL_UNSIGNED_BYTE,
- paletted_texture);
- }
- else {
- tex.rewind(); tex.put(data);
- gl.glTexImage2D(
- GL.GL_TEXTURE_2D,
- 0,
- comp,
- scaled_width,
- scaled_height,
- 0,
- GL.GL_RGBA,
- GL.GL_UNSIGNED_BYTE,
- tex);
- }
- //goto done;
- throw new longjmpException();
- }
- //memcpy (scaled, data, width*height*4); were bytes
- System.arraycopy(data, 0, scaled, 0, width * height);
- }
- else
- GL_ResampleTexture(data, width, height, scaled, scaled_width, scaled_height);
-
- GL_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap);
-
- if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && (samples == gl_solid_format)) {
- uploaded_paletted = true;
- GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height);
- gl.glTexImage2D(
- GL.GL_TEXTURE_2D,
- 0,
- GL_COLOR_INDEX8_EXT,
- scaled_width,
- scaled_height,
- 0,
- GL.GL_COLOR_INDEX,
- GL.GL_UNSIGNED_BYTE,
- paletted_texture);
- }
- else {
- tex.rewind(); tex.put(scaled);
- gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, tex);
- }
-
- if (mipmap) {
- int miplevel;
- miplevel = 0;
- while (scaled_width > 1 || scaled_height > 1) {
- GL_MipMap(scaled, scaled_width, scaled_height);
- scaled_width >>= 1;
- scaled_height >>= 1;
- if (scaled_width < 1)
- scaled_width = 1;
- if (scaled_height < 1)
- scaled_height = 1;
-
- miplevel++;
- if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) {
- uploaded_paletted = true;
- GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height);
- gl.glTexImage2D(
- GL.GL_TEXTURE_2D,
- miplevel,
- GL_COLOR_INDEX8_EXT,
- scaled_width,
- scaled_height,
- 0,
- GL.GL_COLOR_INDEX,
- GL.GL_UNSIGNED_BYTE,
- paletted_texture);
- }
- else {
- tex.rewind(); tex.put(scaled);
- gl.glTexImage2D(
- GL.GL_TEXTURE_2D,
- miplevel,
- comp,
- scaled_width,
- scaled_height,
- 0,
- GL.GL_RGBA,
- GL.GL_UNSIGNED_BYTE,
- tex);
- }
- }
- }
- // label done:
- }
- catch (longjmpException e) {
- ; // replaces label done
- }
-
- if (mipmap) {
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_min);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
- else {
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_max);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, gl_filter_max);
- }
-
- return (samples == gl_alpha_format);
- }
-
- /*
- ===============
- GL_Upload8
-
- Returns has_alpha
- ===============
- */
-
- int[] trans = new int[512 * 256];
-
- boolean GL_Upload8(byte[] data, int width, int height, boolean mipmap, boolean is_sky) {
-
- Arrays.fill(trans, 0);
-
- int s = width * height;
-
- if (s > trans.length)
- ri.Sys_Error(Defines.ERR_DROP, "GL_Upload8: too large");
-
- if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) {
- gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL.GL_COLOR_INDEX, GL.GL_UNSIGNED_BYTE, data);
-
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_max);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, gl_filter_max);
-
- // TODO check this
- return false;
- }
- else {
- int p;
- int rgb;
- for (int i = 0; i < s; i++) {
- p = data[i] & 0xff;
- trans[i] = d_8to24table[p];
-
- if (p == 255) { // transparent, so scan around for another color
- // to avoid alpha fringes
- // FIXME: do a full flood fill so mips work...
- if (i > width && (data[i - width] & 0xff) != 255)
- p = data[i - width] & 0xff;
- else if (i < s - width && (data[i + width] & 0xff) != 255)
- p = data[i + width] & 0xff;
- else if (i > 0 && (data[i - 1] & 0xff) != 255)
- p = data[i - 1] & 0xff;
- else if (i < s - 1 && (data[i + 1] & 0xff) != 255)
- p = data[i + 1] & 0xff;
- else
- p = 0;
- // copy rgb components
-
- // ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0];
- // ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1];
- // ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2];
-
- trans[i] = d_8to24table[p] & 0x00FFFFFF; // only rgb
- }
- }
-
- return GL_Upload32(trans, width, height, mipmap);
- }
- }
-
- /*
- ================
- GL_LoadPic
-
- This is also used as an entry point for the generated r_notexture
- ================
- */
- image_t GL_LoadPic(String name, byte[] pic, int width, int height, int type, int bits) {
- image_t image;
- int i;
-
- // find a free image_t
- for (i = 0; i<numgltextures ; i++)
- {
- image = gltextures[i];
- if (image.texnum == 0)
- break;
- }
-
- if (i == numgltextures)
- {
- if (numgltextures == MAX_GLTEXTURES)
- ri.Sys_Error (Defines.ERR_DROP, "MAX_GLTEXTURES");
-
- numgltextures++;
- }
- image = gltextures[i];
-
- if (name.length() > Defines.MAX_QPATH)
- ri.Sys_Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long");
-
- image.name = name;
- image.registration_sequence = registration_sequence;
-
- image.width = width;
- image.height = height;
- image.type = type;
-
-
- if (type == it_skin && bits == 8)
- R_FloodFillSkin(pic, width, height);
-
- // load little pics into the scrap
- if (image.type == it_pic && bits == 8 && image.width < 64 && image.height < 64) {
- pos_t pos = new pos_t(0, 0);
- int j, k;
-
- int texnum = Scrap_AllocBlock(image.width, image.height, pos);
-
- if (texnum == -1) {
- // replace goto nonscrap
-
- image.scrap = false;
-
- image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array
- GL_Bind(image.texnum);
-
- if (bits == 8) {
- image.has_alpha =
- GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
- }
- else {
- int[] tmp = new int[pic.length / 4];
-
- for (i = 0; i < tmp.length; i++) {
- tmp[i] = ((pic[4 * i + 0] & 0xFF) << 0); // & 0x000000FF;
- tmp[i] |= ((pic[4 * i + 1] & 0xFF) << 8); // & 0x0000FF00;
- tmp[i] |= ((pic[4 * i + 2] & 0xFF) << 16); // & 0x00FF0000;
- tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000;
- }
-
- image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky));
- }
-
- image.upload_width = upload_width; // after power of 2 and scales
- image.upload_height = upload_height;
- image.paletted = uploaded_paletted;
- image.sl = 0;
- image.sh = 1;
- image.tl = 0;
- image.th = 1;
-
- return image;
- }
-
- scrap_dirty = true;
-
- // copy the texels into the scrap block
- k = 0;
- for (i = 0; i < image.height; i++)
- for (j = 0; j < image.width; j++, k++)
- scrap_texels[texnum][(pos.y + i) * BLOCK_WIDTH + pos.x + j] = pic[k];
-
- image.texnum = TEXNUM_SCRAPS + texnum;
- image.scrap = true;
- image.has_alpha = true;
- image.sl = (pos.x + 0.01f) / (float) BLOCK_WIDTH;
- image.sh = (pos.x + image.width - 0.01f) / (float) BLOCK_WIDTH;
- image.tl = (pos.y + 0.01f) / (float) BLOCK_WIDTH;
- image.th = (pos.y + image.height - 0.01f) / (float) BLOCK_WIDTH;
-
- }
- else {
- // this was label nonscrap
-
- image.scrap = false;
-
- image.texnum = TEXNUM_IMAGES + image.getId(); //image pos in array
- GL_Bind(image.texnum);
-
- if (bits == 8) {
- image.has_alpha = GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
- }
- else {
- int[] tmp = new int[pic.length / 4];
-
- for (i = 0; i < tmp.length; i++) {
- tmp[i] = ((pic[4 * i + 0] & 0xFF) << 0); // & 0x000000FF;
- tmp[i] |= ((pic[4 * i + 1] & 0xFF) << 8); // & 0x0000FF00;
- tmp[i] |= ((pic[4 * i + 2] & 0xFF) << 16); // & 0x00FF0000;
- tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000;
- }
-
- image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky));
- }
- image.upload_width = upload_width; // after power of 2 and scales
- image.upload_height = upload_height;
- image.paletted = uploaded_paletted;
- image.sl = 0;
- image.sh = 1;
- image.tl = 0;
- image.th = 1;
- }
- return image;
- }
-
- /*
- ================
- GL_LoadWal
- ================
- */
- image_t GL_LoadWal(String name) {
-
- image_t image = null;
-
- byte[] raw = ri.FS_LoadFile(name);
- if (raw == null) {
- ri.Con_Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n');
- return r_notexture;
- }
-
- qfiles.miptex_t mt = new qfiles.miptex_t(raw);
-
- byte[] pix = new byte[mt.width * mt.height];
- System.arraycopy(raw, mt.offsets[0], pix, 0, pix.length);
-
- image = GL_LoadPic(name, pix, mt.width, mt.height, it_wall, 8);
-
- return image;
- }
-
- /*
- ===============
- GL_FindImage
-
- Finds or loads the given image
- ===============
- */
- image_t GL_FindImage(String name, int type) {
- image_t image = null;
-
- // TODO loest das grossschreibungs problem
- name = name.toLowerCase();
- // bughack for bad strings (fuck \0)
- int index = name.indexOf('\0');
- if (index != -1)
- name = name.substring(0, index);
-
- if (name == null || name.length() < 5)
- return null; // ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name");
- // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name);
-
- // look for it
- for (int i = 0; i < numgltextures; i++)
- {
- image = gltextures[i];
- if (name.equals(image.name))
- {
- image.registration_sequence = registration_sequence;
- return image;
- }
- }
-
- //
- // load the pic from disk
- //
- byte[] pic = null;
- Dimension dim = new Dimension();
-
- if (name.endsWith(".pcx")) {
-
- pic = LoadPCX(name, null, dim);
- if (pic == null)
- return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8);
-
- }
- else if (name.endsWith(".wal")) {
-
- image = GL_LoadWal(name);
-
- }
- else if (name.endsWith(".tga")) {
-
- pic = LoadTGA(name, dim);
-
- if (pic == null)
- return null;
-
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32);
-
- }
- else
- return null;
-
- return image;
- }
-
- /*
- ===============
- R_RegisterSkin
- ===============
- */
- protected image_t R_RegisterSkin(String name) {
- return GL_FindImage(name, it_skin);
- }
-
- /*
- ================
- GL_FreeUnusedImages
-
- Any image that was not touched on this registration sequence
- will be freed.
- ================
- */
- void GL_FreeUnusedImages() {
-
- // never free r_notexture or particle texture
- r_notexture.registration_sequence = registration_sequence;
- r_particletexture.registration_sequence = registration_sequence;
-
- image_t image = null;
-
- for (int i = 0; i < numgltextures; i++) {
- image = gltextures[i];
- // used this sequence
- if (image.registration_sequence == registration_sequence)
- continue;
- // free image_t slot
- if (image.registration_sequence == 0)
- continue;
- // don't free pics
- if (image.type == it_pic)
- continue;
-
- // free it
- // TODO jogl bug
- gl.glDeleteTextures(1, new int[] {image.texnum});
- image.clear();
- }
- }
-
- /*
- ===============
- Draw_GetPalette
- ===============
- */
- protected void Draw_GetPalette() {
- int r, g, b;
- Dimension dim;
- byte[] pic;
- byte[][] palette = new byte[1][]; //new byte[768];
-
- // get the palette
-
- pic = LoadPCX("pics/colormap.pcx", palette, dim = new Dimension());
-
- if (palette[0] == null || palette[0].length != 768)
- ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx");
-
- byte[] pal = palette[0];
-
- int j = 0;
- for (int i = 0; i < 256; i++) {
- r = pal[j++] & 0xFF;
- g = pal[j++] & 0xFF;
- b = pal[j++] & 0xFF;
-
- d_8to24table[i] = (255 << 24) | (b << 16) | (g << 8) | (r << 0);
- }
-
- d_8to24table[255] &= 0x00FFFFFF; // 255 is transparent
-
- particle_t.setColorPalette(d_8to24table);
- }
-
- /*
- ===============
- GL_InitImages
- ===============
- */
- void GL_InitImages() {
- int i, j;
- float g = vid_gamma.value;
-
- registration_sequence = 1;
-
- // init intensity conversions
- intensity = ri.Cvar_Get("intensity", "2", 0);
-
- if (intensity.value <= 1)
- ri.Cvar_Set("intensity", "1");
-
- gl_state.inverse_intensity = 1 / intensity.value;
-
- Draw_GetPalette();
-
- if (qglColorTableEXT) {
- gl_state.d_16to8table = ri.FS_LoadFile("pics/16to8.dat");
- if (gl_state.d_16to8table == null)
- ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx");
- }
-
- if ((gl_config.renderer & (GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2)) != 0) {
- g = 1.0F;
- }
-
- for (i = 0; i < 256; i++) {
-
- if (g == 1.0f) {
- gammatable[i] = (byte) i;
- }
- else {
-
- int inf = (int) (255.0f * Math.pow((i + 0.5) / 255.5, g) + 0.5);
- if (inf < 0)
- inf = 0;
- if (inf > 255)
- inf = 255;
- gammatable[i] = (byte) inf;
- }
- }
-
- for (i = 0; i < 256; i++) {
- j = (int) (i * intensity.value);
- if (j > 255)
- j = 255;
- intensitytable[i] = (byte) j;
- }
- }
-
- /*
- ===============
- GL_ShutdownImages
- ===============
- */
- void GL_ShutdownImages() {
- image_t image;
-
- for (int i=0; i < numgltextures ; i++)
- {
- image = gltextures[i];
-
- if (image.registration_sequence == 0)
- continue; // free image_t slot
- // free it
- // TODO jogl bug
- gl.glDeleteTextures(1, new int[] {image.texnum});
- image.clear();
- }
- }
-
-}
diff --git a/src/jake2/render/fastjogl/Impl.java b/src/jake2/render/fastjogl/Impl.java
deleted file mode 100644
index 03af496..0000000
--- a/src/jake2/render/fastjogl/Impl.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Impl.java
- * Copyright (C) 2003
- *
- * $Id: Impl.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.qcommon.Com;
-import jake2.qcommon.xcommand_t;
-import jake2.sys.KBD;
-
-import java.awt.*;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.JFrame;
-
-import net.java.games.jogl.*;
-
-/**
- * Impl
- *
- * @author cwei
- */
-public class Impl extends Misc implements GLEventListener {
-
- public static final String DRIVER_NAME = "fastjogl";
-
- // handles the post initialization with JoglRenderer
- protected boolean post_init = false;
-
- private final xcommand_t INIT_CALLBACK = new xcommand_t() {
- public void execute() {
- // only used for the first run (initialization)
- // clear the screen
- gl.glClearColor(0, 0, 0, 0);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- //
- // check the post init process
- //
- if (!post_init) {
- ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n");
- }
-
- GLimp_EndFrame();
- }
- };
-
- private xcommand_t callback = INIT_CALLBACK;
- protected boolean contextInUse = false;
-
- private GraphicsDevice device;
- private DisplayMode oldDisplayMode;
-
- GLCanvas canvas;
- JFrame window;
-
- // window position on the screen
- int window_xpos, window_ypos;
-
- /**
- * @return true
- */
- boolean GLimp_Init(int xpos, int ypos) {
- // do nothing
- window_xpos = xpos;
- window_ypos = ypos;
- return true;
- }
-
- /**
- * @param dim
- * @param mode
- * @param fullscreen
- * @return enum rserr_t
- */
- int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) {
-
- Dimension newDim = new Dimension();
-
- ri.Cvar_Get("r_fakeFullscreen", "0", Globals.CVAR_ARCHIVE);
-
- ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
-
- ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
-
- if (!ri.Vid_GetModeInfo(newDim, mode)) {
- ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n");
- return rserr_invalid_mode;
- }
-
- ri.Con_Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n');
-
- // destroy the existing window
- GLimp_Shutdown();
-
- window = new JFrame("Jake2");
-
- GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
-
- // TODO Use debug pipeline
- //canvas.setGL(new DebugGL(canvas.getGL()));
-
- canvas.setNoAutoRedrawMode(true);
- canvas.addGLEventListener(this);
-
- window.getContentPane().add(canvas);
-
- canvas.setSize(newDim.width, newDim.height);
-
- // register event listener
- window.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit");
- }
- });
-
- // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G
- window.addComponentListener(KBD.listener);
- canvas.addKeyListener(KBD.listener);
- canvas.addMouseListener(KBD.listener);
- canvas.addMouseMotionListener(KBD.listener);
-
- /*
- * fullscreen handling
- */
- GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
- device = env.getDefaultScreenDevice();
-
- if (fullscreen && !device.isFullScreenSupported()) {
- ri.Con_Printf(Defines.PRINT_ALL, "...fullscreen not supported\n");
- vid_fullscreen.value = 0;
- vid_fullscreen.modified = false;
- }
-
- fullscreen = fullscreen && device.isFullScreenSupported();
-
- if (oldDisplayMode == null) {
- oldDisplayMode = device.getDisplayMode();
- }
-
- if (fullscreen) {
-
- DisplayMode displayMode = findDisplayMode(newDim, oldDisplayMode.getBitDepth(), oldDisplayMode.getRefreshRate());
-
- if (displayMode != null) {
- newDim.width = displayMode.getWidth();
- newDim.height = displayMode.getHeight();
- window.setUndecorated(true);
- window.setResizable(false);
- device.setFullScreenWindow(window);
- device.setDisplayMode(displayMode);
- window.setLocation(0, 0);
- window.setSize(displayMode.getWidth(), displayMode.getHeight());
- canvas.setSize(displayMode.getWidth(), displayMode.getHeight());
- ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n');
- }
- } else {
- window.setLocation(window_xpos, window_ypos);
- window.pack();
- window.setResizable(false);
- window.setVisible(true);
- }
-
- while (!canvas.isDisplayable()) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {}
- }
- canvas.requestFocus();
-
- this.canvas = canvas;
-
- vid.width = newDim.width;
- vid.height = newDim.height;
-
- // let the sound and input subsystems know about the new window
- ri.Vid_NewWindow(vid.width, vid.height);
-
- return rserr_ok;
- }
-
- DisplayMode findDisplayMode(Dimension dim, int depth, int rate) {
- DisplayMode mode = null;
- DisplayMode m = null;
- DisplayMode[] modes = device.getDisplayModes();
- int w = dim.width;
- int h = dim.height;
-
- for (int i = 0; i < modes.length; i++) {
- m = modes[i];
- if (m.getWidth() == w && m.getHeight() == h && m.getBitDepth() == depth && m.getRefreshRate() == rate) {
- mode = m;
- break;
- }
- }
- if (mode == null) mode = oldDisplayMode;
- Com.Printf(getModeString(mode) + '\n');
- return mode;
- }
-
- String getModeString(DisplayMode m) {
- StringBuffer sb = new StringBuffer();
- sb.append(m.getWidth());
- sb.append('x');
- sb.append(m.getHeight());
- sb.append('x');
- sb.append(m.getBitDepth());
- sb.append('@');
- sb.append(m.getRefreshRate());
- sb.append("Hz");
- return sb.toString();
- }
-
- void GLimp_BeginFrame(float camera_separation) {
- // do nothing
- }
-
- protected void GLimp_EndFrame() {
- gl.glFlush();
- // swap buffer
- // but jogl has no method to swap
- }
-
- protected void GLimp_AppActivate(boolean activate) {
- // do nothing
- }
-
- boolean QGL_Init(String dll_name) {
- // doesn't need libGL.so or .dll loading
- return true;
- }
-
- void QGL_Shutdown() {
- // doesn't need libGL.so or .dll loading
- // do nothing
- }
-
- void GLimp_Shutdown() {
- if (oldDisplayMode != null && device.getFullScreenWindow() != null) {
- try {
- device.setDisplayMode(oldDisplayMode);
- device.setFullScreenWindow(null);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (this.window != null) {
- window.dispose();
- }
- post_init = false;
- callback = INIT_CALLBACK;
- }
-
- void GLimp_EnableLogging(boolean enable) {
- // doesn't need jogl logging
- // do nothing
- }
-
- void GLimp_LogNewFrame() {
- // doesn't need jogl logging
- // do nothing
- }
-
-
-
- // ============================================================================
- // GLEventListener interface
- // ============================================================================
-
- /*
- * @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable)
- */
- public void init(GLDrawable drawable) {
- this.gl = drawable.getGL();
- this.glu = drawable.getGLU();
-
- // this is a hack to run R_init() in gl context
- post_init = R_Init2();
- }
-
- /*
- * @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable)
- */
- public void display(GLDrawable drawable) {
- this.gl = drawable.getGL();
- this.glu = drawable.getGLU();
-
- contextInUse = true;
- callback.execute();
- contextInUse = false;
- }
-
- /*
- * @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean)
- */
- public void displayChanged(GLDrawable drawable, boolean arg1, boolean arg2) {
- // do nothing
- }
-
- /*
- * @see net.java.games.jogl.GLEventListener#reshape(net.java.games.jogl.GLDrawable, int, int, int, int)
- */
- public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
- // do nothing
- }
-
- /*
- * @see jake2.client.refexport_t#updateScreen()
- */
- public void updateScreen() {
- this.callback = INIT_CALLBACK;
- canvas.display();
- }
-
- public void updateScreen(xcommand_t callback) {
- this.callback = callback;
- canvas.display();
- }
-} \ No newline at end of file
diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java
deleted file mode 100644
index b963b21..0000000
--- a/src/jake2/render/fastjogl/Light.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/*
- * Light.java
- * Copyright (C) 2003
- *
- * $Id: Light.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.client.dlight_t;
-import jake2.client.lightstyle_t;
-import jake2.game.GameBase;
-import jake2.game.cplane_t;
-import jake2.qcommon.longjmpException;
-import jake2.render.*;
-import jake2.util.Math3D;
-
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.util.Arrays;
-
-import net.java.games.jogl.GL;
-
-/**
- * Light
- *
- * @author cwei
- */
-public abstract class Light extends Warp {
- // r_light.c
-
- int r_dlightframecount;
-
- static final int DLIGHT_CUTOFF = 64;
-
- /*
- =============================================================================
-
- DYNAMIC LIGHTS BLEND RENDERING
-
- =============================================================================
- */
-
- void R_RenderDlight (dlight_t light)
- {
- int i, j;
- float a;
- float[] v = {0, 0, 0};
- float rad;
-
- rad = light.intensity * 0.35f;
-
- Math3D.VectorSubtract (light.origin, r_origin, v);
-
- gl.glBegin (GL.GL_TRIANGLE_FAN);
- gl.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f);
- for (i=0 ; i<3 ; i++)
- v[i] = light.origin[i] - vpn[i]*rad;
- gl.glVertex3f(v[0], v[1], v[2]);
- gl.glColor3f (0,0,0);
- for (i=16 ; i>=0 ; i--)
- {
- a = (float)(i/16.0f * Math.PI*2);
- for (j=0 ; j<3 ; j++)
- v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad
- + vup[j]*Math.sin(a)*rad);
- gl.glVertex3f(v[0], v[1], v[2]);
- }
- gl.glEnd ();
- }
-
- /*
- =============
- R_RenderDlights
- =============
- */
- void R_RenderDlights()
- {
- if (gl_flashblend.value == 0)
- return;
-
- r_dlightframecount = r_framecount + 1; // because the count hasn't
- // advanced yet for this frame
- gl.glDepthMask(false);
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glShadeModel (GL.GL_SMOOTH);
- gl.glEnable (GL.GL_BLEND);
- gl.glBlendFunc (GL.GL_ONE, GL.GL_ONE);
-
- for (int i=0 ; i<r_newrefdef.num_dlights ; i++)
- {
- R_RenderDlight(r_newrefdef.dlights[i]);
- }
-
- gl.glColor3f (1,1,1);
- gl.glDisable(GL.GL_BLEND);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- gl.glDepthMask(true);
- }
-
-
- /*
- =============================================================================
-
- DYNAMIC LIGHTS
-
- =============================================================================
- */
-
- /*
- =============
- R_MarkLights
- =============
- */
- void R_MarkLights (dlight_t light, int bit, mnode_t node)
- {
- cplane_t splitplane;
- float dist;
- msurface_t surf;
- int i;
- int sidebit;
-
- if (node.contents != -1)
- return;
-
- splitplane = node.plane;
- dist = Math3D.DotProduct (light.origin, splitplane.normal) - splitplane.dist;
-
- if (dist > light.intensity - DLIGHT_CUTOFF)
- {
- R_MarkLights (light, bit, node.children[0]);
- return;
- }
- if (dist < -light.intensity + DLIGHT_CUTOFF)
- {
- R_MarkLights (light, bit, node.children[1]);
- return;
- }
-
- // mark the polygons
- for (i=0 ; i<node.numsurfaces ; i++)
- {
-
- surf = r_worldmodel.surfaces[node.firstsurface + i];
-
- /*
- * cwei
- * bugfix for dlight behind the walls
- */
- dist = Math3D.DotProduct (light.origin, surf.plane.normal) - surf.plane.dist;
- sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK;
- if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit )
- continue;
- /*
- * cwei
- * bugfix end
- */
-
- if (surf.dlightframe != r_dlightframecount)
- {
- surf.dlightbits = 0;
- surf.dlightframe = r_dlightframecount;
- }
- surf.dlightbits |= bit;
- }
-
- R_MarkLights (light, bit, node.children[0]);
- R_MarkLights (light, bit, node.children[1]);
- }
-
-
- /*
- =============
- R_PushDlights
- =============
- */
- void R_PushDlights()
- {
- int i;
- dlight_t l;
-
- if (gl_flashblend.value != 0)
- return;
-
- r_dlightframecount = r_framecount + 1; // because the count hasn't
- // advanced yet for this frame
- for (i=0 ; i<r_newrefdef.num_dlights ; i++) {
- l = r_newrefdef.dlights[i];
- R_MarkLights( l, 1<<i, r_worldmodel.nodes[0] );
- }
- }
-
-
- /*
- =============================================================================
-
- LIGHT SAMPLING
-
- =============================================================================
- */
-
- float[] pointcolor = {0, 0, 0}; // vec3_t
- cplane_t lightplane; // used as shadow plane
- float[] lightspot = {0, 0, 0}; // vec3_t
-
- int RecursiveLightPoint (mnode_t node, float[] start, float[] end)
- {
- float front, back, frac;
- boolean side;
- int sideIndex;
- cplane_t plane;
- float[] mid = {0, 0, 0};
- msurface_t surf;
- int s, t, ds, dt;
- int i;
- mtexinfo_t tex;
- ByteBuffer lightmap;
- int maps;
- int r;
-
- if (node.contents != -1)
- return -1; // didn't hit anything
-
- // calculate mid point
-
- // FIXME: optimize for axial
- plane = node.plane;
- front = Math3D.DotProduct (start, plane.normal) - plane.dist;
- back = Math3D.DotProduct (end, plane.normal) - plane.dist;
- side = (front < 0);
- sideIndex = (side) ? 1 : 0;
-
- if ( (back < 0) == side)
- return RecursiveLightPoint (node.children[sideIndex], start, end);
-
- frac = front / (front-back);
- mid[0] = start[0] + (end[0] - start[0])*frac;
- mid[1] = start[1] + (end[1] - start[1])*frac;
- mid[2] = start[2] + (end[2] - start[2])*frac;
-
- // go down front side
- r = RecursiveLightPoint (node.children[sideIndex], start, mid);
- if (r >= 0)
- return r; // hit something
-
- if ( (back < 0) == side )
- return -1; // didn't hit anuthing
-
- // check for impact on this node
- Math3D.VectorCopy (mid, lightspot);
- lightplane = plane;
-
- int surfIndex = node.firstsurface;
- for (i=0 ; i<node.numsurfaces ; i++, surfIndex++)
- {
- surf = r_worldmodel.surfaces[surfIndex];
-
- if ((surf.flags & (Defines.SURF_DRAWTURB | Defines.SURF_DRAWSKY)) != 0)
- continue; // no lightmaps
-
- tex = surf.texinfo;
-
- s = (int)(Math3D.DotProduct (mid, tex.vecs[0]) + tex.vecs[0][3]);
- t = (int)(Math3D.DotProduct (mid, tex.vecs[1]) + tex.vecs[1][3]);
-
- if (s < surf.texturemins[0] || t < surf.texturemins[1])
- continue;
-
- ds = s - surf.texturemins[0];
- dt = t - surf.texturemins[1];
-
- if ( ds > surf.extents[0] || dt > surf.extents[1] )
- continue;
-
- if (surf.samples == null)
- return 0;
-
- ds >>= 4;
- dt >>= 4;
-
- lightmap = surf.samples;
- int lightmapIndex = 0;
-
- Math3D.VectorCopy (Globals.vec3_origin, pointcolor);
- if (lightmap != null)
- {
- float[] scale = {0, 0, 0};
- float[] rgb;
- lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds);
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++)
- {
- rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb;
- scale[0] = gl_modulate.value * rgb[0];
- scale[1] = gl_modulate.value * rgb[1];
- scale[2] = gl_modulate.value * rgb[2];
-
- pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255);
- pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale[1] * (1.0f/255);
- pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) * scale[2] * (1.0f/255);
- lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1);
- }
- }
- return 1;
- }
-
- // go down back side
- return RecursiveLightPoint (node.children[1 - sideIndex], mid, end);
- }
-
- /*
- ===============
- R_LightPoint
- ===============
- */
- void R_LightPoint (float[] p, float[] color)
- {
- assert (p.length == 3) : "vec3_t bug";
- assert (color.length == 3) : "rgb bug";
-
- float[] end = {0, 0, 0};
- float r;
- int lnum;
- dlight_t dl;
- float light;
- float[] dist = {0, 0, 0};
- float add;
-
- if (r_worldmodel.lightdata == null)
- {
- color[0] = color[1] = color[2] = 1.0f;
- return;
- }
-
- end[0] = p[0];
- end[1] = p[1];
- end[2] = p[2] - 2048;
-
- r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end);
-
- if (r == -1)
- {
- Math3D.VectorCopy (GameBase.vec3_origin, color);
- }
- else
- {
- Math3D.VectorCopy (pointcolor, color);
- }
-
- //
- // add dynamic lights
- //
- light = 0;
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
- {
- dl = r_newrefdef.dlights[lnum];
-
- Math3D.VectorSubtract (currententity.origin, dl.origin, dist);
- add = dl.intensity - Math3D.VectorLength(dist);
- add *= (1.0f/256);
- if (add > 0)
- {
- Math3D.VectorMA (color, add, dl.color, color);
- }
- }
-
- Math3D.VectorScale (color, gl_modulate.value, color);
- }
-
-
-// ===================================================================
-
- float[] s_blocklights = new float[34 * 34 * 3];
-
- /*
- ===============
- R_AddDynamicLights
- ===============
- */
- void R_AddDynamicLights(msurface_t surf)
- {
- int lnum;
- int sd, td;
- float fdist, frad, fminlight;
- float[] impact = {0, 0, 0};
- float[] local = {0, 0, 0};
- int s, t;
- int i;
- int smax, tmax;
- mtexinfo_t tex;
- dlight_t dl;
- float[] pfBL;
- float fsacc, ftacc;
-
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
- tex = surf.texinfo;
-
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
- {
- if ( (surf.dlightbits & (1<<lnum)) == 0 )
- continue; // not lit by this light
-
- dl = r_newrefdef.dlights[lnum];
- frad = dl.intensity;
- fdist = Math3D.DotProduct (dl.origin, surf.plane.normal) -
- surf.plane.dist;
- frad -= Math.abs(fdist);
- // rad is now the highest intensity on the plane
-
- fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
- if (frad < fminlight)
- continue;
- fminlight = frad - fminlight;
-
- for (i=0 ; i<3 ; i++)
- {
- impact[i] = dl.origin[i] -
- surf.plane.normal[i]*fdist;
- }
-
- local[0] = Math3D.DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0];
- local[1] = Math3D.DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1];
-
- pfBL = s_blocklights;
- int pfBLindex = 0;
- for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
- {
- td = (int)(local[1] - ftacc);
- if ( td < 0 )
- td = -td;
-
- for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3)
- {
- sd = (int)( local[0] - fsacc );
-
- if ( sd < 0 )
- sd = -sd;
-
- if (sd > td)
- fdist = sd + (td>>1);
- else
- fdist = td + (sd>>1);
-
- if ( fdist < fminlight )
- {
- pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0];
- pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1];
- pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2];
- }
- }
- }
- }
- }
-
-
- /*
- ** R_SetCacheState
- */
- void R_SetCacheState( msurface_t surf )
- {
- int maps;
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ;
- maps++)
- {
- surf.cached_light[maps] = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].white;
- }
- }
-
- /*
- ===============
- R_BuildLightMap
-
- Combine and scale multiple lightmaps into the floating format in blocklights
- ===============
- */
- void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride)
- {
- int smax, tmax;
- int r, g, b, a, max;
- int i, j, size;
- ByteBuffer lightmap;
- float[] scale = {0, 0, 0, 0};
- int nummaps;
- float[] bl;
- lightstyle_t style;
- int monolightmap;
-
- if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 )
- ri.Sys_Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface");
-
- smax = (surf.extents[0] >> 4) + 1;
- tmax = (surf.extents[1] >> 4) + 1;
- size = smax * tmax;
- if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) )
- ri.Sys_Error(Defines.ERR_DROP, "Bad s_blocklights size");
-
- try {
- // set to full bright if no light data
- if (surf.samples == null)
- {
- int maps;
-
- for (i=0 ; i<size*3 ; i++)
- s_blocklights[i] = 255;
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++)
- {
- style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF];
- }
- // goto store;
- throw new longjmpException();
- }
-
- // count the # of maps
- for ( nummaps = 0 ; nummaps < Defines.MAXLIGHTMAPS && surf.styles[nummaps] != (byte)255 ;
- nummaps++)
- ;
-
- lightmap = surf.samples;
- int lightmapIndex = 0;
-
- // add all the lightmaps
- if ( nummaps == 1 )
- {
- int maps;
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ;
- maps++)
- {
- bl = s_blocklights;
- int blp = 0;
-
- for (i=0 ; i<3 ; i++)
- scale[i] = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i];
-
- if ( scale[0] == 1.0F &&
- scale[1] == 1.0F &&
- scale[2] == 1.0F )
- {
- for (i=0 ; i<size ; i++)
- {
- bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
- bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
- bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
- }
- }
- else
- {
- for (i=0 ; i<size ; i++)
- {
- bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[0];
- bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[1];
- bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[2];
- }
- }
- //lightmap += size*3; // skip to next lightmap
- }
- }
- else
- {
- int maps;
-
- // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 );
-
- Arrays.fill(s_blocklights, 0, size * 3, 0.0f);
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ;
- maps++)
- {
- bl = s_blocklights;
- int blp = 0;
-
- for (i=0 ; i<3 ; i++)
- scale[i] = gl_modulate.value*r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i];
-
- if ( scale[0] == 1.0F &&
- scale[1] == 1.0F &&
- scale[2] == 1.0F )
- {
- for (i=0 ; i<size ; i++)
- {
- bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
- bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
- bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
- }
- }
- else
- {
- for (i=0 ; i<size ; i++)
- {
- bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[0];
- bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[1];
- bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[2];
- }
- }
- //lightmap += size*3; // skip to next lightmap
- }
- }
-
- // add all the dynamic lights
- if (surf.dlightframe == r_framecount)
- R_AddDynamicLights(surf);
-
- // label store:
- } catch (longjmpException store) {}
-
- // put into texture format
- stride -= smax;
- bl = s_blocklights;
- int blp = 0;
-
- monolightmap = gl_monolightmap.string.charAt(0);
-
- int destp = 0;
-
- if ( monolightmap == '0' )
- {
- for (i=0 ; i<tmax ; i++, destp += stride)
- {
- //dest.position(destp);
-
- for (j=0 ; j<smax ; j++)
- {
-
- r = (int)bl[blp++];
- g = (int)bl[blp++];
- b = (int)bl[blp++];
-
- // catch negative lights
- if (r < 0)
- r = 0;
- if (g < 0)
- g = 0;
- if (b < 0)
- b = 0;
-
- /*
- ** determine the brightest of the three color components
- */
- if (r > g)
- max = r;
- else
- max = g;
- if (b > max)
- max = b;
-
- /*
- ** alpha is ONLY used for the mono lightmap case. For this reason
- ** we set it to the brightest of the color components so that
- ** things don't get too dim.
- */
- a = max;
-
- /*
- ** rescale all the color components if the intensity of the greatest
- ** channel exceeds 1.0
- */
- if (max > 255)
- {
- float t = 255.0F / max;
-
- r = (int)(r*t);
- g = (int)(g*t);
- b = (int)(b*t);
- a = (int)(a*t);
- }
- r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
- dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
- }
- }
- }
- else
- {
- for (i=0 ; i<tmax ; i++, destp += stride)
- {
- //dest.position(destp);
-
- for (j=0 ; j<smax ; j++)
- {
-
- r = (int) bl[blp++];
- g = (int) bl[blp++];
- b = (int) bl[blp++];
-
- // catch negative lights
- if (r < 0)
- r = 0;
- if (g < 0)
- g = 0;
- if (b < 0)
- b = 0;
-
- /*
- ** determine the brightest of the three color components
- */
- if (r > g)
- max = r;
- else
- max = g;
- if (b > max)
- max = b;
-
- /*
- ** alpha is ONLY used for the mono lightmap case. For this reason
- ** we set it to the brightest of the color components so that
- ** things don't get too dim.
- */
- a = max;
-
- /*
- ** rescale all the color components if the intensity of the greatest
- ** channel exceeds 1.0
- */
- if (max > 255)
- {
- float t = 255.0F / max;
-
- r = (int)(r*t);
- g = (int)(g*t);
- b = (int)(b*t);
- a = (int)(a*t);
- }
-
- /*
- ** So if we are doing alpha lightmaps we need to set the R, G, and B
- ** components to 0 and we need to set alpha to 1-alpha.
- */
- switch ( monolightmap )
- {
- case 'L':
- case 'I':
- r = a;
- g = b = 0;
- break;
- case 'C':
- // try faking colored lighting
- a = 255 - ((r+g+b)/3);
- r *= a/255.0f;
- g *= a/255.0f;
- b *= a/255.0f;
- break;
- case 'A':
- default:
- r = g = b = 0;
- a = 255 - a;
- break;
- }
- r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
- dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
- }
- }
- }
- }
-
-}
diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java
deleted file mode 100644
index 2363db4..0000000
--- a/src/jake2/render/fastjogl/Main.java
+++ /dev/null
@@ -1,1592 +0,0 @@
-/*
- * Main.java
- * Copyright (C) 2003
- *
- * $Id: Main.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.*;
-import jake2.client.*;
-import jake2.game.cplane_t;
-import jake2.game.cvar_t;
-import jake2.qcommon.qfiles;
-import jake2.qcommon.xcommand_t;
-import jake2.render.*;
-import jake2.util.Math3D;
-import jake2.util.Vargs;
-
-import java.awt.Dimension;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.GLU;
-import net.java.games.jogl.util.BufferUtils;
-import net.java.games.jogl.util.GLUT;
-
-/**
- * Main
- *
- * @author cwei
- */
-public abstract class Main extends Base {
-
- GL gl;
- GLU glu;
- GLUT glut = new GLUT();
-
- public static int[] d_8to24table = new int[256];
-
- int c_visible_lightmaps;
- int c_visible_textures;
-
- int registration_sequence;
-
- // this a hack for function pointer test
- // default disabled
- boolean qglColorTableEXT = false;
- boolean qglActiveTextureARB = false;
- boolean qglPointParameterfEXT = false;
- boolean qglLockArraysEXT = false;
- boolean qwglSwapIntervalEXT = false;
-
- // =================
- // abstract methods
- // =================
- protected abstract void Draw_GetPalette();
-
- abstract void GL_ImageList_f();
- abstract void GL_ScreenShot_f();
- abstract void GL_SetTexturePalette(int[] palette);
- abstract void GL_Strings_f();
-
- abstract void Mod_Modellist_f();
- abstract mleaf_t Mod_PointInLeaf(float[] point, model_t model);
-
- abstract boolean QGL_Init(String dll_name);
- abstract void QGL_Shutdown();
- abstract boolean GLimp_Init(int xpos, int ypos);
- abstract void GLimp_BeginFrame(float camera_separation);
- abstract int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen);
- abstract void GLimp_Shutdown();
- abstract void GLimp_EnableLogging(boolean enable);
- abstract void GLimp_LogNewFrame();
-
- abstract void GL_SetDefaultState();
-
- abstract void GL_InitImages();
- abstract void Mod_Init(); // Model.java
- abstract void R_InitParticleTexture(); // MIsc.java
- abstract void R_DrawAliasModel(entity_t e); // Mesh.java
- abstract void R_DrawBrushModel(entity_t e); // Surf.java
- abstract void Draw_InitLocal();
- abstract void R_LightPoint(float[] p, float[] color);
- abstract void R_PushDlights();
- abstract void R_MarkLeaves();
- abstract void R_DrawWorld();
- abstract void R_RenderDlights();
- abstract void R_DrawAlphaSurfaces();
-
- abstract void Mod_FreeAll();
-
- abstract void GL_ShutdownImages();
- abstract void GL_Bind(int texnum);
- abstract void GL_TexEnv(int mode);
- abstract void GL_TextureMode(String string);
- abstract void GL_TextureAlphaMode(String string);
- abstract void GL_TextureSolidMode(String string);
- abstract void GL_UpdateSwapInterval();
-
- /*
- ====================================================================
-
- from gl_rmain.c
-
- ====================================================================
- */
-
- // IMPORTED FUNCTIONS
- protected refimport_t ri = null;
-
- int GL_TEXTURE0 = GL.GL_TEXTURE0;
- int GL_TEXTURE1 = GL.GL_TEXTURE1;
-
- viddef_t vid = new viddef_t();
-
- model_t r_worldmodel;
-
- float gldepthmin, gldepthmax;
-
- glconfig_t gl_config = new glconfig_t();
- glstate_t gl_state = new glstate_t();
-
- image_t r_notexture; // use for bad textures
- image_t r_particletexture; // little dot for particles
-
- entity_t currententity;
- model_t currentmodel;
-
- cplane_t frustum[] = { new cplane_t(), new cplane_t(), new cplane_t(), new cplane_t()};
-
- int r_visframecount; // bumped when going to a new PVS
- int r_framecount; // used for dlight push checking
-
- int c_brush_polys, c_alias_polys;
-
- float v_blend[] = { 0, 0, 0, 0 }; // final blending color
-
- //
- // view origin
- //
- float[] vup = { 0, 0, 0 };
- float[] vpn = { 0, 0, 0 };
- float[] vright = { 0, 0, 0 };
- float[] r_origin = { 0, 0, 0 };
-
- float r_world_matrix[] = new float[16];
- float r_base_world_matrix[] = new float[16];
-
- //
- // screen size info
- //
- refdef_t r_newrefdef = new refdef_t();
-
- int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
-
- cvar_t r_norefresh;
- cvar_t r_drawentities;
- cvar_t r_drawworld;
- cvar_t r_speeds;
- cvar_t r_fullbright;
- cvar_t r_novis;
- cvar_t r_nocull;
- cvar_t r_lerpmodels;
- cvar_t r_lefthand;
-
- cvar_t r_lightlevel;
- // FIXME: This is a HACK to get the client's light level
-
- cvar_t gl_nosubimage;
- cvar_t gl_allow_software;
-
- cvar_t gl_vertex_arrays;
-
- cvar_t gl_particle_min_size;
- cvar_t gl_particle_max_size;
- cvar_t gl_particle_size;
- cvar_t gl_particle_att_a;
- cvar_t gl_particle_att_b;
- cvar_t gl_particle_att_c;
-
- cvar_t gl_ext_swapinterval;
- cvar_t gl_ext_palettedtexture;
- cvar_t gl_ext_multitexture;
- cvar_t gl_ext_pointparameters;
- cvar_t gl_ext_compiled_vertex_array;
-
- cvar_t gl_log;
- cvar_t gl_bitdepth;
- cvar_t gl_drawbuffer;
- cvar_t gl_driver;
- cvar_t gl_lightmap;
- cvar_t gl_shadows;
- cvar_t gl_mode;
- cvar_t gl_dynamic;
- cvar_t gl_monolightmap;
- cvar_t gl_modulate;
- cvar_t gl_nobind;
- cvar_t gl_round_down;
- cvar_t gl_picmip;
- cvar_t gl_skymip;
- cvar_t gl_showtris;
- cvar_t gl_ztrick;
- cvar_t gl_finish;
- cvar_t gl_clear;
- cvar_t gl_cull;
- cvar_t gl_polyblend;
- cvar_t gl_flashblend;
- cvar_t gl_playermip;
- cvar_t gl_saturatelighting;
- cvar_t gl_swapinterval;
- cvar_t gl_texturemode;
- cvar_t gl_texturealphamode;
- cvar_t gl_texturesolidmode;
- cvar_t gl_lockpvs;
-
- cvar_t gl_3dlabs_broken;
-
- cvar_t vid_fullscreen;
- cvar_t vid_gamma;
- cvar_t vid_ref;
-
- // ============================================================================
- // to port from gl_rmain.c, ...
- // ============================================================================
-
- /*
- =================
- R_CullBox
-
- Returns true if the box is completely outside the frustom
- =================
- */
- final boolean R_CullBox(float[] mins, float[] maxs) {
- assert(mins.length == 3 && maxs.length == 3) : "vec3_t bug";
-
- if (r_nocull.value != 0)
- return false;
-
- for (int i = 0; i < 4; i++) {
- if (Math3D.BoxOnPlaneSide(mins, maxs, frustum[i]) == 2)
- return true;
- }
- return false;
- }
-
- final void R_RotateForEntity(entity_t e) {
-
- gl.glTranslatef(e.origin[0], e.origin[1], e.origin[2]);
-
- gl.glRotatef(e.angles[1], 0, 0, 1);
- gl.glRotatef(-e.angles[0], 0, 1, 0);
- gl.glRotatef(-e.angles[2], 1, 0, 0);
- }
-
- /*
- =============================================================
-
- SPRITE MODELS
-
- =============================================================
- */
-
- /*
- =================
- R_DrawSpriteModel
-
- =================
- */
- void R_DrawSpriteModel(entity_t e) {
- float alpha = 1.0F;
- float[] point = { 0, 0, 0 };
-
- qfiles.dsprframe_t frame;
- qfiles.dsprite_t psprite;
-
- // don't even bother culling, because it's just a single
- // polygon without a surface cache
-
- psprite = (qfiles.dsprite_t) currentmodel.extradata;
-
- e.frame %= psprite.numframes;
-
- frame = psprite.frames[e.frame];
-
- if ((e.flags & Defines.RF_TRANSLUCENT) != 0)
- alpha = e.alpha;
-
- if (alpha != 1.0F)
- gl.glEnable(GL.GL_BLEND);
-
- gl.glColor4f(1, 1, 1, alpha);
-
- GL_Bind(currentmodel.skins[e.frame].texnum);
-
- GL_TexEnv(GL.GL_MODULATE);
-
- if (alpha == 1.0)
- gl.glEnable(GL.GL_ALPHA_TEST);
- else
- gl.glDisable(GL.GL_ALPHA_TEST);
-
- gl.glBegin(GL.GL_QUADS);
-
- gl.glTexCoord2f(0, 1);
- Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
- Math3D.VectorMA(point, -frame.origin_x, vright, point);
- gl.glVertex3f(point[0], point[1], point[2]);
-
- gl.glTexCoord2f(0, 0);
- Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
- Math3D.VectorMA(point, -frame.origin_x, vright, point);
- gl.glVertex3f(point[0], point[1], point[2]);
-
- gl.glTexCoord2f(1, 0);
- Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
- Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
- gl.glVertex3f(point[0], point[1], point[2]);
-
- gl.glTexCoord2f(1, 1);
- Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
- Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
- gl.glVertex3f(point[0], point[1], point[2]);
-
- gl.glEnd();
-
- gl.glDisable(GL.GL_ALPHA_TEST);
- GL_TexEnv(GL.GL_REPLACE);
-
- if (alpha != 1.0F)
- gl.glDisable(GL.GL_BLEND);
-
- gl.glColor4f(1, 1, 1, 1);
- }
-
- // ==================================================================================
-
- /*
- =============
- R_DrawNullModel
- =============
- cwei :-)
- */
- void R_DrawNullModel() {
- float[] shadelight = { 0, 0, 0 };
-
- if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
- // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F;
- shadelight[0] = shadelight[1] = shadelight[2] = 0.0F;
- shadelight[2] = 0.8F;
- }
- else {
- R_LightPoint(currententity.origin, shadelight);
- }
-
- gl.glPushMatrix();
- R_RotateForEntity(currententity);
-
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glColor3f(shadelight[0], shadelight[1], shadelight[2]);
-
- // this replaces the TRIANGLE_FAN
- glut.glutWireCube(gl, 20);
-
- /*
- gl.glBegin(GL.GL_TRIANGLE_FAN);
- gl.glVertex3f(0, 0, -16);
- int i;
- for (i=0 ; i<=4 ; i++) {
- gl.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f);
- }
- gl.glEnd();
-
- gl.glBegin(GL.GL_TRIANGLE_FAN);
- gl.glVertex3f (0, 0, 16);
- for (i=4 ; i>=0 ; i--) {
- gl.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f);
- }
- gl.glEnd();
- */
- gl.glColor3f(1, 1, 1);
- gl.glPopMatrix();
- gl.glEnable(GL.GL_TEXTURE_2D);
- }
-
- /*
- =============
- R_DrawEntitiesOnList
- =============
- */
- void R_DrawEntitiesOnList() {
- int i;
-
- if (r_drawentities.value == 0.0f)
- return;
-
- // draw non-transparent first
- for (i = 0; i < r_newrefdef.num_entities; i++) {
- currententity = r_newrefdef.entities[i];
- if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0)
- continue; // solid
-
- if ((currententity.flags & Defines.RF_BEAM) != 0) {
- R_DrawBeam(currententity);
- }
- else {
- currentmodel = currententity.model;
- if (currentmodel == null) {
- R_DrawNullModel();
- continue;
- }
- switch (currentmodel.type) {
- case mod_alias :
- R_DrawAliasModel(currententity);
- break;
- case mod_brush :
- R_DrawBrushModel(currententity);
- break;
- case mod_sprite :
- R_DrawSpriteModel(currententity);
- break;
- default :
- ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype");
- break;
- }
- }
- }
- // draw transparent entities
- // we could sort these if it ever becomes a problem...
- gl.glDepthMask(false); // no z writes
- for (i = 0; i < r_newrefdef.num_entities; i++) {
- currententity = r_newrefdef.entities[i];
- if ((currententity.flags & Defines.RF_TRANSLUCENT) == 0)
- continue; // solid
-
- if ((currententity.flags & Defines.RF_BEAM) != 0) {
- R_DrawBeam(currententity);
- }
- else {
- currentmodel = currententity.model;
-
- if (currentmodel == null) {
- R_DrawNullModel();
- continue;
- }
- switch (currentmodel.type) {
- case mod_alias :
- R_DrawAliasModel(currententity);
- break;
- case mod_brush :
- R_DrawBrushModel(currententity);
- break;
- case mod_sprite :
- R_DrawSpriteModel(currententity);
- break;
- default :
- ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype");
- break;
- }
- }
- }
- gl.glDepthMask(true); // back to writing
- }
-
- /*
- ** GL_DrawParticles
- **
- */
- void GL_DrawParticles(int num_particles) {
- float[] up = { 0, 0, 0 };
- float[] right = { 0, 0, 0 };
- float scale;
- int color;
-
- float origin_x, origin_y, origin_z;
-
- Math3D.VectorScale(vup, 1.5f, up);
- Math3D.VectorScale(vright, 1.5f, right);
-
- GL_Bind(r_particletexture.texnum);
- gl.glDepthMask(false); // no z buffering
- gl.glEnable(GL.GL_BLEND);
- GL_TexEnv(GL.GL_MODULATE);
-
- gl.glBegin(GL.GL_TRIANGLES);
-
- FloatBuffer sourceVertices = particle_t.vertexArray;
- IntBuffer sourceColors = particle_t.colorArray;
- for (int j = 0, i = 0; i < num_particles; i++) {
- origin_x = sourceVertices.get(j++);
- origin_y = sourceVertices.get(j++);
- origin_z = sourceVertices.get(j++);
-
- // hack a scale up to keep particles from disapearing
- scale =
- (origin_x - r_origin[0]) * vpn[0]
- + (origin_y - r_origin[1]) * vpn[1]
- + (origin_z - r_origin[2]) * vpn[2];
-
- scale = (scale < 20) ? 1 : 1 + scale * 0.004f;
-
- color = sourceColors.get(i);
- gl.glColor4ub(
- (byte)((color >> 0) & 0xFF),
- (byte)((color >> 8) & 0xFF),
- (byte)((color >> 16) & 0xFF),
- (byte)((color >> 24) & 0xFF)
- );
- // first vertex
- gl.glTexCoord2f(0.0625f, 0.0625f);
- gl.glVertex3f(origin_x, origin_y, origin_z);
- // second vertex
- gl.glTexCoord2f(1.0625f, 0.0625f);
- gl.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
- // third vertex
- gl.glTexCoord2f(0.0625f, 1.0625f);
- gl.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
- }
- gl.glEnd();
-
- gl.glDisable(GL.GL_BLEND);
- gl.glColor4f(1, 1, 1, 1);
- gl.glDepthMask(true); // back to normal Z buffering
- GL_TexEnv(GL.GL_REPLACE);
- }
-
- /*
- ===============
- R_DrawParticles
- ===============
- */
- void R_DrawParticles() {
-
- if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) {
-
- //gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
- gl.glVertexPointer(3, GL.GL_FLOAT, 0, particle_t.vertexArray);
- gl.glEnableClientState(GL.GL_COLOR_ARRAY);
- gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, particle_t.colorArray);
-
- gl.glDepthMask(false);
- gl.glEnable(GL.GL_BLEND);
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glPointSize(gl_particle_size.value);
-
- gl.glDrawArrays(GL.GL_POINTS, 0, r_newrefdef.num_particles);
-
- gl.glDisableClientState(GL.GL_COLOR_ARRAY);
- //gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
-
- gl.glDisable(GL.GL_BLEND);
- gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- gl.glDepthMask(true);
- gl.glEnable(GL.GL_TEXTURE_2D);
-
- }
- else {
- GL_DrawParticles(r_newrefdef.num_particles);
- }
- }
-
- /*
- ============
- R_PolyBlend
- ============
- */
- void R_PolyBlend() {
- if (gl_polyblend.value == 0.0f)
- return;
-
- if (v_blend[3] == 0.0f)
- return;
-
- gl.glDisable(GL.GL_ALPHA_TEST);
- gl.glEnable(GL.GL_BLEND);
- gl.glDisable(GL.GL_DEPTH_TEST);
- gl.glDisable(GL.GL_TEXTURE_2D);
-
- gl.glLoadIdentity();
-
- // FIXME: get rid of these
- gl.glRotatef(-90, 1, 0, 0); // put Z going up
- gl.glRotatef(90, 0, 0, 1); // put Z going up
-
- gl.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
-
- gl.glBegin(GL.GL_QUADS);
-
- gl.glVertex3f(10, 100, 100);
- gl.glVertex3f(10, -100, 100);
- gl.glVertex3f(10, -100, -100);
- gl.glVertex3f(10, 100, -100);
- gl.glEnd();
-
- gl.glDisable(GL.GL_BLEND);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glEnable(GL.GL_ALPHA_TEST);
-
- gl.glColor4f(1, 1, 1, 1);
- }
-
- // =======================================================================
-
- int SignbitsForPlane(cplane_t out) {
- // for fast box on planeside test
- int bits = 0;
- for (int j = 0; j < 3; j++) {
- if (out.normal[j] < 0)
- bits |= (1 << j);
- }
- return bits;
- }
-
- void R_SetFrustum() {
- // rotate VPN right by FOV_X/2 degrees
- Math3D.RotatePointAroundVector(frustum[0].normal, vup, vpn, - (90f - r_newrefdef.fov_x / 2f));
- // rotate VPN left by FOV_X/2 degrees
- Math3D.RotatePointAroundVector(frustum[1].normal, vup, vpn, 90f - r_newrefdef.fov_x / 2f);
- // rotate VPN up by FOV_X/2 degrees
- Math3D.RotatePointAroundVector(frustum[2].normal, vright, vpn, 90f - r_newrefdef.fov_y / 2f);
- // rotate VPN down by FOV_X/2 degrees
- Math3D.RotatePointAroundVector(frustum[3].normal, vright, vpn, - (90f - r_newrefdef.fov_y / 2f));
-
- for (int i = 0; i < 4; i++) {
- frustum[i].type = Defines.PLANE_ANYZ;
- frustum[i].dist = Math3D.DotProduct(r_origin, frustum[i].normal);
- frustum[i].signbits = (byte) SignbitsForPlane(frustum[i]);
- }
- }
-
- // =======================================================================
-
- /*
- ===============
- R_SetupFrame
- ===============
- */
- void R_SetupFrame() {
- int i;
- mleaf_t leaf;
-
- r_framecount++;
-
- // build the transformation matrix for the given view angles
- Math3D.VectorCopy(r_newrefdef.vieworg, r_origin);
-
- Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup);
-
- // current viewcluster
- if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) {
- r_oldviewcluster = r_viewcluster;
- r_oldviewcluster2 = r_viewcluster2;
- leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
- r_viewcluster = r_viewcluster2 = leaf.cluster;
-
- // check above and below so crossing solid water doesn't draw wrong
- if (leaf.contents == 0) { // look down a bit
- float[] temp = { 0, 0, 0 };
-
- Math3D.VectorCopy(r_origin, temp);
- temp[2] -= 16;
- leaf = Mod_PointInLeaf(temp, r_worldmodel);
- if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
- r_viewcluster2 = leaf.cluster;
- }
- else { // look up a bit
- float[] temp = { 0, 0, 0 };
-
- Math3D.VectorCopy(r_origin, temp);
- temp[2] += 16;
- leaf = Mod_PointInLeaf(temp, r_worldmodel);
- if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
- r_viewcluster2 = leaf.cluster;
- }
- }
-
- for (i = 0; i < 4; i++)
- v_blend[i] = r_newrefdef.blend[i];
-
- c_brush_polys = 0;
- c_alias_polys = 0;
-
- // clear out the portion of the screen that the NOWORLDMODEL defines
- if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) {
- gl.glEnable(GL.GL_SCISSOR_TEST);
- gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
- gl.glScissor(
- r_newrefdef.x,
- vid.height - r_newrefdef.height - r_newrefdef.y,
- r_newrefdef.width,
- r_newrefdef.height);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- gl.glClearColor(1.0f, 0.0f, 0.5f, 0.5f);
- gl.glDisable(GL.GL_SCISSOR_TEST);
- }
- }
-
- void MYgluPerspective(double fovy, double aspect, double zNear, double zFar) {
- double xmin, xmax, ymin, ymax;
-
- ymax = zNear * Math.tan(fovy * Math.PI / 360.0);
- ymin = -ymax;
-
- xmin = ymin * aspect;
- xmax = ymax * aspect;
-
- xmin += - (2 * gl_state.camera_separation) / zNear;
- xmax += - (2 * gl_state.camera_separation) / zNear;
-
- gl.glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
- }
-
- /*
- =============
- R_SetupGL
- =============
- */
- void R_SetupGL() {
- float screenaspect;
- int x, x2, y2, y, w, h;
-
- //
- // set up viewport
- //
- x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width);
- x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
- y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height);
- y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height);
-
- w = x2 - x;
- h = y - y2;
-
- gl.glViewport(x, y2, w, h);
-
- //
- // set up projection matrix
- //
- screenaspect = (float) r_newrefdef.width / r_newrefdef.height;
- gl.glMatrixMode(GL.GL_PROJECTION);
- gl.glLoadIdentity();
- MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096);
-
- gl.glCullFace(GL.GL_FRONT);
-
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glLoadIdentity();
-
- gl.glRotatef(-90, 1, 0, 0); // put Z going up
- gl.glRotatef(90, 0, 0, 1); // put Z going up
- gl.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0);
- gl.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0);
- gl.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1);
- gl.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]);
-
- gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, r_world_matrix);
-
- //
- // set drawing parms
- //
- if (gl_cull.value != 0.0f)
- gl.glEnable(GL.GL_CULL_FACE);
- else
- gl.glDisable(GL.GL_CULL_FACE);
-
- gl.glDisable(GL.GL_BLEND);
- gl.glDisable(GL.GL_ALPHA_TEST);
- gl.glEnable(GL.GL_DEPTH_TEST);
- }
-
- /*
- =============
- R_Clear
- =============
- */
- int trickframe = 0;
-
- void R_Clear() {
- if (gl_ztrick.value != 0.0f) {
-
- if (gl_clear.value != 0.0f) {
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- }
-
- trickframe++;
- if ((trickframe & 1) != 0) {
- gldepthmin = 0;
- gldepthmax = 0.49999f;
- gl.glDepthFunc(GL.GL_LEQUAL);
- }
- else {
- gldepthmin = 1;
- gldepthmax = 0.5f;
- gl.glDepthFunc(GL.GL_GEQUAL);
- }
- }
- else {
- if (gl_clear.value != 0.0f)
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- else
- gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
-
- gldepthmin = 0;
- gldepthmax = 1;
- gl.glDepthFunc(GL.GL_LEQUAL);
- }
- gl.glDepthRange(gldepthmin, gldepthmax);
- }
-
- void R_Flash() {
- R_PolyBlend();
- }
-
- /*
- ================
- R_RenderView
-
- r_newrefdef must be set before the first call
- ================
- */
- void R_RenderView(refdef_t fd) {
-
- if (r_norefresh.value != 0.0f)
- return;
-
- r_newrefdef = fd;
-
- // included by cwei
- if (r_newrefdef == null) {
- ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null");
- }
-
- if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0)
- ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel");
-
- if (r_speeds.value != 0.0f) {
- c_brush_polys = 0;
- c_alias_polys = 0;
- }
-
- R_PushDlights();
-
- if (gl_finish.value != 0.0f)
- gl.glFinish();
-
- R_SetupFrame();
-
- R_SetFrustum();
-
- R_SetupGL();
-
- R_MarkLeaves(); // done here so we know if we're in water
-
- R_DrawWorld();
-
- R_DrawEntitiesOnList();
-
- R_RenderDlights();
-
- R_DrawParticles();
-
- R_DrawAlphaSurfaces();
-
- R_Flash();
-
- if (r_speeds.value != 0.0f) {
- ri.Con_Printf(
- Defines.PRINT_ALL,
- "%4i wpoly %4i epoly %i tex %i lmaps\n",
- new Vargs(4).add(c_brush_polys).add(c_alias_polys).add(c_visible_textures).add(c_visible_lightmaps));
- }
- }
-
- void R_SetGL2D() {
- // set 2D virtual screen size
- gl.glViewport(0, 0, vid.width, vid.height);
- gl.glMatrixMode(GL.GL_PROJECTION);
- gl.glLoadIdentity();
- gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glLoadIdentity();
- gl.glDisable(GL.GL_DEPTH_TEST);
- gl.glDisable(GL.GL_CULL_FACE);
- gl.glDisable(GL.GL_BLEND);
- gl.glEnable(GL.GL_ALPHA_TEST);
- gl.glColor4f(1, 1, 1, 1);
- }
-
- /*
- ====================
- R_SetLightLevel
-
- ====================
- */
- void R_SetLightLevel() {
- float[] shadelight = { 0, 0, 0 };
-
- if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0)
- return;
-
- // save off light value for server to look at (BIG HACK!)
-
- R_LightPoint(r_newrefdef.vieworg, shadelight);
-
- // pick the greatest component, which should be the same
- // as the mono value returned by software
- if (shadelight[0] > shadelight[1]) {
- if (shadelight[0] > shadelight[2])
- r_lightlevel.value = 150 * shadelight[0];
- else
- r_lightlevel.value = 150 * shadelight[2];
- }
- else {
- if (shadelight[1] > shadelight[2])
- r_lightlevel.value = 150 * shadelight[1];
- else
- r_lightlevel.value = 150 * shadelight[2];
- }
- }
-
- /*
- @@@@@@@@@@@@@@@@@@@@@
- R_RenderFrame
-
- @@@@@@@@@@@@@@@@@@@@@
- */
- protected void R_RenderFrame(refdef_t fd) {
- R_RenderView(fd);
- R_SetLightLevel();
- R_SetGL2D();
- }
-
- protected void R_Register() {
- r_lefthand = ri.Cvar_Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE);
- r_norefresh = ri.Cvar_Get("r_norefresh", "0", 0);
- r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0);
- r_drawentities = ri.Cvar_Get("r_drawentities", "1", 0);
- r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0);
- r_novis = ri.Cvar_Get("r_novis", "0", 0);
- r_nocull = ri.Cvar_Get("r_nocull", "0", 0);
- r_lerpmodels = ri.Cvar_Get("r_lerpmodels", "1", 0);
- r_speeds = ri.Cvar_Get("r_speeds", "0", 0);
-
- r_lightlevel = ri.Cvar_Get("r_lightlevel", "1", 0);
-
- gl_nosubimage = ri.Cvar_Get("gl_nosubimage", "0", 0);
- gl_allow_software = ri.Cvar_Get("gl_allow_software", "0", 0);
-
- gl_particle_min_size = ri.Cvar_Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE);
- gl_particle_max_size = ri.Cvar_Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE);
- gl_particle_size = ri.Cvar_Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE);
- gl_particle_att_a = ri.Cvar_Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE);
- gl_particle_att_b = ri.Cvar_Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE);
- gl_particle_att_c = ri.Cvar_Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE);
-
- gl_modulate = ri.Cvar_Get("gl_modulate", "1", Globals.CVAR_ARCHIVE);
- gl_log = ri.Cvar_Get("gl_log", "0", 0);
- gl_bitdepth = ri.Cvar_Get("gl_bitdepth", "0", 0);
- gl_mode = ri.Cvar_Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480
- gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
- gl_shadows = ri.Cvar_Get("gl_shadows", "0", Globals.CVAR_ARCHIVE);
- gl_dynamic = ri.Cvar_Get("gl_dynamic", "1", 0);
- gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
- gl_round_down = ri.Cvar_Get("gl_round_down", "1", 0);
- gl_picmip = ri.Cvar_Get("gl_picmip", "0", 0);
- gl_skymip = ri.Cvar_Get("gl_skymip", "0", 0);
- gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0);
- gl_ztrick = ri.Cvar_Get("gl_ztrick", "0", 0);
- gl_finish = ri.Cvar_Get("gl_finish", "0", Globals.CVAR_ARCHIVE);
- gl_clear = ri.Cvar_Get("gl_clear", "0", 0);
- gl_cull = ri.Cvar_Get("gl_cull", "1", 0);
- gl_polyblend = ri.Cvar_Get("gl_polyblend", "1", 0);
- gl_flashblend = ri.Cvar_Get("gl_flashblend", "0", 0);
- gl_playermip = ri.Cvar_Get("gl_playermip", "0", 0);
- gl_monolightmap = ri.Cvar_Get("gl_monolightmap", "0", 0);
- gl_driver = ri.Cvar_Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE);
- gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE);
- gl_texturealphamode = ri.Cvar_Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE);
- gl_texturesolidmode = ri.Cvar_Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE);
- gl_lockpvs = ri.Cvar_Get("gl_lockpvs", "0", 0);
-
- gl_vertex_arrays = ri.Cvar_Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE);
-
- gl_ext_swapinterval = ri.Cvar_Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE);
- gl_ext_palettedtexture = ri.Cvar_Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE);
- gl_ext_multitexture = ri.Cvar_Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE);
- gl_ext_pointparameters = ri.Cvar_Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE);
- gl_ext_compiled_vertex_array = ri.Cvar_Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE);
-
- gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
- gl_swapinterval = ri.Cvar_Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE);
-
- gl_saturatelighting = ri.Cvar_Get("gl_saturatelighting", "0", 0);
-
- gl_3dlabs_broken = ri.Cvar_Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE);
-
- vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE);
- vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE);
- vid_ref = ri.Cvar_Get("vid_ref", "fastjogl", Globals.CVAR_ARCHIVE);
-
- ri.Cmd_AddCommand("imagelist", new xcommand_t() {
- public void execute() {
- GL_ImageList_f();
- }
- });
-
- ri.Cmd_AddCommand("screenshot", new xcommand_t() {
- public void execute() {
- GL_ScreenShot_f();
- }
- });
- ri.Cmd_AddCommand("modellist", new xcommand_t() {
- public void execute() {
- Mod_Modellist_f();
- }
- });
- ri.Cmd_AddCommand("gl_strings", new xcommand_t() {
- public void execute() {
- GL_Strings_f();
- }
- });
- }
-
- /*
- ==================
- R_SetMode
- ==================
- */
- protected boolean R_SetMode() {
-
- int err; // enum rserr_t
- boolean fullscreen;
-
-// if (vid_fullscreen.modified && !gl_config.allow_cds) {
-// ri.Con_Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n");
-// ri.Cvar_SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f);
-// vid_fullscreen.modified = false;
-// }
-
- fullscreen = (vid_fullscreen.value > 0.0f);
-
- vid_fullscreen.modified = false;
- gl_mode.modified = false;
-
- Dimension dim = new Dimension(vid.width, vid.height);
-
- if ((err = GLimp_SetMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) {
- gl_state.prev_mode = (int) gl_mode.value;
- }
- else {
- if (err == rserr_invalid_fullscreen) {
- ri.Cvar_SetValue("vid_fullscreen", 0);
- vid_fullscreen.modified = false;
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
- if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok)
- return true;
- }
- else if (err == rserr_invalid_mode) {
- ri.Cvar_SetValue("gl_mode", gl_state.prev_mode);
- gl_mode.modified = false;
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n");
- }
-
- // try setting it back to something safe
- if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) {
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
- return false;
- }
- }
- return true;
- }
-
- /*
- ===============
- R_Init
- ===============
- */
- float[] r_turbsin = new float[256];
-
- protected boolean R_Init(int vid_xpos, int vid_ypos) {
-
- assert(Warp.SIN.length == 256) : "warpsin table bug";
-
- // fill r_turbsin
- for (int j = 0; j < 256; j++) {
- r_turbsin[j] = Warp.SIN[j] * 0.5f;
- }
-
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n');
-
- Draw_GetPalette();
-
- R_Register();
-
- // initialize our QGL dynamic bindings
- if (!QGL_Init(gl_driver.string)) {
- QGL_Shutdown();
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not load \"" + gl_driver.string + "\"\n");
- return false;
- }
-
- // initialize OS-specific parts of OpenGL
- if (!GLimp_Init(vid_xpos, vid_ypos)) {
- QGL_Shutdown();
- return false;
- }
-
- // set our "safe" modes
- gl_state.prev_mode = 3;
-
- // create the window and set up the context
- if (!R_SetMode()) {
- QGL_Shutdown();
- ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n");
- return false;
- }
- return true;
- }
-
- boolean R_Init2() {
- ri.Vid_MenuInit();
-
- /*
- ** get our various GL strings
- */
- gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR);
- ri.Con_Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n');
- gl_config.renderer_string = gl.glGetString(GL.GL_RENDERER);
- ri.Con_Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n');
- gl_config.version_string = gl.glGetString(GL.GL_VERSION);
- ri.Con_Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n');
- gl_config.extensions_string = gl.glGetString(GL.GL_EXTENSIONS);
- ri.Con_Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n');
-
- String renderer_buffer = gl_config.renderer_string.toLowerCase();
- String vendor_buffer = gl_config.vendor_string.toLowerCase();
-
- if (renderer_buffer.indexOf("voodoo") >= 0) {
- if (renderer_buffer.indexOf("rush") < 0)
- gl_config.renderer = GL_RENDERER_VOODOO;
- else
- gl_config.renderer = GL_RENDERER_VOODOO_RUSH;
- }
- else if (vendor_buffer.indexOf("sgi") >= 0)
- gl_config.renderer = GL_RENDERER_SGI;
- else if (renderer_buffer.indexOf("permedia") >= 0)
- gl_config.renderer = GL_RENDERER_PERMEDIA2;
- else if (renderer_buffer.indexOf("glint") >= 0)
- gl_config.renderer = GL_RENDERER_GLINT_MX;
- else if (renderer_buffer.indexOf("glzicd") >= 0)
- gl_config.renderer = GL_RENDERER_REALIZM;
- else if (renderer_buffer.indexOf("gdi") >= 0)
- gl_config.renderer = GL_RENDERER_MCD;
- else if (renderer_buffer.indexOf("pcx2") >= 0)
- gl_config.renderer = GL_RENDERER_PCX2;
- else if (renderer_buffer.indexOf("verite") >= 0)
- gl_config.renderer = GL_RENDERER_RENDITION;
- else
- gl_config.renderer = GL_RENDERER_OTHER;
-
- String monolightmap = gl_monolightmap.string.toUpperCase();
- if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') {
- if (gl_config.renderer == GL_RENDERER_PERMEDIA2) {
- ri.Cvar_Set("gl_monolightmap", "A");
- ri.Con_Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n");
- }
- else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) {
- ri.Cvar_Set("gl_monolightmap", "0");
- }
- else {
- ri.Cvar_Set("gl_monolightmap", "0");
- }
- }
-
- // power vr can't have anything stay in the framebuffer, so
- // the screen needs to redraw the tiled background every frame
- if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) {
- ri.Cvar_Set("scr_drawall", "1");
- }
- else {
- ri.Cvar_Set("scr_drawall", "0");
- }
-
- // #ifdef __linux__
- ri.Cvar_SetValue("gl_finish", 1);
- // #endif
-
- // MCD has buffering issues
- if (gl_config.renderer == GL_RENDERER_MCD) {
- ri.Cvar_SetValue("gl_finish", 1);
- }
-
- if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) {
- if (gl_3dlabs_broken.value != 0.0f)
- gl_config.allow_cds = false;
- else
- gl_config.allow_cds = true;
- }
- else {
- gl_config.allow_cds = true;
- }
-
- if (gl_config.allow_cds)
- ri.Con_Printf(Defines.PRINT_ALL, "...allowing CDS\n");
- else
- ri.Con_Printf(Defines.PRINT_ALL, "...disabling CDS\n");
-
- /*
- ** grab extensions
- */
- if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0
- || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) {
- ri.Con_Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n");
- // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" );
- if (gl_ext_compiled_vertex_array.value != 0.0f)
- qglLockArraysEXT = true;
- else
- qglLockArraysEXT = false;
- // qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" );
- //qglUnlockArraysEXT = true;
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n");
- qglLockArraysEXT = false;
- }
-
- if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) {
- qwglSwapIntervalEXT = true;
- ri.Con_Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n");
- } else {
- qwglSwapIntervalEXT = false;
- ri.Con_Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n");
- }
-
- if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) {
- if (gl_ext_pointparameters.value != 0.0f) {
- // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" );
- qglPointParameterfEXT = true;
- // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" );
- ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n");
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n");
- }
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n");
- }
-
- // #ifdef __linux__
- // if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" ))
- // {
- // if ( gl_ext_palettedtexture->value )
- // {
- // ri.Con_Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" );
- // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" );
- //// qglColorTableEXT = Fake_glColorTableEXT;
- // }
- // else
- // {
- // ri.Con_Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" );
- // }
- // }
- // else
- // {
- // ri.Con_Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" );
- // }
- // #endif
-
- if (!qglColorTableEXT
- && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0
- && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) {
- if (gl_ext_palettedtexture.value != 0.0f) {
- ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n");
- qglColorTableEXT = false; // true; TODO jogl bug
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
- qglColorTableEXT = false;
- }
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n");
- }
-
- if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) {
- ri.Con_Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n");
- qglActiveTextureARB = true;
- GL_TEXTURE0 = GL.GL_TEXTURE0_ARB;
- GL_TEXTURE1 = GL.GL_TEXTURE1_ARB;
- }
- else {
- ri.Con_Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n");
- }
-
- if (!(qglActiveTextureARB))
- return false;
-
- GL_SetDefaultState();
-
- GL_InitImages();
- Mod_Init();
- R_InitParticleTexture();
- Draw_InitLocal();
-
- int err = gl.glGetError();
- if (err != GL.GL_NO_ERROR)
- ri.Con_Printf(
- Defines.PRINT_ALL,
- "glGetError() = 0x%x\n\t%s\n",
- new Vargs(2).add(err).add("" + gl.glGetString(err)));
-
- return true;
- }
-
- /*
- ===============
- R_Shutdown
- ===============
- */
- protected void R_Shutdown() {
- ri.Cmd_RemoveCommand("modellist");
- ri.Cmd_RemoveCommand("screenshot");
- ri.Cmd_RemoveCommand("imagelist");
- ri.Cmd_RemoveCommand("gl_strings");
-
- Mod_FreeAll();
-
- GL_ShutdownImages();
-
- /*
- * shut down OS specific OpenGL stuff like contexts, etc.
- */
- GLimp_Shutdown();
-
- /*
- * shutdown our QGL subsystem
- */
- QGL_Shutdown();
- }
-
- /*
- @@@@@@@@@@@@@@@@@@@@@
- R_BeginFrame
- @@@@@@@@@@@@@@@@@@@@@
- */
- protected void R_BeginFrame(float camera_separation) {
-
- gl_state.camera_separation = camera_separation;
-
- /*
- ** change modes if necessary
- */
- if (gl_mode.modified || vid_fullscreen.modified) {
- // FIXME: only restart if CDS is required
- cvar_t ref;
-
- ref = ri.Cvar_Get("vid_ref", "fastjogl", 0);
- ref.modified = true;
- }
-
- if (gl_log.modified) {
- GLimp_EnableLogging((gl_log.value != 0.0f));
- gl_log.modified = false;
- }
-
- if (gl_log.value != 0.0f) {
- GLimp_LogNewFrame();
- }
-
- /*
- ** update 3Dfx gamma -- it is expected that a user will do a vid_restart
- ** after tweaking this value
- */
- if (vid_gamma.modified) {
- vid_gamma.modified = false;
-
- if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) {
- // wird erstmal nicht gebraucht
-
- /*
- char envbuffer[1024];
- float g;
-
- g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
- Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g );
- putenv( envbuffer );
- Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
- putenv( envbuffer );
- */
- ri.Con_Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt");
- }
- }
-
- GLimp_BeginFrame(camera_separation);
-
- /*
- ** go into 2D mode
- */
- gl.glViewport(0, 0, vid.width, vid.height);
- gl.glMatrixMode(GL.GL_PROJECTION);
- gl.glLoadIdentity();
- gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glLoadIdentity();
- gl.glDisable(GL.GL_DEPTH_TEST);
- gl.glDisable(GL.GL_CULL_FACE);
- gl.glDisable(GL.GL_BLEND);
- gl.glEnable(GL.GL_ALPHA_TEST);
- gl.glColor4f(1, 1, 1, 1);
-
- /*
- ** draw buffer stuff
- */
- if (gl_drawbuffer.modified) {
- gl_drawbuffer.modified = false;
-
- if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) {
- if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT"))
- gl.glDrawBuffer(GL.GL_FRONT);
- else
- gl.glDrawBuffer(GL.GL_BACK);
- }
- }
-
- /*
- ** texturemode stuff
- */
- if (gl_texturemode.modified) {
- GL_TextureMode(gl_texturemode.string);
- gl_texturemode.modified = false;
- }
-
- if (gl_texturealphamode.modified) {
- GL_TextureAlphaMode(gl_texturealphamode.string);
- gl_texturealphamode.modified = false;
- }
-
- if (gl_texturesolidmode.modified) {
- GL_TextureSolidMode(gl_texturesolidmode.string);
- gl_texturesolidmode.modified = false;
- }
-
- /*
- ** swapinterval stuff
- */
- GL_UpdateSwapInterval();
-
- //
- // clear screen if desired
- //
- R_Clear();
- }
-
- int[] r_rawpalette = new int[256];
-
- /*
- =============
- R_SetPalette
- =============
- */
- protected void R_SetPalette(byte[] palette) {
- // 256 RGB values (768 bytes)
- // or null
- int i;
- int color = 0;
-
- if (palette != null) {
- int j =0;
- for (i = 0; i < 256; i++) {
- color = (palette[j++] & 0xFF) << 0;
- color |= (palette[j++] & 0xFF) << 8;
- color |= (palette[j++] & 0xFF) << 16;
- color |= 0xFF000000;
- r_rawpalette[i] = color;
- }
- }
- else {
- for (i = 0; i < 256; i++) {
- r_rawpalette[i] = d_8to24table[i] | 0xff000000;
- }
- }
- GL_SetTexturePalette(r_rawpalette);
-
- gl.glClearColor(0, 0, 0, 0);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gl.glClearColor(1f, 0f, 0.5f, 0.5f);
- }
-
- static final int NUM_BEAM_SEGS = 6;
- float[][] start_points = new float[NUM_BEAM_SEGS][3];
- // array of vec3_t
- float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t
-
- /*
- ** R_DrawBeam
- */
- void R_DrawBeam(entity_t e) {
-
- int i;
- float r, g, b;
-
- float[] perpvec = { 0, 0, 0 }; // vec3_t
- float[] direction = { 0, 0, 0 }; // vec3_t
- float[] normalized_direction = { 0, 0, 0 }; // vec3_t
-
- float[] oldorigin = { 0, 0, 0 }; // vec3_t
- float[] origin = { 0, 0, 0 }; // vec3_t
-
- oldorigin[0] = e.oldorigin[0];
- oldorigin[1] = e.oldorigin[1];
- oldorigin[2] = e.oldorigin[2];
-
- origin[0] = e.origin[0];
- origin[1] = e.origin[1];
- origin[2] = e.origin[2];
-
- normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
- normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
- normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
-
- if (Math3D.VectorNormalize(normalized_direction) == 0.0f)
- return;
-
- Math3D.PerpendicularVector(perpvec, normalized_direction);
- Math3D.VectorScale(perpvec, e.frame / 2, perpvec);
-
- for (i = 0; i < 6; i++) {
- Math3D.RotatePointAroundVector(
- start_points[i],
- normalized_direction,
- perpvec,
- (360.0f / NUM_BEAM_SEGS) * i);
-
- Math3D.VectorAdd(start_points[i], origin, start_points[i]);
- Math3D.VectorAdd(start_points[i], direction, end_points[i]);
- }
-
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glEnable(GL.GL_BLEND);
- gl.glDepthMask(false);
-
- r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF;
- g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF;
- b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF;
-
- r *= 1 / 255.0f;
- g *= 1 / 255.0f;
- b *= 1 / 255.0f;
-
- gl.glColor4f(r, g, b, e.alpha);
-
- gl.glBegin(GL.GL_TRIANGLE_STRIP);
-
- float[] v;
-
- for (i = 0; i < NUM_BEAM_SEGS; i++) {
- v = start_points[i];
- gl.glVertex3f(v[0], v[1], v[2]);
- v = end_points[i];
- gl.glVertex3f(v[0], v[1], v[2]);
- v = start_points[(i + 1) % NUM_BEAM_SEGS];
- gl.glVertex3f(v[0], v[1], v[2]);
- v = end_points[(i + 1) % NUM_BEAM_SEGS];
- gl.glVertex3f(v[0], v[1], v[2]);
- }
- gl.glEnd();
-
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glDisable(GL.GL_BLEND);
- gl.glDepthMask(true);
- }
-
-}
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
deleted file mode 100644
index e7da997..0000000
--- a/src/jake2/render/fastjogl/Mesh.java
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
- * Mesh.java
- * Copyright (C) 2003
- *
- * $Id: Mesh.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-
-import net.java.games.gluegen.runtime.BufferFactory;
-import net.java.games.jogl.GL;
-import net.java.games.jogl.util.BufferUtils;
-import jake2.Defines;
-import jake2.Globals;
-import jake2.client.entity_t;
-import jake2.qcommon.qfiles;
-import jake2.render.image_t;
-import jake2.util.Math3D;
-
-/**
- * Mesh
- *
- * @author cwei
- */
-public abstract class Mesh extends Light {
-
- // g_mesh.c: triangle model functions
-
- /*
- =============================================================
-
- ALIAS MODELS
-
- =============================================================
- */
-
- static final int NUMVERTEXNORMALS = 162;
-
- float[][] r_avertexnormals = Anorms.VERTEXNORMALS;
- float[] shadevector = {0, 0, 0};
- float[] shadelight = {0, 0, 0};
-
- // precalculated dot products for quantized angles
- static final int SHADEDOT_QUANT = 16;
-
- float[][] r_avertexnormal_dots = Anorms.VERTEXNORMAL_DOTS;
-
- float[] shadedots = r_avertexnormal_dots[0];
-
- void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, FloatBuffer lerp, float[] move, float[] frontv, float[] backv )
- {
- int i;
- int lerpIndex = 0;
-
- int[] ovv;
- int[] vv;
-
- //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM
- 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 = 0;
- for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
- {
- normal = r_avertexnormals[verts[i].lightnormalindex];
- ovv = ov[i].v;
- vv = v[i].v;
-
- lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
- lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
- lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
- j+=3;
- }
- }
- else
- {
- int j = 0;
- for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
- {
- ovv = ov[i].v;
- vv = v[i].v;
-
- lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]);
- lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]);
- lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]);
- j+=3;
- }
- }
- }
-
- FloatBuffer colorArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 4);
- FloatBuffer vertexArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 3);
- FloatBuffer textureArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 2);
- boolean isFilled = false;
- float[] tmpVec = {0, 0, 0};
- float[][] vectors = {
- {0, 0, 0}, {0, 0, 0}, {0, 0, 0} // 3 mal vec3_t
- };
-
- /*
- =============
- GL_DrawAliasFrameLerp
-
- interpolates between two frames and origins
- FIXME: batch lerp all vertexes
- =============
- */
-
- void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp)
- {
- float l;
- qfiles.daliasframe_t frame, oldframe;
- qfiles.dtrivertx_t[] v, ov, verts;
-
- int[] order;
- int orderIndex = 0;
- int count;
-
- float frontlerp;
- float alpha;
-
- float[] move = {0, 0, 0}; // vec3_t
- float[] delta = {0, 0, 0}; // vec3_t
-
- float[] frontv = {0, 0, 0}; // vec3_t
- float[] backv = {0, 0, 0}; // vec3_t
-
- int i;
- int index_xyz;
-
- frame = paliashdr.aliasFrames[currententity.frame];
-
- verts = v = frame.verts;
-
- oldframe = paliashdr.aliasFrames[currententity.oldframe];
-
- ov = oldframe.verts;
-
- if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0)
- alpha = currententity.alpha;
- else
- alpha = 1.0f;
-
- // PMM - added double shell
- 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)
- gl.glDisable( GL.GL_TEXTURE_2D );
-
- frontlerp = 1.0f - backlerp;
-
- // move should be the delta back to the previous frame * backlerp
- Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta);
- Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]);
-
- move[0] = Math3D.DotProduct (delta, vectors[0]); // forward
- move[1] = -Math3D.DotProduct (delta, vectors[1]); // left
- move[2] = Math3D.DotProduct (delta, vectors[2]); // up
-
- Math3D.VectorAdd (move, oldframe.translate, move);
-
- for (i=0 ; i<3 ; i++)
- {
- move[i] = backlerp*move[i] + frontlerp*frame.translate[i];
- }
-
- for (i=0 ; i<3 ; i++)
- {
- frontv[i] = frontlerp*frame.scale[i];
- backv[i] = backlerp*oldframe.scale[i];
- }
-
- // ab hier wird optimiert
-
- GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv );
-
- //gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
- gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf );
-
- // PMM - added double damage shell
- 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)
- {
- gl.glColor4f( shadelight[0], shadelight[1], shadelight[2], alpha );
- }
- else
- {
- gl.glEnableClientState( GL.GL_COLOR_ARRAY );
- gl.glColorPointer( 4, GL.GL_FLOAT, 0, colorArrayBuf );
-
- //
- // pre light everything
- //
- FloatBuffer color = colorArrayBuf;
- int j = 0;
- for ( i = 0; i < paliashdr.num_xyz; i++ )
- {
- l = shadedots[verts[i].lightnormalindex];
- color.put(j++, l * shadelight[0]);
- color.put(j++, l * shadelight[1]);
- color.put(j++, l * shadelight[2]);
- color.put(j++, alpha);
- }
- }
-
- gl.glClientActiveTextureARB(GL_TEXTURE0);
- gl.glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureArrayBuf);
- //gl.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY);
-
- int pos = 0;
- int[] counts = paliashdr.counts;
-
- IntBuffer srcIndexBuf = null;
-
- FloatBuffer dstTextureCoords = textureArrayBuf;
- FloatBuffer srcTextureCoords = paliashdr.textureCoordBuf;
-
- int size = 0;
- int dstIndex = 0;
- int srcIndex = 0;
-
- for (int j = 0; j < counts.length; j++) {
-
- // get the vertex count and primitive type
- count = counts[j];
- if (count == 0)
- break; // done
-
- srcIndexBuf = paliashdr.indexElements[j];
-
- size = (count < 0) ? -count + pos : count + pos;
- for (int k = pos; k < size; k++) {
- srcIndex = 2 * k;
- dstIndex = 2 * srcIndexBuf.get(k-pos);
- dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex));
- dstTextureCoords.put(dstIndex + 1, srcTextureCoords.get(srcIndex + 1));
- }
-
- if (count < 0) {
- count = -count;
- gl.glDrawElements(GL.GL_TRIANGLE_FAN, count, GL.GL_UNSIGNED_INT, srcIndexBuf);
- } else {
- gl.glDrawElements(GL.GL_TRIANGLE_STRIP, count, GL.GL_UNSIGNED_INT, srcIndexBuf);
- }
- pos += count;
- }
-
- // PMM - added double damage shell
- 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 )
- gl.glEnable( GL.GL_TEXTURE_2D );
-
- gl.glDisableClientState( GL.GL_COLOR_ARRAY );
-
- }
-
- /*
- =============
- GL_DrawAliasShadow
- =============
- */
- void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum)
- {
- qfiles.dtrivertx_t[] verts;
- int[] order;
- float[] point = {0, 0, 0};
- float height, lheight;
- int count;
- qfiles.daliasframe_t frame;
-
- lheight = currententity.origin[2] - lightspot[2];
-
- frame = paliashdr.aliasFrames[currententity.frame];
-
- verts = frame.verts;
-
- height = 0;
-
- order = paliashdr.glCmds;
-
- height = -lheight + 1.0f;
-
- int orderIndex = 0;
- int index = 0;
-
- // TODO shadow drawing with vertex arrays
-
- while (true)
- {
- // get the vertex count and primitive type
- count = order[orderIndex++];
- if (count == 0)
- break; // done
- if (count < 0)
- {
- count = -count;
- gl.glBegin (GL.GL_TRIANGLE_FAN);
- }
- else
- gl.glBegin (GL.GL_TRIANGLE_STRIP);
-
- do
- {
- index = order[orderIndex + 2] * 3;
- point[0] = vertexArrayBuf.get(index);
- point[1] = vertexArrayBuf.get(index + 1);
- point[2] = vertexArrayBuf.get(index + 2);
-
- point[0] -= shadevector[0]*(point[2]+lheight);
- point[1] -= shadevector[1]*(point[2]+lheight);
- point[2] = height;
- gl.glVertex3f(point[0], point[1], point[2]);
-
- orderIndex += 3;
-
- } while (--count != 0);
-
- gl.glEnd ();
- }
- }
-
-
- /*
- ** R_CullAliasModel
- */
- boolean R_CullAliasModel( float[][] bbox, entity_t e )
- {
- int i;
- float[] mins = {0, 0, 0};
- float[] maxs = {0, 0, 0};
-
- qfiles.dmdl_t paliashdr;
-
- float[] thismins = {0, 0, 0};
- float[] oldmins = {0, 0, 0};
- float[] thismaxs = {0, 0, 0};
- float[] oldmaxs = {0, 0, 0};
- qfiles.daliasframe_t pframe, poldframe;
- float[] angles = {0, 0, 0};
-
- paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
-
- if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) )
- {
- ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n');
- e.frame = 0;
- }
- if ( ( e.oldframe >= paliashdr.num_frames ) || ( e.oldframe < 0 ) )
- {
- ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n');
- e.oldframe = 0;
- }
-
- pframe = paliashdr.aliasFrames[e.frame];
- poldframe = paliashdr.aliasFrames[e.oldframe];
-
- /*
- ** compute axially aligned mins and maxs
- */
- if ( pframe == poldframe )
- {
- for ( i = 0; i < 3; i++ )
- {
- mins[i] = pframe.translate[i];
- maxs[i] = mins[i] + pframe.scale[i]*255;
- }
- }
- else
- {
- for ( i = 0; i < 3; i++ )
- {
- thismins[i] = pframe.translate[i];
- thismaxs[i] = thismins[i] + pframe.scale[i]*255;
-
- oldmins[i] = poldframe.translate[i];
- oldmaxs[i] = oldmins[i] + poldframe.scale[i]*255;
-
- if ( thismins[i] < oldmins[i] )
- mins[i] = thismins[i];
- else
- mins[i] = oldmins[i];
-
- if ( thismaxs[i] > oldmaxs[i] )
- maxs[i] = thismaxs[i];
- else
- maxs[i] = oldmaxs[i];
- }
- }
-
- /*
- ** compute a full bounding box
- */
- for ( i = 0; i < 8; i++ )
- {
- float[] tmp = {0, 0, 0};
-
- if ( (i & 1) != 0 )
- tmp[0] = mins[0];
- else
- tmp[0] = maxs[0];
-
- if ( (i & 2) != 0)
- tmp[1] = mins[1];
- else
- tmp[1] = maxs[1];
-
- if ( (i & 4) != 0)
- tmp[2] = mins[2];
- else
- tmp[2] = maxs[2];
-
- Math3D.VectorCopy( tmp, bbox[i] );
- }
-
- /*
- ** rotate the bounding box
- */
- Math3D.VectorCopy( e.angles, angles );
- angles[YAW] = -angles[YAW];
- Math3D.AngleVectors( angles, vectors[0], vectors[1], vectors[2] );
-
- float[] tmp = {0, 0, 0};
-
- for ( i = 0; i < 8; i++ )
- {
- Math3D.VectorCopy( bbox[i], tmp );
-
- bbox[i][0] = Math3D.DotProduct( vectors[0], tmp );
- bbox[i][1] = -Math3D.DotProduct( vectors[1], tmp );
- bbox[i][2] = Math3D.DotProduct( vectors[2], tmp );
-
- Math3D.VectorAdd( e.origin, bbox[i], bbox[i] );
- }
-
- {
- int p, f;
- int aggregatemask = ~0; // 0xFFFFFFFF
-
- for ( p = 0; p < 8; p++ )
- {
- int mask = 0;
-
- for ( f = 0; f < 4; f++ )
- {
- float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] );
-
- if ( ( dp - frustum[f].dist ) < 0 )
- {
- mask |= ( 1 << f );
- }
- }
-
- aggregatemask &= mask;
- }
-
- if ( aggregatemask != 0 )
- {
- return true;
- }
-
- return false;
- }
- }
-
-
- // bounding box
- float[][] bbox = {
- {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
- {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}
- };
-
- /*
- =================
- R_DrawAliasModel
-
- =================
- */
- void R_DrawAliasModel(entity_t e)
- {
- int i;
- qfiles.dmdl_t paliashdr;
- float an;
-
- image_t skin;
-
- if ( ( e.flags & Defines.RF_WEAPONMODEL ) == 0)
- {
- if ( R_CullAliasModel( bbox, e ) )
- return;
- }
-
- if ( (e.flags & Defines.RF_WEAPONMODEL) != 0 )
- {
- if ( r_lefthand.value == 2.0f )
- return;
- }
-
- paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
-
- //
- // get lighting information
- //
- // PMM - rewrote, reordered to handle new shells & mixing
- // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
- //
- if ( (currententity.flags & ( Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE )) != 0 )
- {
- Math3D.VectorClear(shadelight);
- if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0)
- {
- shadelight[0] = 0.56f;
- shadelight[1] = 0.59f;
- shadelight[2] = 0.45f;
- }
- if ( (currententity.flags & Defines.RF_SHELL_DOUBLE) != 0 )
- {
- shadelight[0] = 0.9f;
- shadelight[1] = 0.7f;
- }
- if ( (currententity.flags & Defines.RF_SHELL_RED) != 0 )
- shadelight[0] = 1.0f;
- if ( (currententity.flags & Defines.RF_SHELL_GREEN) != 0 )
- shadelight[1] = 1.0f;
- if ( (currententity.flags & Defines.RF_SHELL_BLUE) != 0 )
- shadelight[2] = 1.0f;
- }
-
- else if ( (currententity.flags & Defines.RF_FULLBRIGHT) != 0 )
- {
- for (i=0 ; i<3 ; i++)
- shadelight[i] = 1.0f;
- }
- else
- {
- R_LightPoint (currententity.origin, shadelight);
-
- // player lighting hack for communication back to server
- // big hack!
- if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 )
- {
- // pick the greatest component, which should be the same
- // as the mono value returned by software
- if (shadelight[0] > shadelight[1])
- {
- if (shadelight[0] > shadelight[2])
- r_lightlevel.value = 150*shadelight[0];
- else
- r_lightlevel.value = 150*shadelight[2];
- }
- else
- {
- if (shadelight[1] > shadelight[2])
- r_lightlevel.value = 150*shadelight[1];
- else
- r_lightlevel.value = 150*shadelight[2];
- }
- }
-
- if ( gl_monolightmap.string.charAt(0) != '0' )
- {
- float s = shadelight[0];
-
- if ( s < shadelight[1] )
- s = shadelight[1];
- if ( s < shadelight[2] )
- s = shadelight[2];
-
- shadelight[0] = s;
- shadelight[1] = s;
- shadelight[2] = s;
- }
- }
-
- if ( (currententity.flags & Defines.RF_MINLIGHT) != 0 )
- {
- for (i=0 ; i<3 ; i++)
- if (shadelight[i] > 0.1f)
- break;
- if (i == 3)
- {
- shadelight[0] = 0.1f;
- shadelight[1] = 0.1f;
- shadelight[2] = 0.1f;
- }
- }
-
- if ( (currententity.flags & Defines.RF_GLOW) != 0 )
- { // bonus items will pulse with time
- float scale;
- float min;
-
- scale = (float)(0.1f * Math.sin(r_newrefdef.time*7));
- for (i=0 ; i<3 ; i++)
- {
- min = shadelight[i] * 0.8f;
- shadelight[i] += scale;
- if (shadelight[i] < min)
- shadelight[i] = min;
- }
- }
-
- // =================
- // PGM ir goggles color override
- if ( (r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0 && (currententity.flags & Defines.RF_IR_VISIBLE) != 0)
- {
- shadelight[0] = 1.0f;
- shadelight[1] = 0.0f;
- shadelight[2] = 0.0f;
- }
- // PGM
- // =================
-
- shadedots = r_avertexnormal_dots[((int)(currententity.angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
-
- an = (float)(currententity.angles[1]/180*Math.PI);
- shadevector[0] = (float)Math.cos(-an);
- shadevector[1] = (float)Math.sin(-an);
- shadevector[2] = 1;
- Math3D.VectorNormalize(shadevector);
-
- //
- // locate the proper data
- //
-
- c_alias_polys += paliashdr.num_tris;
-
- //
- // draw all the triangles
- //
- if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls
- gl.glDepthRange(gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
-
- if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f) )
- {
- gl.glMatrixMode( GL.GL_PROJECTION );
- gl.glPushMatrix();
- gl.glLoadIdentity();
- gl.glScalef( -1, 1, 1 );
- MYgluPerspective( r_newrefdef.fov_y, ( float ) r_newrefdef.width / r_newrefdef.height, 4, 4096);
- gl.glMatrixMode( GL.GL_MODELVIEW );
-
- gl.glCullFace( GL.GL_BACK );
- }
-
- gl.glPushMatrix ();
- e.angles[PITCH] = -e.angles[PITCH]; // sigh.
- R_RotateForEntity (e);
- e.angles[PITCH] = -e.angles[PITCH]; // sigh.
-
- // select skin
- if (currententity.skin != null)
- skin = currententity.skin; // custom player skin
- else
- {
- if (currententity.skinnum >= qfiles.MAX_MD2SKINS)
- skin = currentmodel.skins[0];
- else
- {
- skin = currentmodel.skins[currententity.skinnum];
- if (skin == null)
- skin = currentmodel.skins[0];
- }
- }
- if (skin == null)
- skin = r_notexture; // fallback...
- GL_Bind(skin.texnum);
-
- // draw it
-
- gl.glShadeModel (GL.GL_SMOOTH);
-
- GL_TexEnv( GL.GL_MODULATE );
- if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 )
- {
- gl.glEnable (GL.GL_BLEND);
- }
-
-
- if ( (currententity.frame >= paliashdr.num_frames)
- || (currententity.frame < 0) )
- {
- ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n');
- currententity.frame = 0;
- currententity.oldframe = 0;
- }
-
- if ( (currententity.oldframe >= paliashdr.num_frames)
- || (currententity.oldframe < 0))
- {
- ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n');
- currententity.frame = 0;
- currententity.oldframe = 0;
- }
-
- if ( r_lerpmodels.value == 0.0f)
- currententity.backlerp = 0;
-
- GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);
-
- GL_TexEnv( GL.GL_REPLACE );
- gl.glShadeModel (GL.GL_FLAT);
-
- gl.glPopMatrix ();
-
- if ( ( currententity.flags & Defines.RF_WEAPONMODEL ) != 0 && ( r_lefthand.value == 1.0F ) )
- {
- gl.glMatrixMode( GL.GL_PROJECTION );
- gl.glPopMatrix();
- gl.glMatrixMode( GL.GL_MODELVIEW );
- gl.glCullFace( GL.GL_FRONT );
- }
-
- if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 )
- {
- gl.glDisable (GL.GL_BLEND);
- }
-
- if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0)
- gl.glDepthRange (gldepthmin, gldepthmax);
-
- if ( gl_shadows.value != 0.0f && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0)
- {
- gl.glPushMatrix ();
- R_RotateForEntity (e);
- gl.glDisable (GL.GL_TEXTURE_2D);
- gl.glEnable (GL.GL_BLEND);
- gl.glColor4f (0,0,0,0.5f);
- GL_DrawAliasShadow (paliashdr, currententity.frame );
- gl.glEnable (GL.GL_TEXTURE_2D);
- gl.glDisable (GL.GL_BLEND);
- gl.glPopMatrix ();
- }
- gl.glColor4f (1,1,1,1);
- }
-
-}
diff --git a/src/jake2/render/fastjogl/Misc.java b/src/jake2/render/fastjogl/Misc.java
deleted file mode 100644
index bcd2a5f..0000000
--- a/src/jake2/render/fastjogl/Misc.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Misc.java
- * Copyright (C) 2003
- *
- * $Id: Misc.java,v 1.1 2004-07-09 06:50:48 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.WGL;
-
-import jake2.Defines;
-
-/**
- * Misc
- *
- * @author cwei
- */
-public abstract class Misc extends Mesh {
-
- /*
- ==================
- R_InitParticleTexture
- ==================
- */
- byte[][] dottexture =
- {
- {0,0,0,0,0,0,0,0},
- {0,0,1,1,0,0,0,0},
- {0,1,1,1,1,0,0,0},
- {0,1,1,1,1,0,0,0},
- {0,0,1,1,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- };
-
- void R_InitParticleTexture()
- {
- int x,y;
- byte[] data = new byte[8 * 8 * 4];
-
- //
- // particle texture
- //
- for (x=0 ; x<8 ; x++)
- {
- for (y=0 ; y<8 ; y++)
- {
- data[y * 32 + x * 4 + 0] = (byte)255;
- data[y * 32 + x * 4 + 1] = (byte)255;
- data[y * 32 + x * 4 + 2] = (byte)255;
- data[y * 32 + x * 4 + 3] = (byte)(dottexture[x][y]*255);
-
- }
- }
- r_particletexture = GL_LoadPic("***particle***", data, 8, 8, it_sprite, 32);
-
- //
- // also use this for bad textures, but without alpha
- //
- for (x=0 ; x<8 ; x++)
- {
- for (y=0 ; y<8 ; y++)
- {
- data[y * 32 + x * 4 + 0] = (byte)(dottexture[x&3][y&3]*255);
- data[y * 32 + x * 4 + 1] = 0; // dottexture[x&3][y&3]*255;
- data[y * 32 + x * 4 + 2] = 0; //dottexture[x&3][y&3]*255;
- data[y * 32 + x * 4 + 3] = (byte)255;
- }
- }
- r_notexture = GL_LoadPic("***r_notexture***", data, 8, 8, it_wall, 32);
- }
-
-
-// /*
-// ==============================================================================
-//
-// SCREEN SHOTS
-//
-// ==============================================================================
-// */
-//
-// typedef struct _TargaHeader {
-// unsigned char id_length, colormap_type, image_type;
-// unsigned short colormap_index, colormap_length;
-// unsigned char colormap_size;
-// unsigned short x_origin, y_origin, width, height;
-// unsigned char pixel_size, attributes;
-// } TargaHeader;
-
-
- /*
- ==================
- GL_ScreenShot_f
- ==================
- */
- void GL_ScreenShot_f()
- {
-// byte *buffer;
-// char picname[80];
-// char checkname[MAX_OSPATH];
-// int i, c, temp;
-// FILE *f;
-//
-// // create the scrnshots directory if it doesn't exist
-// Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir());
-// Sys_Mkdir (checkname);
-//
-////
-//// find a file name to save it to
-////
-// strcpy(picname,"quake00.tga");
-//
-// for (i=0 ; i<=99 ; i++)
-// {
-// picname[5] = i/10 + '0';
-// picname[6] = i%10 + '0';
-// Com_sprintf (checkname, sizeof(checkname), "%s/scrnshot/%s", ri.FS_Gamedir(), picname);
-// f = fopen (checkname, "r");
-// if (!f)
-// break; // file doesn't exist
-// fclose (f);
-// }
-// if (i==100)
-// {
-// ri.Con_Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n");
-// return;
-// }
-//
-//
-// buffer = malloc(vid.width*vid.height*3 + 18);
-// memset (buffer, 0, 18);
-// buffer[2] = 2; // uncompressed type
-// buffer[12] = vid.width&255;
-// buffer[13] = vid.width>>8;
-// buffer[14] = vid.height&255;
-// buffer[15] = vid.height>>8;
-// buffer[16] = 24; // pixel size
-//
-// qglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 );
-//
-// // swap rgb to bgr
-// c = 18+vid.width*vid.height*3;
-// for (i=18 ; i<c ; i+=3)
-// {
-// temp = buffer[i];
-// buffer[i] = buffer[i+2];
-// buffer[i+2] = temp;
-// }
-//
-// f = fopen (checkname, "rw");
-// fwrite (buffer, 1, c, f);
-// fclose (f);
-//
-// free (buffer);
-// ri.Con_Printf (PRINT_ALL, "Wrote %s\n", picname);
- }
-
- /*
- ** GL_Strings_f
- */
- void GL_Strings_f() {
- ri.Con_Printf (Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n');
- ri.Con_Printf (Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n');
- ri.Con_Printf (Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n');
- ri.Con_Printf (Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n');
- }
-
- /*
- ** GL_SetDefaultState
- */
- void GL_SetDefaultState()
- {
- gl.glClearColor(1f,0f, 0.5f , 0.5f); // original quake2
- //gl.glClearColor(0, 0, 0, 0); // replaced with black
- gl.glCullFace(GL.GL_FRONT);
- gl.glEnable(GL.GL_TEXTURE_2D);
-
- gl.glEnable(GL.GL_ALPHA_TEST);
- gl.glAlphaFunc(GL.GL_GREATER, 0.666f);
-
- gl.glDisable (GL.GL_DEPTH_TEST);
- gl.glDisable (GL.GL_CULL_FACE);
- gl.glDisable (GL.GL_BLEND);
-
- gl.glColor4f (1,1,1,1);
-
- gl.glPolygonMode (GL.GL_FRONT_AND_BACK, GL.GL_FILL);
- gl.glShadeModel (GL.GL_FLAT);
-
- GL_TextureMode( gl_texturemode.string );
- GL_TextureAlphaMode( gl_texturealphamode.string );
- GL_TextureSolidMode( gl_texturesolidmode.string );
-
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, gl_filter_min);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, gl_filter_max);
-
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
-
- gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
-
- GL_TexEnv( GL.GL_REPLACE );
-
- if ( qglPointParameterfEXT )
- {
- float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value };
-
- gl.glEnable( GL.GL_POINT_SMOOTH );
- gl.glPointParameterfEXT( GL.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value );
- gl.glPointParameterfEXT( GL.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value );
- gl.glPointParameterfvEXT( GL.GL_DISTANCE_ATTENUATION_EXT, attenuations );
- }
-
- if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f )
- {
- gl.glEnable( GL.GL_SHARED_TEXTURE_PALETTE_EXT );
-
- GL_SetTexturePalette( d_8to24table );
- }
-
- GL_UpdateSwapInterval();
-
- /*
- * vertex array extension
- */
- gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
- gl.glClientActiveTextureARB(GL_TEXTURE0);
- gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
- }
-
- void GL_UpdateSwapInterval()
- {
- if ( gl_swapinterval.modified )
- {
- gl_swapinterval.modified = false;
- if ( !gl_state.stereo_enabled )
- {
- if (qwglSwapIntervalEXT) {
- ((WGL)gl).wglSwapIntervalEXT((int)gl_swapinterval.value);
- }
- }
- }
- }
-}
diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java
deleted file mode 100644
index 4b781be..0000000
--- a/src/jake2/render/fastjogl/Model.java
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * Model.java
- * Copyright (C) 2003
- *
- * $Id: Model.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.game.cplane_t;
-import jake2.game.cvar_t;
-import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.util.Math3D;
-import jake2.util.Vargs;
-
-import java.nio.*;
-import java.util.Arrays;
-import java.util.Vector;
-
-import net.java.games.jogl.util.BufferUtils;
-
-/**
- * Model
- *
- * @author cwei
- */
-public abstract class Model extends Surf {
-
- // models.c -- model loading and caching
-
- model_t loadmodel;
- int modfilelen;
-
- byte[] mod_novis = new byte[Defines.MAX_MAP_LEAFS/8];
-
- static final int MAX_MOD_KNOWN = 512;
- model_t[] mod_known = new model_t[MAX_MOD_KNOWN];
- int mod_numknown;
-
- // the inline * models from the current map are kept seperate
- model_t[] mod_inline = new model_t[MAX_MOD_KNOWN];
-
- abstract void GL_SubdivideSurface(msurface_t surface); // Warp.java
-
- /*
- ===============
- Mod_PointInLeaf
- ===============
- */
- mleaf_t Mod_PointInLeaf(float[] p, model_t model)
- {
- mnode_t node;
- float d;
- cplane_t plane;
-
- if (model == null || model.nodes == null)
- ri.Sys_Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model");
-
- node = model.nodes[0]; // root node
- while (true)
- {
- if (node.contents != -1)
- return (mleaf_t)node;
-
- plane = node.plane;
- d = Math3D.DotProduct(p, plane.normal) - plane.dist;
- if (d > 0)
- node = node.children[0];
- else
- node = node.children[1];
- }
- // never reached
- }
-
-
- byte[] decompressed = new byte[Defines.MAX_MAP_LEAFS / 8];
- byte[] model_visibility = new byte[Defines.MAX_MAP_VISIBILITY];
-
- /*
- ===================
- Mod_DecompressVis
- ===================
- */
- byte[] Mod_DecompressVis(byte[] in, int offset, model_t model)
- {
- int c;
- byte[] out;
- int outp, inp;
- int row;
-
- row = (model.vis.numclusters+7)>>3;
- out = decompressed;
- outp = 0;
- inp = offset;
-
- if (in == null)
- { // no vis info, so make all visible
- while (row != 0)
- {
- out[outp++] = (byte)0xFF;
- row--;
- }
- return decompressed;
- }
-
- do
- {
- if (in[inp] != 0)
- {
- out[outp++] = in[inp++];
- continue;
- }
-
- c = in[inp + 1] & 0xFF;
- inp += 2;
- while (c != 0)
- {
- out[outp++] = 0;
- c--;
- }
- } while (outp < row);
-
- return decompressed;
- }
-
- /*
- ==============
- Mod_ClusterPVS
- ==============
- */
- byte[] Mod_ClusterPVS(int cluster, model_t model)
- {
- if (cluster == -1 || model.vis == null)
- return mod_novis;
- //return Mod_DecompressVis( (byte *)model.vis + model.vis.bitofs[cluster][Defines.DVIS_PVS], model);
- return Mod_DecompressVis(model_visibility, model.vis.bitofs[cluster][Defines.DVIS_PVS], model);
- }
-
-
-// ===============================================================================
-
- /*
- ================
- Mod_Modellist_f
- ================
- */
- void Mod_Modellist_f()
- {
- int i;
- model_t mod;
- int total;
-
- total = 0;
- ri.Con_Printf(Defines.PRINT_ALL,"Loaded models:\n");
- for (i=0; i < mod_numknown ; i++)
- {
- mod = mod_known[i];
- if (mod.name == "")
- continue;
-
- ri.Con_Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name));
- total += mod.extradatasize;
- }
- ri.Con_Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n');
- }
-
- /*
- ===============
- Mod_Init
- ===============
- */
- void Mod_Init()
- {
- // init mod_known
- for (int i=0; i < MAX_MOD_KNOWN; i++) {
- mod_known[i] = new model_t();
- }
- Arrays.fill(mod_novis, (byte)0xff);
- }
-
- byte[] fileBuffer;
-
- /*
- ==================
- Mod_ForName
-
- Loads in a model for the given name
- ==================
- */
- model_t Mod_ForName(String name, boolean crash)
- {
- model_t mod = null;
- int i;
-
- if (name == null || name.length() == 0)
- ri.Sys_Error(Defines.ERR_DROP, "Mod_ForName: NULL name");
-
- //
- // inline models are grabbed only from worldmodel
- //
- if (name.charAt(0) == '*')
- {
- i = Integer.parseInt(name.substring(1));
- if (i < 1 || r_worldmodel == null || i >= r_worldmodel.numsubmodels)
- ri.Sys_Error (Defines.ERR_DROP, "bad inline model number");
- return mod_inline[i];
- }
-
- //
- // search the currently loaded models
- //
- for (i=0; i<mod_numknown ; i++)
- {
- mod = mod_known[i];
-
- if (mod.name == "")
- continue;
- if (mod.name.equals(name) )
- return mod;
- }
-
- //
- // find a free model slot spot
- //
- for (i=0; i<mod_numknown ; i++)
- {
- mod = mod_known[i];
-
- if (mod.name == "")
- break; // free spot
- }
- if (i == mod_numknown)
- {
- if (mod_numknown == MAX_MOD_KNOWN)
- ri.Sys_Error (Defines.ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
- mod_numknown++;
- mod = mod_known[i];
- }
-
- mod.name = name;
-
- //
- // load the file
- //
- fileBuffer = ri.FS_LoadFile(name);
-
- if (fileBuffer == null)
- {
- if (crash)
- ri.Sys_Error(Defines.ERR_DROP, "Mod_NumForName: " + mod.name + " not found");
-
- mod.name = "";
- return null;
- }
-
- modfilelen = fileBuffer.length;
-
- loadmodel = mod;
-
- //
- // fill it in
- //
- ByteBuffer bb = ByteBuffer.wrap(fileBuffer);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- // call the apropriate loader
-
- bb.mark();
- int ident = bb.getInt();
-
- bb.reset();
-
- switch (ident)
- {
- case qfiles.IDALIASHEADER:
- Mod_LoadAliasModel(mod, bb);
- break;
- case qfiles.IDSPRITEHEADER:
- Mod_LoadSpriteModel(mod, bb);
- break;
- case qfiles.IDBSPHEADER:
- Mod_LoadBrushModel(mod, bb);
- break;
- default:
- ri.Sys_Error(Defines.ERR_DROP,"Mod_NumForName: unknown fileid for " + mod.name);
- break;
- }
-
- this.fileBuffer = null; // free it for garbage collection
- return mod;
- }
-
- /*
- ===============================================================================
-
- BRUSHMODEL LOADING
-
- ===============================================================================
- */
-
- byte[] mod_base;
-
-
- /*
- =================
- Mod_LoadLighting
- =================
- */
- void Mod_LoadLighting(lump_t l)
- {
- if (l.filelen == 0)
- {
- loadmodel.lightdata = null;
- return;
- }
- // memcpy (loadmodel.lightdata, mod_base + l.fileofs, l.filelen);
- loadmodel.lightdata = new byte[l.filelen];
- System.arraycopy(mod_base, l.fileofs, loadmodel.lightdata, 0, l.filelen);
- }
-
-
- /*
- =================
- Mod_LoadVisibility
- =================
- */
- void Mod_LoadVisibility(lump_t l)
- {
- int i;
-
- if (l.filelen == 0)
- {
- loadmodel.vis = null;
- return;
- }
-
- System.arraycopy(mod_base, l.fileofs, model_visibility, 0, l.filelen);
-
- ByteBuffer bb = ByteBuffer.wrap(model_visibility, 0, l.filelen);
-
- loadmodel.vis = new qfiles.dvis_t(bb.order(ByteOrder.LITTLE_ENDIAN));
-
- /* done:
- memcpy (loadmodel.vis, mod_base + l.fileofs, l.filelen);
-
- loadmodel.vis.numclusters = LittleLong (loadmodel.vis.numclusters);
- for (i=0 ; i<loadmodel.vis.numclusters ; i++)
- {
- loadmodel.vis.bitofs[i][0] = LittleLong (loadmodel.vis.bitofs[i][0]);
- loadmodel.vis.bitofs[i][1] = LittleLong (loadmodel.vis.bitofs[i][1]);
- }
- */
- }
-
-
- /*
- =================
- Mod_LoadVertexes
- =================
- */
- void Mod_LoadVertexes(lump_t l)
- {
- mvertex_t[] vertexes;
- int i, count;
-
- if ( (l.filelen % mvertex_t.DISK_SIZE) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / mvertex_t.DISK_SIZE;
-
- vertexes = new mvertex_t[count];
-
- loadmodel.vertexes = vertexes;
- loadmodel.numvertexes = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- vertexes[i] = new mvertex_t(bb);
- }
- }
-
- /*
- =================
- RadiusFromBounds
- =================
- */
- float RadiusFromBounds(float[] mins, float[] maxs)
- {
- float[] corner = {0, 0, 0};
-
- for (int i=0 ; i<3 ; i++)
- {
- corner[i] = Math.abs(mins[i]) > Math.abs(maxs[i]) ? Math.abs(mins[i]) : Math.abs(maxs[i]);
- }
- return Math3D.VectorLength(corner);
- }
-
-
- /*
- =================
- Mod_LoadSubmodels
- =================
- */
- void Mod_LoadSubmodels(lump_t l)
- {
- qfiles.dmodel_t in;
- mmodel_t[] out;
- int i, j, count;
-
- if ((l.filelen % qfiles.dmodel_t.SIZE) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / qfiles.dmodel_t.SIZE;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new mmodel_t[count];
-
- loadmodel.submodels = out;
- loadmodel.numsubmodels = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- in = new qfiles.dmodel_t(bb);
- out[i] = new mmodel_t();
- for (j=0 ; j<3 ; j++)
- { // spread the mins / maxs by a pixel
- out[i].mins[j] = in.mins[j] - 1;
- out[i].maxs[j] = in.maxs[j] + 1;
- out[i].origin[j] = in.origin[j];
- }
- out[i].radius = RadiusFromBounds(out[i].mins, out[i].maxs);
- out[i].headnode = in.headnode;
- out[i].firstface = in.firstface;
- out[i].numfaces = in.numfaces;
- }
- }
-
- /*
- =================
- Mod_LoadEdges
- =================
- */
- void Mod_LoadEdges (lump_t l)
- {
- medge_t[] edges;
- int i, count;
-
- if ( (l.filelen % medge_t.DISK_SIZE) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / medge_t.DISK_SIZE;
- // out = Hunk_Alloc ( (count + 1) * sizeof(*out));
- edges = new medge_t[count + 1];
-
- loadmodel.edges = edges;
- loadmodel.numedges = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- edges[i] = new medge_t(bb);
- }
- }
-
- /*
- =================
- Mod_LoadTexinfo
- =================
- */
- void Mod_LoadTexinfo(lump_t l)
- {
- texinfo_t in;
- mtexinfo_t[] out;
- mtexinfo_t step;
- int i, j, count;
- int next;
- String name;
-
- if ((l.filelen % texinfo_t.SIZE) != 0)
- ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / texinfo_t.SIZE;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new mtexinfo_t[count];
- for ( i=0 ; i<count ; i++) {
- out[i] = new mtexinfo_t();
- }
-
- loadmodel.texinfo = out;
- loadmodel.numtexinfo = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++) {
-
- in = new texinfo_t(bb);
- out[i].vecs = in.vecs;
- out[i].flags = in.flags;
- next = in.nexttexinfo;
- if (next > 0)
- out[i].next = loadmodel.texinfo[next];
- else
- out[i].next = null;
-
- name = "textures/" + in.texture + ".wal";
-
- out[i].image = GL_FindImage(name, it_wall);
- if (out[i].image == null) {
- ri.Con_Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n');
- out[i].image = r_notexture;
- }
- }
-
- // count animation frames
- for (i=0 ; i<count ; i++) {
- out[i].numframes = 1;
- for (step = out[i].next ; (step != null) && (step != out[i]) ; step=step.next)
- out[i].numframes++;
- }
- }
-
- /*
- ================
- CalcSurfaceExtents
-
- Fills in s.texturemins[] and s.extents[]
- ================
- */
- void CalcSurfaceExtents(msurface_t s)
- {
- float[] mins = {0, 0};
- float[] maxs = {0, 0};
- float val;
-
- int i, j, e;
- mvertex_t v;
- mtexinfo_t tex;
- int[] bmins = {0, 0};
- int[] bmaxs = {0, 0};
-
- mins[0] = mins[1] = 999999;
- maxs[0] = maxs[1] = -99999;
-
- tex = s.texinfo;
-
- for (i=0 ; i<s.numedges ; i++)
- {
- e = loadmodel.surfedges[s.firstedge+i];
- if (e >= 0)
- v = loadmodel.vertexes[loadmodel.edges[e].v[0]];
- else
- v = loadmodel.vertexes[loadmodel.edges[-e].v[1]];
-
- for (j=0 ; j<2 ; j++)
- {
- val = v.position[0] * tex.vecs[j][0] +
- v.position[1] * tex.vecs[j][1] +
- v.position[2] * tex.vecs[j][2] +
- tex.vecs[j][3];
- if (val < mins[j])
- mins[j] = val;
- if (val > maxs[j])
- maxs[j] = val;
- }
- }
-
- for (i=0 ; i<2 ; i++)
- {
- bmins[i] = (int)Math.floor(mins[i]/16);
- bmaxs[i] = (int)Math.ceil(maxs[i]/16);
-
- s.texturemins[i] = (short)(bmins[i] * 16);
- s.extents[i] = (short)((bmaxs[i] - bmins[i]) * 16);
-
- }
- }
-
- /*
- =================
- Mod_LoadFaces
- =================
- */
- void Mod_LoadFaces (lump_t l)
- {
- qfiles.dface_t in;
- msurface_t[] out;
- int i, count, surfnum;
- int planenum, side;
- int ti;
-
- if ((l.filelen % qfiles.dface_t.SIZE) != 0)
- ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / qfiles.dface_t.SIZE;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new msurface_t[count];
-
- loadmodel.surfaces = out;
- loadmodel.numsurfaces = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- currentmodel = loadmodel;
-
- GL_BeginBuildingLightmaps(loadmodel);
-
- for ( surfnum=0 ; surfnum<count ; surfnum++)
- {
- in = new qfiles.dface_t(bb);
- out[surfnum] = new msurface_t();
- out[surfnum].firstedge = in.firstedge;
- out[surfnum].numedges = in.numedges;
- out[surfnum].flags = 0;
- out[surfnum].polys = null;
-
- planenum = in.planenum;
- side = in.side;
- if (side != 0)
- out[surfnum].flags |= Defines.SURF_PLANEBACK;
-
- out[surfnum].plane = loadmodel.planes[planenum];
-
- ti = in.texinfo;
- if (ti < 0 || ti >= loadmodel.numtexinfo)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
-
- out[surfnum].texinfo = loadmodel.texinfo[ti];
-
- CalcSurfaceExtents(out[surfnum]);
-
- // lighting info
-
- for (i=0 ; i<Defines.MAXLIGHTMAPS ; i++)
- out[surfnum].styles[i] = in.styles[i];
-
- i = in.lightofs;
- if (i == -1)
- out[surfnum].samples = null;
- else {
- ByteBuffer pointer = ByteBuffer.wrap(loadmodel.lightdata);
- pointer.position(i);
- pointer = pointer.slice();
- pointer.mark();
- out[surfnum].samples = pointer; // subarray
- }
-
- // set the drawing flags
-
- if ((out[surfnum].texinfo.flags & Defines.SURF_WARP) != 0)
- {
- out[surfnum].flags |= Defines.SURF_DRAWTURB;
- for (i=0 ; i<2 ; i++)
- {
- out[surfnum].extents[i] = 16384;
- out[surfnum].texturemins[i] = -8192;
- }
- GL_SubdivideSurface(out[surfnum]); // cut up polygon for warps
- }
-
- // create lightmaps and polygons
- if ((out[surfnum].texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0)
- GL_CreateSurfaceLightmap(out[surfnum]);
-
- if ((out[surfnum].texinfo.flags & Defines.SURF_WARP) == 0)
- GL_BuildPolygonFromSurface(out[surfnum]);
-
- }
- GL_EndBuildingLightmaps ();
- }
-
-
- /*
- =================
- Mod_SetParent
- =================
- */
- void Mod_SetParent(mnode_t node, mnode_t parent)
- {
- node.parent = parent;
- if (node.contents != -1) return;
- Mod_SetParent(node.children[0], node);
- Mod_SetParent(node.children[1], node);
- }
-
- /*
- =================
- Mod_LoadNodes
- =================
- */
- void Mod_LoadNodes(lump_t l)
- {
- int i, j, count, p;
- qfiles.dnode_t in;
- mnode_t[] out;
-
- if ((l.filelen % qfiles.dnode_t.SIZE) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / qfiles.dnode_t.SIZE;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new mnode_t[count];
-
- loadmodel.nodes = out;
- loadmodel.numnodes = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- // initialize the tree array
- for ( i=0 ; i<count ; i++) out[i] = new mnode_t(); // do first before linking
-
- // fill and link the nodes
- for ( i=0 ; i<count ; i++)
- {
- in = new qfiles.dnode_t(bb);
- for (j=0 ; j<3 ; j++)
- {
- out[i].mins[j] = in.mins[j];
- out[i].maxs[j] = in.maxs[j];
- }
-
- p = in.planenum;
- out[i].plane = loadmodel.planes[p];
-
- out[i].firstsurface = in.firstface;
- out[i].numsurfaces = in.numfaces;
- out[i].contents = -1; // differentiate from leafs
-
- for (j=0 ; j<2 ; j++)
- {
- p = in.children[j];
- if (p >= 0)
- out[i].children[j] = loadmodel.nodes[p];
- else
- out[i].children[j] = loadmodel.leafs[-1 - p]; // mleaf_t extends mnode_t
- }
- }
-
- Mod_SetParent(loadmodel.nodes[0], null); // sets nodes and leafs
- }
-
- /*
- =================
- Mod_LoadLeafs
- =================
- */
- void Mod_LoadLeafs(lump_t l)
- {
- qfiles.dleaf_t in;
- mleaf_t[] out;
- int i, j, count, p;
-
- if ((l.filelen % qfiles.dleaf_t.SIZE) != 0)
- ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / qfiles.dleaf_t.SIZE;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new mleaf_t[count];
-
- loadmodel.leafs = out;
- loadmodel.numleafs = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- in = new qfiles.dleaf_t(bb);
- out[i] = new mleaf_t();
- for (j=0 ; j<3 ; j++)
- {
- out[i].mins[j] = in.mins[j];
- out[i].maxs[j] = in.maxs[j];
-
- }
-
- out[i].contents = in.contents;
- out[i].cluster = in.cluster;
- out[i].area = in.area;
-
- out[i].setMarkSurface(in.firstleafface, loadmodel.marksurfaces);
- out[i].nummarksurfaces = in.numleaffaces;
- }
- }
-
-
- /*
- =================
- Mod_LoadMarksurfaces
- =================
- */
- void Mod_LoadMarksurfaces(lump_t l)
- {
- int i, j, count;
-
- msurface_t[] out;
-
- if ((l.filelen % Defines.SIZE_OF_SHORT) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
- count = l.filelen / Defines.SIZE_OF_SHORT;
- // out = Hunk_Alloc ( count*sizeof(*out));
- out = new msurface_t[count];
-
- loadmodel.marksurfaces = out;
- loadmodel.nummarksurfaces = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- j = bb.getShort();
- if (j < 0 || j >= loadmodel.numsurfaces)
- ri.Sys_Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
-
- out[i] = loadmodel.surfaces[j];
- }
- }
-
-
- /*
- =================
- Mod_LoadSurfedges
- =================
- */
- void Mod_LoadSurfedges(lump_t l)
- {
- int i, count;
- int[] offsets;
-
- if ( (l.filelen % Defines.SIZE_OF_INT) != 0)
- ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / Defines.SIZE_OF_INT;
- if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES)
- ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count);
-
- offsets = new int[count];
-
- loadmodel.surfedges = offsets;
- loadmodel.numsurfedges = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++) offsets[i] = bb.getInt();
- }
-
-
- /*
- =================
- Mod_LoadPlanes
- =================
- */
- void Mod_LoadPlanes(lump_t l)
- {
- int i, j;
- cplane_t[] out;
- qfiles.dplane_t in;
- int count;
- int bits;
-
- if ((l.filelen % qfiles.dplane_t.SIZE) != 0)
- ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name);
-
- count = l.filelen / qfiles.dplane_t.SIZE;
- // out = Hunk_Alloc ( count*2*sizeof(*out));
- out = new cplane_t[count * 2];
-
- loadmodel.planes = out;
- loadmodel.numplanes = count;
-
- ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
- bb.order(ByteOrder.LITTLE_ENDIAN);
-
- for ( i=0 ; i<count ; i++)
- {
- bits = 0;
- in = new qfiles.dplane_t(bb);
- out[i] = new cplane_t();
- for (j=0 ; j<3 ; j++)
- {
- out[i].normal[j] = in.normal[j];
- if (out[i].normal[j] < 0)
- bits |= (1<<j);
- }
-
- out[i].dist = in.dist;
- out[i].type = (byte)in.type;
- out[i].signbits = (byte)bits;
- }
- }
-
- /*
- =================
- Mod_LoadBrushModel
- =================
- */
- void Mod_LoadBrushModel(model_t mod, ByteBuffer buffer)
- {
- int i;
- qfiles.dheader_t header;
- mmodel_t bm;
-
- loadmodel.type = mod_brush;
- if (loadmodel != mod_known[0])
- ri.Sys_Error(Defines.ERR_DROP, "Loaded a brush model after the world");
-
- header = new qfiles.dheader_t(buffer);
-
- i = header.version;
- if (i != Defines.BSPVERSION)
- ri.Sys_Error (Defines.ERR_DROP, "Mod_LoadBrushModel: " + mod.name + " has wrong version number (" + i + " should be " + Defines.BSPVERSION + ")");
-
- mod_base = fileBuffer; //(byte *)header;
-
- // load into heap
- Mod_LoadVertexes(header.lumps[Defines.LUMP_VERTEXES]); // ok
- Mod_LoadEdges(header.lumps[Defines.LUMP_EDGES]); // ok
- Mod_LoadSurfedges(header.lumps[Defines.LUMP_SURFEDGES]); // ok
- Mod_LoadLighting(header.lumps[Defines.LUMP_LIGHTING]); // ok
- Mod_LoadPlanes(header.lumps[Defines.LUMP_PLANES]); // ok
- Mod_LoadTexinfo(header.lumps[Defines.LUMP_TEXINFO]); // ok
- Mod_LoadFaces(header.lumps[Defines.LUMP_FACES]); // ok
- Mod_LoadMarksurfaces(header.lumps[Defines.LUMP_LEAFFACES]);
- Mod_LoadVisibility(header.lumps[Defines.LUMP_VISIBILITY]); // ok
- Mod_LoadLeafs(header.lumps[Defines.LUMP_LEAFS]); // ok
- Mod_LoadNodes(header.lumps[Defines.LUMP_NODES]); // ok
- Mod_LoadSubmodels(header.lumps[Defines.LUMP_MODELS]);
- mod.numframes = 2; // regular and alternate animation
-
- //
- // set up the submodels
- //
- model_t starmod;
-
- for (i=0 ; i<mod.numsubmodels ; i++)
- {
-
- bm = mod.submodels[i];
- starmod = mod_inline[i] = loadmodel.copy();
-
- starmod.firstmodelsurface = bm.firstface;
- starmod.nummodelsurfaces = bm.numfaces;
- starmod.firstnode = bm.headnode;
- if (starmod.firstnode >= loadmodel.numnodes)
- ri.Sys_Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode");
-
- Math3D.VectorCopy(bm.maxs, starmod.maxs);
- Math3D.VectorCopy(bm.mins, starmod.mins);
- starmod.radius = bm.radius;
-
- if (i == 0)
- loadmodel = starmod.copy();
-
- starmod.numleafs = bm.visleafs;
- }
- }
-
- /*
- ==============================================================================
-
- ALIAS MODELS
-
- ==============================================================================
- */
-
- /*
- =================
- Mod_LoadAliasModel
- =================
- */
- void Mod_LoadAliasModel (model_t mod, ByteBuffer buffer)
- {
- int i, j;
- qfiles.dmdl_t pheader;
- qfiles.dstvert_t[] poutst;
- qfiles.dtriangle_t[] pouttri;
- qfiles.daliasframe_t[] poutframe;
- int[] poutcmd;
-
- pheader = new qfiles.dmdl_t(buffer);
-
- if (pheader.version != qfiles.ALIAS_VERSION)
- ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)",
- new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION));
-
- if (pheader.skinheight > MAX_LBM_HEIGHT)
- ri.Sys_Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT);
-
- if (pheader.num_xyz <= 0)
- ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices");
-
- if (pheader.num_xyz > qfiles.MAX_VERTS)
- ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices");
-
- if (pheader.num_st <= 0)
- ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices");
-
- if (pheader.num_tris <= 0)
- ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles");
-
- if (pheader.num_frames <= 0)
- ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no frames");
-
- //
- // load base s and t vertices (not used in gl version)
- //
- poutst = new qfiles.dstvert_t[pheader.num_st];
- buffer.position(pheader.ofs_st);
- for (i=0 ; i<pheader.num_st ; i++)
- {
- poutst[i] = new qfiles.dstvert_t(buffer);
- }
-
- //
- // load triangle lists
- //
- pouttri = new qfiles.dtriangle_t[pheader.num_tris];
- buffer.position(pheader.ofs_tris);
- for (i=0 ; i<pheader.num_tris ; i++)
- {
- pouttri[i] = new qfiles.dtriangle_t(buffer);
- }
-
- //
- // load the frames
- //
- poutframe = new qfiles.daliasframe_t[pheader.num_frames];
- buffer.position(pheader.ofs_frames);
- for (i=0 ; i<pheader.num_frames ; i++)
- {
- poutframe[i] = new qfiles.daliasframe_t(buffer);
- // verts are all 8 bit, so no swapping needed
- poutframe[i].verts = new qfiles.dtrivertx_t[pheader.num_xyz];
- for (int k=0; k < pheader.num_xyz; k++) {
- poutframe[i].verts[k] = new qfiles.dtrivertx_t(buffer);
- }
- }
-
- mod.type = mod_alias;
-
- //
- // load the glcmds
- //
- poutcmd = new int[pheader.num_glcmds];
- buffer.position(pheader.ofs_glcmds);
- for (i=0 ; i<pheader.num_glcmds ; i++)
- poutcmd[i] = buffer.getInt(); // LittleLong (pincmd[i]);
-
- // register all skins
- String[] skinNames = new String[pheader.num_skins];
- byte[] nameBuf = new byte[qfiles.MAX_SKINNAME];
- buffer.position(pheader.ofs_skins);
- for (i=0 ; i<pheader.num_skins ; i++)
- {
- buffer.get(nameBuf);
- skinNames[i] = new String(nameBuf).trim();
- mod.skins[i] = GL_FindImage(skinNames[i], it_skin);
- }
-
- // set the model arrays
- pheader.skinNames = skinNames; // skin names
- pheader.stVerts = poutst; // textur koordinaten
- pheader.triAngles = pouttri; // dreiecke
- pheader.glCmds = poutcmd; // STRIP or FAN
- pheader.aliasFrames = poutframe; // frames mit vertex array
-
- mod.extradata = pheader;
-
- mod.mins[0] = -32;
- mod.mins[1] = -32;
- mod.mins[2] = -32;
- mod.maxs[0] = 32;
- mod.maxs[1] = 32;
- mod.maxs[2] = 32;
-
- precompileGLCmds(pheader);
- }
-
- /*
- ==============================================================================
-
- SPRITE MODELS
-
- ==============================================================================
- */
-
- /*
- =================
- Mod_LoadSpriteModel
- =================
- */
- void Mod_LoadSpriteModel(model_t mod, ByteBuffer buffer)
- {
- qfiles.dsprite_t sprout = new qfiles.dsprite_t(buffer);
-
- if (sprout.version != qfiles.SPRITE_VERSION)
- ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)",
- new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION));
-
- if (sprout.numframes > qfiles.MAX_MD2SKINS)
- ri.Sys_Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)",
- new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS));
-
- for (int i=0 ; i<sprout.numframes ; i++)
- {
- mod.skins[i] = GL_FindImage(sprout.frames[i].name, it_sprite);
- }
-
- mod.type = mod_sprite;
- mod.extradata = sprout;
- }
-
-// =============================================================================
-
- /*
- @@@@@@@@@@@@@@@@@@@@@
- R_BeginRegistration
-
- Specifies the model that will be used as the world
- @@@@@@@@@@@@@@@@@@@@@
- */
- protected void R_BeginRegistration(String model)
- {
- resetModelArrays();
- resetPolygonArrays();
-
- cvar_t flushmap;
-
- registration_sequence++;
- r_oldviewcluster = -1; // force markleafs
-
- String fullname = "maps/" + model + ".bsp";
-
- // explicitly free the old map if different
- // this guarantees that mod_known[0] is the world map
- flushmap = ri.Cvar_Get("flushmap", "0", 0);
- if ( !mod_known[0].name.equals(fullname) || flushmap.value != 0.0f)
- Mod_Free(mod_known[0]);
- r_worldmodel = Mod_ForName(fullname, true);
-
- r_viewcluster = -1;
- }
-
-
- /*
- @@@@@@@@@@@@@@@@@@@@@
- R_RegisterModel
-
- @@@@@@@@@@@@@@@@@@@@@
- */
- protected model_t R_RegisterModel(String name)
- {
- model_t mod = null;
- int i;
- qfiles.dsprite_t sprout;
- qfiles.dmdl_t pheader;
-
- mod = Mod_ForName(name, false);
- if (mod != null)
- {
- mod.registration_sequence = registration_sequence;
-
- // register any images used by the models
- if (mod.type == mod_sprite)
- {
- sprout = (qfiles.dsprite_t)mod.extradata;
- for (i=0 ; i<sprout.numframes ; i++)
- mod.skins[i] = GL_FindImage(sprout.frames[i].name, it_sprite);
- }
- else if (mod.type == mod_alias)
- {
- pheader = (qfiles.dmdl_t)mod.extradata;
- for (i=0 ; i<pheader.num_skins ; i++)
- mod.skins[i] = GL_FindImage(pheader.skinNames[i], it_skin);
- // PGM
- mod.numframes = pheader.num_frames;
- // PGM
- }
- else if (mod.type == mod_brush)
- {
- for (i=0 ; i<mod.numtexinfo ; i++)
- mod.texinfo[i].image.registration_sequence = registration_sequence;
- }
- }
- return mod;
- }
-
-
- /*
- @@@@@@@@@@@@@@@@@@@@@
- R_EndRegistration
-
- @@@@@@@@@@@@@@@@@@@@@
- */
- protected void R_EndRegistration()
- {
- model_t mod;
-
- for (int i=0; i<mod_numknown ; i++)
- {
- mod = mod_known[i];
- if (mod.name == "")
- continue;
- if (mod.registration_sequence != registration_sequence)
- { // don't need this model
- Mod_Free(mod);
- } else {
- // precompile AliasModels
- if (mod.type == mod_alias)
- precompileGLCmds((qfiles.dmdl_t)mod.extradata);
- }
- }
- GL_FreeUnusedImages();
-
- //modelMemoryUsage();
- }
-
-
-// =============================================================================
-
-
- /*
- ================
- Mod_Free
- ================
- */
- void Mod_Free (model_t mod)
- {
- mod.clear();
- }
-
- /*
- ================
- Mod_FreeAll
- ================
- */
- void Mod_FreeAll()
- {
- for (int i=0 ; i<mod_numknown ; i++)
- {
- if (mod_known[i].extradata != null)
- Mod_Free(mod_known[i]);
- }
- }
-
- /*
- * new functions for vertex array handling
- */
- static final int MODEL_BUFFER_SIZE = 50000;
- static FloatBuffer globalModelTextureCoordBuf = BufferUtils.newFloatBuffer(MODEL_BUFFER_SIZE * 2);
- static IntBuffer globalModelVertexIndexBuf = BufferUtils.newIntBuffer(MODEL_BUFFER_SIZE);
-
- void precompileGLCmds(qfiles.dmdl_t model) {
- model.textureCoordBuf = globalModelTextureCoordBuf.slice();
- model.vertexIndexBuf = globalModelVertexIndexBuf.slice();
- Vector tmp = new Vector();
-
- int count = 0;
- int[] order = model.glCmds;
- int orderIndex = 0;
- while (true)
- {
- // get the vertex count and primitive type
- count = order[orderIndex++];
- if (count == 0)
- break; // done
-
- tmp.addElement(new Integer(count));
-
- if (count < 0)
- {
- count = -count;
- //gl.glBegin (GL.GL_TRIANGLE_FAN);
- }
- else
- {
- //gl.glBegin (GL.GL_TRIANGLE_STRIP);
- }
-
- do {
- // texture coordinates come from the draw list
- globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 0]));
- globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 1]));
- globalModelVertexIndexBuf.put(order[orderIndex + 2]);
-
- orderIndex += 3;
- } while (--count != 0);
- }
-
- int size = tmp.size();
-
- model.counts = new int[size];
- model.indexElements = new IntBuffer[size];
-
- count = 0;
- int pos = 0;
- for (int i = 0; i < model.counts.length; i++) {
- count = ((Integer)tmp.get(i)).intValue();
- model.counts[i] = count;
-
- count = (count < 0) ? -count : count;
- model.vertexIndexBuf.position(pos);
- model.indexElements[i] = model.vertexIndexBuf.slice();
- pos += count;
- }
- }
-
- static void resetModelArrays() {
- globalModelTextureCoordBuf.rewind();
- globalModelVertexIndexBuf.rewind();
- }
-
- static void modelMemoryUsage() {
- System.out.println("AliasModels: globalVertexBuffer size " + globalModelVertexIndexBuf.position());
- }
-}
diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java
deleted file mode 100644
index c7e7bc0..0000000
--- a/src/jake2/render/fastjogl/Surf.java
+++ /dev/null
@@ -1,1464 +0,0 @@
-/*
- * Surf.java
- * Copyright (C) 2003
- *
- * $Id: Surf.java,v 1.1 2004-07-09 06:50:48 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import jake2.Defines;
-import jake2.client.*;
-import jake2.game.cplane_t;
-import jake2.render.*;
-import jake2.util.Lib;
-import jake2.util.Math3D;
-
-import java.nio.*;
-import java.util.Arrays;
-
-import net.java.games.jogl.GL;
-import net.java.games.jogl.util.BufferUtils;
-
-/**
- * Surf
- *
- * @author cwei
- */
-public abstract class Surf extends Draw {
-
- // GL_RSURF.C: surface-related refresh code
- float[] modelorg = {0, 0, 0}; // relative to viewpoint
-
- msurface_t r_alpha_surfaces;
-
- static final int DYNAMIC_LIGHT_WIDTH = 128;
- static final int DYNAMIC_LIGHT_HEIGHT = 128;
-
- static final int LIGHTMAP_BYTES = 4;
-
- static final int BLOCK_WIDTH = 128;
- static final int BLOCK_HEIGHT = 128;
-
- static final int MAX_LIGHTMAPS = 128;
-
- int c_visible_lightmaps;
- int c_visible_textures;
-
- static final int GL_LIGHTMAP_FORMAT = GL.GL_RGBA;
-
- static class gllightmapstate_t
- {
- int internal_format;
- int current_lightmap_texture;
-
- msurface_t[] lightmap_surfaces = new msurface_t[MAX_LIGHTMAPS];
- int[] allocated = new int[BLOCK_WIDTH];
-
- // the lightmap texture data needs to be kept in
- // main memory so texsubimage can update properly
- //byte[] lightmap_buffer = new byte[4 * BLOCK_WIDTH * BLOCK_HEIGHT];
- IntBuffer lightmap_buffer = Lib.newIntBuffer(BLOCK_WIDTH * BLOCK_HEIGHT, ByteOrder.LITTLE_ENDIAN);
-
- public gllightmapstate_t() {
- for (int i = 0; i < MAX_LIGHTMAPS; i++)
- lightmap_surfaces[i] = new msurface_t();
- }
-
- public void clearLightmapSurfaces() {
- for (int i = 0; i < MAX_LIGHTMAPS; i++)
- // TODO lightmap_surfaces[i].clear();
- lightmap_surfaces[i] = new msurface_t();
- }
-
- }
-
- gllightmapstate_t gl_lms = new gllightmapstate_t();
-
- // Model.java
- abstract byte[] Mod_ClusterPVS(int cluster, model_t model);
- // Warp.java
- abstract void R_DrawSkyBox();
- abstract void R_AddSkySurface(msurface_t surface);
- abstract void R_ClearSkyBox();
- abstract void EmitWaterPolys(msurface_t fa);
- // Light.java
- abstract void R_MarkLights (dlight_t light, int bit, mnode_t node);
- abstract void R_SetCacheState( msurface_t surf );
- abstract void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride);
-
- /*
- =============================================================
-
- BRUSH MODELS
-
- =============================================================
- */
-
- /*
- ===============
- R_TextureAnimation
-
- Returns the proper texture for a given time and base texture
- ===============
- */
- image_t R_TextureAnimation(mtexinfo_t tex)
- {
- int c;
-
- if (tex.next == null)
- return tex.image;
-
- c = currententity.frame % tex.numframes;
- while (c != 0)
- {
- tex = tex.next;
- c--;
- }
-
- return tex.image;
- }
-
- /*
- ================
- DrawGLPoly
- ================
- */
- void DrawGLPoly(glpoly_t p)
- {
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
-
- // ============
- // PGM
- /*
- ================
- DrawGLFlowingPoly -- version of DrawGLPoly that handles scrolling texture
- ================
- */
- void DrawGLFlowingPoly(glpoly_t p)
- {
- int i;
- float scroll;
-
- scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) );
- if(scroll == 0.0f)
- scroll = -64.0f;
-
- FloatBuffer texCoord = globalPolygonInterleavedBuf;
- float[][] v = p.verts;
- int index = p.pos * POLYGON_STRIDE;
- for (i=0 ; i<p.numverts ; i++) {
- texCoord.put(index, v[i][3] + scroll);
- index += POLYGON_STRIDE;
- }
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
- // PGM
- // ============
-
- /*
- ** R_DrawTriangleOutlines
- */
- void R_DrawTriangleOutlines()
- {
- int i, j;
- glpoly_t p;
-
- if (gl_showtris.value == 0)
- return;
-
- gl.glDisable (GL.GL_TEXTURE_2D);
- gl.glDisable (GL.GL_DEPTH_TEST);
- gl.glColor4f (1,1,1,1);
-
- for (i=0 ; i<MAX_LIGHTMAPS ; i++)
- {
- msurface_t surf;
-
- for ( surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain )
- {
- p = surf.polys;
- for ( ; p != null ; p=p.chain)
- {
- for (j=2 ; j<p.numverts ; j++ )
- {
- gl.glBegin (GL.GL_LINE_STRIP);
- gl.glVertex3fv (p.verts[0]);
- gl.glVertex3fv (p.verts[j-1]);
- gl.glVertex3fv (p.verts[j]);
- gl.glVertex3fv (p.verts[0]);
- gl.glEnd ();
- }
- }
- }
- }
-
- gl.glEnable (GL.GL_DEPTH_TEST);
- gl.glEnable (GL.GL_TEXTURE_2D);
- }
-
- private IntBuffer temp2 = Lib.newIntBuffer(34 * 34, ByteOrder.LITTLE_ENDIAN);
-
- /*
- ================
- R_RenderBrushPoly
- ================
- */
- void R_RenderBrushPoly(msurface_t fa)
- {
- int maps;
- image_t image;
- boolean is_dynamic = false;
-
- c_brush_polys++;
-
- image = R_TextureAnimation(fa.texinfo);
-
- if ((fa.flags & Defines.SURF_DRAWTURB) != 0)
- {
- GL_Bind( image.texnum );
-
- // warp texture, no lightmaps
- GL_TexEnv( GL.GL_MODULATE );
- gl.glColor4f( gl_state.inverse_intensity,
- gl_state.inverse_intensity,
- gl_state.inverse_intensity,
- 1.0F );
- EmitWaterPolys (fa);
- GL_TexEnv( GL.GL_REPLACE );
-
- return;
- }
- else
- {
- GL_Bind( image.texnum );
- GL_TexEnv( GL.GL_REPLACE );
- }
-
- // ======
- // PGM
- if((fa.texinfo.flags & Defines.SURF_FLOWING) != 0)
- DrawGLFlowingPoly(fa.polys);
- else
- DrawGLPoly (fa.polys);
- // PGM
- // ======
-
- // ersetzt goto
- boolean gotoDynamic = false;
- /*
- ** check for lightmap modification
- */
- for ( maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte)255; maps++ )
- {
- if ( r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps] ) {
- gotoDynamic = true;
- break;
- }
- }
-
- // this is a hack from cwei
- if (maps == 4) maps--;
-
- // dynamic this frame or dynamic previously
- if ( gotoDynamic || ( fa.dlightframe == r_framecount ) )
- {
- // label dynamic:
- if ( gl_dynamic.value != 0 )
- {
- if (( fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP ) ) == 0)
- {
- is_dynamic = true;
- }
- }
- }
-
- if ( is_dynamic )
- {
- if ( ( (fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0 ) && ( fa.dlightframe != r_framecount ) )
- {
- // ist ersetzt durch temp2: unsigned temp[34*34];
- int smax, tmax;
-
- smax = (fa.extents[0]>>4)+1;
- tmax = (fa.extents[1]>>4)+1;
-
- R_BuildLightMap( fa, temp2, smax);
- R_SetCacheState( fa );
-
- GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum );
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- fa.light_s, fa.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp2 );
-
- fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
- gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
- }
- else
- {
- fa.lightmapchain = gl_lms.lightmap_surfaces[0];
- gl_lms.lightmap_surfaces[0] = fa;
- }
- }
- else
- {
- fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
- gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
- }
- }
-
-
- /*
- ================
- R_DrawAlphaSurfaces
-
- Draw water surfaces and windows.
- The BSP tree is waled front to back, so unwinding the chain
- of alpha_surfaces will draw back to front, giving proper ordering.
- ================
- */
- void R_DrawAlphaSurfaces()
- {
- msurface_t s;
- float intens;
-
- //
- // go back to the world matrix
- //
- gl.glLoadMatrixf(r_world_matrix);
-
- gl.glEnable (GL.GL_BLEND);
- GL_TexEnv(GL.GL_MODULATE );
-
-
- // the textures are prescaled up for a better lighting range,
- // so scale it back down
- intens = gl_state.inverse_intensity;
-
- gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf);
-
- for (s=r_alpha_surfaces ; s != null ; s=s.texturechain)
- {
- GL_Bind(s.texinfo.image.texnum);
- c_brush_polys++;
- if ((s.texinfo.flags & Defines.SURF_TRANS33) != 0)
- gl.glColor4f (intens, intens, intens, 0.33f);
- else if ((s.texinfo.flags & Defines.SURF_TRANS66) != 0)
- gl.glColor4f (intens, intens, intens, 0.66f);
- else
- gl.glColor4f (intens,intens,intens,1);
- if ((s.flags & Defines.SURF_DRAWTURB) != 0)
- EmitWaterPolys(s);
- else if((s.texinfo.flags & Defines.SURF_FLOWING) != 0) // PGM 9/16/98
- DrawGLFlowingPoly(s.polys); // PGM
- else
- DrawGLPoly(s.polys);
- }
-
- GL_TexEnv( GL.GL_REPLACE );
- gl.glColor4f (1,1,1,1);
- gl.glDisable (GL.GL_BLEND);
-
- r_alpha_surfaces = null;
- }
-
- /*
- ================
- DrawTextureChains
- ================
- */
- void DrawTextureChains()
- {
- int i;
- msurface_t s;
- image_t image;
-
- c_visible_textures = 0;
-
- for (i = 0; i < numgltextures ; i++)
- {
- image = gltextures[i];
-
- if (image.registration_sequence == 0)
- continue;
- if (image.texturechain == null)
- continue;
- c_visible_textures++;
-
- for ( s = image.texturechain; s != null ; s=s.texturechain)
- {
- if ( ( s.flags & Defines.SURF_DRAWTURB) == 0 )
- R_RenderBrushPoly(s);
- }
- }
-
- GL_EnableMultitexture( false );
- for (i = 0; i < numgltextures ; i++)
- {
- image = gltextures[i];
-
- if (image.registration_sequence == 0)
- continue;
- s = image.texturechain;
- if (s == null)
- continue;
-
- for ( ; s != null ; s=s.texturechain)
- {
- if ( (s.flags & Defines.SURF_DRAWTURB) != 0 )
- R_RenderBrushPoly(s);
- }
-
- image.texturechain = null;
- }
-
- GL_TexEnv( GL.GL_REPLACE );
- }
-
- // direct buffer
- private IntBuffer temp = Lib.newIntBuffer(128 * 128, ByteOrder.LITTLE_ENDIAN);
-
- void GL_RenderLightmappedPoly( msurface_t surf )
- {
- int i, nv = surf.polys.numverts;
- int map = 0;
- int index;
- float[][] v;
- FloatBuffer texCoord = globalPolygonInterleavedBuf;
- image_t image = R_TextureAnimation( surf.texinfo );
- boolean is_dynamic = false;
- int lmtex = surf.lightmaptexturenum;
- glpoly_t p;
-
- // ersetzt goto
- boolean gotoDynamic = false;
-
- for ( map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte)255); map++ )
- {
- if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] ) {
- gotoDynamic = true;
- break;
- }
- }
-
- // this is a hack from cwei
- if (map == 4) map--;
-
- // dynamic this frame or dynamic previously
- if ( gotoDynamic || ( surf.dlightframe == r_framecount ) )
- {
- // label dynamic:
- if ( gl_dynamic.value != 0 )
- {
- if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP )) == 0 )
- {
- is_dynamic = true;
- }
- }
- }
-
- if ( is_dynamic )
- {
- // ist raus gezogen worden int[] temp = new int[128*128];
- int smax, tmax;
-
- if ( ( (surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0 ) && ( surf.dlightframe != r_framecount ) )
- {
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- R_BuildLightMap( surf, temp, smax);
- R_SetCacheState( surf );
-
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
-
- lmtex = surf.lightmaptexturenum;
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- surf.light_s, surf.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp );
-
- }
- else
- {
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- R_BuildLightMap( surf, temp, smax);
-
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
-
- lmtex = 0;
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- surf.light_s, surf.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp );
-
- }
-
- c_brush_polys++;
-
- GL_MBind( GL_TEXTURE0, image.texnum );
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex );
-
- // ==========
- // PGM
- if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0)
- {
- float scroll;
-
- scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) );
- if(scroll == 0.0f)
- scroll = -64.0f;
-
- for ( p = surf.polys; p != null; p = p.chain )
- {
- v = p.verts;
- index = p.pos * POLYGON_STRIDE;
- for (i=0 ; i<p.numverts ; i++) {
- texCoord.put(index, v[i][3] + scroll);
- index += POLYGON_STRIDE;
- }
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
- }
- else
- {
- for ( p = surf.polys; p != null; p = p.chain )
- {
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
- }
- // PGM
- // ==========
- }
- else
- {
- c_brush_polys++;
-
- GL_MBind( GL_TEXTURE0, image.texnum );
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex);
-
- // ==========
- // PGM
- if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0)
- {
- float scroll;
-
- scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) );
- if(scroll == 0.0)
- scroll = -64.0f;
-
- for ( p = surf.polys; p != null; p = p.chain )
- {
- v = p.verts;
- index = p.pos * POLYGON_STRIDE;
- for (i=0 ; i<p.numverts ; i++) {
- texCoord.put(index, v[i][3] + scroll);
- index += POLYGON_STRIDE;
- }
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
- }
- else
- {
- // PGM
- // ==========
- for ( p = surf.polys; p != null; p = p.chain )
- {
- gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts);
- }
-
- // ==========
- // PGM
- }
- // PGM
- // ==========
- }
- }
-
- /*
- =================
- R_DrawInlineBModel
- =================
- */
- void R_DrawInlineBModel()
- {
- int i, k;
- cplane_t pplane;
- float dot;
- msurface_t psurf;
- dlight_t lt;
-
- // calculate dynamic lighting for bmodel
- if ( gl_flashblend.value == 0 )
- {
- for (k=0 ; k<r_newrefdef.num_dlights ; k++)
- {
- lt = r_newrefdef.dlights[k];
- R_MarkLights(lt, 1<<k, currentmodel.nodes[currentmodel.firstnode]);
- }
- }
-
- // psurf = &currentmodel->surfaces[currentmodel->firstmodelsurface];
- int psurfp = currentmodel.firstmodelsurface;
- msurface_t[] surfaces;
- surfaces = currentmodel.surfaces;
- //psurf = surfaces[psurfp];
-
- if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 )
- {
- gl.glEnable (GL.GL_BLEND);
- gl.glColor4f (1,1,1,0.25f);
- GL_TexEnv( GL.GL_MODULATE );
- }
-
- //
- // draw texture
- //
- for (i=0 ; i<currentmodel.nummodelsurfaces ; i++)
- {
- psurf = surfaces[psurfp++];
- // find which side of the node we are on
- pplane = psurf.plane;
-
- dot = Math3D.DotProduct(modelorg, pplane.normal) - pplane.dist;
-
- // draw the polygon
- if (((psurf.flags & Defines.SURF_PLANEBACK) != 0 && (dot < -BACKFACE_EPSILON)) ||
- ((psurf.flags & Defines.SURF_PLANEBACK) == 0 && (dot > BACKFACE_EPSILON)))
- {
- if ((psurf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0 )
- { // add to the translucent chain
- psurf.texturechain = r_alpha_surfaces;
- r_alpha_surfaces = psurf;
- }
- else if ( (psurf.flags & Defines.SURF_DRAWTURB) == 0 )
- {
- GL_RenderLightmappedPoly( psurf );
- }
- else
- {
- GL_EnableMultitexture( false );
- R_RenderBrushPoly( psurf );
- GL_EnableMultitexture( true );
- }
- }
- }
-
- if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) {
- gl.glDisable (GL.GL_BLEND);
- gl.glColor4f (1,1,1,1);
- GL_TexEnv( GL.GL_REPLACE );
- }
- }
-
- /*
- =================
- R_DrawBrushModel
- =================
- */
- void R_DrawBrushModel(entity_t e)
- {
- float[] mins = {0, 0, 0};
- float[] maxs = {0, 0, 0};
- int i;
- boolean rotated;
-
- if (currentmodel.nummodelsurfaces == 0)
- return;
-
- currententity = e;
- gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1;
-
- if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0)
- {
- rotated = true;
- for (i=0 ; i<3 ; i++)
- {
- mins[i] = e.origin[i] - currentmodel.radius;
- maxs[i] = e.origin[i] + currentmodel.radius;
- }
- }
- else
- {
- rotated = false;
- Math3D.VectorAdd(e.origin, currentmodel.mins, mins);
- Math3D.VectorAdd(e.origin, currentmodel.maxs, maxs);
- }
-
- if (R_CullBox(mins, maxs)) return;
-
- gl.glColor3f (1,1,1);
-
- // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));
-
- // TODO wird beim multitexturing nicht gebraucht
- //gl_lms.clearLightmapSurfaces();
-
- Math3D.VectorSubtract (r_newrefdef.vieworg, e.origin, modelorg);
- if (rotated)
- {
- float[] temp = {0, 0, 0};
- float[] forward = {0, 0, 0};
- float[] right = {0, 0, 0};
- float[] up = {0, 0, 0};
-
- Math3D.VectorCopy (modelorg, temp);
- Math3D.AngleVectors (e.angles, forward, right, up);
- modelorg[0] = Math3D.DotProduct (temp, forward);
- modelorg[1] = -Math3D.DotProduct (temp, right);
- modelorg[2] = Math3D.DotProduct (temp, up);
- }
-
- gl.glPushMatrix();
-
- e.angles[0] = -e.angles[0]; // stupid quake bug
- e.angles[2] = -e.angles[2]; // stupid quake bug
- R_RotateForEntity(e);
- e.angles[0] = -e.angles[0]; // stupid quake bug
- e.angles[2] = -e.angles[2]; // stupid quake bug
-
- GL_EnableMultitexture( true );
- GL_SelectTexture(GL_TEXTURE0);
- GL_TexEnv( GL.GL_REPLACE );
- gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf);
- GL_SelectTexture(GL_TEXTURE1);
- GL_TexEnv( GL.GL_MODULATE );
- gl.glTexCoordPointer(2, GL.GL_FLOAT, POLYGON_BYTE_STRIDE, globalPolygonTexCoord1Buf);
- gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
-
- R_DrawInlineBModel();
-
- gl.glClientActiveTextureARB(GL_TEXTURE1);
- gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
-
- GL_EnableMultitexture( false );
-
- gl.glPopMatrix();
- }
-
- /*
- =============================================================
-
- WORLD MODEL
-
- =============================================================
- */
-
- /*
- ================
- R_RecursiveWorldNode
- ================
- */
- void R_RecursiveWorldNode (mnode_t node)
- {
- int c, side, sidebit;
- cplane_t plane;
- msurface_t surf;
- msurface_t mark;
- mleaf_t pleaf;
- float dot = 0;
- image_t image;
-
- if (node.contents == Defines.CONTENTS_SOLID)
- return; // solid
-
- if (node.visframe != r_visframecount)
- return;
-
- if (R_CullBox(node.mins, node.maxs))
- return;
-
- // if a leaf node, draw stuff
- if (node.contents != -1)
- {
- pleaf = (mleaf_t)node;
-
- // check for door connected areas
- if (r_newrefdef.areabits != null)
- {
- if ( ((r_newrefdef.areabits[pleaf.area >> 3] & 0xFF) & (1 << (pleaf.area & 7)) ) == 0 )
- return; // not visible
- }
-
- int markp = 0;
-
- mark = pleaf.getMarkSurface(markp); // first marked surface
- c = pleaf.nummarksurfaces;
-
- if (c != 0)
- {
- do
- {
- mark.visframe = r_framecount;
- mark = pleaf.getMarkSurface(++markp); // next surface
- } while (--c != 0);
- }
-
- return;
- }
-
- // node is just a decision point, so go down the apropriate sides
-
- // find which side of the node we are on
- plane = node.plane;
-
- switch (plane.type)
- {
- case Defines.PLANE_X:
- dot = modelorg[0] - plane.dist;
- break;
- case Defines.PLANE_Y:
- dot = modelorg[1] - plane.dist;
- break;
- case Defines.PLANE_Z:
- dot = modelorg[2] - plane.dist;
- break;
- default:
- dot = Math3D.DotProduct(modelorg, plane.normal) - plane.dist;
- break;
- }
-
- if (dot >= 0.0f)
- {
- side = 0;
- sidebit = 0;
- }
- else
- {
- side = 1;
- sidebit = Defines.SURF_PLANEBACK;
- }
-
- // recurse down the children, front side first
- R_RecursiveWorldNode(node.children[side]);
-
- // draw stuff
- //for ( c = node.numsurfaces, surf = r_worldmodel.surfaces[node.firstsurface]; c != 0 ; c--, surf++)
- for ( c = 0; c < node.numsurfaces; c++)
- {
- surf = r_worldmodel.surfaces[node.firstsurface + c];
- if (surf.visframe != r_framecount)
- continue;
-
- if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit )
- continue; // wrong side
-
- if ((surf.texinfo.flags & Defines.SURF_SKY) != 0)
- { // just adds to visible sky bounds
- R_AddSkySurface(surf);
- }
- else if ((surf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0)
- { // add to the translucent chain
- surf.texturechain = r_alpha_surfaces;
- r_alpha_surfaces = surf;
- }
- else
- {
- if ( ( surf.flags & Defines.SURF_DRAWTURB) == 0 )
- {
- GL_RenderLightmappedPoly( surf );
- }
- else
- {
- // the polygon is visible, so add it to the texture
- // sorted chain
- // FIXME: this is a hack for animation
- image = R_TextureAnimation(surf.texinfo);
- surf.texturechain = image.texturechain;
- image.texturechain = surf;
- }
- }
- }
-
- // recurse down the back side
- R_RecursiveWorldNode(node.children[1 - side]);
- }
-
-
- /*
- =============
- R_DrawWorld
- =============
- */
- void R_DrawWorld()
- {
- entity_t ent = new entity_t();
-
- if (r_drawworld.value == 0)
- return;
-
- if ( (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0 )
- return;
-
- currentmodel = r_worldmodel;
-
- Math3D.VectorCopy(r_newrefdef.vieworg, modelorg);
-
- // auto cycle the world frame for texture animation
- // memset (&ent, 0, sizeof(ent));
- ent.frame = (int)(r_newrefdef.time*2);
- currententity = ent;
-
- gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1;
-
- gl.glColor3f (1,1,1);
- // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces));
- // TODO wird bei multitexture nicht gebraucht
- //gl_lms.clearLightmapSurfaces();
-
- R_ClearSkyBox();
-
- GL_EnableMultitexture( true );
-
- GL_SelectTexture( GL_TEXTURE0);
- GL_TexEnv( GL.GL_REPLACE );
- gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf);
- GL_SelectTexture( GL_TEXTURE1);
- gl.glTexCoordPointer(2, GL.GL_FLOAT, POLYGON_BYTE_STRIDE, globalPolygonTexCoord1Buf);
- gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
-
- if ( gl_lightmap.value != 0)
- GL_TexEnv( GL.GL_REPLACE );
- else
- GL_TexEnv( GL.GL_MODULATE );
-
- R_RecursiveWorldNode(r_worldmodel.nodes[0]); // root node
-
- gl.glClientActiveTextureARB(GL_TEXTURE1);
- gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
-
- GL_EnableMultitexture( false );
-
- DrawTextureChains();
- R_DrawSkyBox();
- R_DrawTriangleOutlines();
- }
-
- byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8];
-
- /*
- ===============
- R_MarkLeaves
-
- Mark the leaves and nodes that are in the PVS for the current
- cluster
- ===============
- */
- void R_MarkLeaves()
- {
- byte[] vis;
- //byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8];
-
- Arrays.fill(fatvis, (byte)0);
-
- mnode_t node;
- int i, c;
- mleaf_t leaf;
- int cluster;
-
- if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && r_novis.value == 0 && r_viewcluster != -1)
- return;
-
- // development aid to let you run around and see exactly where
- // the pvs ends
- if (gl_lockpvs.value != 0)
- return;
-
- r_visframecount++;
- r_oldviewcluster = r_viewcluster;
- r_oldviewcluster2 = r_viewcluster2;
-
- if (r_novis.value != 0 || r_viewcluster == -1 || r_worldmodel.vis == null)
- {
- // mark everything
- for (i=0 ; i<r_worldmodel.numleafs ; i++)
- r_worldmodel.leafs[i].visframe = r_visframecount;
- for (i=0 ; i<r_worldmodel.numnodes ; i++)
- r_worldmodel.nodes[i].visframe = r_visframecount;
- return;
- }
-
- vis = Mod_ClusterPVS(r_viewcluster, r_worldmodel);
- // may have to combine two clusters because of solid water boundaries
- if (r_viewcluster2 != r_viewcluster)
- {
- // memcpy (fatvis, vis, (r_worldmodel.numleafs+7)/8);
- System.arraycopy(vis, 0, fatvis, 0, (r_worldmodel.numleafs+7) / 8);
- 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++];
- }
-
- vis = fatvis;
- }
-
- for ( i=0; i < r_worldmodel.numleafs; i++)
- {
- leaf = r_worldmodel.leafs[i];
- cluster = leaf.cluster;
- if (cluster == -1)
- continue;
- if (((vis[cluster>>3] & 0xFF) & (1 << (cluster & 7))) != 0)
- {
- node = (mnode_t)leaf;
- do
- {
- if (node.visframe == r_visframecount)
- break;
- node.visframe = r_visframecount;
- node = node.parent;
- } while (node != null);
- }
- }
- }
-
-
-
- /*
- =============================================================================
-
- LIGHTMAP ALLOCATION
-
- =============================================================================
- */
-
- void LM_InitBlock()
- {
- Arrays.fill(gl_lms.allocated, 0);
- }
-
- void LM_UploadBlock( boolean dynamic )
- {
- int texture;
- int height = 0;
-
- if ( dynamic )
- {
- texture = 0;
- }
- else
- {
- texture = gl_lms.current_lightmap_texture;
- }
-
- GL_Bind( gl_state.lightmap_textures + texture );
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
-
- if ( dynamic )
- {
- int i;
-
- for ( i = 0; i < BLOCK_WIDTH; i++ )
- {
- if ( gl_lms.allocated[i] > height )
- height = gl_lms.allocated[i];
- }
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D,
- 0,
- 0, 0,
- BLOCK_WIDTH, height,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE,
- gl_lms.lightmap_buffer );
- }
- else
- {
- gl.glTexImage2D( GL.GL_TEXTURE_2D,
- 0,
- gl_lms.internal_format,
- BLOCK_WIDTH, BLOCK_HEIGHT,
- 0,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE,
- gl_lms.lightmap_buffer );
- if ( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS )
- ri.Sys_Error( Defines.ERR_DROP, "LM_UploadBlock() - MAX_LIGHTMAPS exceeded\n" );
-
-
- //debugLightmap(gl_lms.lightmap_buffer, 128, 128, 4);
-
- }
- }
-
- // returns a texture number and the position inside it
- boolean LM_AllocBlock (int w, int h, pos_t pos)
- {
- int x = pos.x;
- int y = pos.y;
- int i, j;
- int best, best2;
-
- best = BLOCK_HEIGHT;
-
- for (i=0 ; i<BLOCK_WIDTH-w ; i++)
- {
- best2 = 0;
-
- for (j=0 ; j<w ; j++)
- {
- if (gl_lms.allocated[i+j] >= best)
- break;
- if (gl_lms.allocated[i+j] > best2)
- best2 = gl_lms.allocated[i+j];
- }
- if (j == w)
- { // this is a valid spot
- pos.x = x = i;
- pos.y = y = best = best2;
- }
- }
-
- if (best + h > BLOCK_HEIGHT)
- return false;
-
- for (i=0 ; i<w ; i++)
- gl_lms.allocated[x + i] = best + h;
-
- return true;
- }
-
- /*
- ================
- GL_BuildPolygonFromSurface
- ================
- */
- void GL_BuildPolygonFromSurface(msurface_t fa)
- {
- int i, lindex, lnumverts;
- medge_t[] pedges;
- medge_t r_pedge;
- int vertpage;
- float[] vec;
- float s, t;
- glpoly_t poly;
- float[] total = {0, 0, 0};
-
- // reconstruct the polygon
- pedges = currentmodel.edges;
- lnumverts = fa.numedges;
- vertpage = 0;
-
- Math3D.VectorClear(total);
- //
- // draw texture
- //
- // poly = Hunk_Alloc (sizeof(glpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float));
- poly = new glpoly_t(lnumverts);
-
- poly.next = fa.polys;
- poly.flags = fa.flags;
- fa.polys = poly;
- poly.numverts = lnumverts;
-
- for (i=0 ; i<lnumverts ; i++)
- {
- lindex = currentmodel.surfedges[fa.firstedge + i];
-
- if (lindex > 0)
- {
- r_pedge = pedges[lindex];
- vec = currentmodel.vertexes[r_pedge.v[0]].position;
- }
- else
- {
- r_pedge = pedges[-lindex];
- vec = currentmodel.vertexes[r_pedge.v[1]].position;
- }
- s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3];
- s /= fa.texinfo.image.width;
-
- t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3];
- t /= fa.texinfo.image.height;
-
- Math3D.VectorAdd (total, vec, total);
- Math3D.VectorCopy (vec, poly.verts[i]);
- poly.verts[i][3] = s;
- poly.verts[i][4] = t;
-
- //
- // lightmap texture coordinates
- //
- s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3];
- s -= fa.texturemins[0];
- s += fa.light_s*16;
- s += 8;
- s /= BLOCK_WIDTH*16; //fa.texinfo.texture.width;
-
- t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3];
- t -= fa.texturemins[1];
- t += fa.light_t*16;
- t += 8;
- t /= BLOCK_HEIGHT*16; //fa.texinfo.texture.height;
-
- poly.verts[i][5] = s;
- poly.verts[i][6] = t;
- }
-
- poly.numverts = lnumverts;
-
- precompilePolygon(poly);
-
- }
-
- /*
- ========================
- GL_CreateSurfaceLightmap
- ========================
- */
- void GL_CreateSurfaceLightmap(msurface_t surf)
- {
- int smax, tmax;
- IntBuffer base;
-
- if ( (surf.flags & (Defines.SURF_DRAWSKY | Defines.SURF_DRAWTURB)) != 0)
- return;
-
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- pos_t lightPos = new pos_t(surf.light_s, surf.light_t);
-
- if ( !LM_AllocBlock( smax, tmax, lightPos ) )
- {
- LM_UploadBlock( false );
- LM_InitBlock();
- lightPos = new pos_t(surf.light_s, surf.light_t);
- if ( !LM_AllocBlock( smax, tmax, lightPos ) )
- {
- ri.Sys_Error( Defines.ERR_FATAL, "Consecutive calls to LM_AllocBlock(" + smax +"," + tmax +") failed\n");
- }
- }
-
- // kopiere die koordinaten zurueck
- surf.light_s = lightPos.x;
- surf.light_t = lightPos.y;
-
- surf.lightmaptexturenum = gl_lms.current_lightmap_texture;
-
- base = gl_lms.lightmap_buffer;
- base.position(surf.light_t * BLOCK_WIDTH + surf.light_s);
-
- R_SetCacheState( surf );
- R_BuildLightMap(surf, base.slice(), BLOCK_WIDTH);
- }
-
- lightstyle_t[] lightstyles;
- IntBuffer dummy = BufferUtils.newIntBuffer(128*128);
-
- /*
- ==================
- GL_BeginBuildingLightmaps
-
- ==================
- */
- void GL_BeginBuildingLightmaps(model_t m)
- {
- // static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
- int i;
-
- // init lightstyles
- if ( lightstyles == null ) {
- lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES];
- for (i = 0; i < lightstyles.length; i++)
- {
- lightstyles[i] = new lightstyle_t();
- }
- }
-
- // memset( gl_lms.allocated, 0, sizeof(gl_lms.allocated) );
- Arrays.fill(gl_lms.allocated, 0);
-
- r_framecount = 1; // no dlightcache
-
- GL_EnableMultitexture( true );
- GL_SelectTexture( GL_TEXTURE1);
-
- /*
- ** setup the base lightstyles so the lightmaps won't have to be regenerated
- ** the first time they're seen
- */
- for (i=0 ; i < Defines.MAX_LIGHTSTYLES ; i++)
- {
- lightstyles[i].rgb[0] = 1;
- lightstyles[i].rgb[1] = 1;
- lightstyles[i].rgb[2] = 1;
- lightstyles[i].white = 3;
- }
- r_newrefdef.lightstyles = lightstyles;
-
- if (gl_state.lightmap_textures == 0)
- {
- gl_state.lightmap_textures = TEXNUM_LIGHTMAPS;
- }
-
- gl_lms.current_lightmap_texture = 1;
-
- /*
- ** if mono lightmaps are enabled and we want to use alpha
- ** blending (a,1-a) then we're likely running on a 3DLabs
- ** Permedia2. In a perfect world we'd use a GL_ALPHA lightmap
- ** in order to conserve space and maximize bandwidth, however
- ** this isn't a perfect world.
- **
- ** So we have to use alpha lightmaps, but stored in GL_RGBA format,
- ** which means we only get 1/16th the color resolution we should when
- ** using alpha lightmaps. If we find another board that supports
- ** only alpha lightmaps but that can at least support the GL_ALPHA
- ** format then we should change this code to use real alpha maps.
- */
-
- char format = gl_monolightmap.string.toUpperCase().charAt(0);
-
- if ( format == 'A' )
- {
- gl_lms.internal_format = gl_tex_alpha_format;
- }
- /*
- ** try to do hacked colored lighting with a blended texture
- */
- else if ( format == 'C' )
- {
- gl_lms.internal_format = gl_tex_alpha_format;
- }
- else if ( format == 'I' )
- {
- gl_lms.internal_format = GL.GL_INTENSITY8;
- }
- else if ( format == 'L' )
- {
- gl_lms.internal_format = GL.GL_LUMINANCE8;
- }
- else
- {
- gl_lms.internal_format = gl_tex_solid_format;
- }
-
- /*
- ** initialize the dynamic lightmap texture
- */
- GL_Bind( gl_state.lightmap_textures + 0 );
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
- gl.glTexImage2D( GL.GL_TEXTURE_2D,
- 0,
- gl_lms.internal_format,
- BLOCK_WIDTH, BLOCK_HEIGHT,
- 0,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE,
- dummy );
- }
-
- /*
- =======================
- GL_EndBuildingLightmaps
- =======================
- */
- void GL_EndBuildingLightmaps()
- {
- LM_UploadBlock( false );
- GL_EnableMultitexture( false );
- }
-
- /*
- * new functions for vertex array handling
- */
- static final int POLYGON_BUFFER_SIZE = 120000;
- static final int POLYGON_STRIDE = 7;
- static final int POLYGON_BYTE_STRIDE = POLYGON_STRIDE * BufferUtils.SIZEOF_FLOAT;
-
- static FloatBuffer globalPolygonInterleavedBuf = BufferUtils.newFloatBuffer(POLYGON_BUFFER_SIZE * 7);
- static FloatBuffer globalPolygonTexCoord1Buf = null;
-
- static {
- globalPolygonInterleavedBuf.position(POLYGON_STRIDE - 2);
- globalPolygonTexCoord1Buf = globalPolygonInterleavedBuf.slice();
- globalPolygonInterleavedBuf.position(0);
- };
-
- void precompilePolygon(glpoly_t p) {
-
- p.pos = globalPolygonInterleavedBuf.position() / POLYGON_STRIDE;
-
- float[] v;
- FloatBuffer buffer = globalPolygonInterleavedBuf;
-
- for (int i = 0; i < p.verts.length; i++) {
- v = p.verts[i];
- // textureCoord0
- buffer.put(v[3]);
- buffer.put(v[4]);
-
- // vertex
- buffer.put(v[0]);
- buffer.put(v[1]);
- buffer.put(v[2]);
-
- // textureCoord1
- buffer.put(v[5]);
- buffer.put(v[6]);
- }
- }
-
- public static void resetPolygonArrays() {
- globalPolygonInterleavedBuf.rewind();
- }
-
- //ImageFrame frame;
-
-// void debugLightmap(byte[] buf, int w, int h, float scale) {
-// IntBuffer pix = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();
-//
-// int[] pixel = new int[w * h];
-//
-// pix.get(pixel);
-//
-// BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR);
-// image.setRGB(0, 0, w, h, pixel, 0, w);
-// AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(scale, scale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
-// BufferedImage tmp = op.filter(image, null);
-//
-// if (frame == null) {
-// frame = new ImageFrame(null);
-// frame.show();
-// }
-// frame.showImage(tmp);
-//
-// }
-
-}
diff --git a/src/jake2/render/fastjogl/Warp.java b/src/jake2/render/fastjogl/Warp.java
deleted file mode 100644
index f9a5b07..0000000
--- a/src/jake2/render/fastjogl/Warp.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * Warp.java
- * Copyright (C) 2003
- *
- * $Id: Warp.java,v 1.1 2004-07-09 06:50:49 hzi 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.
-
-*/
-package jake2.render.fastjogl;
-
-import java.nio.FloatBuffer;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.game.GameBase;
-import jake2.render.glpoly_t;
-import jake2.render.image_t;
-import jake2.render.msurface_t;
-import jake2.util.Math3D;
-import net.java.games.jogl.GL;
-
-/**
- * Warp
- *
- * @author cwei
- */
-public abstract class Warp extends Model {
-
-
- // warpsin.h
- public static final float[] SIN = {
- 0f, 0.19633f, 0.392541f, 0.588517f, 0.784137f, 0.979285f, 1.17384f, 1.3677f,
- 1.56072f, 1.75281f, 1.94384f, 2.1337f, 2.32228f, 2.50945f, 2.69512f, 2.87916f,
- 3.06147f, 3.24193f, 3.42044f, 3.59689f, 3.77117f, 3.94319f, 4.11282f, 4.27998f,
- 4.44456f, 4.60647f, 4.76559f, 4.92185f, 5.07515f, 5.22538f, 5.37247f, 5.51632f,
- 5.65685f, 5.79398f, 5.92761f, 6.05767f, 6.18408f, 6.30677f, 6.42566f, 6.54068f,
- 6.65176f, 6.75883f, 6.86183f, 6.9607f, 7.05537f, 7.14579f, 7.23191f, 7.31368f,
- 7.39104f, 7.46394f, 7.53235f, 7.59623f, 7.65552f, 7.71021f, 7.76025f, 7.80562f,
- 7.84628f, 7.88222f, 7.91341f, 7.93984f, 7.96148f, 7.97832f, 7.99036f, 7.99759f,
- 8f, 7.99759f, 7.99036f, 7.97832f, 7.96148f, 7.93984f, 7.91341f, 7.88222f,
- 7.84628f, 7.80562f, 7.76025f, 7.71021f, 7.65552f, 7.59623f, 7.53235f, 7.46394f,
- 7.39104f, 7.31368f, 7.23191f, 7.14579f, 7.05537f, 6.9607f, 6.86183f, 6.75883f,
- 6.65176f, 6.54068f, 6.42566f, 6.30677f, 6.18408f, 6.05767f, 5.92761f, 5.79398f,
- 5.65685f, 5.51632f, 5.37247f, 5.22538f, 5.07515f, 4.92185f, 4.76559f, 4.60647f,
- 4.44456f, 4.27998f, 4.11282f, 3.94319f, 3.77117f, 3.59689f, 3.42044f, 3.24193f,
- 3.06147f, 2.87916f, 2.69512f, 2.50945f, 2.32228f, 2.1337f, 1.94384f, 1.75281f,
- 1.56072f, 1.3677f, 1.17384f, 0.979285f, 0.784137f, 0.588517f, 0.392541f, 0.19633f,
- 9.79717e-16f, -0.19633f, -0.392541f, -0.588517f, -0.784137f, -0.979285f, -1.17384f, -1.3677f,
- -1.56072f, -1.75281f, -1.94384f, -2.1337f, -2.32228f, -2.50945f, -2.69512f, -2.87916f,
- -3.06147f, -3.24193f, -3.42044f, -3.59689f, -3.77117f, -3.94319f, -4.11282f, -4.27998f,
- -4.44456f, -4.60647f, -4.76559f, -4.92185f, -5.07515f, -5.22538f, -5.37247f, -5.51632f,
- -5.65685f, -5.79398f, -5.92761f, -6.05767f, -6.18408f, -6.30677f, -6.42566f, -6.54068f,
- -6.65176f, -6.75883f, -6.86183f, -6.9607f, -7.05537f, -7.14579f, -7.23191f, -7.31368f,
- -7.39104f, -7.46394f, -7.53235f, -7.59623f, -7.65552f, -7.71021f, -7.76025f, -7.80562f,
- -7.84628f, -7.88222f, -7.91341f, -7.93984f, -7.96148f, -7.97832f, -7.99036f, -7.99759f,
- -8f, -7.99759f, -7.99036f, -7.97832f, -7.96148f, -7.93984f, -7.91341f, -7.88222f,
- -7.84628f, -7.80562f, -7.76025f, -7.71021f, -7.65552f, -7.59623f, -7.53235f, -7.46394f,
- -7.39104f, -7.31368f, -7.23191f, -7.14579f, -7.05537f, -6.9607f, -6.86183f, -6.75883f,
- -6.65176f, -6.54068f, -6.42566f, -6.30677f, -6.18408f, -6.05767f, -5.92761f, -5.79398f,
- -5.65685f, -5.51632f, -5.37247f, -5.22538f, -5.07515f, -4.92185f, -4.76559f, -4.60647f,
- -4.44456f, -4.27998f, -4.11282f, -3.94319f, -3.77117f, -3.59689f, -3.42044f, -3.24193f,
- -3.06147f, -2.87916f, -2.69512f, -2.50945f, -2.32228f, -2.1337f, -1.94384f, -1.75281f,
- -1.56072f, -1.3677f, -1.17384f, -0.979285f, -0.784137f, -0.588517f, -0.392541f, -0.19633f
- };
-
- // gl_warp.c -- sky and water polygons
- //extern model_t *loadmodel; // Model.java
-
- String skyname;
- float skyrotate;
- float[] skyaxis = {0, 0, 0};
- image_t[] sky_images = new image_t[6];
-
- msurface_t warpface;
-
- static final int SUBDIVIDE_SIZE = 64;
-
- void BoundPoly(int numverts, float[][] verts, float[] mins, float[] maxs)
- {
- int i, j;
- float[] v;
-
- mins[0] = mins[1] = mins[2] = 9999;
- maxs[0] = maxs[1] = maxs[2] = -9999;
- for (i=0 ; i<numverts ; i++)
- {
- v = verts[i];
- for (j=0 ; j<3 ; j++)
- {
- if (v[j] < mins[j])
- mins[j] = v[j];
- if (v[j] > maxs[j])
- maxs[j] = v[j];
- }
- }
- }
-
- void SubdividePolygon(int numverts, float[][] verts)
- {
- int i, j, k;
- float[] mins = {0, 0, 0};
- float[] maxs = {0, 0, 0};
- float m;
- float[] v = {0, 0, 0};
- float[][] front = new float[64][3];
- float[][] back = new float[64][3];
-
- int f, b;
- float[] dist = new float[64];
- float frac;
- glpoly_t poly;
- float s, t;
- float[] total = {0, 0, 0};
- float total_s, total_t;
-
- if (numverts > 60)
- ri.Sys_Error(Defines.ERR_DROP, "numverts = " + numverts);
-
- BoundPoly(numverts, verts, mins, maxs);
-
- // x,y und z
- for (i=0 ; i<3 ; i++)
- {
- m = (mins[i] + maxs[i]) * 0.5f;
- m = SUBDIVIDE_SIZE * (float)Math.floor(m / SUBDIVIDE_SIZE + 0.5f);
- if (maxs[i] - m < 8)
- continue;
- if (m - mins[i] < 8)
- continue;
-
- // cut it
- for (j=0 ; j<numverts ; j++) {
- dist[j] = verts[j][i] - m;
- }
-
- // wrap cases
- dist[j] = dist[0];
-
- Math3D.VectorCopy(verts[0], verts[numverts]);
-
- f = b = 0;
- for (j=0 ; j<numverts ; j++)
- {
- v = verts[j];
- if (dist[j] >= 0)
- {
- Math3D.VectorCopy(v, front[f]);
- f++;
- }
- if (dist[j] <= 0)
- {
- Math3D.VectorCopy(v, back[b]);
- b++;
- }
- if (dist[j] == 0 || dist[j+1] == 0) continue;
-
- if ( (dist[j] > 0) != (dist[j+1] > 0) )
- {
- // clip point
- frac = dist[j] / (dist[j] - dist[j+1]);
- for (k=0 ; k<3 ; k++)
- front[f][k] = back[b][k] = v[k] + frac*(verts[j+1][k] - v[k]);
-
- f++;
- b++;
- }
- }
-
- SubdividePolygon(f, front);
- SubdividePolygon(b, back);
- return;
- }
-
- // add a point in the center to help keep warp valid
-
- // wird im Konstruktor erschlagen
- // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));
-
- // init polys
- poly = new glpoly_t(numverts + 2);
-
- poly.next = warpface.polys;
- warpface.polys = poly;
- poly.numverts = numverts + 2;
- Math3D.VectorClear(total);
- total_s = 0;
- total_t = 0;
- for (i=0 ; i<numverts ; i++)
- {
- Math3D.VectorCopy(verts[i], poly.verts[i+1]);
- s = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[0]);
- t = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[1]);
-
- total_s += s;
- total_t += t;
- Math3D.VectorAdd(total, verts[i], total);
-
- poly.verts[i+1][3] = s;
- poly.verts[i+1][4] = t;
- }
-
- Math3D.VectorScale(total, (1.0f/numverts), poly.verts[0]);
- poly.verts[0][3] = total_s/numverts;
- poly.verts[0][4] = total_t/numverts;
-
- // memcpy (poly.verts[i+1], poly.verts[1], sizeof(poly.verts[0]));
- System.arraycopy(poly.verts[1], 0, poly.verts[i+1], 0, poly.verts[1].length); // :-)
-
- precompilePolygon(poly);
- }
-
- /*
- ================
- GL_SubdivideSurface
-
- Breaks a polygon up along axial 64 unit
- boundaries so that turbulent and sky warps
- can be done reasonably.
- ================
- */
- void GL_SubdivideSurface(msurface_t fa)
- {
- float[][] verts = new float[64][3];
-
- int numverts;
- int i;
- int lindex;
- float[] vec;
-
- warpface = fa;
-
- //
- // convert edges back to a normal polygon
- //
- numverts = 0;
- for (i=0 ; i < fa.numedges ; i++)
- {
- lindex = loadmodel.surfedges[fa.firstedge + i];
-
- if (lindex > 0)
- vec = loadmodel.vertexes[loadmodel.edges[lindex].v[0]].position;
- else
- vec = loadmodel.vertexes[loadmodel.edges[-lindex].v[1]].position;
- Math3D.VectorCopy(vec, verts[numverts]);
- numverts++;
- }
-
- SubdividePolygon(numverts, verts);
- }
-
-// =========================================================
-
-
-
-//// speed up sin calculations - Ed
-// float r_turbsin[] =
-// {
-// #include "warpsin.h"
-// };
- static final float TURBSCALE = (float)(256.0f / (2 * Math.PI));
-
- /*
- =============
- EmitWaterPolys
-
- Does a water warp on the pre-fragmented glpoly_t chain
- =============
- */
- void EmitWaterPolys(msurface_t fa)
- {
- glpoly_t p, bp;
- float[] v;
- int i;
- float s = 0;
- float t = 0;
- float os, ot;
- float scroll;
- float rdt = r_newrefdef.time;
-
- if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0)
- scroll = -64 * ( (r_newrefdef.time*0.5f) - (int)(r_newrefdef.time*0.5f) );
- else
- scroll = 0;
-
- int index;
- FloatBuffer texCoord = globalPolygonInterleavedBuf;
- for (bp=fa.polys ; bp != null ; bp=bp.next)
- {
- p = bp;
-
- index = p.pos * POLYGON_STRIDE;
- for (i=0; i<p.numverts ; i++)
- {
- v = p.verts[i];
- os = v[3];
- ot = v[4];
-
- s = os + Warp.SIN[(int)((ot * 0.125f + r_newrefdef.time) * TURBSCALE) & 255];
- s += scroll;
- s *= (1.0f/64);
-
- t = ot + Warp.SIN[(int)((os * 0.125f + rdt) * TURBSCALE) & 255];
- t *= (1.0f/64);
-
- texCoord.put(index, s);
- texCoord.put(index + 1, t);
- index += POLYGON_STRIDE;
- }
- gl.glDrawArrays(GL.GL_TRIANGLE_FAN, p.pos, p.numverts);
- }
- }
-
-// ===================================================================
-
-
- float[][] skyclip = {
- { 1, 1, 0},
- { 1, -1, 0},
- { 0, -1, 1},
- { 0, 1, 1},
- { 1, 0, 1},
- {-1, 0, 1}
- };
-
- int c_sky;
-
- // 1 = s, 2 = t, 3 = 2048
- int[][] st_to_vec =
- {
- {3,-1,2},
- {-3,1,2},
-
- {1,3,2},
- {-1,-3,2},
-
- {-2,-1,3}, // 0 degrees yaw, look straight up
- {2,-1,-3} // look straight down
-
- };
-
- int[][] vec_to_st =
- {
- {-2,3,1},
- {2,3,-1},
-
- {1,3,2},
- {-1,3,-2},
-
- {-2,-1,3},
- {-2,1,-3}
-
- };
-
- float[][] skymins = new float[2][6];
- float[][] skymaxs = new float[2][6];
- float sky_min, sky_max;
-
- void DrawSkyPolygon (int nump, float[][] vecs)
- {
- int i,j;
- float[] v = {0, 0, 0};
- float[] av = {0, 0, 0};
- float s, t, dv;
- int axis;
- float[] vp;
-
- c_sky++;
- // decide which face it maps to
- Math3D.VectorCopy(Globals.vec3_origin, v);
- for (i=0; i<nump ; i++)
- {
- Math3D.VectorAdd(vecs[i], v, v);
- }
- av[0] = Math.abs(v[0]);
- av[1] = Math.abs(v[1]);
- av[2] = Math.abs(v[2]);
- if (av[0] > av[1] && av[0] > av[2])
- {
- if (v[0] < 0)
- axis = 1;
- else
- axis = 0;
- }
- else if (av[1] > av[2] && av[1] > av[0])
- {
- if (v[1] < 0)
- axis = 3;
- else
- axis = 2;
- }
- else
- {
- if (v[2] < 0)
- axis = 5;
- else
- axis = 4;
- }
-
- // project new texture coords
- for (i=0 ; i<nump ; i++)
- {
- j = vec_to_st[axis][2];
- if (j > 0)
- dv = vecs[i][j - 1];
- else
- dv = -vecs[i][-j - 1];
- if (dv < 0.001f)
- continue; // don't divide by zero
- j = vec_to_st[axis][0];
- if (j < 0)
- s = -vecs[i][-j -1] / dv;
- else
- s = vecs[i][j-1] / dv;
- j = vec_to_st[axis][1];
- if (j < 0)
- t = -vecs[i][-j -1] / dv;
- else
- t = vecs[i][j-1] / dv;
-
- if (s < skymins[0][axis])
- skymins[0][axis] = s;
- if (t < skymins[1][axis])
- skymins[1][axis] = t;
- if (s > skymaxs[0][axis])
- skymaxs[0][axis] = s;
- if (t > skymaxs[1][axis])
- skymaxs[1][axis] = t;
- }
- }
-
- static final float ON_EPSILON = 0.1f; // point on plane side epsilon
- static final int MAX_CLIP_VERTS = 64;
-
- static final int SIDE_BACK = 1;
- static final int SIDE_FRONT = 0;
- static final int SIDE_ON = 2;
-
- float[] dists = new float[MAX_CLIP_VERTS];
- int[] sides = new int[MAX_CLIP_VERTS];
- float[][][][] newv = new float[6][2][MAX_CLIP_VERTS][3];
-
- void ClipSkyPolygon(int nump, float[][] vecs, int stage)
- {
- float[] norm;
- float[] v;
- boolean front, back;
- float d, e;
- int[] newc = { 0, 0 };
- int i, j;
-
- if (nump > MAX_CLIP_VERTS-2)
- ri.Sys_Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS");
- if (stage == 6)
- { // fully clipped, so draw it
- DrawSkyPolygon(nump, vecs);
- return;
- }
-
- front = back = false;
- norm = skyclip[stage];
- for (i=0 ; i<nump ; i++)
- {
- d = Math3D.DotProduct(vecs[i], norm);
- if (d > ON_EPSILON)
- {
- front = true;
- sides[i] = SIDE_FRONT;
- }
- else if (d < -ON_EPSILON)
- {
- back = true;
- sides[i] = SIDE_BACK;
- }
- else
- sides[i] = SIDE_ON;
- dists[i] = d;
- }
-
- if (!front || !back)
- { // not clipped
- ClipSkyPolygon (nump, vecs, stage+1);
- return;
- }
-
- // clip it
- sides[i] = sides[0];
- dists[i] = dists[0];
- Math3D.VectorCopy(vecs[0], vecs[i]);
- newc[0] = newc[1] = 0;
-
- for (i=0; i<nump ; i++)
- {
- v = vecs[i];
- switch (sides[i])
- {
- case SIDE_FRONT:
- Math3D.VectorCopy(v, newv[stage][0][newc[0]]);
- newc[0]++;
- break;
- case SIDE_BACK:
- Math3D.VectorCopy(v, newv[stage][1][newc[1]]);
- newc[1]++;
- break;
- case SIDE_ON:
- Math3D.VectorCopy(v, newv[stage][0][newc[0]]);
- newc[0]++;
- Math3D.VectorCopy (v, newv[stage][1][newc[1]]);
- newc[1]++;
- break;
- }
-
- if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
- continue;
-
- d = dists[i] / (dists[i] - dists[i+1]);
- for (j=0 ; j<3 ; j++)
- {
- e = v[j] + d * (vecs[i + 1][j] - v[j]);
- newv[stage][0][newc[0]][j] = e;
- newv[stage][1][newc[1]][j] = e;
- }
- newc[0]++;
- newc[1]++;
- }
-
- // continue
- ClipSkyPolygon(newc[0], newv[stage][0], stage+1);
- ClipSkyPolygon(newc[1], newv[stage][1], stage+1);
- }
-
- float[][] verts = new float[MAX_CLIP_VERTS][3];
-
- /*
- =================
- R_AddSkySurface
- =================
- */
- void R_AddSkySurface(msurface_t fa)
- {
- int i;
- glpoly_t p;
-
- // calculate vertex values for sky box
- for (p=fa.polys ; p != null ; p=p.next)
- {
- for (i=0 ; i < p.numverts ; i++)
- {
- Math3D.VectorSubtract(p.verts[i], r_origin, verts[i]);
- }
- ClipSkyPolygon (p.numverts, verts, 0);
- }
- }
-
-
- /*
- ==============
- R_ClearSkyBox
- ==============
- */
- void R_ClearSkyBox()
- {
- int i;
-
- for (i=0 ; i<6 ; i++)
- {
- skymins[0][i] = skymins[1][i] = 9999;
- skymaxs[0][i] = skymaxs[1][i] = -9999;
- }
- }
-
-
- void MakeSkyVec (float s, float t, int axis)
- {
- float[] v = {0, 0, 0};
- float[] b = {0, 0, 0};
- int j, k;
-
- b[0] = s*2300;
- b[1] = t*2300;
- b[2] = 2300;
-
- for (j=0 ; j<3 ; j++)
- {
- k = st_to_vec[axis][j];
- if (k < 0)
- v[j] = -b[-k - 1];
- else
- v[j] = b[k - 1];
- }
-
- // avoid bilerp seam
- s = (s + 1) * 0.5f;
- t = (t + 1) * 0.5f;
-
- if (s < sky_min)
- s = sky_min;
- else if (s > sky_max)
- s = sky_max;
- if (t < sky_min)
- t = sky_min;
- else if (t > sky_max)
- t = sky_max;
-
- t = 1.0f - t;
- gl.glTexCoord2f (s, t);
- gl.glVertex3f(v[0], v[1], v[2]);
- }
-
- /*
- ==============
- R_DrawSkyBox
- ==============
- */
- int[] skytexorder = {0,2,1,3,4,5};
-
- void R_DrawSkyBox()
- {
- int i;
-
- if (skyrotate != 0)
- { // check for no sky at all
- for (i=0 ; i<6 ; i++)
- if (skymins[0][i] < skymaxs[0][i]
- && skymins[1][i] < skymaxs[1][i])
- break;
- if (i == 6)
- return; // nothing visible
- }
-
- gl.glPushMatrix ();
- gl.glTranslatef (r_origin[0], r_origin[1], r_origin[2]);
- gl.glRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);
-
- for (i=0 ; i<6 ; i++)
- {
- if (skyrotate != 0)
- { // hack, forces full sky to draw when rotating
- skymins[0][i] = -1;
- skymins[1][i] = -1;
- skymaxs[0][i] = 1;
- skymaxs[1][i] = 1;
- }
-
- if (skymins[0][i] >= skymaxs[0][i]
- || skymins[1][i] >= skymaxs[1][i])
- continue;
-
- GL_Bind(sky_images[skytexorder[i]].texnum);
-
- gl.glBegin(GL.GL_QUADS);
- MakeSkyVec(skymins[0][i], skymins[1][i], i);
- MakeSkyVec(skymins[0][i], skymaxs[1][i], i);
- MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i);
- MakeSkyVec(skymaxs[0][i], skymins[1][i], i);
- gl.glEnd ();
- }
- gl.glPopMatrix ();
- }
-
-
- /*
- ============
- R_SetSky
- ============
- */
- // 3dstudio environment map names
- String[] suf = {"rt", "bk", "lf", "ft", "up", "dn"};
-
- protected void R_SetSky(String name, float rotate, float[] axis)
- {
- assert (axis.length == 3) : "vec3_t bug";
- int i;
- String pathname;
-
-// strncpy (skyname, name, sizeof(skyname)-1);
- skyname = name;
-
- skyrotate = rotate;
- Math3D.VectorCopy(axis, skyaxis);
-
- for (i=0 ; i<6 ; i++)
- {
- // chop down rotating skies for less memory
- if (gl_skymip.value != 0 || skyrotate != 0)
- gl_picmip.value++;
-
- if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0) {
- // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]);
- pathname = "env/" + skyname + suf[i] + ".pcx";
- } else {
- // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
- pathname = "env/" + skyname + suf[i] + ".tga";
- }
-
- sky_images[i] = GL_FindImage(pathname, it_sky);
-
- if (sky_images[i] == null)
- sky_images[i] = r_notexture;
-
- if (gl_skymip.value != 0 || skyrotate != 0)
- { // take less memory
- gl_picmip.value--;
- sky_min = 1.0f / 256;
- sky_max = 255.0f / 256;
- }
- else
- {
- sky_min = 1.0f / 512;
- sky_max = 511.0f / 512;
- }
- }
- }
-
-
-}
diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java
index 4e65481..0f29750 100644
--- a/src/jake2/render/jogl/Image.java
+++ b/src/jake2/render/jogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Image.java,v 1.1 2004-07-07 19:59:38 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -549,179 +549,204 @@ public abstract class Image extends Main {
//
// =========================================================
// */
+ //
+ // typedef struct _TargaHeader {
+ // unsigned char id_length, colormap_type, image_type;
+ // unsigned short colormap_index, colormap_length;
+ // unsigned char colormap_size;
+ // unsigned short x_origin, y_origin, width, height;
+ // unsigned char pixel_size, attributes;
+ // } TargaHeader;
+ //
+ //
/*
=============
LoadTGA
=============
*/
byte[] LoadTGA(String name, Dimension dim) {
- int columns, rows, numPixels;
- int pixbuf; // index into pic
- int row, column;
- byte[] raw;
- ByteBuffer buf_p;
- int length;
- qfiles.tga_t targa_header;
- byte[] pic = null;
-
+ // TODO LoadTGA()
+ // int columns, rows, numPixels;
+ // byte *pixbuf;
+ // int row, column;
+ // byte *buf_p;
+ // byte *buffer;
+ // int length;
+ // TargaHeader targa_header;
+ // byte *targa_rgba;
+ // byte tmp[2];
//
- // load the file
+ // *pic = NULL;
//
- raw = ri.FS_LoadFile (name);
-
- if (raw == null)
- {
- ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n');
- return null;
- }
-
- targa_header = new qfiles.tga_t(raw);
-
- if (targa_header.image_type != 2 && targa_header.image_type != 10)
- ri.Sys_Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
-
- if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
- ri.Sys_Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
-
- columns = targa_header.width;
- rows = targa_header.height;
- numPixels = columns * rows;
-
- if (dim != null) {
- dim.width = columns;
- dim.height = rows;
- }
-
- pic = new byte[numPixels * 4]; // targa_rgba;
-
- if (targa_header.id_length != 0)
- targa_header.data.position(targa_header.id_length); // skip TARGA image comment
-
- buf_p = targa_header.data;
-
- byte red,green,blue,alphabyte;
- red = green = blue = alphabyte = 0;
- int packetHeader, packetSize, j;
-
- if (targa_header.image_type==2) { // Uncompressed, RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
-
- for(column=0; column<columns; column++) {
- switch (targa_header.pixel_size) {
- case 24:
-
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- }
- }
- }
- else if (targa_header.image_type==10) { // Runlength encoded RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
- try {
-
- for(column=0; column<columns; ) {
-
- packetHeader= buf_p.get() & 0xFF;
- packetSize = 1 + (packetHeader & 0x7f);
-
- if ((packetHeader & 0x80) != 0) { // run-length packet
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- break;
- }
-
- for(j=0;j<packetSize;j++) {
- pic[pixbuf++]=red;
- pic[pixbuf++]=green;
- pic[pixbuf++]=blue;
- pic[pixbuf++]=alphabyte;
- column++;
- if (column==columns) { // run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- else { // non run-length packet
- for(j=0;j<packetSize;j++) {
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- column++;
- if (column==columns) { // pixel packet run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- }
- } catch (longjmpException e){
- // label breakOut:
- }
- }
- }
- return pic;
+ // //
+ // // load the file
+ // //
+ // length = ri.FS_LoadFile (name, (void **)&buffer);
+ // if (!buffer)
+ // {
+ // ri.Con_Printf (PRINT_DEVELOPER, "Bad tga file %s\n", name);
+ // return;
+ // }
+ //
+ // buf_p = buffer;
+ //
+ // targa_header.id_length = *buf_p++;
+ // targa_header.colormap_type = *buf_p++;
+ // targa_header.image_type = *buf_p++;
+ //
+ // tmp[0] = buf_p[0];
+ // tmp[1] = buf_p[1];
+ // targa_header.colormap_index = LittleShort ( *((short *)tmp) );
+ // buf_p+=2;
+ // tmp[0] = buf_p[0];
+ // tmp[1] = buf_p[1];
+ // targa_header.colormap_length = LittleShort ( *((short *)tmp) );
+ // buf_p+=2;
+ // targa_header.colormap_size = *buf_p++;
+ // targa_header.x_origin = LittleShort ( *((short *)buf_p) );
+ // buf_p+=2;
+ // targa_header.y_origin = LittleShort ( *((short *)buf_p) );
+ // buf_p+=2;
+ // targa_header.width = LittleShort ( *((short *)buf_p) );
+ // buf_p+=2;
+ // targa_header.height = LittleShort ( *((short *)buf_p) );
+ // buf_p+=2;
+ // targa_header.pixel_size = *buf_p++;
+ // targa_header.attributes = *buf_p++;
+ //
+ // if (targa_header.image_type!=2
+ // && targa_header.image_type!=10)
+ // ri.Sys_Error (ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
+ //
+ // if (targa_header.colormap_type !=0
+ // || (targa_header.pixel_size!=32 && targa_header.pixel_size!=24))
+ // ri.Sys_Error (ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
+ //
+ // columns = targa_header.width;
+ // rows = targa_header.height;
+ // numPixels = columns * rows;
+ //
+ // if (width)
+ // *width = columns;
+ // if (height)
+ // *height = rows;
+ //
+ // targa_rgba = malloc (numPixels*4);
+ // *pic = targa_rgba;
+ //
+ // if (targa_header.id_length != 0)
+ // buf_p += targa_header.id_length; // skip TARGA image comment
+ //
+ // if (targa_header.image_type==2) { // Uncompressed, RGB images
+ // for(row=rows-1; row>=0; row--) {
+ // pixbuf = targa_rgba + row*columns*4;
+ // for(column=0; column<columns; column++) {
+ // unsigned char red,green,blue,alphabyte;
+ // switch (targa_header.pixel_size) {
+ // case 24:
+ //
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // *pixbuf++ = red;
+ // *pixbuf++ = green;
+ // *pixbuf++ = blue;
+ // *pixbuf++ = 255;
+ // break;
+ // case 32:
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // alphabyte = *buf_p++;
+ // *pixbuf++ = red;
+ // *pixbuf++ = green;
+ // *pixbuf++ = blue;
+ // *pixbuf++ = alphabyte;
+ // break;
+ // }
+ // }
+ // }
+ // }
+ // else if (targa_header.image_type==10) { // Runlength encoded RGB images
+ // unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
+ // for(row=rows-1; row>=0; row--) {
+ // pixbuf = targa_rgba + row*columns*4;
+ // for(column=0; column<columns; ) {
+ // packetHeader= *buf_p++;
+ // packetSize = 1 + (packetHeader & 0x7f);
+ // if (packetHeader & 0x80) { // run-length packet
+ // switch (targa_header.pixel_size) {
+ // case 24:
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // alphabyte = 255;
+ // break;
+ // case 32:
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // alphabyte = *buf_p++;
+ // break;
+ // }
+ //
+ // for(j=0;j<packetSize;j++) {
+ // *pixbuf++=red;
+ // *pixbuf++=green;
+ // *pixbuf++=blue;
+ // *pixbuf++=alphabyte;
+ // column++;
+ // if (column==columns) { // run spans across rows
+ // column=0;
+ // if (row>0)
+ // row--;
+ // else
+ // goto breakOut;
+ // pixbuf = targa_rgba + row*columns*4;
+ // }
+ // }
+ // }
+ // else { // non run-length packet
+ // for(j=0;j<packetSize;j++) {
+ // switch (targa_header.pixel_size) {
+ // case 24:
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // *pixbuf++ = red;
+ // *pixbuf++ = green;
+ // *pixbuf++ = blue;
+ // *pixbuf++ = 255;
+ // break;
+ // case 32:
+ // blue = *buf_p++;
+ // green = *buf_p++;
+ // red = *buf_p++;
+ // alphabyte = *buf_p++;
+ // *pixbuf++ = red;
+ // *pixbuf++ = green;
+ // *pixbuf++ = blue;
+ // *pixbuf++ = alphabyte;
+ // break;
+ // }
+ // column++;
+ // if (column==columns) { // pixel packet run spans across rows
+ // column=0;
+ // if (row>0)
+ // row--;
+ // else
+ // goto breakOut;
+ // pixbuf = targa_rgba + row*columns*4;
+ // }
+ // }
+ // }
+ // }
+ // breakOut:;
+ // }
+ // }
+ //
+ // ri.FS_FreeFile (buffer);
+ return null; // remove this
}
/*
diff --git a/src/jake2/render/jogl/Impl.java b/src/jake2/render/jogl/Impl.java
index 991c349..48241db 100644
--- a/src/jake2/render/jogl/Impl.java
+++ b/src/jake2/render/jogl/Impl.java
@@ -2,7 +2,7 @@
* Impl.java
* Copyright (C) 2003
*
- * $Id: Impl.java,v 1.4 2004-07-08 20:56:55 hzi Exp $
+ * $Id: Impl.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -27,10 +27,7 @@ package jake2.render.jogl;
import jake2.Defines;
import jake2.Globals;
-import jake2.client.CL;
-import jake2.qcommon.Com;
import jake2.qcommon.xcommand_t;
-import jake2.server.SV;
import jake2.sys.KBD;
import java.awt.Dimension;
@@ -129,7 +126,9 @@ public class Impl extends Misc implements GLEventListener {
// register event listener
window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
- ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit");
+ R_Shutdown();
+ System.out.println("Received event " + e.paramString() + ", exiting...\n");
+ System.exit(0);
}
});
@@ -138,12 +137,11 @@ public class Impl extends Misc implements GLEventListener {
canvas.addMouseListener(KBD.listener);
canvas.addMouseMotionListener(KBD.listener);
window.addComponentListener(KBD.listener);
- canvas.requestFocus();
-
+
window.pack();
window.show();
canvas.requestFocus();
-
+
this.canvas = canvas;
vid.width = newDim.width;
@@ -224,10 +222,12 @@ public class Impl extends Misc implements GLEventListener {
this.contextInUse = true;
if (switchToCallback) {
- callback.execute();
+ if (callback == null)
+ ri.updateScreenCallback();
+ else
+ callback.execute();
}
- else
- {
+ else {
// after the first run (initialization) switch to callback
switchToCallback = true;
@@ -271,9 +271,9 @@ public class Impl extends Misc implements GLEventListener {
* @see jake2.client.refexport_t#updateScreen()
*/
public void updateScreen(xcommand_t callback) {
-// if (canvas == null) {
-// throw new IllegalStateException("Refresh modul \"" + DRIVER_NAME + "\" have to be initialized.");
-// }
+ if (canvas == null) {
+ throw new IllegalStateException("Refresh modul \"" + DRIVER_NAME + "\" have to be initialized.");
+ }
this.callback = callback;
canvas.display();
}
diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java
index 686884a..fc23e4a 100644
--- a/src/jake2/render/jogl/Light.java
+++ b/src/jake2/render/jogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.3 2004-07-08 20:56:55 hzi Exp $
+ * $Id: Light.java,v 1.1 2004-07-07 19:59:38 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,8 +29,6 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.Arrays;
-import net.java.games.jogl.GL;
-
import jake2.Defines;
import jake2.Globals;
import jake2.client.dlight_t;
@@ -66,30 +64,30 @@ public abstract class Light extends Warp {
void R_RenderDlight (dlight_t light)
{
- int i, j;
- float a;
- float[] v = {0, 0, 0};
- float rad;
-
- rad = light.intensity * 0.35f;
-
- Math3D.VectorSubtract (light.origin, r_origin, v);
-
- gl.glBegin (GL.GL_TRIANGLE_FAN);
- gl.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f);
- for (i=0 ; i<3 ; i++)
- v[i] = light.origin[i] - vpn[i]*rad;
- gl.glVertex3fv (v);
- gl.glColor3f (0,0,0);
- for (i=16 ; i>=0 ; i--)
- {
- a = (float)(i/16.0f * Math.PI*2);
- for (j=0 ; j<3 ; j++)
- v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad
- + vup[j]*Math.sin(a)*rad);
- gl.glVertex3fv (v);
- }
- gl.glEnd ();
+// int i, j;
+// float a;
+// vec3_t v;
+// float rad;
+//
+// rad = light.intensity * 0.35;
+//
+// VectorSubtract (light.origin, r_origin, v);
+//
+// qglBegin (GL_TRIANGLE_FAN);
+// qglColor3f (light.color[0]*0.2, light.color[1]*0.2, light.color[2]*0.2);
+// for (i=0 ; i<3 ; i++)
+// v[i] = light.origin[i] - vpn[i]*rad;
+// qglVertex3fv (v);
+// qglColor3f (0,0,0);
+// for (i=16 ; i>=0 ; i--)
+// {
+// a = i/16.0 * M_PI*2;
+// for (j=0 ; j<3 ; j++)
+// v[j] = light.origin[j] + vright[j]*cos(a)*rad
+// + vup[j]*sin(a)*rad;
+// qglVertex3fv (v);
+// }
+// qglEnd ();
}
/*
@@ -99,31 +97,29 @@ public abstract class Light extends Warp {
*/
void R_RenderDlights()
{
- int i;
- dlight_t l;
-
- if (gl_flashblend.value == 0)
- return;
-
- r_dlightframecount = r_framecount + 1; // because the count hasn't
- // advanced yet for this frame
- gl.glDepthMask(false);
- gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glShadeModel (GL.GL_SMOOTH);
- gl.glEnable (GL.GL_BLEND);
- gl.glBlendFunc (GL.GL_ONE, GL.GL_ONE);
-
- for (i=0 ; i<r_newrefdef.num_dlights ; i++)
- {
- l = r_newrefdef.dlights[i];
- R_RenderDlight (l);
- }
-
- gl.glColor3f (1,1,1);
- gl.glDisable(GL.GL_BLEND);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- gl.glDepthMask(true);
+// int i;
+// dlight_t *l;
+//
+// if (!gl_flashblend.value)
+// return;
+//
+// r_dlightframecount = r_framecount + 1; // because the count hasn't
+// // advanced yet for this frame
+// qglDepthMask (0);
+// qglDisable (GL_TEXTURE_2D);
+// qglShadeModel (GL_SMOOTH);
+// qglEnable (GL_BLEND);
+// qglBlendFunc (GL_ONE, GL_ONE);
+//
+// l = r_newrefdef.dlights;
+// for (i=0 ; i<r_newrefdef.num_dlights ; i++, l++)
+// R_RenderDlight (l);
+//
+// qglColor3f (1,1,1);
+// qglDisable (GL_BLEND);
+// qglEnable (GL_TEXTURE_2D);
+// qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+// qglDepthMask (1);
}
@@ -146,7 +142,6 @@ public abstract class Light extends Warp {
float dist;
msurface_t surf;
int i;
- int sidebit;
if (node.contents != -1)
return;
@@ -168,22 +163,7 @@ public abstract class Light extends Warp {
// mark the polygons
for (i=0 ; i<node.numsurfaces ; i++)
{
-
surf = r_worldmodel.surfaces[node.firstsurface + i];
-
- /*
- * cwei
- * bugfix for dlight behind the walls
- */
- dist = Math3D.DotProduct (light.origin, surf.plane.normal) - surf.plane.dist;
- sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK;
- if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit )
- continue;
- /*
- * cwei
- * bugfix end
- */
-
if (surf.dlightframe != r_dlightframecount)
{
surf.dlightbits = 0;
@@ -410,78 +390,76 @@ public abstract class Light extends Warp {
*/
void R_AddDynamicLights(msurface_t surf)
{
- int lnum;
- int sd, td;
- float fdist, frad, fminlight;
- float[] impact = {0, 0, 0};
- float[] local = {0, 0, 0};
- int s, t;
- int i;
- int smax, tmax;
- mtexinfo_t tex;
- dlight_t dl;
- float[] pfBL;
- float fsacc, ftacc;
-
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
- tex = surf.texinfo;
-
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
- {
- if ( (surf.dlightbits & (1<<lnum)) == 0 )
- continue; // not lit by this light
-
- dl = r_newrefdef.dlights[lnum];
- frad = dl.intensity;
- fdist = Math3D.DotProduct (dl.origin, surf.plane.normal) -
- surf.plane.dist;
- frad -= Math.abs(fdist);
- // rad is now the highest intensity on the plane
-
- fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
- if (frad < fminlight)
- continue;
- fminlight = frad - fminlight;
-
- for (i=0 ; i<3 ; i++)
- {
- impact[i] = dl.origin[i] -
- surf.plane.normal[i]*fdist;
- }
-
- local[0] = Math3D.DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0];
- local[1] = Math3D.DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1];
-
- pfBL = s_blocklights;
- int pfBLindex = 0;
- for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
- {
- td = (int)(local[1] - ftacc);
- if ( td < 0 )
- td = -td;
-
- for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3)
- {
- sd = (int)( local[0] - fsacc );
-
- if ( sd < 0 )
- sd = -sd;
-
- if (sd > td)
- fdist = sd + (td>>1);
- else
- fdist = td + (sd>>1);
-
- if ( fdist < fminlight )
- {
- pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0];
- pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1];
- pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2];
- }
- }
- }
- }
+// int lnum;
+// int sd, td;
+// float fdist, frad, fminlight;
+// vec3_t impact, local;
+// int s, t;
+// int i;
+// int smax, tmax;
+// mtexinfo_t *tex;
+// dlight_t *dl;
+// float *pfBL;
+// float fsacc, ftacc;
+//
+// smax = (surf.extents[0]>>4)+1;
+// tmax = (surf.extents[1]>>4)+1;
+// tex = surf.texinfo;
+//
+// for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
+// {
+// if ( !(surf.dlightbits & (1<<lnum) ) )
+// continue; // not lit by this light
+//
+// dl = &r_newrefdef.dlights[lnum];
+// frad = dl.intensity;
+// fdist = DotProduct (dl.origin, surf.plane.normal) -
+// surf.plane.dist;
+// frad -= fabs(fdist);
+// // rad is now the highest intensity on the plane
+//
+// fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
+// if (frad < fminlight)
+// continue;
+// fminlight = frad - fminlight;
+//
+// for (i=0 ; i<3 ; i++)
+// {
+// impact[i] = dl.origin[i] -
+// surf.plane.normal[i]*fdist;
+// }
+//
+// local[0] = DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0];
+// local[1] = DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1];
+//
+// pfBL = s_blocklights;
+// for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
+// {
+// td = local[1] - ftacc;
+// if ( td < 0 )
+// td = -td;
+//
+// for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBL += 3)
+// {
+// sd = Q_ftol( local[0] - fsacc );
+//
+// if ( sd < 0 )
+// sd = -sd;
+//
+// if (sd > td)
+// fdist = sd + (td>>1);
+// else
+// fdist = td + (sd>>1);
+//
+// if ( fdist < fminlight )
+// {
+// pfBL[0] += ( frad - fdist ) * dl.color[0];
+// pfBL[1] += ( frad - fdist ) * dl.color[1];
+// pfBL[2] += ( frad - fdist ) * dl.color[2];
+// }
+// }
+// }
+// }
}
diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java
index 37e4445..45d28bb 100644
--- a/src/jake2/render/jogl/Mesh.java
+++ b/src/jake2/render/jogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Mesh.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -228,7 +228,7 @@ public abstract class Mesh extends Light {
else
{
gl.glEnableClientState( GL.GL_COLOR_ARRAY );
- gl.glColorPointer( 4, GL.GL_FLOAT, 0, colorArrayBuf );
+ gl.glColorPointer( 3, GL.GL_FLOAT, 0, colorArrayBuf );
//
// pre light everything
@@ -237,7 +237,7 @@ public abstract class Mesh extends Light {
for ( i = 0; i < paliashdr.num_xyz; i++ )
{
l = shadedots[verts[i].lightnormalindex];
- colorArrayBuf.put(l * shadelight[0]).put(l * shadelight[1]).put(l * shadelight[2]).put(alpha);
+ colorArrayBuf.put(l * shadelight[0]).put(l * shadelight[1]).put(l * shadelight[2]);
}
}
diff --git a/src/jake2/render/jogl/Surf.java b/src/jake2/render/jogl/Surf.java
index 7f05332..7baf69f 100644
--- a/src/jake2/render/jogl/Surf.java
+++ b/src/jake2/render/jogl/Surf.java
@@ -2,7 +2,7 @@
* Surf.java
* Copyright (C) 2003
*
- * $Id: Surf.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Surf.java,v 1.1 2004-07-07 19:59:43 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -36,8 +36,6 @@ import java.util.Collection;
import java.util.Iterator;
import net.java.games.jogl.GL;
-import net.java.games.jogl.util.BufferUtils;
-
import jake2.Defines;
import jake2.client.dlight_t;
import jake2.client.entity_t;
@@ -88,21 +86,15 @@ public abstract class Surf extends Draw {
int current_lightmap_texture;
msurface_t[] lightmap_surfaces = new msurface_t[MAX_LIGHTMAPS];
+
int[] allocated = new int[BLOCK_WIDTH];
// the lightmap texture data needs to be kept in
// main memory so texsubimage can update properly
byte[] lightmap_buffer = new byte[4 * BLOCK_WIDTH * BLOCK_HEIGHT];
-
- public gllightmapstate_t() {
- for (int i = 0; i < MAX_LIGHTMAPS; i++)
- lightmap_surfaces[i] = new msurface_t();
- }
-
public void clearLightmapSurfaces() {
for (int i = 0; i < MAX_LIGHTMAPS; i++)
- // TODO lightmap_surfaces[i].clear();
lightmap_surfaces[i] = new msurface_t();
}
@@ -398,74 +390,64 @@ public abstract class Surf extends Draw {
for ( surf = gl_lms.lightmap_surfaces[0]; surf != null; surf = surf.lightmapchain )
{
- int smax, tmax;
- ByteBuffer base;
-
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- pos_t lightPos = new pos_t(surf.dlight_s, surf.dlight_t);
-
- if ( LM_AllocBlock( smax, tmax, lightPos) )
- {
- // kopiere die koordinaten zurueck
- surf.dlight_s = lightPos.x;
- surf.dlight_t = lightPos.y;
-
- base = ByteBuffer.wrap(gl_lms.lightmap_buffer);
- base.position( ( surf.dlight_t * BLOCK_WIDTH + surf.dlight_s ) * LIGHTMAP_BYTES);
-
- R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
- }
- else
- {
- msurface_t drawsurf;
-
- // upload what we have so far
- LM_UploadBlock( true );
-
- // draw all surfaces that use this lightmap
- for ( drawsurf = newdrawsurf; drawsurf != surf; drawsurf = drawsurf.lightmapchain )
- {
- if ( drawsurf.polys != null )
- DrawGLPolyChain( drawsurf.polys,
- ( drawsurf.light_s - drawsurf.dlight_s ) * ( 1.0f / 128.0f ),
- ( drawsurf.light_t - drawsurf.dlight_t ) * ( 1.0f / 128.0f ) );
- }
-
- newdrawsurf = drawsurf;
-
- // clear the block
- LM_InitBlock();
-
- // try uploading the block now
- if ( !LM_AllocBlock( smax, tmax, lightPos) )
- {
- ri.Sys_Error( Defines.ERR_FATAL, "Consecutive calls to LM_AllocBlock(" + smax + "," + tmax + ") failed (dynamic)\n");
- }
-
- // kopiere die koordinaten zurueck
- surf.dlight_s = lightPos.x;
- surf.dlight_t = lightPos.y;
-
- base = ByteBuffer.wrap(gl_lms.lightmap_buffer);
- base.position( ( surf.dlight_t * BLOCK_WIDTH + surf.dlight_s ) * LIGHTMAP_BYTES);
-
- R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
- }
+// int smax, tmax;
+// byte *base;
+//
+// smax = (surf->extents[0]>>4)+1;
+// tmax = (surf->extents[1]>>4)+1;
+//
+// if ( LM_AllocBlock( smax, tmax, &surf->dlight_s, &surf->dlight_t ) )
+// {
+// base = gl_lms.lightmap_buffer;
+// base += ( surf->dlight_t * BLOCK_WIDTH + surf->dlight_s ) * LIGHTMAP_BYTES;
+//
+// R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+// }
+// else
+// {
+// msurface_t *drawsurf;
+//
+// // upload what we have so far
+// LM_UploadBlock( true );
+//
+// // draw all surfaces that use this lightmap
+// for ( drawsurf = newdrawsurf; drawsurf != surf; drawsurf = drawsurf->lightmapchain )
+// {
+// if ( drawsurf->polys )
+// DrawGLPolyChain( drawsurf->polys,
+// ( drawsurf->light_s - drawsurf->dlight_s ) * ( 1.0 / 128.0 ),
+// ( drawsurf->light_t - drawsurf->dlight_t ) * ( 1.0 / 128.0 ) );
+// }
+//
+// newdrawsurf = drawsurf;
+//
+// // clear the block
+// LM_InitBlock();
+//
+// // try uploading the block now
+// if ( !LM_AllocBlock( smax, tmax, &surf->dlight_s, &surf->dlight_t ) )
+// {
+// ri.Sys_Error( ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed (dynamic)\n", smax, tmax );
+// }
+//
+// base = gl_lms.lightmap_buffer;
+// base += ( surf->dlight_t * BLOCK_WIDTH + surf->dlight_s ) * LIGHTMAP_BYTES;
+//
+// R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+// }
}
/*
** draw remainder of dynamic lightmaps that haven't been uploaded yet
*/
- if ( newdrawsurf != null )
- LM_UploadBlock( true );
-
- for ( surf = newdrawsurf; surf != null; surf = surf.lightmapchain )
- {
- if ( surf.polys != null )
- DrawGLPolyChain( surf.polys, ( surf.light_s - surf.dlight_s ) * ( 1.0f / 128.0f ), ( surf.light_t - surf.dlight_t ) * ( 1.0f / 128.0f ) );
- }
+// if ( newdrawsurf != null )
+// LM_UploadBlock( true );
+//
+// for ( surf = newdrawsurf; surf != null; surf = surf.lightmapchain )
+// {
+// if ( surf.polys != null )
+// DrawGLPolyChain( surf.polys, ( surf.light_s - surf.dlight_s ) * ( 1.0f / 128.0f ), ( surf.light_t - surf.dlight_t ) * ( 1.0f / 128.0f ) );
+// }
}
/*
@@ -475,8 +457,6 @@ public abstract class Surf extends Draw {
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glDepthMask( true );
}
-
- private ByteBuffer temp2 = BufferUtils.newByteBuffer(34 * 34 * 4);
/*
================
@@ -523,64 +503,57 @@ public abstract class Surf extends Draw {
// PGM
// ======
- // ersetzt goto
- boolean gotoDynamic = false;
- /*
- ** check for lightmap modification
- */
- for ( maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte)255; maps++ )
- {
- if ( r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps] ) {
- gotoDynamic = true;
- break;
- }
- }
-
- // this is a hack from cwei
- if (maps == 4) maps--;
-
- // dynamic this frame or dynamic previously
- if ( gotoDynamic || ( fa.dlightframe == r_framecount ) )
- {
- // label dynamic:
- if ( gl_dynamic.value != 0 )
- {
- if (( fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP ) ) == 0)
- {
- is_dynamic = true;
- }
- }
- }
-
+// /*
+// ** check for lightmap modification
+// */
+// for ( maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++ )
+// {
+// if ( r_newrefdef.lightstyles[fa->styles[maps]].white != fa->cached_light[maps] )
+// goto dynamic;
+// }
+//
+// // dynamic this frame or dynamic previously
+// if ( ( fa->dlightframe == r_framecount ) )
+// {
+// dynamic:
+// if ( gl_dynamic->value )
+// {
+// if (!( fa->texinfo->flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP ) ) )
+// {
+// is_dynamic = true;
+// }
+// }
+// }
+//
if ( is_dynamic )
{
- if ( ( (fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0 ) && ( fa.dlightframe != r_framecount ) )
- {
- // ist ersetzt durch temp2: unsigned temp[34*34];
- int smax, tmax;
-
- smax = (fa.extents[0]>>4)+1;
- tmax = (fa.extents[1]>>4)+1;
-
- R_BuildLightMap( fa, temp2, smax*4 );
- R_SetCacheState( fa );
-
- GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum );
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- fa.light_s, fa.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp2 );
-
- fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
- gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
- }
- else
- {
- fa.lightmapchain = gl_lms.lightmap_surfaces[0];
- gl_lms.lightmap_surfaces[0] = fa;
- }
+// if ( ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != r_framecount ) )
+// {
+// unsigned temp[34*34];
+// int smax, tmax;
+//
+// smax = (fa->extents[0]>>4)+1;
+// tmax = (fa->extents[1]>>4)+1;
+//
+// R_BuildLightMap( fa, (void *)temp, smax*4 );
+// R_SetCacheState( fa );
+//
+// GL_Bind( gl_state.lightmap_textures + fa->lightmaptexturenum );
+//
+// qglTexSubImage2D( GL_TEXTURE_2D, 0,
+// fa->light_s, fa->light_t,
+// smax, tmax,
+// GL_LIGHTMAP_FORMAT,
+// GL_UNSIGNED_BYTE, temp );
+//
+// fa->lightmapchain = gl_lms.lightmap_surfaces[fa->lightmaptexturenum];
+// gl_lms.lightmap_surfaces[fa->lightmaptexturenum] = fa;
+// }
+// else
+// {
+// fa->lightmapchain = gl_lms.lightmap_surfaces[0];
+// gl_lms.lightmap_surfaces[0] = fa;
+// }
}
else
{
@@ -716,8 +689,6 @@ public abstract class Surf extends Draw {
GL_TexEnv( GL.GL_REPLACE );
}
- // direct buffer
- ByteBuffer temp = BufferUtils.newByteBuffer(128 * 128 * 4);
void GL_RenderLightmappedPoly( msurface_t surf )
{
@@ -729,74 +700,66 @@ public abstract class Surf extends Draw {
int lmtex = surf.lightmaptexturenum;
glpoly_t p;
- // ersetzt goto
- boolean gotoDynamic = false;
-
- for ( map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte)255); map++ )
- {
- if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] ) {
- gotoDynamic = true;
- break;
- }
- }
-
- // this is a hack from cwei
- if (map == 4) map--;
-
- // dynamic this frame or dynamic previously
- if ( gotoDynamic || ( surf.dlightframe == r_framecount ) )
- {
- // label dynamic:
- if ( gl_dynamic.value != 0 )
- {
- if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP )) == 0 )
- {
- is_dynamic = true;
- }
- }
- }
-
+// for ( map = 0; map < Defines.MAXLIGHTMAPS && surf.styles[map] != (byte)255; map++ )
+// {
+// if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] )
+// goto dynamic;
+// }
+//
+// // dynamic this frame or dynamic previously
+// if ( ( surf.dlightframe == r_framecount ) )
+// {
+// dynamic:
+// if ( gl_dynamic.value )
+// {
+// if ( !(surf.texinfo.flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP ) ) )
+// {
+// is_dynamic = true;
+// }
+// }
+// }
+//
if ( is_dynamic )
{
- // ist raus gezogen worden int[] temp = new int[128*128];
- int smax, tmax;
-
+// unsigned temp[128*128];
+// int smax, tmax;
+//
if ( ( (surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0 ) && ( surf.dlightframe != r_framecount ) )
{
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- R_BuildLightMap( surf, temp, smax*4 );
- R_SetCacheState( surf );
-
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
-
- lmtex = surf.lightmaptexturenum;
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- surf.light_s, surf.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp );
-
+// smax = (surf.extents[0]>>4)+1;
+// tmax = (surf.extents[1]>>4)+1;
+//
+// R_BuildLightMap( surf, (void *)temp, smax*4 );
+// R_SetCacheState( surf );
+//
+// GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
+//
+// lmtex = surf.lightmaptexturenum;
+//
+// gl.glTexSubImage2D( GL_TEXTURE_2D, 0,
+// surf.light_s, surf.light_t,
+// smax, tmax,
+// GL_LIGHTMAP_FORMAT,
+// GL_UNSIGNED_BYTE, temp );
+//
}
else
{
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
-
- R_BuildLightMap( surf, temp, smax*4 );
-
- GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
-
- lmtex = 0;
-
- gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
- surf.light_s, surf.light_t,
- smax, tmax,
- GL_LIGHTMAP_FORMAT,
- GL.GL_UNSIGNED_BYTE, temp );
-
+// smax = (surf.extents[0]>>4)+1;
+// tmax = (surf.extents[1]>>4)+1;
+//
+// R_BuildLightMap( surf, (void *)temp, smax*4 );
+//
+// GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
+//
+// lmtex = 0;
+//
+// gl.glTexSubImage2D( GL_TEXTURE_2D, 0,
+// surf.light_s, surf.light_t,
+// smax, tmax,
+// GL_LIGHTMAP_FORMAT,
+// GL_UNSIGNED_BYTE, temp );
+//
}
c_brush_polys++;
diff --git a/src/jake2/render/jogl/Warp.java b/src/jake2/render/jogl/Warp.java
index 8ccb93a..f02acbb 100644
--- a/src/jake2/render/jogl/Warp.java
+++ b/src/jake2/render/jogl/Warp.java
@@ -2,7 +2,7 @@
* Warp.java
* Copyright (C) 2003
*
- * $Id: Warp.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Warp.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -698,7 +698,8 @@ public abstract class Warp extends Model {
pathname = "env/" + skyname + suf[i] + ".pcx";
} else {
// Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
- pathname = "env/" + skyname + suf[i] + ".tga";
+ // TODO impl: LoadTGA
+ pathname = "env/" + skyname + suf[i] + ".pcx";
}
sky_images[i] = GL_FindImage(pathname, it_sky);
diff --git a/src/jake2/render/msurface_t.java b/src/jake2/render/msurface_t.java
index c6247d9..a43ddbd 100644
--- a/src/jake2/render/msurface_t.java
+++ b/src/jake2/render/msurface_t.java
@@ -19,14 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: msurface_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: msurface_t.java,v 1.1 2004-07-07 19:59:35 hzi Exp $
package jake2.render;
import java.nio.ByteBuffer;
import jake2.game.*;
-import jake2.qcommon.texinfo_t;
import jake2.*;
public class msurface_t
@@ -51,8 +50,7 @@ public class msurface_t
public msurface_t texturechain;
public msurface_t lightmapchain;
- // TODO check this
- public mtexinfo_t texinfo = new mtexinfo_t();
+ public mtexinfo_t texinfo;
// lighting info
public int dlightframe;
@@ -64,40 +62,5 @@ public class msurface_t
// values currently used in lightmap
//public byte samples[]; // [numstyles*surfsize]
public ByteBuffer samples; // [numstyles*surfsize]
-
- public void clear() {
- visframe = 0;
- //plane = null;
- flags = 0;
-
- firstedge = 0;
- numedges = 0;
-
- texturemins[0] = texturemins[1] = 0;
- extents[0] = extents[1] = 0;
-
- light_s = light_t = 0;
- dlight_s = dlight_t = 0;
-
- //polys = null;
- texturechain = null;
- lightmapchain = null;
-
- //texinfo = null;
-
- dlightframe = 0;
- dlightbits = 0;
-
- lightmaptexturenum = 0;
-
- for (int i = 0; i < styles.length; i++)
- {
- styles[i] = 0;
- }
- for (int i = 0; i < cached_light.length; i++)
- {
- cached_light[i] = 0;
- }
- //samples = null;
- }
+
}
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index 8f6eec4..c6d433b 100644
--- a/src/jake2/server/SV_GAME.java
+++ b/src/jake2/server/SV_GAME.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_GAME.java,v 1.4 2004-07-08 20:56:54 hzi Exp $
+// $Id: SV_GAME.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
package jake2.server;
@@ -262,9 +262,6 @@ public class SV_GAME extends SV_INIT {
cluster = CM.CM_LeafCluster(leafnum);
area2 = CM.CM_LeafArea(leafnum);
- // quake2 bugfix
- if (cluster == -1)
- return false;
if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7)))))
return false;
@@ -296,10 +293,7 @@ public class SV_GAME extends SV_INIT {
cluster = CM.CM_LeafCluster(leafnum);
area2 = CM.CM_LeafArea(leafnum);
- // quake2 bugfix
- if (cluster == -1)
- return false;
- if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7)))))
+ if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7)))))
return false; // more than one bounce away
if (!CM.CM_AreasConnected(area1, area2))
return false; // a door blocks hearing
@@ -312,7 +306,7 @@ public class SV_GAME extends SV_INIT {
return;
//TODO: impl SV_StartSound
- SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs);
+ //SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs);
}
//==============================================
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index b4b4ee6..8fcfa37 100644
--- a/src/jake2/server/SV_INIT.java
+++ b/src/jake2/server/SV_INIT.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_INIT.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_INIT.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
package jake2.server;
@@ -115,7 +115,7 @@ public class SV_INIT extends Globals {
//
VectorCopy(svent.s.origin, svent.s.old_origin);
// rst: bugfix
- sv.baselines[entnum].set(svent.s);// = svent.s.getClone();
+ sv.baselines[entnum] = svent.s.getClone();
}
}
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index 0764ce6..ca6b07e 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.3 2004-07-08 20:56:54 hzi Exp $
+// $Id: SV_SEND.java,v 1.1 2004-07-07 19:59:49 hzi Exp $
package jake2.server;
@@ -232,10 +232,6 @@ public class SV_SEND extends SV_MAIN {
area2 = CM.CM_LeafArea(leafnum);
if (!CM.CM_AreasConnected(area1, area2))
continue;
-
- // quake2 bugfix
- if (cluster == -1)
- continue;
if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7)))))
continue;
}
@@ -287,7 +283,7 @@ public class SV_SEND extends SV_MAIN {
int flags;
int i;
int ent;
- float[] origin_v = {0,0,0};
+ float[] origin_v = null;
boolean use_phs;
if (volume < 0 || volume > 1.0)
diff --git a/src/jake2/server/SV_USER.java b/src/jake2/server/SV_USER.java
index c6e355e..1136d20 100644
--- a/src/jake2/server/SV_USER.java
+++ b/src/jake2/server/SV_USER.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_USER.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_USER.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
package jake2.server;
@@ -308,10 +308,11 @@ public class SV_USER extends SV_SEND {
|| allow_download.value == 0 // leading dot is no good
|| name.charAt(0) == '.' // leading slash bad as well, must be in subdir
|| name.charAt(0) == '/' // next up, skin check
- || (name.startsWith("players/") && 0 == allow_download_players.value) // now models
- || (name.startsWith("models/") && 0 == allow_download_models.value) // now sounds
- || (name.startsWith("sound/") && 0 == allow_download_sounds.value) // now maps (note special case for maps, must not be in pak)
- || (name.startsWith("maps/") && 0 == allow_download_maps.value) // MUST be in a subdirectory
+ || (strncmp(name, "players/", 6) == 0 && 0 == allow_download_players.value) // now models
+ || (strncmp(name, "models/", 6) == 0 && 0 == allow_download_models.value) // now sounds
+ || (strncmp(name, "sound/", 6) == 0
+ && 0 == allow_download_sounds.value) // now maps (note special case for maps, must not be in pak)
+ || (strncmp(name, "maps/", 6) == 0 && 0 == allow_download_maps.value) // MUST be in a subdirectory
|| name.indexOf('/') == -1) { // don't allow anything with .. path
MSG.WriteByte(sv_client.netchan.message, svc_download);
MSG.WriteShort(sv_client.netchan.message, -1);
@@ -331,7 +332,7 @@ public class SV_USER extends SV_SEND {
if (sv_client.download == null // special check for maps, if it came from a pak file, don't allow
// download ZOID
- || (name.startsWith("maps/") && FS.file_from_pak != 0)) {
+ || (strncmp(name, "maps/", 5) == 0 && FS.file_from_pak != 0)) {
Com.DPrintf("Couldn't download " + name + " to " + sv_client.name + "\n");
if (sv_client.download != null) {
FS.FreeFile(sv_client.download);
diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java
index 4e78084..a400959 100644
--- a/src/jake2/server/SV_WORLD.java
+++ b/src/jake2/server/SV_WORLD.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 07.01.2000 by RST.
-// $Id: SV_WORLD.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_WORLD.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
package jake2.server;
@@ -607,7 +607,7 @@ public class SV_WORLD extends SV_CCMDS
clip.trace.startsolid = true;
}
else
- clip.trace.set(trace);
+ clip.trace = trace.getClone();
}
else if (trace.startsolid)
clip.trace.startsolid = true;
diff --git a/src/jake2/sound/DummyDriver.java b/src/jake2/sound/DummyDriver.java
deleted file mode 100644
index e663d09..0000000
--- a/src/jake2/sound/DummyDriver.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Created on Apr 25, 2004
- *
- * Copyright (C) 2003
- *
- * $Id: DummyDriver.java,v 1.1 2004-07-08 20:56:49 hzi 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.
-
-*/
-package jake2.sound;
-
-/**
- * DummyDriver
- *
- * @author cwei
- */
-public final class DummyDriver implements Sound {
-
- static {
- S.register(new DummyDriver());
- };
-
- private DummyDriver() {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#Init()
- */
- public boolean Init() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#Shutdown()
- */
- public void Shutdown() {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#BeginRegistration()
- */
- public void BeginRegistration() {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#RegisterSound(java.lang.String)
- */
- public sfx_t RegisterSound(String sample) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#EndRegistration()
- */
- public void EndRegistration() {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#StartLocalSound(java.lang.String)
- */
- public void StartLocalSound(String sound) {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float)
- */
- public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#Update(float[], float[], float[], float[])
- */
- public void Update(float[] origin, float[] forward, float[] right, float[] up) {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
- */
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#StopAllSounds()
- */
- public void StopAllSounds() {
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#getName()
- */
- public String getName() {
- return "dummy";
- }
-}
diff --git a/src/jake2/sound/S.java b/src/jake2/sound/S.java
deleted file mode 100644
index c696501..0000000
--- a/src/jake2/sound/S.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * S.java
- * Copyright (C) 2003
- *
- * $Id: S.java,v 1.1 2004-07-08 20:56:49 hzi 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.
-
-*/
-package jake2.sound;
-
-import jake2.Defines;
-import jake2.game.cvar_t;
-import jake2.qcommon.Com;
-import jake2.qcommon.Cvar;
-
-import java.util.Vector;
-
-/**
- * S
- */
-public class S {
-
- static Sound impl;
- static cvar_t s_impl;
-
- static Vector drivers = new Vector(3);
-
- static {
- try {
- Class.forName("jake2.sound.DummyDriver");
- Class.forName("jake2.sound.joal.JOALSoundImpl");
- Class.forName("jake2.sound.jsound.JSoundImpl");
- }
- catch (ClassNotFoundException e) {
- }
- };
-
- public static void register(Sound driver) {
- if (driver == null) {
- throw new IllegalArgumentException("Sound implementation can't be null");
- }
- if (!drivers.contains(driver)) {
- drivers.add(driver);
- }
- }
-
- public static void useDriver(String driverName) {
- Sound driver = null;
- int count = drivers.size();
- for (int i = 0; i < count; i++) {
- driver = (Sound) drivers.get(i);
- if (driver.getName().equals(driverName)) {
- impl = driver;
- return;
- }
- }
- // if driver not found use dummy
- impl = (Sound)drivers.get(0);
- }
-
- public static void Init() {
-
- Com.Printf("\n------- sound initialization -------\n");
-
- cvar_t cv = Cvar.Get("s_initsound", "1", 0);
- if (cv.value == 0.0f) {
- Com.Printf("not initializing.\n");
- useDriver("dummy");
- return;
- }
-
- s_impl = Cvar.Get("s_impl", "joal", Defines.CVAR_ARCHIVE);
- useDriver(s_impl.string);
-
- if (impl.Init()) {
- // driver ok
- Cvar.Set("s_impl", impl.getName());
- } else {
- // fallback
- useDriver("dummy");
- }
-
- Com.Printf("\n------- use sound driver \"" + impl.getName() + "\" -------\n");
- StopAllSounds();
- }
-
- public static void Shutdown() {
- impl.Shutdown();
- }
-
- /*
- =====================
- S_BeginRegistration
- =====================
- */
- public static void BeginRegistration() {
- impl.BeginRegistration();
- }
-
- /*
- =====================
- S_RegisterSound
- =====================
- */
- public static sfx_t RegisterSound(String sample) {
- return impl.RegisterSound(sample);
- }
-
- /*
- =====================
- S_EndRegistration
- =====================
- */
- public static void EndRegistration() {
- impl.EndRegistration();
- }
-
- /*
- ==================
- S_StartLocalSound
- ==================
- */
- public static void StartLocalSound(String sound) {
- impl.StartLocalSound(sound);
- }
-
- /*
- ====================
- S_StartSound
-
- Validates the parms and ques the sound up
- if pos is NULL, the sound will be dynamically sourced from the entity
- Entchannel 0 will never override a playing sound
- ====================
- */
- public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
- impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs);
- }
-
- /*
- ============
- S_Update
-
- Called once each time through the main loop
- ============
- */
- public static void Update(float[] origin, float[] forward, float[] right, float[] up) {
- impl.Update(origin, forward, right, up);
- }
-
- /*
- ============
- S_RawSamples
-
- Cinematic streaming and voice over network
- ============
- */
- public static void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
- impl.RawSamples(samples, rate, width, channels, data);
- }
-
- /*
- ==================
- S_StopAllSounds
- ==================
- */
- public static void StopAllSounds() {
- impl.StopAllSounds();
- }
-}
diff --git a/src/jake2/sound/Sound.java b/src/jake2/sound/Sound.java
deleted file mode 100644
index 30bd8c6..0000000
--- a/src/jake2/sound/Sound.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Created on Apr 25, 2004
- *
- * Copyright (C) 2003
- *
- * $Id: Sound.java,v 1.1 2004-07-08 20:56:49 hzi 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.
-
-*/
-package jake2.sound;
-
-/**
- * Sound
- *
- * @author cwei
- */
-public interface Sound {
-
-
- String getName();
-
- boolean Init();
- void Shutdown();
-
- /*
- =====================
- S_BeginRegistration
- =====================
- */
- void BeginRegistration();
-
- /*
- =====================
- S_RegisterSound
- =====================
- */
- sfx_t RegisterSound(String sample);
-
- /*
- =====================
- S_EndRegistration
- =====================
- */
- void EndRegistration();
-
- /*
- ==================
- S_StartLocalSound
- ==================
- */
- void StartLocalSound(String sound);
-
- /*
- ====================
- S_StartSound
-
- Validates the parms and ques the sound up
- if pos is NULL, the sound will be dynamically sourced from the entity
- Entchannel 0 will never override a playing sound
- ====================
- */
- void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs);
-
- /*
- ============
- S_Update
-
- Called once each time through the main loop
- ============
- */
- void Update(float[] origin, float[] forward, float[] right, float[] up);
- /*
- ============
- S_RawSamples
-
- Cinematic streaming and voice over network
- ============
- */
- void RawSamples(int samples, int rate, int width, int channels, byte[] data);
-
- /*
- ==================
- S_StopAllSounds
- ==================
- */
- void StopAllSounds();
-
-}
diff --git a/src/jake2/sound/joal/Channel.java b/src/jake2/sound/joal/Channel.java
deleted file mode 100644
index ced496f..0000000
--- a/src/jake2/sound/joal/Channel.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Created on Jun 19, 2004
- *
- * Copyright (C) 2003
- *
- * $Id: Channel.java,v 1.1 2004-07-09 06:50:52 hzi 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.
-
-*/
-package jake2.sound.joal;
-
-/**
- * Channel
- *
- * @author cwei
- */
-public class Channel {
-
- final static int LISTENER = 0;
- final static int FIXED = 1;
- final static int DYNAMIC = 2;
-
- int entnum;
- int entchannel;
- int bufferId;
- float rolloff;
- boolean autosound = false;
- int sourceId;
- boolean active = false;
- boolean modified = false;
- boolean bufferChanged = false;
-
- // sound attributes
- int type;
- int entity;
- float[] origin = {0, 0, 0};
-
- Channel(int sourceId) {
- this.sourceId = sourceId;
- clear();
- }
-
- void addListener() {
- type = LISTENER;
- }
-
- void addFixed(float[] origin) {
- type = FIXED;
- this.origin = origin;
- }
-
- void addDynamic(int entity) {
- type = DYNAMIC;
- this.entity = entity;
- }
-
- void clear() {
- entnum = -1;
- entchannel = -1;
- bufferId = -1;
- bufferChanged = false;
- rolloff = 0;
- autosound = false;
- active = false;
- modified = false;
- }
-}
diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java
deleted file mode 100644
index 8a005ce..0000000
--- a/src/jake2/sound/joal/JOALSoundImpl.java
+++ /dev/null
@@ -1,793 +0,0 @@
-/*
- * JOALSoundImpl.java
- * Copyright (C) 2004
- *
- * $Id: JOALSoundImpl.java,v 1.1 2004-07-09 06:50:52 hzi Exp $
- */
-package jake2.sound.joal;
-
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.client.CL;
-import jake2.game.*;
-import jake2.qcommon.*;
-import jake2.sound.*;
-import jake2.util.Math3D;
-import jake2.util.Vargs;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.*;
-
-import net.java.games.joal.*;
-
-/**
- * JOALSoundImpl
- */
-public final class JOALSoundImpl implements Sound {
-
- static {
- S.register(new JOALSoundImpl());
- };
-
- static AL al;
- static ALC alc;
-
- cvar_t s_volume;
-
- private static final int MAX_SFX = Defines.MAX_SOUNDS * 2;
- private static final int MAX_CHANNELS = 32;
-
- private int[] buffers = new int[MAX_SFX];
- private int[] sources = new int[MAX_CHANNELS];
- private Channel[] channels = null;
-
- private JOALSoundImpl() {
- }
-
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#Init()
- */
- public boolean Init() {
-
- try {
- initOpenAL();
- al = ALFactory.getAL();
- checkError();
- } catch (OpenALException e) {
- Com.Printf(e.getMessage() + '\n');
- return false;
- }
-
- checkError();
- al.alGenBuffers(MAX_SFX, buffers);
- al.alGenSources(MAX_CHANNELS, sources);
- checkError();
- s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
- initChannels();
- al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED);
-// al.alDistanceModel(AL.AL_INVERSE_DISTANCE);
- Cmd.AddCommand("play", new xcommand_t() {
- public void execute() {
- Play();
- }
- });
- Cmd.AddCommand("stopsound", new xcommand_t() {
- public void execute() {
- StopAllSounds();
- }
- });
- Cmd.AddCommand("soundlist", new xcommand_t() {
- public void execute() {
- SoundList();
- }
- });
- Cmd.AddCommand("soundinfo", new xcommand_t() {
- public void execute() {
- SoundInfo_f();
- }
- });
-
- num_sfx = 0;
-
-
- Com.Printf("sound sampling rate: 44100Hz\n");
-
- StopAllSounds();
- Com.Printf("------------------------------------\n");
- return true;
- }
-
-
- private void initOpenAL() throws OpenALException {
- ALFactory.initialize();
- alc = ALFactory.getALC();
- String deviceName = null;
-
- String os = System.getProperty("os.name");
- if (os.startsWith("Windows")) {
- deviceName = "DirectSound3D";
- }
- ALC.Device device = alc.alcOpenDevice(deviceName);
- String deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER);
- String defaultSpecifier = alc.alcGetString(device, ALC.ALC_DEFAULT_DEVICE_SPECIFIER);
-
- Com.Printf(os + " using " + ((deviceName == null) ? defaultSpecifier : deviceName) + '\n');
-
- ALC.Context context = alc.alcCreateContext(device, new int[] {0});
- alc.alcMakeContextCurrent(context);
- // Check for an error.
- if (alc.alcGetError(device) != ALC.ALC_NO_ERROR) {
- Com.DPrintf("Error with SoundDevice");
- }
- }
-
- void exitOpenAL() {
- // Get the current context.
- ALC.Context curContext = alc.alcGetCurrentContext();
- // Get the device used by that context.
- ALC.Device curDevice = alc.alcGetContextsDevice(curContext);
- // Reset the current context to NULL.
- alc.alcMakeContextCurrent(null);
- // Release the context and the device.
- alc.alcDestroyContext(curContext);
- alc.alcCloseDevice(curDevice);
- }
-
- private void initChannels() {
-
- // create channels
- channels = new Channel[MAX_CHANNELS];
-
- int sourceId;
- for (int i = 0; i < MAX_CHANNELS; i++) {
- sourceId = sources[i];
- channels[i] = new Channel(sourceId);
-
- // set default values for AL sources
- al.alSourcef (sourceId, AL.AL_GAIN, s_volume.value);
- al.alSourcef (sourceId, AL.AL_PITCH, 1.0f);
- al.alSourcei (sourceId, AL.AL_SOURCE_ABSOLUTE, AL.AL_TRUE);
- al.alSourcefv(sourceId, AL.AL_VELOCITY, NULLVECTOR);
- al.alSourcei (sourceId, AL.AL_LOOPING, AL.AL_FALSE);
- al.alSourcef (sourceId, AL.AL_REFERENCE_DISTANCE, 300.0f);
- al.alSourcef (sourceId, AL.AL_MIN_GAIN, 0.0005f);
- al.alSourcef (sourceId, AL.AL_MAX_GAIN, 1.0f);
- }
- }
-
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t)
- */
- private void initBuffer(sfx_t sfx)
- {
- if (sfx.cache == null ) {
- //System.out.println(sfx.name + " " + sfx.cache.length+ " " + sfx.cache.loopstart + " " + sfx.cache.speed + " " + sfx.cache.stereo + " " + sfx.cache.width);
- return;
- }
-
- int format = AL.AL_FORMAT_MONO16;
- byte[] data = sfx.cache.data;
- int freq = sfx.cache.speed;
- int size = data.length;
-
-// if (buffers[sfx.id] != 0)
-// al.alDeleteBuffers(1, new int[] {buffers[sfx.id] });
-//
-// int[] bid = new int[1];
-// al.alBufferData( bid[0], format, data, size, freq);
-// buffers[sfx.id] = bid[0];
-// al.alBufferData( bid[0], format, data, size, freq);
-
- al.alBufferData( buffers[sfx.id], format, data, size, freq);
-// int error;
-// if ((error = al.alGetError()) != AL.AL_NO_ERROR) {
-// String message;
-// switch(error) {
-// case AL.AL_INVALID_OPERATION: message = "invalid operation"; break;
-// case AL.AL_INVALID_VALUE: message = "invalid value"; break;
-// case AL.AL_INVALID_ENUM: message = "invalid enum"; break;
-// case AL.AL_INVALID_NAME: message = "invalid name"; break;
-// default: message = "" + error;
-// }
-// Com.DPrintf("Error Buffer " + sfx.id + ": " + sfx.name + " (" + size + ") --> " + message + '\n');
-// }
- }
-
- private void checkError() {
- int error;
- if ((error = al.alGetError()) != AL.AL_NO_ERROR) {
- String message;
- switch(error) {
- case AL.AL_INVALID_OPERATION: message = "invalid operation"; break;
- case AL.AL_INVALID_VALUE: message = "invalid value"; break;
- case AL.AL_INVALID_ENUM: message = "invalid enum"; break;
- case AL.AL_INVALID_NAME: message = "invalid name"; break;
- default: message = "" + error;
- }
- Com.DPrintf("AL Error: " + message +'\n');
- }
- }
-
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#Shutdown()
- */
- public void Shutdown() {
- StopAllSounds();
- al.alDeleteSources(sources.length, sources);
- al.alDeleteBuffers(buffers.length, buffers);
- exitOpenAL();
- //ALut.alutExit();
- Cmd.RemoveCommand("play");
- Cmd.RemoveCommand("stopsound");
- Cmd.RemoveCommand("soundlist");
- Cmd.RemoveCommand("soundinfo");
-
- // free all sounds
- for (int i = 0; i < num_sfx; i++) {
- if (known_sfx[i].name == null)
- continue;
- known_sfx[i].clear();
- }
- num_sfx = 0;
- }
-
- private final static float[] NULLVECTOR = {0, 0, 0};
- private float[] entityOrigin = {0, 0, 0};
- private float[] sourceOrigin = {0, 0, 0};
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float)
- */
- public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
-
- if (sfx == null)
- return;
-
- if (sfx.name.charAt(0) == '*')
- sfx = RegisterSexedSound(Globals.cl_entities[entnum].current, sfx.name);
-
- if (LoadSound(sfx) == null)
- return; // can't load sound
-
- if (attenuation != Defines.ATTN_STATIC)
- attenuation *= 0.5f;
-
- Channel ch = pickChannel(entnum, entchannel, buffers[sfx.id], attenuation);
-
- if (ch == null) return;
-
- if (entnum == Globals.cl.playernum + 1) {
- ch.addListener();
- } else if (origin != null) {
- ch.addFixed(origin);
- } else {
- ch.addDynamic(entnum);
- }
- }
-
- Channel pickChannel(int entnum, int entchannel, int bufferId, float rolloff) {
-
- Channel ch = null;
- int state;
- int i;
-
- for (i = 0; i < MAX_CHANNELS; i++) {
- ch = channels[i];
-
- if (entchannel != 0 && ch.entnum == entnum && ch.entchannel == entchannel) {
- // always override sound from same entity
- break;
- }
-
- // don't let monster sounds override player sounds
- if ((ch.entnum == Globals.cl.playernum+1) && (entnum != Globals.cl.playernum+1) && ch.bufferId != -1)
- continue;
-
- // looking for a free AL source
- if (!ch.active) {
- break;
- }
- }
-
- if (i == MAX_CHANNELS)
- return null;
-
- ch.entnum = entnum;
- ch.entchannel = entchannel;
- if (ch.bufferId != bufferId) {
- ch.bufferId = bufferId;
- ch.bufferChanged = true;
- }
- ch.rolloff = rolloff * 2;
- ch.active = true;
- ch.modified = true;
-
- return ch;
- }
-
- private float[] listenerOrigin = {0, 0, 0};
- private float[] listenerOrientation = {0, 0, 0, 0, 0, 0};
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#Update(float[], float[], float[], float[])
- */
- public void Update(float[] origin, float[] forward, float[] right, float[] up) {
-
- convertVector(origin, listenerOrigin);
- al.alListenerfv(AL.AL_POSITION, listenerOrigin);
-
- convertOrientation(forward, up, listenerOrientation);
- al.alListenerfv(AL.AL_ORIENTATION, listenerOrientation);
-
- AddLoopSounds(origin);
- playChannels(listenerOrigin);
- }
-
- Map looptable = new Hashtable(2 * MAX_CHANNELS);
-
- /*
- ==================
- S_AddLoopSounds
-
- Entities with a ->sound field will generated looped sounds
- that are automatically started, stopped, and merged together
- as the entities are sent to the client
- ==================
- */
- void AddLoopSounds(float[] listener) {
-
- if (Globals.cl_paused.value != 0.0f) {
- removeUnusedLoopSounds();
- return;
- }
-
- if (Globals.cls.state != Globals.ca_active) {
- removeUnusedLoopSounds();
- return;
- }
-
- if (!Globals.cl.sound_prepped) {
- removeUnusedLoopSounds();
- return;
- }
-
- Channel ch;
- sfx_t sfx;
- sfxcache_t sc;
- int num;
- entity_state_t ent;
- Object key;
- int sound = 0;
-
- for (int i=0 ; i<Globals.cl.frame.num_entities ; i++) {
- num = (Globals.cl.frame.parse_entities + i)&(Defines.MAX_PARSE_ENTITIES-1);
- ent = Globals.cl_parse_entities[num];
- sound = ent.sound;
-
- if (sound == 0) continue;
-
- key = new Integer(ent.number);
- ch = (Channel)looptable.get(key);
-
- if (ch != null) {
- // keep on looping
- ch.autosound = true;
- ch.origin = ent.origin;
- continue;
- }
-
- sfx = Globals.cl.sound_precache[sound];
- if (sfx == null)
- continue; // bad sound effect
-
- sc = sfx.cache;
- if (sc == null)
- continue;
-
- // allocate a channel
- ch = pickChannel(0, 0, buffers[sfx.id], 6);
- if (ch == null)
- break;
-
- ch.addFixed(ent.origin);
- ch.autosound = true;
-
- looptable.put(key, ch);
- al.alSourcei(ch.sourceId, AL.AL_LOOPING, AL.AL_TRUE);
- }
-
- removeUnusedLoopSounds();
-
- }
-
- void removeUnusedLoopSounds() {
- Channel ch;
- // stop unused loopsounds
- for (Iterator iter = looptable.values().iterator(); iter.hasNext();) {
- ch = (Channel)iter.next();
- if (!ch.autosound) {
- al.alSourceStop(ch.sourceId);
- al.alSourcei(ch.sourceId, AL.AL_LOOPING, AL.AL_FALSE);
- iter.remove();
- ch.clear();
- }
- }
- }
-
- void playChannels(float[] listenerOrigin) {
-
- float[] sourceOrigin = {0, 0, 0};
- float[] entityOrigin = {0, 0, 0};
- Channel ch;
- int sourceId;
- int state;
-
- for (int i = 0; i < MAX_CHANNELS; i++) {
- ch = channels[i];
- if (ch.active) {
- sourceId = ch.sourceId;
-
- switch (ch.type) {
- case Channel.LISTENER:
- Math3D.VectorCopy(listenerOrigin, sourceOrigin);
- break;
- case Channel.DYNAMIC:
- CL.GetEntitySoundOrigin(ch.entity, entityOrigin);
- convertVector(entityOrigin, sourceOrigin);
- break;
- case Channel.FIXED:
- convertVector(ch.origin, sourceOrigin);
- break;
- }
-
- if (ch.modified) {
- if (ch.bufferChanged)
- al.alSourcei (sourceId, AL.AL_BUFFER, ch.bufferId);
-
- al.alSourcef (sourceId, AL.AL_GAIN, s_volume.value);
- al.alSourcef (sourceId, AL.AL_ROLLOFF_FACTOR, ch.rolloff);
- al.alSourcefv(sourceId, AL.AL_POSITION, sourceOrigin);
- al.alSourcePlay(sourceId);
- ch.modified = false;
- } else {
- state = al.alGetSourcei(ch.sourceId, AL.AL_SOURCE_STATE);
- if (state == AL.AL_PLAYING) {
- al.alSourcefv(sourceId, AL.AL_POSITION, sourceOrigin);
- } else {
- ch.clear();
- }
- }
- ch.autosound = false;
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#StopAllSounds()
- */
- public void StopAllSounds() {
- for (int i = 0; i < MAX_CHANNELS; i++) {
- al.alSourceStop(sources[i]);
- al.alSourcei(sources[i], AL.AL_BUFFER, 0);
- channels[i].clear();
- }
- }
-
- static void convertVector(float[] from, float[] to) {
- to[0] = from[0];
- to[1] = from[2];
- to[2] = -from[1];
- }
-
- static void convertOrientation(float[] forward, float[] up, float[] orientation) {
- orientation[0] = forward[0];
- orientation[1] = forward[2];
- orientation[2] = -forward[1];
- orientation[3] = up[0];
- orientation[4] = up[2];
- orientation[5] = -up[1];
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#getName()
- */
- public String getName() {
- return "joal";
- }
-
-
- int s_registration_sequence;
- boolean s_registering;
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#BeginRegistration()
- */
- public void BeginRegistration() {
- s_registration_sequence++;
- s_registering = true;
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#RegisterSound(java.lang.String)
- */
- public sfx_t RegisterSound(String name) {
- sfx_t sfx = FindName(name, true);
- sfx.registration_sequence = s_registration_sequence;
-
- if (!s_registering)
- LoadSound(sfx);
-
- return sfx;
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#EndRegistration()
- */
- public void EndRegistration() {
- int i;
- sfx_t sfx;
- int size;
-
- // free any sounds not from this registration sequence
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.name == null)
- continue;
- if (sfx.registration_sequence != s_registration_sequence) {
- // don't need this sound
- sfx.clear();
- }
- }
-
- // load everything in
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.name == null)
- continue;
- LoadSound(sfx);
- }
-
- s_registering = false;
- }
-
- sfx_t RegisterSexedSound(entity_state_t ent, String base) {
-
- sfx_t sfx = null;
-
- // determine what model the client is using
- String model = "male";
- int n = Globals.CS_PLAYERSKINS + ent.number - 1;
- if (Globals.cl.configstrings[n] != null) {
- int p = Globals.cl.configstrings[n].indexOf('\\');
- if (p >= 0) {
- p++;
- model = Globals.cl.configstrings[n].substring(p);
- //strcpy(model, p);
- p = model.indexOf('/');
- if (p > 0)
- model = model.substring(0, p);
- }
- }
- // if we can't figure it out, they're male
- if (model == null || model.length() == 0)
- model = "male";
-
- // see if we already know of the model specific sound
- String sexedFilename = "#players/" + model + "/" + base.substring(1);
- //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
- sfx = FindName(sexedFilename, false);
-
- if (sfx == null) {
- // no, so see if it exists
- RandomAccessFile f = null;
- try {
- f = FS.FOpenFile(sexedFilename.substring(1));
- } catch (IOException e) {}
- if (f != null) {
- // yes, close the file and register it
- try {
- FS.FCloseFile(f);
- } catch (IOException e1) {}
- sfx = RegisterSound(sexedFilename);
- } else {
- // no, revert to the male sound in the pak0.pak
- //Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
- String maleFilename = "player/male/" + base.substring(1);
- sfx = AliasName(sexedFilename, maleFilename);
- }
- }
-
- //System.out.println(sfx.name);
- return sfx;
- }
-
-
- static sfx_t[] known_sfx = new sfx_t[MAX_SFX];
- static {
- for (int i = 0; i< known_sfx.length; i++)
- known_sfx[i] = new sfx_t();
- }
- static int num_sfx;
-
- sfx_t FindName(String name, boolean create) {
- int i;
- sfx_t sfx = null;
-
- if (name == null)
- Com.Error(Defines.ERR_FATAL, "S_FindName: NULL\n");
- if (name.length() == 0)
- Com.Error(Defines.ERR_FATAL, "S_FindName: empty name\n");
-
- if (name.length() >= Defines.MAX_QPATH)
- Com.Error(Defines.ERR_FATAL, "Sound name too long: " + name);
-
- // see if already loaded
- for (i = 0; i < num_sfx; i++)
- if (name.equals(known_sfx[i].name)) {
- return known_sfx[i];
- }
-
- if (!create)
- return null;
-
- // find a free sfx
- for (i = 0; i < num_sfx; i++)
- if (known_sfx[i].name == null)
- // registration_sequence < s_registration_sequence)
- break;
-
- if (i == num_sfx) {
- if (num_sfx == MAX_SFX)
- Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t");
- num_sfx++;
- }
-
- sfx = known_sfx[i];
- sfx.clear();
- sfx.name = name;
- sfx.registration_sequence = s_registration_sequence;
- // cwei
- sfx.id = i;
-
- return sfx;
- }
-
- /*
- ==================
- S_AliasName
-
- ==================
- */
- sfx_t AliasName(String aliasname, String truename)
- {
- sfx_t sfx = null;
- String s;
- int i;
-
- s = new String(truename);
-
- // find a free sfx
- for (i=0 ; i < num_sfx ; i++)
- if (known_sfx[i].name == null)
- break;
-
- if (i == num_sfx)
- {
- if (num_sfx == MAX_SFX)
- Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t");
- num_sfx++;
- }
-
- sfx = known_sfx[i];
- sfx.clear();
- sfx.name = new String(aliasname);
- sfx.registration_sequence = s_registration_sequence;
- sfx.truename = s;
- // cwei
- sfx.id = i;
-
- return sfx;
- }
-
- /*
- ==============
- S_LoadSound
- ==============
- */
- public sfxcache_t LoadSound(sfx_t s) {
- sfxcache_t sc = WaveLoader.LoadSound(s);
- initBuffer(s);
- return sc;
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#StartLocalSound(java.lang.String)
- */
- public void StartLocalSound(String sound) {
- sfx_t sfx;
-
- sfx = RegisterSound(sound);
- if (sfx == null) {
- Com.Printf("S_StartLocalSound: can't cache " + sound + "\n");
- return;
- }
- StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0);
- }
-
- /* (non-Javadoc)
- * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
- */
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
- // TODO implement RawSamples
- }
-
- /*
- ===============================================================================
-
- console functions
-
- ===============================================================================
- */
-
- void Play() {
- int i;
- String name;
- sfx_t sfx;
-
- i = 1;
- while (i < Cmd.Argc()) {
- name = new String(Cmd.Argv(i));
- if (name.indexOf('.') == -1)
- name += ".wav";
-
- sfx = RegisterSound(name);
- StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f);
- i++;
- }
- }
-
- void SoundList() {
- int i;
- sfx_t sfx;
- sfxcache_t sc;
- int size, total;
-
- total = 0;
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.registration_sequence == 0)
- continue;
- sc = sfx.cache;
- if (sc != null) {
- size = sc.length * sc.width * (sc.stereo + 1);
- total += size;
- if (sc.loopstart >= 0)
- Com.Printf("L");
- else
- Com.Printf(" ");
- Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name));
- } else {
- if (sfx.name.charAt(0) == '*')
- Com.Printf(" placeholder : " + sfx.name + "\n");
- else
- Com.Printf(" not loaded : " + sfx.name + "\n");
- }
- }
- Com.Printf("Total resident: " + total + "\n");
- }
-
- void SoundInfo_f() {
-
- Com.Printf("%5d stereo\n", new Vargs(1).add(1));
- Com.Printf("%5d samples\n", new Vargs(1).add(22050));
- Com.Printf("%5d samplebits\n", new Vargs(1).add(16));
- Com.Printf("%5d speed\n", new Vargs(1).add(44100));
- }
-
-}
diff --git a/src/jake2/sound/soundinfo_t.java b/src/jake2/sound/soundinfo_t.java
deleted file mode 100644
index 2c9e6c6..0000000
--- a/src/jake2/sound/soundinfo_t.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * soundinfo_t.java
- * Copyright (C) 2004
- *
- * $Id: soundinfo_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
- */
-package jake2.sound;
-
-/**
- * soundinfo_t
- */
-public class soundinfo_t {
- int channels;
- int samples; // mono samples in buffer
- int submission_chunk; // don't mix less than this #
- int samplepos; // in mono samples
- int samplebits;
- int speed;
-}
diff --git a/src/jake2/sound/wavinfo_t.java b/src/jake2/sound/wavinfo_t.java
deleted file mode 100644
index 76a28fc..0000000
--- a/src/jake2/sound/wavinfo_t.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * wavinfo_t.java
- * Copyright (C) 2004
- *
- * $Id: wavinfo_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
- */
-package jake2.sound;
-
-/**
- * wavinfo_t
- */
-public class wavinfo_t {
- public int rate;
- public int width;
- public int channels;
- public int loopstart;
- public int samples;
- public int dataofs; // chunk starts this many bytes from file start
-}
diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java
index 8a08956..5e8c0df 100644
--- a/src/jake2/sys/Sys.java
+++ b/src/jake2/sys/Sys.java
@@ -2,7 +2,7 @@
* Sys.java
* Copyright (C) 2003
*
- * $Id: Sys.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Sys.java,v 1.2 2004-07-08 15:58:47 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -202,7 +202,7 @@ public final class Sys extends Defines {
return 0;
}
- return Globals.curtime = (int) (System.currentTimeMillis() - secbase);
+ return Globals.curtime = (int) (Globals.slomo.value * (System.currentTimeMillis() - secbase));
}
diff --git a/src/jake2/util/Math3D.java b/src/jake2/util/Math3D.java
index a434a05..6c607b3 100644
--- a/src/jake2/util/Math3D.java
+++ b/src/jake2/util/Math3D.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: Math3D.java,v 1.4 2004-07-08 20:56:54 hzi Exp $
+// $Id: Math3D.java,v 1.2 2004-07-08 15:58:48 hzi Exp $
package jake2.util;
@@ -33,9 +33,8 @@ public class Math3D extends Lib {
static final float piratio = (float)(Math.PI / 360.0);
public static void set(float v1[], float v2[]) {
- v1[0] = v2[0];
- v1[1] = v2[1];
- v1[2] = v2[2];
+ for (int i = 0; i < v1.length; i++)
+ v1[i] = v2[i];
}
@@ -106,10 +105,11 @@ public class Math3D extends Lib {
to[2] = veca[2] + scale * vecb[2];
}
public static final float VectorNormalize(float[] v) {
+ float length, ilength;
- float length = VectorLength(v);
+ length = VectorLength(v);
if (length != 0.0f) {
- float ilength = 1.0f / length;
+ ilength = 1.0f / length;
v[0] *= ilength;
v[1] *= ilength;
v[2] *= ilength;
@@ -164,7 +164,7 @@ public class Math3D extends Lib {
}
public static void vectoangles(float[] value1, float[] angles) {
-
+ float forward;
float yaw, pitch;
if (value1[1] == 0 && value1[0] == 0) {
@@ -184,7 +184,7 @@ public class Math3D extends Lib {
if (yaw < 0)
yaw += 360;
- float forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
+ forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
pitch = (int) (Math.atan2(value1[2], forward) * 180 / Math.PI);
if (pitch < 0)
pitch += 360;
@@ -195,18 +195,13 @@ public class Math3D extends Lib {
angles[Defines.ROLL] = 0;
}
- private static float m[][] = new float[3][3];
- private static float im[][] = new float[3][3];
- private static float tmpmat[][] = new float[3][3];
- private static float zrot[][] = new float[3][3];
- public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) {
-
- //float m[][] = new float[3][3];
- //float im[][] = new float[3][3];
- //float zrot[][] = new float[3][3];
- //float tmpmat[][] = new float[3][3];
- //float rot[][] = new float[3][3];
-
+ public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) {
+ float m[][] = new float[3][3];
+ float im[][] = new float[3][3];
+ float zrot[][] = new float[3][3];
+ float tmpmat[][] = new float[3][3];
+ float rot[][] = new float[3][3];
+ int i;
float[] vr = { 0.0f, 0.0f, 0.0f };
float[] vup = { 0.0f, 0.0f, 0.0f };
float[] vf = { 0.0f, 0.0f, 0.0f };
@@ -230,33 +225,29 @@ public class Math3D extends Lib {
m[1][2] = vf[1];
m[2][2] = vf[2];
- //Math3D.MatCopy(m, im); // achtung: src -> dst
+ Math3D.MatCopy(m, im); // achtung: src -> dst
- im[0][0] = m[0][0];
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
- im[1][1] = m[1][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
- im[2][2] = m[2][2];
- zrot[0][2] = zrot[1][2] = zrot[2][0] = zrot[2][1] = 0.0f;
+ Math3D.MatClear(zrot);
- zrot[2][2] = 1.0F;
+ zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
- zrot[0][0] = zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
+ zrot[0][0] = (float) Math.cos(Math3D.DEG2RAD(degrees));
zrot[0][1] = (float) Math.sin(Math3D.DEG2RAD(degrees));
- zrot[1][0] = -zrot[0][1];
- //zrot[1][0] = - (float) Math.sin(Math3D.DEG2RAD(degrees));
- //zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
+ zrot[1][0] = - (float) Math.sin(Math3D.DEG2RAD(degrees));
+ zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
Math3D.R_ConcatRotations(m, zrot, tmpmat);
- Math3D.R_ConcatRotations(tmpmat, im, zrot);
+ Math3D.R_ConcatRotations(tmpmat, im, rot);
- for (int i = 0; i < 3; i++) {
- dst[i] = zrot[i][0] * point[0] + zrot[i][1] * point[1] + zrot[i][2] * point[2];
+ for (i = 0; i < 3; i++) {
+ dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];
}
}
@@ -337,7 +328,7 @@ public class Math3D extends Lib {
int pos;
int i;
float minelem = 1.0F;
-
+ float tempvec[] = { 0.0f, 0.0f, 0.0f };
// find the smallest magnitude axially aligned vector
for (pos = 0, i = 0; i < 3; i++) {
@@ -346,7 +337,7 @@ public class Math3D extends Lib {
minelem = Math.abs(src[i]);
}
}
- float tempvec[] = { 0.0f, 0.0f, 0.0f };
+ tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
tempvec[pos] = 1.0F;
// project the point onto the plane defined by src
@@ -430,11 +421,13 @@ public class Math3D extends Lib {
}
// this is the slow, general version
- private static float corners[][] = new float[2][3];
public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) {
-
+ int i;
+ float dist1, dist2;
+ int sides;
+ float corners[][] = new float[2][3];
- for (int i = 0; i < 3; i++) {
+ for (i = 0; i < 3; i++) {
if (p.normal[i] < 0) {
corners[0][i] = emins[i];
corners[1][i] = emaxs[i];
@@ -444,9 +437,9 @@ public class Math3D extends Lib {
corners[0][i] = emaxs[i];
}
}
- float dist1 = Math3D.DotProduct(p.normal, corners[0]) - p.dist;
- float dist2 = Math3D.DotProduct(p.normal, corners[1]) - p.dist;
- int sides = 0;
+ dist1 = Math3D.DotProduct(p.normal, corners[0]) - p.dist;
+ dist2 = Math3D.DotProduct(p.normal, corners[1]) - p.dist;
+ sides = 0;
if (dist1 >= 0)
sides = 1;
if (dist2 < 0)
@@ -459,14 +452,13 @@ public class Math3D extends Lib {
float angle;
float sr, sp, sy, cr, cp, cy;
- cr = 2.0f * piratio;
- angle = (float) (angles[Defines.YAW] * (cr));
+ angle = (float) (angles[Defines.YAW] * (2.0f * piratio));
sy = (float) Math.sin(angle);
cy = (float) Math.cos(angle);
- angle = (float) (angles[Defines.PITCH] * (cr));
+ angle = (float) (angles[Defines.PITCH] * (2.0f * piratio));
sp = (float) Math.sin(angle);
cp = (float) Math.cos(angle);
- angle = (float) (angles[Defines.ROLL] * (cr));
+ angle = (float) (angles[Defines.ROLL] * (2.0f * piratio));
sr = (float) Math.sin(angle);
cr = (float) Math.cos(angle);
@@ -476,9 +468,9 @@ public class Math3D extends Lib {
forward[2] = -sp;
}
if (right != null) {
- right[0] = (-sr * sp * cy + cr * sy);
- right[1] = (-sr * sp * sy + -cr * cy);
- right[2] = -sr * cp;
+ right[0] = (-1 * sr * sp * cy + -1 * cr * -sy);
+ right[1] = (-1 * sr * sp * sy + -1 * cr * cy);
+ right[2] = -1 * sr * cp;
}
if (up != null) {
up[0] = (cr * sp * cy + -sr * -sy);
@@ -487,21 +479,21 @@ public class Math3D extends Lib {
}
}
-// public static void MatClear(float m[][]) {
-// m[0][0] = m[0][1] = m[0][2] = m[1][0] = m[1][1] = m[1][2] = m[2][0] = m[2][1] = m[2][2] = 0.0f;
-// }
+ public static void MatClear(float m[][]) {
+ m[0][0] = m[0][1] = m[0][2] = m[1][0] = m[1][1] = m[1][2] = m[2][0] = m[2][1] = m[2][2] = 0.0f;
+ }
-// private static final void MatCopy(float src[][], float dst[][]) {
-// dst[0][0]=src[0][0];
-// dst[0][1]=src[0][1];
-// dst[0][2]=src[0][2];
-// dst[1][0]=src[1][0];
-// dst[1][1]=src[1][1];
-// dst[1][2]=src[1][2];
-// dst[2][0]=src[2][0];
-// dst[2][1]=src[2][1];
-// dst[2][2]=src[2][2];
-// }
+ private static final void MatCopy(float src[][], float dst[][]) {
+ dst[0][0]=src[0][0];
+ dst[0][1]=src[0][1];
+ dst[0][2]=src[0][2];
+ dst[1][0]=src[1][0];
+ dst[1][1]=src[1][1];
+ dst[1][2]=src[1][2];
+ dst[2][0]=src[2][0];
+ dst[2][1]=src[2][1];
+ dst[2][2]=src[2][2];
+ }
public static void G_ProjectSource(float[] point, float[] distance, float[] forward, float[] right, float[] result) {
result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1];
@@ -511,7 +503,7 @@ public class Math3D extends Lib {
- public static final float DotProduct(float[] x, float[] y) {
+ public static float DotProduct(float[] x, float[] y) {
return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
}
diff --git a/test/jake2/qcommon/TestTGA.java b/test/jake2/qcommon/TestTGA.java
deleted file mode 100644
index 32d45cd..0000000
--- a/test/jake2/qcommon/TestTGA.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * TestTGA.java
- * Copyright (C) 2003
- *
- * $Id: TestTGA.java,v 1.1 2004-07-08 20:24:31 hzi 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.
-
-*/
-package jake2.qcommon;
-
-import jake2.game.Cmd;
-import jake2.imageio.ImageFrame;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.IntBuffer;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.TreeSet;
-import java.util.logging.*;
-
-import javax.imageio.stream.MemoryCacheImageInputStream;
-
-
-
-/**
- * TestTGA
- *
- * @author cwei
- */
-public class TestTGA {
-
- public static void main(String[] args) {
- System.out.println("*** Start TGA test ***\n");
-
- init();
-
- FS.InitFilesystem();
-
- // search for pack_t
- FS.searchpath_t search;
- Collection filenames = new TreeSet();
- for (search = FS.fs_searchpaths; search != null; search = search.next) {
- // is the element a pak file?
- if (search.pack != null) {
- // add all the pak file names
- filenames.addAll(search.pack.files.keySet());
- }
- }
-
- ImageFrame frame = new ImageFrame(null);
- frame.setVisible(true);
- frame.setLocation(50, 50);
- frame.setSize(800, 800);
-
- byte[] buffer = null;
- Dimension dim = new Dimension();
- BufferedImage image = null;
-
- int[] pixel = new int[512 * 512];
-
-
- for (Iterator it = filenames.iterator(); it.hasNext();) {
-
- String filename = it.next().toString();
- if (!filename.endsWith(".tga")) continue;
-
- System.out.println(filename);
- buffer = LoadTGA(filename, dim);
-
- if (buffer != null) {
- try {
-
- int w = dim.width;
- int h = dim.height;
- int size = w * h;
-
- int r, g, b, a;
-
- for (int i = 0; i < size; i++)
- {
- r = buffer[4* i + 0] & 0xFF;
- g = buffer[4* i + 1] & 0xFF;
- b = buffer[4* i + 2] & 0xFF;
- a = buffer[4* i +3] & 0xFF;
-
- pixel[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
- }
-
- image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
- image.setRGB(0, 0, w, h, pixel, 0, w);
-
- AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(3, 3), AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
- BufferedImage tmp = op.filter(image, null);
-
- frame.showImage(tmp);
- frame.setTitle(filename);
-
- Thread.sleep(500);
-
- } catch (InterruptedException e) {
- }
- }
- }
- frame.dispose();
-
- System.gc();
- Runtime rt = Runtime.getRuntime();
- System.out.println(
- "\nJVM total memory: " + rt.totalMemory() / 1024 + " Kbytes");
-
- System.out.println("\n*** TGA test is succeeded :-) ***");
- }
-
- static void init() {
- // init the global LogManager with the logging.properties file
- try {
- LogManager.getLogManager().readConfiguration(
- TestFS.class.getResourceAsStream("/jake2/logging.properties"));
- } catch (SecurityException secEx) {
- secEx.printStackTrace();
- } catch (IOException ioEx) {
- System.err.println(
- "FATAL Error: can't load /jake2/logging.properties (classpath)");
- ioEx.printStackTrace();
- }
- }
-
- /*
- =============
- LoadTGA
- =============
- */
- static byte[] LoadTGA(String name, Dimension dim) {
- int columns, rows, numPixels;
- int pixbuf; // index into pic
- int row, column;
- byte[] raw;
- ByteBuffer buf_p;
- int length;
- qfiles.tga_t targa_header;
- byte[] pic = null;
-
- //
- // load the file
- //
- raw = FS.LoadFile(name);
-
- if (raw == null)
- {
- System.out.println("Bad tga file "+ name +'\n');
- return null;
- }
-
- targa_header = new qfiles.tga_t(raw);
-
- if (targa_header.image_type != 2 && targa_header.image_type != 10)
- System.out.println("LoadTGA: Only type 2 and 10 targa RGB images supported\n");
-
- if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
- System.out.println("LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
-
- columns = targa_header.width;
- rows = targa_header.height;
- numPixels = columns * rows;
-
- if (dim != null) {
- dim.width = columns;
- dim.height = rows;
- }
-
- pic = new byte[numPixels * 4]; // targa_rgba;
-
- if (targa_header.id_length != 0)
- targa_header.data.position(targa_header.id_length); // skip TARGA image comment
-
- buf_p = targa_header.data;
-
- byte red,green,blue,alphabyte;
- red = green = blue = alphabyte = 0;
- int packetHeader, packetSize, j;
-
- if (targa_header.image_type==2) { // Uncompressed, RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
-
- for(column=0; column<columns; column++) {
- switch (targa_header.pixel_size) {
- case 24:
-
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- }
- }
- }
- else if (targa_header.image_type==10) { // Runlength encoded RGB images
- for(row=rows-1; row>=0; row--) {
-
- pixbuf = row * columns * 4;
- try {
-
- for(column=0; column<columns; ) {
-
- packetHeader= buf_p.get() & 0xFF;
- packetSize = 1 + (packetHeader & 0x7f);
-
- if ((packetHeader & 0x80) != 0) { // run-length packet
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- break;
- }
-
- for(j=0;j<packetSize;j++) {
- pic[pixbuf++]=red;
- pic[pixbuf++]=green;
- pic[pixbuf++]=blue;
- pic[pixbuf++]=alphabyte;
- column++;
- if (column==columns) { // run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- else { // non run-length packet
- for(j=0;j<packetSize;j++) {
- switch (targa_header.pixel_size) {
- case 24:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = (byte)255;
- break;
- case 32:
- blue = buf_p.get();
- green = buf_p.get();
- red = buf_p.get();
- alphabyte = buf_p.get();
- pic[pixbuf++] = red;
- pic[pixbuf++] = green;
- pic[pixbuf++] = blue;
- pic[pixbuf++] = alphabyte;
- break;
- }
- column++;
- if (column==columns) { // pixel packet run spans across rows
- column=0;
- if (row>0)
- row--;
- else
- // goto label breakOut;
- throw new longjmpException();
-
- pixbuf = row * columns * 4;
- }
- }
- }
- }
- } catch (longjmpException e){
- // label breakOut:
- }
- }
- }
- return pic;
- }
-
-}
diff --git a/test/jake2/render/DancingQueens.java b/test/jake2/render/DancingQueens.java
index d7d2ea4..fbf233b 100644
--- a/test/jake2/render/DancingQueens.java
+++ b/test/jake2/render/DancingQueens.java
@@ -2,7 +2,7 @@
* DancingQueens.java
* Copyright (C) 2003
*
- * $Id: DancingQueens.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: DancingQueens.java,v 1.1 2004-07-07 19:59:58 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -204,14 +204,9 @@ public class DancingQueens
void run()
{
startTime = System.currentTimeMillis();
- xcommand_t callback = new xcommand_t() {
- public void execute() {
- updateScreen();
- }
- };
while (true)
{
- re.updateScreen(callback);
+ re.updateScreen(null);
KBD.Update();
Cbuf.Execute();
}
diff --git a/test/jake2/render/TestMap.java b/test/jake2/render/TestMap.java
index 711b159..9419fa1 100644
--- a/test/jake2/render/TestMap.java
+++ b/test/jake2/render/TestMap.java
@@ -2,7 +2,7 @@
* TestMap.java
* Copyright (C) 2003
*
- * $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: TestMap.java,v 1.1 2004-07-07 19:59:59 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -177,7 +177,7 @@ public class TestMap
}
};
- Qcommon.InitForTestMap(new String[] { "TestMap $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $" });
+ Qcommon.InitForTestMap(new String[] { "TestMap $Id: TestMap.java,v 1.1 2004-07-07 19:59:59 hzi Exp $" });
// sehr wichtig !!!
VID.Shutdown();
@@ -218,14 +218,9 @@ public class TestMap
void run()
{
startTime = System.currentTimeMillis();
- xcommand_t callback = new xcommand_t() {
- public void execute() {
- updateScreen();
- }
- };
while (true)
{
- re.updateScreen(callback);
+ re.updateScreen(null);
KBD.Update();
Cbuf.Execute();
}
diff --git a/test/jake2/render/TestRenderer.java b/test/jake2/render/TestRenderer.java
index e152747..976d57c 100644
--- a/test/jake2/render/TestRenderer.java
+++ b/test/jake2/render/TestRenderer.java
@@ -2,7 +2,7 @@
* TestRenderer.java
* Copyright (C) 2003
*
- * $Id: TestRenderer.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: TestRenderer.java,v 1.1 2004-07-07 19:59:59 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -226,13 +226,8 @@ public class TestRenderer {
void run() {
startTime = System.currentTimeMillis();
- xcommand_t callback = new xcommand_t() {
- public void execute() {
- updateScreen();
- }
- };
while (true) {
- re.updateScreen(callback);
+ re.updateScreen(null);
KBD.Update();
Cbuf.Execute();
try {