Menu

PGraphics to PImage error

Help
Anonymous
2011-05-23
2012-12-26
  • Anonymous

    Anonymous - 2011-05-23

    HI Andres,

    thanks for the great library, the video capabilities keep getting better! Im using your lib extensively in a project right now, but am having a problem.

    I have an offscreen PGraphics buffer that I try to draw to the stage using the image() method, but it throws this error:

    Exception in thread "Animation Thread" java.lang.NoSuchMethodError: processing.core.PImage.getCache(Lprocessing/core/PGraphics;)Ljava/lang/Object;
    at codeanticode.glgraphics.GLGraphics.renderTriangles(Unknown Source)
    at processing.core.PGraphics3D.endShape(PGraphics3D.java:649)
    at processing.core.PGraphics.endShape(PGraphics.java:1181)
    at processing.core.PGraphics.imageImpl(PGraphics.java:2824)
    at processing.core.PGraphics.image(PGraphics.java:2680)
    at processing.core.PApplet.image(PApplet.java:8440)
    at twitterThreading$Tweet.drawTweet(twitterThreading.java:218)
    at twitterThreading$TwitterStreamThread.moveDown(twitterThreading.java:338)
    at twitterThreading$TwitterStreamThread.newTweet(twitterThreading.java:331)
    at twitterThreading$TwitterStreamThread.getTimeline(twitterThreading.java:293)
    at twitterThreading$TwitterStreamThread.<init>(twitterThreading.java:280)
    at twitterThreading.setup(twitterThreading.java:51)
    at processing.core.PApplet.handleDraw(PApplet.java:1583)
    at processing.core.PApplet.run(PApplet.java:1503)
    at java.lang.Thread.run(Thread.java:680)

    which does not appear if i change the main class MODE. both my main mode and the PGraphics mode use your lib as the mode, specifically it looks like the get() method on the PGraphics is where the error is thrown. here's the class that is throwing the error:

    class Tweet {
      
      public int xx;
      public int yy;
      public PGraphics tw;
      public PImage img;
      
     public Tweet (int _x, int _y, PGraphics tweetBuffer) {
      
       xx = _x;
       yy = _y;
       tw = tweetBuffer;
       println("creating image");
       img = tw.get(0, 0, tweetBuffer.width, tweetBuffer.height);
       println("image created");
     } 
     public void drawTweet (int amountToMove) {
       
      println("drawing image");
      image(img, xx, yy+=amountToMove); 
       println("success!");
     }
      
    }
    

    thanks for looking!
    ak

     
  • Andres Colubri

    Andres Colubri - 2011-05-23

    Hello, so the error only appears when you use GLConstants.GLGRAPHICS as the renderer, is this correct?

    Another question: how do you create the tweetBuffer object that you pass as an argument to the Tweet constructor? Is it a GLGraphicsOffScreen object?

     
  • Anonymous

    Anonymous - 2011-05-23

    Hi Andres,

    It looks like it may be a larger issue with the PImage.getCache() method.

    The error does appear when I use any renderer, either yours or any of the built ins. I am currently using PGraphics as the offscreen buffer, but I will look into the GLGraphicsOffScreen. The tweetBuffer comes from another class that handles the drawing of the offscreen buffer here:

    PGraphics createPost () {
        
        PGraphics buf = createGraphics(500, 85, JAVA2D);
        
        println("post was posted");
       
        float UNheight = 18;//textAscent()+textDescent();
       buf.beginDraw();
        buf.smooth();
        buf.noFill();
        buf.noStroke();
        buf.fill(83, 212, 255);
        buf.rect(0, 0, 5, 75);
        buf.image(img, 10, 0);
        buf.fill(0,0,200);
        buf.textFont(font);
        buf.text(username, 70, 10);
        buf.fill(0);
        buf.text(post, 70, UNheight, 400, 60);
        buf.fill(150);
        buf.text(postTime.toString(), 12, 65);
        buf.stroke(100);
        buf.line(10, 75, 500, 75); 
        
       buf.endDraw();
       
        
        return buf;
      }
    

    It looks like you have seen this error before in this thread:

    http://forum.processing.org/topic/using-controlp5-and-glgraphics-at-the-same-time

    but because I see the error despite the renderer, it seems like it may not be a problem with your class in this situation.
    my thread on the fourm is here(I thought it was a font issue at first):

    http://forum.processing.org/topic/textfont-required

    Thanks!
    ak

     
  • Anonymous

    Anonymous - 2011-05-23

    Hi Andres,

    ok, so now I am using your GLGraphicsOffScreen object for my buffer, and the error seems to occur when I try to draw any images (bitmaps) to the buffer. So I can set up the buffer, beginDraw(), smooth(), noFill(), and draw a rectangle, but as soon as I use the image() method, it throws the incompatibility error listed before.

    this is true if it is an image, or if I am drawing text (using a bitmap font).

    thoughts?

    thanks!
    ak

     
  • Anonymous

    Anonymous - 2011-05-23

    Howdy!

    Update, it looks like it is a problem with all OPENGL rendered sketches importing processing.xml (im not even using xml!) but I was able to isolate what was working, then slowly start adding things back until they broke and found that as soon as I imported the processing xml lib, it throws this error :

    processing.core.PImage.getCache(Lprocessing/core/PGraphics;)Ljava/lang/Object;
    at processing.opengl.PGraphicsOpenGL.bindTexture(PGraphicsOpenGL.java:821)

    here's a bare minimum sketch that proves this: http://dl.dropbox.com/u/4933598/MinimalTest.zip

    Thanks for your great lib, unfortunately the core libs it extends are problematic.

    ak

     
  • Andres Colubri

    Andres Colubri - 2011-05-24

    ok, I will continue the discussion over the processing forum, where more people can see it.

     

Log in to post a comment.