From: Carsten W. <ca...@us...> - 2005-01-17 13:30:49
|
Update of /cvsroot/jake2/jake2/src/jake2/render/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19611/src/jake2/render/lwjgl Modified Files: Main.java Log Message: local float[] otimize; code clean up Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/lwjgl/Main.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Main.java 14 Dec 2004 12:56:58 -0000 1.2 --- Main.java 17 Jan 2005 13:30:38 -0000 1.3 *************** *** 63,67 **** public abstract class Main extends Base { - public static int[] d_8to24table = new int[256]; --- 63,66 ---- *************** *** 128,132 **** int GL_TEXTURE1 = GL13.GL_TEXTURE1; - model_t r_worldmodel; --- 127,130 ---- *************** *** 240,250 **** // ============================================================================ ! /* ! ================= ! R_CullBox ! ! Returns true if the box is completely outside the frustom ! ================= ! */ final boolean R_CullBox(float[] mins, float[] maxs) { assert(mins.length == 3 && maxs.length == 3) : "vec3_t bug"; --- 238,245 ---- // ============================================================================ ! /** ! * R_CullBox ! * Returns true if the box is completely outside the frustum ! */ final boolean R_CullBox(float[] mins, float[] maxs) { assert(mins.length == 3 && maxs.length == 3) : "vec3_t bug"; *************** *** 260,265 **** } final void R_RotateForEntity(entity_t e) { - gl.glTranslatef(e.origin[0], e.origin[1], e.origin[2]); --- 255,262 ---- } + /** + * R_RotateForEntity + */ final void R_RotateForEntity(entity_t e) { gl.glTranslatef(e.origin[0], e.origin[1], e.origin[2]); *************** *** 277,289 **** */ ! /* ! ================= ! R_DrawSpriteModel ! ! ================= ! */ void R_DrawSpriteModel(entity_t e) { float alpha = 1.0F; - float[] point = { 0, 0, 0 }; qfiles.dsprframe_t frame; --- 274,284 ---- */ ! // stack variable ! private final float[] point = { 0, 0, 0 }; ! /** ! * R_DrawSpriteModel ! */ void R_DrawSpriteModel(entity_t e) { float alpha = 1.0F; qfiles.dsprframe_t frame; *************** *** 351,363 **** // ================================================================================== ! /* ! ============= ! R_DrawNullModel ! ============= ! cwei :-) */ void R_DrawNullModel() { - float[] shadelight = { 0, 0, 0 }; - if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) { // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F; --- 346,355 ---- // ================================================================================== ! // stack variable ! private final float[] shadelight = { 0, 0, 0 }; ! /** ! * R_DrawNullModel */ void R_DrawNullModel() { if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) { // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F; *************** *** 399,414 **** } ! /* ! ============= ! R_DrawEntitiesOnList ! ============= ! */ void R_DrawEntitiesOnList() { - int i; - if (r_drawentities.value == 0.0f) return; // draw non-transparent first for (i = 0; i < r_newrefdef.num_entities; i++) { currententity = r_newrefdef.entities[i]; --- 391,403 ---- } ! /** ! * R_DrawEntitiesOnList ! */ void R_DrawEntitiesOnList() { if (r_drawentities.value == 0.0f) return; // draw non-transparent first + int i; for (i = 0; i < r_newrefdef.num_entities; i++) { currententity = r_newrefdef.entities[i]; *************** *** 478,491 **** } ! /* ! ** GL_DrawParticles ! ** ! */ void GL_DrawParticles(int num_particles) { - float[] up = { 0, 0, 0 }; - float[] right = { 0, 0, 0 }; - float scale; - int color; - float origin_x, origin_y, origin_z; --- 467,477 ---- } ! // stack variable ! private final float[] up = { 0, 0, 0 }; ! private final float[] right = { 0, 0, 0 }; ! /** ! * GL_DrawParticles ! */ void GL_DrawParticles(int num_particles) { float origin_x, origin_y, origin_z; *************** *** 502,505 **** --- 488,493 ---- FloatBuffer sourceVertices = particle_t.vertexArray; IntBuffer sourceColors = particle_t.colorArray; + float scale; + int color; for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); *************** *** 541,549 **** } ! /* ! =============== ! R_DrawParticles ! =============== ! */ void R_DrawParticles() { --- 529,535 ---- } ! /** ! * R_DrawParticles ! */ void R_DrawParticles() { *************** *** 576,584 **** } ! /* ! ============ ! R_PolyBlend ! ============ ! */ void R_PolyBlend() { if (gl_polyblend.value == 0.0f) --- 562,568 ---- } ! /** ! * R_PolyBlend ! */ void R_PolyBlend() { if (gl_polyblend.value == 0.0f) *************** *** 618,621 **** --- 602,608 ---- // ======================================================================= + /** + * SignbitsForPlane + */ int SignbitsForPlane(cplane_t out) { // for fast box on planeside test *************** *** 628,631 **** --- 615,621 ---- } + /** + * R_SetFrustum + */ void R_SetFrustum() { // rotate VPN right by FOV_X/2 degrees *************** *** 647,659 **** // ======================================================================= ! /* ! =============== ! R_SetupFrame ! =============== ! */ void R_SetupFrame() { - int i; - mleaf_t leaf; - r_framecount++; --- 637,646 ---- // ======================================================================= ! // stack variable ! private final float[] temp = {0, 0, 0}; ! /** ! * R_SetupFrame ! */ void R_SetupFrame() { r_framecount++; *************** *** 664,667 **** --- 651,655 ---- // current viewcluster + mleaf_t leaf; if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) { r_oldviewcluster = r_viewcluster; *************** *** 672,677 **** // check above and below so crossing solid water doesn't draw wrong if (leaf.contents == 0) { // look down a bit - float[] temp = { 0, 0, 0 }; - Math3D.VectorCopy(r_origin, temp); temp[2] -= 16; --- 660,663 ---- *************** *** 681,686 **** } else { // look up a bit - float[] temp = { 0, 0, 0 }; - Math3D.VectorCopy(r_origin, temp); temp[2] += 16; --- 667,670 ---- *************** *** 691,695 **** } ! for (i = 0; i < 4; i++) v_blend[i] = r_newrefdef.blend[i]; --- 675,679 ---- } ! for (int i = 0; i < 4; i++) v_blend[i] = r_newrefdef.blend[i]; *************** *** 712,723 **** } void MYgluPerspective(double fovy, double aspect, double zNear, double zFar) { ! double xmin, xmax, ymin, ymax; ! ! ymax = zNear * Math.tan(fovy * Math.PI / 360.0); ! ymin = -ymax; ! xmin = ymin * aspect; ! xmax = ymax * aspect; xmin += - (2 * gl_state.camera_separation) / zNear; --- 696,713 ---- } + /** + * MYgluPerspective + * + * @param fovy + * @param aspect + * @param zNear + * @param zFar + */ void MYgluPerspective(double fovy, double aspect, double zNear, double zFar) { ! double ymax = zNear * Math.tan(fovy * Math.PI / 360.0); ! double ymin = -ymax; ! double xmin = ymin * aspect; ! double xmax = ymax * aspect; xmin += - (2 * gl_state.camera_separation) / zNear; *************** *** 727,735 **** } ! /* ! ============= ! R_SetupGL ! ============= ! */ void R_SetupGL() { --- 717,723 ---- } ! /** ! * R_SetupGL ! */ void R_SetupGL() { *************** *** 787,797 **** } - /* - ============= - R_Clear - ============= - */ int trickframe = 0; void R_Clear() { if (gl_ztrick.value != 0.0f) { --- 775,783 ---- } int trickframe = 0; + /** + * R_Clear + */ void R_Clear() { if (gl_ztrick.value != 0.0f) { *************** *** 826,840 **** } void R_Flash() { R_PolyBlend(); } ! /* ! ================ ! R_RenderView ! ! r_newrefdef must be set before the first call ! ================ ! */ void R_RenderView(refdef_t fd) { --- 812,826 ---- } + /** + * R_Flash + */ void R_Flash() { R_PolyBlend(); } ! /** ! * R_RenderView ! * r_newrefdef must be set before the first call ! */ void R_RenderView(refdef_t fd) { *************** *** 890,893 **** --- 876,882 ---- } + /** + * R_SetGL2D + */ void R_SetGL2D() { // set 2D virtual screen size *************** *** 905,917 **** } ! /* ! ==================== ! R_SetLightLevel ! ! ==================== ! */ void R_SetLightLevel() { - float[] shadelight = { 0, 0, 0 }; - if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) return; --- 894,903 ---- } ! // stack variable ! private final float[] shadelight1 = { 0, 0, 0 }; ! /** ! * R_SetLightLevel ! */ void R_SetLightLevel() { if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) return; *************** *** 923,946 **** // pick the greatest component, which should be the same // as the mono value returned by software ! if (shadelight[0] > shadelight[1]) { ! if (shadelight[0] > shadelight[2]) ! r_lightlevel.value = 150 * shadelight[0]; else ! r_lightlevel.value = 150 * shadelight[2]; } else { ! if (shadelight[1] > shadelight[2]) ! r_lightlevel.value = 150 * shadelight[1]; else ! r_lightlevel.value = 150 * shadelight[2]; } } ! /* ! @@@@@@@@@@@@@@@@@@@@@ ! R_RenderFrame ! ! @@@@@@@@@@@@@@@@@@@@@ ! */ protected void R_RenderFrame(refdef_t fd) { R_RenderView(fd); --- 909,929 ---- // pick the greatest component, which should be the same // as the mono value returned by software ! if (shadelight1[0] > shadelight1[1]) { ! if (shadelight1[0] > shadelight1[2]) ! r_lightlevel.value = 150 * shadelight1[0]; else ! r_lightlevel.value = 150 * shadelight1[2]; } else { ! if (shadelight1[1] > shadelight1[2]) ! r_lightlevel.value = 150 * shadelight1[1]; else ! r_lightlevel.value = 150 * shadelight1[2]; } } ! /** ! * R_RenderFrame ! */ protected void R_RenderFrame(refdef_t fd) { R_RenderView(fd); *************** *** 949,952 **** --- 932,938 ---- } + /** + * R_Register + */ protected void R_Register() { r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); *************** *** 1040,1060 **** } ! /* ! ================== ! R_SetMode ! ================== ! */ protected boolean R_SetMode() { ! ! int err; // enum rserr_t ! boolean fullscreen; ! ! // if (vid_fullscreen.modified && !gl_config.allow_cds) { ! // VID.Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n"); ! // Cvar.SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f); ! // vid_fullscreen.modified = false; ! // } ! ! fullscreen = (vid_fullscreen.value > 0.0f); vid_fullscreen.modified = false; --- 1026,1034 ---- } ! /** ! * R_SetMode ! */ protected boolean R_SetMode() { ! boolean fullscreen = (vid_fullscreen.value > 0.0f); vid_fullscreen.modified = false; *************** *** 1063,1066 **** --- 1037,1041 ---- Dimension dim = new Dimension(vid.width, vid.height); + int err; // enum rserr_t if ((err = GLimp_SetMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) { gl_state.prev_mode = (int) gl_mode.value; *************** *** 1089,1099 **** } - /* - =============== - R_Init - =============== - */ float[] r_turbsin = new float[256]; protected boolean R_Init(int vid_xpos, int vid_ypos) { --- 1064,1072 ---- } float[] r_turbsin = new float[256]; + /** + * R_Init + */ protected boolean R_Init(int vid_xpos, int vid_ypos) { *************** *** 1122,1125 **** --- 1095,1101 ---- } + /** + * R_Init2 + */ protected boolean R_Init2() { VID.MenuInit(); *************** *** 1314,1322 **** } ! /* ! =============== ! R_Shutdown ! =============== ! */ protected void R_Shutdown() { Cmd.RemoveCommand("modellist"); --- 1290,1296 ---- } ! /** ! * R_Shutdown ! */ protected void R_Shutdown() { Cmd.RemoveCommand("modellist"); *************** *** 1335,1343 **** } ! /* ! @@@@@@@@@@@@@@@@@@@@@ ! R_BeginFrame ! @@@@@@@@@@@@@@@@@@@@@ ! */ protected void R_BeginFrame(float camera_separation) { --- 1309,1315 ---- } ! /** ! * R_BeginFrame ! */ protected void R_BeginFrame(float camera_separation) { *************** *** 1450,1458 **** int[] r_rawpalette = new int[256]; ! /* ! ============= ! R_SetPalette ! ============= ! */ protected void R_SetPalette(byte[] palette) { // 256 RGB values (768 bytes) --- 1422,1428 ---- int[] r_rawpalette = new int[256]; ! /** ! * R_SetPalette ! */ protected void R_SetPalette(byte[] palette) { // 256 RGB values (768 bytes) *************** *** 1488,1506 **** float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t ! /* ! ** R_DrawBeam ! */ void R_DrawBeam(entity_t e) { - - int i; - float r, g, b; - - float[] perpvec = { 0, 0, 0 }; // vec3_t - float[] direction = { 0, 0, 0 }; // vec3_t - float[] normalized_direction = { 0, 0, 0 }; // vec3_t - - float[] oldorigin = { 0, 0, 0 }; // vec3_t - float[] origin = { 0, 0, 0 }; // vec3_t - oldorigin[0] = e.oldorigin[0]; oldorigin[1] = e.oldorigin[1]; --- 1458,1471 ---- float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t ! // stack variable ! private final float[] perpvec = { 0, 0, 0 }; // vec3_t ! private final float[] direction = { 0, 0, 0 }; // vec3_t ! private final float[] normalized_direction = { 0, 0, 0 }; // vec3_t ! private final float[] oldorigin = { 0, 0, 0 }; // vec3_t ! private final float[] origin = { 0, 0, 0 }; // vec3_t ! /** ! * R_DrawBeam ! */ void R_DrawBeam(entity_t e) { oldorigin[0] = e.oldorigin[0]; oldorigin[1] = e.oldorigin[1]; *************** *** 1521,1525 **** Math3D.VectorScale(perpvec, e.frame / 2, perpvec); ! for (i = 0; i < 6; i++) { Math3D.RotatePointAroundVector( start_points[i], --- 1486,1490 ---- Math3D.VectorScale(perpvec, e.frame / 2, perpvec); ! for (int i = 0; i < 6; i++) { Math3D.RotatePointAroundVector( start_points[i], *************** *** 1536,1542 **** gl.glDepthMask(false); ! r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; ! g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; ! b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; r *= 1 / 255.0f; --- 1501,1507 ---- gl.glDepthMask(false); ! float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; ! float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; ! float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; r *= 1 / 255.0f; *************** *** 1550,1554 **** float[] v; ! for (i = 0; i < NUM_BEAM_SEGS; i++) { v = start_points[i]; gl.glVertex3f(v[0], v[1], v[2]); --- 1515,1519 ---- float[] v; ! for (int i = 0; i < NUM_BEAM_SEGS; i++) { v = start_points[i]; gl.glVertex3f(v[0], v[1], v[2]); *************** *** 1566,1569 **** gl.glDepthMask(true); } ! ! } --- 1531,1533 ---- gl.glDepthMask(true); } ! } \ No newline at end of file |