diff --git a/.idea/artifacts/NuBuildGDX_jar.xml b/.idea/artifacts/NuBuildGDX_jar.xml index b093ed5..70dac9c 100644 --- a/.idea/artifacts/NuBuildGDX_jar.xml +++ b/.idea/artifacts/NuBuildGDX_jar.xml @@ -5,10 +5,8 @@ - - diff --git a/.idea/libraries/lwjgl_opengl_3_2_3.xml b/.idea/libraries/lwjgl_opengl_3_2_3.xml deleted file mode 100644 index a2f2a59..0000000 --- a/.idea/libraries/lwjgl_opengl_3_2_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/lwjgl_opengl_3_2_3_natives_windows.xml b/.idea/libraries/lwjgl_opengl_3_2_3_natives_windows.xml deleted file mode 100644 index bbb89d2..0000000 --- a/.idea/libraries/lwjgl_opengl_3_2_3_natives_windows.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/NuBuildGDX.iml b/NuBuildGDX.iml index 3c184ba..4798bfa 100644 --- a/NuBuildGDX.iml +++ b/NuBuildGDX.iml @@ -18,8 +18,6 @@ - - \ No newline at end of file diff --git a/libs/lwjgl-opengl-3.2.3-natives-linux.jar b/libs/lwjgl-opengl-3.2.3-natives-linux.jar deleted file mode 100644 index bbe4538..0000000 Binary files a/libs/lwjgl-opengl-3.2.3-natives-linux.jar and /dev/null differ diff --git a/libs/lwjgl-opengl-3.2.3-natives-windows.jar b/libs/lwjgl-opengl-3.2.3-natives-windows.jar deleted file mode 100644 index 977cfcb..0000000 Binary files a/libs/lwjgl-opengl-3.2.3-natives-windows.jar and /dev/null differ diff --git a/libs/lwjgl-opengl-3.2.3.jar b/libs/lwjgl-opengl-3.2.3.jar deleted file mode 100644 index b7dcfa3..0000000 Binary files a/libs/lwjgl-opengl-3.2.3.jar and /dev/null differ diff --git a/src/ru/m210projects/Blood/Factory/BloodFactory.java b/src/ru/m210projects/Blood/Factory/BloodFactory.java index 1a23e28..f222ccd 100644 --- a/src/ru/m210projects/Blood/Factory/BloodFactory.java +++ b/src/ru/m210projects/Blood/Factory/BloodFactory.java @@ -62,10 +62,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new BloodSoftware(app.pEngine); - else - return new BloodPolymost(app.pEngine); + return new BloodSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Blood/Factory/BloodPolymost.java b/src/ru/m210projects/Blood/Factory/BloodPolymost.java deleted file mode 100644 index 7d5dee2..0000000 --- a/src/ru/m210projects/Blood/Factory/BloodPolymost.java +++ /dev/null @@ -1,263 +0,0 @@ -// This file is part of BloodGDX. -// Copyright (C) 2017-2019 Alexander Makarov-[M210] (m210-2007@mail.ru) -// -// BloodGDX 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 3 of the License, or -// (at your option) any later version. -// -// BloodGDX 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 BloodGDX. If not, see . - -package ru.m210projects.Blood.Factory; - -import static com.badlogic.gdx.graphics.GL20.GL_SRC_ALPHA; -import static com.badlogic.gdx.graphics.GL20.GL_SRC_COLOR; -import static com.badlogic.gdx.graphics.GL20.GL_TEXTURE; -import static ru.m210projects.Build.Engine.DETAILPAL; -import static ru.m210projects.Build.Engine.GLOWPAL; -import static ru.m210projects.Build.Engine.MAXPALOOKUPS; -import static ru.m210projects.Build.Engine.TRANSLUSCENT1; -import static ru.m210projects.Build.Engine.TRANSLUSCENT2; -import static ru.m210projects.Build.Engine.globalpal; -import static ru.m210projects.Build.Engine.globalshade; -import static ru.m210projects.Build.Engine.numshades; -import static ru.m210projects.Build.Engine.palookupfog; -import static ru.m210projects.Build.Gameutils.BClipRange; -import static ru.m210projects.Build.Render.Types.GL10.GL_COMBINE_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_COMBINE_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_FOG_COLOR; -import static ru.m210projects.Build.Render.Types.GL10.GL_FOG_END; -import static ru.m210projects.Build.Render.Types.GL10.GL_FOG_START; -import static ru.m210projects.Build.Render.Types.GL10.GL_INTERPOLATE_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_MODELVIEW; -import static ru.m210projects.Build.Render.Types.GL10.GL_OPERAND0_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_OPERAND1_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_OPERAND2_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_PREVIOUS_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_SOURCE0_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_SOURCE1_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_SOURCE2_RGB_ARB; -import static ru.m210projects.Build.Render.Types.GL10.GL_TEXTURE0; -import static ru.m210projects.Build.Render.Types.GL10.GL_TEXTURE_ENV; -import static ru.m210projects.Build.Render.Types.GL10.GL_TEXTURE_ENV_MODE; - -import com.badlogic.gdx.graphics.Color; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Architecture.BuildGdx; -import ru.m210projects.Build.OnSceenDisplay.Console; -import ru.m210projects.Build.Render.GLFog; -import ru.m210projects.Build.Render.GLInfo; -import ru.m210projects.Build.Render.Polymost.Polymost; -import ru.m210projects.Build.Render.TextureHandle.DummyTileData; -import ru.m210projects.Build.Render.TextureHandle.GLTile; -import ru.m210projects.Build.Render.TextureHandle.TextureManager; -import ru.m210projects.Build.Render.TextureHandle.TileData.PixelFormat; -import ru.m210projects.Build.Render.Types.Palette; -import ru.m210projects.Build.Settings.GLSettings; - -public class BloodPolymost extends Polymost { - - private GLTile dummy; - private final float[] pal1_color = { 1.0f, 1.0f, 1.0f, 1.0f }; - - public BloodPolymost(Engine engine) { - super(engine, new BloodMapSettings()); - - globalfog = new GLFog() { - @Override - public void calc() { - if (combvis == 0) { - start = FULLVIS_BEGIN; - end = FULLVIS_END; - } else if (shade >= numshades - 1) { - start = -1; - end = 0.001f; - } else { - start = (shade > 0) ? 0 : -(FOGDISTCONST * shade) / combvis; - end = (FOGDISTCONST * (numshades - 1 - shade)) / combvis; - } - - color[0] = (palookupfog[pal][0] / 63.f); - color[1] = (palookupfog[pal][1] / 63.f); - color[2] = (palookupfog[pal][2] / 63.f); - color[3] = 1; - - if (pal == 1 && (GLInfo.multisample == 0 || !GLSettings.usePaletteShader.get())) { // Blood's pal 1 - start = 0; - if (end > 2) - end = 2; - } - - BuildGdx.gl.glFogfv(GL_FOG_COLOR, color, 0); - BuildGdx.gl.glFogf(GL_FOG_START, start); - BuildGdx.gl.glFogf(GL_FOG_END, end); - } - }; - globalfog.setFogScale(64); - } - - @Override - protected void calc_and_apply_fog(int shade, int vis, int pal) { - PixelFormat fmt = textureCache.getFmt(globalpicnum); - if (fmt == null || fmt != PixelFormat.Pal8) { - if (rendering == Rendering.Sprite && globalpal == 5 && globalshade == 127) - shade = 0; // Blood's shadows (for pal 1) - - if (globalpal == 1 || pal == 1) { - if (rendering == Rendering.Model) { - shade = tspriteptr[Rendering.Model.getIndex()].shade; - if (shade > 0) - shade = BClipRange((int) (2.8f * shade), 32, 52); - } else - shade = 0; - } - } - - super.calc_and_apply_fog(shade, vis, pal); - } - - @Override - public void uninit() { - if (dummy != null) - dummy.delete(); - dummy = null; - super.uninit(); - } - - @Override - public Color getshadefactor(int shade, int method) { - if (Rendering.Skybox.getIndex() != 0 && globalpal == 1 && GLInfo.multisample != 0) { - bindBloodPalette(shade); - return super.getshadefactor(0, 0); - } - - Color c = super.getshadefactor(shade, method); - if (globalpal == 1) - c.r = c.g = c.b = 1; // Blood's pal 1 - - return c; - } - - protected void bindDummyTexture() { - if (dummy == null) - dummy = new GLTile(new DummyTileData(PixelFormat.Rgba, 1, 1), 1, false); - bind(dummy); - } - - public void bindBloodPalette(int shade) { - textureCache.activateEffect(); - bindDummyTexture(); - - pal1_color[3] = ((numshades - shade) / (float) numshades) + 0.1f; - BuildGdx.gl.glTexEnvfv(GL_TEXTURE_ENV, 8705, pal1_color, 0); // GL_TEXTURE_ENV_COLOR - - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); - - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, 34166); // GL_CONSTANT - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, 34166); // GL_CONSTANT - BuildGdx.gl.glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); - } - - @Override - public TextureManager newTextureManager(Engine engine) { - return new BloodTextureManager(engine); - } - - @Override - public void setTextureParameters(GLTile tile, int tilenum, int pal, int shade, int skybox, int method) { - if (tile.getPixelFormat() == PixelFormat.Pal8) { - if (!texshader.isBinded()) { - BuildGdx.gl.glActiveTexture(GL_TEXTURE0); - texshader.begin(); - } - texshader.setTextureParams(pal, shade); - - float alpha = 1.0f; - switch (method & 3) { - case 2: - alpha = TRANSLUSCENT1; - break; - case 3: - alpha = TRANSLUSCENT2; - break; - } - - if (!engine.getTile(tilenum).isLoaded()) - alpha = 0.01f; // Hack to update Z-buffer for invalid mirror textures - - texshader.setDrawLastIndex((method & 3) == 0 || !textureCache.alphaMode(method)); - texshader.setTransparent(alpha); - } else { - // texture scale by parkar request - if (tile.isHighTile() && ((tile.getHiresXScale() != 1.0f) || (tile.getHiresYScale() != 1.0f)) - && Rendering.Skybox.getIndex() == 0) { - BuildGdx.gl.glMatrixMode(GL_TEXTURE); - BuildGdx.gl.glLoadIdentity(); - BuildGdx.gl.glScalef(tile.getHiresXScale(), tile.getHiresYScale(), 1.0f); - BuildGdx.gl.glMatrixMode(GL_MODELVIEW); - } - - if (GLInfo.multisample != 0 && GLSettings.useHighTile.get() && Rendering.Skybox.getIndex() == 0) { - if (Console.Geti("r_detailmapping") != 0) { - GLTile detail = textureCache.get(tile.getPixelFormat(), tilenum, DETAILPAL, 0, method); - if (detail != null) { - bind(detail); - setupTextureDetail(detail); - - BuildGdx.gl.glMatrixMode(GL_TEXTURE); - BuildGdx.gl.glLoadIdentity(); - if (detail.isHighTile() && (detail.getHiresXScale() != 1.0f) - || (detail.getHiresYScale() != 1.0f)) - BuildGdx.gl.glScalef(detail.getHiresXScale(), detail.getHiresYScale(), 1.0f); - BuildGdx.gl.glMatrixMode(GL_MODELVIEW); - } - } - - if (Console.Geti("r_glowmapping") != 0) { - GLTile glow = textureCache.get(tile.getPixelFormat(), tilenum, GLOWPAL, 0, method); - if (glow != null) { - bind(glow); - setupTextureGlow(glow); - } - } - } - - Color c = getshadefactor(shade, method); - if (tile.isHighTile() && defs.texInfo != null) { - if (tile.getPal() != pal) { - // apply tinting for replaced textures - - Palette p = defs.texInfo.getTints(pal); - c.r *= p.r / 255.0f; - c.g *= p.g / 255.0f; - c.b *= p.b / 255.0f; - } - - Palette pdetail = defs.texInfo.getTints(MAXPALOOKUPS - 1); - if (pdetail.r != 255 || pdetail.g != 255 || pdetail.b != 255) { - c.r *= pdetail.r / 255.0f; - c.g *= pdetail.g / 255.0f; - c.b *= pdetail.b / 255.0f; - } - } - - if (!engine.getTile(tilenum).isLoaded()) - c.a = 0.01f; // Hack to update Z-buffer for invalid mirror textures - BuildGdx.gl.glColor4f(c.r, c.g, c.b, c.a); - } - } - -} diff --git a/src/ru/m210projects/Blood/View.java b/src/ru/m210projects/Blood/View.java index 503caa2..7f9b830 100644 --- a/src/ru/m210projects/Blood/View.java +++ b/src/ru/m210projects/Blood/View.java @@ -886,25 +886,6 @@ public static void viewDrawScreen(int gViewIndex, int smooth) { engine.getzsofslope(nSector, (int) x, (int) y, zofslope); int lz = 4 << 8; long crossDz = 0; - if (z < zofslope[CEIL] + lz) { - if (nLower == -1 || (engine.getrender().getType().equals(RenderType.Polymost) // Polymost zNear Plane - // tweak - && sector[nSector].ceilingpicnum < MIRRORLABEL - || sector[nSector].ceilingpicnum >= MIRRORLABEL + MAXMIRRORS)) { - crossDz = z; - z = zofslope[CEIL] + lz; - crossDz -= z; - } - } - if (z > zofslope[FLOOR] - lz) { - if (nUpper == -1 || (engine.getrender().getType().equals(RenderType.Polymost) - && sector[nSector].floorpicnum < MIRRORLABEL - || sector[nSector].floorpicnum >= MIRRORLABEL + MAXMIRRORS)) { - crossDz = z; - z = zofslope[FLOOR] - lz; - crossDz -= z; - } - } nHoriz = BClipRange(nHoriz, -200, 200); int defHoriz = kHorizDefault; diff --git a/src/ru/m210projects/Build/Pattern/CommonMenus/MenuVideoMode.java b/src/ru/m210projects/Build/Pattern/CommonMenus/MenuVideoMode.java index 86e2044..0117785 100644 --- a/src/ru/m210projects/Build/Pattern/CommonMenus/MenuVideoMode.java +++ b/src/ru/m210projects/Build/Pattern/CommonMenus/MenuVideoMode.java @@ -238,7 +238,6 @@ public void run() { MenuConteiner item = (MenuConteiner) pItem; switch(item.num) { case 0: choosedRender = RenderType.Software; break; - case 1: choosedRender = RenderType.Polymost; break; } } }); @@ -246,8 +245,7 @@ public void run() { }; String[] renderers = new String[] { - RenderType.Software.getName(), - RenderType.Polymost.getName() + RenderType.Software.getName() }; mRenderer = new MenuConteiner("Renderer", style, posx, posy += itemHeight, width, renderers, 0, renderCallback) { @Override @@ -255,7 +253,6 @@ public void open() { choosedRender = currentRender = app.pEngine.getrender().getType(); switch(currentRender) { case Software: num = 0; break; - case Polymost: num = 1; break; } } }; diff --git a/src/ru/m210projects/Build/Render/Polymost/Polymost.java b/src/ru/m210projects/Build/Render/Polymost/Polymost.java index bda9884..cc7ea8e 100644 --- a/src/ru/m210projects/Build/Render/Polymost/Polymost.java +++ b/src/ru/m210projects/Build/Render/Polymost/Polymost.java @@ -592,6 +592,11 @@ public void setDefs(DefScript defs) { this.defs = defs; } + @Override + public RenderType getType() { + return RenderType.Software; + } + // // invalidatetile // pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular @@ -4093,11 +4098,6 @@ protected Polymost2D allocOrphoRenderer(IOverheadMapSettings settings) { return new Polymost2D(this, settings); } - @Override - public RenderType getType() { - return RenderType.Polymost; - } - @Override public PixelFormat getTexFormat() { return PixelFormat.Rgb; // textureCache.getShader() != null ? PixelFormat.Pal8 : PixelFormat.Rgb; diff --git a/src/ru/m210projects/Build/Render/Renderer.java b/src/ru/m210projects/Build/Render/Renderer.java index 64a513c..f0b8a54 100644 --- a/src/ru/m210projects/Build/Render/Renderer.java +++ b/src/ru/m210projects/Build/Render/Renderer.java @@ -26,7 +26,7 @@ public interface Renderer { enum RenderType { - Software(FrameType.Canvas, "Classic"), Polymost(FrameType.GL, "Polymost"); + Software(FrameType.Canvas, "Classic"); FrameType type; String name; diff --git a/src/ru/m210projects/Build/Settings/BuildConfig.java b/src/ru/m210projects/Build/Settings/BuildConfig.java index 82bcb04..4d4c107 100644 --- a/src/ru/m210projects/Build/Settings/BuildConfig.java +++ b/src/ru/m210projects/Build/Settings/BuildConfig.java @@ -198,7 +198,7 @@ public KeyType setNum(int num) { public String mAddress = "localhost"; public int mPort = NETPORT; - public RenderType renderType = RenderType.Polymost; + public RenderType renderType = RenderType.Software; public boolean gPrecache = true; public BuildConfig(String path, String name) { diff --git a/src/ru/m210projects/Build/desktop/AWT/AWTInput.java b/src/ru/m210projects/Build/desktop/AWT/AWTInput.java index f7ca764..52349c4 100644 --- a/src/ru/m210projects/Build/desktop/AWT/AWTInput.java +++ b/src/ru/m210projects/Build/desktop/AWT/AWTInput.java @@ -127,16 +127,16 @@ public void update() { KeyEvent e = keyEvents.get(i); currentEventTimeStamp = e.timeStamp; switch (e.type) { - case KeyEvent.KEY_DOWN: - processor.keyDown(e.keyCode); - keyJustPressed = true; - justPressedKeys[e.keyCode] = true; - break; - case KeyEvent.KEY_UP: - processor.keyUp(e.keyCode); - break; - case KeyEvent.KEY_TYPED: - processor.keyTyped(e.keyChar); + case KeyEvent.KEY_DOWN: + processor.keyDown(e.keyCode); + keyJustPressed = true; + justPressedKeys[e.keyCode] = true; + break; + case KeyEvent.KEY_UP: + processor.keyUp(e.keyCode); + break; + case KeyEvent.KEY_TYPED: + processor.keyTyped(e.keyChar); } usedKeyEvents.free(e); } @@ -249,7 +249,7 @@ private void updated () { }); JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, - null); + null); pane.setInitialValue(null); pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation()); @@ -278,7 +278,7 @@ public void windowGainedFocus (WindowEvent arg0) { Object selectedValue = pane.getValue(); if (selectedValue != null && (selectedValue instanceof Integer) - && ((Integer)selectedValue).intValue() == JOptionPane.OK_OPTION) { + && ((Integer)selectedValue).intValue() == JOptionPane.OK_OPTION) { listener.input(textField.getText()); } else { listener.canceled(); @@ -423,206 +423,206 @@ public void keyTyped (java.awt.event.KeyEvent e) { protected static int translateKeyCode (java.awt.event.KeyEvent ke) { switch (ke.getKeyCode()) { - case java.awt.event.KeyEvent.VK_MULTIPLY: - return Keys.STAR; - case java.awt.event.KeyEvent.VK_DECIMAL: - return KEY_NUMDECIMAL; - case java.awt.event.KeyEvent.VK_PAUSE: - return KEY_PAUSE; - case java.awt.event.KeyEvent.VK_CAPS_LOCK: - return KEY_CAPSLOCK; - case java.awt.event.KeyEvent.VK_SCROLL_LOCK: - return KEY_SCROLLOCK; - case java.awt.event.KeyEvent.VK_BACK_SPACE: - return Keys.BACKSPACE; - case java.awt.event.KeyEvent.VK_LEFT: - return Keys.LEFT; - case java.awt.event.KeyEvent.VK_RIGHT: - return Keys.RIGHT; - case java.awt.event.KeyEvent.VK_UP: - return Keys.UP; - case java.awt.event.KeyEvent.VK_DOWN: - return Keys.DOWN; - case java.awt.event.KeyEvent.VK_QUOTE: - return Keys.APOSTROPHE; - case java.awt.event.KeyEvent.VK_OPEN_BRACKET: - return Keys.LEFT_BRACKET; - case java.awt.event.KeyEvent.VK_CLOSE_BRACKET: - return Keys.RIGHT_BRACKET; - case java.awt.event.KeyEvent.VK_BACK_QUOTE: - return Keys.GRAVE; - case java.awt.event.KeyEvent.VK_NUM_LOCK: - return Keys.NUM; - case java.awt.event.KeyEvent.VK_EQUALS: - return Keys.EQUALS; - case java.awt.event.KeyEvent.VK_0: - return Keys.NUM_0; - case java.awt.event.KeyEvent.VK_1: - return Keys.NUM_1; - case java.awt.event.KeyEvent.VK_2: - return Keys.NUM_2; - case java.awt.event.KeyEvent.VK_3: - return Keys.NUM_3; - case java.awt.event.KeyEvent.VK_4: - return Keys.NUM_4; - case java.awt.event.KeyEvent.VK_5: - return Keys.NUM_5; - case java.awt.event.KeyEvent.VK_6: - return Keys.NUM_6; - case java.awt.event.KeyEvent.VK_7: - return Keys.NUM_7; - case java.awt.event.KeyEvent.VK_8: - return Keys.NUM_8; - case java.awt.event.KeyEvent.VK_9: - return Keys.NUM_9; - case java.awt.event.KeyEvent.VK_A: - return Keys.A; - case java.awt.event.KeyEvent.VK_B: - return Keys.B; - case java.awt.event.KeyEvent.VK_C: - return Keys.C; - case java.awt.event.KeyEvent.VK_D: - return Keys.D; - case java.awt.event.KeyEvent.VK_E: - return Keys.E; - case java.awt.event.KeyEvent.VK_F: - return Keys.F; - case java.awt.event.KeyEvent.VK_G: - return Keys.G; - case java.awt.event.KeyEvent.VK_H: - return Keys.H; - case java.awt.event.KeyEvent.VK_I: - return Keys.I; - case java.awt.event.KeyEvent.VK_J: - return Keys.J; - case java.awt.event.KeyEvent.VK_K: - return Keys.K; - case java.awt.event.KeyEvent.VK_L: - return Keys.L; - case java.awt.event.KeyEvent.VK_M: - return Keys.M; - case java.awt.event.KeyEvent.VK_N: - return Keys.N; - case java.awt.event.KeyEvent.VK_O: - return Keys.O; - case java.awt.event.KeyEvent.VK_P: - return Keys.P; - case java.awt.event.KeyEvent.VK_Q: - return Keys.Q; - case java.awt.event.KeyEvent.VK_R: - return Keys.R; - case java.awt.event.KeyEvent.VK_S: - return Keys.S; - case java.awt.event.KeyEvent.VK_T: - return Keys.T; - case java.awt.event.KeyEvent.VK_U: - return Keys.U; - case java.awt.event.KeyEvent.VK_V: - return Keys.V; - case java.awt.event.KeyEvent.VK_W: - return Keys.W; - case java.awt.event.KeyEvent.VK_X: - return Keys.X; - case java.awt.event.KeyEvent.VK_Y: - return Keys.Y; - case java.awt.event.KeyEvent.VK_Z: - return Keys.Z; - case java.awt.event.KeyEvent.VK_ALT: - ke.consume(); - if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) - return Keys.ALT_LEFT; - return Keys.ALT_RIGHT; - case java.awt.event.KeyEvent.VK_BACK_SLASH: - return Keys.BACKSLASH; - case java.awt.event.KeyEvent.VK_COMMA: - return Keys.COMMA; - case java.awt.event.KeyEvent.VK_DELETE: - return Keys.FORWARD_DEL; - case java.awt.event.KeyEvent.VK_ENTER: - return Keys.ENTER; - case java.awt.event.KeyEvent.VK_HOME: - return Keys.HOME; - case java.awt.event.KeyEvent.VK_END: - return Keys.END; - case java.awt.event.KeyEvent.VK_PAGE_DOWN: - return Keys.PAGE_DOWN; - case java.awt.event.KeyEvent.VK_PAGE_UP: - return Keys.PAGE_UP; - case java.awt.event.KeyEvent.VK_INSERT: - return Keys.INSERT; - case java.awt.event.KeyEvent.VK_SUBTRACT: - case java.awt.event.KeyEvent.VK_MINUS: - return Keys.MINUS; - case java.awt.event.KeyEvent.VK_PERIOD: - return Keys.PERIOD; - case java.awt.event.KeyEvent.VK_ADD: - case java.awt.event.KeyEvent.VK_PLUS: - return Keys.PLUS; - case java.awt.event.KeyEvent.VK_SEMICOLON: - return Keys.SEMICOLON; - case java.awt.event.KeyEvent.VK_SHIFT: - if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) - return Keys.SHIFT_LEFT; - return Keys.SHIFT_RIGHT; - case java.awt.event.KeyEvent.VK_SLASH: - case java.awt.event.KeyEvent.VK_DIVIDE: - return Keys.SLASH; - case java.awt.event.KeyEvent.VK_SPACE: - return Keys.SPACE; - case java.awt.event.KeyEvent.VK_TAB: - return Keys.TAB; - case java.awt.event.KeyEvent.VK_CONTROL: - if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) - return Keys.CONTROL_LEFT; - return Keys.CONTROL_RIGHT; - case java.awt.event.KeyEvent.VK_ESCAPE: - return Keys.ESCAPE; - case java.awt.event.KeyEvent.VK_F1: - return Keys.F1; - case java.awt.event.KeyEvent.VK_F2: - return Keys.F2; - case java.awt.event.KeyEvent.VK_F3: - return Keys.F3; - case java.awt.event.KeyEvent.VK_F4: - return Keys.F4; - case java.awt.event.KeyEvent.VK_F5: - return Keys.F5; - case java.awt.event.KeyEvent.VK_F6: - return Keys.F6; - case java.awt.event.KeyEvent.VK_F7: - return Keys.F7; - case java.awt.event.KeyEvent.VK_F8: - return Keys.F8; - case java.awt.event.KeyEvent.VK_F9: - return Keys.F9; - case java.awt.event.KeyEvent.VK_F10: - return Keys.F10; - case java.awt.event.KeyEvent.VK_F11: - return Keys.F11; - case java.awt.event.KeyEvent.VK_F12: - return Keys.F12; - case java.awt.event.KeyEvent.VK_COLON: - return Keys.COLON; - case java.awt.event.KeyEvent.VK_NUMPAD0: - return Keys.NUMPAD_0; - case java.awt.event.KeyEvent.VK_NUMPAD1: - return Keys.NUMPAD_1; - case java.awt.event.KeyEvent.VK_NUMPAD2: - return Keys.NUMPAD_2; - case java.awt.event.KeyEvent.VK_NUMPAD3: - return Keys.NUMPAD_3; - case java.awt.event.KeyEvent.VK_NUMPAD4: - return Keys.NUMPAD_4; - case java.awt.event.KeyEvent.VK_NUMPAD5: - return Keys.NUMPAD_5; - case java.awt.event.KeyEvent.VK_NUMPAD6: - return Keys.NUMPAD_6; - case java.awt.event.KeyEvent.VK_NUMPAD7: - return Keys.NUMPAD_7; - case java.awt.event.KeyEvent.VK_NUMPAD8: - return Keys.NUMPAD_8; - case java.awt.event.KeyEvent.VK_NUMPAD9: - return Keys.NUMPAD_9; + case java.awt.event.KeyEvent.VK_MULTIPLY: + return Keys.STAR; + case java.awt.event.KeyEvent.VK_DECIMAL: + return KEY_NUMDECIMAL; + case java.awt.event.KeyEvent.VK_PAUSE: + return KEY_PAUSE; + case java.awt.event.KeyEvent.VK_CAPS_LOCK: + return KEY_CAPSLOCK; + case java.awt.event.KeyEvent.VK_SCROLL_LOCK: + return KEY_SCROLLOCK; + case java.awt.event.KeyEvent.VK_BACK_SPACE: + return Keys.BACKSPACE; + case java.awt.event.KeyEvent.VK_LEFT: + return Keys.LEFT; + case java.awt.event.KeyEvent.VK_RIGHT: + return Keys.RIGHT; + case java.awt.event.KeyEvent.VK_UP: + return Keys.UP; + case java.awt.event.KeyEvent.VK_DOWN: + return Keys.DOWN; + case java.awt.event.KeyEvent.VK_QUOTE: + return Keys.APOSTROPHE; + case java.awt.event.KeyEvent.VK_OPEN_BRACKET: + return Keys.LEFT_BRACKET; + case java.awt.event.KeyEvent.VK_CLOSE_BRACKET: + return Keys.RIGHT_BRACKET; + case java.awt.event.KeyEvent.VK_BACK_QUOTE: + return Keys.GRAVE; + case java.awt.event.KeyEvent.VK_NUM_LOCK: + return Keys.NUM; + case java.awt.event.KeyEvent.VK_EQUALS: + return Keys.EQUALS; + case java.awt.event.KeyEvent.VK_0: + return Keys.NUM_0; + case java.awt.event.KeyEvent.VK_1: + return Keys.NUM_1; + case java.awt.event.KeyEvent.VK_2: + return Keys.NUM_2; + case java.awt.event.KeyEvent.VK_3: + return Keys.NUM_3; + case java.awt.event.KeyEvent.VK_4: + return Keys.NUM_4; + case java.awt.event.KeyEvent.VK_5: + return Keys.NUM_5; + case java.awt.event.KeyEvent.VK_6: + return Keys.NUM_6; + case java.awt.event.KeyEvent.VK_7: + return Keys.NUM_7; + case java.awt.event.KeyEvent.VK_8: + return Keys.NUM_8; + case java.awt.event.KeyEvent.VK_9: + return Keys.NUM_9; + case java.awt.event.KeyEvent.VK_A: + return Keys.A; + case java.awt.event.KeyEvent.VK_B: + return Keys.B; + case java.awt.event.KeyEvent.VK_C: + return Keys.C; + case java.awt.event.KeyEvent.VK_D: + return Keys.D; + case java.awt.event.KeyEvent.VK_E: + return Keys.E; + case java.awt.event.KeyEvent.VK_F: + return Keys.F; + case java.awt.event.KeyEvent.VK_G: + return Keys.G; + case java.awt.event.KeyEvent.VK_H: + return Keys.H; + case java.awt.event.KeyEvent.VK_I: + return Keys.I; + case java.awt.event.KeyEvent.VK_J: + return Keys.J; + case java.awt.event.KeyEvent.VK_K: + return Keys.K; + case java.awt.event.KeyEvent.VK_L: + return Keys.L; + case java.awt.event.KeyEvent.VK_M: + return Keys.M; + case java.awt.event.KeyEvent.VK_N: + return Keys.N; + case java.awt.event.KeyEvent.VK_O: + return Keys.O; + case java.awt.event.KeyEvent.VK_P: + return Keys.P; + case java.awt.event.KeyEvent.VK_Q: + return Keys.Q; + case java.awt.event.KeyEvent.VK_R: + return Keys.R; + case java.awt.event.KeyEvent.VK_S: + return Keys.S; + case java.awt.event.KeyEvent.VK_T: + return Keys.T; + case java.awt.event.KeyEvent.VK_U: + return Keys.U; + case java.awt.event.KeyEvent.VK_V: + return Keys.V; + case java.awt.event.KeyEvent.VK_W: + return Keys.W; + case java.awt.event.KeyEvent.VK_X: + return Keys.X; + case java.awt.event.KeyEvent.VK_Y: + return Keys.Y; + case java.awt.event.KeyEvent.VK_Z: + return Keys.Z; + case java.awt.event.KeyEvent.VK_ALT: + ke.consume(); + if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) + return Keys.ALT_LEFT; + return Keys.ALT_RIGHT; + case java.awt.event.KeyEvent.VK_BACK_SLASH: + return Keys.BACKSLASH; + case java.awt.event.KeyEvent.VK_COMMA: + return Keys.COMMA; + case java.awt.event.KeyEvent.VK_DELETE: + return Keys.FORWARD_DEL; + case java.awt.event.KeyEvent.VK_ENTER: + return Keys.ENTER; + case java.awt.event.KeyEvent.VK_HOME: + return Keys.HOME; + case java.awt.event.KeyEvent.VK_END: + return Keys.END; + case java.awt.event.KeyEvent.VK_PAGE_DOWN: + return Keys.PAGE_DOWN; + case java.awt.event.KeyEvent.VK_PAGE_UP: + return Keys.PAGE_UP; + case java.awt.event.KeyEvent.VK_INSERT: + return Keys.INSERT; + case java.awt.event.KeyEvent.VK_SUBTRACT: + case java.awt.event.KeyEvent.VK_MINUS: + return Keys.MINUS; + case java.awt.event.KeyEvent.VK_PERIOD: + return Keys.PERIOD; + case java.awt.event.KeyEvent.VK_ADD: + case java.awt.event.KeyEvent.VK_PLUS: + return Keys.PLUS; + case java.awt.event.KeyEvent.VK_SEMICOLON: + return Keys.SEMICOLON; + case java.awt.event.KeyEvent.VK_SHIFT: + if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) + return Keys.SHIFT_LEFT; + return Keys.SHIFT_RIGHT; + case java.awt.event.KeyEvent.VK_SLASH: + case java.awt.event.KeyEvent.VK_DIVIDE: + return Keys.SLASH; + case java.awt.event.KeyEvent.VK_SPACE: + return Keys.SPACE; + case java.awt.event.KeyEvent.VK_TAB: + return Keys.TAB; + case java.awt.event.KeyEvent.VK_CONTROL: + if(ke.getKeyLocation() == java.awt.event.KeyEvent.KEY_LOCATION_LEFT) + return Keys.CONTROL_LEFT; + return Keys.CONTROL_RIGHT; + case java.awt.event.KeyEvent.VK_ESCAPE: + return Keys.ESCAPE; + case java.awt.event.KeyEvent.VK_F1: + return Keys.F1; + case java.awt.event.KeyEvent.VK_F2: + return Keys.F2; + case java.awt.event.KeyEvent.VK_F3: + return Keys.F3; + case java.awt.event.KeyEvent.VK_F4: + return Keys.F4; + case java.awt.event.KeyEvent.VK_F5: + return Keys.F5; + case java.awt.event.KeyEvent.VK_F6: + return Keys.F6; + case java.awt.event.KeyEvent.VK_F7: + return Keys.F7; + case java.awt.event.KeyEvent.VK_F8: + return Keys.F8; + case java.awt.event.KeyEvent.VK_F9: + return Keys.F9; + case java.awt.event.KeyEvent.VK_F10: + return Keys.F10; + case java.awt.event.KeyEvent.VK_F11: + return Keys.F11; + case java.awt.event.KeyEvent.VK_F12: + return Keys.F12; + case java.awt.event.KeyEvent.VK_COLON: + return Keys.COLON; + case java.awt.event.KeyEvent.VK_NUMPAD0: + return Keys.NUMPAD_0; + case java.awt.event.KeyEvent.VK_NUMPAD1: + return Keys.NUMPAD_1; + case java.awt.event.KeyEvent.VK_NUMPAD2: + return Keys.NUMPAD_2; + case java.awt.event.KeyEvent.VK_NUMPAD3: + return Keys.NUMPAD_3; + case java.awt.event.KeyEvent.VK_NUMPAD4: + return Keys.NUMPAD_4; + case java.awt.event.KeyEvent.VK_NUMPAD5: + return Keys.NUMPAD_5; + case java.awt.event.KeyEvent.VK_NUMPAD6: + return Keys.NUMPAD_6; + case java.awt.event.KeyEvent.VK_NUMPAD7: + return Keys.NUMPAD_7; + case java.awt.event.KeyEvent.VK_NUMPAD8: + return Keys.NUMPAD_8; + case java.awt.event.KeyEvent.VK_NUMPAD9: + return Keys.NUMPAD_9; } return Input.Keys.UNKNOWN; } @@ -812,4 +812,4 @@ public void setCatchKey(int arg0, boolean arg1) { @Override public void dispose() { } -} +} \ No newline at end of file diff --git a/src/ru/m210projects/Build/desktop/AWT/AWTMouse.java b/src/ru/m210projects/Build/desktop/AWT/AWTMouse.java index d7f552d..8c7b5cc 100644 --- a/src/ru/m210projects/Build/desktop/AWT/AWTMouse.java +++ b/src/ru/m210projects/Build/desktop/AWT/AWTMouse.java @@ -106,12 +106,10 @@ public AWTMouse(JDisplay display) @Override public void setWindowHandle() { /* nothing */ } - private void setMousePosition(int x, int y) { - if (Math.abs(this.x - x) > 1 || Math.abs(this.y - y) > 1) { - if (robot != null) robot.mouseMove(x, y); - } - this.x = x; - this.y = y; + private void setMousePosition(int x, int y) + { + if(robot != null) + robot.mouseMove(x, y); } @Override @@ -142,46 +140,60 @@ public void reset() } @Override - public long processEvents(InputProcessor processor) { - List eventsCopy; + public long processEvents (InputProcessor processor) { synchronized (this) { - eventsCopy = new ArrayList<>(touchEvents); - touchEvents.clear(); - justTouched = false; - Arrays.fill(justPressedButtons, false); - } + if (justTouched) { + justTouched = false; + Arrays.fill(justPressedButtons, false); + } - long currentEventTimeStamp = -1; - if (processor != null) { - for (TouchEvent e : eventsCopy) { - currentEventTimeStamp = e.timeStamp; - switch (e.type) { - case TouchEvent.TOUCH_DOWN: - processor.touchDown(e.x, e.y, e.pointer, e.button); - justPressedButtons[e.button] = true; + long currentEventTimeStamp = -1; + if (processor != null) { + int len = touchEvents.size(); + for (int i = 0; i < len; i++) { + TouchEvent e = touchEvents.get(i); + currentEventTimeStamp = e.timeStamp; + switch (e.type) { + case TouchEvent.TOUCH_DOWN: + processor.touchDown(e.x, e.y, e.pointer, e.button); + justPressedButtons[e.button] = true; + justTouched = true; + break; + case TouchEvent.TOUCH_UP: + processor.touchUp(e.x, e.y, e.pointer, e.button); + break; + case TouchEvent.TOUCH_DRAGGED: + processor.touchDragged(e.x, e.y, e.pointer); + break; + case TouchEvent.TOUCH_MOVED: + processor.mouseMoved(e.x, e.y); + break; + case TouchEvent.TOUCH_SCROLLED: + processor.scrolled(e.scrollAmount); + break; + } + usedTouchEvents.free(e); + } + } else { + int len = touchEvents.size(); + for (int i = 0; i < len; i++) { + TouchEvent event = touchEvents.get(i); + if (event.type == TouchEvent.TOUCH_DOWN && event.button != -1) { + justPressedButtons[event.button] = true; justTouched = true; - break; - case TouchEvent.TOUCH_UP: - processor.touchUp(e.x, e.y, e.pointer, e.button); - break; - case TouchEvent.TOUCH_DRAGGED: - processor.touchDragged(e.x, e.y, e.pointer); - break; - case TouchEvent.TOUCH_MOVED: - processor.mouseMoved(e.x, e.y); - break; - case TouchEvent.TOUCH_SCROLLED: - processor.scrolled(e.scrollAmount); - break; + } + usedTouchEvents.free(event); } - usedTouchEvents.free(e); } + if (touchEvents.isEmpty()) { wheel = 0; } - } - return currentEventTimeStamp; + touchEvents.clear(); + + return currentEventTimeStamp; + } } @Override @@ -241,16 +253,14 @@ public void mouseExited (MouseEvent e) { checkCatched(e); } - private void checkCatched(MouseEvent e) { - if (!display.isActive()) return; + private void checkCatched (MouseEvent e) { + if(!display.isActive()) + return; Canvas canvas = display.getCanvas(); if (catched && canvas.isShowing()) { - int canvasWidth = canvas.getWidth(); - int canvasHeight = canvas.getHeight(); - - if (e.getX() < 10 || e.getX() >= canvasWidth - 10 || e.getY() < 10 || e.getY() >= canvasHeight - 10) { - setCursorPosition(canvasWidth / 2, canvasHeight / 2); + if (e.getX() < 0 || e.getX() >= canvas.getWidth() || e.getY() < 0 || e.getY() >= canvas.getHeight()) { + setCursorPosition(canvas.getWidth() / 2, canvas.getHeight() / 2); showCursor(false); } } @@ -411,4 +421,4 @@ public boolean isCursorCatched() { public boolean isInsideWindow() { return mouseInside; } -} +} \ No newline at end of file diff --git a/src/ru/m210projects/Build/desktop/DesktopFactory.java b/src/ru/m210projects/Build/desktop/DesktopFactory.java index a887d27..3a9d227 100644 --- a/src/ru/m210projects/Build/desktop/DesktopFactory.java +++ b/src/ru/m210projects/Build/desktop/DesktopFactory.java @@ -38,8 +38,6 @@ import ru.m210projects.Build.desktop.AWT.AWTGraphics; import ru.m210projects.Build.desktop.AWT.AWTInput; import ru.m210projects.Build.desktop.Controllers.JControllers; -import ru.m210projects.Build.desktop.GLFW.Lwjgl3Graphics; -import ru.m210projects.Build.desktop.GLFW.Lwjgl3Input; import ru.m210projects.Build.desktop.audio.ALAudio; import ru.m210projects.Build.desktop.audio.ALSoundDrv; import ru.m210projects.Build.desktop.audio.GdxAL; @@ -98,24 +96,12 @@ public BuildFrame getFrame(BuildConfiguration config, FrameType type) { return new BuildFrame(config) { @Override public BuildGraphics getGraphics(FrameType type) { - if(type == FrameType.GL) - return new Lwjgl3Graphics(cfg); - - if(type == FrameType.Canvas) - return new AWTGraphics(cfg); - - throw new UnsupportedOperationException("Unsupported frame type: " + type); + return new AWTGraphics(cfg); } @Override public BuildInput getInput(FrameType type) { - if(type == FrameType.GL) - return new Lwjgl3Input(); - - if(type == FrameType.Canvas) - return new AWTInput(); - - throw new UnsupportedOperationException("Unsupported frame type: " + type); + return new AWTInput(); } }; } diff --git a/src/ru/m210projects/Build/desktop/GLFW/GLFWSync.java b/src/ru/m210projects/Build/desktop/GLFW/GLFWSync.java deleted file mode 100644 index f9a5d28..0000000 --- a/src/ru/m210projects/Build/desktop/GLFW/GLFWSync.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2002-2012 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package ru.m210projects.Build.desktop.GLFW; - -import org.lwjgl.glfw.GLFW; - -/** -* A highly accurate sync method that continually adapts to the system -* it runs on to provide reliable results. -* -* @author Riven -* @author kappaOne -*/ - -public class GLFWSync { - - /** number of nano seconds in a second */ - private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L; - - /** The time to sleep/yield until the next frame */ - private static long nextFrame = 0; - - /** whether the initialisation code has run */ - private static boolean initialised = false; - - /** for calculating the averages the previous sleep/yield times are stored */ - private static RunningAvg sleepDurations = new RunningAvg(10); - private static RunningAvg yieldDurations = new RunningAvg(10); - - /** - * An accurate sync method that will attempt to run at a constant frame rate. - * It should be called once every frame. - * - * @param fps - the desired frame rate, in frames per second - */ - public static void sync(int fps) { - if (fps <= 0) return; - if (!initialised) initialise(); - - try { - // sleep until the average sleep time is greater than the time remaining till nextFrame - for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) { - Thread.sleep(1); - sleepDurations.add((t1 = getTime()) - t0); // update average sleep time - } - - // slowly dampen sleep average if too high to avoid yielding too much - sleepDurations.dampenForLowResTicker(); - - // yield until the average yield time is greater than the time remaining till nextFrame - for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) { - Thread.yield(); - yieldDurations.add((t1 = getTime()) - t0); // update average yield time - } - } catch (InterruptedException e) { - - } - - // schedule next frame, drop frame(s) if already too late for next frame - nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime()); - } - - /** - * This method will initialise the sync method by setting initial - * values for sleepDurations/yieldDurations and nextFrame. - * - * If running on windows it will start the sleep timer fix. - */ - private static void initialise() { - initialised = true; - - sleepDurations.init(1000 * 1000); - yieldDurations.init((int) (-(getTime() - getTime()) * 1.333)); - - nextFrame = getTime(); - } - - /** - * Get the system time in nano seconds - * - * @return will return the current time in nano's - */ - private static long getTime() { - return (long)(GLFW.glfwGetTime() * NANOS_IN_SECOND); - } - - private static class RunningAvg { - private final long[] slots; - private int offset; - - private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms - private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f is exactly right! - - public RunningAvg(int slotCount) { - this.slots = new long[slotCount]; - this.offset = 0; - } - - public void init(long value) { - while (this.offset < this.slots.length) { - this.slots[this.offset++] = value; - } - } - - public void add(long value) { - this.slots[this.offset++ % this.slots.length] = value; - this.offset %= this.slots.length; - } - - public long avg() { - long sum = 0; - for (int i = 0; i < this.slots.length; i++) { - sum += this.slots[i]; - } - return sum / this.slots.length; - } - - public void dampenForLowResTicker() { - if (this.avg() > DAMPEN_THRESHOLD) { - for (int i = 0; i < this.slots.length; i++) { - this.slots[i] *= DAMPEN_FACTOR; - } - } - } - } - -} diff --git a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3GL10.java b/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3GL10.java deleted file mode 100644 index eb89687..0000000 --- a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3GL10.java +++ /dev/null @@ -1,1029 +0,0 @@ -package ru.m210projects.Build.desktop.GLFW; - -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.ShortBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.EXTFramebufferObject; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.lwjgl.opengl.GL13; -import org.lwjgl.opengl.GL14; -import org.lwjgl.opengl.GL15; - -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.math.Matrix4; -import com.badlogic.gdx.utils.GdxRuntimeException; - -import ru.m210projects.Build.Render.Types.GL10; - -public class Lwjgl3GL10 extends GL10 { - - @Override - public void glActiveTexture (int texture) { - if(Gdx.graphics.getGLVersion().isVersionEqualToOrHigher(1, 3)) - GL13.glActiveTexture(texture); - } - - @Override - public void glBindBuffer (int target, int buffer) { - GL15.glBindBuffer(target, buffer); - } - - @Override - public void glBindFramebuffer (int target, int framebuffer) { - EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer); - } - - @Override - public void glBindRenderbuffer (int target, int renderbuffer) { - EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer); - } - - @Override - public void glBindTexture (int target, int texture) { - GL11.glBindTexture(target, texture); - } - - @Override - public void glBlendColor (float red, float green, float blue, float alpha) { - GL14.glBlendColor(red, green, blue, alpha); - } - - @Override - public void glBlendEquation (int mode) { - GL14.glBlendEquation(mode); - } - - @Override - public void glBlendFunc (int sfactor, int dfactor) { - GL11.glBlendFunc(sfactor, dfactor); - } - - @Override - public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) { - GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); - } - - @Override - public void glBufferData (int target, int size, Buffer data, int usage) { - if (data == null) - GL15.glBufferData(target, size, usage); - else if (data instanceof ByteBuffer) - GL15.glBufferData(target, (ByteBuffer)data, usage); - else if (data instanceof IntBuffer) - GL15.glBufferData(target, (IntBuffer)data, usage); - else if (data instanceof FloatBuffer) - GL15.glBufferData(target, (FloatBuffer)data, usage); - else if (data instanceof DoubleBuffer) - GL15.glBufferData(target, (DoubleBuffer)data, usage); - else if (data instanceof ShortBuffer) // - GL15.glBufferData(target, (ShortBuffer)data, usage); - } - - @Override - public void glBufferSubData (int target, int offset, int size, Buffer data) { - if (data == null) - throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL"); - else if (data instanceof ByteBuffer) - GL15.glBufferSubData(target, offset, (ByteBuffer)data); - else if (data instanceof IntBuffer) - GL15.glBufferSubData(target, offset, (IntBuffer)data); - else if (data instanceof FloatBuffer) - GL15.glBufferSubData(target, offset, (FloatBuffer)data); - else if (data instanceof DoubleBuffer) - GL15.glBufferSubData(target, offset, (DoubleBuffer)data); - else if (data instanceof ShortBuffer) // - GL15.glBufferSubData(target, offset, (ShortBuffer)data); - } - - @Override - public int glCheckFramebufferStatus (int target) { - return EXTFramebufferObject.glCheckFramebufferStatusEXT(target); - } - - @Override - public void glClear (int mask) { - GL11.glClear(mask); - } - - @Override - public void glClearColor (float red, float green, float blue, float alpha) { - GL11.glClearColor(red, green, blue, alpha); - } - - @Override - public void glClearDepthf (float depth) { - GL11.glClearDepth(depth); - } - - @Override - public void glClearStencil (int s) { - GL11.glClearStencil(s); - } - - @Override - public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha) { - GL11.glColorMask(red, green, blue, alpha); - } - - @Override - public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border, - int imageSize, Buffer data) { - if (data instanceof ByteBuffer) { - GL13.glCompressedTexImage2D(target, level, internalformat, width, height, border, (ByteBuffer)data); - } else { - throw new GdxRuntimeException("Can't use " + data.getClass().getName() + " with this method. Use ByteBuffer instead."); - } - } - - @Override - public final void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, - int format, int imageSize, Buffer data) { - if (!(data instanceof ByteBuffer)) - throw new GdxRuntimeException("Can't use " + data.getClass().getName() - + " with this method. Use ByteBuffer. Blame LWJGL"); - GL13.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, (ByteBuffer)data); - } - - @Override - public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) { - GL11.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); - } - - @Override - public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) { - GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); - } - - @Override - public void glCullFace (int mode) { - GL11.glCullFace(mode); - } - - @Override - public void glDeleteBuffers (int n, IntBuffer buffers) { - GL15.glDeleteBuffers(buffers); - } - - @Override - public void glDeleteBuffer (int buffer) { - GL15.glDeleteBuffers(buffer); - } - - @Override - public void glDeleteFramebuffers (int n, IntBuffer framebuffers) { - EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers); - } - - @Override - public void glDeleteFramebuffer (int framebuffer) { - EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffer); - } - - @Override - public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers) { - EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers); - } - - @Override - public void glDeleteRenderbuffer (int renderbuffer) { - EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffer); - } - - @Override - public void glDeleteTextures (int n, IntBuffer textures) { - GL11.glDeleteTextures(textures); - } - - @Override - public void glDeleteTexture (int texture) { - GL11.glDeleteTextures(texture); - } - - @Override - public void glDepthFunc (int func) { - GL11.glDepthFunc(func); - } - - @Override - public void glDepthMask (boolean flag) { - GL11.glDepthMask(flag); - } - - @Override - public void glDepthRangef (float zNear, float zFar) { - GL11.glDepthRange(zNear, zFar); - } - - @Override - public void glDisable (int cap) { - GL11.glDisable(cap); - } - - @Override - public void glDrawArrays (int mode, int first, int count) { - GL11.glDrawArrays(mode, first, count); - } - - @Override - public void glDrawElements (int mode, int count, int type, Buffer indices) { - if (indices instanceof ShortBuffer && type == GL11.GL_UNSIGNED_SHORT) - GL11.glDrawElements(mode, (ShortBuffer)indices); - else if (indices instanceof ByteBuffer && type == GL11.GL_UNSIGNED_SHORT) - GL11.glDrawElements(mode, ((ByteBuffer)indices).asShortBuffer()); - else if (indices instanceof ByteBuffer && type == GL11.GL_UNSIGNED_BYTE) - GL11.glDrawElements(mode, (ByteBuffer)indices); - else - throw new GdxRuntimeException("Can't use " + indices.getClass().getName() - + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL"); - } - - @Override - public void glEnable (int cap) { - GL11.glEnable(cap); - } - - @Override - public void glFinish () { - GL11.glFinish(); - } - - @Override - public void glFlush () { - GL11.glFlush(); - } - - @Override - public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer) { - EXTFramebufferObject.glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); - } - - @Override - public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level) { - EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); - } - - @Override - public void glFrontFace (int mode) { - GL11.glFrontFace(mode); - } - - @Override - public void glGenBuffers (int n, IntBuffer buffers) { - GL15.glGenBuffers(buffers); - } - - @Override - public int glGenBuffer () { - return GL15.glGenBuffers(); - } - - @Override - public void glGenFramebuffers (int n, IntBuffer framebuffers) { - EXTFramebufferObject.glGenFramebuffersEXT(framebuffers); - } - - @Override - public int glGenFramebuffer () { - return EXTFramebufferObject.glGenFramebuffersEXT(); - } - - @Override - public void glGenRenderbuffers (int n, IntBuffer renderbuffers) { - EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers); - } - - @Override - public int glGenRenderbuffer () { - return EXTFramebufferObject.glGenRenderbuffersEXT(); - } - - @Override - public void glGenTextures (int n, IntBuffer textures) { - GL11.glGenTextures(textures); - } - - @Override - public int glGenTexture () { - return GL11.glGenTextures(); - } - - @Override - public void glGenerateMipmap (int target) { - EXTFramebufferObject.glGenerateMipmapEXT(target); - } - - @Override - public void glGetBooleanv (int pname, Buffer params) { - GL11.glGetBooleanv(pname, (ByteBuffer)params); - } - - @Override - public void glGetBufferParameteriv (int target, int pname, IntBuffer params) { - GL15.glGetBufferParameteriv(target, pname, params); - } - - @Override - public int glGetError () { - return GL11.glGetError(); - } - - @Override - public void glGetFloatv (int pname, FloatBuffer params) { - GL11.glGetFloatv(pname, params); - } - - @Override - public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params) { - EXTFramebufferObject.glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); - } - - @Override - public void glGetIntegerv (int pname, IntBuffer params) { - GL11.glGetIntegerv(pname, params); - } - - @Override - public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params) { - EXTFramebufferObject.glGetRenderbufferParameterivEXT(target, pname, params); - } - - @Override - public String glGetString (int name) { - return GL11.glGetString(name); - } - - @Override - public void glGetTexParameterfv (int target, int pname, FloatBuffer params) { - GL11.glGetTexParameterfv(target, pname, params); - } - - @Override - public void glGetTexParameteriv (int target, int pname, IntBuffer params) { - GL11.glGetTexParameteriv(target, pname, params); - } - - @Override - public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer) { - throw new UnsupportedOperationException("unsupported, won't implement"); - } - - @Override - public void glHint (int target, int mode) { - GL11.glHint(target, mode); - } - - @Override - public boolean glIsBuffer (int buffer) { - return GL15.glIsBuffer(buffer); - } - - @Override - public boolean glIsEnabled (int cap) { - return GL11.glIsEnabled(cap); - } - - @Override - public boolean glIsFramebuffer (int framebuffer) { - return EXTFramebufferObject.glIsFramebufferEXT(framebuffer); - } - - @Override - public boolean glIsRenderbuffer (int renderbuffer) { - return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer); - } - - @Override - public boolean glIsTexture (int texture) { - return GL11.glIsTexture(texture); - } - - @Override - public void glLineWidth (float width) { - GL11.glLineWidth(width); - } - - @Override - public void glPixelStorei (int pname, int param) { - GL11.glPixelStorei(pname, param); - } - - @Override - public void glPolygonOffset (float factor, float units) { - GL11.glPolygonOffset(factor, units); - } - - @Override - public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) { - if (pixels instanceof ByteBuffer) - GL11.glReadPixels(x, y, width, height, format, type, (ByteBuffer)pixels); - else if (pixels instanceof ShortBuffer) - GL11.glReadPixels(x, y, width, height, format, type, (ShortBuffer)pixels); - else if (pixels instanceof IntBuffer) - GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer)pixels); - else if (pixels instanceof FloatBuffer) - GL11.glReadPixels(x, y, width, height, format, type, (FloatBuffer)pixels); - else - throw new GdxRuntimeException("Can't use " + pixels.getClass().getName() - + " with this method. Use ByteBuffer, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL"); - } - - @Override - public void glRenderbufferStorage (int target, int internalformat, int width, int height) { - EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height); - } - - @Override - public void glSampleCoverage (float value, boolean invert) { - GL13.glSampleCoverage(value, invert); - } - - @Override - public void glScissor (int x, int y, int width, int height) { - GL11.glScissor(x, y, width, height); - } - - @Override - public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) { - throw new UnsupportedOperationException("unsupported, won't implement"); - } - - @Override - public void glStencilFunc (int func, int ref, int mask) { - GL11.glStencilFunc(func, ref, mask); - } - - @Override - public void glStencilMask (int mask) { - GL11.glStencilMask(mask); - } - - @Override - public void glStencilOp (int fail, int zfail, int zpass) { - GL11.glStencilOp(fail, zfail, zpass); - } - - @Override - public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, - Buffer pixels) { - if (pixels == null) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)null); - else if (pixels instanceof ByteBuffer) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)pixels); - else if (pixels instanceof ShortBuffer) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ShortBuffer)pixels); - else if (pixels instanceof IntBuffer) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (IntBuffer)pixels); - else if (pixels instanceof FloatBuffer) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (FloatBuffer)pixels); - else if (pixels instanceof DoubleBuffer) - GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (DoubleBuffer)pixels); - else - throw new GdxRuntimeException("Can't use " + pixels.getClass().getName() - + " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL"); - } - - @Override - public void glTexParameterf (int target, int pname, float param) { - // LwjglGraphics.major is should to be 1 if we are in LwjglGL10. - if(Gdx.graphics.getGLVersion().getMinorVersion() < 2 && param == GL12.GL_CLAMP_TO_EDGE) param = GL11.GL_CLAMP; - GL11.glTexParameterf(target, pname, param); - } - - @Override - public void glTexParameterfv (int target, int pname, FloatBuffer params) { - GL11.glTexParameterfv(target, pname, params); - } - - @Override - public void glTexParameteri (int target, int pname, int param) { - GL11.glTexParameteri(target, pname, param); - } - - @Override - public void glTexParameteriv (int target, int pname, IntBuffer params) { - GL11.glTexParameteriv(target, pname, params); - } - - @Override - public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, - Buffer pixels) { - if (pixels instanceof ByteBuffer) - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ByteBuffer)pixels); - else if (pixels instanceof ShortBuffer) - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ShortBuffer)pixels); - else if (pixels instanceof IntBuffer) - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (IntBuffer)pixels); - else if (pixels instanceof FloatBuffer) - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (FloatBuffer)pixels); - else if (pixels instanceof DoubleBuffer) - GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (DoubleBuffer)pixels); - else - throw new GdxRuntimeException("Can't use " + pixels.getClass().getName() - + " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL"); - } - - @Override - public void glDrawElements (int mode, int count, int type, int indices) { - GL11.glDrawElements(mode, count, type, indices); - } - - @Override - public void glAlphaFunc (int func, float ref) { - GL11.glAlphaFunc(func, ref); - } - - @Override - public void glClientActiveTexture (int texture) { - try { - GL13.glClientActiveTexture(texture); - } catch (Throwable ex) { - - } - } - - @Override - public void glColor4f (float red, float green, float blue, float alpha) { - GL11.glColor4f(red, green, blue, alpha); - } - - @Override - public void glColorPointer (int size, int type, int stride, Buffer pointer) { - if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) - GL11.glColorPointer(size, type, stride, (FloatBuffer)pointer); - else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) - GL11.glColorPointer(size, type, stride, ((ByteBuffer)pointer).asFloatBuffer()); - else if (pointer instanceof ByteBuffer && type == GL11.GL_UNSIGNED_BYTE) - GL11.glColorPointer(size, type, stride, (ByteBuffer)pointer); - else - throw new GdxRuntimeException("Can't use " + pointer.getClass().getName() - + " with this method, use FloatBuffer or ByteBuffer. blame LWJGL"); - } - - @Override - public void glDisableClientState (int array) { - GL11.glDisableClientState(array); - } - - @Override - public void glEnableClientState (int array) { - GL11.glEnableClientState(array); - } - - @Override - public void glFogf (int pname, float param) { - GL11.glFogf(pname, param); - } - - @Override - public void glFogfv (int pname, FloatBuffer params) { - GL11.glFogfv(pname, params); - } - - @Override - public void glFrustumf (float left, float right, float bottom, float top, float zNear, float zFar) { - GL11.glFrustum(left, right, bottom, top, zNear, zFar); - } - - @Override - public void glLightModelf (int pname, float param) { - GL11.glLightModelf(pname, param); - } - - @Override - public void glLightModelfv (int pname, FloatBuffer params) { - GL11.glLightModelfv(pname, params); - } - - @Override - public void glLightf (int light, int pname, float param) { - GL11.glLightf(light, pname, param); - } - - @Override - public void glLightfv (int light, int pname, FloatBuffer params) { - GL11.glLightfv(light, pname, params); - } - - @Override - public void glLoadIdentity () { - GL11.glLoadIdentity(); - } - - @Override - public void glLoadMatrixf (FloatBuffer m) { - GL11.glLoadMatrixf(m); - } - - @Override - public void glLogicOp (int opcode) { - GL11.glLogicOp(opcode); - } - - @Override - public void glMaterialf (int face, int pname, float param) { - GL11.glMaterialf(face, pname, param); - } - - @Override - public void glMaterialfv (int face, int pname, FloatBuffer params) { - GL11.glMaterialfv(face, pname, params); - } - - @Override - public void glMatrixMode (int mode) { - GL11.glMatrixMode(mode); - } - - @Override - public void glMultMatrixf (FloatBuffer m) { - GL11.glMultMatrixf(m); - } - - @Override - public void glMultiTexCoord4f (int target, float s, float t, float r, float q) { - GL13.glMultiTexCoord4f(target, s, t, r, q); - } - - @Override - public void glNormal3f (float nx, float ny, float nz) { - GL11.glNormal3f(nx, ny, nz); - } - - @Override - public void glNormalPointer (int type, int stride, Buffer pointer) { - if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) - GL11.glNormalPointer(type, stride, (FloatBuffer)pointer); - else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) - GL11.glNormalPointer(type, stride, ((ByteBuffer)pointer).asFloatBuffer()); - else if (pointer instanceof ByteBuffer && type == GL11.GL_BYTE) - GL11.glNormalPointer(type, stride, (ByteBuffer)pointer); - else - throw new GdxRuntimeException("Can't use " + pointer.getClass().getName() - + " with this method. GL10.GL_SHORT not supported. Use FloatBuffer instead. Blame LWJGL"); - } - - @Override - public void glOrthof (float left, float right, float bottom, float top, float zNear, float zFar) { - GL11.glOrtho(left, right, bottom, top, zNear, zFar); - } - - @Override - public void glPointSize (float size) { - GL11.glPointSize(size); - } - - @Override - public void glPopMatrix () { - GL11.glPopMatrix(); - } - - @Override - public void glPushMatrix () { - GL11.glPushMatrix(); - } - - @Override - public void glRotatef (float angle, float x, float y, float z) { - GL11.glRotatef(angle, x, y, z); - } - - @Override - public void glScalef (float x, float y, float z) { - GL11.glScalef(x, y, z); - } - - @Override - public void glShadeModel (int mode) { - GL11.glShadeModel(mode); - } - - @Override - public void glTexCoordPointer (int size, int type, int stride, Buffer pointer) { - if (pointer instanceof ShortBuffer && type == GL11.GL_SHORT) - GL11.glTexCoordPointer(size, type, stride, (ShortBuffer)pointer); - else if (pointer instanceof ByteBuffer && type == GL11.GL_SHORT) - GL11.glTexCoordPointer(size, type, stride, ((ByteBuffer)pointer).asShortBuffer()); - else if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) - GL11.glTexCoordPointer(size, type, stride, (FloatBuffer)pointer); - else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) - GL11.glTexCoordPointer(size, type, stride, ((ByteBuffer)pointer).asFloatBuffer()); - else - throw new GdxRuntimeException( - "Can't use " - + pointer.getClass().getName() - + " with this method. Use ShortBuffer or FloatBuffer or ByteBuffer instead with GL_FLOAT or GL_SHORT. GL_BYTE is not supported. Blame LWJGL"); - } - - @Override - public void glTexEnvf (int target, int pname, float param) { - GL11.glTexEnvf(target, pname, param); - } - - @Override - public void glTexEnvfv (int target, int pname, FloatBuffer params) { - GL11.glTexEnvfv(target, pname, params); - } - - @Override - public void glTranslatef (float x, float y, float z) { - GL11.glTranslatef(x, y, z); - } - - @Override - public void glVertexPointer (int size, int type, int stride, Buffer pointer) { - if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) - GL11.glVertexPointer(size, type, stride, ((FloatBuffer)pointer)); - else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) - GL11.glVertexPointer(size, type, stride, ((ByteBuffer)pointer).asFloatBuffer()); - else - throw new GdxRuntimeException("Can't use " + pointer.getClass().getName() - + " with this method. Use FloatBuffer or ByteBuffers with GL10.GL_FLOAT instead. Blame LWJGL"); - } - - @Override - public void glViewport (int x, int y, int width, int height) { - GL11.glViewport(x, y, width, height); - } - - @Override - public void glDeleteTextures (int n, int[] textures, int offset) { - GL11.glDeleteTextures(toBuffer(n, textures, offset)); - } - - @Override - public void glFogfv (int pname, float[] params, int offset) { - GL11.glFogfv(pname, toBuffer(params, offset)); - } - - @Override - public void glGenTextures (int n, int[] textures, int offset) { - for (int i = offset; i < offset + n; i++) - textures[i] = GL11.glGenTextures(); - } - - IntBuffer getBuffer = BufferUtils.createIntBuffer(100); - @Override - public void glGetIntegerv (int pname, int[] params, int offset) { - GL11.glGetIntegerv(pname, getBuffer); - // FIXME Yeah, so. This sucks as well :D LWJGL does not set pos/lim. - for (int i = offset, j = 0; i < params.length; i++, j++) { - if (j == getBuffer.capacity()) return; - params[i] = getBuffer.get(j); - } - } - - @Override - public void glLightModelfv (int pname, float[] params, int offset) { - GL11.glLightModelfv(pname, toBuffer(params, offset)); - } - - @Override - public void glLightfv (int light, int pname, float[] params, int offset) { - GL11.glLightfv(light, pname, toBuffer(params, offset)); - } - - @Override - public void glLoadMatrixf (float[] m, int offset) { - GL11.glLoadMatrixf(toBuffer(m, offset)); - } - - @Override - public void glMaterialfv (int face, int pname, float[] params, int offset) { - GL11.glMaterialfv(face, pname, toBuffer(params, offset)); - } - - @Override - public void glMultMatrixf (float[] m, int offset) { - GL11.glMultMatrixf(toBuffer(m, offset)); - } - - @Override - public void glTexEnvfv (int target, int pname, float[] params, int offset) { - GL11.glTexEnvfv(target, pname, toBuffer(params, offset)); - } - - @Override - public void glPolygonMode (int face, int mode) { - GL11.glPolygonMode(face, mode); - } - - @Override - public void glDeleteBuffers (int n, int[] buffers, int offset) { - GL15.glDeleteBuffers(toBuffer(n, buffers, offset)); - } - - @Override - public void glGenBuffers (int n, int[] buffers, int offset) { - for (int i = offset; i < offset + n; i++) - buffers[i] = GL15.glGenBuffers(); - } - - @Override - public void glGetLightfv (int light, int pname, FloatBuffer params) { - GL11.glGetLightfv(light, pname, params); - } - - @Override - public void glGetMaterialfv (int face, int pname, FloatBuffer params) { - GL11.glGetMaterialfv(face, pname, params); - } - - @Override - public void glGetTexEnviv (int env, int pname, IntBuffer params) { - GL11.glGetTexEnviv(env, pname, params); - } - - @Override - public void glPointParameterf (int pname, float param) { - GL14.glPointParameterf(pname, param); - } - - @Override - public void glPointParameterfv (int pname, FloatBuffer params) { - GL14.glPointParameterfv(pname, params); - } - - @Override - public void glTexEnvi (int target, int pname, int param) { - GL11.glTexEnvi(target, pname, param); - } - - @Override - public void glTexEnviv (int target, int pname, int[] params, int offset) { - GL11.glTexEnviv(target, pname, toBuffer(params, offset)); - } - - @Override - public void glTexEnviv (int target, int pname, IntBuffer params) { - GL11.glTexEnviv(target, pname, params); - } - - @Override - public void glTexParameterfv (int target, int pname, float[] params, int offset) { - GL11.glTexParameterfv(target, pname, toBuffer(params, offset)); - } - - @Override - public void glTexParameteriv (int target, int pname, int[] params, int offset) { - GL11.glTexParameteriv(target, pname, toBuffer(params, offset)); - } - - @Override - public void glColorPointer (int size, int type, int stride, int pointer) { - GL11.glColorPointer(size, type, stride, pointer); - } - - @Override - public void glNormalPointer (int type, int stride, int pointer) { - GL11.glNormalPointer(type, stride, pointer); - } - - @Override - public void glTexCoordPointer (int size, int type, int stride, int pointer) { - GL11.glTexCoordPointer(size, type, stride, pointer); - } - - @Override - public void glVertexPointer (int size, int type, int stride, int pointer) { - GL11.glVertexPointer(size, type, stride, pointer); - } - - @Override - public void glBegin(int type) { - GL11.glBegin(type); - } - - @Override - public void glEnd() { - GL11.glEnd(); - } - - @Override - public void glFogi(int pname, int params) { - GL11.glFogf(pname, params); - } - - @Override - public void glBindTexture(int target, IntBuffer texture) { - GL11.glBindTexture(target, texture.get(0)); - } - - FloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(4 * 4); - @Override - public void glLoadMatrixf(float[][] m) { - matrixBuffer.clear(); - for(int i = 0; i < m.length; i++) - matrixBuffer.put(m[i]); - matrixBuffer.rewind(); - GL11.glLoadMatrixf(matrixBuffer); - } - - @Override - public void glLoadMatrix(Matrix4 m) { - matrixBuffer.clear(); - matrixBuffer.put(m.getValues()); - matrixBuffer.rewind(); - GL11.glLoadMatrixf(matrixBuffer); - } - - @Override - public void glVertex2i(int x, int y) { - GL11.glVertex2i(x, y); - } - - @Override - public void glVertex2f(float x, float y) { - GL11.glVertex2f(x, y); - } - - @Override - public void glVertex2d(double x, double y) { - GL11.glVertex2d(x, y); - } - - @Override - public void glVertex3d(double x, double y, double z) { - GL11.glVertex3d(x, y, z); - } - - @Override - public void glTexCoord2f(float s, float t) { - GL11.glTexCoord2f(s, t); - } - - @Override - public void glTexCoord2d(double s, double t) { - GL11.glTexCoord2d(s, t); - } - - @Override - public void glColor4ub(int red, int green, int blue, int alpha) { - GL11.glColor4f((red&0xFF)/255f, (green&0xFF)/255f, (blue&0xFF)/255f, (alpha&0xFF)/255f); - } - - @Override - public void glPopAttrib() { - GL11.glPopAttrib(); - } - - @Override - public void glPushAttrib(int mask) { - GL11.glPushAttrib(mask); - } - - @Override - public void glMultiTexCoord2d(int target, double s, double t) { - GL13.glMultiTexCoord2d(target, s, t); - } - - @Override - public void glReadBuffer(int mode) { - GL11.glReadBuffer(mode); - } - - @Override - public int glGenQueries() { - return 0; - } - - @Override - public void glBeginQuery(int target, int id) { - - } - - @Override - public void glEndQuery(int target) { - - } - - @Override - public int glGetQueryObjecti(int id, int pname) { - return 0; - } - - @Override - public void glDepthRange(double near_val, double far_val) { - GL11.glDepthRange(near_val, far_val); - } - - @Override - public void glDepthMask(int param) { - GL11.glDepthMask(param != GL11.GL_FALSE); - } - - @Override - public void glClipPlanef(int plane, float a, float b, float c, float d) { - GL11.glClipPlane(plane, toPlaneBufferd(a,b,c,d)); - } - - @Override - public int glGetInteger(int pname) { - return GL11.glGetInteger(pname); - } -} diff --git a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Graphics.java b/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Graphics.java deleted file mode 100644 index d393f95..0000000 --- a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Graphics.java +++ /dev/null @@ -1,728 +0,0 @@ -package ru.m210projects.Build.desktop.GLFW; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.nio.IntBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.PointerBuffer; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.glfw.GLFWErrorCallback; -import org.lwjgl.glfw.GLFWFramebufferSizeCallback; -import org.lwjgl.glfw.GLFWGammaRamp; -import org.lwjgl.glfw.GLFWImage; -import org.lwjgl.glfw.GLFWVidMode; -import org.lwjgl.glfw.GLFWVidMode.Buffer; -import org.lwjgl.glfw.GLFWWindowFocusCallback; -import org.lwjgl.opengl.GL; -import org.lwjgl.opengl.GL11; - -import com.badlogic.gdx.Application; -import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Cursor; -import com.badlogic.gdx.backends.lwjgl3.Lwjgl3NativesLoader; -import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window; -import com.badlogic.gdx.graphics.Cursor; -import com.badlogic.gdx.graphics.Cursor.SystemCursor; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.GL30; -import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.Pixmap.Format; -import com.badlogic.gdx.graphics.glutils.GLVersion; -import com.badlogic.gdx.graphics.glutils.HdpiMode; -import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.utils.GdxRuntimeException; -import com.badlogic.gdx.utils.SharedLibraryLoader; - -import ru.m210projects.Build.Architecture.BuildConfiguration; -import ru.m210projects.Build.Architecture.BuildFrame.FrameType; -import ru.m210projects.Build.Architecture.BuildGdx; -import ru.m210projects.Build.Architecture.BuildGraphics; - -public class Lwjgl3Graphics extends BuildGraphics { - - private int samples = 0; - private int r = 8, g = 8, b = 8, a = 8; // 32bit - - private static GLVersion glVersion; - private BufferFormat bufferFormat; - protected long windowHandle; - - private volatile int backBufferWidth; - private volatile int backBufferHeight; - private volatile int logicalWidth; - private volatile int logicalHeight; - private int windowPosXBeforeFullscreen; - private int windowPosYBeforeFullscreen; - private DisplayMode displayModeBeforeFullscreen = null; - - private IntBuffer tmpBuffer = BufferUtils.createIntBuffer(1); - private IntBuffer tmpBuffer2 = BufferUtils.createIntBuffer(1); - - private GLFWErrorCallback errorCallback; - - private BuildConfiguration config; - private int rate; - private boolean wasResized = false; - private boolean isActive = false; - - public Lwjgl3Graphics(BuildConfiguration config) { - Lwjgl3NativesLoader.load(); - this.config = config; - } - - private final GLFWWindowFocusCallback focusCallback = new GLFWWindowFocusCallback() { - @Override - public void invoke(long windowHandle, final boolean focused) { - BuildGdx.app.postRunnable(new Runnable() { - @Override - public void run() { - isActive = focused; - } - }); - } - }; - - private Runnable resetPollingStates; - protected void setPollingStatesCallback(Runnable handleCallback) - { - this.resetPollingStates = handleCallback; - } - - private GLFWFramebufferSizeCallback resizeCallback = new GLFWFramebufferSizeCallback() { - @Override - public void invoke(long windowHandle, final int width, final int height) { - updateFramebufferInfo(); - wasResized = true; - } - }; - - private long createGlfwWindow(BuildConfiguration config) { - GLFW.glfwDefaultWindowHints(); - GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); - GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, config.resizable ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE); - GLFW.glfwWindowHint(GLFW.GLFW_MAXIMIZED, GLFW.GLFW_FALSE); - - GLFW.glfwWindowHint(GLFW.GLFW_RED_BITS, r); - GLFW.glfwWindowHint(GLFW.GLFW_GREEN_BITS, g); - GLFW.glfwWindowHint(GLFW.GLFW_BLUE_BITS, b); - GLFW.glfwWindowHint(GLFW.GLFW_ALPHA_BITS, a); - GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, config.stencil); - GLFW.glfwWindowHint(GLFW.GLFW_DEPTH_BITS, config.depth); - GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, samples); - - if (config.useGL30) { - int gles30ContextMajorVersion = 3; - int gles30ContextMinorVersion = 2; - - GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, gles30ContextMajorVersion); - GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, gles30ContextMinorVersion); - if (SharedLibraryLoader.isMac) { - // hints mandatory on OS X for GL 3.2+ context creation, but fail on Windows if - // the - // WGL_ARB_create_context extension is not available - // see: http://www.glfw.org/docs/latest/compat.html - GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE); - GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE); - } - } - - long windowHandle = 0; - if (!config.fullscreen) { - GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, config.undecorated ? GLFW.GLFW_FALSE : GLFW.GLFW_TRUE); - windowHandle = GLFW.glfwCreateWindow(config.width, config.height, config.title, 0, 0); - - rate = getDesktopDisplayMode().refreshRate; - } else { - DisplayMode bestMode = null; - for (DisplayMode mode : getDisplayLwjglModes()) { - if (mode.width == config.width && mode.height == config.height) { - if (bestMode == null || bestMode.refreshRate < mode.refreshRate) { - bestMode = mode; - } - } - } - - if (bestMode == null) - bestMode = this.getDesktopDisplayMode(); - - GLFW.glfwWindowHint(GLFW.GLFW_REFRESH_RATE, bestMode.refreshRate); - windowHandle = GLFW.glfwCreateWindow(bestMode.width, bestMode.height, config.title, - ((Lwjgl3DisplayMode) bestMode).getMonitor(), 0); - rate = bestMode.refreshRate; - } - if (windowHandle == 0) - throw new GdxRuntimeException("Couldn't create window"); - - if (!config.fullscreen) { - if (config.x == -1 && config.y == -1) { - GLFWVidMode vidMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); - GLFW.glfwSetWindowPos(windowHandle, vidMode.width() / 2 - config.width / 2, - vidMode.height() / 2 - config.height / 2); - } else { - GLFW.glfwSetWindowPos(windowHandle, config.x, config.y); - } - } - - GLFW.glfwSetWindowFocusCallback(windowHandle, focusCallback); - GLFW.glfwSetFramebufferSizeCallback(windowHandle, resizeCallback); - - GLFW.glfwMakeContextCurrent(windowHandle); - GL.createCapabilities(); - - initiateGL(); - return windowHandle; - } - - private void initiateGL() { - String versionString = GL11.glGetString(GL11.GL_VERSION); - String vendorString = GL11.glGetString(GL11.GL_VENDOR); - String rendererString = GL11.glGetString(GL11.GL_RENDERER); - glVersion = new GLVersion(Application.ApplicationType.Desktop, versionString, vendorString, rendererString); - } - - private void updateFramebufferInfo() { - GLFW.glfwGetFramebufferSize(windowHandle, tmpBuffer, tmpBuffer2); - this.backBufferWidth = tmpBuffer.get(0); - this.backBufferHeight = tmpBuffer2.get(0); - GLFW.glfwGetWindowSize(windowHandle, tmpBuffer, tmpBuffer2); - Lwjgl3Graphics.this.logicalWidth = tmpBuffer.get(0); - Lwjgl3Graphics.this.logicalHeight = tmpBuffer2.get(0); - bufferFormat = new BufferFormat(r, g, b, a, config.depth, config.stencil, samples, false); - } - - @Override - protected void init() throws Exception { - if (!GLFW.glfwInit()) - throw new GdxRuntimeException("Unable to initialize GLFW"); - - errorCallback = GLFWErrorCallback.createPrint(System.err); - GLFW.glfwSetErrorCallback(errorCallback); - GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE); - - windowHandle = createGlfwWindow(config); - - gl10 = new Lwjgl3GL10(); - if (config.useGL30) { - Class GL30 = Class.forName("com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL30"); - Constructor LwjglGL30 = GL30.getDeclaredConstructor(); - LwjglGL30.setAccessible(true); - gl30 = (GL30) LwjglGL30.newInstance(); - this.gl20 = this.gl30; - } else { - Class GL20Class = Class.forName("com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL20"); - Constructor LwjglGL20 = GL20Class.getDeclaredConstructor(); - LwjglGL20.setAccessible(true); - gl20 = (GL20) LwjglGL20.newInstance(); - this.gl30 = null; - } - updateFramebufferInfo(); - - setUndecorated(config.borderless); - GLFW.glfwShowWindow(windowHandle); - } - - @Override - public GraphicsType getType() { - return GraphicsType.LWJGL3; - } - - @Override - protected int getRefreshRate() { - return rate; - } - - @Override - protected boolean isDirty() { - return false; - } - - @Override - protected void sync(int fps) { - GLFWSync.sync(fps); - } - - private static final long NANOS_IN_SECOND = 1000L * 1000L; - public void sleepAtLeast(long millis) throws InterruptedException { - double t0 = GLFW.glfwGetTime(); - long millisLeft = millis; - while (millisLeft > 0) { - Thread.sleep(millisLeft); - millisLeft -= ((GLFW.glfwGetTime() - t0) * NANOS_IN_SECOND); - } - } - - @Override - protected void update() { - Thread renderThread = new Thread(); - renderThread.start(); - GLFW.glfwSwapBuffers(windowHandle); - GLFW.glfwPollEvents(); - } - - @Override - protected void updateSize(int width, int height) { - if (BuildGdx.gl != null) - BuildGdx.gl.glViewport(0, 0, width, height); - } - - @Override - protected boolean wasResized() { - boolean out = wasResized; - wasResized = false; - return out; - } - - @Override - protected int getX() { - GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2); - return tmpBuffer.get(0); - } - - @Override - protected int getY() { - GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2); - return tmpBuffer2.get(0); - } - - @Override - protected boolean isActive() { - return isActive; - } - - @Override - protected boolean isCloseRequested() { - return GLFW.glfwWindowShouldClose(windowHandle); - } - - @Override - protected void dispose() { - GLFW.glfwSetErrorCallback(null); - GLFW.glfwSetWindowFocusCallback(windowHandle, null); - GLFW.glfwSetFramebufferSizeCallback(windowHandle, null); - GLFW.glfwDestroyWindow(windowHandle); - - this.focusCallback.free(); - this.resizeCallback.free(); - this.errorCallback.free(); - - try { - Method disposeCursor = Lwjgl3Cursor.class.getDeclaredMethod("disposeSystemCursors"); - disposeCursor.setAccessible(true); - disposeCursor.invoke(disposeCursor); - } catch(Exception e) { - e.printStackTrace(); - } - - GLFW.glfwTerminate(); - } - - @Override - public int getWidth() { - if (config.hdpiMode == HdpiMode.Pixels) { - return backBufferWidth; - } else { - return logicalWidth; - } - } - - @Override - public int getHeight() { - if (config.hdpiMode == HdpiMode.Pixels) { - return backBufferHeight; - } else { - return logicalHeight; - } - } - - @Override - public void setFramesPerSecond(int fps) { - config.foregroundFPS = fps; - config.backgroundFPS = fps; - } - - @Override - public FrameType getFrameType() { - return FrameType.GL; - } - - @Override - public GLVersion getGLVersion() { - return glVersion; - } - - @Override - public boolean supportsDisplayModeChange() { - return true; - } - - @Override - public Monitor getPrimaryMonitor() { - return toLwjgl3Monitor(GLFW.glfwGetPrimaryMonitor()); - } - - @Override - public Monitor getMonitor() { - Monitor[] monitors = getMonitors(); - Monitor result = monitors[0]; - - GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2); - int windowX = tmpBuffer.get(0); - int windowY = tmpBuffer2.get(0); - GLFW.glfwGetWindowSize(windowHandle, tmpBuffer, tmpBuffer2); - int windowWidth = tmpBuffer.get(0); - int windowHeight = tmpBuffer2.get(0); - int overlap; - int bestOverlap = 0; - - for (Monitor monitor : monitors) { - DisplayMode mode = getDisplayMode(monitor); - - overlap = Math.max(0, - Math.min(windowX + windowWidth, monitor.virtualX + mode.width) - - Math.max(windowX, monitor.virtualX)) - * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height) - - Math.max(windowY, monitor.virtualY)); - - if (bestOverlap < overlap) { - bestOverlap = overlap; - result = monitor; - } - } - return result; - } - - @Override - public Monitor[] getMonitors() { - PointerBuffer glfwMonitors = GLFW.glfwGetMonitors(); - Monitor[] monitors = new Monitor[glfwMonitors.limit()]; - for (int i = 0; i < glfwMonitors.limit(); i++) { - monitors[i] = toLwjgl3Monitor(glfwMonitors.get(i)); - } - return monitors; - } - - @Override - public DisplayMode[] getDisplayModes() { - return getDisplayLwjglModes(getMonitor()); - } - - @Override - public DisplayMode[] getDisplayModes(Monitor monitor) { - return getDisplayLwjglModes(monitor); - } - - @Override - public DisplayMode getDisplayMode() { - return getDisplayMode(getMonitor()); - } - - @Override - public DisplayMode getDesktopDisplayMode() { - return getDisplayLwjglMode(); - } - - @Override - public DisplayMode getDisplayMode(Monitor monitor) { - return getDisplayLwjglMode(monitor); - } - - @Override - public boolean setFullscreenMode(DisplayMode displayMode) { - if(resetPollingStates != null) - resetPollingStates.run(); - Lwjgl3DisplayMode newMode = (Lwjgl3DisplayMode) displayMode; - if (isFullscreen()) { - Lwjgl3DisplayMode currentMode = (Lwjgl3DisplayMode) getDisplayMode(); - if (currentMode.getMonitor() == newMode.getMonitor() && currentMode.refreshRate == newMode.refreshRate) { - // same monitor and refresh rate - GLFW.glfwSetWindowSize(windowHandle, newMode.width, newMode.height); - } else { - // different monitor and/or refresh rate - GLFW.glfwSetWindowMonitor(windowHandle, newMode.getMonitor(), 0, 0, newMode.width, newMode.height, - newMode.refreshRate); - } - } else { - // store window position so we can restore it when switching from fullscreen to - // windowed later - storeCurrentWindowPositionAndDisplayMode(); - - // switch from windowed to fullscreen - GLFW.glfwSetWindowMonitor(windowHandle, newMode.getMonitor(), 0, 0, newMode.width, newMode.height, - newMode.refreshRate); - } - - rate = newMode.refreshRate; - updateFramebufferInfo(); - return true; - } - - @Override - public boolean setWindowedMode(int width, int height) { - if(resetPollingStates != null) - resetPollingStates.run(); - if (!isFullscreen()) { - GLFW.glfwSetWindowSize(windowHandle, width, height); - } else { - if (displayModeBeforeFullscreen == null) { - storeCurrentWindowPositionAndDisplayMode(); - } - - GLFW.glfwSetWindowMonitor(windowHandle, 0, windowPosXBeforeFullscreen, windowPosYBeforeFullscreen, width, - height, displayModeBeforeFullscreen.refreshRate); - } - - rate = getDesktopDisplayMode().refreshRate; - updateFramebufferInfo(); - return true; - } - - @Override - public void setTitle(String title) { - if (title == null) - title = ""; - GLFW.glfwSetWindowTitle(windowHandle, title); - } - - @Override - public void setUndecorated(boolean undecorated) { - this.config.undecorated = undecorated; - GLFW.glfwSetWindowAttrib(windowHandle, GLFW.GLFW_DECORATED, undecorated ? GLFW.GLFW_FALSE : GLFW.GLFW_TRUE); - } - - @Override - public void setResizable(boolean resizable) { - this.config.resizable = resizable; - GLFW.glfwSetWindowAttrib(windowHandle, GLFW.GLFW_RESIZABLE, resizable ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE); - } - - @Override - public void setVSync(boolean vsync) { - GLFW.glfwSwapInterval(vsync ? 1 : 0); - } - - @Override - public BufferFormat getBufferFormat() { - return bufferFormat; - } - - @Override - public boolean supportsExtension(String extension) { - return GLFW.glfwExtensionSupported(extension); - } - - @Override - public boolean isFullscreen() { - return GLFW.glfwGetWindowMonitor(windowHandle) != 0; - } - - @Override - public Cursor newCursor(Pixmap pixmap, int xHotspot, int yHotspot) { - try { - Constructor Lwjgl3Cursor = Class.forName("com.badlogic.gdx.backends.lwjgl3.Lwjgl3Cursor").getDeclaredConstructor(Lwjgl3Window.class, Pixmap.class, int.class, int.class); - Lwjgl3Cursor.setAccessible(true); - return (Cursor) Lwjgl3Cursor.newInstance(null, pixmap, xHotspot, yHotspot); - } catch(Exception e) { - e.printStackTrace(); - } - - return null; - } - - @Override - public void setCursor(Cursor cursor) { - try { - Field glfwCursor = Lwjgl3Cursor.class.getDeclaredField("glfwCursor"); - glfwCursor.setAccessible(true); - GLFW.glfwSetCursor(windowHandle, (Long) glfwCursor.get(cursor)); - } catch(Exception e) { - e.printStackTrace(); - } - } - - @Override - public void setSystemCursor(SystemCursor systemCursor) { - try { - Method setSystemCursor = Lwjgl3Cursor.class.getDeclaredMethod("setSystemCursor", long.class, SystemCursor.class); - setSystemCursor.setAccessible(true); - setSystemCursor.invoke(null, windowHandle, systemCursor); - } catch(Exception e) { - e.printStackTrace(); - } - } - - @Override - public Object extra(Option opt, Object... obj) { - switch(opt) - { - case GLSetConfiguration: - if(obj.length < 3) - return false; - float gamma = (Float) obj[0]; - float brightness = (Float) obj[1]; - float contrast = (Float) obj[2]; - - return setDisplayConfiguration(gamma, brightness, contrast); - case GLDefConfiguration: - return setDisplayConfiguration(1.0f, 0.0f, 1.0f); - default: - throw new UnsupportedOperationException("not implemented"); - } - } - - private boolean setDisplayConfiguration(float gamma, float brightness, float contrast) { - try { - if ( brightness < -1.0f || brightness > 1.0f ) - throw new IllegalArgumentException("Invalid brightness value"); - if ( contrast < 0.0f ) - throw new IllegalArgumentException("Invalid contrast value"); - - long monitorHandle = ((Lwjgl3Monitor) getMonitor()).monitorHandle; - GLFWGammaRamp ramp = GLFW.glfwGetGammaRamp(monitorHandle); - int rampSize = ramp.size(); - if ( rampSize == 0 ) - throw new Exception("Display configuration not supported"); - - for ( int i = 0; i < rampSize; i++ ) { - float intensity = (float) i / (rampSize - 1); - // apply gamma - float rampEntry = (float) Math.pow(intensity, gamma); - // apply brightness - rampEntry += brightness; - // apply contrast - rampEntry = (rampEntry - 0.5f) * contrast + 0.5f; - // Clamp entry to [0, 1] - if ( rampEntry > 1.0f ) - rampEntry = 1.0f; - else if ( rampEntry < 0.0f ) - rampEntry = 0.0f; - - short value = (short) (rampEntry * 65535); - - ramp.red().put(i, value); - ramp.green().put(i, value); - ramp.blue().put(i, value); - } - GLFW.glfwSetGammaRamp(monitorHandle, ramp); - } catch (Exception e) { e.printStackTrace(); return false; } - - return true; - } - - @Override - public float getPpiX() { - return getPpcX() / 0.393701f; - } - - @Override - public float getPpiY() { - return getPpcY() / 0.393701f; - } - - @Override - public float getPpcX() { - Lwjgl3Monitor monitor = (Lwjgl3Monitor) getMonitor(); - GLFW.glfwGetMonitorPhysicalSize(monitor.monitorHandle, tmpBuffer, tmpBuffer2); - int sizeX = tmpBuffer.get(0); - DisplayMode mode = getDisplayMode(); - return mode.width / (float) sizeX * 10; - } - - @Override - public float getPpcY() { - Lwjgl3Monitor monitor = (Lwjgl3Monitor) getMonitor(); - GLFW.glfwGetMonitorPhysicalSize(monitor.monitorHandle, tmpBuffer, tmpBuffer2); - int sizeY = tmpBuffer2.get(0); - DisplayMode mode = getDisplayMode(); - return mode.height / (float) sizeY * 10; - } - - private void storeCurrentWindowPositionAndDisplayMode() { - windowPosXBeforeFullscreen = getX(); - windowPosYBeforeFullscreen = getY(); - displayModeBeforeFullscreen = getDisplayMode(); - } - - public static class Lwjgl3DisplayMode extends DisplayMode { - final long monitorHandle; - - Lwjgl3DisplayMode(long monitor, int width, int height, int refreshRate, int bitsPerPixel) { - super(width, height, refreshRate, bitsPerPixel); - this.monitorHandle = monitor; - } - - public long getMonitor() { - return monitorHandle; - } - } - - public static class Lwjgl3Monitor extends Monitor { - final long monitorHandle; - - Lwjgl3Monitor(long monitor, int virtualX, int virtualY, String name) { - super(virtualX, virtualY, name); - this.monitorHandle = monitor; - } - - public long getMonitorHandle() { - return monitorHandle; - } - } - - private Lwjgl3Monitor toLwjgl3Monitor(long glfwMonitor) { - GLFW.glfwGetMonitorPos(glfwMonitor, tmpBuffer, tmpBuffer2); - int virtualX = tmpBuffer.get(0); - int virtualY = tmpBuffer2.get(0); - String name = GLFW.glfwGetMonitorName(glfwMonitor); - return new Lwjgl3Monitor(glfwMonitor, virtualX, virtualY, name); - } - - /** - * @return the currently active {@link DisplayMode} of the primary monitor - */ - private DisplayMode getDisplayLwjglMode() { - GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); - return new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(), - videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits()); - } - - /** - * @return the currently active {@link DisplayMode} of the given monitor - */ - private DisplayMode getDisplayLwjglMode(Monitor monitor) { - GLFWVidMode videoMode = GLFW.glfwGetVideoMode(((Lwjgl3Monitor) monitor).monitorHandle); - return new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor) monitor).monitorHandle, videoMode.width(), - videoMode.height(), videoMode.refreshRate(), - videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits()); - } - - /** - * @return the available {@link DisplayMode}s of the primary monitor - */ - private DisplayMode[] getDisplayLwjglModes() { - Buffer videoModes = GLFW.glfwGetVideoModes(GLFW.glfwGetPrimaryMonitor()); - DisplayMode[] result = new DisplayMode[videoModes.limit()]; - for (int i = 0; i < result.length; i++) { - GLFWVidMode videoMode = videoModes.get(i); - result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(GLFW.glfwGetPrimaryMonitor(), videoMode.width(), videoMode.height(), - videoMode.refreshRate(), videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits()); - } - return result; - } - - /** - * @return the available {@link DisplayMode}s of the given {@link Monitor} - */ - private DisplayMode[] getDisplayLwjglModes(Monitor monitor) { - Buffer videoModes = GLFW.glfwGetVideoModes(((Lwjgl3Monitor) monitor).monitorHandle); - DisplayMode[] result = new DisplayMode[videoModes.limit()]; - for (int i = 0; i < result.length; i++) { - GLFWVidMode videoMode = videoModes.get(i); - result[i] = new Lwjgl3Graphics.Lwjgl3DisplayMode(((Lwjgl3Monitor) monitor).monitorHandle, videoMode.width(), - videoMode.height(), videoMode.refreshRate(), - videoMode.redBits() + videoMode.greenBits() + videoMode.blueBits()); - } - return result; - } - -} diff --git a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Input.java b/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Input.java deleted file mode 100644 index 021d832..0000000 --- a/src/ru/m210projects/Build/desktop/GLFW/Lwjgl3Input.java +++ /dev/null @@ -1,689 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package ru.m210projects.Build.desktop.GLFW; - -import static ru.m210projects.Build.Input.Keymap.KEY_CAPSLOCK; -import static ru.m210projects.Build.Input.Keymap.KEY_PAUSE; -import static ru.m210projects.Build.Input.Keymap.KEY_SCROLLOCK; -import static ru.m210projects.Build.Input.Keymap.KEY_NUMDECIMAL; - -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; -import java.util.Arrays; - -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.OverlayLayout; -import javax.swing.SwingUtilities; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -import org.lwjgl.glfw.GLFW; -import org.lwjgl.glfw.GLFWCharCallback; -import org.lwjgl.glfw.GLFWCursorPosCallback; -import org.lwjgl.glfw.GLFWKeyCallback; -import org.lwjgl.glfw.GLFWMouseButtonCallback; -import org.lwjgl.glfw.GLFWScrollCallback; - -import com.badlogic.gdx.graphics.glutils.HdpiMode; -import com.badlogic.gdx.Input; -import com.badlogic.gdx.InputEventQueue; -import com.badlogic.gdx.InputProcessor; -import com.badlogic.gdx.utils.TimeUtils; - -import ru.m210projects.Build.Architecture.BuildFrame; -import ru.m210projects.Build.Architecture.BuildGdx; -import ru.m210projects.Build.Architecture.BuildInput; - -public class Lwjgl3Input implements BuildInput { - - private InputProcessor inputProcessor; - private final InputEventQueue eventQueue = new InputEventQueue(); - private BuildFrame frame; - private long windowHandle; - - private int mouseX, mouseY; - private int mousePressed; - private int deltaX, deltaY; - private boolean justTouched; - private int pressedKeys; - private boolean keyJustPressed; - private boolean[] justPressedKeys = new boolean[256]; - private boolean[] justPressedButtons = new boolean[5]; - private char lastCharacter; - - private GLFWKeyCallback keyCallback = new GLFWKeyCallback() { - @Override - public void invoke(long window, int key, int scancode, int action, int mods) { - switch (action) { - case GLFW.GLFW_PRESS: - key = getGdxKeyCode(key); - eventQueue.keyDown(key); - pressedKeys++; - keyJustPressed = true; - justPressedKeys[key] = true; - frame.getGraphics().requestRendering(); - lastCharacter = 0; - char character = characterForKeyCode(key); - if (character != 0) charCallback.invoke(window, character); - break; - case GLFW.GLFW_RELEASE: - pressedKeys--; - frame.getGraphics().requestRendering(); - eventQueue.keyUp(getGdxKeyCode(key)); - break; - - case GLFW.GLFW_REPEAT: - if (lastCharacter != 0) { - frame.getGraphics().requestRendering(); - eventQueue.keyTyped(lastCharacter); - } - break; - } - } - }; - - private GLFWCharCallback charCallback = new GLFWCharCallback() { - @Override - public void invoke(long window, int codepoint) { - if ((codepoint & 0xff00) == 0xf700) return; - lastCharacter = (char)codepoint; - frame.getGraphics().requestRendering(); - eventQueue.keyTyped((char)codepoint); - } - }; - - private GLFWScrollCallback scrollCallback = new GLFWScrollCallback() { - private long pauseTime = 250000000L; //250ms - private float scrollYRemainder; - private long lastScrollEventTime; - @Override - public void invoke(long window, double scrollX, double scrollY) { - frame.getGraphics().requestRendering(); - if (scrollYRemainder > 0 && scrollY < 0 || scrollYRemainder < 0 && scrollY > 0 || - TimeUtils.nanoTime() - lastScrollEventTime > pauseTime ) { - // fire a scroll event immediately: - // - if the scroll direction changes; - // - if the user did not move the wheel for more than 250ms - scrollYRemainder = 0; - int scrollAmount = (int)-Math.signum(scrollY); - eventQueue.scrolled(scrollAmount); - lastScrollEventTime = TimeUtils.nanoTime(); - } - else { - scrollYRemainder += scrollY; - while (Math.abs(scrollYRemainder) >= 1) { - int scrollAmount = (int)-Math.signum(scrollY); - eventQueue.scrolled(scrollAmount); - lastScrollEventTime = TimeUtils.nanoTime(); - scrollYRemainder += scrollAmount; - } - } - } - }; - - private GLFWCursorPosCallback cursorPosCallback = new GLFWCursorPosCallback() { - private int logicalMouseY; - private int logicalMouseX; - - @Override - public void invoke(long windowHandle, double x, double y) { - deltaX = (int) x - logicalMouseX; - deltaY = (int) y - logicalMouseY; - mouseX = logicalMouseX = (int) x; - mouseY = logicalMouseY = (int) y; - - frame.getGraphics().requestRendering(); - if (mousePressed > 0) { - eventQueue.touchDragged(mouseX, mouseY, 0); - } else { - eventQueue.mouseMoved(mouseX, mouseY); - } - } - }; - - private GLFWMouseButtonCallback mouseButtonCallback = new GLFWMouseButtonCallback() { - @Override - public void invoke(long window, int button, int action, int mods) { - int gdxButton = toGdxButton(button); - if (button != -1 && gdxButton == -1) return; - - if (action == GLFW.GLFW_PRESS) { - mousePressed++; - justTouched = true; - justPressedButtons[gdxButton] = true; - frame.getGraphics().requestRendering(); - eventQueue.touchDown(mouseX, mouseY, 0, gdxButton); - } else { - mousePressed = Math.max(0, mousePressed - 1); - frame.getGraphics().requestRendering(); - eventQueue.touchUp(mouseX, mouseY, 0, gdxButton); - } - } - - private int toGdxButton (int button) { - if (button == 0) return Buttons.LEFT; - if (button == 1) return Buttons.RIGHT; - if (button == 2) return Buttons.MIDDLE; - if (button == 3) return Buttons.BACK; - if (button == 4) return Buttons.FORWARD; - return -1; - } - }; - - @Override - public void init(BuildFrame frame) { - this.frame = frame; - Lwjgl3Graphics graphics = (Lwjgl3Graphics)frame.getGraphics(); - this.windowHandle = graphics.windowHandle; - graphics.setPollingStatesCallback(new Runnable() { - @Override - public void run() { - resetPollingStates(); - } - }); - windowHandleChanged(windowHandle); - } - - public void resetPollingStates() { - justTouched = false; - keyJustPressed = false; - Arrays.fill(justPressedKeys, false); - Arrays.fill(justPressedButtons, false); - eventQueue.setProcessor(null); - eventQueue.drain(); - } - - public void windowHandleChanged(long windowHandle) { - resetPollingStates(); - GLFW.glfwSetKeyCallback(windowHandle, keyCallback); - GLFW.glfwSetCharCallback(windowHandle, charCallback); - GLFW.glfwSetScrollCallback(windowHandle, scrollCallback); - GLFW.glfwSetCursorPosCallback(windowHandle, cursorPosCallback); - GLFW.glfwSetMouseButtonCallback(windowHandle, mouseButtonCallback); - } - - public void update() { - eventQueue.setProcessor(inputProcessor); - eventQueue.drain(); - } - - private boolean postRunnable = false; - private Runnable prepareNext = new Runnable() { - @Override - public void run() { - if(justTouched) { - justTouched = false; - Arrays.fill(justPressedButtons, false); - } - - if (keyJustPressed) { - keyJustPressed = false; - Arrays.fill(justPressedKeys, false); - } - - deltaX = 0; - deltaY = 0; - - postRunnable = false; - } - }; - - private void prepareNext() - { - if(postRunnable) return; - - BuildGdx.app.postRunnable(prepareNext); - postRunnable = true; - } - - @Override - public int getMaxPointers () { - return 1; - } - - @Override - public int getX() { - return mouseX; - } - - @Override - public int getX(int pointer) { - return pointer == 0 ? mouseX : 0; - } - - @Override - public int getDeltaX() { - if(deltaX != 0) - prepareNext(); - return deltaX; - } - - @Override - public int getDeltaX(int pointer) { - return pointer == 0 ? getDeltaX() : 0; - } - - @Override - public int getY() { - return mouseY; - } - - @Override - public int getY(int pointer) { - return pointer == 0? mouseY: 0; - } - - @Override - public int getDeltaY() { - if(deltaY != 0) - prepareNext(); - return deltaY; - } - - @Override - public int getDeltaY(int pointer) { - return pointer == 0 ? getDeltaY() : 0; - } - - @Override - public boolean isTouched() { - return GLFW.glfwGetMouseButton(windowHandle, GLFW.GLFW_MOUSE_BUTTON_1) == GLFW.GLFW_PRESS || - GLFW.glfwGetMouseButton(windowHandle, GLFW.GLFW_MOUSE_BUTTON_2) == GLFW.GLFW_PRESS || - GLFW.glfwGetMouseButton(windowHandle, GLFW.GLFW_MOUSE_BUTTON_3) == GLFW.GLFW_PRESS || - GLFW.glfwGetMouseButton(windowHandle, GLFW.GLFW_MOUSE_BUTTON_4) == GLFW.GLFW_PRESS || - GLFW.glfwGetMouseButton(windowHandle, GLFW.GLFW_MOUSE_BUTTON_5) == GLFW.GLFW_PRESS; - } - - @Override - public boolean justTouched() { - boolean out = justTouched; - if(out) - prepareNext(); - return out; - } - - @Override - public boolean isTouched(int pointer) { - return pointer == 0 ? isTouched() : false; - } - - @Override - public float getPressure () { - return getPressure(0); - } - - @Override - public float getPressure (int pointer) { - return isTouched(pointer) ? 1 : 0; - } - - @Override - public boolean isButtonPressed(int button) { - if(button >= 8) return false; - return GLFW.glfwGetMouseButton(windowHandle, button) == GLFW.GLFW_PRESS; - } - - @Override - public boolean isButtonJustPressed(int button) { - if(button < 0 || button >= justPressedButtons.length) { - return false; - } - - boolean out = justPressedButtons[button]; - if(out) - prepareNext(); - return out; - } - - @Override - public boolean isKeyPressed(int key) { - if (key == Input.Keys.ANY_KEY) - return pressedKeys > 0; - - int code; - if((code = getGlfwKeyCode(key)) == 0) return false; - - return GLFW.glfwGetKey(windowHandle, code) == GLFW.GLFW_PRESS; - } - - @Override - public boolean isKeyJustPressed(int key) { - if (key < 0 || key > 256) { - return false; - } - - boolean out = false; - if (key == Input.Keys.ANY_KEY) { - out = keyJustPressed; - } else out = justPressedKeys[key]; - if(out) - prepareNext(); - return out; - } - - @Override - public void getTextInput(final TextInputListener listener, final String title, final String text, final String hint) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run () { - JPanel panel = new JPanel(new FlowLayout()); - - JPanel textPanel = new JPanel(); - textPanel.setLayout(new OverlayLayout(textPanel)); - panel.add(textPanel); - - final JTextField textField = new JTextField(20); - textField.setText(text); - textField.setAlignmentX(0.0f); - textPanel.add(textField); - - final JLabel placeholderLabel = new JLabel(hint); - placeholderLabel.setForeground(Color.GRAY); - placeholderLabel.setAlignmentX(0.0f); - textPanel.add(placeholderLabel, 0); - - textField.getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void removeUpdate (DocumentEvent arg0) { - this.updated(); - } - - @Override - public void insertUpdate (DocumentEvent arg0) { - this.updated(); - } - - @Override - public void changedUpdate (DocumentEvent arg0) { - this.updated(); - } - - private void updated () { - if (textField.getText().length() == 0) - placeholderLabel.setVisible(true); - else - placeholderLabel.setVisible(false); - } - }); - - JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, - null); - - pane.setInitialValue(null); - pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation()); - - Border border = textField.getBorder(); - placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField))); - - JDialog dialog = pane.createDialog(null, title); - pane.selectInitialValue(); - - dialog.addWindowFocusListener(new WindowFocusListener() { - - @Override - public void windowLostFocus (WindowEvent arg0) { - } - - @Override - public void windowGainedFocus (WindowEvent arg0) { - textField.requestFocusInWindow(); - } - }); - - dialog.setModal(true); - dialog.setAlwaysOnTop(true); - dialog.setVisible(true); - dialog.dispose(); - - Object selectedValue = pane.getValue(); - - if (selectedValue != null && (selectedValue instanceof Integer) - && ((Integer)selectedValue).intValue() == JOptionPane.OK_OPTION) { - listener.input(textField.getText()); - } else { - listener.canceled(); - } - - } - }); - } - - @Override - public long getCurrentEventTime() { - // queue sets its event time for each event dequeued/processed - return eventQueue.getCurrentEventTime(); - } - - @Override - public void setInputProcessor(InputProcessor processor) { - this.inputProcessor = processor; - } - - @Override - public InputProcessor getInputProcessor() { - return inputProcessor; - } - - @Override - public void setCursorCatched(boolean catched) { - GLFW.glfwSetInputMode(windowHandle, GLFW.GLFW_CURSOR, catched ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL); - } - - @Override - public boolean isCursorCatched() { - return GLFW.glfwGetInputMode(windowHandle, GLFW.GLFW_CURSOR) == GLFW.GLFW_CURSOR_DISABLED; - } - - @Override - public void setCursorPosition(int x, int y) { - if(frame.getConfig().hdpiMode == HdpiMode.Pixels) { - float xScale = frame.getGraphics().getLogicalWidth() / (float)frame.getGraphics().getBackBufferWidth(); - float yScale = frame.getGraphics().getLogicalHeight() / (float)frame.getGraphics().getBackBufferHeight(); - x = (int)(x * xScale); - y = (int)(y * yScale); - } - mouseX = x; - mouseY = y; - GLFW.glfwSetCursorPos(windowHandle, x, y); - } - - private char characterForKeyCode (int key) { - // Map certain key codes to character codes. - switch (key) { - case Keys.BACKSPACE: - return 8; - case Keys.TAB: - return '\t'; - case Keys.FORWARD_DEL: - return 127; - case Keys.ENTER: - return '\n'; - } - return 0; - } - - protected int getGdxKeyCode (int lwjglKeyCode) { - switch (lwjglKeyCode) { - default: - return com.badlogic.gdx.backends.lwjgl3.Lwjgl3Input.getGdxKeyCode(lwjglKeyCode); - } - } - - protected int getGlfwKeyCode (int gdxKeyCode) { - switch (gdxKeyCode) { - case KEY_PAUSE: - return 0; //Keyboard.KEY_PAUSE; - case KEY_CAPSLOCK: - return 0; //return Keyboard.KEY_CAPITAL; - case KEY_SCROLLOCK: - return 0; //return Keyboard.KEY_SCROLL; - case KEY_NUMDECIMAL: - return 0; //return Keyboard.KEY_DECIMAL; - default: - return com.badlogic.gdx.backends.lwjgl3.Lwjgl3Input.getGlfwKeyCode(gdxKeyCode); - } - } - - @Override - public void processEvents() { - } - - @Override - public void processMessages() { - } - - @Override - public boolean cursorHandler() { - // TODO Auto-generated method stub - return false; - } - - @Override - public int getDWheel() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void dispose() { - keyCallback.free(); - charCallback.free(); - scrollCallback.free(); - cursorPosCallback.free(); - mouseButtonCallback.free(); - } - - // -------------------------------------------------------------------------- - // -------------------------- Nothing to see below this line except for stubs - // -------------------------------------------------------------------------- - @Override - public void setCatchBackKey(boolean catchBack) { - } - - @Override - public boolean isCatchBackKey() { - return false; - } - - @Override - public void setCatchMenuKey(boolean catchMenu) { - } - - @Override - public boolean isCatchMenuKey() { - return false; - } - - @Override - public void setCatchKey (int keycode, boolean catchKey) { - - } - - @Override - public boolean isCatchKey (int keycode) { - return false; - } - - @Override - public float getAccelerometerX() { - return 0; - } - - @Override - public float getAccelerometerY() { - return 0; - } - - @Override - public float getAccelerometerZ() { - return 0; - } - - @Override - public boolean isPeripheralAvailable(Peripheral peripheral) { - return peripheral == Peripheral.HardwareKeyboard; - } - - @Override - public int getRotation() { - return 0; - } - - @Override - public Orientation getNativeOrientation() { - return Orientation.Landscape; - } - - @Override - public void setOnscreenKeyboardVisible(boolean visible) { - } - - @Override - public void vibrate(int milliseconds) { - } - - @Override - public void vibrate(long[] pattern, int repeat) { - } - - @Override - public void cancelVibrate() { - } - - @Override - public float getAzimuth() { - return 0; - } - - @Override - public float getPitch() { - return 0; - } - - @Override - public float getRoll() { - return 0; - } - - @Override - public void getRotationMatrix(float[] matrix) { - } - - @Override - public float getGyroscopeX() { - return 0; - } - - @Override - public float getGyroscopeY() { - return 0; - } - - @Override - public float getGyroscopeZ() { - return 0; - } -} diff --git a/src/ru/m210projects/Duke3D/Factory/DukeFactory.java b/src/ru/m210projects/Duke3D/Factory/DukeFactory.java index 3a63ad6..a970b0b 100644 --- a/src/ru/m210projects/Duke3D/Factory/DukeFactory.java +++ b/src/ru/m210projects/Duke3D/Factory/DukeFactory.java @@ -59,10 +59,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new DukeSoftware(app.pEngine); - else - return new DukePolymost(app.pEngine); + return new DukeSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Duke3D/Factory/DukePolymost.java b/src/ru/m210projects/Duke3D/Factory/DukePolymost.java deleted file mode 100644 index 7b80e8b..0000000 --- a/src/ru/m210projects/Duke3D/Factory/DukePolymost.java +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of DukeGDX. -// Copyright (C) 2019 Alexander Makarov-[M210] (m210-2007@mail.ru) -// -// DukeGDX 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 3 of the License, or -// (at your option) any later version. -// -// DukeGDX 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 DukeGDX. If not, see . - -package ru.m210projects.Duke3D.Factory; - -import static ru.m210projects.Build.Engine.globalshade; -import static ru.m210projects.Duke3D.Globals.ps; -import static ru.m210projects.Duke3D.Globals.screenpeek; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class DukePolymost extends Polymost { - public DukePolymost(Engine engine) { - super(engine, new DukeMapSettings()); - } - - @Override - protected void calc_and_apply_fog(int shade, int vis, int pal) { - // Nightvision hack - if (ps[screenpeek].heat_on != 0 && rendering == Rendering.Sprite) { - if ((tspriteptr[Rendering.Sprite.getIndex()].cstat & 2) != 0) { - vis = 0; - globalshade -= 4; - } - } - super.calc_and_apply_fog(shade, vis, pal); - } -} diff --git a/src/ru/m210projects/LSP/Factory/LSPFactory.java b/src/ru/m210projects/LSP/Factory/LSPFactory.java index 3c811fc..5442ddf 100644 --- a/src/ru/m210projects/LSP/Factory/LSPFactory.java +++ b/src/ru/m210projects/LSP/Factory/LSPFactory.java @@ -70,10 +70,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new LSPSoftware(app.pEngine); - else - return new LSPPolymost(app.pEngine); + return new LSPSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/LSP/Factory/LSPPolymost.java b/src/ru/m210projects/LSP/Factory/LSPPolymost.java deleted file mode 100644 index c787238..0000000 --- a/src/ru/m210projects/LSP/Factory/LSPPolymost.java +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of LSPGDX. -// Copyright (C) 2020 Alexander Makarov-[M210] (m210-2007@mail.ru) -// -// LSPGDX 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 3 of the License, or -// (at your option) any later version. -// -// LSPGDX 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 LSPGDX. If not, see . - -package ru.m210projects.LSP.Factory; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class LSPPolymost extends Polymost { - - public LSPPolymost(Engine engine) { - super(engine, new LSPMapSettings()); - globalfog.setFogScale(64); - } -} diff --git a/src/ru/m210projects/Launcher/desktop/Components/Settings.java b/src/ru/m210projects/Launcher/desktop/Components/Settings.java index fe11ca6..8d57ac4 100644 --- a/src/ru/m210projects/Launcher/desktop/Components/Settings.java +++ b/src/ru/m210projects/Launcher/desktop/Components/Settings.java @@ -116,7 +116,6 @@ public void itemStateChanged(ItemEvent e) { comboRenderer = new JComboBox(); comboRenderer.addItem(RenderType.Software.getName()); - comboRenderer.addItem(RenderType.Polymost.getName()); comboRenderer.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { @@ -125,9 +124,6 @@ public void itemStateChanged(ItemEvent e) { case 0: entry.getConfig().renderType = RenderType.Software; break; - case 1: - entry.getConfig().renderType = RenderType.Polymost; - break; } } } @@ -339,8 +335,6 @@ public void update() { if (cfg.renderType == RenderType.Software) comboRenderer.setSelectedIndex(0); - else if (cfg.renderType == RenderType.Polymost) - comboRenderer.setSelectedIndex(1); else { // unknown renderer cfg.renderType = RenderType.Software; diff --git a/src/ru/m210projects/Powerslave/Factory/PSFactory.java b/src/ru/m210projects/Powerslave/Factory/PSFactory.java index 1cbcec9..fc5fa6b 100644 --- a/src/ru/m210projects/Powerslave/Factory/PSFactory.java +++ b/src/ru/m210projects/Powerslave/Factory/PSFactory.java @@ -60,10 +60,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new PSSoftware(app.pEngine); - else - return new PSPolymost(app.pEngine); + return new PSSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Powerslave/Factory/PSPolymost.java b/src/ru/m210projects/Powerslave/Factory/PSPolymost.java deleted file mode 100644 index 2022679..0000000 --- a/src/ru/m210projects/Powerslave/Factory/PSPolymost.java +++ /dev/null @@ -1,129 +0,0 @@ -// This file is part of PowerslaveGDX. -// Copyright (C) 2019 Alexander Makarov-[M210] (m210-2007@mail.ru) -// -// PowerslaveGDX 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 3 of the License, or -// (at your option) any later version. -// -// PowerslaveGDX 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 PowerslaveGDX. If not, see . - -package ru.m210projects.Powerslave.Factory; - -import static ru.m210projects.Build.Engine.globalpal; -import static ru.m210projects.Build.Engine.globalvisibility; -import static ru.m210projects.Build.Engine.palookupfog; -import static ru.m210projects.Build.Pragmas.mulscale; -import static ru.m210projects.Powerslave.Globals.SectFlag; -import static ru.m210projects.Powerslave.Globals.nLocalPlayer; -import static ru.m210projects.Powerslave.Globals.nPlayerViewSect; -import static ru.m210projects.Powerslave.Light.bTorch; - -import com.badlogic.gdx.graphics.Color; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; -import ru.m210projects.Build.Render.TextureHandle.TileData.PixelFormat; -import ru.m210projects.Build.Settings.GLSettings; - -public class PSPolymost extends Polymost { - - public PSPolymost(Engine engine) { - super(engine, new PSMapSettings()); - r_parallaxskypanning = 1; - globalfog.setFogScale(64); - } - - @Override - public Color getshadefactor(int shade, int method) { - PixelFormat fmt = textureCache.getFmt(globalpicnum); - if (fmt == null || fmt != PixelFormat.Pal8) { - switch (globalpal) { - case 1: - case 5: - case 6: - shade = 0; - break; - case 4: - case 11: - shade /= 4; - break; - } - } - return super.getshadefactor(shade, method); - } - - @Override - protected void calc_and_apply_fog(int shade, int vis, int pal) { - PixelFormat fmt = textureCache.getFmt(globalpicnum); - if (fmt == null || fmt == PixelFormat.Pal8) { - super.calc_and_apply_fog(shade, vis, pal); - return; - } - - switch (globalpal) { - case 1: // nodim - case 8: // nodim - shade = -128; - break; - } - - globalfog.shade = shade; - palookupfog[5][0] = 63; // set redbrite to 0 - - if (!GLSettings.usePaletteShader.get() && (SectFlag[nPlayerViewSect[nLocalPlayer]] & 0x2000) != 0) { - palookupfog[0][0] = 0; - palookupfog[0][1] = 10; - palookupfog[0][2] = 20; - } else { - palookupfog[0][0] = 0; - palookupfog[0][1] = 0; - palookupfog[0][2] = 0; - } - - pal = 0; - switch (globalpal) { - case 2: // torch - case 3: // notorch - case 9: // torch - case 10: // notorch - globalfog.shade *= 4; - int globvis = globalvisibility; - if (bTorch == 0 && (globalpal == 3 || globalpal == 10)) { - globalfog.shade *= globalpal == 3 ? 3 : 1; - globvis *= globalpal == 3 ? 10 : 30; - } else { - globvis *= globalpal == 3 ? 3 : 4; - } - - globalfog.combvis = globvis; - if (vis != 0) - globalfog.combvis = mulscale(globvis, (vis + 16) & 0xFF, 4); - break; - case 1: // nodim - case 8: // nodim - case 6: // grnbrite - case 4: // brite - case 11: // brite - globalfog.combvis = 0; - break; - case 5: // redbrite - palookupfog[5][0] = 63; - pal = 5; - default: - globalfog.combvis = globalvisibility; - if (vis != 0) - globalfog.combvis = mulscale(globalvisibility, (vis + 16) & 0xFF, 4); - break; - } - - globalfog.pal = pal; - globalfog.calc(); - } -} diff --git a/src/ru/m210projects/Redneck/Factory/RRFactory.java b/src/ru/m210projects/Redneck/Factory/RRFactory.java index 960bb93..6b14cf3 100644 --- a/src/ru/m210projects/Redneck/Factory/RRFactory.java +++ b/src/ru/m210projects/Redneck/Factory/RRFactory.java @@ -60,10 +60,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new RRSoftware(app.pEngine); - else - return new RRPolymost(app.pEngine); + return new RRSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Redneck/Factory/RRPolymost.java b/src/ru/m210projects/Redneck/Factory/RRPolymost.java deleted file mode 100644 index 2e5a6bd..0000000 --- a/src/ru/m210projects/Redneck/Factory/RRPolymost.java +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of RedneckGDX -// Copyright (C) 2017-2019 Alexander Makarov-[M210] (m210-2007@mail.ru) -// -// RedneckGDX 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 3 of the License, or -// (at your option) any later version. -// -// RedneckGDX 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 RedneckGDX. If not, see . - -package ru.m210projects.Redneck.Factory; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class RRPolymost extends Polymost { - - public RRPolymost(Engine engine) { - super(engine, new RRMapSettings()); - } -} diff --git a/src/ru/m210projects/Tekwar/Factory/TekFactory.java b/src/ru/m210projects/Tekwar/Factory/TekFactory.java index e51f60f..6e84766 100644 --- a/src/ru/m210projects/Tekwar/Factory/TekFactory.java +++ b/src/ru/m210projects/Tekwar/Factory/TekFactory.java @@ -44,10 +44,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new TekSoftware(app.pEngine); - else - return new TekPolymost(app.pEngine); + return new TekSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Tekwar/Factory/TekPolymost.java b/src/ru/m210projects/Tekwar/Factory/TekPolymost.java deleted file mode 100644 index 6004bbd..0000000 --- a/src/ru/m210projects/Tekwar/Factory/TekPolymost.java +++ /dev/null @@ -1,200 +0,0 @@ -package ru.m210projects.Tekwar.Factory; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class TekPolymost extends Polymost { - - public TekPolymost(Engine engine) { - super(engine, new TekMapSettings()); - - globalfog.setFogScale(64); - } - - /* - * @Override public void drawoverheadmap(int cposx, int cposy, int czoom, short - * cang) { int i, j, k, l = 0, x1, y1, x2 = 0, y2 = 0, x3, y3, x4, y4, ox, oy, - * xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; int - * xrepeat, yrepeat, z1, z2, startwall, endwall; int xvect, yvect, xvect2, - * yvect2; char col; WALL wal, wal2; SPRITE spr; - * - * xvect = sintable[(-cang) & 2047] * czoom; yvect = sintable[(1536 - cang) & - * 2047] * czoom; xvect2 = mulscale(xvect, yxaspect, 16); yvect2 = - * mulscale(yvect, yxaspect, 16); - * - * // Draw red lines for (i = 0; i < numsectors; i++) { startwall = - * sector[i].wallptr; endwall = sector[i].wallptr + sector[i].wallnum; - * - * z1 = sector[i].ceilingz; z2 = sector[i].floorz; - * - * for (j = startwall; j < endwall; j++) { wal = wall[j]; k = wal.nextwall; if - * (k < 0) continue; - * - * if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0) continue; if ((k > j) && - * ((show2dwall[k >> 3] & (1 << (k & 7))) > 0)) continue; - * - * if (sector[wal.nextsector].ceilingz == z1) if (sector[wal.nextsector].floorz - * == z2) if (((wal.cstat | wall[wal.nextwall].cstat) & (16 + 32)) == 0) - * continue; - * - * col = 232; - * - * if (gViewMode == kView2DIcon) { if (sector[i].floorz != sector[i].ceilingz) - * if (sector[wal.nextsector].floorz != sector[wal.nextsector].ceilingz) if - * (((wal.cstat | wall[wal.nextwall].cstat) & (16 + 32)) == 0) if - * (sector[i].floorz == sector[wal.nextsector].floorz) continue; if - * (sector[i].floorpicnum != sector[wal.nextsector].floorpicnum) continue; if - * (sector[i].floorshade != sector[wal.nextsector].floorshade) continue; col = - * 232; } - * - * ox = wal.x - cposx; oy = wal.y - cposy; x1 = dmulscale(ox, xvect, -oy, yvect, - * 16) + (xdim << 11); y1 = dmulscale(oy, xvect2, ox, yvect2, 16) + (ydim << - * 11); - * - * wal2 = wall[wal.point2]; ox = wal2.x - cposx; oy = wal2.y - cposy; x2 = - * dmulscale(ox, xvect, -oy, yvect, 16) + (xdim << 11); y2 = dmulscale(oy, - * xvect2, ox, yvect2, 16) + (ydim << 11); - * - * drawline256(x1, y1, x2, y2, col); } } - * - * // Draw sprites k = gPlayer[screenpeek].playersprite; for (i = 0; i < - * numsectors; i++) for (j = headspritesect[i]; j >= 0; j = nextspritesect[j]) - * if ((show2dsprite[j >> 3] & (1 << (j & 7))) > 0) { spr = sprite[j]; Tile pic - * = engine.getTile(spr.picnum); if ((spr.cstat & 0x8000) != 0) continue; col = - * 56; if ((spr.cstat & 1) != 0) col = 248; if (j == k) continue; - * - * ILoc oldLoc = game.pInt.getsprinterpolate(j); sprx = spr.x; spry = spr.y; if - * (oldLoc != null) { sprx += mulscale(spr.x - oldLoc.x, smoothratio, 16); spry - * += mulscale(spr.y - oldLoc.y, smoothratio, 16); } - * - * switch (spr.cstat & 48) { case 0: ox = sprx - cposx; oy = spry - cposy; x1 = - * dmulscale(ox, xvect, -oy, yvect, 16); y1 = dmulscale(oy, xvect2, ox, yvect2, - * 16); - * - * ox = (sintable[(spr.ang + 512) & 2047] >> 7); oy = (sintable[(spr.ang) & - * 2047] >> 7); x2 = dmulscale(ox, xvect, -oy, yvect, 16); y2 = dmulscale(oy, - * xvect, ox, yvect, 16); - * - * x3 = mulscale(x2, yxaspect, 16); y3 = mulscale(y2, yxaspect, 16); - * - * drawline256(x1 - x2 + (xdim << 11), y1 - y3 + (ydim << 11), x1 + x2 + (xdim - * << 11), y1 + y3 + (ydim << 11), col); drawline256(x1 - y2 + (xdim << 11), y1 - * + x3 + (ydim << 11), x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col); - * drawline256(x1 + y2 + (xdim << 11), y1 - x3 + (ydim << 11), x1 + x2 + (xdim - * << 11), y1 + y3 + (ydim << 11), col); break; case 16: x1 = sprx; y1 = spry; - * xoff = (byte) (pic.getOffsetX() + spr.xoffset); if ((spr.cstat & 4) > 0) xoff - * = -xoff; k = spr.ang; l = spr.xrepeat; dax = sintable[k & 2047] * l; day = - * sintable[(k + 1536) & 2047] * l; l = pic.getWidth(); k = (l >> 1) + xoff; x1 - * -= mulscale(dax, k, 16); x2 = x1 + mulscale(dax, l, 16); y1 -= mulscale(day, - * k, 16); y2 = y1 + mulscale(day, l, 16); - * - * ox = x1 - cposx; oy = y1 - cposy; x1 = dmulscale(ox, xvect, -oy, yvect, 16); - * y1 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * ox = x2 - cposx; oy = y2 - cposy; x2 = dmulscale(ox, xvect, -oy, yvect, 16); - * y2 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * drawline256(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + - * (ydim << 11), col); - * - * break; case 32: if (gViewMode == kView2D) { xoff = (byte) (pic.getOffsetX() + - * spr.xoffset); yoff = (byte) (pic.getOffsetY() + spr.yoffset); if ((spr.cstat - * & 4) > 0) xoff = -xoff; if ((spr.cstat & 8) > 0) yoff = -yoff; - * - * k = spr.ang; cosang = sintable[(k + 512) & 2047]; sinang = sintable[k]; xspan - * = pic.getWidth(); xrepeat = spr.xrepeat; yspan = pic.getHeight(); yrepeat = - * spr.yrepeat; - * - * dax = ((xspan >> 1) + xoff) * xrepeat; day = ((yspan >> 1) + yoff) * yrepeat; - * x1 = sprx + dmulscale(sinang, dax, cosang, day, 16); y1 = spry + - * dmulscale(sinang, day, -cosang, dax, 16); l = xspan * xrepeat; x2 = x1 - - * mulscale(sinang, l, 16); y2 = y1 + mulscale(cosang, l, 16); l = yspan * - * yrepeat; k = -mulscale(cosang, l, 16); x3 = x2 + k; x4 = x1 + k; k = - * -mulscale(sinang, l, 16); y3 = y2 + k; y4 = y1 + k; - * - * ox = x1 - cposx; oy = y1 - cposy; x1 = dmulscale(ox, xvect, -oy, yvect, 16); - * y1 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * ox = x2 - cposx; oy = y2 - cposy; x2 = dmulscale(ox, xvect, -oy, yvect, 16); - * y2 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * ox = x3 - cposx; oy = y3 - cposy; x3 = dmulscale(ox, xvect, -oy, yvect, 16); - * y3 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * ox = x4 - cposx; oy = y4 - cposy; x4 = dmulscale(ox, xvect, -oy, yvect, 16); - * y4 = dmulscale(oy, xvect2, ox, yvect2, 16); - * - * drawline256(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + - * (ydim << 11), col); - * - * drawline256(x2 + (xdim << 11), y2 + (ydim << 11), x3 + (xdim << 11), y3 + - * (ydim << 11), col); - * - * drawline256(x3 + (xdim << 11), y3 + (ydim << 11), x4 + (xdim << 11), y4 + - * (ydim << 11), col); - * - * drawline256(x4 + (xdim << 11), y4 + (ydim << 11), x1 + (xdim << 11), y1 + - * (ydim << 11), col); - * - * } break; } } - * - * // Draw white lines for (i = 0; i < numsectors; i++) { startwall = - * sector[i].wallptr; endwall = sector[i].wallptr + sector[i].wallnum; - * - * k = -1; for (j = startwall; j < endwall; j++) { wal = wall[j]; if - * (wal.nextwall >= 0) continue; - * - * if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0) continue; - * - * if (engine.getTile(wal.picnum).getWidth() == 0) continue; if - * (engine.getTile(wal.picnum).getHeight() == 0) continue; - * - * if (j == k) { x1 = x2; y1 = y2; } else { ox = wal.x - cposx; oy = wal.y - - * cposy; x1 = dmulscale(ox, xvect, -oy, yvect, 16) + (xdim << 11); y1 = - * dmulscale(oy, xvect2, ox, yvect2, 16) + (ydim << 11); } - * - * k = wal.point2; wal2 = wall[k]; ox = wal2.x - cposx; oy = wal2.y - cposy; x2 - * = dmulscale(ox, xvect, -oy, yvect, 16) + (xdim << 11); y2 = dmulscale(oy, - * xvect2, ox, yvect2, 16) + (ydim << 11); - * - * drawline256(x1, y1, x2, y2, 239); } } - * - * // draw player for (i = connecthead; i >= 0; i = connectpoint2[i]) { SPRITE - * pPlayer = sprite[gPlayer[i].playersprite]; ILoc oldLoc = - * game.pInt.getsprinterpolate(gPlayer[i].playersprite); - * - * sprx = pPlayer.x; spry = pPlayer.y; if (oldLoc != null) { sprx += - * mulscale(pPlayer.x - oldLoc.x, smoothratio, 16); spry += mulscale(pPlayer.y - - * oldLoc.y, smoothratio, 16); } - * - * ox = sprx - cposx; oy = spry - cposy; - * - * int dx = dmulscale(ox, xvect, -oy, yvect, 16); int dy = dmulscale(oy, xvect2, - * ox, yvect2, 16); - * - * int dang = (pPlayer.ang - cang) & 0x7FF; - * - * if (i == screenpeek) { dx = 0; dy = screenpeek ^ i; dang = 0; } - * - * if (i == screenpeek /* || pGameInfo.nGameType == 1) { - * - * if (gViewMode == kView2D) { ox = (sintable[(pPlayer.ang + 512) & 2047] >> 7); - * oy = (sintable[(pPlayer.ang) & 2047] >> 7); x2 = 0; y2 = -(czoom << 5); - * - * x3 = mulscale(x2, yxaspect, 16); y3 = mulscale(y2, yxaspect, 16); - * - * col = 31; - * - * drawline256(dx - x2 + (xdim << 11), dy - y3 + (ydim << 11), dx + x2 + (xdim - * << 11), dy + y3 + (ydim << 11), col); drawline256(dx - y2 + (xdim << 11), dy - * + x3 + (ydim << 11), dx + x2 + (xdim << 11), dy + y3 + (ydim << 11), col); - * drawline256(dx + y2 + (xdim << 11), dy - x3 + (ydim << 11), dx + x2 + (xdim - * << 11), dy + y3 + (ydim << 11), col); } else { int nZoom = mulscale(yxaspect, - * czoom * (klabs((sector[pPlayer.sectnum].floorz - pPlayer.z) >> 8) + - * pPlayer.yrepeat), 16); nZoom = BClipRange(nZoom, 22000, 0x20000); int sx = - * (dx << 4) + (xdim << 15); int sy = (dy << 4) + (ydim << 15); - * - * rotatesprite(sx, sy, nZoom, (short) dang, pPlayer.picnum, pPlayer.shade, - * pPlayer.pal, (pPlayer.cstat & 2) >> 1, wx1, wy1, wx2, wy2); } } } } - */ -} diff --git a/src/ru/m210projects/Wang/Factory/WangFactory.java b/src/ru/m210projects/Wang/Factory/WangFactory.java index d9ef955..d55255e 100644 --- a/src/ru/m210projects/Wang/Factory/WangFactory.java +++ b/src/ru/m210projects/Wang/Factory/WangFactory.java @@ -43,10 +43,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new WangSoftware(app.pEngine); - else - return new WangPolymost(app.pEngine); + return new WangSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Wang/Factory/WangPolymost.java b/src/ru/m210projects/Wang/Factory/WangPolymost.java deleted file mode 100644 index f9b9f1c..0000000 --- a/src/ru/m210projects/Wang/Factory/WangPolymost.java +++ /dev/null @@ -1,32 +0,0 @@ -package ru.m210projects.Wang.Factory; - -import static ru.m210projects.Build.Engine.globalpal; -import static ru.m210projects.Build.Engine.palookupfog; -import static ru.m210projects.Wang.Game.Player; -import static ru.m210projects.Wang.Game.screenpeek; -import static ru.m210projects.Wang.Gameutils.SectorIsUnderwaterArea; -import static ru.m210projects.Wang.Palette.PALETTE_DIVE; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class WangPolymost extends Polymost { - - public WangPolymost(Engine engine) { - super(engine, new WangMapSettings()); - } - - @Override - protected void calc_and_apply_fog(int shade, int vis, int pal) { - if (globalpal == PALETTE_DIVE || pal == PALETTE_DIVE) { - palookupfog[PALETTE_DIVE][0] = 0; - palookupfog[PALETTE_DIVE][1] = 0; - if (SectorIsUnderwaterArea(Player[screenpeek].cursectnum)) - palookupfog[PALETTE_DIVE][2] = 15; - else - palookupfog[PALETTE_DIVE][2] = 0; - } - - super.calc_and_apply_fog(shade, vis, pal); - } -} diff --git a/src/ru/m210projects/Witchaven/Factory/WHFactory.java b/src/ru/m210projects/Witchaven/Factory/WHFactory.java index 8e0595c..a02d877 100644 --- a/src/ru/m210projects/Witchaven/Factory/WHFactory.java +++ b/src/ru/m210projects/Witchaven/Factory/WHFactory.java @@ -48,10 +48,7 @@ public BuildEngine engine() throws Exception { @Override public Renderer renderer(RenderType type) { - if (type == RenderType.Software) - return new WHSoftware(app.pEngine); - else - return new WHPolymost(app.pEngine); + return new WHSoftware(app.pEngine); } @Override diff --git a/src/ru/m210projects/Witchaven/Factory/WHPolymost.java b/src/ru/m210projects/Witchaven/Factory/WHPolymost.java deleted file mode 100644 index 3fdd4a3..0000000 --- a/src/ru/m210projects/Witchaven/Factory/WHPolymost.java +++ /dev/null @@ -1,46 +0,0 @@ -package ru.m210projects.Witchaven.Factory; - -import static ru.m210projects.Build.Engine.globalposx; -import static ru.m210projects.Build.Engine.globalposy; -import static ru.m210projects.Build.Engine.wall; -import static ru.m210projects.Build.Gameutils.BClipLow; -import static ru.m210projects.Build.Pragmas.klabs; -import static ru.m210projects.Witchaven.WHScreen.drawfloormirror; - -import com.badlogic.gdx.graphics.Color; - -import ru.m210projects.Build.Engine; -import ru.m210projects.Build.Render.Polymost.Polymost; - -public class WHPolymost extends Polymost { - - public WHPolymost(Engine engine) { - super(engine, new WHMapSettings()); - globalfog.setFogScale(64); - } - - @Override - public Color getshadefactor(int shade, int method) { - if (drawfloormirror) { - switch (rendering) { - case Sprite: - shade = 20; - break; - case Wall: - case MaskWall: - int wal = rendering.getIndex(); - - int dist = klabs(wall[wal].x - globalposx); - dist += klabs(wall[wal].y - globalposy); - - shade = BClipLow(dist >> 7, 20); - - break; - default: - shade = 30; - break; - } - } - return super.getshadefactor(shade, method); - } -}