Skip to content

Commit

Permalink
flicker bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteTimesSix committed May 5, 2015
1 parent 7796c3c commit 317c085
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion VesselView/VesselViewer.cs
Expand Up @@ -32,6 +32,8 @@ public class VesselViewer
public ViewerSettings basicSettings=new ViewerSettings();
public CustomModeSettings customMode;

private RenderTexture screenBuffer;

//stage counters
private int stagesLastTime = 0;
private int stagesThisTimeMax = 0;
Expand Down Expand Up @@ -61,7 +63,21 @@ public VesselViewer()
lastUpdate = Time.time - 1f;
}

public void drawCall(RenderTexture screen, bool internalScreen) {
private void readyTexture(RenderTexture outputTexture)
{
if (screenBuffer == null) createTexture(outputTexture);
else if (screenBuffer.height != outputTexture.height | screenBuffer.width != outputTexture.width) createTexture(outputTexture);
}

private void createTexture(RenderTexture outputTexture)
{
screenBuffer = new RenderTexture(outputTexture.width, outputTexture.height, outputTexture.depth, outputTexture.format);
}

public void drawCall(RenderTexture screen) {
readyTexture(screen);
RenderTexture activeTexture = screen;
screen = screenBuffer;
//MonoBehaviour.print("VV draw call");
//Latency mode to limit to one frame per second if FPS is affected
//also because it happens to look exactly like those NASA screens :3
Expand Down Expand Up @@ -118,6 +134,8 @@ public VesselViewer()
}

}
screen = activeTexture;
Graphics.Blit(screenBuffer, screen);
//MonoBehaviour.print("VV draw call done");
}

Expand Down
2 changes: 1 addition & 1 deletion VesselViewPlugin/VesselViewPlugin.cs
Expand Up @@ -318,7 +318,7 @@ void Update()
{
if (settings.screenVisible)
{
viewer.drawCall(screen, false);
viewer.drawCall(screen);
}
}

Expand Down
2 changes: 1 addition & 1 deletion VesselViewRPM/InternalVesselView.cs
Expand Up @@ -117,7 +117,7 @@ public bool RenderViewer(RenderTexture screen, float cameraAspect)
}
//MonoBehaviour.print("screen draw call");
//if (ViewerConstants.VVDEBUG) MonoBehaviour.print("Viewer draw call");
viewer.drawCall(screen,true);
viewer.drawCall(screen);
//MonoBehaviour.print("screen draw call done");
return true;
}
Expand Down

0 comments on commit 317c085

Please sign in to comment.