Syphon / Processing

Syphon Implementation for Processing
Other
137 stars 33 forks source link

GetImage example is broken #22

Closed bangnoise closed 9 years ago

bangnoise commented 9 years ago

The example for GetImage illustrates nicely the problem with the current SyphonClient implementation

Add a call to background(0) at the start of draw() and watch the output flicker....

It should properly do something like this

public void draw() {

Always background(0)

    background(0);

active() should be added to expose JSyphonClient's isValid

    if (client.active()) { 

available() should be renamed to something like newFrameAvailable()

        if (client.newFrameAvailable()) {
            // The first time getImage() is called with 
            // a null argument, it will initialize the PImage
            // object with the correct size.
            img = client.getImage(img); // load the pixels array with the updated image info (slow)
           // img = client.getImage(img, false); // does not load the pixels array (faster)
        }

If the client is active, draw every pass regardless of whether the frame is new

        if (image.width() && image.height()) {
            image(img, 0, 0, width, height);
        }
    }
codeanticode commented 9 years ago

Fixed in 2.0-RC1