From: Carsten W. <ca...@us...> - 2005-11-14 23:59:09
|
Update of /cvsroot/jake2/jake2/src/jake2/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2243/src/jake2/render Modified Files: Tag: render-refactoring Renderer.java JoglRenderer.java Added Files: Tag: render-refactoring Jsr231Renderer.java LwjglRenderer.java Log Message: new render drivers (alpha see TODO) Index: JoglRenderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/JoglRenderer.java,v retrieving revision 1.6.8.2 retrieving revision 1.6.8.3 diff -C2 -d -r1.6.8.2 -r1.6.8.3 *** JoglRenderer.java 24 Oct 2005 22:46:04 -0000 1.6.8.2 --- JoglRenderer.java 14 Nov 2005 23:59:00 -0000 1.6.8.3 *************** *** 30,33 **** --- 30,34 ---- import jake2.client.refexport_t; import jake2.qcommon.xcommand_t; + import jake2.render.opengl.JoglDriver; import jake2.sys.JOGLKBD; import jake2.sys.KBD; *************** *** 40,48 **** * @author cwei */ ! final class JoglRenderer extends JoglBase implements refexport_t, Ref { - private JOGLKBD kbd=new JOGLKBD(); - public static final String DRIVER_NAME = "jogl"; static { --- 41,52 ---- * @author cwei */ ! final class JoglRenderer extends JoglDriver implements refexport_t, Ref { public static final String DRIVER_NAME = "jogl"; + + private KBD kbd = new JOGLKBD(); + + // TODO extract a interface from render code + private jake2.render.basic.Misc impl = new jake2.render.basic.Misc(); static { *************** *** 51,54 **** --- 55,59 ---- private JoglRenderer() { + // singleton } *************** *** 59,70 **** // ============================================================================ ! /** * @see jake2.client.refexport_t#Init() */ public boolean Init(int vid_xpos, int vid_ypos) { // pre init ! if (!R_Init()) return false; ! // calls the R_Init2() internally ! updateScreen(); // the result from R_Init2() return post_init; --- 64,83 ---- // ============================================================================ ! ! private boolean post_init = false; ! /** * @see jake2.client.refexport_t#Init() */ public boolean Init(int vid_xpos, int vid_ypos) { + // init the OpenGL drivers + impl.setGlImpl(this); // pre init ! if (!impl.R_Init(vid_xpos, vid_ypos)) return false; ! // calls the R_Init2() internally ! updateScreen(new xcommand_t() { ! public void execute() { ! JoglRenderer.this.post_init = impl.R_Init2(); ! } ! }); // the result from R_Init2() return post_init; *************** *** 75,79 **** */ public void Shutdown() { ! R_Shutdown(); } --- 88,92 ---- */ public void Shutdown() { ! impl.R_Shutdown(); } *************** *** 83,87 **** public void BeginRegistration(String map) { if (contextInUse) { ! R_BeginRegistration(map); return; } --- 96,100 ---- public void BeginRegistration(String map) { if (contextInUse) { ! impl.R_BeginRegistration(map); return; } *************** *** 91,95 **** updateScreen(new xcommand_t() { public void execute() { ! R_BeginRegistration(JoglRenderer.this.name); } }); --- 104,108 ---- updateScreen(new xcommand_t() { public void execute() { ! impl.R_BeginRegistration(JoglRenderer.this.name); } }); *************** *** 106,110 **** if (contextInUse) ! return R_RegisterModel(name); model = null; --- 119,123 ---- if (contextInUse) ! return impl.R_RegisterModel(name); model = null; *************** *** 113,117 **** updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.model = R_RegisterModel(JoglRenderer.this.name); } }); --- 126,130 ---- updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.model = impl.R_RegisterModel(JoglRenderer.this.name); } }); *************** *** 124,128 **** public image_t RegisterSkin(String name) { if (contextInUse) ! return R_RegisterSkin(name); this.image = null; --- 137,141 ---- public image_t RegisterSkin(String name) { if (contextInUse) ! return impl.R_RegisterSkin(name); this.image = null; *************** *** 131,135 **** updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.image = R_RegisterSkin(JoglRenderer.this.name); } }); --- 144,148 ---- updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.image = impl.R_RegisterSkin(JoglRenderer.this.name); } }); *************** *** 144,148 **** public image_t RegisterPic(String name) { if (contextInUse) ! return Draw_FindPic(name); this.image = null; --- 157,161 ---- public image_t RegisterPic(String name) { if (contextInUse) ! return impl.Draw_FindPic(name); this.image = null; *************** *** 151,155 **** updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.image = Draw_FindPic(JoglRenderer.this.name); } }); --- 164,168 ---- updateScreen(new xcommand_t() { public void execute() { ! JoglRenderer.this.image = impl.Draw_FindPic(JoglRenderer.this.name); } }); *************** *** 165,169 **** public void SetSky(String name, float rotate, float[] axis) { if (contextInUse) { ! R_SetSky(name, rotate, axis); return; } --- 178,182 ---- public void SetSky(String name, float rotate, float[] axis) { if (contextInUse) { ! impl.R_SetSky(name, rotate, axis); return; } *************** *** 175,179 **** updateScreen(new xcommand_t() { public void execute() { ! R_SetSky(JoglRenderer.this.name, JoglRenderer.this.rotate, JoglRenderer.this.axis); } }); --- 188,192 ---- updateScreen(new xcommand_t() { public void execute() { ! impl.R_SetSky(JoglRenderer.this.name, JoglRenderer.this.rotate, JoglRenderer.this.axis); } }); *************** *** 185,189 **** public void EndRegistration() { if (contextInUse) { ! R_EndRegistration(); return; } --- 198,202 ---- public void EndRegistration() { if (contextInUse) { ! impl.R_EndRegistration(); return; } *************** *** 191,195 **** updateScreen(new xcommand_t() { public void execute() { ! R_EndRegistration(); } }); --- 204,208 ---- updateScreen(new xcommand_t() { public void execute() { ! impl.R_EndRegistration(); } }); *************** *** 200,204 **** */ public void RenderFrame(refdef_t fd) { ! R_RenderFrame(fd); } --- 213,217 ---- */ public void RenderFrame(refdef_t fd) { ! impl.R_RenderFrame(fd); } *************** *** 207,211 **** */ public void DrawGetPicSize(Dimension dim, String name) { ! Draw_GetPicSize(dim, name); } --- 220,224 ---- */ public void DrawGetPicSize(Dimension dim, String name) { ! impl.Draw_GetPicSize(dim, name); } *************** *** 214,218 **** */ public void DrawPic(int x, int y, String name) { ! Draw_Pic(x, y, name); } --- 227,231 ---- */ public void DrawPic(int x, int y, String name) { ! impl.Draw_Pic(x, y, name); } *************** *** 221,226 **** */ public void DrawStretchPic(int x, int y, int w, int h, String name) { ! Draw_StretchPic(x, y, w, h, name); } /** --- 234,241 ---- */ public void DrawStretchPic(int x, int y, int w, int h, String name) { ! impl.Draw_StretchPic(x, y, w, h, name); } + + private int x, y, num; /** *************** *** 228,232 **** */ public void DrawChar(int x, int y, int num) { ! Draw_Char(x, y, num); } --- 243,260 ---- */ public void DrawChar(int x, int y, int num) { ! if (contextInUse) { ! impl.Draw_Char(x, y, num);; ! return; ! } ! ! this.x = x; ! this.y = y; ! this.num = num; ! ! updateScreen(new xcommand_t() { ! public void execute() { ! impl.Draw_Char(JoglRenderer.this.x, JoglRenderer.this.y, JoglRenderer.this.num); ! } ! }); } *************** *** 235,239 **** */ public void DrawTileClear(int x, int y, int w, int h, String name) { ! Draw_TileClear(x, y, w, h, name); } --- 263,267 ---- */ public void DrawTileClear(int x, int y, int w, int h, String name) { ! impl.Draw_TileClear(x, y, w, h, name); } *************** *** 242,246 **** */ public void DrawFill(int x, int y, int w, int h, int c) { ! Draw_Fill(x, y, w, h, c); } --- 270,274 ---- */ public void DrawFill(int x, int y, int w, int h, int c) { ! impl.Draw_Fill(x, y, w, h, c); } *************** *** 249,253 **** */ public void DrawFadeScreen() { ! Draw_FadeScreen(); } --- 277,281 ---- */ public void DrawFadeScreen() { ! impl.Draw_FadeScreen(); } *************** *** 256,260 **** */ public void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { ! Draw_StretchRaw(x, y, w, h, cols, rows, data); } --- 284,288 ---- */ public 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); } *************** *** 263,267 **** */ public void CinematicSetPalette(byte[] palette) { ! R_SetPalette(palette); } --- 291,295 ---- */ public void CinematicSetPalette(byte[] palette) { ! impl.R_SetPalette(palette); } *************** *** 270,274 **** */ public void BeginFrame(float camera_separation) { ! R_BeginFrame(camera_separation); } --- 298,302 ---- */ public void BeginFrame(float camera_separation) { ! impl.R_BeginFrame(camera_separation); } *************** *** 277,281 **** */ public void EndFrame() { ! GLimp_EndFrame(); } --- 305,309 ---- */ public void EndFrame() { ! endFrame(); } *************** *** 284,288 **** */ public void AppActivate(boolean activate) { ! GLimp_AppActivate(activate); } --- 312,316 ---- */ public void AppActivate(boolean activate) { ! appActivate(activate); } *************** *** 290,293 **** --- 318,325 ---- return Defines.API_VERSION; } + + public KBD getKeyboardHandler() { + return kbd; + } // ============================================================================ *************** *** 306,313 **** return this; } - - public KBD getKeyboardHandler() - { - return kbd; - } } \ No newline at end of file --- 338,340 ---- Index: Renderer.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/Renderer.java,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -C2 -d -r1.6 -r1.6.6.1 *** Renderer.java 12 Jan 2005 00:37:13 -0000 1.6 --- Renderer.java 14 Nov 2005 23:59:00 -0000 1.6.6.1 *************** *** 41,62 **** static { try { ! try { ! Class.forName("net.java.games.jogl.GL"); ! Class.forName("jake2.render.JoglRenderer"); ! } catch (ClassNotFoundException e) { ! // ignore the jogl drivers if runtime not in classpath ! } ! try { Class.forName("org.lwjgl.opengl.GL11"); ! Class.forName("jake2.render.LWJGLRenderer"); } catch (ClassNotFoundException e) { // ignore the lwjgl driver if runtime not in classpath } ! try { ! Class.forName("net.java.games.jogl.GL"); ! Class.forName("jake2.render.FastJoglRenderer"); ! } catch (ClassNotFoundException e) { ! // ignore the fastjogl drivers if runtime not in classpath ! } } catch (Throwable e) { e.printStackTrace(); --- 41,62 ---- static { try { ! try { ! Class.forName("net.java.games.jogl.GL"); ! Class.forName("jake2.render.JoglRenderer"); ! } catch (ClassNotFoundException e) { ! // ignore the fastjogl drivers if runtime not in classpath ! } ! try { Class.forName("org.lwjgl.opengl.GL11"); ! Class.forName("jake2.render.LwjglRenderer"); } catch (ClassNotFoundException e) { // ignore the lwjgl driver if runtime not in classpath } ! try { ! Class.forName("javax.media.opengl.GL"); ! Class.forName("jake2.render.Jsr231Renderer"); ! } catch (ClassNotFoundException e) { ! // ignore the jogl drivers if runtime not in classpath ! } } catch (Throwable e) { e.printStackTrace(); --- NEW FILE: LwjglRenderer.java --- /* * LwjglRenderer.java * Copyright (C) 2004 * * $Id: LwjglRenderer.java,v 1.1.2.1 2005/11/14 23:59:00 cawe Exp $ */ /* 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 jake2.Defines; import jake2.client.*; import jake2.qcommon.xcommand_t; import jake2.render.opengl.LwjglDriver; import jake2.sys.*; import java.awt.Dimension; import java.awt.DisplayMode; /** * LwjglRenderer * * @author dsanders/cwei */ final class LwjglRenderer extends LwjglDriver implements refexport_t, Ref { public static final String DRIVER_NAME = "lwjgl"; private KBD kbd = new LWJGLKBD(); // TODO extract a interface from render code private jake2.render.basic.Misc impl = new jake2.render.basic.Misc(); static { Renderer.register(new LwjglRenderer()); }; private LwjglRenderer() { } // ============================================================================ // 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.setGlImpl(this); // pre init if (!impl.R_Init(vid_xpos, vid_ypos)) return false; // 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) { impl.R_BeginRegistration(map); } /** * @see jake2.client.refexport_t#RegisterModel(java.lang.String) */ public final model_t RegisterModel(String name) { return impl.R_RegisterModel(name); } /** * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) */ public final image_t RegisterSkin(String name) { return impl.R_RegisterSkin(name); } /** * @see jake2.client.refexport_t#RegisterPic(java.lang.String) */ public final image_t RegisterPic(String name) { 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) { impl.R_SetSky(name, rotate, axis); } /** * @see jake2.client.refexport_t#EndRegistration() */ public final void EndRegistration() { 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(java.awt.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) { 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(); /* try { Thread.sleep(1); } catch (InterruptedException e) { }*/ } /** * @see jake2.client.refexport_t#AppActivate(boolean) */ public final void AppActivate(boolean activate) { appActivate(activate); } 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() { return this; } } --- NEW FILE: Jsr231Renderer.java --- /* * Jsr231Renderer.java * Copyright (C) 2004 * * $Id: Jsr231Renderer.java,v 1.1.2.1 2005/11/14 23:59:00 cawe Exp $ */ /* 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 jake2.Defines; import jake2.client.refdef_t; import jake2.client.refexport_t; import jake2.render.opengl.Jsr231Driver; import jake2.sys.JOGLKBD; import jake2.sys.KBD; import java.awt.Dimension; /** * Jsr231Renderer * * @author dsanders/cwei */ final class Jsr231Renderer extends Jsr231Driver implements refexport_t, Ref { public static final String DRIVER_NAME = "jsr231"; private KBD kbd = new JOGLKBD(); // TODO extract a interface from render code private jake2.render.basic.Misc impl = new jake2.render.basic.Misc(); static { Renderer.register(new Jsr231Renderer()); }; private Jsr231Renderer() { // 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.setGlImpl(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(java.awt.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 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() { return this; } } |