diff options
author | Sven Gothel <[email protected]> | 2012-10-08 02:59:22 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-10-08 02:59:22 +0200 |
commit | 3119458b32c8620f971ba44488389ddf03b2d705 (patch) | |
tree | b1ebd265578e453b7f8a010fc26b816997469be5 /src/jake2/render | |
parent | 377c8b0c884067ea5c009a440992fef3afa92200 (diff) |
Remove lwjgl
Diffstat (limited to 'src/jake2/render')
-rw-r--r-- | src/jake2/render/LwjglRenderer.java | 244 | ||||
-rw-r--r-- | src/jake2/render/opengl/LwjglDriver.java | 331 | ||||
-rw-r--r-- | src/jake2/render/opengl/LwjglGL.java | 311 |
3 files changed, 0 insertions, 886 deletions
diff --git a/src/jake2/render/LwjglRenderer.java b/src/jake2/render/LwjglRenderer.java deleted file mode 100644 index 1add3d3..0000000 --- a/src/jake2/render/LwjglRenderer.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * LwjglRenderer.java - * Copyright (C) 2004 - * - * $Id: LwjglRenderer.java,v 1.5 2007-01-11 23:20:40 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.LwjglDriver; -import jake2.sys.KBD; -import jake2.sys.LWJGLKBD; - -import java.awt.Dimension; - -/** - * 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(); - - // is set from Renderer factory - private RenderAPI impl; - - 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.setGLDriver(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(); - } - - /** - * @see jake2.client.refexport_t#AppActivate(boolean) - */ - public final void AppActivate(boolean activate) { - appActivate(activate); - } - - public void screenshot() { - 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; - } -}
\ No newline at end of file diff --git a/src/jake2/render/opengl/LwjglDriver.java b/src/jake2/render/opengl/LwjglDriver.java deleted file mode 100644 index e44dffc..0000000 --- a/src/jake2/render/opengl/LwjglDriver.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * LWJGLBase.java - * Copyright (C) 2004 - * - * $Id: LwjglDriver.java,v 1.5 2007-11-03 13:04:23 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.opengl; - -import jake2.Defines; -import jake2.client.VID; -import jake2.qcommon.Com; -import jake2.qcommon.xcommand_t; -import jake2.render.Base; - -import java.awt.Dimension; -import java.util.LinkedList; - -import org.lwjgl.LWJGLException; -import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.DisplayMode; - -/** - * LWJGLBase - * - * @author dsanders/cwei - */ -public abstract class LwjglDriver extends LwjglGL implements GLDriver { - - protected LwjglDriver() { - // see LwjglRenderer - } - - private DisplayMode oldDisplayMode; - - // window position on the screen - int window_xpos, window_ypos; - - private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) { - return new java.awt.DisplayMode(m.getWidth(), m.getHeight(), m - .getBitsPerPixel(), m.getFrequency()); - } - - public java.awt.DisplayMode[] getModeList() { - DisplayMode[] modes; - try { - modes = Display.getAvailableDisplayModes(); - } catch (LWJGLException e) { - Com.Println(e.getMessage()); - return new java.awt.DisplayMode[0]; - } - LinkedList l = new LinkedList(); - l.add(toAwtDisplayMode(oldDisplayMode)); - - for (int i = 0; i < modes.length; i++) { - DisplayMode m = modes[i]; - - if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) - continue; - if (m.getFrequency() > oldDisplayMode.getFrequency()) - continue; - if (m.getHeight() < 240 || m.getWidth() < 320) - continue; - - int j = 0; - java.awt.DisplayMode ml = null; - for (j = 0; j < l.size(); j++) { - ml = (java.awt.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(toAwtDisplayMode(m)); - } else if (ml.getWidth() > m.getWidth() - || ml.getHeight() > m.getHeight()) { - l.add(j, toAwtDisplayMode(m)); - } else if (m.getFrequency() > ml.getRefreshRate()) { - l.remove(j); - l.add(j, toAwtDisplayMode(m)); - } - } - java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; - l.toArray(ma); - return ma; - } - - public DisplayMode[] getLWJGLModeList() { - DisplayMode[] modes; - try { - modes = Display.getAvailableDisplayModes(); - } catch (LWJGLException e) { - Com.Println(e.getMessage()); - return new DisplayMode[0]; - } - - LinkedList l = new LinkedList(); - l.add(oldDisplayMode); - - for (int i = 0; i < modes.length; i++) { - DisplayMode m = modes[i]; - - if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) - continue; - if (m.getFrequency() > Math.max(60, oldDisplayMode.getFrequency())) - continue; - if (m.getHeight() < 240 || m.getWidth() < 320) - continue; - if (m.getHeight() > oldDisplayMode.getHeight() || m.getWidth() > oldDisplayMode.getWidth()) - 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.getFrequency() > ml.getFrequency()) { - l.remove(j); - l.add(j, m); - } - } - DisplayMode[] ma = new DisplayMode[l.size()]; - l.toArray(ma); - return ma; - } - - private DisplayMode findDisplayMode(Dimension dim) { - DisplayMode mode = null; - DisplayMode m = null; - DisplayMode[] modes = getLWJGLModeList(); - 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.getBitsPerPixel()); - sb.append('@'); - sb.append(m.getFrequency()); - sb.append("Hz"); - return sb.toString(); - } - - /** - * @param dim - * @param mode - * @param fullscreen - * @return enum rserr_t - */ - public int setMode(Dimension dim, int mode, boolean fullscreen) { - - Dimension newDim = new Dimension(); - - VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); - - VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); - - /* - * fullscreen handling - */ - if (oldDisplayMode == null) { - oldDisplayMode = Display.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'); - - // destroy the existing window - shutdown(); - - Display.setTitle("Jake2 (lwjgl)"); - - DisplayMode displayMode = findDisplayMode(newDim); - newDim.width = displayMode.getWidth(); - newDim.height = displayMode.getHeight(); - - if (fullscreen) { - try { - Display.setDisplayMode(displayMode); - } catch (LWJGLException e) { - return Base.rserr_invalid_mode; - } - - Display.setLocation(0, 0); - - try { - Display.setFullscreen(fullscreen); - } catch (LWJGLException e) { - return Base.rserr_invalid_fullscreen; - } - - VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " - + getModeString(displayMode) + '\n'); - - } else { - try { - Display.setDisplayMode(displayMode); - } catch (LWJGLException e) { - return Base.rserr_invalid_mode; - } - - try { - Display.setFullscreen(false); - } catch (LWJGLException e) { - return Base.rserr_invalid_fullscreen; - } - //Display.setLocation(window_xpos, window_ypos); - } - - Base.setVid(newDim.width, newDim.height); - - // vid.width = newDim.width; - // vid.height = newDim.height; - - try { - Display.create(); - } catch (LWJGLException e) { - return Base.rserr_unknown; - } - - // let the sound and input subsystems know about the new window - VID.NewWindow(newDim.width, newDim.height); - return Base.rserr_ok; - } - - public void shutdown() { - if (oldDisplayMode != null && Display.isFullscreen()) { - try { - Display.setDisplayMode(oldDisplayMode); - } catch (Exception e) { - e.printStackTrace(); - } - } - - while (Display.isCreated()) { - Display.destroy(); - } - } - - /** - * @return true - */ - public boolean init(int xpos, int ypos) { - // do nothing - window_xpos = xpos; - window_ypos = ypos; - return true; - } - - public void beginFrame(float camera_separation) { - // do nothing - } - - public void endFrame() { - glFlush(); - // swap buffers - Display.update(); - } - - public void appActivate(boolean activate) { - // do nothing - } - - public void enableLogging(boolean enable) { - // do nothing - } - - public void logNewFrame() { - // do nothing - } - - /** - * this is a hack for jogl renderers. - * - * @param callback - */ - public final void updateScreen(xcommand_t callback) { - callback.execute(); - } - -} diff --git a/src/jake2/render/opengl/LwjglGL.java b/src/jake2/render/opengl/LwjglGL.java deleted file mode 100644 index c248c3a..0000000 --- a/src/jake2/render/opengl/LwjglGL.java +++ /dev/null @@ -1,311 +0,0 @@ -package jake2.render.opengl; - -import java.nio.*; - -import org.lwjgl.opengl.*; - -public class LwjglGL implements QGL { - - LwjglGL() { - // singleton - } - - public final void glAlphaFunc(int func, float ref) { - GL11.glAlphaFunc(func, ref); - } - - public final void glBegin(int mode) { - GL11.glBegin(mode); - } - - public final void glBindTexture(int target, int texture) { - GL11.glBindTexture(target, texture); - } - - public final void glBlendFunc(int sfactor, int dfactor) { - GL11.glBlendFunc(sfactor, dfactor); - } - - public final void glClear(int mask) { - GL11.glClear(mask); - } - - public final void glClearColor(float red, float green, float blue, float alpha) { - GL11.glClearColor(red, green, blue, alpha); - } - - public final void glColor3f(float red, float green, float blue) { - GL11.glColor3f(red, green, blue); - } - - public final void glColor3ub(byte red, byte green, byte blue) { - GL11.glColor3ub(red, green, blue); - } - - public final void glColor4f(float red, float green, float blue, float alpha) { - GL11.glColor4f(red, green, blue, alpha); - } - - public final void glColor4ub(byte red, byte green, byte blue, byte alpha) { - GL11.glColor4ub(red, green, blue, alpha); - } - - public final void glColorPointer(int size, boolean unsigned, int stride, - ByteBuffer pointer) { - GL11.glColorPointer(size, unsigned, stride, pointer); - } - - public final void glColorPointer(int size, int stride, FloatBuffer pointer) { - GL11.glColorPointer(size, stride, pointer); - } - - public final void glCullFace(int mode) { - GL11.glCullFace(mode); - } - - public final void glDeleteTextures(IntBuffer textures) { - GL11.glDeleteTextures(textures); - } - - public final void glDepthFunc(int func) { - GL11.glDepthFunc(func); - } - - public final void glDepthMask(boolean flag) { - GL11.glDepthMask(flag); - } - - public final void glDepthRange(double zNear, double zFar) { - GL11.glDepthRange(zNear, zFar); - } - - public final void glDisable(int cap) { - GL11.glDisable(cap); - } - - public final void glDisableClientState(int cap) { - GL11.glDisableClientState(cap); - } - - public final void glDrawArrays(int mode, int first, int count) { - GL11.glDrawArrays(mode, first, count); - } - - public final void glDrawBuffer(int mode) { - GL11.glDrawBuffer(mode); - } - - public final void glDrawElements(int mode, IntBuffer indices) { - GL11.glDrawElements(mode, indices); - } - - public final void glEnable(int cap) { - GL11.glEnable(cap); - } - - public final void glEnableClientState(int cap) { - GL11.glEnableClientState(cap); - } - - public final void glEnd() { - GL11.glEnd(); - } - - public final void glFinish() { - GL11.glFinish(); - } - - public final void glFlush() { - GL11.glFlush(); - } - - public final void glFrustum(double left, double right, double bottom, - double top, double zNear, double zFar) { - GL11.glFrustum(left, right, bottom, top, zNear, zFar); - } - - public final int glGetError() { - return GL11.glGetError(); - } - - public final void glGetFloat(int pname, FloatBuffer params) { - GL11.glGetFloat(pname, params); - } - - public final String glGetString(int name) { - return GL11.glGetString(name); - } - - public void glHint(int target, int mode) { - GL11.glHint(target, mode); - } - - public final void glInterleavedArrays(int format, int stride, - FloatBuffer pointer) { - GL11.glInterleavedArrays(format, stride, pointer); - } - - public final void glLoadIdentity() { - GL11.glLoadIdentity(); - } - - public final void glLoadMatrix(FloatBuffer m) { - GL11.glLoadMatrix(m); - } - - public final void glMatrixMode(int mode) { - GL11.glMatrixMode(mode); - } - - public final void glOrtho(double left, double right, double bottom, - double top, double zNear, double zFar) { - GL11.glOrtho(left, right, bottom, top, zNear, zFar); - } - - public final void glPixelStorei(int pname, int param) { - GL11.glPixelStorei(pname, param); - } - - public final void glPointSize(float size) { - GL11.glPointSize(size); - } - - public final void glPolygonMode(int face, int mode) { - GL11.glPolygonMode(face, mode); - } - - public final void glPopMatrix() { - GL11.glPopMatrix(); - } - - public final void glPushMatrix() { - GL11.glPushMatrix(); - } - - public final void glReadPixels(int x, int y, int width, int height, - int format, int type, ByteBuffer pixels) { - GL11.glReadPixels(x, y, width, height, format, type, pixels); - } - - public final void glRotatef(float angle, float x, float y, float z) { - GL11.glRotatef(angle, x, y, z); - } - - public final void glScalef(float x, float y, float z) { - GL11.glScalef(x, y, z); - } - - public final void glScissor(int x, int y, int width, int height) { - GL11.glScissor(x, y, width, height); - } - - public final void glShadeModel(int mode) { - GL11.glShadeModel(mode); - } - - public final void glTexCoord2f(float s, float t) { - GL11.glTexCoord2f(s, t); - } - - public final void glTexCoordPointer(int size, int stride, FloatBuffer pointer) { - GL11.glTexCoordPointer(size, stride, pointer); - } - - public final void glTexEnvi(int target, int pname, int param) { - GL11.glTexEnvi(target, pname, param); - } - - public final void glTexImage2D(int target, int level, int internalformat, - int width, int height, int border, int format, int type, - ByteBuffer pixels) { - GL11.glTexImage2D(target, level, internalformat, width, height, border, - format, type, pixels); - } - - public final void glTexImage2D(int target, int level, int internalformat, - int width, int height, int border, int format, int type, - IntBuffer pixels) { - GL11.glTexImage2D(target, level, internalformat, width, height, border, - format, type, pixels); - } - - public final void glTexParameterf(int target, int pname, float param) { - GL11.glTexParameterf(target, pname, param); - } - - public final void glTexParameteri(int target, int pname, int param) { - GL11.glTexParameteri(target, pname, param); - } - - public final void glTexSubImage2D(int target, int level, int xoffset, - int yoffset, int width, int height, int format, int type, - IntBuffer pixels) { - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, - format, type, pixels); - } - - public final void glTranslatef(float x, float y, float z) { - GL11.glTranslatef(x, y, z); - } - - public final void glVertex2f(float x, float y) { - GL11.glVertex2f(x, y); - } - - public final void glVertex3f(float x, float y, float z) { - GL11.glVertex3f(x, y, z); - } - - public final void glVertexPointer(int size, int stride, FloatBuffer pointer) { - GL11.glVertexPointer(size, stride, pointer); - } - - public final void glViewport(int x, int y, int width, int height) { - GL11.glViewport(x, y, width, height); - } - - public final void glColorTable(int target, int internalFormat, int width, - int format, int type, ByteBuffer data) { - EXTPalettedTexture.glColorTableEXT(target, internalFormat, width, format, type, data); - } - - public final void glActiveTextureARB(int texture) { - ARBMultitexture.glActiveTextureARB(texture); - } - - public final void glClientActiveTextureARB(int texture) { - ARBMultitexture.glClientActiveTextureARB(texture); - } - - public final void glPointParameterEXT(int pname, FloatBuffer pfParams) { - EXTPointParameters.glPointParameterEXT(pname, pfParams); - } - - public final void glPointParameterfEXT(int pname, float param) { - EXTPointParameters.glPointParameterfEXT(pname, param); - } - - public final void glLockArraysEXT(int first, int count) { - EXTCompiledVertexArray.glLockArraysEXT(first, count); - } - - public final void glArrayElement(int index) { - GL11.glArrayElement(index); - } - - public final void glUnlockArraysEXT() { - EXTCompiledVertexArray.glUnlockArraysEXT(); - } - - public final void glMultiTexCoord2f(int target, float s, float t) { - GL13.glMultiTexCoord2f(target, s, t); - } - - /* - * util extensions - */ - public void setSwapInterval(int interval) { - Display.setSwapInterval(interval); - } - -} |