From 176de197451e4faa7e58ef19ea3cfb5b1f234b95 Mon Sep 17 00:00:00 2001 From: yugecin Date: Tue, 13 Dec 2016 00:01:01 +0100 Subject: [PATCH] nullcheck to fix #106 --- .../opsu/render/CurveRenderState.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/itdelatrisu/opsu/render/CurveRenderState.java b/src/itdelatrisu/opsu/render/CurveRenderState.java index abb8421e..a7df129c 100644 --- a/src/itdelatrisu/opsu/render/CurveRenderState.java +++ b/src/itdelatrisu/opsu/render/CurveRenderState.java @@ -105,15 +105,23 @@ public class CurveRenderState { public CurveRenderState(HitObject hitObject, Vec2f[] curve) { this.hitObject = hitObject; this.curve = curve; + initFBO(); + } + + + private void initFBO() { FrameBufferCache cache = FrameBufferCache.getInstance(); Rendertarget mapping = cache.get(hitObject); - if (mapping == null) - mapping = cache.insert(hitObject); - fbo = mapping; - createVertexBuffer(fbo.getVbo()); + if(mapping==null) + mapping=cache.insert(hitObject); + fbo=mapping; + + createVertexBuffer(fbo.getVbo() + + ); //write impossible value to make sure the fbo is cleared - lastPointDrawn = -1; - spliceFrom = spliceTo = -1; + lastPointDrawn=-1; + spliceFrom=spliceTo=-1; } public void splice(int from, int to) { @@ -135,6 +143,12 @@ public class CurveRenderState { public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; + if (fbo == null) { + // this should not be null, but issue #106 claims it is possible, at least 3 people had this... + // debugging shows that the draw was called after discardGeometry was, which does not really make sense + initFBO(); + } + if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);