From 307e118b3a936254a4464a752253c47b9e35e496 Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 22 Sep 2017 10:26:36 -0500 Subject: [PATCH] fixed mac render glitch, flipped visualizer --- .../audio/visualizer/BasicVisualizer.java | 20 +++++++++++++++---- .../graphics/meshes/TitleBarMesh.java | 8 +++----- .../ui/components/TitleBarVisualizer.java | 3 +++ .../graphics/ui/components/Visualizer.java | 4 ++++ .../rhythmbullet/desktop/DesktopLauncher.java | 3 +++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java index 586c337..45fb5a6 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java @@ -24,7 +24,8 @@ public class BasicVisualizer extends VisualizerCore { private float barHeightMultiplier; private float rotation; private Vector2 angleRot; - + private boolean flip; + public BasicVisualizer() { super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0); barHeightMultiplier = Gdx.graphics.getHeight()*0.008f; @@ -39,8 +40,7 @@ public class BasicVisualizer extends VisualizerCore { angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation)); textures = new Texture[barCount]; bars = new Sprite[barCount]; - - + for (int i = 0; i < textures.length; i++) { textures[i] = new Texture(pixmap); bars[i] = new Sprite(textures[i]); @@ -108,7 +108,11 @@ public class BasicVisualizer extends VisualizerCore { for (int i = 0; i < bars.length; i++) { barSpace = i*(barWidth+spaceBetweenBars); - bars[i].setRotation(rotation); + if (flip) { + bars[i].setRotation(rotation+180); + } else { + bars[i].setRotation(rotation); + } bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y); } } @@ -128,4 +132,12 @@ public class BasicVisualizer extends VisualizerCore { public void setRotation(float rotation) { this.rotation = rotation; } + + public void flip() { + flip = flip ? false : true; + } + + public boolean isFlipped() { + return flip; + } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/meshes/TitleBarMesh.java b/core/src/zero1hd/rhythmbullet/graphics/meshes/TitleBarMesh.java index 51b46c4..1a28a31 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/meshes/TitleBarMesh.java +++ b/core/src/zero1hd/rhythmbullet/graphics/meshes/TitleBarMesh.java @@ -81,24 +81,21 @@ public class TitleBarMesh implements Disposable { verts[idx++] = c; } - private void flush() { + public void flush() { if (idx != 0) { mesh.setVertices(verts); Gdx.gl.glDepthMask(false); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); - + int vertCount = idx/TOTAL_VARS; cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); shader.begin(); - shader.setUniformMatrix("u_projTrans", cam.combined); - mesh.render(shader, GL20.GL_TRIANGLE_FAN, 0, vertCount); - shader.end(); Gdx.gl.glDepthMask(true); @@ -110,5 +107,6 @@ public class TitleBarMesh implements Disposable { @Override public void dispose() { mesh.dispose(); + shader.dispose(); } } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java index 567cb7f..2ce8709 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/TitleBarVisualizer.java @@ -28,6 +28,7 @@ public class TitleBarVisualizer extends Group implements Disposable { hvisual.setWidth(getWidth()); hvisual.setHeight(Gdx.graphics.getHeight()*0.3f); + hvisual.getVis().flip(); } @Override @@ -38,6 +39,8 @@ public class TitleBarVisualizer extends Group implements Disposable { @Override public void draw(Batch batch, float parentAlpha) { background.draw(); + batch.end(); + batch.begin(); super.draw(batch, parentAlpha); } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java index 40fff43..eea377b 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/Visualizer.java @@ -63,4 +63,8 @@ public class Visualizer extends Widget { public boolean isUpdatePositioning() { return updatePositioning; } + + public BasicVisualizer getVis() { + return vis; + } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java index 81bcfdc..fbf0a66 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java @@ -10,6 +10,9 @@ public class DesktopLauncher { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Rhythm Bullet"; config.resizable = false; + config.allowSoftwareMode = true; + config.useHDPI = true; + config.vSyncEnabled = true; new LwjglApplication(new RhythmBullet(), config); } }