aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-08 10:44:05 +0200
committerSven Gothel <[email protected]>2012-10-08 10:44:05 +0200
commitf5612e7dfc635359f15b402c2ee9022a5e703a9d (patch)
tree0b54287f72b87a2693f38ed308195e928311a093
parent3119458b32c8620f971ba44488389ddf03b2d705 (diff)
Simple NEWT port: Remove AWT dependencies in Jake2 / JOGL / Fast (default mode) - Prepare for ES2NEWT
- Removed AWT init dialog, replaced w/ UI less auto install if n/a @ default location: $HOME/Jake2/baseq2 - JOGL GL2 Renderer 'joglgl2' - JOGL ES2 Renderer 'jogles2' (TBD) - Replaced JOGLKBD (AWT) w/ NEWTKBD - JOGL* Renderer using NEWT
-rw-r--r--.settings/org.eclipse.jdt.core.prefs9
-rw-r--r--Jake2.sh5
-rw-r--r--src/jake2/Jake2.java14
-rwxr-xr-xsrc/jake2/Jake2Applet.java9
-rw-r--r--src/jake2/client/Menu.java19
-rw-r--r--src/jake2/client/SCR.java21
-rw-r--r--src/jake2/client/VID.java23
-rw-r--r--src/jake2/client/refexport_t.java7
-rw-r--r--src/jake2/qcommon/Q2DataDialog.java3
-rw-r--r--src/jake2/qcommon/Q2DataTool.java191
-rw-r--r--src/jake2/qcommon/Qcommon.java39
-rw-r--r--src/jake2/render/DummyRenderer.java9
-rw-r--r--src/jake2/render/JoglES2Renderer.java (renamed from src/jake2/render/JoglRenderer.java)20
-rw-r--r--src/jake2/render/JoglGL2Renderer.java253
-rw-r--r--src/jake2/render/RenderAPI.java4
-rw-r--r--src/jake2/render/Renderer.java14
-rw-r--r--src/jake2/render/basic/Draw.java7
-rw-r--r--src/jake2/render/basic/Image.java27
-rw-r--r--src/jake2/render/basic/Main.java3
-rw-r--r--src/jake2/render/fast/Draw.java7
-rw-r--r--src/jake2/render/fast/Image.java17
-rw-r--r--src/jake2/render/fast/Main.java3
-rw-r--r--src/jake2/render/opengl/GLDriver.java6
-rw-r--r--src/jake2/render/opengl/JoglDriver.java450
-rw-r--r--src/jake2/render/opengl/JoglES2.java (renamed from src/jake2/render/opengl/JoglGL.java)4
-rw-r--r--src/jake2/render/opengl/JoglES2Driver.java135
-rw-r--r--src/jake2/render/opengl/JoglGL2.java317
-rw-r--r--src/jake2/render/opengl/JoglGL2Driver.java135
-rw-r--r--src/jake2/render/opengl/NEWTWin.java218
-rw-r--r--src/jake2/sys/InputListener.java71
-rw-r--r--src/jake2/sys/Jake2InputEvent.java6
-rw-r--r--src/jake2/sys/KBD.java3
-rw-r--r--src/jake2/sys/NEWTKBD.java (renamed from src/jake2/sys/JOGLKBD.java)117
-rw-r--r--test/jake2/render/TestMap.java2
-rw-r--r--test/jake2/render/TestRenderer.java7
-rw-r--r--webstart/jake2_jogl.jnlp4
-rw-r--r--webstart/jake2_online.jnlp4
37 files changed, 1507 insertions, 676 deletions
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index e6e1b9c..c66812a 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,3 @@
-#Sun Mar 02 16:46:58 CET 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -8,16 +7,18 @@ org.eclipse.jdt.core.codeComplete.localPrefixes=
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
diff --git a/Jake2.sh b/Jake2.sh
index be7058a..7ed059d 100644
--- a/Jake2.sh
+++ b/Jake2.sh
@@ -5,4 +5,7 @@ cd `dirname $0`
# for jogl and joal
CP=lib/jogamp/gluegen-rt.jar:lib/jogamp/joal.jar:lib/jogamp/jogl-all.jar:dist/lib/jake2.jar
-exec java -Xmx100M -cp $CP jake2.Jake2 $*
+#D_ARGS="-Dnewt.debug.Window.MouseEvent"
+#D_ARGS="-Dnewt.debug.Window.KeyEvent"
+
+exec java -Xmx100M -cp $CP $D_ARGS jake2.Jake2 $*
diff --git a/src/jake2/Jake2.java b/src/jake2/Jake2.java
index 454e5df..2d1385a 100644
--- a/src/jake2/Jake2.java
+++ b/src/jake2/Jake2.java
@@ -28,15 +28,16 @@ package jake2;
import jake2.qcommon.*;
import jake2.sys.Timer;
-import java.util.Locale;
+// import java.util.Locale;
/**
* Jake2 is the main class of Quake2 for Java.
*/
public final class Jake2 {
- public static Q2DataDialog Q2Dialog;
-
+ // public static Q2DataDialog Q2Dialog;
+ public static Q2DataTool q2DataTool;
+
/**
* main is used to start the game. Quake2 for Java supports the following
* command line arguments:
@@ -80,9 +81,10 @@ public final class Jake2 {
// open the q2dialog, if we are not in dedicated mode.
if (Globals.dedicated.value != 1.0f)
{
- Q2Dialog = new Q2DataDialog();
- Locale.setDefault(Locale.US);
- Q2Dialog.setVisible(true);
+ q2DataTool = new Q2DataTool();
+ // Q2Dialog = new Q2DataDialog();
+ // Locale.setDefault(Locale.US);
+ // Q2Dialog.setVisible(true);
}
// in C the first arg is the filename
diff --git a/src/jake2/Jake2Applet.java b/src/jake2/Jake2Applet.java
index 3b7e7c0..7f1d558 100755
--- a/src/jake2/Jake2Applet.java
+++ b/src/jake2/Jake2Applet.java
@@ -31,7 +31,6 @@ import jake2.sys.Timer;
import java.awt.BorderLayout;
import java.awt.Color;
-import java.util.Locale;
import javax.swing.JApplet;
import netscape.javascript.*;
@@ -39,6 +38,7 @@ import netscape.javascript.*;
/**
* Jake2 is the main class of Quake2 for Java.
*/
+@SuppressWarnings("serial")
public class Jake2Applet extends JApplet {
private JSObject self;
@@ -102,9 +102,10 @@ public class Jake2Applet extends JApplet {
// open the q2dialog, if we are not in dedicated mode.
if (Globals.dedicated.value != 1.0f) {
- Jake2.Q2Dialog = new Q2DataDialog();
- Locale.setDefault(Locale.US);
- Jake2.Q2Dialog.setVisible(true);
+ // Jake2.Q2Dialog = new Q2DataDialog();
+ // Locale.setDefault(Locale.US);
+ // Jake2.Q2Dialog.setVisible(true);
+ Jake2.q2DataTool = new Q2DataTool();
}
Qcommon.Init(new String[] { "Jake2" });
diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java
index 7cc6f9c..5b4c589 100644
--- a/src/jake2/client/Menu.java
+++ b/src/jake2/client/Menu.java
@@ -31,15 +31,14 @@ import jake2.game.cvar_t;
import jake2.qcommon.*;
import jake2.sound.S;
import jake2.sys.*;
-import jake2.sys.NET;
-import jake2.sys.Sys;
import jake2.util.*;
-import java.awt.Dimension;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Comparator;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Menu
*
@@ -177,7 +176,7 @@ public final class Menu extends Key {
Dimension dim = new Dimension();
Globals.re.DrawGetPicSize(dim, name);
- Globals.re.DrawPic(viddef.getWidth() / 2 - dim.width / 2,
+ Globals.re.DrawPic(viddef.getWidth() / 2 - dim.getWidth() / 2,
viddef.getHeight() / 2 - 110, name);
}
@@ -446,8 +445,8 @@ public final class Menu extends Key {
for (i = 0; i < names.length; i++) {
Globals.re.DrawGetPicSize(dim, names[i]);
- w = dim.width;
- h = dim.height;
+ w = dim.getWidth();
+ h = dim.getHeight();
if (w > widest)
widest = w;
@@ -470,8 +469,8 @@ public final class Menu extends Key {
(int) ((Globals.cls.realtime / 100)) % NUM_CURSOR_FRAMES);
Globals.re.DrawGetPicSize(dim, "m_main_plaque");
- w = dim.width;
- h = dim.height;
+ w = dim.getWidth();
+ h = dim.getHeight();
Globals.re.DrawPic(xoffset - 30 - w, ystart, "m_main_plaque");
Globals.re.DrawPic(xoffset - 30 - w, ystart + h + 5, "m_main_logo");
@@ -4232,8 +4231,8 @@ public final class Menu extends Key {
int w, h;
Dimension d = new Dimension();
re.DrawGetPicSize(d, "quit");
- w = d.width;
- h = d.height;
+ w = d.getWidth();
+ h = d.getHeight();
re.DrawPic((viddef.getWidth() - w) / 2, (viddef.getHeight() - h) / 2, "quit");
}
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index fb4121c..50cd74c 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -33,11 +33,12 @@ import jake2.sound.S;
import jake2.sys.Timer;
import jake2.util.Vargs;
-import java.awt.Dimension;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
+import javax.media.nativewindow.util.Dimension;
+
/**
* SCR
*/
@@ -489,7 +490,7 @@ public final class SCR extends Globals {
return;
re.DrawGetPicSize(dim, "pause");
- re.DrawPic((viddef.getWidth() - dim.width) / 2, viddef.getHeight() / 2 + 8,
+ re.DrawPic((viddef.getWidth() - dim.getWidth()) / 2, viddef.getHeight() / 2 + 8,
"pause");
}
@@ -504,8 +505,8 @@ public final class SCR extends Globals {
scr_draw_loading = 0;
re.DrawGetPicSize(dim, "loading");
- re.DrawPic((viddef.getWidth() - dim.width) / 2,
- (viddef.getHeight() - dim.height) / 2, "loading");
+ re.DrawPic((viddef.getWidth() - dim.getWidth()) / 2,
+ (viddef.getHeight() - dim.getHeight()) / 2, "loading");
}
// =============================================================================
@@ -769,8 +770,8 @@ public final class SCR extends Globals {
}
- dim.width = width * 8;
- dim.height = lines * 8;
+ dim.setWidth(width * 8);
+ dim.setHeight(lines * 8);
}
static void DrawHUDString(String string, int x, int y, int centerwidth,
@@ -864,8 +865,8 @@ public final class SCR extends Globals {
crosshair_pic = "ch" + (int) crosshair.value;
Dimension dim = new Dimension();
re.DrawGetPicSize(dim, crosshair_pic);
- crosshair_width = dim.width;
- crosshair_height = dim.height;
+ crosshair_width = dim.getWidth();
+ crosshair_height = dim.getHeight();
if (crosshair_width == 0)
crosshair_pic = "";
}
@@ -1214,8 +1215,8 @@ public final class SCR extends Globals {
re.CinematicSetPalette(null);
scr_draw_loading = 0; // false
re.DrawGetPicSize(dim, "loading");
- re.DrawPic((viddef.getWidth() - dim.width) / 2,
- (viddef.getHeight() - dim.height) / 2, "loading");
+ re.DrawPic((viddef.getWidth() - dim.getWidth()) / 2,
+ (viddef.getHeight() - dim.getHeight()) / 2, "loading");
}
// if a cinematic is supposed to be running, handle menus
// and console specially
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 6af2220..f27d4f3 100644
--- a/src/jake2/client/VID.java
+++ b/src/jake2/client/VID.java
@@ -35,8 +35,12 @@ import jake2.sound.S;
import jake2.sys.IN;
import jake2.util.Vargs;
-import java.awt.Dimension;
-import java.awt.DisplayMode;
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.SurfaceSize;
+
+import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.util.MonitorMode;
/**
* VID is a video driver.
@@ -137,8 +141,8 @@ public class VID extends Globals {
if (mode < 0 || mode >= modes.length)
return false;
- dim.width = modes[mode].width;
- dim.height = modes[mode].height;
+ dim.setWidth( modes[mode].width );
+ dim.setHeight( modes[mode].height );
return true;
}
@@ -482,12 +486,15 @@ public class VID extends Globals {
};
static void initModeList() {
- DisplayMode[] modes = re.getModeList();
+ ScreenMode[] modes = re.getModeList();
fs_resolutions = new String[modes.length];
fs_modes = new vidmode_t[modes.length];
for (int i = 0; i < modes.length; i++) {
- DisplayMode m = modes[i];
- StringBuffer sb = new StringBuffer(18);
+ final ScreenMode sm = modes[i];
+ final MonitorMode mm = sm.getMonitorMode();
+ final SurfaceSize ss = mm.getSurfaceSize();
+ final DimensionImmutable m = ss.getResolution();
+ final StringBuffer sb = new StringBuffer();
sb.append('[');
sb.append(m.getWidth());
sb.append(' ');
@@ -704,7 +711,7 @@ public class VID extends Globals {
*/
Dimension dim = new Dimension();
re.DrawGetPicSize( dim, "m_banner_video" );
- re.DrawPic( viddef.getWidth() / 2 - dim.width / 2, viddef.getHeight() /2 - 110, "m_banner_video" );
+ re.DrawPic( viddef.getWidth() / 2 - dim.getWidth() / 2, viddef.getHeight() /2 - 110, "m_banner_video" );
/*
** move cursor to a reasonable starting position
diff --git a/src/jake2/client/refexport_t.java b/src/jake2/client/refexport_t.java
index a5c3b25..3cde83e 100644
--- a/src/jake2/client/refexport_t.java
+++ b/src/jake2/client/refexport_t.java
@@ -31,8 +31,9 @@ import jake2.render.image_t;
import jake2.render.model_t;
import jake2.sys.KBD;
-import java.awt.Dimension;
-import java.awt.DisplayMode;
+import javax.media.nativewindow.util.Dimension;
+
+import com.jogamp.newt.ScreenMode;
/**
* refexport_t
@@ -107,7 +108,7 @@ public interface refexport_t {
int apiVersion();
- DisplayMode[] getModeList();
+ ScreenMode[] getModeList();
KBD getKeyboardHandler();
}
diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java
index ffb5842..9e3b318 100644
--- a/src/jake2/qcommon/Q2DataDialog.java
+++ b/src/jake2/qcommon/Q2DataDialog.java
@@ -309,9 +309,6 @@ public class Q2DataDialog extends javax.swing.JDialog {
}
- /* (non-Javadoc)
- * @see java.awt.Component#paint(java.awt.Graphics)
- */
public void paint(Graphics g) {
g.drawImage(image, 0, 0, null);
}
diff --git a/src/jake2/qcommon/Q2DataTool.java b/src/jake2/qcommon/Q2DataTool.java
new file mode 100644
index 0000000..b12acfc
--- /dev/null
+++ b/src/jake2/qcommon/Q2DataTool.java
@@ -0,0 +1,191 @@
+/*
+ * Q2DataDialog.java
+ * Copyright (C) 2003
+ */
+package jake2.qcommon;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+public class Q2DataTool {
+ static final String home = System.getProperty("user.home");
+ static final String sep = System.getProperty("file.separator");
+ static final String dataDir = home + sep + "Jake2";
+ static final String baseq2Dir = dataDir + sep + "baseq2";
+
+ private Vector<String> mirrorNames = new Vector<String>();
+ private Vector<String> mirrorLinks = new Vector<String>();
+ private byte[] buf = new byte[8192];
+
+ public void testQ2Data() {
+ initMirrors();
+ for(int i=0; !isAvail() && i<mirrorNames.size(); i++) {
+ try {
+ install(i);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ void destroy() {
+
+ }
+
+ void setStatus(String text) {
+ System.err.println(text);
+ System.err.println();
+ }
+
+ boolean isAvail() {
+ Cvar.Set("cddir", baseq2Dir);
+ FS.setCDDir();
+ return null != FS.LoadFile("pics/colormap.pcx");
+ }
+
+ void initMirrors() {
+ InputStream in = getClass().getResourceAsStream("/mirrors");
+ BufferedReader r = new BufferedReader(new InputStreamReader(in));
+ try {
+ while (true) {
+ String name = r.readLine();
+ String value = r.readLine();
+ if (name == null || value == null) break;
+ mirrorNames.add(name);
+ mirrorLinks.add(value);
+ }
+ } catch (Exception e) {}
+ finally {
+ try {
+ r.close();
+ } catch (Exception e1) {}
+ try {
+ in.close();
+ } catch (Exception e1) {}
+ }
+ }
+
+ void install(int mirrorIdx) {
+ final String mirrorName = mirrorNames.get(mirrorIdx);
+ final String mirror = mirrorLinks.get(mirrorIdx);
+ InputStream in = null;
+ OutputStream out = null;
+ File outFile = null;
+
+ setStatus("downloading from "+mirrorName+": <"+mirror+">");
+
+ File dir = null;
+ try {
+ dir = new File(dataDir);
+ dir.mkdirs();
+ }
+ catch (Exception e) {}
+ try {
+ if (!dir.isDirectory() || !dir.canWrite()) {
+ setStatus("can't write to " + dataDir);
+ return;
+ }
+ }
+ catch (Exception e) {
+ setStatus(e.getMessage());
+ return;
+ }
+
+ try {
+ URL url = new URL(mirror);
+ URLConnection conn = url.openConnection();
+ // int length = conn.getContentLength();
+
+ in = conn.getInputStream();
+
+ outFile = File.createTempFile("Jake2Data", ".zip");
+ outFile.deleteOnExit();
+ out = new FileOutputStream(outFile);
+
+ copyStream(in, out);
+ } catch (Exception e) {
+ setStatus(e.getMessage());
+ return;
+ } finally {
+ try {
+ in.close();
+ } catch (Exception e) {}
+ try {
+ out.close();
+ } catch (Exception e) {}
+ }
+
+ try {
+ installData(outFile.getCanonicalPath());
+ } catch (Exception e) {
+ setStatus(e.getMessage());
+ return;
+ }
+
+
+ try {
+ if (outFile != null) outFile.delete();
+ } catch (Exception e) {}
+
+ setStatus("installation successful from "+mirrorName+": <"+mirror+">");
+ }
+
+
+ void installData(String filename) throws Exception {
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ ZipFile f = new ZipFile(filename);
+ Enumeration<? extends ZipEntry> e = f.entries();
+ while (e.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry)e.nextElement();
+ String name = entry.getName();
+ int i;
+ if ((i = name.indexOf("/baseq2")) > -1 && name.indexOf(".dll") == -1) {
+ name = dataDir + name.substring(i);
+ File outFile = new File(name);
+ if (entry.isDirectory()) {
+ outFile.mkdirs();
+ } else {
+ setStatus("installing " + outFile.getName());
+ outFile.getParentFile().mkdirs();
+ out = new FileOutputStream(outFile);
+ in = f.getInputStream(entry);
+ copyStream(in, out);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ try {in.close();} catch (Exception e1) {}
+ try {out.close();} catch (Exception e1) {}
+ }
+ }
+
+ void copyStream(InputStream in, OutputStream out) throws Exception {
+ try {
+ // int c = 0;
+ int l;
+ while ((l = in.read(buf)) > 0) {
+ out.write(buf, 0, l);
+ // c += l;
+ }
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ try {
+ in.close();
+ } catch (Exception e) {}
+ try {
+ out.close();
+ } catch (Exception e) {}
+ }
+ }
+
+}
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index bd4ca88..79f6f29 100644
--- a/src/jake2/qcommon/Qcommon.java
+++ b/src/jake2/qcommon/Qcommon.java
@@ -74,21 +74,24 @@ public final class Qcommon extends Globals {
Cbuf.AddEarlyCommands(false);
Cbuf.Execute();
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.setStatus("initializing filesystem...");
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.setStatus("initializing filesystem...");
+ }
FS.InitFilesystem();
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.setStatus("loading config...");
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.setStatus("loading config...");
+ }
reconfigure(false);
FS.setCDDir(); // use cddir from config.cfg
FS.markBaseSearchPaths(); // mark the default search paths
-
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2
+
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.testQ2Data(); // test for valid baseq2
+ }
reconfigure(true); // reload default.cfg and config.cfg
@@ -114,18 +117,21 @@ public final class Qcommon extends Globals {
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.setStatus("initializing network subsystem...");
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.setStatus("initializing network subsystem...");
+ }
NET.Init(); //ok
Netchan.Netchan_Init(); //ok
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.setStatus("initializing server subsystem...");
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.setStatus("initializing server subsystem...");
+ }
SV_MAIN.SV_Init(); //ok
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.setStatus("initializing client subsystem...");
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.setStatus("initializing client subsystem...");
+ }
CL.Init();
@@ -148,9 +154,10 @@ public final class Qcommon extends Globals {
// save config when configuration is completed
CL.WriteConfiguration();
-
- if (Globals.dedicated.value != 1.0f)
- Jake2.Q2Dialog.dispose();
+
+ if (Globals.dedicated.value != 1.0f) {
+ Jake2.q2DataTool.destroy();
+ }
} catch (longjmpException e) {
Sys.Error("Error during initialization");
diff --git a/src/jake2/render/DummyRenderer.java b/src/jake2/render/DummyRenderer.java
index 8e07c18..73d05a6 100644
--- a/src/jake2/render/DummyRenderer.java
+++ b/src/jake2/render/DummyRenderer.java
@@ -7,8 +7,9 @@
package jake2.render;
-import java.awt.Dimension;
-import java.awt.DisplayMode;
+import javax.media.nativewindow.util.Dimension;
+
+import com.jogamp.newt.ScreenMode;
import jake2.client.refdef_t;
import jake2.client.refexport_t;
@@ -81,7 +82,7 @@ public class DummyRenderer implements refexport_t {
}
/* (non-Javadoc)
- * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String)
+ * @see jake2.client.refexport_t#DrawGetPicSize(Dimension, java.lang.String)
*/
public void DrawGetPicSize(Dimension dim, String name) {
}
@@ -169,7 +170,7 @@ public class DummyRenderer implements refexport_t {
/* (non-Javadoc)
* @see jake2.client.refexport_t#getModeList()
*/
- public DisplayMode[] getModeList() {
+ public ScreenMode[] getModeList() {
return null;
}
diff --git a/src/jake2/render/JoglRenderer.java b/src/jake2/render/JoglES2Renderer.java
index 19e1888..109df9e 100644
--- a/src/jake2/render/JoglRenderer.java
+++ b/src/jake2/render/JoglES2Renderer.java
@@ -24,34 +24,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render;
+import javax.media.nativewindow.util.Dimension;
+
import jake2.Defines;
import jake2.client.refdef_t;
import jake2.client.refexport_t;
-import jake2.render.opengl.JoglDriver;
-import jake2.sys.JOGLKBD;
+import jake2.render.opengl.JoglES2Driver;
+import jake2.sys.NEWTKBD;
import jake2.sys.KBD;
-import java.awt.Dimension;
-
/**
* JoglRenderer
*
* @author dsanders/cwei
*/
-final class JoglRenderer extends JoglDriver implements refexport_t, Ref {
+final class JoglES2Renderer extends JoglES2Driver implements refexport_t, Ref {
- public static final String DRIVER_NAME = "jogl2";
+ public static final String DRIVER_NAME = "jogles2";
- private KBD kbd = new JOGLKBD();
+ private KBD kbd = new NEWTKBD();
// is set from Renderer factory
private RenderAPI impl;
static {
- Renderer.register(new JoglRenderer());
+ Renderer.register(new JoglES2Renderer());
};
- private JoglRenderer() {
+ private JoglES2Renderer() {
// singleton
}
@@ -137,7 +137,7 @@ final class JoglRenderer extends JoglDriver implements refexport_t, Ref {
}
/**
- * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String)
+ * @see jake2.client.refexport_t#DrawGetPicSize(Dimension, java.lang.String)
*/
public final void DrawGetPicSize(Dimension dim, String name) {
impl.Draw_GetPicSize(dim, name);
diff --git a/src/jake2/render/JoglGL2Renderer.java b/src/jake2/render/JoglGL2Renderer.java
new file mode 100644
index 0000000..bcfa43c
--- /dev/null
+++ b/src/jake2/render/JoglGL2Renderer.java
@@ -0,0 +1,253 @@
+/*
+ * JoglRenderer.java
+ * Copyright (C) 2004
+ *
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+package jake2.render;
+
+import javax.media.nativewindow.util.Dimension;
+
+import jake2.Defines;
+import jake2.client.refdef_t;
+import jake2.client.refexport_t;
+import jake2.render.opengl.JoglGL2Driver;
+import jake2.sys.NEWTKBD;
+import jake2.sys.KBD;
+
+/**
+ * JoglRenderer
+ *
+ * @author dsanders/cwei
+ */
+final class JoglGL2Renderer extends JoglGL2Driver implements refexport_t, Ref {
+
+ public static final String DRIVER_NAME = "joglgl2";
+
+ private KBD kbd = new NEWTKBD();
+
+ // is set from Renderer factory
+ private RenderAPI impl;
+
+ static {
+ Renderer.register(new JoglGL2Renderer());
+ };
+
+ private JoglGL2Renderer() {
+ // singleton
+ }
+
+ // ============================================================================
+ // public interface for Renderer implementations
+ //
+ // refexport_t (ref.h)
+ // ============================================================================
+
+ /**
+ * @see jake2.client.refexport_t#Init()
+ */
+ public boolean Init(int vid_xpos, int vid_ypos) {
+ // init the OpenGL drivers
+ impl.setGLDriver(this);
+ // pre init
+ if (!impl.R_Init(vid_xpos, vid_ypos)) return false;
+ // activates the OpenGL context
+ activate();
+ // post init
+ return impl.R_Init2();
+ }
+
+ /**
+ * @see jake2.client.refexport_t#Shutdown()
+ */
+ public void Shutdown() {
+ impl.R_Shutdown();
+ }
+
+ /**
+ * @see jake2.client.refexport_t#BeginRegistration(java.lang.String)
+ */
+ public final void BeginRegistration(String map) {
+ activate();
+ impl.R_BeginRegistration(map);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#RegisterModel(java.lang.String)
+ */
+ public final model_t RegisterModel(String name) {
+ activate();
+ return impl.R_RegisterModel(name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#RegisterSkin(java.lang.String)
+ */
+ public final image_t RegisterSkin(String name) {
+ activate();
+ return impl.R_RegisterSkin(name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#RegisterPic(java.lang.String)
+ */
+ public final image_t RegisterPic(String name) {
+ activate();
+ return impl.Draw_FindPic(name);
+ }
+ /**
+ * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[])
+ */
+ public final void SetSky(String name, float rotate, float[] axis) {
+ activate();
+ impl.R_SetSky(name, rotate, axis);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#EndRegistration()
+ */
+ public final void EndRegistration() {
+ activate();
+ impl.R_EndRegistration();
+ }
+
+ /**
+ * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t)
+ */
+ public final void RenderFrame(refdef_t fd) {
+ impl.R_RenderFrame(fd);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawGetPicSize(Dimension, java.lang.String)
+ */
+ public final void DrawGetPicSize(Dimension dim, String name) {
+ impl.Draw_GetPicSize(dim, name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String)
+ */
+ public final void DrawPic(int x, int y, String name) {
+ impl.Draw_Pic(x, y, name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String)
+ */
+ public final void DrawStretchPic(int x, int y, int w, int h, String name) {
+ impl.Draw_StretchPic(x, y, w, h, name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawChar(int, int, int)
+ */
+ public final void DrawChar(int x, int y, int num) {
+ activate();
+ impl.Draw_Char(x, y, num);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String)
+ */
+ public final void DrawTileClear(int x, int y, int w, int h, String name) {
+ impl.Draw_TileClear(x, y, w, h, name);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int)
+ */
+ public final void DrawFill(int x, int y, int w, int h, int c) {
+ impl.Draw_Fill(x, y, w, h, c);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawFadeScreen()
+ */
+ public final void DrawFadeScreen() {
+ impl.Draw_FadeScreen();
+ }
+
+ /**
+ * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[])
+ */
+ public final void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) {
+ impl.Draw_StretchRaw(x, y, w, h, cols, rows, data);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#CinematicSetPalette(byte[])
+ */
+ public final void CinematicSetPalette(byte[] palette) {
+ impl.R_SetPalette(palette);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#BeginFrame(float)
+ */
+ public final void BeginFrame(float camera_separation) {
+ impl.R_BeginFrame(camera_separation);
+ }
+
+ /**
+ * @see jake2.client.refexport_t#EndFrame()
+ */
+ public final void EndFrame() {
+ endFrame();
+ }
+
+ /**
+ * @see jake2.client.refexport_t#AppActivate(boolean)
+ */
+ public final void AppActivate(boolean activate) {
+ appActivate(activate);
+ }
+
+ public void screenshot() {
+ activate();
+ impl.GL_ScreenShot_f();
+ }
+
+ public final int apiVersion() {
+ return Defines.API_VERSION;
+ }
+
+ public KBD getKeyboardHandler() {
+ return kbd;
+ }
+ // ============================================================================
+ // Ref interface
+ // ============================================================================
+
+ public final String getName() {
+ return DRIVER_NAME;
+ }
+
+ public final String toString() {
+ return DRIVER_NAME;
+ }
+
+ public final refexport_t GetRefAPI(RenderAPI renderer) {
+ this.impl = renderer;
+ return this;
+ }
+
+}
diff --git a/src/jake2/render/RenderAPI.java b/src/jake2/render/RenderAPI.java
index ab4ea9d..0c5f9f1 100644
--- a/src/jake2/render/RenderAPI.java
+++ b/src/jake2/render/RenderAPI.java
@@ -1,10 +1,10 @@
package jake2.render;
+import javax.media.nativewindow.util.Dimension;
+
import jake2.client.refdef_t;
import jake2.render.opengl.GLDriver;
-import java.awt.Dimension;
-
public interface RenderAPI {
void setGLDriver(GLDriver impl);
diff --git a/src/jake2/render/Renderer.java b/src/jake2/render/Renderer.java
index a283640..bb4b250 100644
--- a/src/jake2/render/Renderer.java
+++ b/src/jake2/render/Renderer.java
@@ -39,7 +39,7 @@ public class Renderer {
static RenderAPI fastRenderer = new jake2.render.fast.Misc();
static RenderAPI basicRenderer = new jake2.render.basic.Misc();
- static Vector drivers = new Vector(2);
+ static Vector drivers = new Vector(3);
static {
try {
@@ -50,8 +50,15 @@ public class Renderer {
// ignore the lwjgl driver if runtime not in classpath
}
try {
- Class.forName("javax.media.opengl.GL");
- Class.forName("jake2.render.JoglRenderer");
+ Class.forName("javax.media.opengl.GL2ES2");
+ Class.forName("jake2.render.JoglES2Renderer");
+ } catch (ClassNotFoundException e) {
+ // ignore the new jogl driver if runtime not in classpath
+ e.printStackTrace();
+ }
+ try {
+ Class.forName("javax.media.opengl.GL2");
+ Class.forName("jake2.render.JoglGL2Renderer");
} catch (ClassNotFoundException e) {
// ignore the new jogl driver if runtime not in classpath
e.printStackTrace();
@@ -68,7 +75,6 @@ public class Renderer {
}
if (!drivers.contains(impl)) {
System.err.println("Add driver: "+impl+", "+impl.getName());
- Thread.dumpStack();
drivers.add(impl);
}
}
diff --git a/src/jake2/render/basic/Draw.java b/src/jake2/render/basic/Draw.java
index 52ee9fc..156431a 100644
--- a/src/jake2/render/basic/Draw.java
+++ b/src/jake2/render/basic/Draw.java
@@ -31,10 +31,11 @@ import jake2.qcommon.Com;
import jake2.render.image_t;
import jake2.util.Lib;
-import java.awt.Dimension;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Draw
* (gl_draw.c)
@@ -123,8 +124,8 @@ public abstract class Draw extends Image {
public void Draw_GetPicSize(Dimension dim, String pic) {
image_t image = Draw_FindPic(pic);
- dim.width = (image != null) ? image.width : -1;
- dim.height = (image != null) ? image.height : -1;
+ dim.setWidth((image != null) ? image.width : -1);
+ dim.setHeight((image != null) ? image.height : -1);
}
/*
diff --git a/src/jake2/render/basic/Image.java b/src/jake2/render/basic/Image.java
index 6ec5482..a830e26 100644
--- a/src/jake2/render/basic/Image.java
+++ b/src/jake2/render/basic/Image.java
@@ -32,15 +32,17 @@ import jake2.render.image_t;
import jake2.util.Lib;
import jake2.util.Vargs;
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
+// import java.awt.geom.AffineTransform; // FIXME
+// import java.awt.image.AffineTransformOp; // FIXME
+// import java.awt.image.BufferedImage; // FIXME
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.util.Arrays;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Image
@@ -493,8 +495,8 @@ public abstract class Image extends Main {
}
if (dim != null) {
- dim.width = width;
- dim.height = height;
+ dim.setWidth(width);
+ dim.setHeight(height);
}
//
@@ -574,8 +576,8 @@ public abstract class Image extends Main {
numPixels = columns * rows;
if (dim != null) {
- dim.width = columns;
- dim.height = rows;
+ dim.setWidth(columns);
+ dim.setHeight(rows);
}
pic = new byte[numPixels * 4]; // targa_rgba;
@@ -884,6 +886,10 @@ public abstract class Image extends Main {
//
// *** this source do the same ***
+ throw new RuntimeException("Replace impl. w/ non AWT!");
+ /**
+ * NO AWT !
+ *
BufferedImage image = new BufferedImage(inwidth, inheight,
BufferedImage.TYPE_INT_ARGB);
@@ -895,6 +901,7 @@ public abstract class Image extends Main {
BufferedImage tmp = op.filter(image, null);
tmp.getRGB(0, 0, outwidth, outheight, out, 0, outwidth);
+ */
// *** end ***
@@ -1490,7 +1497,7 @@ public abstract class Image extends Main {
pic = LoadPCX(name, null, dim);
if (pic == null)
return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8);
+ image = GL_LoadPic(name, pic, dim.getWidth(), dim.getHeight(), type, 8);
} else if (name.endsWith(".wal")) {
@@ -1503,7 +1510,7 @@ public abstract class Image extends Main {
if (pic == null)
return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32);
+ image = GL_LoadPic(name, pic, dim.getWidth(), dim.getHeight(), type, 32);
} else
return null;
diff --git a/src/jake2/render/basic/Main.java b/src/jake2/render/basic/Main.java
index 8f46270..79bb86e 100644
--- a/src/jake2/render/basic/Main.java
+++ b/src/jake2/render/basic/Main.java
@@ -34,10 +34,11 @@ import jake2.util.Lib;
import jake2.util.Math3D;
import jake2.util.Vargs;
-import java.awt.Dimension;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Main
*
diff --git a/src/jake2/render/fast/Draw.java b/src/jake2/render/fast/Draw.java
index 6eeb937..87d2522 100644
--- a/src/jake2/render/fast/Draw.java
+++ b/src/jake2/render/fast/Draw.java
@@ -31,10 +31,11 @@ import jake2.qcommon.Com;
import jake2.render.image_t;
import jake2.util.Lib;
-import java.awt.Dimension;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Draw
* (gl_draw.c)
@@ -118,8 +119,8 @@ public abstract class Draw extends Image {
public void Draw_GetPicSize(Dimension dim, String pic) {
image_t image = Draw_FindPic(pic);
- dim.width = (image != null) ? image.width : -1;
- dim.height = (image != null) ? image.height : -1;
+ dim.setWidth((image != null) ? image.width : -1);
+ dim.setHeight((image != null) ? image.height : -1);
}
/*
diff --git a/src/jake2/render/fast/Image.java b/src/jake2/render/fast/Image.java
index 49a143d..cce6ab6 100644
--- a/src/jake2/render/fast/Image.java
+++ b/src/jake2/render/fast/Image.java
@@ -32,7 +32,6 @@ import jake2.render.image_t;
import jake2.util.Lib;
import jake2.util.Vargs;
-import java.awt.Dimension;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
@@ -40,6 +39,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Image
*
@@ -472,8 +473,8 @@ public abstract class Image extends Main {
}
if (dim != null) {
- dim.width = width;
- dim.height = height;
+ dim.setWidth(width);
+ dim.setHeight(height);
}
//
@@ -556,8 +557,8 @@ public abstract class Image extends Main {
numPixels = columns * rows;
if (dim != null) {
- dim.width = columns;
- dim.height = rows;
+ dim.setWidth(columns);
+ dim.setHeight(rows);
}
pic = new byte[numPixels * 4]; // targa_rgba;
@@ -1473,7 +1474,7 @@ public abstract class Image extends Main {
pic = LoadPCX(name, null, dim);
if (pic == null)
return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8);
+ image = GL_LoadPic(name, pic, dim.getWidth(), dim.getHeight(), type, 8);
}
else if (name.endsWith(".wal")) {
@@ -1488,14 +1489,14 @@ public abstract class Image extends Main {
if (pic == null)
return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32);
+ image = GL_LoadPic(name, pic, dim.getWidth(), dim.getHeight(), type, 32);
} else {
pic = LoadPCX("pics/" + name + ".pcx", null, dim);
if (pic == null)
return null;
- image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8);
+ image = GL_LoadPic(name, pic, dim.getWidth(), dim.getHeight(), type, 8);
}
diff --git a/src/jake2/render/fast/Main.java b/src/jake2/render/fast/Main.java
index e5583cd..471e40d 100644
--- a/src/jake2/render/fast/Main.java
+++ b/src/jake2/render/fast/Main.java
@@ -32,10 +32,11 @@ import jake2.qcommon.*;
import jake2.render.*;
import jake2.util.*;
-import java.awt.Dimension;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+import javax.media.nativewindow.util.Dimension;
+
/**
* Main
*
diff --git a/src/jake2/render/opengl/GLDriver.java b/src/jake2/render/opengl/GLDriver.java
index 8a8eb4c..6fda8cf 100644
--- a/src/jake2/render/opengl/GLDriver.java
+++ b/src/jake2/render/opengl/GLDriver.java
@@ -1,8 +1,10 @@
package jake2.render.opengl;
+import javax.media.nativewindow.util.Dimension;
+
import jake2.qcommon.xcommand_t;
-import java.awt.Dimension;
+import com.jogamp.newt.ScreenMode;
public interface GLDriver {
@@ -22,7 +24,7 @@ public interface GLDriver {
void logNewFrame();
- java.awt.DisplayMode[] getModeList();
+ ScreenMode[] getModeList();
void updateScreen(xcommand_t callback);
diff --git a/src/jake2/render/opengl/JoglDriver.java b/src/jake2/render/opengl/JoglDriver.java
deleted file mode 100644
index 8a1818a..0000000
--- a/src/jake2/render/opengl/JoglDriver.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * JoglDriver.java
- * Copyright (C) 2004
- *
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-package jake2.render.opengl;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.SizeChangeListener;
-import jake2.client.VID;
-import jake2.qcommon.Cbuf;
-import jake2.qcommon.xcommand_t;
-import jake2.render.Base;
-import jake2.sys.JOGLKBD;
-
-import java.awt.*;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.LinkedList;
-
-import javax.media.opengl.*;
-import javax.media.opengl.awt.GLCanvas;
-import javax.swing.ImageIcon;
-
-import jogamp.opengl.FPSCounterImpl;
-
-/**
- * JoglCommon
- */
-public abstract class JoglDriver extends JoglGL implements GLDriver {
-
- protected JoglDriver() {
- // singleton
- }
-
- private GraphicsDevice device;
- private DisplayMode oldDisplayMode;
- private volatile Display display;
- private volatile Frame window;
-
- // This is either the above Window reference or the global
- // applet if we're running in applet mode
- private volatile Container container;
-
- // window position on the screen
- int window_xpos, window_ypos;
-
- public DisplayMode[] getModeList() {
- DisplayMode[] modes = device.getDisplayModes();
- LinkedList<DisplayMode> l = new LinkedList<DisplayMode>();
- l.add(oldDisplayMode);
-
- for (int i = 0; i < modes.length; i++) {
- DisplayMode m = modes[i];
-
- if (m.getBitDepth() != oldDisplayMode.getBitDepth()) continue;
- if (m.getRefreshRate() > oldDisplayMode.getRefreshRate()) continue;
- if (m.getHeight() < 240 || m.getWidth() < 320) continue;
-
- int j = 0;
- DisplayMode ml = null;
- for (j = 0; j < l.size(); j++) {
- ml = (DisplayMode)l.get(j);
- if (ml.getWidth() > m.getWidth()) break;
- if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break;
- }
- if (j == l.size()) {
- l.addLast(m);
- } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) {
- l.add(j, m);
- } else if (m.getRefreshRate() > ml.getRefreshRate()){
- l.remove(j);
- l.add(j, m);
- }
- }
- DisplayMode[] ma = new DisplayMode[l.size()];
- l.toArray(ma);
- return ma;
- }
-
- DisplayMode findDisplayMode(Dimension dim) {
- DisplayMode mode = null;
- DisplayMode m = null;
- DisplayMode[] modes = getModeList();
- int w = dim.width;
- int h = dim.height;
-
- for (int i = 0; i < modes.length; i++) {
- m = modes[i];
- if (m.getWidth() == w && m.getHeight() == h) {
- mode = m;
- break;
- }
- }
- if (mode == null) mode = oldDisplayMode;
- return mode;
- }
-
- String getModeString(DisplayMode m) {
- StringBuffer sb = new StringBuffer();
- sb.append(m.getWidth());
- sb.append('x');
- sb.append(m.getHeight());
- sb.append('x');
- sb.append(m.getBitDepth());
- sb.append('@');
- sb.append(m.getRefreshRate());
- sb.append("Hz");
- return sb.toString();
- }
-
- /**
- * @param dim
- * @param mode
- * @param fullscreen
- * @return enum Base.rserr_t
- */
- public int setMode(Dimension dim, int mode, boolean fullscreen) {
-
- final Dimension newDim = new Dimension();
-
- VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
-
- VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
-
- if (Globals.appletMode && container == null) {
- container = (Container) Globals.applet;
- }
-
- /*
- * full screen handling
- */
- if (device == null) {
- GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
- device = env.getDefaultScreenDevice();
- }
-
- if (oldDisplayMode == null) {
- oldDisplayMode = device.getDisplayMode();
- }
-
- if (!VID.GetModeInfo(newDim, mode)) {
- VID.Printf(Defines.PRINT_ALL, " invalid mode\n");
- return Base.rserr_invalid_mode;
- }
-
- VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n');
-
- if (!Globals.appletMode) {
- // destroy the existing window
- if (window != null) shutdown();
-
- window = new Frame("Jake2 (jogl2)");
- container = window;
- ImageIcon icon = new ImageIcon(getClass().getResource("/icon-small.png"));
- window.setIconImage(icon.getImage());
- window.setLayout(new GridBagLayout());
- // register event listener
- window.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit");
- }
- });
- }
-
- if (Globals.appletMode) {
- // Destroy the previous display if there is one
- shutdown();
-
- // We don't support full-screen mode
- fullscreen = false;
-
- // We need to feed the container to the JOGL
- // keyboard class manually because we'll never get
- // a component shown event for it
- JOGLKBD.Init(container);
- }
-
- Display canvas = new Display(new GLCapabilities(GLProfile.get(GLProfile.GL2)));
- // we want keypressed events for TAB key
- canvas.setFocusTraversalKeysEnabled(false);
- canvas.setSize(newDim.width, newDim.height);
-
- // the OpenGL canvas grows and shrinks with the window
- final GridBagConstraints gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.weightx = gbc.weighty = 1;
-
- // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G
- container.addComponentListener(JOGLKBD.listener);
- canvas.addKeyListener(JOGLKBD.listener);
- canvas.addMouseListener(JOGLKBD.listener);
- canvas.addMouseMotionListener(JOGLKBD.listener);
- canvas.addMouseWheelListener(JOGLKBD.listener);
-
- if (fullscreen) {
-
- container.add(canvas, gbc);
-
- DisplayMode displayMode = findDisplayMode(newDim);
-
- newDim.width = displayMode.getWidth();
- newDim.height = displayMode.getHeight();
- window.setUndecorated(true);
- window.setResizable(false);
-
- device.setFullScreenWindow(window);
-
- if (device.isFullScreenSupported())
- device.setDisplayMode(displayMode);
-
- window.setLocation(0, 0);
- window.setSize(displayMode.getWidth(), displayMode.getHeight());
- canvas.setSize(displayMode.getWidth(), displayMode.getHeight());
-
- VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n');
-
- } else {
- if (!Globals.appletMode) {
- container.add(canvas, gbc);
- final Frame f2 = window;
- try {
- EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- //f2.setLocation(window_xpos, window_ypos);
- f2.pack();
- f2.setResizable(false);
- f2.setVisible(true);
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- final Display fd = canvas;
- try {
- EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- container.add(fd, BorderLayout.CENTER);
- // Notify the size listener about the change
- SizeChangeListener listener = Globals.sizeChangeListener;
- if (listener != null) {
- listener.sizeChanged(newDim.width, newDim.height);
- }
- fd.setSize(newDim.width, newDim.height);
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- if (!Globals.appletMode) {
- while (!canvas.isDisplayable() || !window.isDisplayable()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {}
- }
- }
- canvas.requestFocus();
- canvas.display(); // force GL resource validation
- this.display = canvas;
-
- setGL(display.getGL());
- init(0, 0);
-
- return Base.rserr_ok;
- }
-
- public void shutdown() {
- if (!Globals.appletMode) {
- try {
- EventQueue.invokeAndWait(new Runnable() {
- public void run() {
- if (oldDisplayMode != null
- && device.getFullScreenWindow() != null) {
- try {
- if (device.isFullScreenSupported()) {
- if (!device.getDisplayMode().equals(oldDisplayMode))
- device.setDisplayMode(oldDisplayMode);
-
- }
- device.setFullScreenWindow(null);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- if (window != null) {
- if (display != null) display.destroy();
- window.dispose();
- while (window.isDisplayable()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
-
- }
- }
- } else {
- if (display != null) {
- display.destroy();
- // Remove the old display if there is one
- container.remove(display);
- }
- }
- display = null;
- }
-
- /**
- * @return true
- */
- public boolean init(int xpos, int ypos) {
- // set window position
- window_xpos = xpos;
- window_ypos = ypos;
- // clear the screen
- // first buffer
- beginFrame(0.0f);
- glViewport(0, 0, display.getWidth(), display.getHeight());
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- endFrame();
- // second buffer
- beginFrame(0.0f);
- glViewport(0, 0, display.getWidth(), display.getHeight());
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- endFrame();
- return true;
- }
-
- public void beginFrame(float camera_separation) {
- display.activate();
- }
-
- public void endFrame() {
- display.update();
- }
-
- public void appActivate(boolean activate) {
- // do nothing
- }
-
- public void enableLogging(boolean enable) {
- // do nothing
- }
-
- public void logNewFrame() {
- // do nothing
- }
-
- /*
- * @see jake2.client.refexport_t#updateScreen()
- */
-
- public void updateScreen(xcommand_t callback) {
- callback.execute();
- }
-
- protected void activate() {
- display.activate();
- }
-
- // --------------------------------------------------------------------------
-
- @SuppressWarnings("serial")
- private static class Display extends GLCanvas {
- final FPSCounterImpl fpsCounter;
-
- public Display(GLCapabilities capabilities) {
- super(capabilities);
- setAutoSwapBufferMode(false);
- fpsCounter = new FPSCounterImpl();
- fpsCounter.setUpdateFPSFrames(60*5, System.err); // all 5s in 60hz mode
- }
-
- @Override
- public GL2 getGL() {
- activate();
- return super.getGL().getGL2();
- }
-
-
- /**
- * @see java.awt.Component#setBounds(int, int, int, int)
- */
- @Override
- public void setBounds(int x, int y, int width, int height) {
- final int mask = ~0x03;
- if ((width & 0x03) != 0) {
- width &= mask;
- width += 4;
- }
-
-// System.out.println("display bounds: " + x + ", " + y + ", " + width + ", " + height);
- super.setBounds(x, y, width, height);
- Base.setVid(width, height);
- // let the sound and input subsystems know about the new window
- VID.NewWindow(width, height);
- }
-
- void activate() {
- final GLContext ctx = this.getContext();
- if ( null != ctx && GLContext.getCurrent() != ctx ) {
- ctx.makeCurrent();
- }
- }
-
- private void release() {
- final GLContext ctx = this.getContext();
- if ( null != ctx && GLContext.getCurrent() == ctx) {
- ctx.release();
- }
- }
-
- void update() {
- release();
- swapBuffers();
- fpsCounter.tickFPS();
- }
- }
-}
diff --git a/src/jake2/render/opengl/JoglGL.java b/src/jake2/render/opengl/JoglES2.java
index c009a40..1967619 100644
--- a/src/jake2/render/opengl/JoglGL.java
+++ b/src/jake2/render/opengl/JoglES2.java
@@ -5,11 +5,11 @@ import java.nio.*;
import javax.media.opengl.GL2;
-public class JoglGL implements QGL {
+public class JoglES2 implements QGL {
private GL2 gl;
- JoglGL() {
+ JoglES2() {
// singleton
}
diff --git a/src/jake2/render/opengl/JoglES2Driver.java b/src/jake2/render/opengl/JoglES2Driver.java
new file mode 100644
index 0000000..7319324
--- /dev/null
+++ b/src/jake2/render/opengl/JoglES2Driver.java
@@ -0,0 +1,135 @@
+/*
+ * JoglDriver.java
+ * Copyright (C) 2004
+ *
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+package jake2.render.opengl;
+
+import jake2.qcommon.xcommand_t;
+import jake2.render.Base;
+
+import javax.media.nativewindow.util.Dimension;
+import javax.media.opengl.*;
+
+import com.jogamp.newt.ScreenMode;
+
+/**
+ * JoglCommon
+ */
+public abstract class JoglES2Driver extends JoglES2 implements GLDriver {
+
+ protected JoglES2Driver() {
+ // singleton
+ }
+
+ private NEWTWin newtWin = null;
+
+ public ScreenMode[] getModeList() {
+ if(null == newtWin) {
+ throw new RuntimeException("NEWTWin not yet initialized.");
+ }
+ return newtWin.getModeList();
+ }
+
+ public int setMode(Dimension dim, int mode, boolean fullscreen) {
+ if(null == newtWin) {
+ newtWin = new NEWTWin();
+ }
+ int res = newtWin.setMode(dim, mode, fullscreen);
+ if( Base.rserr_ok == res ) {
+
+ setGL(newtWin.window.getGL().getGL2());
+ init(0, 0);
+
+ return Base.rserr_ok;
+ }
+ return res;
+ }
+
+ public void shutdown() {
+ if(null != newtWin) {
+ newtWin.shutdown();
+ }
+ }
+
+ /**
+ * @return true
+ */
+ public boolean init(int xpos, int ypos) {
+ // clear the screen
+ // first buffer
+ beginFrame(0.0f);
+ glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ endFrame();
+ // second buffer
+ beginFrame(0.0f);
+ glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ endFrame();
+ return true;
+ }
+
+ public void beginFrame(float camera_separation) {
+ activate();
+ }
+
+ public void endFrame() {
+ final GLContext ctx = newtWin.window.getContext();
+ if ( null != ctx && GLContext.getCurrent() == ctx) {
+ ctx.release();
+ }
+ newtWin.window.swapBuffers();
+ newtWin.fpsCounter.tickFPS();
+ }
+
+ public void appActivate(boolean activate) {
+ // do nothing
+ }
+
+ public void enableLogging(boolean enable) {
+ // do nothing
+ }
+
+ public void logNewFrame() {
+ // do nothing
+ }
+
+ /*
+ * @see jake2.client.refexport_t#updateScreen()
+ */
+ public void updateScreen(xcommand_t callback) {
+ callback.execute();
+ }
+
+ protected void activate() {
+ final GLContext ctx = newtWin.window.getContext();
+ if ( null != ctx && GLContext.getCurrent() != ctx ) {
+ ctx.makeCurrent();
+ }
+ }
+
+ // --------------------------------------------------------------------------
+}
diff --git a/src/jake2/render/opengl/JoglGL2.java b/src/jake2/render/opengl/JoglGL2.java
new file mode 100644
index 0000000..a1d1b17
--- /dev/null
+++ b/src/jake2/render/opengl/JoglGL2.java
@@ -0,0 +1,317 @@
+package jake2.render.opengl;
+
+
+import java.nio.*;
+
+import javax.media.opengl.GL2;
+
+public class JoglGL2 implements QGL {
+
+ private GL2 gl;
+
+ JoglGL2() {
+ // singleton
+ }
+
+ void setGL(GL2 gl) {
+ this.gl = gl;
+ }
+
+ public void glAlphaFunc(int func, float ref) {
+ gl.glAlphaFunc(func, ref);
+ }
+
+ public void glBegin(int mode) {
+ gl.glBegin(mode);
+ }
+
+ public void glBindTexture(int target, int texture) {
+ gl.glBindTexture(target, texture);
+ }
+
+ public void glBlendFunc(int sfactor, int dfactor) {
+ gl.glBlendFunc(sfactor, dfactor);
+ }
+
+ public void glClear(int mask) {
+ gl.glClear(mask);
+ }
+
+ public void glClearColor(float red, float green, float blue, float alpha) {
+ gl.glClearColor(red, green, blue, alpha);
+ }
+
+ public void glColor3f(float red, float green, float blue) {
+ gl.glColor3f(red, green, blue);
+ }
+
+ public void glColor3ub(byte red, byte green, byte blue) {
+ gl.glColor3ub(red, green, blue);
+ }
+
+ public void glColor4f(float red, float green, float blue, float alpha) {
+ gl.glColor4f(red, green, blue, alpha);
+ }
+
+ public void glColor4ub(byte red, byte green, byte blue, byte alpha) {
+ gl.glColor4ub(red, green, blue, alpha);
+ }
+
+ public void glColorPointer(int size, boolean unsigned, int stride,
+ ByteBuffer pointer) {
+ gl.glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer);
+ }
+
+ public void glColorPointer(int size, int stride, FloatBuffer pointer) {
+ gl.glColorPointer(size, GL_FLOAT, stride, pointer);
+ }
+
+ public void glCullFace(int mode) {
+ gl.glCullFace(mode);
+ }
+
+ public void glDeleteTextures(IntBuffer textures) {
+ gl.glDeleteTextures(textures.limit(), textures);
+ }
+
+ public void glDepthFunc(int func) {
+ gl.glDepthFunc(func);
+ }
+
+ public void glDepthMask(boolean flag) {
+ gl.glDepthMask(flag);
+ }
+
+ public void glDepthRange(double zNear, double zFar) {
+ gl.glDepthRange(zNear, zFar);
+ }
+
+ public void glDisable(int cap) {
+ gl.glDisable(cap);
+ }
+
+ public void glDisableClientState(int cap) {
+ gl.glDisableClientState(cap);
+ }
+
+ public void glDrawArrays(int mode, int first, int count) {
+ gl.glDrawArrays(mode, first, count);
+ }
+
+ public void glDrawBuffer(int mode) {
+ gl.glDrawBuffer(mode);
+ }
+
+ public void glDrawElements(int mode, IntBuffer indices) {
+ gl.glDrawElements(mode, indices.limit(), GL_UNSIGNED_INT, indices);
+ }
+
+ public void glEnable(int cap) {
+ gl.glEnable(cap);
+ }
+
+ public void glEnableClientState(int cap) {
+ gl.glEnableClientState(cap);
+ }
+
+ public void glEnd() {
+ gl.glEnd();
+ }
+
+ public void glFinish() {
+ gl.glFinish();
+ }
+
+ public void glFlush() {
+ gl.glFlush();
+ }
+
+ public void glFrustum(double left, double right, double bottom,
+ double top, double zNear, double zFar) {
+ gl.glFrustum(left, right, bottom, top, zNear, zFar);
+ }
+
+ public int glGetError() {
+ return gl.glGetError();
+ }
+
+ public void glGetFloat(int pname, FloatBuffer params) {
+ gl.glGetFloatv(pname, params);
+ }
+
+ public String glGetString(int name) {
+ return gl.glGetString(name);
+ }
+
+ public void glHint(int target, int mode) {
+ gl.glHint(target, mode);
+ }
+
+ public void glInterleavedArrays(int format, int stride,
+ FloatBuffer pointer) {
+ gl.glInterleavedArrays(format, stride, pointer);
+ }
+
+ public void glLoadIdentity() {
+ gl.glLoadIdentity();
+ }
+
+ public void glLoadMatrix(FloatBuffer m) {
+ gl.glLoadMatrixf(m);
+ }
+
+ public void glMatrixMode(int mode) {
+ gl.glMatrixMode(mode);
+ }
+
+ public void glOrtho(double left, double right, double bottom,
+ double top, double zNear, double zFar) {
+ gl.glOrtho(left, right, bottom, top, zNear, zFar);
+ }
+
+ public void glPixelStorei(int pname, int param) {
+ gl.glPixelStorei(pname, param);
+ }
+
+ public void glPointSize(float size) {
+ gl.glPointSize(size);
+ }
+
+ public void glPolygonMode(int face, int mode) {
+ gl.glPolygonMode(face, mode);
+ }
+
+ public void glPopMatrix() {
+ gl.glPopMatrix();
+ }
+
+ public void glPushMatrix() {
+ gl.glPushMatrix();
+ }
+
+ public void glReadPixels(int x, int y, int width, int height,
+ int format, int type, ByteBuffer pixels) {
+ gl.glReadPixels(x, y, width, height, format, type, pixels);
+ }
+
+ public void glRotatef(float angle, float x, float y, float z) {
+ gl.glRotatef(angle, x, y, z);
+ }
+
+ public void glScalef(float x, float y, float z) {
+ gl.glScalef(x, y, z);
+ }
+
+ public void glScissor(int x, int y, int width, int height) {
+ gl.glScissor(x, y, width, height);
+ }
+
+ public void glShadeModel(int mode) {
+ gl.glShadeModel(mode);
+ }
+
+ public void glTexCoord2f(float s, float t) {
+ gl.glTexCoord2f(s, t);
+ }
+
+ public void glTexCoordPointer(int size, int stride, FloatBuffer pointer) {
+ gl.glTexCoordPointer(size, GL_FLOAT, stride, pointer);
+ }
+
+ public void glTexEnvi(int target, int pname, int param) {
+ gl.glTexEnvi(target, pname, param);
+ }
+
+ public void glTexImage2D(int target, int level, int internalformat,
+ int width, int height, int border, int format, int type,
+ ByteBuffer pixels) {
+ gl.glTexImage2D(target, level, internalformat, width, height, border,
+ format, type, pixels);
+ }
+
+ public void glTexImage2D(int target, int level, int internalformat,
+ int width, int height, int border, int format, int type,
+ IntBuffer pixels) {
+ gl.glTexImage2D(target, level, internalformat, width, height, border,
+ format, type, pixels);
+ }
+
+ public void glTexParameterf(int target, int pname, float param) {
+ gl.glTexParameterf(target, pname, param);
+ }
+
+ public void glTexParameteri(int target, int pname, int param) {
+ gl.glTexParameteri(target, pname, param);
+ }
+
+ public void glTexSubImage2D(int target, int level, int xoffset,
+ int yoffset, int width, int height, int format, int type,
+ IntBuffer pixels) {
+ gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height,
+ format, type, pixels);
+ }
+
+ public void glTranslatef(float x, float y, float z) {
+ gl.glTranslatef(x, y, z);
+ }
+
+ public void glVertex2f(float x, float y) {
+ gl.glVertex2f(x, y);
+ }
+
+ public void glVertex3f(float x, float y, float z) {
+ gl.glVertex3f(x, y, z);
+ }
+
+ public void glVertexPointer(int size, int stride, FloatBuffer pointer) {
+ gl.glVertexPointer(size, GL_FLOAT, stride, pointer);
+ }
+
+ public void glViewport(int x, int y, int width, int height) {
+ gl.glViewport(x, y, width, height);
+ }
+
+ public void glColorTable(int target, int internalFormat, int width,
+ int format, int type, ByteBuffer data) {
+ gl.glColorTable(target, internalFormat, width, format, type, data);
+ }
+
+ public void glActiveTextureARB(int texture) {
+ gl.glActiveTexture(texture);
+ }
+
+ public void glClientActiveTextureARB(int texture) {
+ gl.glClientActiveTexture(texture);
+ }
+
+ public void glPointParameterEXT(int pname, FloatBuffer pfParams) {
+ gl.glPointParameterfv(pname, pfParams);
+ }
+
+ public void glPointParameterfEXT(int pname, float param) {
+ gl.glPointParameterf(pname, param);
+ }
+ public void glLockArraysEXT(int first, int count) {
+ gl.glLockArraysEXT(first, count);
+ }
+
+ public void glArrayElement(int index) {
+ gl.glArrayElement(index);
+ }
+
+ public void glUnlockArraysEXT() {
+ gl.glUnlockArraysEXT();
+ }
+
+ public void glMultiTexCoord2f(int target, float s, float t) {
+ gl.glMultiTexCoord2f(target, s, t);
+ }
+
+ /*
+ * util extensions
+ */
+ public void setSwapInterval(int interval) {
+ gl.setSwapInterval(interval);
+ }
+
+}
diff --git a/src/jake2/render/opengl/JoglGL2Driver.java b/src/jake2/render/opengl/JoglGL2Driver.java
new file mode 100644
index 0000000..46b7f97
--- /dev/null
+++ b/src/jake2/render/opengl/JoglGL2Driver.java
@@ -0,0 +1,135 @@
+/*
+ * JoglDriver.java
+ * Copyright (C) 2004
+ *
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+package jake2.render.opengl;
+
+import jake2.qcommon.xcommand_t;
+import jake2.render.Base;
+
+import javax.media.nativewindow.util.Dimension;
+import javax.media.opengl.*;
+
+import com.jogamp.newt.ScreenMode;
+
+/**
+ * JoglCommon
+ */
+public abstract class JoglGL2Driver extends JoglGL2 implements GLDriver {
+
+ protected JoglGL2Driver() {
+ // singleton
+ }
+
+ private NEWTWin newtWin = null;
+
+ public ScreenMode[] getModeList() {
+ if(null == newtWin) {
+ throw new RuntimeException("NEWTWin not yet initialized.");
+ }
+ return newtWin.getModeList();
+ }
+
+ public int setMode(Dimension dim, int mode, boolean fullscreen) {
+ if(null == newtWin) {
+ newtWin = new NEWTWin();
+ }
+ int res = newtWin.setMode(dim, mode, fullscreen);
+ if( Base.rserr_ok == res ) {
+
+ setGL(newtWin.window.getGL().getGL2());
+ init(0, 0);
+
+ return Base.rserr_ok;
+ }
+ return res;
+ }
+
+ public void shutdown() {
+ if(null != newtWin) {
+ newtWin.shutdown();
+ }
+ }
+
+ /**
+ * @return true
+ */
+ public boolean init(int xpos, int ypos) {
+ // clear the screen
+ // first buffer
+ beginFrame(0.0f);
+ glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ endFrame();
+ // second buffer
+ beginFrame(0.0f);
+ glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ endFrame();
+ return true;
+ }
+
+ public void beginFrame(float camera_separation) {
+ activate();
+ }
+
+ public void endFrame() {
+ final GLContext ctx = newtWin.window.getContext();
+ if ( null != ctx && GLContext.getCurrent() == ctx) {
+ ctx.release();
+ }
+ newtWin.window.swapBuffers();
+ newtWin.fpsCounter.tickFPS();
+ }
+
+ public void appActivate(boolean activate) {
+ // do nothing
+ }
+
+ public void enableLogging(boolean enable) {
+ // do nothing
+ }
+
+ public void logNewFrame() {
+ // do nothing
+ }
+
+ /*
+ * @see jake2.client.refexport_t#updateScreen()
+ */
+ public void updateScreen(xcommand_t callback) {
+ callback.execute();
+ }
+
+ protected void activate() {
+ final GLContext ctx = newtWin.window.getContext();
+ if ( null != ctx && GLContext.getCurrent() != ctx ) {
+ ctx.makeCurrent();
+ }
+ }
+
+ // --------------------------------------------------------------------------
+}
diff --git a/src/jake2/render/opengl/NEWTWin.java b/src/jake2/render/opengl/NEWTWin.java
new file mode 100644
index 0000000..662dbc7
--- /dev/null
+++ b/src/jake2/render/opengl/NEWTWin.java
@@ -0,0 +1,218 @@
+/*
+ * NEWTWin.java
+ * Copyright (C) 2004
+ *
+ */
+package jake2.render.opengl;
+
+import jake2.Defines;
+import jake2.Globals;
+import jake2.SizeChangeListener;
+import jake2.client.VID;
+import jake2.qcommon.Cbuf;
+import jake2.render.Base;
+import jake2.sys.NEWTKBD;
+
+import java.util.List;
+
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.SurfaceSize;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.FPSCounterImpl;
+
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.newt.util.MonitorMode;
+import com.jogamp.newt.util.ScreenModeUtil;
+
+public class NEWTWin {
+ ScreenMode oldDisplayMode = null;
+ volatile Screen screen = null;
+ volatile GLWindow window = null;
+ final FPSCounterImpl fpsCounter = new FPSCounterImpl();
+
+ public ScreenMode[] getModeList() {
+ final List<ScreenMode> sml = screen.getScreenModes();
+ ScreenMode[] sma = new ScreenMode[sml.size()];
+ sml.toArray(sma);
+ return sma;
+ }
+
+ public ScreenMode findDisplayMode(DimensionImmutable dim) {
+ final List<ScreenMode> sml = ScreenModeUtil.filterByResolution(screen.getScreenModes(), dim);
+ if(sml.size() == 0) {
+ return oldDisplayMode;
+ }
+ return sml.get(0);
+ }
+
+ public String getModeString(ScreenMode sm) {
+ final MonitorMode mm = sm.getMonitorMode();
+ final SurfaceSize ss = mm.getSurfaceSize();
+ final DimensionImmutable m = ss.getResolution();
+ final StringBuffer sb = new StringBuffer();
+ sb.append(m.getWidth());
+ sb.append('x');
+ sb.append(m.getHeight());
+ sb.append('x');
+ sb.append(ss.getBitsPerPixel());
+ sb.append('@');
+ sb.append(mm.getRefreshRate());
+ sb.append("Hz");
+ return sb.toString();
+ }
+
+ /**
+ * @param dim
+ * @param mode
+ * @param fullscreen
+ * @return enum Base.rserr_t
+ */
+ public int setMode(Dimension dim, int mode, boolean fullscreen) {
+
+ final Dimension newDim = new Dimension();
+
+ VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
+
+ VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
+
+ /**
+ if (Globals.appletMode && container == null) {
+ container = (Container) Globals.applet;
+ } */
+
+ final boolean screenRemRef;
+ if(null == screen) {
+ screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0);
+ screen.addReference(); // trigger native creation
+ screenRemRef = true;
+ } else {
+ screenRemRef = false;
+ }
+
+ if (!VID.GetModeInfo(newDim, mode)) {
+ VID.Printf(Defines.PRINT_ALL, " invalid mode\n");
+ return Base.rserr_invalid_mode;
+ }
+
+ VID.Printf(Defines.PRINT_ALL, " " + newDim.getWidth() + " " + newDim.getHeight() + '\n');
+
+ if (!Globals.appletMode) {
+ // destroy the existing window
+ if (window != null) shutdown();
+ }
+
+ if(null == window) {
+ window = GLWindow.create(screen, new GLCapabilities(GLProfile.get(GLProfile.GL2)));
+ window.setTitle("Jake2 (jogl-gl2-newt)");
+ }
+
+ if (oldDisplayMode == null) {
+ oldDisplayMode = window.getScreen().getCurrentScreenMode();
+ }
+
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyNotify(WindowEvent e) {
+ if (!Globals.appletMode) {
+ Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit");
+ }
+ }
+
+ public void windowResized(WindowEvent e) {
+ int width = window.getWidth();
+ int height = window.getHeight();
+ final int mask = ~0x03;
+ if ((width & 0x03) != 0) {
+ width &= mask;
+ width += 4;
+ }
+
+ Base.setVid(width, height);
+ // let the sound and input subsystems know about the new window
+ VID.NewWindow(width, height);
+ }
+ });
+
+ if (Globals.appletMode) {
+ // Destroy the previous display if there is one
+ shutdown();
+
+ // We don't support full-screen mode
+ fullscreen = false;
+ }
+
+ // We need to feed the NEWT Window to the NEWTKBD
+ NEWTKBD.Init(window);
+
+ window.setSize(newDim.getWidth(), newDim.getHeight());
+
+ // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G
+ window.addWindowListener(NEWTKBD.listener);
+ window.addKeyListener(NEWTKBD.listener);
+ window.addMouseListener(NEWTKBD.listener);
+
+ if (fullscreen) {
+ window.setFullscreen(true);
+
+ ScreenMode sm = findDisplayMode(newDim);
+ final DimensionImmutable smDim = sm.getMonitorMode().getSurfaceSize().getResolution();
+ newDim.setWidth( smDim.getWidth() );
+ newDim.setHeight( smDim.getHeight() );
+ window.getScreen().setCurrentScreenMode(sm);
+ window.setFullscreen(true);
+ window.setVisible(true);
+
+ VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + sm.toString() + '\n');
+
+ } else {
+ if (!Globals.appletMode) {
+ window.setVisible(true);
+ } else {
+ // Notify the size listener about the change
+ final SizeChangeListener listener = Globals.sizeChangeListener;
+ if (listener != null) {
+ listener.sizeChanged(newDim.getWidth(), newDim.getHeight());
+ }
+ }
+ }
+
+ if (!Globals.appletMode) {
+ while ( !window.isNativeValid()|| !window.isRealized() ) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {}
+ }
+ }
+ window.requestFocus();
+ window.display(); // force GL resource validation
+
+ if(screenRemRef) {
+ screen.removeReference();
+ }
+
+ fpsCounter.setUpdateFPSFrames(5*60, System.err);
+
+ return Base.rserr_ok;
+ }
+
+ void shutdown() {
+ if (!Globals.appletMode) {
+ if ( null != window ) {
+ window.destroy();
+ }
+ } else {
+ if ( null != window ) {
+ window.destroy(); // same thing
+ }
+ }
+ window = null;
+ }
+
+}
diff --git a/src/jake2/sys/InputListener.java b/src/jake2/sys/InputListener.java
index 8cbe2ae..3efece2 100644
--- a/src/jake2/sys/InputListener.java
+++ b/src/jake2/sys/InputListener.java
@@ -25,17 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.sys;
-import java.awt.event.*;
+import com.jogamp.newt.event.*;
+
import java.util.LinkedList;
/**
* InputListener
*/
-public final class InputListener implements KeyListener, MouseListener,
- MouseMotionListener, ComponentListener, MouseWheelListener {
+public final class InputListener implements KeyListener, MouseListener, WindowListener {
// modifications of eventQueue must be thread safe!
- private static LinkedList eventQueue = new LinkedList();
+ private static LinkedList<Jake2InputEvent> eventQueue = new LinkedList<Jake2InputEvent>();
static void addEvent(Jake2InputEvent ev) {
synchronized (eventQueue) {
@@ -51,67 +51,88 @@ public final class InputListener implements KeyListener, MouseListener,
return ev;
}
+ @Override
public void keyPressed(KeyEvent e) {
- if (!((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0)) {
- addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e));
- }
+ addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e));
}
+ @Override
public void keyReleased(KeyEvent e) {
- addEvent(new Jake2InputEvent(Jake2InputEvent.KeyRelease, e));
+ addEvent(new Jake2InputEvent(Jake2InputEvent.KeyRelease, e));
}
+ @Override
public void keyTyped(KeyEvent e) {
- if ((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
- addEvent(new Jake2InputEvent(Jake2InputEvent.KeyPress, e));
- addEvent(new Jake2InputEvent(Jake2InputEvent.KeyRelease, e));
- }
}
+ @Override
public void mouseClicked(MouseEvent e) {
}
+ @Override
public void mouseEntered(MouseEvent e) {
}
+ @Override
public void mouseExited(MouseEvent e) {
}
+ @Override
+ public void mouseWheelMoved(MouseEvent e) {
+ addEvent(new Jake2InputEvent(Jake2InputEvent.WheelMoved, e));
+ }
+
+ @Override
public void mousePressed(MouseEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.ButtonPress, e));
}
+ @Override
public void mouseReleased(MouseEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.ButtonRelease, e));
}
+ @Override
public void mouseDragged(MouseEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.MotionNotify, e));
}
+ @Override
public void mouseMoved(MouseEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.MotionNotify, e));
}
- public void componentHidden(ComponentEvent e) {
- }
-
- public void componentMoved(ComponentEvent e) {
+ @Override
+ public void windowMoved(WindowEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.ConfigureNotify, e));
}
- public void componentResized(ComponentEvent e) {
+ @Override
+ public void windowResized(WindowEvent e) {
addEvent(new Jake2InputEvent(Jake2InputEvent.ConfigureNotify, e));
}
- public void componentShown(ComponentEvent e) {
- JOGLKBD.c = e.getComponent();
- addEvent(new Jake2InputEvent(Jake2InputEvent.CreateNotify, e));
- }
-
- public void mouseWheelMoved(MouseWheelEvent e) {
- addEvent(new Jake2InputEvent(Jake2InputEvent.WheelMoved, e));
- }
+ @Override
+ public void windowDestroyNotify(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDestroyed(WindowEvent e) {
+ }
+
+ @Override
+ public void windowGainedFocus(WindowEvent e) {
+ addEvent(new Jake2InputEvent(Jake2InputEvent.ConfigureNotify, e));
+ }
+
+ @Override
+ public void windowLostFocus(WindowEvent e) {
+ }
+
+ @Override
+ public void windowRepaint(WindowUpdateEvent e) {
+ addEvent(new Jake2InputEvent(Jake2InputEvent.ConfigureNotify, e));
+ }
}
diff --git a/src/jake2/sys/Jake2InputEvent.java b/src/jake2/sys/Jake2InputEvent.java
index 32becf9..cce63bc 100644
--- a/src/jake2/sys/Jake2InputEvent.java
+++ b/src/jake2/sys/Jake2InputEvent.java
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.sys;
-import java.awt.AWTEvent;
+import com.jogamp.newt.event.NEWTEvent;
/**
* Jake2InputEvent
@@ -40,9 +40,9 @@ class Jake2InputEvent {
static final int ConfigureNotify = 6;
static final int WheelMoved = 7;
int type;
- AWTEvent ev;
+ NEWTEvent ev;
- Jake2InputEvent(int type, AWTEvent ev) {
+ Jake2InputEvent(int type, NEWTEvent ev) {
this.type = type;
this.ev = ev;
}
diff --git a/src/jake2/sys/KBD.java b/src/jake2/sys/KBD.java
index 2ed7ac0..33df0f4 100644
--- a/src/jake2/sys/KBD.java
+++ b/src/jake2/sys/KBD.java
@@ -31,9 +31,6 @@ package jake2.sys;
*/
abstract public class KBD {
- static int win_x = 0;
- static int win_y = 0;
-
// motion values
public static int mx = 0;
public static int my = 0;
diff --git a/src/jake2/sys/JOGLKBD.java b/src/jake2/sys/NEWTKBD.java
index dbf54fb..6b53254 100644
--- a/src/jake2/sys/JOGLKBD.java
+++ b/src/jake2/sys/NEWTKBD.java
@@ -1,40 +1,26 @@
package jake2.sys;
-import jake2.Globals;
import jake2.client.Key;
-import java.awt.*;
-import java.awt.event.*;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.*;
-import javax.swing.ImageIcon;
-
-final public class JOGLKBD extends KBD
+final public class NEWTKBD extends KBD
{
- static Robot robot;
public static InputListener listener = new InputListener();
- static Cursor emptyCursor = null;
- static Component c = null;
+ // static Cursor emptyCursor = null;
+ static Window c = null;
static int win_w2 = 0;
static int win_h2 = 0;
- static {
- try {
- robot = new Robot();
- } catch (AWTException e) {
- if (!Globals.appletMode) {
- System.exit(1);
- }
- }
- }
-
public void Init() {
}
// Used only for the applet case
- public static void Init(Component component) {
- c = component;
- handleCreateAndConfigureNotify(component);
+ public static void Init(Window window) {
+ c = window;
+ handleCreateAndConfigureNotify(window);
}
public void Update() {
@@ -51,12 +37,17 @@ final public class JOGLKBD extends KBD
Jake2InputEvent event;
while ( (event=InputListener.nextEvent()) != null ) {
+ Window eventWin = null;
+ Object source = event.ev.getSource();
+ if(source instanceof Window) {
+ eventWin = (Window)source;
+ }
switch(event.type) {
case Jake2InputEvent.KeyPress:
case Jake2InputEvent.KeyRelease:
- Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress);
+ Do_Key_Event(XLateKeyCode((KeyEvent)event.ev), event.type == Jake2InputEvent.KeyPress);
break;
-
+
case Jake2InputEvent.MotionNotify:
// if (IN.ignorefirst) {
// IN.ignorefirst = false;
@@ -70,7 +61,7 @@ final public class JOGLKBD extends KBD
my = 0;
}
break;
- // see java.awt.MouseEvent
+
case Jake2InputEvent.ButtonPress:
key = mouseEventToKey((MouseEvent)event.ev);
Do_Key_Event(key, true);
@@ -82,7 +73,7 @@ final public class JOGLKBD extends KBD
break;
case Jake2InputEvent.WheelMoved:
- int dir = ((MouseWheelEvent)event.ev).getWheelRotation();
+ int dir = ((MouseEvent)event.ev).getWheelRotation();
if (dir > 0) {
Do_Key_Event(Key.K_MWHEELDOWN, true);
Do_Key_Event(Key.K_MWHEELDOWN, false);
@@ -93,51 +84,26 @@ final public class JOGLKBD extends KBD
break;
case Jake2InputEvent.CreateNotify :
- case Jake2InputEvent.ConfigureNotify :
- handleCreateAndConfigureNotify(((ComponentEvent)event.ev).getComponent());
+ case Jake2InputEvent.ConfigureNotify :
+ handleCreateAndConfigureNotify(eventWin);
break;
}
}
if (mx != 0 || my != 0) {
// move the mouse to the window center again
- robot.mouseMove(win_x + win_w2, win_y + win_h2);
+ c.warpPointer(c.getWidth()/2, c.getHeight()/2);
}
}
- private static void handleCreateAndConfigureNotify(Component component) {
- // Probably could unify this code better, but for now just
- // leave the two code paths separate
- if (!Globals.appletMode) {
- win_x = 0;
- win_y = 0;
- win_w2 = component.getWidth() / 2;
- win_h2 = component.getHeight() / 2;
- int left = 0; int top = 0;
- while (component != null) {
- if (component instanceof Container) {
- Insets insets = ((Container)component).getInsets();
- left += insets.left;
- top += insets.top;
- }
- win_x += component.getX();
- win_y += component.getY();
- component = component.getParent();
- }
- win_x += left; win_y += top;
- win_w2 -= left / 2; win_h2 -= top / 2;
- } else {
- win_x = 0;
- win_y = 0;
+ private static void handleCreateAndConfigureNotify(Window component) {
+ if(null != component) {
win_w2 = component.getWidth() / 2;
win_h2 = component.getHeight() / 2;
- Point p = component.getLocationOnScreen();
- win_x = p.x;
- win_y = p.y;
}
}
- // strange button numbering in java.awt.MouseEvent
+ // Different NEWT button numbering:
// BUTTON1(left) BUTTON2(center) BUTTON3(right)
// K_MOUSE1 K_MOUSE3 K_MOUSE2
private final int mouseEventToKey(MouseEvent ev) {
@@ -151,11 +117,9 @@ final public class JOGLKBD extends KBD
}
}
- private static int XLateKey(KeyEvent ev) {
-
- int key = 0;
+ private static int XLateKeyCode(KeyEvent ev) {
int code = ev.getKeyCode();
-
+ int key = 0;
switch(code) {
// 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break;
case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break;
@@ -221,40 +185,49 @@ final public class JOGLKBD extends KBD
// toggle console for DE and US keyboards
case KeyEvent.VK_DEAD_ACUTE:
case KeyEvent.VK_CIRCUMFLEX:
- case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break;
-
+ case KeyEvent.VK_DEAD_CIRCUMFLEX:
+ case KeyEvent.VK_BACK_QUOTE:
+ key='`';
+ break;
default:
- key = ev.getKeyChar();
-
- if (key >= 'A' && key <= 'Z')
- key = key - 'A' + 'a';
- break;
+ if( KeyEvent.VK_0 <= code && code <= KeyEvent.VK_9 ) {
+ key = code - KeyEvent.VK_0 + '0';
+ }
+ if( KeyEvent.VK_A <= code && code <= KeyEvent.VK_Z ) {
+ key = code - KeyEvent.VK_A + 'a';
+ }
}
if (key > 255) key = 0;
return key;
- }
-
+ }
+
public void Do_Key_Event(int key, boolean down) {
Key.Event(key, down, Timer.Milliseconds());
}
public void centerMouse() {
- robot.mouseMove(win_x + win_w2, win_y + win_h2);
+ c.warpPointer(c.getWidth()/2, c.getHeight()/2);
}
public void installGrabs()
{
+ /*
if (emptyCursor == null) {
ImageIcon emptyIcon = new ImageIcon(new byte[0]);
emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor");
}
c.setCursor(emptyCursor);
- centerMouse();
+ */
+ c.setPointerVisible(false);
+ centerMouse();
}
public void uninstallGrabs()
{
+ /*
c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ */
+ c.setPointerVisible(true);
}
}
diff --git a/test/jake2/render/TestMap.java b/test/jake2/render/TestMap.java
index f127a19..3dd89fd 100644
--- a/test/jake2/render/TestMap.java
+++ b/test/jake2/render/TestMap.java
@@ -84,7 +84,7 @@ public class TestMap
// sehr wichtig !!!
VID.Shutdown();
- Globals.re = this.re = Renderer.getDriver("jogl2", true);
+ Globals.re = this.re = Renderer.getDriver("joglgl2", true);
re.Init(0, 0);
diff --git a/test/jake2/render/TestRenderer.java b/test/jake2/render/TestRenderer.java
index a1a9515..3c0bb7f 100644
--- a/test/jake2/render/TestRenderer.java
+++ b/test/jake2/render/TestRenderer.java
@@ -35,10 +35,11 @@ import jake2.sys.KBD;
import jake2.util.Lib;
import jake2.util.Math3D;
-import java.awt.Dimension;
import java.nio.FloatBuffer;
import java.util.*;
+import javax.media.nativewindow.util.Dimension;
+
/**
* TestRenderer
*
@@ -75,7 +76,7 @@ public class TestRenderer {
Locale.setDefault(Locale.US);
Jake2.Q2Dialog.setVisible(true);
- String DRIVER = "jogl2";
+ String DRIVER = "joglgl2";
Qcommon.Init(new String[] { "TestRenderer", "+set", "gl_mode", "6",
"+set", "vid_fullscreen", "0", "+set", "vid_ref", DRIVER });
@@ -125,7 +126,7 @@ public class TestRenderer {
Dimension wal = new Dimension();
re.DrawGetPicSize(wal, "/textures/e1u1/basemap.wal");
- re.DrawPic(0, viddef.getHeight() - wal.height, "/textures/e1u1/basemap.wal");
+ re.DrawPic(0, viddef.getHeight() - wal.getHeight(), "/textures/e1u1/basemap.wal");
switch (testnr) {
case 0:
diff --git a/webstart/jake2_jogl.jnlp b/webstart/jake2_jogl.jnlp
index b1b0811..342f405 100644
--- a/webstart/jake2_jogl.jnlp
+++ b/webstart/jake2_jogl.jnlp
@@ -7,7 +7,7 @@
<title>Jake2 - JOGL2</title>
<vendor>Bytonic Software</vendor>
<homepage href="http://www.bytonic.de/html/jake2.html"/>
- <description>Java port of the Quake2 game engine (jogl2)</description>
+ <description>Java port of the Quake2 game engine (jogl-gl2-newt)</description>
<icon href="http://jogamp.org/deployment/test/jake2/icon.gif"/>
<offline-allowed/>
</information>
@@ -27,7 +27,7 @@
<application-desc main-class="jake2.Jake2">
<argument>+set</argument>
<argument>vid_ref</argument>
- <argument>jogl2</argument>
+ <argument>joglgl2</argument>
<argument>+set</argument>
<argument>s_impl</argument>
<argument>joal</argument>
diff --git a/webstart/jake2_online.jnlp b/webstart/jake2_online.jnlp
index 6564ba0..4be2496 100644
--- a/webstart/jake2_online.jnlp
+++ b/webstart/jake2_online.jnlp
@@ -7,7 +7,7 @@
<title>Jake2 - JOGL2</title>
<vendor>Bytonic Software</vendor>
<homepage href="http://www.bytonic.de/html/jake2.html"/>
- <description>Java port of the Quake2 game engine (jogl2)</description>
+ <description>Java port of the Quake2 game engine (jogl-gl2-newt)</description>
<icon href="http://jogamp.org/deployment/test/jake2/icon.gif"/>
<offline-allowed/>
</information>
@@ -27,7 +27,7 @@
<application-desc main-class="jake2.Jake2">
<argument>+set</argument>
<argument>vid_ref</argument>
- <argument>jogl2</argument>
+ <argument>joglgl2</argument>
<argument>+set</argument>
<argument>s_impl</argument>
<argument>joal</argument>