summaryrefslogtreecommitdiffstats
path: root/src/jake2/render
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-19 19:39:57 +0000
committerHolger Zickner <[email protected]>2004-07-19 19:39:57 +0000
commita1fc4edc16c4e8960a0f2b0a97ea973b0785372a (patch)
tree92627719f99ddc26816ec2d0463d678e4cf15410 /src/jake2/render
parentb378bf48ede3be8864dc094a615fba8890940714 (diff)
profiling
Diffstat (limited to 'src/jake2/render')
-rw-r--r--src/jake2/render/fastjogl/Image.java19
-rw-r--r--src/jake2/render/fastjogl/Light.java4
-rw-r--r--src/jake2/render/fastjogl/Main.java33
-rw-r--r--src/jake2/render/fastjogl/Mesh.java183
-rw-r--r--src/jake2/render/fastjogl/Model.java8
-rw-r--r--src/jake2/render/fastjogl/Surf.java8
6 files changed, 111 insertions, 144 deletions
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java
index a6b1a91..22f3d02 100644
--- a/src/jake2/render/fastjogl/Image.java
+++ b/src/jake2/render/fastjogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.4 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Image.java,v 1.5 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1465,13 +1465,13 @@ public abstract class Image extends Main {
*/
image_t GL_FindImage(String name, int type) {
image_t image = null;
-
- // TODO loest das grossschreibungs problem
- name = name.toLowerCase();
- // bughack for bad strings (fuck \0)
- int index = name.indexOf('\0');
- if (index != -1)
- name = name.substring(0, index);
+
+// // TODO loest das grossschreibungs problem
+// name = name.toLowerCase();
+// // bughack for bad strings (fuck \0)
+// int index = name.indexOf('\0');
+// if (index != -1)
+// name = name.substring(0, index);
if (name == null || name.length() < 5)
return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name");
@@ -1491,6 +1491,7 @@ public abstract class Image extends Main {
//
// load the pic from disk
//
+ image = null;
byte[] pic = null;
Dimension dim = new Dimension();
@@ -1517,8 +1518,6 @@ public abstract class Image extends Main {
image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32);
}
- else
- return null;
return image;
}
diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java
index 5e7cce5..0ec6807 100644
--- a/src/jake2/render/fastjogl/Light.java
+++ b/src/jake2/render/fastjogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.5 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Light.java,v 1.6 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -570,7 +570,7 @@ public abstract class Light extends Warp {
// memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 );
- Arrays.fill(s_blocklights, 0, size * 3, 0.0f);
+ //Arrays.fill(s_blocklights, 0, size * 3, 0.0f);
for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ;
maps++)
diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java
index bcc4e92..44c31c8 100644
--- a/src/jake2/render/fastjogl/Main.java
+++ b/src/jake2/render/fastjogl/Main.java
@@ -2,7 +2,7 @@
* Main.java
* Copyright (C) 2003
*
- * $Id: Main.java,v 1.3 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Main.java,v 1.4 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -502,11 +502,12 @@ public abstract class Main extends Base {
scale = (scale < 20) ? 1 : 1 + scale * 0.004f;
color = sourceColors.get(i);
+
gl.glColor4ub(
- (byte)((color >> 0) & 0xFF),
+ (byte)((color) & 0xFF),
(byte)((color >> 8) & 0xFF),
(byte)((color >> 16) & 0xFF),
- (byte)((color >> 24) & 0xFF)
+ (byte)((color >>> 24))
);
// first vertex
gl.glTexCoord2f(0.0625f, 0.0625f);
@@ -718,26 +719,28 @@ public abstract class Main extends Base {
=============
*/
void R_SetupGL() {
- float screenaspect;
- int x, x2, y2, y, w, h;
//
// set up viewport
//
- x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width);
- x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
- y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height);
- y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height);
-
- w = x2 - x;
- h = y - y2;
+ //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width);
+ int x = r_newrefdef.x;
+ //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
+ int x2 = r_newrefdef.x + r_newrefdef.width;
+ //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height);
+ int y = vid.height - r_newrefdef.y;
+ //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height);
+ int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height);
+
+ int w = x2 - x;
+ int h = y - y2;
gl.glViewport(x, y2, w, h);
//
// set up projection matrix
//
- screenaspect = (float) r_newrefdef.width / r_newrefdef.height;
+ float screenaspect = (float) r_newrefdef.width / r_newrefdef.height;
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096);
@@ -1168,10 +1171,6 @@ public abstract class Main extends Base {
Cvar.Set("scr_drawall", "0");
}
- // #ifdef __linux__
- Cvar.SetValue("gl_finish", 1);
- // #endif
-
// MCD has buffering issues
if (gl_config.renderer == GL_RENDERER_MCD) {
Cvar.SetValue("gl_finish", 1);
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
index 1569ff9..bff8756 100644
--- a/src/jake2/render/fastjogl/Mesh.java
+++ b/src/jake2/render/fastjogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.4 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Mesh.java,v 1.5 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -68,10 +68,8 @@ public abstract class Mesh extends Light {
float[] shadedots = r_avertexnormal_dots[0];
- void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv )
+ void GL_LerpVerts(int nverts, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv )
{
- int lerpIndex = 0;
-
int[] ovv;
int[] vv;
FloatBuffer lerp = vertexArrayBuf;
@@ -85,12 +83,11 @@ public abstract class Mesh extends Light {
{
normal = r_avertexnormals[verts[i].lightnormalindex];
ovv = ov[i].v;
- vv = v[i].v;
+ vv = verts[i].v;
- lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
- lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
- lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
- j+=3;
+ lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
+ lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
+ lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
}
}
else
@@ -99,12 +96,11 @@ public abstract class Mesh extends Light {
for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
{
ovv = ov[i].v;
- vv = v[i].v;
+ vv = verts[i].v;
- lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]);
- lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]);
- lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]);
- j+=3;
+ lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]);
+ lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]);
+ lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]);
}
}
}
@@ -129,32 +125,20 @@ public abstract class Mesh extends Light {
void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp)
{
- float l;
- qfiles.daliasframe_t frame, oldframe;
- qfiles.dtrivertx_t[] v, ov, verts;
-
- int[] order;
- int orderIndex = 0;
int count;
-
- float frontlerp;
float alpha;
- float[] move = {0, 0, 0}; // vec3_t
-
+ float[] move = {0, 0, 0}; // vec3_t
float[] frontv = {0, 0, 0}; // vec3_t
float[] backv = {0, 0, 0}; // vec3_t
- int i;
- int index_xyz;
-
- frame = paliashdr.aliasFrames[currententity.frame];
+ qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame];
- verts = v = frame.verts;
+ qfiles.dtrivertx_t[] verts = frame.verts;
- oldframe = paliashdr.aliasFrames[currententity.oldframe];
+ qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe];
- ov = oldframe.verts;
+ qfiles.dtrivertx_t[] ov = oldframe.verts;
if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0)
alpha = currententity.alpha;
@@ -165,7 +149,7 @@ public abstract class Mesh extends Light {
if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
gl.glDisable( GL.GL_TEXTURE_2D );
- frontlerp = 1.0f - backlerp;
+ float frontlerp = 1.0f - backlerp;
// move should be the delta back to the previous frame * backlerp
Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv);
@@ -177,7 +161,7 @@ public abstract class Mesh extends Light {
Math3D.VectorAdd (move, oldframe.translate, move);
- for (i=0 ; i<3 ; i++)
+ for (int i=0 ; i<3 ; i++)
{
move[i] = backlerp*move[i] + frontlerp*frame.translate[i];
frontv[i] = frontlerp*frame.scale[i];
@@ -186,7 +170,7 @@ public abstract class Mesh extends Light {
// ab hier wird optimiert
- GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv );
+ GL_LerpVerts( paliashdr.num_xyz, ov, verts, move, frontv, backv );
//gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf );
@@ -206,7 +190,8 @@ public abstract class Mesh extends Light {
//
FloatBuffer color = colorArrayBuf;
int j = 0;
- for ( i = 0; i < paliashdr.num_xyz; i++ )
+ float l;
+ for (int i = 0; i < paliashdr.num_xyz; i++ )
{
l = shadedots[verts[i].lightnormalindex];
color.put(j++, l * shadelight[0]);
@@ -241,20 +226,21 @@ public abstract class Mesh extends Light {
srcIndexBuf = paliashdr.indexElements[j];
- size = (count < 0) ? -count + pos : count + pos;
+ int mode = GL.GL_TRIANGLE_STRIP;
+ if (count < 0) {
+ mode = GL.GL_TRIANGLE_FAN;
+ count = -count;
+ }
+ size = count + pos;
+ srcIndex = 2 * pos;
for (int k = pos; k < size; k++) {
- srcIndex = 2 * k;
dstIndex = 2 * srcIndexBuf.get(k-pos);
- dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex));
- dstTextureCoords.put(dstIndex + 1, srcTextureCoords.get(srcIndex + 1));
+ dstTextureCoords.put(dstIndex++, srcTextureCoords.get(srcIndex++));
+ dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex++));
}
- if (count < 0) {
- count = -count;
- gl.glDrawElements(GL.GL_TRIANGLE_FAN, count, GL.GL_UNSIGNED_INT, srcIndexBuf);
- } else {
- gl.glDrawElements(GL.GL_TRIANGLE_STRIP, count, GL.GL_UNSIGNED_INT, srcIndexBuf);
- }
+ gl.glDrawElements(mode, count, GL.GL_UNSIGNED_INT, srcIndexBuf);
+
pos += count;
}
@@ -336,21 +322,18 @@ public abstract class Mesh extends Light {
** R_CullAliasModel
*/
// TODO sync with jogl renderer. hoz
- boolean R_CullAliasModel(entity_t e)
- {
- float[] mins = {0, 0, 0};
- float[] maxs = {0, 0, 0};
-
- qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
+ boolean R_CullAliasModel(entity_t e) {
+ float[] mins = { 0, 0, 0 };
+ float[] maxs = { 0, 0, 0 };
- if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) )
- {
- VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n');
+ qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;
+
+ if ((e.frame >= paliashdr.num_frames) || (e.frame < 0)) {
+ VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such frame " + e.frame + '\n');
e.frame = 0;
}
- if ( ( e.oldframe >= paliashdr.num_frames ) || ( e.oldframe < 0 ) )
- {
- VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n');
+ if ((e.oldframe >= paliashdr.num_frames) || (e.oldframe < 0)) {
+ VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n');
e.oldframe = 0;
}
@@ -360,106 +343,88 @@ public abstract class Mesh extends Light {
/*
** compute axially aligned mins and maxs
*/
- if ( pframe == poldframe )
- {
- for ( int i = 0; i < 3; i++ )
- {
+ if (pframe == poldframe) {
+ for (int i = 0; i < 3; i++) {
mins[i] = pframe.translate[i];
- maxs[i] = mins[i] + pframe.scale[i]*255;
+ maxs[i] = mins[i] + pframe.scale[i] * 255;
}
- }
- else
- {
- //float[] thismins = {0, 0, 0};
- //float[] oldmins = {0, 0, 0};
- float[] thismaxs = {0, 0, 0};
- float[] oldmaxs = {0, 0, 0};
- for ( int i = 0; i < 3; i++ )
- {
- //thismins[i] = pframe.translate[i];
- thismaxs[i] = pframe.translate[i] + pframe.scale[i]*255;
+ } else {
+ float thismaxs, oldmaxs;
+ for (int i = 0; i < 3; i++) {
+ thismaxs = pframe.translate[i] + pframe.scale[i] * 255;
- //oldmins[i] = poldframe.translate[i];
- oldmaxs[i] = poldframe.translate[i] + poldframe.scale[i]*255;
+ oldmaxs = poldframe.translate[i] + poldframe.scale[i] * 255;
- if ( pframe.translate[i] < poldframe.translate[i] )
+ if (pframe.translate[i] < poldframe.translate[i])
mins[i] = pframe.translate[i];
else
mins[i] = poldframe.translate[i];
- if ( thismaxs[i] > oldmaxs[i] )
- maxs[i] = thismaxs[i];
+ if (thismaxs > oldmaxs)
+ maxs[i] = thismaxs;
else
- maxs[i] = oldmaxs[i];
+ maxs[i] = oldmaxs;
}
}
/*
** compute a full bounding box
*/
- float[] tmp = {0, 0, 0};
- for ( int i = 0; i < 8; i++ )
- {
-
- if ( (i & 1) != 0 )
+ float[] tmp;
+ for (int i = 0; i < 8; i++) {
+ tmp = bbox[i];
+ if ((i & 1) != 0)
tmp[0] = mins[0];
else
tmp[0] = maxs[0];
- if ( (i & 2) != 0)
+ if ((i & 2) != 0)
tmp[1] = mins[1];
else
tmp[1] = maxs[1];
- if ( (i & 4) != 0)
+ if ((i & 4) != 0)
tmp[2] = mins[2];
else
tmp[2] = maxs[2];
-
- Math3D.VectorCopy( tmp, bbox[i] );
}
/*
** rotate the bounding box
*/
- //float[] angles = {0, 0, 0};
- Math3D.VectorCopy( e.angles, tmp );
+ tmp = mins;
+ Math3D.VectorCopy(e.angles, tmp);
tmp[YAW] = -tmp[YAW];
- Math3D.AngleVectors( tmp, vectors[0], vectors[1], vectors[2] );
+ Math3D.AngleVectors(tmp, vectors[0], vectors[1], vectors[2]);
- for ( int i = 0; i < 8; i++ )
- {
- Math3D.VectorCopy( bbox[i], tmp );
+ for (int i = 0; i < 8; i++) {
+ Math3D.VectorCopy(bbox[i], tmp);
- bbox[i][0] = Math3D.DotProduct( vectors[0], tmp );
- bbox[i][1] = -Math3D.DotProduct( vectors[1], tmp );
- bbox[i][2] = Math3D.DotProduct( vectors[2], tmp );
+ bbox[i][0] = Math3D.DotProduct(vectors[0], tmp);
+ bbox[i][1] = -Math3D.DotProduct(vectors[1], tmp);
+ bbox[i][2] = Math3D.DotProduct(vectors[2], tmp);
- Math3D.VectorAdd( e.origin, bbox[i], bbox[i] );
+ Math3D.VectorAdd(e.origin, bbox[i], bbox[i]);
}
int f, mask;
int aggregatemask = ~0; // 0xFFFFFFFF
-
- for ( int p = 0; p < 8; p++ )
- {
+
+ for (int p = 0; p < 8; p++) {
mask = 0;
- for ( f = 0; f < 4; f++ )
- {
- float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] );
+ for (f = 0; f < 4; f++) {
+ float dp = Math3D.DotProduct(frustum[f].normal, bbox[p]);
- if ( ( dp - frustum[f].dist ) < 0 )
- {
- mask |= ( 1 << f );
+ if ((dp - frustum[f].dist) < 0) {
+ mask |= (1 << f);
}
}
aggregatemask &= mask;
}
- if ( aggregatemask != 0 )
- {
+ if (aggregatemask != 0) {
return true;
}
diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java
index e928c5e..90cb7c9 100644
--- a/src/jake2/render/fastjogl/Model.java
+++ b/src/jake2/render/fastjogl/Model.java
@@ -2,7 +2,7 @@
* Model.java
* Copyright (C) 2003
*
- * $Id: Model.java,v 1.3 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Model.java,v 1.4 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1084,7 +1084,11 @@ public abstract class Model extends Surf {
for (i=0 ; i<pheader.num_skins ; i++)
{
buffer.get(nameBuf);
- skinNames[i] = new String(nameBuf).trim();
+ skinNames[i] = new String(nameBuf);
+ int n = skinNames[i].indexOf('\0');
+ if (n > -1) {
+ skinNames[i] = skinNames[i].substring(0, n);
+ }
mod.skins[i] = GL_FindImage(skinNames[i], it_skin);
}
diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java
index a37eb32..32f1a92 100644
--- a/src/jake2/render/fastjogl/Surf.java
+++ b/src/jake2/render/fastjogl/Surf.java
@@ -2,7 +2,7 @@
* Surf.java
* Copyright (C) 2003
*
- * $Id: Surf.java,v 1.3 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Surf.java,v 1.4 2004-07-19 19:39:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -973,10 +973,10 @@ public abstract class Surf extends Draw {
*/
void R_MarkLeaves()
{
- byte[] vis;
+ //byte[] vis;
//byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8];
- Arrays.fill(fatvis, (byte)0);
+ //Arrays.fill(fatvis, (byte)0);
mnode_t node;
int i, c;
@@ -1005,7 +1005,7 @@ public abstract class Surf extends Draw {
return;
}
- vis = Mod_ClusterPVS(r_viewcluster, r_worldmodel);
+ byte[] vis = Mod_ClusterPVS(r_viewcluster, r_worldmodel);
// may have to combine two clusters because of solid water boundaries
if (r_viewcluster2 != r_viewcluster)
{