From: Rene S. <sa...@us...> - 2006-10-31 14:00:31
|
Update of /cvsroot/jake2/jake2/src/jake2/render/common In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5804/src/jake2/render/common Modified Files: Surf.java Base.java Model.java Misc.java Warp.java Mesh.java Log Message: imports cleaned up, independence from individual GL implementations Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Surf.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Surf.java 31 Oct 2006 13:06:32 -0000 1.1 --- Surf.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 26,46 **** ! import java.nio.*; ! import java.util.Arrays; ! ! import org.lwjgl.opengl.GL11; ! ! import net.java.games.jogl.GL; ! import net.java.games.jogl.util.BufferUtils; ! ! import jake2.*; import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; import jake2.render.*; - import jake2.render.common.Image.pos_t; - import jake2.server.*; import jake2.util.*; public abstract class Surf extends Draw { --- 26,38 ---- ! import jake2.Defines; import jake2.client.*; ! import jake2.game.cplane_t; ! import jake2.qcommon.Com; import jake2.render.*; import jake2.util.*; + import java.nio.*; + import java.util.Arrays; public abstract class Surf extends Draw { *************** *** 463,467 **** } ! IntBuffer dummy = BufferUtils.newIntBuffer(128 * 128); /** --- 455,459 ---- } ! IntBuffer dummy = newIntBuffer(128 * 128); /** *************** *** 598,602 **** } ! GL_TexEnv(GL.GL_REPLACE); } --- 590,594 ---- } ! GL_TexEnv(ggl.GL_REPLACE); } *************** *** 652,658 **** lmtex = surf.lightmaptexturenum; ! ggl.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, ! GL.GL_UNSIGNED_BYTE, temp); } else { --- 644,650 ---- lmtex = surf.lightmaptexturenum; ! ggl.glTexSubImage2D(ggl.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, ! ggl.GL_UNSIGNED_BYTE, temp); } else { *************** *** 666,672 **** lmtex = 0; ! ggl.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, ! GL.GL_UNSIGNED_BYTE, temp); } --- 658,664 ---- lmtex = 0; ! ggl.glTexSubImage2D(ggl.GL_TEXTURE_2D, 0, surf.light_s, surf.light_t, smax, tmax, GL_LIGHTMAP_FORMAT, ! ggl.GL_UNSIGNED_BYTE, temp); } *************** *** 689,698 **** for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); ! ggl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { for (p = surf.polys; p != null; p = p.chain) { ! ggl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); } } --- 681,690 ---- for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); ! ggl.glDrawArrays(ggl.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } } else { for (p = surf.polys; p != null; p = p.chain) { ! ggl.glDrawArrays(ggl.GL_POLYGON, p.pos, p.numverts); } } *************** *** 717,721 **** for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); ! ggl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } --- 709,713 ---- for (p = surf.polys; p != null; p = p.chain) { p.beginScrolling(scroll); ! ggl.glDrawArrays(ggl.GL_POLYGON, p.pos, p.numverts); p.endScrolling(); } *************** *** 724,728 **** // ========== for (p = surf.polys; p != null; p = p.chain) { ! ggl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); } --- 716,720 ---- // ========== for (p = surf.polys; p != null; p = p.chain) { ! ggl.glDrawArrays(ggl.GL_POLYGON, p.pos, p.numverts); } Index: Mesh.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Mesh.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Mesh.java 31 Oct 2006 13:06:32 -0000 1.1 --- Mesh.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- // Created on 25.08.2006 by RST. + // $Id$ *************** *** 36,42 **** import java.nio.IntBuffer; - import net.java.games.joal.util.BufferUtils; - - public abstract class Mesh extends Light { --- 37,40 ---- *************** *** 58,68 **** // bounding box ! protected float[][] bbox = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, ! { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; /* ! * ================== R_InitParticleTexture ================== ! */ protected byte[][] dottexture = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 0, 0, 0 }, --- 56,70 ---- // bounding box ! protected float[][] bbox = { ! { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, ! { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } ! }; /* ! ================== ! R_InitParticleTexture ! ================== ! */ protected byte[][] dottexture = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 0, 0, 0 }, *************** *** 141,147 **** } ! protected FloatBuffer colorArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 4); ! protected FloatBuffer vertexArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 3); ! protected FloatBuffer textureArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 2); protected boolean isFilled = false; --- 143,149 ---- } ! protected FloatBuffer colorArrayBuf = newFloatBuffer(qfiles.MAX_VERTS * 4); ! protected FloatBuffer vertexArrayBuf = newFloatBuffer(qfiles.MAX_VERTS * 3); ! protected FloatBuffer textureArrayBuf = newFloatBuffer(qfiles.MAX_VERTS * 2); protected boolean isFilled = false; *************** *** 461,467 **** /* ! * ================= R_DrawAliasModel ! * ! * ================= */ // TODO sync with jogl renderer. hoz --- 463,470 ---- /* ! ================= ! R_DrawAliasModel ! ! ================= */ // TODO sync with jogl renderer. hoz Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Model.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Model.java 31 Oct 2006 13:06:32 -0000 1.1 --- Model.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 39,44 **** import java.util.Vector; - import net.java.games.jogl.util.BufferUtils; - /** * model loading and caching. --- 39,42 ---- *************** *** 1182,1189 **** protected static FloatBuffer globalModelTextureCoordBuf = ! BufferUtils.newFloatBuffer(MODEL_BUFFER_SIZE * 2); protected static IntBuffer globalModelVertexIndexBuf = ! BufferUtils.newIntBuffer(MODEL_BUFFER_SIZE); protected void precompileGLCmds(qfiles.dmdl_t model) { --- 1180,1187 ---- protected static FloatBuffer globalModelTextureCoordBuf = ! newFloatBuffer(MODEL_BUFFER_SIZE * 2); protected static IntBuffer globalModelVertexIndexBuf = ! newIntBuffer(MODEL_BUFFER_SIZE); protected void precompileGLCmds(qfiles.dmdl_t model) { Index: Warp.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Warp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Warp.java 31 Oct 2006 13:06:32 -0000 1.1 --- Warp.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 24,29 **** package jake2.render.common; - - import net.java.games.jogl.GL; import jake2.Defines; import jake2.Globals; --- 24,27 ---- *************** *** 665,669 **** GL_Bind(sky_images[skytexorder[i]].texnum); ! ggl.glBegin(GL.GL_QUADS); MakeSkyVec(skymins[0][i], skymins[1][i], i); MakeSkyVec(skymins[0][i], skymaxs[1][i], i); --- 663,667 ---- GL_Bind(sky_images[skytexorder[i]].texnum); ! ggl.glBegin(ggl.GL_QUADS); MakeSkyVec(skymins[0][i], skymins[1][i], i); MakeSkyVec(skymins[0][i], skymaxs[1][i], i); Index: Base.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Base.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Base.java 31 Oct 2006 13:06:32 -0000 1.1 --- Base.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 24,32 **** package jake2.render.common; public class Base { public static GenericGL ggl; ! // to be initialized! protected int GL_TEXTURE0 = -1; protected int GL_TEXTURE1 = -1; --- 24,34 ---- package jake2.render.common; + import java.nio.*; + public class Base { public static GenericGL ggl; ! // to be initialized protected int GL_TEXTURE0 = -1; protected int GL_TEXTURE1 = -1; *************** *** 34,38 **** public static final String REF_VERSION = "GL 0.01"; - // up / down public static final int PITCH = 0; --- 36,39 ---- *************** *** 95,97 **** --- 96,154 ---- public static final int GL_RENDERER_OTHER = 0x80000000; + // to unify BufferUtils. + + public static final int SIZEOF_BYTE = 1; + public static final int SIZEOF_SHORT = 2; + public static final int SIZEOF_INT = 4; + public static final int SIZEOF_FLOAT = 4; + public static final int SIZEOF_LONG = 8; + public static final int SIZEOF_DOUBLE = 8; + + // ---------------------------------------------------------------------- + // Allocation routines + // + + /** + * Allocates a new direct ByteBuffer with the specified number of elements. + * The returned buffer will have its byte order set to the host platform's + * native byte order. + */ + public static ByteBuffer newByteBuffer(int numElements) { + ByteBuffer bb = ByteBuffer.allocateDirect(numElements); + bb.order(ByteOrder.nativeOrder()); + return bb; + } + + /** Allocates a new direct DoubleBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static DoubleBuffer newDoubleBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); + return bb.asDoubleBuffer(); + } + + /** Allocates a new direct FloatBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static FloatBuffer newFloatBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); + return bb.asFloatBuffer(); + } + + /** Allocates a new direct IntBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static IntBuffer newIntBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); + return bb.asIntBuffer(); + } + + /** Allocates a new direct LongBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static LongBuffer newLongBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_LONG); + return bb.asLongBuffer(); + } + } Index: Misc.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/common/Misc.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Misc.java 31 Oct 2006 13:06:32 -0000 1.1 --- Misc.java 31 Oct 2006 14:00:23 -0000 1.2 *************** *** 25,34 **** ! import jake2.*; ! import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; --- 25,30 ---- ! import jake2.Defines; ! import jake2.client.VID; |