Skip to content

Saving an OpenGL PGraphics results in a black image #6094

@jbellis

Description

@jbellis

This looks a lot like #4578 except that it still happens with DISABLE_ASYNC_SAVEFRAME. The workaround to get a PImage first doesn't work, either -- but I can still draw it to the main canvas!

(This does work with a Java2D PGraphics.)

Code to reproduce:

    private PGraphics pg;

    public void settings() {
        size(400, 400, P2D);
    }

    public void setup() {
        pg = createGraphics(200, 200, P2D);
        pg.hint(PConstants.DISABLE_ASYNC_SAVEFRAME);
    }

    public void draw() {
        pg.beginDraw();
        pg.fill(0, 100, 100);
        pg.rect(0,0, pg.width,pg.height);
        pg.endDraw();

        // this works
        image(pg, 0,0); 
        
        // this doesn't work (saves completely black image)
        pg.save("C:\\temp\\foo.png"); 
        
        // this doesn't work either
        PImage pi = pg.get();
        pi.save("C:\\temp\\foo.png"); 
        
        noLoop();
    }
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions