PGraphics in P2D mode renders only black color.

edited April 2017 in Using Processing

My sketch is in P2D mode, and PGraphics that I'm using in it is also P2D. When I draw on that PGraphics locally (on my PC), it works fine, but when I'm running my sketch on a server, the PGraphics is always rendered as a black image.
I thought that maybe there's an issue with P2D renderer on the server (graphics card issues or something), but the main sketch which is also in P2D mode runs normally.

So, in short:

on my PC - P2D sketch and P2D PGraphics both work fine

on server - P2D sketch works fine, P2D PGraphics is rendered black

I don't even know where to begin resolving this issue..

Tagged:

Answers

  • edited April 2017

    By "server" you've meant Processing.js (Pjs), right? http://ProcessingJS.org L-)

    If that's the case, be aware that Pjs library is pretty much halted on Processing 1's API: :(|)
    http://ProcessingJS.org/reference/

    In P1, its P2D renderer wasn't based on OpenGL as it is now since P2. @-)
    Therefore, when we pass that constant as size()'s argument there, WebGL isn't activated! #-o

    Try out P3D or OPENGL in order to activate WebGL when running your code in a browser under Pjs. *-:)

  • In order to keep cross-mode compatibility between Java Mode & JS Mode (Pjs), try this trick out: :ar!
    size(800, 600, 1/2 != 1/2.? P2D : P3D);

  • edited April 2017

    By "server" you've meant Processing.js (Pjs), right?

    No, I mean running Processing code on a server, literally.

    I am generating hundreds of thousands of images and would like to use the server we have at work to do that, since it's a beast, but I'm having the issue described above.

    It's really weird because when I'm using x2go (a GUI tool which allows me to see what's on the server) to remotely connect to the server, the issue is present, but when I connect the monitor directly to the server's video card, the problem is gone, but I would really like to use it remotely.

    I have a feeling that this is a graphics card issue and I think the problem is with the choice Processing/OpenGL is making when choosing which card to use. Is there any simple way I could force Processing to use a card of my choice?

  • If the server is running 'headless', ie it has no gui, then you may lose the ability to create pictures on it.

    See here: https://github.com/processing/processing/wiki/Running-without-a-Display

    What operating system is the server running?

  • edited April 2017

    @Patakk --

    If you are doing long runs with hundreds of thousands of images then you may want to disconnect from a running session and reconnect later.

    In that case, you should probably use the second option from the "Running without a Display" discussion that @koogs linked above:

    sudo Xvfb :1 -screen 0 1024x768x24 </dev/null &
    export DISPLAY=":1"
    

    ...and when you run the sketch from the command line as per those instructions:

    /home/<username>/processing/processing-java --sketch=/path/to/sketch/folder --run
    

    ...do so with something session-reconnection-friendly like screen

  • The lack of GUI is not the issue (since I followed the instructions on how to run without a display), the images are rendered fine if I'm not using P2D, I checked that out with a toy example.

    But it's weird because if I'm saving images drawn in the main sketch, it works fine, but the issue is only if I'm saving what is drawn on the PGraphics that are in the P2D mode.

    Anyway, I'm 99% sure it's the graphics card issue and I would just like to be able to choose which card I'm using, is that possible??

Sign In or Register to comment.