From b1b1664e1118704f8d70643b6c5d57c63f09fbff Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Mon, 8 Jun 2015 16:42:54 -0400 Subject: [PATCH] Follow-up to #91. Pass the border color into CurveRenderState instead of determining it there; store the color as a static field in Curve (since it shouldn't change per-beatmap). Also removed the leftover FrameBufferCache warning from #64. Signed-off-by: Jeffrey Han --- .../opsu/objects/curves/Curve.java | 9 +++++++-- .../opsu/render/CurveRenderState.java | 19 +++++++------------ .../opsu/render/FrameBufferCache.java | 6 ------ src/itdelatrisu/opsu/states/Game.java | 3 ++- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/itdelatrisu/opsu/objects/curves/Curve.java b/src/itdelatrisu/opsu/objects/curves/Curve.java index 14217f07..1ae526ab 100644 --- a/src/itdelatrisu/opsu/objects/curves/Curve.java +++ b/src/itdelatrisu/opsu/objects/curves/Curve.java @@ -39,6 +39,9 @@ public abstract class Curve { /** Points generated along the curve should be spaced this far apart. */ protected static float CURVE_POINTS_SEPERATION = 5; + /** The curve border color. */ + private static Color borderColor; + /** Whether OpenGL 3.0 is supported. */ private static boolean openGL30 = false; @@ -77,8 +80,10 @@ public abstract class Curve { * @param width the container width * @param height the container height * @param circleSize the circle size + * @param borderColor the curve border color */ - public static void init(int width, int height, float circleSize) { + public static void init(int width, int height, float circleSize, Color borderColor) { + Curve.borderColor = borderColor; openGL30 = GLContext.getCapabilities().OpenGL30; if (openGL30) CurveRenderState.init(width, height, circleSize); @@ -117,7 +122,7 @@ public abstract class Curve { else { if (renderState == null) renderState = new CurveRenderState(hitObject); - renderState.draw(color, curve); + renderState.draw(color, borderColor, curve); } } diff --git a/src/itdelatrisu/opsu/render/CurveRenderState.java b/src/itdelatrisu/opsu/render/CurveRenderState.java index 1af760b8..287ebd63 100644 --- a/src/itdelatrisu/opsu/render/CurveRenderState.java +++ b/src/itdelatrisu/opsu/render/CurveRenderState.java @@ -18,9 +18,7 @@ package itdelatrisu.opsu.render; import itdelatrisu.opsu.GameImage; -import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Utils; -import itdelatrisu.opsu.audio.MusicController; import itdelatrisu.opsu.beatmap.HitObject; import itdelatrisu.opsu.objects.curves.Vec2f; @@ -92,9 +90,10 @@ public class CurveRenderState { * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve + * @param borderColor the curve border color * @param curve the points along the curve to be drawn */ - public void draw(Color color, Vec2f[] curve) { + public void draw(Color color, Color borderColor, Vec2f[] curve) { float alpha = color.a; // if this curve hasn't been drawn, draw it and cache the result @@ -113,7 +112,7 @@ public class CurveRenderState { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); Utils.COLOR_WHITE_FADE.a = 1.0f; - this.draw_curve(color, curve); + this.draw_curve(color, borderColor, curve); color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, old_tex); @@ -229,9 +228,10 @@ public class CurveRenderState { /** * Do the actual drawing of the curve into the currently bound framebuffer. * @param color the color of the curve + * @param borderColor the curve border color * @param curve the points along the curve */ - private void draw_curve(Color color, Vec2f[] curve) { + private void draw_curve(Color color, Color borderColor, Vec2f[] curve) { staticState.initGradient(); RenderState state = startRender(); int vtx_buf; @@ -262,12 +262,7 @@ public class CurveRenderState { GL20.glEnableVertexAttribArray(staticState.texCoordLoc); GL20.glUniform1i(staticState.texLoc, 0); GL20.glUniform3f(staticState.colLoc, color.r, color.g, color.b); - Color borderColor; - if(Options.isBeatmapSkinIgnored()) - borderColor = Options.getSkin().getSliderBorderColor(); - else - borderColor = MusicController.getBeatmap().getSliderBorderColor(); - GL20.glUniform4f(staticState.colBorderLoc,borderColor.r,borderColor.g,borderColor.b,borderColor.a); + GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a); //stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w) //2*4 is for skipping the first 2 floats (u,v) GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4); @@ -356,7 +351,7 @@ public class CurveRenderState { /** OpenGL shader uniform location of the color attribute. */ protected int colLoc = 0; - /** OpenGL shader uniform location of the border color attribute */ + /** OpenGL shader uniform location of the border color attribute. */ protected int colBorderLoc = 0; /** OpenGL shader uniform location of the texture sampler attribute. */ diff --git a/src/itdelatrisu/opsu/render/FrameBufferCache.java b/src/itdelatrisu/opsu/render/FrameBufferCache.java index e1ea1e58..2558dd15 100644 --- a/src/itdelatrisu/opsu/render/FrameBufferCache.java +++ b/src/itdelatrisu/opsu/render/FrameBufferCache.java @@ -23,8 +23,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import org.newdawn.slick.util.Log; - /** * This is cache for OpenGL FrameBufferObjects. This is currently only used * to draw curve objects of the new slider style. Does currently not integrate @@ -33,9 +31,6 @@ import org.newdawn.slick.util.Log; * @author Bigpet {@literal } */ public class FrameBufferCache { - /** The initial cache size. */ - //private static final int INITIAL_CACHE_SIZE = 4; - /** The single framebuffer cache instance. */ private static FrameBufferCache instance = null; @@ -123,7 +118,6 @@ public class FrameBufferCache { // no unmapped RTTFramebuffer found, create a new one buffer = Rendertarget.createRTTFramebuffer(width, height); cache.add(buffer); - Log.warn("Framebuffer cache was not large enough, possible resource leak."); cacheMap.put(obj, buffer); return buffer; } diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 2e035b13..eea43540 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -1393,7 +1393,8 @@ public class Game extends BasicGameState { Circle.init(container, circleSize); Slider.init(container, circleSize, beatmap); Spinner.init(container); - Curve.init(container.getWidth(), container.getHeight(), circleSize); + Curve.init(container.getWidth(), container.getHeight(), circleSize, (Options.isBeatmapSkinIgnored()) ? + Options.getSkin().getSliderBorderColor() : beatmap.getSliderBorderColor()); // approachRate (hit object approach time) if (approachRate < 5)