fix sliders disappearing when multiple sliders are active or when later sliders is done earlier (2b maps etc)

This commit is contained in:
yugecin
2017-03-05 11:58:07 +01:00
parent d6144187ad
commit 2f1f860ca3
6 changed files with 70 additions and 42 deletions

View File

@@ -26,6 +26,7 @@ import itdelatrisu.opsu.objects.curves.Vec2f;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.LinkedList;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.EXTFramebufferObject;
@@ -69,6 +70,8 @@ public class CurveRenderState {
private int spliceFrom;
private int spliceTo;
protected LinkedList<Utils.Pair<Integer, Integer>> pointsToRender;
private final int mirrors;
/**
@@ -138,6 +141,14 @@ public class CurveRenderState {
lastPointDrawn = -1; // force redraw
}
public void draw(Color color, Color borderColor, LinkedList<Utils.Pair<Integer, Integer>> pointsToRender) {
lastPointDrawn = -1;
firstPointDrawn = -1;
this.pointsToRender = pointsToRender;
draw(color, borderColor, 0, curve.length);
this.pointsToRender = null;
}
/**
* Draw a curve to the screen that's tinted with `color`. The first time
* this is called this caches the image result of the curve and on subsequent
@@ -348,7 +359,11 @@ public class CurveRenderState {
max = 1;
}
for (int i = 0; i < max; i++) {
renderCurve(from, to, i);
if (pointsToRender == null) {
renderCurve(from, to, i);
} else {
renderCurve(i);
}
}
GL11.glFlush();
GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
@@ -370,6 +385,15 @@ public class CurveRenderState {
}
}
private void renderCurve(int mirror) {
for (Utils.Pair<Integer, Integer> point : pointsToRender) {
for (int i = point.first * 2; i < point.second * 2 - 1; ++i) {
final int index = i + curve.length * 2 * mirror;
GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, index * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2);
}
}
}
/**
* Fill {@code buff} with the texture coordinates and positions for a cone
* that has its center at the coordinates {@code (x1,y1)}.