Allow markers to use content/displays as textures (#11142)
* Allow markers to use content/displays as textures * Don't process empty commands * Allow canvases to be used as marker textures * Proper Json serialization --------- Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -149,8 +149,7 @@ public class CanvasBlock extends Block{
|
||||
public @Nullable Texture texture;
|
||||
public byte[] data = new byte[Mathf.ceil(canvasSize * canvasSize * bitsPerPixel / 8f)];
|
||||
public int blending;
|
||||
|
||||
protected boolean updated = false;
|
||||
public boolean updated = false;
|
||||
|
||||
public void setPixel(int pos, int index){
|
||||
if(pos < canvasSize * canvasSize && pos >= 0 && index >= 0 && index < palette.length){
|
||||
|
||||
@@ -89,15 +89,7 @@ public class LogicDisplay extends Block{
|
||||
//don't even bother processing anything when displays are off.
|
||||
if(!Vars.renderer.drawDisplays) return;
|
||||
|
||||
Draw.draw(Draw.z(), () -> {
|
||||
if(buffer == null){
|
||||
buffer = new FrameBuffer(displaySize, displaySize);
|
||||
//clear the buffer - some OSs leave garbage in it
|
||||
buffer.begin(Pal.darkerMetal);
|
||||
buffer.end();
|
||||
}
|
||||
});
|
||||
|
||||
Draw.draw(Draw.z(), this::ensureBuffer);
|
||||
processCommands();
|
||||
|
||||
Draw.blend(Blending.disabled);
|
||||
@@ -129,11 +121,20 @@ public class LogicDisplay extends Block{
|
||||
operations++;
|
||||
}
|
||||
|
||||
public void ensureBuffer() {
|
||||
if(buffer == null){
|
||||
buffer = new FrameBuffer(displaySize, displaySize);
|
||||
//clear the buffer - some OSs leave garbage in it
|
||||
buffer.begin(Pal.darkerMetal);
|
||||
buffer.end();
|
||||
}
|
||||
}
|
||||
|
||||
public void processCommands(){
|
||||
//don't bother processing commands if displays are off
|
||||
if(!commands.isEmpty() && buffer != null){
|
||||
Draw.draw(Draw.z(), () -> {
|
||||
if(buffer == null) return;
|
||||
if(buffer == null || commands.isEmpty()) return;
|
||||
|
||||
Tmp.m1.set(Draw.proj());
|
||||
Tmp.m2.set(Draw.trans());
|
||||
|
||||
Reference in New Issue
Block a user