Loading...
Logo
Processing Forum
I've been messing with the joons renderer which mis-uses noSmooth() to create "new" objects, unfortunately this somewhat messes with the opengl display in processing-2.0, much flickering. Does anyone know of more suitable command to misuse.

Replies(8)

I am sorry, but I understand nothing of your question...
What do you mean by "mis-use"? Why do you want a "no-op" command? How noSmooth() can create new objects? And to what purpose?
Well the original method is overidden and does not do any sort of "smooth", rather it "ends" a group of vertices and writes previously recorded vertices out as a wavefront object.  What is needed is a valid PGraphics method that doesn't really do anything so it can placed after a group of vertices (including box, which is reimplemented as a group of vertices).
I think I understand better, although I don't see why you don't use endRecord(), for example, which would be understandable, instead of hijacking some innocent function...
The problem is that endRecord() would finish recording, indeed it is required at end of recording, what, I'm doing with noSmooth() here is to make the first box obj0, and the rest obj1. In the draw render is after beginRecord() and followed by endRecord(). I tried using g.is2D() but that did not seem to work. Since the flickering only happens when I try to display the rayTraced Image at end there might be another work around.

Copy code
  1.     public void render() {  // encapsulate the processing sketch as a function 
  2.         translate(0, 0, 8);
  3.         fill(255, 0, 0);
  4.         box(15);
  5.         noSmooth();
  6.         translate(0, 0, 15);
  7.         box(15);
  8.         translate(15, 0, 0);
  9.         box(15);
  10.         translate(-15, 0, 15);
  11.         box(15);
  12.         translate(0, 0, 15);
  13.         box(15);
  14.         translate(15, 0, 0);
  15.         box(15);
  16.     }

Ah, OK. The PDF library uses nextPage(), perhaps you can do something like that (nextBox()?).
Yes that would seem to be the way to do it, except unfortunately I get a cast issue. The joons renderer extends PGraphics, but of course with a P3D sketch the renderer is actually PGraphics3D so I can't cast PGraphics3D to a JoonsRenderer. Another case for preferring composition over inheritance? I think the simplest solution is not to worry about displaying raytraced image at end of raytracing (or use an external program like feh linux). Actually I found a solution, yet another disgusting hack I'm afraid PGraphics3D can't cope with repeated call to smooth() so Andres  sets it to disabled ( to cope with flickering screen), so this works:-

Copy code
  1. noSmooth(); // hack to end object
  2. smooth();     // hack that disables smoothing only needs to be called once in draw loop.
I don't understand your issue.
Either you set the renderer as being your PGraphics type, like the PDF library does, as specified in the size() command. In this case, you can cast g to your specific type.
Or you create a PGraphics of the right type, same process.

Note that you can extend PGraphics3D instead of just PGraphics, it is even recommended to gain extra features.
This is the error message I get when I substitute PGraphics3D for PGraphics (I dont' think it such a good idea since processing-2.0 to extend PGraphics3D it is part of opengl package).

Info: XInitThreads() called for concurrent Thread support
Exception in thread "Animation Thread" java.lang.NullPointerException
    at processing.opengl.PGL.getError(PGL.java:1096)
    at processing.opengl.PGraphicsOpenGL.report(PGraphicsOpenGL.java:5218)
    at processing.opengl.PGraphicsOpenGL.endDraw(PGraphicsOpenGL.java:1741)
    at processing.core.PApplet.endRecord(PApplet.java:10008)
    at test.RotatePushPop.draw(RotatePushPop.java:93)
    at processing.core.PApplet.handleDraw(PApplet.java:2128)
    at processing.opengl.PGL$PGLListener.display(PGL.java:2595)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
    at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:928)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
    at javax.media.opengl.awt.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:945)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:666)
    at java.awt.EventQueue.access$400(EventQueue.java:81)
    at java.awt.EventQueue$2.run(EventQueue.java:627)
    at java.awt.EventQueue$2.run(EventQueue.java:625)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:636)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Apart from flickering which can be fixed (albeit with a hack) the library is working OK.