diff options
author | Carsten Weisse <[email protected]> | 2005-10-24 22:41:12 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-10-24 22:41:12 +0000 |
commit | 317bc9f0639f06772b53e6d7253d15690138c190 (patch) | |
tree | 02a680b66b3c3e316781e6e54e7aa5c8fef6c7f8 /src/jake2/render/fastjogl/Main.java | |
parent | 4fab90dc0c6e4083e3be2f2b9d1822f922452319 (diff) |
now uses QGL interface for OpenGL calls
Diffstat (limited to 'src/jake2/render/fastjogl/Main.java')
-rw-r--r-- | src/jake2/render/fastjogl/Main.java | 183 |
1 files changed, 91 insertions, 92 deletions
diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java index cc3ed27..c5df8c9 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.8 2005-05-07 18:23:26 cawe Exp $ + * $Id: Main.java,v 1.8.6.1 2005-10-24 22:41:12 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -33,6 +33,7 @@ import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; import jake2.render.*; +import jake2.util.*; import jake2.util.Math3D; import jake2.util.Vargs; @@ -40,7 +41,6 @@ import java.awt.Dimension; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import net.java.games.jogl.GL; import net.java.games.jogl.Version; /** @@ -112,10 +112,6 @@ public abstract class Main extends Base { ==================================================================== */ - int GL_TEXTURE0 = GL.GL_TEXTURE0; - int GL_TEXTURE1 = GL.GL_TEXTURE1; - - model_t r_worldmodel; float gldepthmin, gldepthmax; @@ -146,7 +142,7 @@ public abstract class Main extends Base { float[] vright = { 0, 0, 0 }; float[] r_origin = { 0, 0, 0 }; - float r_world_matrix[] = new float[16]; + FloatBuffer r_world_matrix = Lib.newFloatBuffer(16); float r_base_world_matrix[] = new float[16]; // @@ -288,20 +284,20 @@ public abstract class Main extends Base { alpha = e.alpha; if (alpha != 1.0F) - gl.glEnable(GL.GL_BLEND); + gl.glEnable(GL_BLEND); gl.glColor4f(1, 1, 1, alpha); GL_Bind(currentmodel.skins[e.frame].texnum); - GL_TexEnv(GL.GL_MODULATE); + GL_TexEnv(GL_MODULATE); if (alpha == 1.0) - gl.glEnable(GL.GL_ALPHA_TEST); + gl.glEnable(GL_ALPHA_TEST); else - gl.glDisable(GL.GL_ALPHA_TEST); + gl.glDisable(GL_ALPHA_TEST); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL_QUADS); gl.glTexCoord2f(0, 1); Math3D.VectorMA(e.origin, -frame.origin_y, vup, point); @@ -325,11 +321,11 @@ public abstract class Main extends Base { gl.glEnd(); - gl.glDisable(GL.GL_ALPHA_TEST); - GL_TexEnv(GL.GL_REPLACE); + gl.glDisable(GL_ALPHA_TEST); + GL_TexEnv(GL_REPLACE); if (alpha != 1.0F) - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL_BLEND); gl.glColor4f(1, 1, 1, 1); } @@ -357,14 +353,13 @@ public abstract class Main extends Base { gl.glPushMatrix(); R_RotateForEntity(currententity); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glDisable(GL_TEXTURE_2D); gl.glColor3f(shadelight[0], shadelight[1], shadelight[2]); // this replaces the TRIANGLE_FAN - glut.glutWireCube(gl, 20); + //glut.glutWireCube(gl, 20); - /* - gl.glBegin(GL.GL_TRIANGLE_FAN); + gl.glBegin(GL_TRIANGLE_FAN); gl.glVertex3f(0, 0, -16); int i; for (i=0 ; i<=4 ; i++) { @@ -372,16 +367,16 @@ public abstract class Main extends Base { } gl.glEnd(); - gl.glBegin(GL.GL_TRIANGLE_FAN); + gl.glBegin(GL_TRIANGLE_FAN); gl.glVertex3f (0, 0, 16); for (i=4 ; i>=0 ; i--) { gl.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f); } gl.glEnd(); - */ + gl.glColor3f(1, 1, 1); gl.glPopMatrix(); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glEnable(GL_TEXTURE_2D); } /* @@ -480,10 +475,10 @@ public abstract class Main extends Base { GL_Bind(r_particletexture.texnum); gl.glDepthMask(false); // no z buffering - gl.glEnable(GL.GL_BLEND); - GL_TexEnv(GL.GL_MODULATE); + gl.glEnable(GL_BLEND); + GL_TexEnv(GL_MODULATE); - gl.glBegin(GL.GL_TRIANGLES); + gl.glBegin(GL_TRIANGLES); FloatBuffer sourceVertices = particle_t.vertexArray; IntBuffer sourceColors = particle_t.colorArray; @@ -520,10 +515,10 @@ public abstract class Main extends Base { } gl.glEnd(); - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL_BLEND); gl.glColor4f(1, 1, 1, 1); gl.glDepthMask(true); // back to normal Z buffering - GL_TexEnv(GL.GL_REPLACE); + GL_TexEnv(GL_REPLACE); } /* @@ -535,25 +530,25 @@ public abstract class Main extends Base { if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) { - //gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - gl.glVertexPointer(3, GL.GL_FLOAT, 0, particle_t.vertexArray); - gl.glEnableClientState(GL.GL_COLOR_ARRAY); - gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, particle_t.colorArray); + //gl.glEnableClientState(GL_VERTEX_ARRAY); + gl.glVertexPointer(3, 0, particle_t.vertexArray); + gl.glEnableClientState(GL_COLOR_ARRAY); + gl.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer()); gl.glDepthMask(false); - gl.glEnable(GL.GL_BLEND); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glEnable(GL_BLEND); + gl.glDisable(GL_TEXTURE_2D); gl.glPointSize(gl_particle_size.value); - gl.glDrawArrays(GL.GL_POINTS, 0, r_newrefdef.num_particles); + gl.glDrawArrays(GL_POINTS, 0, r_newrefdef.num_particles); - gl.glDisableClientState(GL.GL_COLOR_ARRAY); - //gl.glDisableClientState(GL.GL_VERTEX_ARRAY); + gl.glDisableClientState(GL_COLOR_ARRAY); + //gl.glDisableClientState(GL_VERTEX_ARRAY); - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL_BLEND); gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); gl.glDepthMask(true); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glEnable(GL_TEXTURE_2D); } else { @@ -573,10 +568,10 @@ public abstract class Main extends Base { if (v_blend[3] == 0.0f) return; - gl.glDisable(GL.GL_ALPHA_TEST); - gl.glEnable(GL.GL_BLEND); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glDisable(GL_ALPHA_TEST); + gl.glEnable(GL_BLEND); + gl.glDisable(GL_DEPTH_TEST); + gl.glDisable(GL_TEXTURE_2D); gl.glLoadIdentity(); @@ -586,7 +581,7 @@ public abstract class Main extends Base { gl.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL_QUADS); gl.glVertex3f(10, 100, 100); gl.glVertex3f(10, -100, 100); @@ -594,9 +589,9 @@ public abstract class Main extends Base { gl.glVertex3f(10, 100, -100); gl.glEnd(); - gl.glDisable(GL.GL_BLEND); - gl.glEnable(GL.GL_TEXTURE_2D); - gl.glEnable(GL.GL_ALPHA_TEST); + gl.glDisable(GL_BLEND); + gl.glEnable(GL_TEXTURE_2D); + gl.glEnable(GL_ALPHA_TEST); gl.glColor4f(1, 1, 1, 1); } @@ -683,16 +678,16 @@ public abstract class Main extends Base { // clear out the portion of the screen that the NOWORLDMODEL defines if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) { - gl.glEnable(GL.GL_SCISSOR_TEST); + gl.glEnable(GL_SCISSOR_TEST); gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); gl.glScissor( r_newrefdef.x, vid.height - r_newrefdef.height - r_newrefdef.y, r_newrefdef.width, r_newrefdef.height); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl.glClearColor(1.0f, 0.0f, 0.5f, 0.5f); - gl.glDisable(GL.GL_SCISSOR_TEST); + gl.glDisable(GL_SCISSOR_TEST); } } @@ -739,13 +734,13 @@ public abstract class Main extends Base { // set up projection matrix // float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); - gl.glCullFace(GL.GL_FRONT); + gl.glCullFace(GL_FRONT); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glRotatef(-90, 1, 0, 0); // put Z going up @@ -755,19 +750,19 @@ public abstract class Main extends Base { gl.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1); gl.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]); - gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, r_world_matrix); + gl.glGetFloat(GL_MODELVIEW_MATRIX, r_world_matrix); // // set drawing parms // if (gl_cull.value != 0.0f) - gl.glEnable(GL.GL_CULL_FACE); + gl.glEnable(GL_CULL_FACE); else - gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL_CULL_FACE); - gl.glDisable(GL.GL_BLEND); - gl.glDisable(GL.GL_ALPHA_TEST); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glDisable(GL_BLEND); + gl.glDisable(GL_ALPHA_TEST); + gl.glEnable(GL_DEPTH_TEST); } /* @@ -781,30 +776,30 @@ public abstract class Main extends Base { if (gl_ztrick.value != 0.0f) { if (gl_clear.value != 0.0f) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL_COLOR_BUFFER_BIT); } trickframe++; if ((trickframe & 1) != 0) { gldepthmin = 0; gldepthmax = 0.49999f; - gl.glDepthFunc(GL.GL_LEQUAL); + gl.glDepthFunc(GL_LEQUAL); } else { gldepthmin = 1; gldepthmax = 0.5f; - gl.glDepthFunc(GL.GL_GEQUAL); + gl.glDepthFunc(GL_GEQUAL); } } else { if (gl_clear.value != 0.0f) - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); else - gl.glClear(GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL_DEPTH_BUFFER_BIT); gldepthmin = 0; gldepthmax = 1; - gl.glDepthFunc(GL.GL_LEQUAL); + gl.glDepthFunc(GL_LEQUAL); } gl.glDepthRange(gldepthmin, gldepthmax); } @@ -876,15 +871,15 @@ public abstract class Main extends Base { void R_SetGL2D() { // set 2D virtual screen size gl.glViewport(0, 0, vid.width, vid.height); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glDisable(GL.GL_CULL_FACE); - gl.glDisable(GL.GL_BLEND); - gl.glEnable(GL.GL_ALPHA_TEST); + gl.glDisable(GL_DEPTH_TEST); + gl.glDisable(GL_CULL_FACE); + gl.glDisable(GL_BLEND); + gl.glEnable(GL_ALPHA_TEST); gl.glColor4f(1, 1, 1, 1); } @@ -1079,7 +1074,11 @@ public abstract class Main extends Base { */ float[] r_turbsin = new float[256]; - protected boolean R_Init(int vid_xpos, int vid_ypos) { + protected boolean R_Init() { + return R_Init(0, 0); + } + + protected boolean R_Init(int vid_xpos, int vid_ypos) { assert(Warp.SIN.length == 256) : "warpsin table bug"; @@ -1112,13 +1111,13 @@ public abstract class Main extends Base { ** get our various GL strings */ VID.Printf(Defines.PRINT_ALL, "JOGL_VERSION: " + Version.getVersion() + '\n'); - gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR); + gl_config.vendor_string = gl.glGetString(GL_VENDOR); VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); - gl_config.renderer_string = gl.glGetString(GL.GL_RENDERER); + gl_config.renderer_string = gl.glGetString(GL_RENDERER); VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); - gl_config.version_string = gl.glGetString(GL.GL_VERSION); + gl_config.version_string = gl.glGetString(GL_VERSION); VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); - gl_config.extensions_string = gl.glGetString(GL.GL_EXTENSIONS); + gl_config.extensions_string = gl.glGetString(GL_EXTENSIONS); VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); gl_config.parseOpenGLVersion(); @@ -1273,8 +1272,8 @@ public abstract class Main extends Base { if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); qglActiveTextureARB = true; - GL_TEXTURE0 = GL.GL_TEXTURE0_ARB; - GL_TEXTURE1 = GL.GL_TEXTURE1_ARB; +// TEXTURE0 = GL_TEXTURE0_ARB; +// TEXTURE1 = GL_TEXTURE1_ARB; } else { VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); @@ -1291,7 +1290,7 @@ public abstract class Main extends Base { Draw_InitLocal(); int err = gl.glGetError(); - if (err != GL.GL_NO_ERROR) + if (err != GL_NO_ERROR) VID.Printf( Defines.PRINT_ALL, "glGetError() = 0x%x\n\t%s\n", @@ -1380,15 +1379,15 @@ public abstract class Main extends Base { ** go into 2D mode */ gl.glViewport(0, 0, vid.width, vid.height); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glDisable(GL.GL_CULL_FACE); - gl.glDisable(GL.GL_BLEND); - gl.glEnable(GL.GL_ALPHA_TEST); + gl.glDisable(GL_DEPTH_TEST); + gl.glDisable(GL_CULL_FACE); + gl.glDisable(GL_BLEND); + gl.glEnable(GL_ALPHA_TEST); gl.glColor4f(1, 1, 1, 1); /* @@ -1399,9 +1398,9 @@ public abstract class Main extends Base { if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) { if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) - gl.glDrawBuffer(GL.GL_FRONT); + gl.glDrawBuffer(GL_FRONT); else - gl.glDrawBuffer(GL.GL_BACK); + gl.glDrawBuffer(GL_BACK); } } @@ -1465,7 +1464,7 @@ public abstract class Main extends Base { GL_SetTexturePalette(r_rawpalette); gl.glClearColor(0, 0, 0, 0); - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL_COLOR_BUFFER_BIT); gl.glClearColor(1f, 0f, 0.5f, 0.5f); } @@ -1518,8 +1517,8 @@ public abstract class Main extends Base { Math3D.VectorAdd(start_points[i], direction, end_points[i]); } - gl.glDisable(GL.GL_TEXTURE_2D); - gl.glEnable(GL.GL_BLEND); + gl.glDisable(GL_TEXTURE_2D); + gl.glEnable(GL_BLEND); gl.glDepthMask(false); r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; @@ -1532,7 +1531,7 @@ public abstract class Main extends Base { gl.glColor4f(r, g, b, e.alpha); - gl.glBegin(GL.GL_TRIANGLE_STRIP); + gl.glBegin(GL_TRIANGLE_STRIP); float[] v; @@ -1548,8 +1547,8 @@ public abstract class Main extends Base { } gl.glEnd(); - gl.glEnable(GL.GL_TEXTURE_2D); - gl.glDisable(GL.GL_BLEND); + gl.glEnable(GL_TEXTURE_2D); + gl.glDisable(GL_BLEND); gl.glDepthMask(true); } |