You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(52) |
Aug
(34) |
Sep
(99) |
Oct
(110) |
Nov
(21) |
Dec
(69) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(117) |
Feb
(90) |
Mar
(1) |
Apr
(22) |
May
(96) |
Jun
(25) |
Jul
(22) |
Aug
|
Sep
|
Oct
(18) |
Nov
(43) |
Dec
(71) |
2006 |
Jan
(20) |
Feb
(10) |
Mar
|
Apr
(4) |
May
(2) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(60) |
Nov
(63) |
Dec
(35) |
2007 |
Jan
(18) |
Feb
(40) |
Mar
(14) |
Apr
(18) |
May
(33) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
(1) |
Mar
(25) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Holger Z. <hz...@us...> - 2004-12-16 22:46:06
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28343/src/jake2/sys Modified Files: LWJGLKBD.java JOGLKBD.java KBD.java IN.java Log Message: jwjgl mouse handling works fine without recentering Index: KBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/KBD.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** KBD.java 14 Dec 2004 00:11:01 -0000 1.6 --- KBD.java 16 Dec 2004 22:45:55 -0000 1.7 *************** *** 48,52 **** abstract public void installGrabs(); abstract public void uninstallGrabs(); ! abstract public void centerMouse(); } --- 48,52 ---- abstract public void installGrabs(); abstract public void uninstallGrabs(); ! //abstract public void centerMouse(); } Index: IN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/IN.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IN.java 14 Dec 2004 00:11:01 -0000 1.6 --- IN.java 16 Dec 2004 22:45:55 -0000 1.7 *************** *** 35,44 **** import jake2.util.Math3D; - import java.awt.Component; - import java.awt.Cursor; - import java.awt.Point; - - import javax.swing.ImageIcon; - /** * IN --- 35,38 ---- *************** *** 81,88 **** private static void install_grabs() { - Globals.re.getKeyboardHandler().installGrabs(); - Globals.re.getKeyboardHandler().centerMouse(); - ignorefirst = true; } --- 75,79 ---- Index: JOGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/JOGLKBD.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JOGLKBD.java 15 Dec 2004 19:43:19 -0000 1.3 --- JOGLKBD.java 16 Dec 2004 22:45:55 -0000 1.4 *************** *** 213,216 **** --- 213,217 ---- } c.setCursor(emptyCursor); + centerMouse(); } Index: LWJGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/LWJGLKBD.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LWJGLKBD.java 16 Dec 2004 21:25:07 -0000 1.5 --- LWJGLKBD.java 16 Dec 2004 22:45:54 -0000 1.6 *************** *** 13,19 **** */ public class LWJGLKBD extends KBD { - - private int win_w2; - private int win_h2; private char[] lwjglKeycodeMap = null; --- 13,16 ---- *************** *** 32,38 **** if (!Mouse.isBuffered()) Mouse.enableBuffer(); - win_w2=Display.getDisplayMode().getWidth()/2; - win_h2=Display.getDisplayMode().getHeight()/2; - if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; --- 29,32 ---- *************** *** 188,198 **** Key.Event(key, down, Sys.Milliseconds()); } - - public void centerMouse() - { - Mouse.setPosition(win_x + win_w2,win_y + win_h2); - //Mouse.setGrabbed(true); - //Mouse.setTrackingEnabled(true); - } public void installGrabs() --- 182,185 ---- |
From: Holger Z. <hz...@us...> - 2004-12-16 22:01:41
|
Update of /cvsroot/jake2/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19382/CVSROOT Modified Files: avail Log Message: write acces for sound package Index: avail =================================================================== RCS file: /cvsroot/jake2/CVSROOT/avail,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** avail 15 Dec 2004 19:28:07 -0000 1.1 --- avail 16 Dec 2004 22:01:29 -0000 1.2 *************** *** 2,4 **** avail|hzi avail|cawe, salomo|jake2 ! avail|dsanders1234|jake2/src/jake2/render/lwjgl --- 2,4 ---- avail|hzi avail|cawe, salomo|jake2 ! avail|dsanders1234|jake2/src/jake2/render/lwjgl, jake2/src/jake2/sound/lwjgl |
From: Carsten W. <ca...@us...> - 2004-12-16 21:56:28
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18008/src/jake2/render/lwjgl Modified Files: Model.java Surf.java Log Message: vertexarray reset at the end of level loading not in the main loop Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Model.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Model.java 14 Dec 2004 12:56:59 -0000 1.2 --- Model.java 16 Dec 2004 21:55:58 -0000 1.3 *************** *** 1262,1265 **** --- 1262,1266 ---- } GL_FreeUnusedImages(); + resetPolygonArrays(); //modelMemoryUsage(); Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Surf.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Surf.java 16 Dec 2004 00:47:17 -0000 1.3 --- Surf.java 16 Dec 2004 21:55:58 -0000 1.4 *************** *** 764,770 **** e.angles[2] = -e.angles[2]; // stupid quake bug - globalPolygonInterleavedBuf.rewind(); - globalPolygonTexCoord1Buf.rewind(); - GL_EnableMultitexture( true ); GL_SelectTexture(GL_TEXTURE0); --- 764,767 ---- *************** *** 1458,1461 **** --- 1455,1459 ---- public static void resetPolygonArrays() { globalPolygonInterleavedBuf.rewind(); + globalPolygonTexCoord1Buf.rewind(); } |
From: Carsten W. <ca...@us...> - 2004-12-16 21:25:16
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11357/src/jake2/sys Modified Files: LWJGLKBD.java Log Message: fixes a right mouse button bug. (dsanders) Index: LWJGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/LWJGLKBD.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LWJGLKBD.java 16 Dec 2004 00:00:01 -0000 1.4 --- LWJGLKBD.java 16 Dec 2004 21:25:07 -0000 1.5 *************** *** 19,22 **** --- 19,24 ---- private char[] lwjglKeycodeMap = null; + private boolean mouseHasTwoButtons = false; + public void Init() { *************** *** 35,38 **** --- 37,42 ---- if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; + mouseHasTwoButtons = (Mouse.getButtonCount() == 2); + } catch (Exception e) {;} } *************** *** 87,92 **** { int button=Mouse.getEventButton(); ! if (button>=0) { Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); } --- 91,99 ---- { int button=Mouse.getEventButton(); ! if (button >= 0) { + if (button == 1 && mouseHasTwoButtons) { + button = 2; // A three button mouse numbering scheme... + } Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); } |
From: Carsten W. <ca...@us...> - 2004-12-16 21:13:22
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9182/src/jake2/render Modified Files: Renderer.java Log Message: checks the runtime package for opengl drivers Index: Renderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/Renderer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Renderer.java 14 Dec 2004 12:58:05 -0000 1.4 --- Renderer.java 16 Dec 2004 21:13:06 -0000 1.5 *************** *** 37,52 **** public class Renderer { - static Vector drivers = new Vector(3); - public static final String DEFAULT = JoglRenderer.DRIVER_NAME; - private static final String DEFAULT_CLASS = "jake2.render.JoglRenderer"; - static { try { ! Class.forName("jake2.render.JoglRenderer"); ! Class.forName("jake2.render.FastJoglRenderer"); ! Class.forName("jake2.render.LWJGLRenderer"); ! } catch (ClassNotFoundException e) { e.printStackTrace(); } --- 37,58 ---- public class Renderer { static Vector drivers = new Vector(3); static { try { ! try { ! Class.forName("net.java.games.jogl.GL"); ! Class.forName("jake2.render.JoglRenderer"); ! Class.forName("jake2.render.FastJoglRenderer"); ! } catch (ClassNotFoundException e) { ! // ignore the jogl drivers if runtime not in classpath ! } ! try { ! Class.forName("org.lwjgl.opengl.GL11"); ! Class.forName("jake2.render.LWJGLRenderer"); ! } catch (ClassNotFoundException e) { ! // ignore the lwjgl driver if runtime not in classpath ! } ! } catch (Throwable e) { e.printStackTrace(); } |
From: Carsten W. <ca...@us...> - 2004-12-16 21:12:09
|
Update of /cvsroot/jake2/jake2/src/jake2/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8929/src/jake2/sound Modified Files: S.java Log Message: checks the runtime package for sound drivers Index: S.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/S.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** S.java 16 Dec 2004 20:17:55 -0000 1.4 --- S.java 16 Dec 2004 21:11:56 -0000 1.5 *************** *** 45,51 **** static { try { Class.forName("jake2.sound.DummyDriver"); ! Class.forName("jake2.sound.joal.JOALSoundImpl"); ! Class.forName("jake2.sound.lwjgl.LWJGLSoundImpl"); } catch (Throwable e) { --- 45,62 ---- static { try { + // dummy driver (no sound) Class.forName("jake2.sound.DummyDriver"); ! try { ! Class.forName("net.java.games.joal.AL"); ! Class.forName("jake2.sound.joal.JOALSoundImpl"); ! } catch (ClassNotFoundException e) { ! // ignore the joal driver if runtime not in classpath ! } ! try { ! Class.forName("org.lwjgl.openal.AL"); ! Class.forName("jake2.sound.lwjgl.LWJGLSoundImpl"); ! } catch (ClassNotFoundException e) { ! // ignore the lwjgl driver if runtime not in classpath ! } } catch (Throwable e) { *************** *** 87,91 **** } ! s_impl = Cvar.Get("s_impl", "joal", Defines.CVAR_ARCHIVE); useDriver(s_impl.string); --- 98,108 ---- } ! // set the first driver after dummy as default ! String defaultDriver = "dummy"; ! if (drivers.size() > 1){ ! defaultDriver = ((Sound)drivers.elementAt(1)).getName(); ! } ! ! s_impl = Cvar.Get("s_impl", defaultDriver, Defines.CVAR_ARCHIVE); useDriver(s_impl.string); *************** *** 189,191 **** return impl.getName(); } ! } --- 206,208 ---- return impl.getName(); } ! } \ No newline at end of file |
From: Carsten W. <ca...@us...> - 2004-12-16 20:33:18
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32405/src/jake2/sound/lwjgl Modified Files: LWJGLSoundImpl.java Log Message: renamed to lwjgl Index: LWJGLSoundImpl.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/lwjgl/LWJGLSoundImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LWJGLSoundImpl.java 16 Dec 2004 20:17:55 -0000 1.1 --- LWJGLSoundImpl.java 16 Dec 2004 20:33:08 -0000 1.2 *************** *** 1,836 **** ! /* ! * LWJGLSoundImpl.java ! * Copyright (C) 2004 ! * ! * $Id$ ! */ ! package jake2.sound.lwjgl; ! ! import jake2.Defines; ! import jake2.Globals; [...1643 lines suppressed...] ! 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)); ! } ! ! } |
From: Carsten W. <ca...@us...> - 2004-12-16 20:18:11
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28384/src/jake2/sound/lwjgl Added Files: LWJGLSoundImpl.java Channel.java Log Message: initial checkin of the lwjgl sound from david sanders --- NEW FILE: Channel.java --- /* * Created on Jun 19, 2004 * * Copyright (C) 2003 * * $Id: Channel.java,v 1.1 2004/12/16 20:17:55 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.sound.lwjgl; /** * 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; } } --- NEW FILE: LWJGLSoundImpl.java --- /* * LWJGLSoundImpl.java * Copyright (C) 2004 * * $Id: LWJGLSoundImpl.java,v 1.1 2004/12/16 20:17:55 cawe Exp $ */ package jake2.sound.lwjgl; import jake2.Defines; import jake2.Globals; import jake2.client.CL; import jake2.client.CL_ents; import jake2.game.*; import jake2.qcommon.*; import jake2.sound.*; import jake2.util.*; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.*; import java.util.*; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.openal.*; import org.lwjgl.openal.eax.EAX20; import org.lwjgl.openal.eax.EAXListenerProperties; /** * LWJGLSoundImpl */ public final class LWJGLSoundImpl implements Sound { static { S.register(new LWJGLSoundImpl()); }; private boolean hasEAX; private cvar_t s_volume; private static final int MAX_SFX = Defines.MAX_SOUNDS * 2; private static final int MAX_CHANNELS = 32; private IntBuffer buffers = BufferUtils.createIntBuffer(MAX_SFX); private IntBuffer sources = BufferUtils.createIntBuffer(MAX_CHANNELS); private Channel[] channels = null; private int num_channels = 0; // singleton private LWJGLSoundImpl() { } /* (non-Javadoc) * @see jake2.sound.SoundImpl#Init() */ public boolean Init() { try { initOpenAL(); checkError(); initOpenALExtensions(); } catch (OpenALException e) { Com.Printf(e.getMessage() + '\n'); return false; } catch (Exception e) { Com.DPrintf(e.getMessage() + '\n'); return false; } AL10.alGenBuffers(buffers); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); initChannels(); AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); 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 { try { AL.create(); } catch (LWJGLException e) { throw new OpenALException(e); } String deviceName = null; String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { deviceName = "DirectSound3D"; } String deviceSpecifier = ALC.alcGetString(ALC.ALC_DEVICE_SPECIFIER); String defaultSpecifier = ALC.alcGetString(ALC.ALC_DEFAULT_DEVICE_SPECIFIER); Com.Printf(os + " using " + ((deviceName == null) ? defaultSpecifier : deviceName) + '\n'); // Check for an error. if (ALC.alcGetError() != ALC.ALC_NO_ERROR) { Com.DPrintf("Error with SoundDevice"); } } private void initOpenALExtensions() throws OpenALException { if (AL10.alIsExtensionPresent("EAX2.0")) { Com.Printf("... using EAX2.0\n"); hasEAX=true; } else { Com.Printf("... EAX2.0 not found\n"); hasEAX=false; } } void exitOpenAL() { // Release the context and the device. AL.destroy(); } private void initChannels() { // create channels channels = new Channel[MAX_CHANNELS]; int sourceId; IntBuffer tmp = BufferUtils.createIntBuffer(1); int error; for (int i = 0; i < MAX_CHANNELS; i++) { AL10.alGenSources(tmp); sourceId = tmp.get(0); //if ((error = al.alGetError()) != AL.AL_NO_ERROR) break; if (sourceId <= 0) break; sources.put(i, sourceId); channels[i] = new Channel(sourceId); num_channels++; // set default values for AL sources AL10.alSourcef (sourceId, AL10.AL_GAIN, s_volume.value); AL10.alSourcef (sourceId, AL10.AL_PITCH, 1.0f); AL10.alSourcei (sourceId, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE); AL10.nalSourcefv(sourceId, AL10.AL_VELOCITY, NULLVECTOR_BUFFER,0); AL10.alSourcei (sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef (sourceId, AL10.AL_REFERENCE_DISTANCE, 300.0f); AL10.alSourcef (sourceId, AL10.AL_MIN_GAIN, 0.0005f); AL10.alSourcef (sourceId, AL10.AL_MAX_GAIN, 1.0f); } Com.Printf("... using " + num_channels + " channels\n"); } /* (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 = AL10.AL_FORMAT_MONO16; ByteBuffer data = BufferUtils.createByteBuffer(sfx.cache.data.length); data.put(sfx.cache.data); data.rewind(); int freq = sfx.cache.speed; AL10.alBufferData( buffers.get(sfx.bufferId), format, data, freq); } private void checkError() { Com.DPrintf("AL Error: " + alErrorString() +'\n'); } private String alErrorString(){ int error; String message = ""; if ((error = AL10.alGetError()) != AL10.AL_NO_ERROR) { switch(error) { case AL10.AL_INVALID_OPERATION: message = "invalid operation"; break; case AL10.AL_INVALID_VALUE: message = "invalid value"; break; case AL10.AL_INVALID_ENUM: message = "invalid enum"; break; case AL10.AL_INVALID_NAME: message = "invalid name"; break; default: message = "" + error; } } return message; } /* (non-Javadoc) * @see jake2.sound.SoundImpl#Shutdown() */ public void Shutdown() { StopAllSounds(); AL10.alDeleteSources(sources); AL10.alDeleteBuffers(buffers); exitOpenAL(); 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; num_channels = 0; } //private final static float[] NULLVECTOR = {0, 0, 0}; private final static FloatBuffer NULLVECTOR_BUFFER=Lib.newFloatBuffer(3); 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.get(sfx.bufferId), 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 < num_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 == num_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 FloatBuffer listenerOriginBuffer=FloatBuffer.wrap(listenerOrigin); private float[] listenerOrientation = {0, 0, 0, 0, 0, 0}; private FloatBuffer listenerOrientationBuffer=FloatBuffer.wrap(listenerOrientation); private IntBuffer eaxEnv = Lib.newIntBuffer(1); private int currentEnv = -1; private boolean changeEnv = true; // TODO workaround for JOAL-bug // should be EAX.LISTENER private final static int EAX_LISTENER = 0; // should be EAX.SOURCE private final static int EAX_SOURCE = 1; /* (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); AL10.nalListenerfv(AL10.AL_POSITION, listenerOriginBuffer,0); convertOrientation(forward, up, listenerOrientation); AL10.nalListenerfv(AL10.AL_ORIENTATION, listenerOrientationBuffer,0); if (hasEAX) { // workaround for environment initialisation if (currentEnv == -1) { eaxEnv.put(0, EAX20.EAX_ENVIRONMENT_UNDERWATER); EAX20.eaxSet(EAX_LISTENER, EAXListenerProperties.EAXLISTENER_ENVIRONMENT | EAXListenerProperties.EAXLISTENER_DEFERRED, 0, eaxEnv, 4); changeEnv = true; } if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) { changeEnv = currentEnv != EAX20.EAX_ENVIRONMENT_UNDERWATER; currentEnv = EAX20.EAX_ENVIRONMENT_UNDERWATER; } else { changeEnv = currentEnv != EAX20.EAX_ENVIRONMENT_GENERIC; currentEnv = EAX20.EAX_ENVIRONMENT_GENERIC; } if (changeEnv) { eaxEnv.put(0, currentEnv); EAX20.eaxSet(EAX_LISTENER, EAXListenerProperties.EAXLISTENER_ENVIRONMENT | EAXListenerProperties.EAXLISTENER_DEFERRED, 0, eaxEnv, 4); } } AddLoopSounds(origin); playChannels(listenerOrigin); } Map looptable = new Hashtable(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.get(sfx.bufferId), 6); if (ch == null) break; ch.addFixed(ent.origin); ch.autosound = true; looptable.put(key, ch); AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.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) { AL10.alSourceStop(ch.sourceId); AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); iter.remove(); ch.clear(); } } } void playChannels(float[] listenerOrigin) { float[] sourceOrigin = {0, 0, 0}; FloatBuffer sourceOriginBuffer=FloatBuffer.wrap(sourceOrigin); float[] entityOrigin = {0, 0, 0}; Channel ch; int sourceId; int state; for (int i = 0; i < num_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_ents.GetEntitySoundOrigin(ch.entity, entityOrigin); convertVector(entityOrigin, sourceOrigin); break; case Channel.FIXED: convertVector(ch.origin, sourceOrigin); break; } if (ch.modified) { if (ch.bufferChanged) AL10.alSourcei (sourceId, AL10.AL_BUFFER, ch.bufferId); AL10.alSourcef (sourceId, AL10.AL_GAIN, s_volume.value); AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff); AL10.nalSourcefv(sourceId, AL10.AL_POSITION, sourceOriginBuffer,0); AL10.alSourcePlay(sourceId); ch.modified = false; } else { state = AL10.alGetSourcei(ch.sourceId, AL10.AL_SOURCE_STATE); if (state == AL10.AL_PLAYING) { AL10.nalSourcefv(sourceId, AL10.AL_POSITION, sourceOriginBuffer,0); } else { ch.clear(); } } ch.autosound = false; } } } /* (non-Javadoc) * @see jake2.sound.SoundImpl#StopAllSounds() */ public void StopAllSounds() { for (int i = 0; i < num_channels; i++) { AL10.alSourceStop(sources.get(i)); AL10.alSourcei(sources.get(i), AL10.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 "lwjgl_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 // TODO configstrings for player male and female are wrong 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 String maleFilename = "player/male/" + base.substring(1); sfx = AliasName(sexedFilename, maleFilename); } } 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; sfx.bufferId = 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; // set the AL bufferId sfx.bufferId = 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)); } } |
From: Carsten W. <ca...@us...> - 2004-12-16 20:18:11
|
Update of /cvsroot/jake2/jake2/src/jake2/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28384/src/jake2/sound Modified Files: S.java Log Message: initial checkin of the lwjgl sound from david sanders Index: S.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sound/S.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** S.java 3 Nov 2004 14:33:06 -0000 1.3 --- S.java 16 Dec 2004 20:17:55 -0000 1.4 *************** *** 47,51 **** Class.forName("jake2.sound.DummyDriver"); Class.forName("jake2.sound.joal.JOALSoundImpl"); ! Class.forName("jake2.sound.jsound.JSoundImpl"); } catch (Throwable e) { --- 47,51 ---- Class.forName("jake2.sound.DummyDriver"); Class.forName("jake2.sound.joal.JOALSoundImpl"); ! Class.forName("jake2.sound.lwjgl.LWJGLSoundImpl"); } catch (Throwable e) { |
From: Carsten W. <ca...@us...> - 2004-12-16 19:55:30
|
Update of /cvsroot/jake2/jake2/src/jake2/sound/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22903/src/jake2/sound/lwjgl Log Message: Directory /cvsroot/jake2/jake2/src/jake2/sound/lwjgl added to the repository |
From: Carsten W. <ca...@us...> - 2004-12-16 19:53:53
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22372/src/jake2/render/lwjgl Modified Files: Base.java Added Files: LWJGLBase.java Log Message: LWJGLBase was moved to its package Index: Base.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Base.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Base.java 14 Dec 2004 12:56:59 -0000 1.2 --- Base.java 16 Dec 2004 19:53:41 -0000 1.3 *************** *** 26,30 **** package jake2.render.lwjgl; - import jake2.render.LWJGLBase; import org.lwjgl.opengl.GL11; --- 26,29 ---- --- NEW FILE: LWJGLBase.java --- /* * LWJGLBase.java * Copyright (C) 2004 * * $Id: LWJGLBase.java,v 1.1 2004/12/16 19:53:41 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.client.VID; import jake2.client.viddef_t; import jake2.game.cvar_t; import jake2.qcommon.xcommand_t; import java.awt.Dimension; import java.util.LinkedList; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import org.lwjgl.util.GLImpl; public abstract class LWJGLBase { // IMPORTED FUNCTIONS protected DisplayMode oldDisplayMode; protected GLImpl gl=new GLImpl(); // window position on the screen int window_xpos, window_ypos; protected viddef_t vid = new viddef_t(); // handles the post initialization with JoglRenderer protected boolean post_init = false; protected boolean contextInUse = false; protected abstract boolean R_Init2(); protected 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(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // // check the post init process // if (!post_init) { VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); } GLimp_EndFrame(); } }; protected xcommand_t callback = INIT_CALLBACK; protected cvar_t vid_fullscreen; // enum rserr_t protected static final int rserr_ok = 0; protected static final int rserr_invalid_fullscreen = 1; protected static final int rserr_invalid_mode = 2; protected static final int rserr_unknown = 3; private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) { return new java.awt.DisplayMode(m.getWidth(),m.getHeight(),m.getBitsPerPixel(),m.getFrequency()); } public java.awt.DisplayMode[] getModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(toAwtDisplayMode(oldDisplayMode)); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; java.awt.DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (java.awt.DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(toAwtDisplayMode(m)); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, toAwtDisplayMode(m)); } else if (m.getFrequency() > ml.getRefreshRate()){ l.remove(j); l.add(j, toAwtDisplayMode(m)); } } java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; l.toArray(ma); return ma; } public DisplayMode[] getLWJGLModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(oldDisplayMode); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(m); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, m); } else if (m.getFrequency() > ml.getFrequency()){ l.remove(j); l.add(j, m); } } DisplayMode[] ma = new DisplayMode[l.size()]; l.toArray(ma); return ma; } private DisplayMode findDisplayMode(Dimension dim) { DisplayMode mode = null; DisplayMode m = null; DisplayMode[] modes = getLWJGLModeList(); 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) { mode = m; break; } } if (mode == null) mode = oldDisplayMode; 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.getBitsPerPixel()); sb.append('@'); sb.append(m.getFrequency()); sb.append("Hz"); return sb.toString(); } /** * @param dim * @param mode * @param fullscreen * @return enum rserr_t */ protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { Dimension newDim = new Dimension(); VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); /* * fullscreen handling */ if (oldDisplayMode == null) { oldDisplayMode = Display.getDisplayMode(); } if (!VID.GetModeInfo(newDim, mode)) { VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); return rserr_invalid_mode; } VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); // destroy the existing window GLimp_Shutdown(); Display.setTitle("Jake2"); DisplayMode displayMode = findDisplayMode(newDim); newDim.width = displayMode.getWidth(); newDim.height = displayMode.getHeight(); if (fullscreen) { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } Display.setLocation(0,0); try { Display.setFullscreen(fullscreen); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } try { Display.setFullscreen(false); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } Display.setLocation(window_xpos, window_ypos); } vid.width = newDim.width; vid.height = newDim.height; try { Display.create(); } catch (LWJGLException e) { return rserr_unknown; } // let the sound and input subsystems know about the new window VID.NewWindow(vid.width, vid.height); post_init = R_Init2(); updateScreen(); return rserr_ok; } protected void GLimp_Shutdown() { if (oldDisplayMode != null && Display.isFullscreen()) { try { Display.setFullscreen(false); Display.setDisplayMode(oldDisplayMode); } catch (Exception e) { e.printStackTrace(); } } if (Display.isCreated()) Display.destroy(); post_init = false; callback = INIT_CALLBACK; } /** * @return true */ protected boolean GLimp_Init(int xpos, int ypos) { // do nothing window_xpos = xpos; window_ypos = ypos; return true; } protected void GLimp_EndFrame() { gl.glFlush(); // swap buffer // TODO this and a new JOGL-release solves the flickering bug (Loading) // canvas.swapBuffers(); } protected void GLimp_BeginFrame(float camera_separation) { // do nothing } protected void GLimp_AppActivate(boolean activate) { // do nothing } protected void GLimp_EnableLogging(boolean enable) { // doesn't need jogl logging // do nothing } protected void GLimp_LogNewFrame() { // doesn't need jogl logging // do nothing } /* * @see jake2.client.refexport_t#updateScreen() */ public void updateScreen() { this.callback = INIT_CALLBACK; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } public void updateScreen(xcommand_t callback) { this.callback = callback; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } } |
From: Carsten W. <ca...@us...> - 2004-12-16 19:53:52
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22372/src/jake2/render Removed Files: LWJGLBase.java Log Message: LWJGLBase was moved to its package --- LWJGLBase.java DELETED --- |
From: Carsten W. <ca...@us...> - 2004-12-16 19:47:00
|
Update of /cvsroot/jake2/jake2/src/jake2/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20655/src/jake2/util Modified Files: Lib.java Log Message: the reference to jogl removed Index: Lib.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Lib.java 6 Dec 2004 13:47:02 -0000 1.10 --- Lib.java 16 Dec 2004 19:46:49 -0000 1.11 *************** *** 31,36 **** import java.nio.*; - import net.java.games.jogl.util.BufferUtils; - public class Lib { --- 31,34 ---- *************** *** 280,285 **** */ ! public static final int SIZEOF_FLOAT = BufferUtils.SIZEOF_FLOAT; ! public static final int SIZEOF_INT = BufferUtils.SIZEOF_INT; public static FloatBuffer newFloatBuffer(int numElements) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); --- 278,284 ---- */ ! public static final int SIZEOF_FLOAT = 4; ! public static final int SIZEOF_INT = 4; ! public static FloatBuffer newFloatBuffer(int numElements) { ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); |
From: David <dsa...@us...> - 2004-12-16 00:47:26
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17951/src/jake2/render/lwjgl Modified Files: Surf.java Log Message: Added two rewind statements for nio buffers, which fixes a graphics bug. Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Surf.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Surf.java 14 Dec 2004 12:56:59 -0000 1.2 --- Surf.java 16 Dec 2004 00:47:17 -0000 1.3 *************** *** 764,767 **** --- 764,770 ---- e.angles[2] = -e.angles[2]; // stupid quake bug + globalPolygonInterleavedBuf.rewind(); + globalPolygonTexCoord1Buf.rewind(); + GL_EnableMultitexture( true ); GL_SelectTexture(GL_TEXTURE0); |
From: Carsten W. <ca...@us...> - 2004-12-16 00:00:10
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8357/src/jake2/sys Modified Files: LWJGLKBD.java Log Message: simple Index: LWJGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/LWJGLKBD.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LWJGLKBD.java 14 Dec 2004 17:41:38 -0000 1.3 --- LWJGLKBD.java 16 Dec 2004 00:00:01 -0000 1.4 *************** *** 58,69 **** Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! int key; ! char ch; ! boolean down; while (Keyboard.next()) { ! key = Keyboard.getEventKey(); ! ch = Keyboard.getEventCharacter(); ! down = Keyboard.getEventKeyState(); // fill the character translation table --- 58,67 ---- Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! while (Keyboard.next()) { ! int key = Keyboard.getEventKey(); ! char ch = Keyboard.getEventCharacter(); ! boolean down = Keyboard.getEventKeyState(); // fill the character translation table |
From: Holger Z. <hz...@us...> - 2004-12-15 19:43:34
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12432/src/jake2/sys Modified Files: JOGLKBD.java Log Message: reenable mousewheel support Index: JOGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/JOGLKBD.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JOGLKBD.java 14 Dec 2004 00:11:01 -0000 1.2 --- JOGLKBD.java 15 Dec 2004 19:43:19 -0000 1.3 *************** *** 3,17 **** import jake2.client.Key; ! import java.awt.AWTException; ! import java.awt.Component; ! import java.awt.Container; ! import java.awt.Cursor; ! import java.awt.Insets; ! import java.awt.Point; ! import java.awt.Robot; ! import java.awt.event.ComponentEvent; ! import java.awt.event.InputEvent; ! import java.awt.event.KeyEvent; ! import java.awt.event.MouseEvent; import javax.swing.ImageIcon; --- 3,8 ---- import jake2.client.Key; ! import java.awt.*; ! import java.awt.event.*; import javax.swing.ImageIcon; *************** *** 81,85 **** Do_Key_Event(Key.K_MOUSE1 + b, false); break; ! case Jake2InputEvent.CreateNotify : case Jake2InputEvent.ConfigureNotify : --- 72,87 ---- Do_Key_Event(Key.K_MOUSE1 + b, false); break; ! ! case Jake2InputEvent.WheelMoved: ! int dir = ((MouseWheelEvent)event.ev).getWheelRotation(); ! if (dir > 0) { ! Do_Key_Event(Key.K_MWHEELDOWN, true); ! Do_Key_Event(Key.K_MWHEELDOWN, false); ! } else { ! Do_Key_Event(Key.K_MWHEELUP, true); ! Do_Key_Event(Key.K_MWHEELUP, false); ! } ! break; ! case Jake2InputEvent.CreateNotify : case Jake2InputEvent.ConfigureNotify : |
From: Holger Z. <hz...@us...> - 2004-12-15 19:28:16
|
Update of /cvsroot/jake2/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8691/CVSROOT Modified Files: commitinfo checkoutlist Added Files: avail Log Message: setup access control Index: checkoutlist =================================================================== RCS file: /cvsroot/jake2/CVSROOT/checkoutlist,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** checkoutlist 7 Jun 2004 16:10:11 -0000 1.1 --- checkoutlist 15 Dec 2004 19:28:07 -0000 1.2 *************** *** 12,13 **** --- 12,14 ---- # # comment lines begin with '#' + avail --- NEW FILE: avail --- unavail avail|hzi avail|cawe, salomo|jake2 avail|dsanders1234|jake2/src/jake2/render/lwjgl Index: commitinfo =================================================================== RCS file: /cvsroot/jake2/CVSROOT/commitinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** commitinfo 7 Jun 2004 16:10:11 -0000 1.1 --- commitinfo 15 Dec 2004 19:28:07 -0000 1.2 *************** *** 14,15 **** --- 14,16 ---- # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". + ALL /cvsroot/sitedocs/CVSROOT/cvstools/cvs_acls |
From: Carsten W. <ca...@us...> - 2004-12-14 17:41:48
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22895/src/jake2/sys Modified Files: LWJGLKBD.java Log Message: mouse uses delta --> freelook is ok; keycode translation is now ok Index: LWJGLKBD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/LWJGLKBD.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LWJGLKBD.java 14 Dec 2004 00:11:01 -0000 1.2 --- LWJGLKBD.java 14 Dec 2004 17:41:38 -0000 1.3 *************** *** 14,19 **** public class LWJGLKBD extends KBD { ! static private int win_w2; ! static private int win_h2; public void Init() --- 14,21 ---- public class LWJGLKBD extends KBD { ! private int win_w2; ! private int win_h2; ! ! private char[] lwjglKeycodeMap = null; public void Init() *************** *** 25,32 **** --- 27,37 ---- if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); + if (!Keyboard.isTranslationEnabled()) Keyboard.enableTranslation(); if (!Mouse.isBuffered()) Mouse.enableBuffer(); win_w2=Display.getDisplayMode().getWidth()/2; win_h2=Display.getDisplayMode().getHeight()/2; + + if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; } catch (Exception e) {;} *************** *** 41,66 **** Keyboard.destroy(); Mouse.destroy(); } private void HandleEvents() { if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! ! for (int i=0; i<Keyboard.getNumKeyboardEvents(); i++) { ! Keyboard.next(); ! int key=Keyboard.getEventKey(); ! char ch=Keyboard.getEventCharacter(); ! Do_Key_Event(XLateKey(key,ch),Keyboard.getEventKeyState()); } if (IN.mouse_active) { ! mx=(Mouse.getX()-win_w2)*2; ! my=(Mouse.getY()-win_h2)*2; } else --- 46,82 ---- Keyboard.destroy(); Mouse.destroy(); + // free the memory for GC + lwjglKeycodeMap = null; } private void HandleEvents() { + Keyboard.poll(); + if (Display.isCloseRequested()) { Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } ! int key; ! char ch; ! boolean down; ! while (Keyboard.next()) { ! key = Keyboard.getEventKey(); ! ch = Keyboard.getEventCharacter(); ! down = Keyboard.getEventKeyState(); ! // fill the character translation table ! // this is needed because the getEventCharacter() returns \0 if a key is released ! // keycode is correct but the charachter value is not ! if (down) lwjglKeycodeMap[key] = ch; ! ! Do_Key_Event(XLateKey(key,ch), down); } if (IN.mouse_active) { ! mx = Mouse.getDX() << 1; ! my = -Mouse.getDY() << 1; } else *************** *** 80,84 **** } ! private static int XLateKey(int code, int ch) { int key = 0; --- 96,100 ---- } ! private int XLateKey(int code, int ch) { int key = 0; *************** *** 151,164 **** case Keyboard.KEY_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; ! default: ! key = ch; if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; break; } if (key > 255) key = 0; - return key; } --- 167,180 ---- case Keyboard.KEY_INSERT: key = Key.K_INS; break; // toggle console for DE and US keyboards + case Keyboard.KEY_GRAVE: case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; ! default: ! key = lwjglKeycodeMap[code]; if (key >= 'A' && key <= 'Z') ! key = key - 'A' + 'a'; break; } if (key > 255) key = 0; return key; } |
From: Carsten W. <ca...@us...> - 2004-12-14 12:58:13
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26420/src/jake2/render Modified Files: Renderer.java Log Message: modification to integrate the LWJGLRenderer Index: Renderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/Renderer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Renderer.java 16 Jul 2004 10:11:34 -0000 1.3 --- Renderer.java 14 Dec 2004 12:58:05 -0000 1.4 *************** *** 47,50 **** --- 47,51 ---- Class.forName("jake2.render.JoglRenderer"); Class.forName("jake2.render.FastJoglRenderer"); + Class.forName("jake2.render.LWJGLRenderer"); } catch (ClassNotFoundException e) { e.printStackTrace(); |
From: Carsten W. <ca...@us...> - 2004-12-14 12:57:24
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26188/src/jake2/render Added Files: LWJGLRenderer.java LWJGLBase.java Log Message: initial import of the lwjgl Renderer from David Sanders --- NEW FILE: LWJGLRenderer.java --- /* * LWJGLRenderer.java * Copyright (C) 2004 * * $Id: LWJGLRenderer.java,v 1.2 2004/12/14 12:57:14 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render; import jake2.Defines; import jake2.client.refdef_t; import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; import jake2.render.lwjgl.Misc; import jake2.sys.KBD; import jake2.sys.LWJGLKBD; import java.awt.Dimension; /** * LWJGLRenderer * * @author dsanders/cwei */ final class LWJGLRenderer extends Misc implements refexport_t, Ref { private LWJGLKBD kbd=new LWJGLKBD(); public static final String DRIVER_NAME = "lwjgl"; static { Renderer.register(new LWJGLRenderer()); }; private LWJGLRenderer() { } // ============================================================================ // 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(LWJGLRenderer.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() { LWJGLRenderer.this.model = R_RegisterModel(LWJGLRenderer.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() { LWJGLRenderer.this.image = R_RegisterSkin(LWJGLRenderer.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() { LWJGLRenderer.this.image = Draw_FindPic(LWJGLRenderer.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(LWJGLRenderer.this.name, LWJGLRenderer.this.rotate, LWJGLRenderer.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() { return this; } public KBD getKeyboardHandler() { return kbd; } } --- NEW FILE: LWJGLBase.java --- /* * LWJGLBase.java * Copyright (C) 2004 * * $Id: LWJGLBase.java,v 1.2 2004/12/14 12:57:14 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render; import jake2.Defines; import jake2.client.VID; import jake2.client.viddef_t; import jake2.game.cvar_t; import jake2.qcommon.xcommand_t; import java.awt.Dimension; import java.util.LinkedList; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.GL11; import org.lwjgl.util.GLImpl; public abstract class LWJGLBase { // IMPORTED FUNCTIONS protected DisplayMode oldDisplayMode; protected GLImpl gl=new GLImpl(); // window position on the screen int window_xpos, window_ypos; protected viddef_t vid = new viddef_t(); // handles the post initialization with JoglRenderer protected boolean post_init = false; protected boolean contextInUse = false; protected abstract boolean R_Init2(); protected 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(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // // check the post init process // if (!post_init) { VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); } GLimp_EndFrame(); } }; protected xcommand_t callback = INIT_CALLBACK; protected cvar_t vid_fullscreen; // enum rserr_t protected static final int rserr_ok = 0; protected static final int rserr_invalid_fullscreen = 1; protected static final int rserr_invalid_mode = 2; protected static final int rserr_unknown = 3; private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) { return new java.awt.DisplayMode(m.getWidth(),m.getHeight(),m.getBitsPerPixel(),m.getFrequency()); } public java.awt.DisplayMode[] getModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(toAwtDisplayMode(oldDisplayMode)); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; java.awt.DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (java.awt.DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(toAwtDisplayMode(m)); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, toAwtDisplayMode(m)); } else if (m.getFrequency() > ml.getRefreshRate()){ l.remove(j); l.add(j, toAwtDisplayMode(m)); } } java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; l.toArray(ma); return ma; } public DisplayMode[] getLWJGLModeList() { DisplayMode[] modes = Display.getAvailableDisplayModes(); LinkedList l = new LinkedList(); l.add(oldDisplayMode); for (int i = 0; i < modes.length; i++) { DisplayMode m = modes[i]; if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (DisplayMode)l.get(j); if (ml.getWidth() > m.getWidth()) break; if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(m); } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, m); } else if (m.getFrequency() > ml.getFrequency()){ l.remove(j); l.add(j, m); } } DisplayMode[] ma = new DisplayMode[l.size()]; l.toArray(ma); return ma; } private DisplayMode findDisplayMode(Dimension dim) { DisplayMode mode = null; DisplayMode m = null; DisplayMode[] modes = getLWJGLModeList(); 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) { mode = m; break; } } if (mode == null) mode = oldDisplayMode; 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.getBitsPerPixel()); sb.append('@'); sb.append(m.getFrequency()); sb.append("Hz"); return sb.toString(); } /** * @param dim * @param mode * @param fullscreen * @return enum rserr_t */ protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { Dimension newDim = new Dimension(); VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); /* * fullscreen handling */ if (oldDisplayMode == null) { oldDisplayMode = Display.getDisplayMode(); } if (!VID.GetModeInfo(newDim, mode)) { VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); return rserr_invalid_mode; } VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); // destroy the existing window GLimp_Shutdown(); Display.setTitle("Jake2"); DisplayMode displayMode = findDisplayMode(newDim); newDim.width = displayMode.getWidth(); newDim.height = displayMode.getHeight(); if (fullscreen) { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } Display.setLocation(0,0); try { Display.setFullscreen(fullscreen); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { try { Display.setDisplayMode(displayMode); } catch (LWJGLException e) { return rserr_invalid_mode; } try { Display.setFullscreen(false); } catch (LWJGLException e) { return rserr_invalid_fullscreen; } Display.setLocation(window_xpos, window_ypos); } vid.width = newDim.width; vid.height = newDim.height; try { Display.create(); } catch (LWJGLException e) { return rserr_unknown; } // let the sound and input subsystems know about the new window VID.NewWindow(vid.width, vid.height); post_init = R_Init2(); updateScreen(); return rserr_ok; } protected void GLimp_Shutdown() { if (oldDisplayMode != null && Display.isFullscreen()) { try { Display.setFullscreen(false); Display.setDisplayMode(oldDisplayMode); } catch (Exception e) { e.printStackTrace(); } } if (Display.isCreated()) Display.destroy(); post_init = false; callback = INIT_CALLBACK; } /** * @return true */ protected boolean GLimp_Init(int xpos, int ypos) { // do nothing window_xpos = xpos; window_ypos = ypos; return true; } protected void GLimp_EndFrame() { gl.glFlush(); // swap buffer // TODO this and a new JOGL-release solves the flickering bug (Loading) // canvas.swapBuffers(); } protected void GLimp_BeginFrame(float camera_separation) { // do nothing } protected void GLimp_AppActivate(boolean activate) { // do nothing } protected void GLimp_EnableLogging(boolean enable) { // doesn't need jogl logging // do nothing } protected void GLimp_LogNewFrame() { // doesn't need jogl logging // do nothing } /* * @see jake2.client.refexport_t#updateScreen() */ public void updateScreen() { this.callback = INIT_CALLBACK; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } public void updateScreen(xcommand_t callback) { this.callback = callback; contextInUse = true; callback.execute(); contextInUse = false; Display.update(); } } |
From: Carsten W. <ca...@us...> - 2004-12-14 12:57:08
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26188/src/jake2/render/lwjgl Added Files: Main.java Draw.java Light.java Model.java Surf.java Mesh.java Image.java Anorms.java Warp.java Misc.java Base.java Log Message: initial import of the lwjgl Renderer from David Sanders --- NEW FILE: Image.java --- /* * Image.java * Copyright (C) 2003 * * $Id: Image.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1657 lines suppressed...] */ 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 texnumBuffer.clear(); texnumBuffer.put(0,image.texnum); gl.glDeleteTextures(texnumBuffer); image.clear(); } } } --- NEW FILE: Surf.java --- /* * Surf.java * Copyright (C) 2003 * * $Id: Surf.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1442 lines suppressed...] // 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); // // } } --- NEW FILE: Light.java --- /* * Light.java * Copyright (C) 2003 * * $Id: Light.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.Globals; import jake2.client.dlight_t; import jake2.game.GameBase; import jake2.game.cplane_t; import jake2.qcommon.Com; import jake2.qcommon.longjmpException; import jake2.render.mnode_t; import jake2.render.msurface_t; import jake2.render.mtexinfo_t; import jake2.util.Math3D; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.Arrays; import org.lwjgl.opengl.GL11; /** * 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 (GL11.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(GL11.GL_TEXTURE_2D); gl.glShadeModel (GL11.GL_SMOOTH); gl.glEnable (GL11.GL_BLEND); gl.glBlendFunc (GL11.GL_ONE, GL11.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(GL11.GL_BLEND); gl.glEnable(GL11.GL_TEXTURE_2D); gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.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) { if (node.contents != -1) return -1; // didn't hit anything msurface_t surf; int s, t, ds, dt; int i; mtexinfo_t tex; ByteBuffer lightmap; int maps; float[] mid = {0, 0, 0}; // calculate mid point // FIXME: optimize for axial cplane_t plane = node.plane; float front = Math3D.DotProduct (start, plane.normal) - plane.dist; float back = Math3D.DotProduct (end, plane.normal) - plane.dist; boolean side = (front < 0); int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); float 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 int 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; float[] scale = {0, 0, 0}; 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}; dlight_t dl; 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; float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) { Math3D.VectorCopy (Globals.vec3_origin, color); } else { Math3D.VectorCopy (pointcolor, color); } // // add dynamic lights // for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { dl = r_newrefdef.dlights[lnum]; Math3D.VectorSubtract (currententity.origin, dl.origin, end); add = dl.intensity - Math3D.VectorLength(end); 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 =============== */ // TODO sync with jogl renderer. hoz void R_AddDynamicLights(msurface_t surf) { int sd, td; float fdist, frad, fminlight; float[] impact = {0, 0, 0}; float[] local = {0, 0, 0}; int s, t; dlight_t dl; float[] pfBL; float fsacc, ftacc; int smax = (surf.extents[0]>>4)+1; int tmax = (surf.extents[1]>>4)+1; mtexinfo_t tex = surf.texinfo; for (int 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 (int 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 ) { for (int 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 =============== */ // TODO sync with jogl renderer. hoz void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride) { int r, g, b, a, max; int i, j; ByteBuffer lightmap; float[] scale = {0, 0, 0}; int nummaps; float[] bl; //lightstyle_t style; if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 ) Com.Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); int smax = (surf.extents[0] >> 4) + 1; int tmax = (surf.extents[1] >> 4) + 1; int size = smax * tmax; if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) ) Com.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; // TODO useless? hoz // 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; int 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)); } } } } } --- NEW FILE: Base.java --- /* * Base.java * Copyright (C) 2003 * * $Id: Base.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.render.LWJGLBase; import org.lwjgl.opengl.GL11; /** * Base * * @author dsanders/cwei */ public abstract class Base extends LWJGLBase { static final int GL_COLOR_INDEX8_EXT = GL11.GL_COLOR_INDEX; static final String REF_VERSION = "GL 0.01"; // up / down static final int PITCH = 0; // left / right static final int YAW = 1; // fall over static final int ROLL = 2; /* skins will be outline flood filled and mip mapped pics and sprites with alpha will be outline flood filled pic won't be mip mapped model skin sprite frame wall texture pic */ // enum imagetype_t static final int it_skin = 0; static final int it_sprite = 1; static final int it_wall = 2; static final int it_pic = 3; static final int it_sky = 4; // enum modtype_t static final int mod_bad = 0; static final int mod_brush = 1; static final int mod_sprite = 2; static final int mod_alias = 3; static final int TEXNUM_LIGHTMAPS = 1024; static final int TEXNUM_SCRAPS = 1152; static final int TEXNUM_IMAGES = 1153; static final int MAX_GLTEXTURES = 1024; // =================================================================== // // #include "gl_model.h" // // void GL_BeginRendering (int *x, int *y, int *width, int *height); // void GL_EndRendering (void); // // void GL_SetDefaultState( void ); // void GL_UpdateSwapInterval( void ); static class glvert_t { float x, y, z; float s, t; float r, g, b; } static final int MAX_LBM_HEIGHT = 480; static final float BACKFACE_EPSILON = 0.01f; // ==================================================== // // void R_TranslatePlayerSkin (int playernum); // void GL_Bind (int texnum); // void GL_MBind( GLenum target, int texnum ); // void GL_TexEnv( GLenum value ); // void GL_EnableMultitexture( qboolean enable ); // void GL_SelectTexture( GLenum ); // // void R_LightPoint (vec3_t p, vec3_t color); // void R_PushDlights (void); // // ==================================================================== // // extern int registration_sequence; // // // void V_AddBlend (float r, float g, float b, float a, float *v_blend); // // int R_Init( void *hinstance, void *hWnd ); // void R_Shutdown( void ); // // void R_RenderView (refdef_t *fd); // void GL_ScreenShot_f (void); // void R_DrawAliasModel (entity_t *e); // void R_DrawBrushModel (entity_t *e); // void R_DrawSpriteModel (entity_t *e); // void R_DrawBeam( entity_t *e ); // void R_DrawWorld (void); // void R_RenderDlights (void); // void R_DrawAlphaSurfaces (void); // void R_RenderBrushPoly (msurface_t *fa); // void R_InitParticleTexture (void); // void Draw_InitLocal (void); // void GL_SubdivideSurface (msurface_t *fa); // qboolean R_CullBox (vec3_t mins, vec3_t maxs); // void R_RotateForEntity (entity_t *e); // void R_MarkLeaves (void); // // glpoly_t *WaterWarpPolyVerts (glpoly_t *p); // void EmitWaterPolys (msurface_t *fa); // void R_AddSkySurface (msurface_t *fa); // void R_ClearSkyBox (void); // void R_DrawSkyBox (void); // void R_MarkLights (dlight_t *light, int bit, mnode_t *node); // // // void COM_StripExtension (char *in, char *out); // // void Draw_GetPicSize (int *w, int *h, char *name); // void Draw_Pic (int x, int y, char *name); // void Draw_StretchPic (int x, int y, int w, int h, char *name); // void Draw_Char (int x, int y, int c); // void Draw_TileClear (int x, int y, int w, int h, char *name); // void Draw_Fill (int x, int y, int w, int h, int c); // void Draw_FadeScreen (void); // void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data); // // void R_BeginFrame( float camera_separation ); // void R_SwapBuffers( int ); // void R_SetPalette ( const unsigned char *palette); // // int Draw_GetPalette (void); // // void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight); // // struct image_s *R_RegisterSkin (char *name); // // void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height); // image_t *GL_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type, int bits); // image_t *GL_FindImage (char *name, imagetype_t type); // void GL_TextureMode( char *string ); // void GL_ImageList_f (void); // // void GL_SetTexturePalette( unsigned palette[256] ); // // void GL_InitImages (void); // void GL_ShutdownImages (void); // // void GL_FreeUnusedImages (void); // // void GL_TextureAlphaMode( char *string ); // void GL_TextureSolidMode( char *string ); // // /* // ** GL extension emulation functions // */ // void GL_DrawParticles( int n, const particle_t particles[], const unsigned colortable[768] ); // /* ** GL config stuff */ static final int GL_RENDERER_VOODOO = 0x00000001; static final int GL_RENDERER_VOODOO2 = 0x00000002; static final int GL_RENDERER_VOODOO_RUSH = 0x00000004; static final int GL_RENDERER_BANSHEE = 0x00000008; static final int GL_RENDERER_3DFX = 0x0000000F; static final int GL_RENDERER_PCX1 = 0x00000010; static final int GL_RENDERER_PCX2 = 0x00000020; static final int GL_RENDERER_PMX = 0x00000040; static final int GL_RENDERER_POWERVR = 0x00000070; static final int GL_RENDERER_PERMEDIA2 = 0x00000100; static final int GL_RENDERER_GLINT_MX = 0x00000200; static final int GL_RENDERER_GLINT_TX = 0x00000400; static final int GL_RENDERER_3DLABS_MISC = 0x00000800; static final int GL_RENDERER_3DLABS = 0x00000F00; static final int GL_RENDERER_REALIZM = 0x00001000; static final int GL_RENDERER_REALIZM2 = 0x00002000; static final int GL_RENDERER_INTERGRAPH = 0x00003000; static final int GL_RENDERER_3DPRO = 0x00004000; static final int GL_RENDERER_REAL3D = 0x00008000; static final int GL_RENDERER_RIVA128 = 0x00010000; static final int GL_RENDERER_DYPIC = 0x00020000; static final int GL_RENDERER_V1000 = 0x00040000; static final int GL_RENDERER_V2100 = 0x00080000; static final int GL_RENDERER_V2200 = 0x00100000; static final int GL_RENDERER_RENDITION = 0x001C0000; static final int GL_RENDERER_O2 = 0x00100000; static final int GL_RENDERER_IMPACT = 0x00200000; static final int GL_RENDERER_RE = 0x00400000; static final int GL_RENDERER_IR = 0x00800000; static final int GL_RENDERER_SGI = 0x00F00000; static final int GL_RENDERER_MCD = 0x01000000; static final int GL_RENDERER_OTHER = 0x80000000; // typedef struct // { // int renderer; // const char *renderer_string; // const char *vendor_string; // const char *version_string; // const char *extensions_string; // // qboolean allow_cds; // } glconfig_t; // // typedef struct // { // float inverse_intensity; // qboolean fullscreen; // // int prev_mode; // // unsigned char *d_16to8table; // // int lightmap_textures; // // int currenttextures[2]; // int currenttmu; // // float camera_separation; // qboolean stereo_enabled; // // unsigned char originalRedGammaTable[256]; // unsigned char originalGreenGammaTable[256]; // unsigned char originalBlueGammaTable[256]; // } glstate_t; // // /* // ==================================================================== // // IMPORTED FUNCTIONS // // ==================================================================== // */ // // extern refimport_t ri; // // // /* // ==================================================================== // // IMPLEMENTATION SPECIFIC FUNCTIONS // // ==================================================================== // */ // // void GLimp_BeginFrame( float camera_separation ); // void GLimp_EndFrame( void ); // int GLimp_Init( void *hinstance, void *hWnd ); // void GLimp_Shutdown( void ); // int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen ); // void GLimp_AppActivate( qboolean active ); // void GLimp_EnableLogging( qboolean enable ); // void GLimp_LogNewFrame( void ); // } --- NEW FILE: Draw.java --- /* * Draw.java * Copyright (C) 2003 * * $Id: Draw.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.client.VID; import jake2.qcommon.Com; import jake2.render.image_t; import java.awt.Dimension; import java.nio.ByteBuffer; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; /** * 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(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.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 (GL11.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) { VID.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(GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.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(GL11.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) { VID.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 (GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.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 (GL11.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) { VID.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(GL11.GL_ALPHA_TEST); GL_Bind(image.texnum); gl.glBegin (GL11.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(GL11.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) Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); gl.glDisable(GL11.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 (GL11.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(GL11.GL_TEXTURE_2D); } //============================================================================= /* ================ Draw_FadeScreen ================ */ protected void Draw_FadeScreen() { gl.glEnable(GL11.GL_BLEND); gl.glDisable(GL11.GL_TEXTURE_2D); gl.glColor4f(0, 0, 0, 0.8f); gl.glBegin(GL11.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(GL11.GL_TEXTURE_2D); gl.glDisable(GL11.GL_BLEND); } // ==================================================================== IntBuffer image32=BufferUtils.createIntBuffer(256*256); ByteBuffer image8=BufferUtils.createByteBuffer(256*256); /* ============= 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]; image32.clear(); 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.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac>>16)] & 0xff]); frac += fracstep; } } gl.glTexImage2D (GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image32); } else { //byte[] image8 = new byte[256*256]; image8.clear(); 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.put(destIndex + j, data[sourceIndex + (frac>>16)]); frac += fracstep; } } gl.glTexImage2D( GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, image8 ); } gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) gl.glDisable (GL11.GL_ALPHA_TEST); gl.glBegin (GL11.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 (GL11.GL_ALPHA_TEST); } } --- NEW FILE: Model.java --- /* * Model.java * Copyright (C) 2003 * * $Id: Model.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1327 lines suppressed...] 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()); } } --- NEW FILE: Main.java --- /* * Main.java * Copyright (C) 2003 * * $Id: Main.java,v 1.2 2004/12/14 12:56:58 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. [...1530 lines suppressed...] 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(GL11.GL_TEXTURE_2D); gl.glDisable(GL11.GL_BLEND); gl.glDepthMask(true); } } --- NEW FILE: Warp.java --- /* * Warp.java * Copyright (C) 2003 * * $Id: Warp.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; import jake2.Defines; import jake2.Globals; import jake2.qcommon.Com; import jake2.render.glpoly_t; import jake2.render.image_t; import jake2.render.msurface_t; import jake2.util.Math3D; import java.nio.FloatBuffer; import org.lwjgl.opengl.GL11; /** * 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; float s, t; float[] total = {0, 0, 0}; float total_s, total_t; if (numverts > 60) Com.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 glpoly_t 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(GL11.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) Com.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(GL11.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; } } } } --- NEW FILE: Anorms.java --- /* * Anorms.java * Copyright (C) 2003 * * $Id: Anorms.java,v 1.2 2004/12/14 12:56:59 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.lwjgl; /** * 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}, ... [truncated message content] |
From: Carsten W. <ca...@us...> - 2004-12-14 12:54:37
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25688/src/jake2/client Modified Files: VID.java Log Message: simple video menu label alignment Index: VID.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/VID.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** VID.java 14 Dec 2004 00:11:10 -0000 1.10 --- VID.java 14 Dec 2004 12:54:25 -0000 1.11 *************** *** 572,576 **** "[OpenGL jogl ]", "[OpenGL fastjogl]", ! "[OpenGL lwjgl]", null }; --- 572,576 ---- "[OpenGL jogl ]", "[OpenGL fastjogl]", ! "[OpenGL lwjgl ]", null }; |
From: Carsten W. <ca...@us...> - 2004-12-14 12:49:23
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24720/src/jake2/client Modified Files: particle_t.java Log Message: the backbuffer of colorArray is a ByteBuffer; we need this for lwjgl Index: particle_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/particle_t.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** particle_t.java 9 Jul 2004 06:50:50 -0000 1.2 --- particle_t.java 14 Dec 2004 12:48:51 -0000 1.3 *************** *** 31,37 **** public class particle_t { public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); - public static IntBuffer colorArray = Lib.newIntBuffer(Defines.MAX_PARTICLES, ByteOrder.LITTLE_ENDIAN); public static int[] colorTable = new int[256]; public static void setColorPalette(int[] palette) { --- 31,41 ---- public class particle_t { + // lwjgl renderer needs a ByteBuffer + private static ByteBuffer colorByteArray = Lib.newByteBuffer(Defines.MAX_PARTICLES * Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN); + public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); public static int[] colorTable = new int[256]; + public static IntBuffer colorArray = colorByteArray.asIntBuffer(); + public static void setColorPalette(int[] palette) { *************** *** 40,42 **** --- 44,50 ---- } } + + public static ByteBuffer getColorAsByteBuffer() { + return colorByteArray; + } } |
From: Carsten W. <ca...@us...> - 2004-12-14 01:08:42
|
Update of /cvsroot/jake2/jake2/test/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18799/test/jake2/render Modified Files: DancingQueens.java TestMap.java DebugCulling.java TestRenderer.java Log Message: changes for KBD interface Index: TestMap.java =================================================================== RCS file: /cvsroot/jake2/jake2/test/jake2/render/TestMap.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestMap.java 16 Jul 2004 10:11:36 -0000 1.5 --- TestMap.java 14 Dec 2004 01:08:32 -0000 1.6 *************** *** 122,126 **** { re.updateScreen(callback); ! KBD.Update(); Cbuf.Execute(); } --- 122,126 ---- { re.updateScreen(callback); ! re.getKeyboardHandler().Update(); Cbuf.Execute(); } Index: DebugCulling.java =================================================================== RCS file: /cvsroot/jake2/jake2/test/jake2/render/DebugCulling.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DebugCulling.java 16 Jul 2004 10:11:36 -0000 1.3 --- DebugCulling.java 14 Dec 2004 01:08:32 -0000 1.4 *************** *** 91,95 **** { re.updateScreen(null); ! KBD.Update(); // try { // Thread.sleep(5); --- 91,95 ---- { re.updateScreen(null); ! re.getKeyboardHandler().Update(); // try { // Thread.sleep(5); Index: TestRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/test/jake2/render/TestRenderer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestRenderer.java 16 Jul 2004 10:11:36 -0000 1.5 --- TestRenderer.java 14 Dec 2004 01:08:32 -0000 1.6 *************** *** 143,147 **** while (true) { re.updateScreen(callback); ! KBD.Update(); Cbuf.Execute(); try { --- 143,147 ---- while (true) { re.updateScreen(callback); ! re.getKeyboardHandler().Update(); Cbuf.Execute(); try { Index: DancingQueens.java =================================================================== RCS file: /cvsroot/jake2/jake2/test/jake2/render/DancingQueens.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DancingQueens.java 16 Jul 2004 10:11:36 -0000 1.5 --- DancingQueens.java 14 Dec 2004 01:08:32 -0000 1.6 *************** *** 127,131 **** { re.updateScreen(callback); ! KBD.Update(); Cbuf.Execute(); } --- 127,131 ---- { re.updateScreen(callback); ! re.getKeyboardHandler().Update(); Cbuf.Execute(); } |
From: Carsten W. <ca...@us...> - 2004-12-14 00:58:23
|
Update of /cvsroot/jake2/jake2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16164 Modified Files: .classpath Log Message: add the lwjgl libs to the classpath Index: .classpath =================================================================== RCS file: /cvsroot/jake2/jake2/.classpath,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .classpath 24 Oct 2004 13:01:32 -0000 1.5 --- .classpath 14 Dec 2004 00:58:12 -0000 1.6 *************** *** 9,12 **** --- 9,14 ---- <classpathentry kind="lib" path="lib/jogl/jogl.jar"/> <classpathentry kind="lib" path="resources"/> + <classpathentry kind="lib" path="lib/lwjgl/lwjgl_util.jar"/> + <classpathentry kind="lib" path="lib/lwjgl/lwjgl.jar"/> <classpathentry kind="output" path="build"/> </classpath> |