aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2006-11-20 23:15:13 +0000
committerCarsten Weisse <[email protected]>2006-11-20 23:15:13 +0000
commitf8c991f3b7725f893532f9739682ce62d0abdac1 (patch)
treebcaa9504af7db1f1c307a8de162b4f4afad68b36
parent62f9b9725244d3557c2deccfd7791949e8c0ebae (diff)
the Renderer factory sets the right RenderAPI (fast or basic) for driver impls
-rw-r--r--src/jake2/client/VID.java10
-rw-r--r--src/jake2/render/JoglRenderer.java12
-rw-r--r--src/jake2/render/Jsr231Renderer.java17
-rw-r--r--src/jake2/render/LwjglRenderer.java13
-rw-r--r--src/jake2/render/Ref.java7
-rw-r--r--src/jake2/render/Renderer.java24
6 files changed, 48 insertions, 35 deletions
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 48c4ffb..864276e 100644
--- a/src/jake2/client/VID.java
+++ b/src/jake2/client/VID.java
@@ -2,7 +2,7 @@
* VID.java
* Copyright (C) 2003
*
- * $Id: VID.java,v 1.16.4.2 2005-12-25 18:11:24 cawe Exp $
+ * $Id: VID.java,v 1.16.4.3 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -167,7 +167,7 @@ public class VID extends Globals {
VID_LoadRefresh
==============
*/
- static boolean LoadRefresh( String name )
+ static boolean LoadRefresh( String name, boolean fast )
{
if ( reflib_active )
@@ -197,7 +197,7 @@ public class VID extends Globals {
}
Com.Printf( "LoadLibrary(\"" + name +"\")\n" );
- Globals.re = Renderer.getDriver(name);
+ Globals.re = Renderer.getDriver(name, fast);
if (Globals.re == null)
{
@@ -256,7 +256,7 @@ public class VID extends Globals {
Globals.cls.disable_screen = 1.0f; // true;
- if ( !LoadRefresh( vid_ref.string ) )
+ if ( !LoadRefresh( vid_ref.string, true ) )
{
String renderer;
if (vid_ref.string.equals(Renderer.getPreferedName())) {
@@ -273,7 +273,7 @@ public class VID extends Globals {
if (gl_mode.value != 0.0f) {
Com.Printf("Trying mode 0\n");
Cvar.SetValue("gl_mode", 0);
- if ( !LoadRefresh( vid_ref.string ) )
+ if ( !LoadRefresh( vid_ref.string, false ) )
Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!");
} else
Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!");
diff --git a/src/jake2/render/JoglRenderer.java b/src/jake2/render/JoglRenderer.java
index d014a09..c95f344 100644
--- a/src/jake2/render/JoglRenderer.java
+++ b/src/jake2/render/JoglRenderer.java
@@ -2,7 +2,7 @@
* JoglRenderer.java
* Copyright (C) 2003
*
- * $Id: JoglRenderer.java,v 1.6.8.5 2006-11-20 21:27:57 cawe Exp $
+ * $Id: JoglRenderer.java,v 1.6.8.6 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -44,10 +44,10 @@ final class JoglRenderer extends JoglDriver implements refexport_t, Ref {
public static final String DRIVER_NAME = "jogl";
- private KBD kbd = new JOGLKBD();
+ private KBD kbd = new JOGLKBD();
- // TODO extract a interface from render code
- private RenderAPI impl = new jake2.render.fast.Misc();
+ // is set from Renderer factory
+ private RenderAPI impl;
static {
Renderer.register(new JoglRenderer());
@@ -334,7 +334,9 @@ final class JoglRenderer extends JoglDriver implements refexport_t, Ref {
return DRIVER_NAME;
}
- public refexport_t GetRefAPI() {
+ public refexport_t GetRefAPI(RenderAPI renderer) {
+ this.impl = renderer;
return this;
}
+
} \ No newline at end of file
diff --git a/src/jake2/render/Jsr231Renderer.java b/src/jake2/render/Jsr231Renderer.java
index d6e821c..226c16b 100644
--- a/src/jake2/render/Jsr231Renderer.java
+++ b/src/jake2/render/Jsr231Renderer.java
@@ -2,7 +2,7 @@
* Jsr231Renderer.java
* Copyright (C) 2004
*
- * $Id: Jsr231Renderer.java,v 1.1.2.3 2006-11-20 21:27:57 cawe Exp $
+ * $Id: Jsr231Renderer.java,v 1.1.2.4 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -41,14 +41,14 @@ import java.awt.Dimension;
*/
final class Jsr231Renderer extends Jsr231Driver implements refexport_t, Ref {
- public static final String DRIVER_NAME = "jsr231";
+ public static final String DRIVER_NAME = "jsr231";
- private KBD kbd = new JOGLKBD();
+ private KBD kbd = new JOGLKBD();
- // TODO extract a interface from render code
- private RenderAPI impl = new jake2.render.fast.Misc();
+ // is set from Renderer factory
+ private RenderAPI impl;
- static {
+ static {
Renderer.register(new Jsr231Renderer());
};
@@ -241,7 +241,8 @@ final class Jsr231Renderer extends Jsr231Driver implements refexport_t, Ref {
return DRIVER_NAME;
}
- public final refexport_t GetRefAPI() {
- return this;
+ public final refexport_t GetRefAPI(RenderAPI renderer) {
+ this.impl = renderer;
+ return this;
}
} \ No newline at end of file
diff --git a/src/jake2/render/LwjglRenderer.java b/src/jake2/render/LwjglRenderer.java
index 0ae021f..36ebc2e 100644
--- a/src/jake2/render/LwjglRenderer.java
+++ b/src/jake2/render/LwjglRenderer.java
@@ -2,7 +2,7 @@
* LwjglRenderer.java
* Copyright (C) 2004
*
- * $Id: LwjglRenderer.java,v 1.1.2.3 2006-11-20 21:27:57 cawe Exp $
+ * $Id: LwjglRenderer.java,v 1.1.2.4 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -41,12 +41,12 @@ import java.awt.DisplayMode;
*/
final class LwjglRenderer extends LwjglDriver implements refexport_t, Ref {
- public static final String DRIVER_NAME = "lwjgl";
+ public static final String DRIVER_NAME = "lwjgl";
- private KBD kbd = new LWJGLKBD();
+ private KBD kbd = new LWJGLKBD();
- // TODO extract a interface from render code
- private RenderAPI impl = new jake2.render.fast.Misc();
+ // is set from Renderer factory
+ private RenderAPI impl;
static {
Renderer.register(new LwjglRenderer());
@@ -237,7 +237,8 @@ final class LwjglRenderer extends LwjglDriver implements refexport_t, Ref {
return DRIVER_NAME;
}
- public final refexport_t GetRefAPI() {
+ public final refexport_t GetRefAPI(RenderAPI renderer) {
+ this.impl = renderer;
return this;
}
} \ No newline at end of file
diff --git a/src/jake2/render/Ref.java b/src/jake2/render/Ref.java
index 568f709..6f3e3c5 100644
--- a/src/jake2/render/Ref.java
+++ b/src/jake2/render/Ref.java
@@ -2,7 +2,7 @@
* Ref.java
* Copyright (C) 2003
*
- * $Id: Ref.java,v 1.2 2004-07-16 10:11:34 cawe Exp $
+ * $Id: Ref.java,v 1.2.12.1 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -34,9 +34,6 @@ import jake2.client.refexport_t;
*/
public interface Ref {
- // ============================================================================
- // extensions (cwei)
- // ============================================================================
- refexport_t GetRefAPI();
+ refexport_t GetRefAPI(RenderAPI renderer);
String getName();
}
diff --git a/src/jake2/render/Renderer.java b/src/jake2/render/Renderer.java
index 552df34..e5bbc0b 100644
--- a/src/jake2/render/Renderer.java
+++ b/src/jake2/render/Renderer.java
@@ -2,7 +2,7 @@
* Renderer.java
* Copyright (C) 2003
*
- * $Id: Renderer.java,v 1.6.6.1 2005-11-14 23:59:00 cawe Exp $
+ * $Id: Renderer.java,v 1.6.6.2 2006-11-20 23:15:13 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,16 +25,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render;
-import java.util.Vector;
-
import jake2.client.refexport_t;
+import java.util.Vector;
+
/**
* Renderer
*
* @author cwei
*/
public class Renderer {
+
+ static RenderAPI fastRenderer = new jake2.render.fast.Misc();
+ static RenderAPI basicRenderer = new jake2.render.basic.Misc();
static Vector drivers = new Vector(3);
@@ -72,18 +75,26 @@ public class Renderer {
}
}
- /**
+ /**
+ * Factory method to get the Renderer implementation.
+ * @return refexport_t (Renderer singleton)
+ */
+ public static refexport_t getDriver(String driverName) {
+ return getDriver(driverName, true);
+ }
+
+ /**
* Factory method to get the Renderer implementation.
* @return refexport_t (Renderer singleton)
*/
- public static refexport_t getDriver(String driverName) {
+ public static refexport_t getDriver(String driverName, boolean fast) {
// find a driver
Ref driver = null;
int count = drivers.size();
for (int i = 0; i < count; i++) {
driver = (Ref) drivers.get(i);
if (driver.getName().equals(driverName)) {
- return driver.GetRefAPI();
+ return driver.GetRefAPI((fast) ? fastRenderer : basicRenderer);
}
}
// null if driver not found
@@ -107,4 +118,5 @@ public class Renderer {
}
return names;
}
+
} \ No newline at end of file