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 <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-06-08 16:42:54 -04:00
parent a7d05a4b26
commit b1b1664e11
4 changed files with 16 additions and 21 deletions

View File

@ -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);
}
}

View File

@ -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,11 +262,6 @@ 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);
//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)
@ -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. */

View File

@ -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 <dravorek (at) gmail.com>}
*/
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;
}

View File

@ -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)