aboutsummaryrefslogtreecommitdiffstats
path: root/test/jake2/render
diff options
context:
space:
mode:
Diffstat (limited to 'test/jake2/render')
-rw-r--r--test/jake2/render/DancingQueens.java6
-rw-r--r--test/jake2/render/TestMap.java58
-rw-r--r--test/jake2/render/TestRenderer.java52
3 files changed, 72 insertions, 44 deletions
diff --git a/test/jake2/render/DancingQueens.java b/test/jake2/render/DancingQueens.java
index d7d2ea4..db4200c 100644
--- a/test/jake2/render/DancingQueens.java
+++ b/test/jake2/render/DancingQueens.java
@@ -2,7 +2,7 @@
* DancingQueens.java
* Copyright (C) 2003
*
- * $Id: DancingQueens.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: DancingQueens.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -152,14 +152,14 @@ public class DancingQueens
};
- Qcommon.InitForTestMap(new String[] {"DancingQueens"});
+ Qcommon.Init(new String[] {"DancingQueens"});
// sehr wichtig !!!
VID.Shutdown();
String[] names = Renderer.getDriverNames();
System.out.println("Registered Drivers: " + Arrays.asList(names));
- this.re = Renderer.getDriver("jogl", ri);
+ this.re = Renderer.getDriver("fastjogl", ri);
System.out.println("Use driver: " + re);
System.out.println();
diff --git a/test/jake2/render/TestMap.java b/test/jake2/render/TestMap.java
index 711b159..e6670dc 100644
--- a/test/jake2/render/TestMap.java
+++ b/test/jake2/render/TestMap.java
@@ -2,7 +2,7 @@
* TestMap.java
* Copyright (C) 2003
*
- * $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: TestMap.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -36,6 +36,7 @@ import jake2.sys.KBD;
import jake2.util.*;
import java.awt.Dimension;
+import java.nio.FloatBuffer;
import java.util.*;
/**
@@ -177,7 +178,7 @@ public class TestMap
}
};
- Qcommon.InitForTestMap(new String[] { "TestMap $Id: TestMap.java,v 1.2 2004-07-08 20:24:31 hzi Exp $" });
+ Qcommon.Init(new String[] { "TestMap $Id: TestMap.java,v 1.3 2004-07-09 06:50:51 hzi Exp $" });
// sehr wichtig !!!
VID.Shutdown();
@@ -246,8 +247,8 @@ public class TestMap
break;
case 1 :
// register the map
- re.SetSky("space1", 0, new float[]{ 0, 0, 0 });
re.BeginRegistration("base1");
+ re.SetSky("space1", 0, new float[]{ 0, 0, 0 });
re.EndRegistration();
currentState = 2;
//break;
@@ -431,7 +432,7 @@ public class TestMap
refdef.time = time() * 0.001f;
// particle init
- particles.clear();
+ r_numparticles = 0;
// check the enemy distance
float[] diff = {0, 0, 0};
@@ -451,11 +452,7 @@ public class TestMap
// particles
animateParticles();
- particle_t[] tmp = new particle_t[particles.size()];
- particles.toArray(tmp);
-
- refdef.particles = tmp;
- refdef.num_particles = tmp.length;
+ refdef.num_particles = r_numparticles;
}
else {
ent.frame = 0;
@@ -463,10 +460,11 @@ public class TestMap
}
}
+ refdef.num_dlights = 0;
+
re.RenderFrame(refdef);
}
- private Vector particles = new Vector(1024); // = new particle_t[20];
private LinkedList active_particles = new LinkedList();
private boolean explode = false;
private float[] target;
@@ -480,8 +478,7 @@ public class TestMap
float time, time2;
float[] org = {0, 0, 0};
int color;
- particle_t particle;
-
+
time = 0.0f;
for (Iterator it = active_particles.iterator(); it.hasNext();)
@@ -514,13 +511,8 @@ public class TestMap
org[1] = p.org[1] + p.vel[1]*time + p.accel[1]*time2;
org[2] = p.org[2] + p.vel[2]*time + p.accel[2]*time2;
- particle = new particle_t();
- particle.alpha = alpha;
- Math3D.VectorCopy(org, particle.origin);
- particle.color = color;
-
- particles.add(particle);
-
+ AddParticle(org, color, alpha);
+
// PMM
if (p.alphavel == INSTANT_PARTICLE)
{
@@ -565,7 +557,7 @@ public class TestMap
Math3D.VectorMA (dir, s, up, dir);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1 + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x74 + (Lib.rand() & 7);
for (j=0 ; j<3 ; j++)
{
@@ -592,7 +584,7 @@ public class TestMap
Math3D.VectorClear (p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.6f + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x0 + Lib.rand()&15;
for (j=0 ; j<3 ; j++)
@@ -625,4 +617,28 @@ public class TestMap
IN.toggleMouse();
}
};
+
+ int r_numparticles = 0;
+ /*
+ =====================
+ V_AddParticle
+
+ =====================
+ */
+ void AddParticle(float[] org, int color, float alpha) {
+ if (r_numparticles >= Defines.MAX_PARTICLES)
+ return;
+
+ int i = r_numparticles++;
+
+ int c = particle_t.colorTable[color];
+ c |= (int)(alpha * 255) << 24;
+ particle_t.colorArray.put(i, c);
+
+ i *= 3;
+ FloatBuffer vertexBuf = particle_t.vertexArray;
+ vertexBuf.put(i++, org[0]);
+ vertexBuf.put(i++, org[1]);
+ vertexBuf.put(i++, org[2]);
+ }
}
diff --git a/test/jake2/render/TestRenderer.java b/test/jake2/render/TestRenderer.java
index e152747..376bb60 100644
--- a/test/jake2/render/TestRenderer.java
+++ b/test/jake2/render/TestRenderer.java
@@ -2,7 +2,7 @@
* TestRenderer.java
* Copyright (C) 2003
*
- * $Id: TestRenderer.java,v 1.2 2004-07-08 20:24:31 hzi Exp $
+ * $Id: TestRenderer.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render;
import java.awt.Dimension;
+import java.nio.FloatBuffer;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
@@ -441,7 +442,6 @@ public class TestRenderer {
re.RenderFrame(refdef);
}
- private Vector particles = new Vector(1024); // = new particle_t[20];
private LinkedList active_particles = new LinkedList();
private boolean explode = false;
private float[] target;
@@ -450,7 +450,7 @@ public class TestRenderer {
private void testParticles() {
- particles.clear();
+ r_numparticles = 0;
if (active_particles.size() == 0) {
if (explode)
@@ -474,14 +474,9 @@ public class TestRenderer {
animateParticles();
- drawString(refdef.x, refdef.y - 20, "active particles: " + particles.size());
+ drawString(refdef.x, refdef.y - 20, "active particles: " + r_numparticles);
- particle_t[] tmp = new particle_t[particles.size()];
-
- particles.toArray(tmp);
-
- refdef.particles = tmp;
- refdef.num_particles = tmp.length;
+ refdef.num_particles = r_numparticles;
refdef.areabits = null;
refdef.num_entities = 0;
@@ -582,7 +577,7 @@ public class TestRenderer {
p.accel[0] = p.accel[1] = 0;
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + Lib.frand() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
active_particles.add(p);
}
@@ -604,7 +599,6 @@ public class TestRenderer {
float time, time2;
float[] org = {0, 0, 0};
int color;
- particle_t particle;
time = 0.0f;
@@ -637,13 +631,8 @@ public class TestRenderer {
org[0] = p.org[0] + p.vel[0]*time + p.accel[0]*time2;
org[1] = p.org[1] + p.vel[1]*time + p.accel[1]*time2;
org[2] = p.org[2] + p.vel[2]*time + p.accel[2]*time2;
-
- particle = new particle_t();
- particle.alpha = alpha;
- Math3D.VectorCopy(org, particle.origin);
- particle.color = color;
- particles.add(particle);
+ AddParticle(org, color, alpha);
// PMM
if (p.alphavel == INSTANT_PARTICLE)
@@ -778,7 +767,7 @@ public class TestRenderer {
Math3D.VectorMA (dir, s, up, dir);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1 + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x74 + (Lib.rand() & 7);
for (j=0 ; j<3 ; j++)
{
@@ -805,7 +794,7 @@ public class TestRenderer {
Math3D.VectorClear (p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.6f + Lib.frand() * 0.2f);
+ p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x0 + Lib.rand()&15;
for (j=0 ; j<3 ; j++)
@@ -830,5 +819,28 @@ public class TestRenderer {
testnr = testnr % 3;
}
};
+
+ int r_numparticles = 0;
+ /*
+ =====================
+ V_AddParticle
+ =====================
+ */
+ void AddParticle(float[] org, int color, float alpha) {
+ if (r_numparticles >= Defines.MAX_PARTICLES)
+ return;
+
+ int i = r_numparticles++;
+
+ int c = particle_t.colorTable[color];
+ c |= (int)(alpha * 255) << 24;
+ particle_t.colorArray.put(i, c);
+
+ i *= 3;
+ FloatBuffer vertexBuf = particle_t.vertexArray;
+ vertexBuf.put(i++, org[0]);
+ vertexBuf.put(i++, org[1]);
+ vertexBuf.put(i++, org[2]);
+ }
}