How to initializing a GLPBuffer in JOGL2

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to initializing a GLPBuffer in JOGL2

Martin
Hi,

Jzy3d 0.8 (i.e. JOGL1) offers offscreen rendering using GLPBuffer. I wonder how to initialize a GLPBuffer properly in JOGL2:

public void initGLPBuffer(int width, int height) {
        GLCapabilities caps = org.jzy3d.global.Settings.getInstance().getGLCapabilities();
        caps.setDoubleBuffered(false);
        glpBuffer = GLDrawableFactory.getFactory(GLProfile.getDefault()).createGLPbuffer(null, caps, null, width,height, null);
        //glpBuffer = GLDrawableFactory.getDesktopFactory().createGLPbuffer(null, caps, null, width, height, null);
               
        glpBuffer.addGLEventListener(renderer);
        glContext =  glpBuffer.createContext(null);
        glContext.makeCurrent();
        glpBuffer.createContext(glContext);
        //renderer.reshape(glpBuffer, 0, 0, width, height);
}

Although I properly define dimensions (400*400), when starting this way, I got:

Exception in thread "main" java.lang.IllegalArgumentException: Width (0) and height (0) must be > 0
        at java.awt.image.SampleModel.<init>(Unknown Source)
        at java.awt.image.ComponentSampleModel.<init>(Unknown Source)
        at java.awt.image.PixelInterleavedSampleModel.<init>(Unknown Source)
        at java.awt.image.Raster.createInterleavedRaster(Unknown Source)
        at java.awt.image.Raster.createInterleavedRaster(Unknown Source)
        at java.awt.image.BufferedImage.<init>(Unknown Source)
        at com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(Screenshot.java:256)
        at com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(Screenshot.java:218)
        at com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(Screenshot.java:192)
        at org.jzy3d.plot3d.rendering.view.Renderer3d.display(Renderer3d.java:87)
        at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
        at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
        at jogamp.opengl.GLPbufferImpl$DisplayAction.run(GLPbufferImpl.java:300)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
        at jogamp.opengl.GLPbufferImpl.invokeGL(GLPbufferImpl.java:286)
        at jogamp.opengl.GLPbufferImpl.display(GLPbufferImpl.java:149)
        at org.jzy3d.plot3d.rendering.canvas.OffscreenCanvasNotWorking.screenshot(OffscreenCanvasNotWorking.java:82)
        at org.jzy3d.demos.offscreen.WireSurfaceOffscreenDemo.createScreenshot(WireSurfaceOffscreenDemo.java:44)
        at org.jzy3d.demos.offscreen.WireSurfaceOffscreenDemo.init(WireSurfaceOffscreenDemo.java:37)
        at org.jzy3d.demos.offscreen.WireSurfaceOffscreenDemo.main(WireSurfaceOffscreenDemo.java:30)

I tried calling reshape(...) on my GLEventListener, but once called, GLAutoDrawable.getGL() returns null when passing the GLPBuffer as GLAutoDrawable, so the reshape method of my GLEventListener can't do its job.

I tried using GLProfile.getGL2GL3() as profile, but it does not work better.
I also tried using GLDrawableFactory.getDesktopFactory() to build the GLPBuffer with the same problems.

Thanks in advance for your suggestions...

Martin
Reply | Threaded
Open this post in threaded view
|

Re: How to initializing a GLPBuffer in JOGL2

gouessej
Administrator
Hi

Maybe you should rather use Sven's new API to manipulate FBOs.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: How to initializing a GLPBuffer in JOGL2

Martin
Does it mean GLPBuffer is not usable anymore?
Reply | Threaded
Open this post in threaded view
|

Re: How to initializing a GLPBuffer in JOGL2

Sven Gothel
Administrator
On 08/24/2012 07:20 PM, Martin [via jogamp] wrote:
> Does it mean GLPBuffer is not usable anymore?
>
It is .. where it is supported :)

However, just do as the exception says .. use a valid size > 0x0.

Pbuffer and FBO GLAutoDrawable examples are within the JOGL unit test
using the GLDrawableFactory directly.

~Sven


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to initializing a GLPBuffer in JOGL2

Martin
Sven Gothel wrote
However, just do as the exception says .. use a valid size > 0x0.
That was already done.

Very surprised to see that following code is working:

protected void initGLPBuffer(int width, int height) {
        GLCapabilities caps = org.jzy3d.global.Settings.getInstance().getGLCapabilities();
        caps.setDoubleBuffered(false);
        if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null))
            throw new RuntimeException("No pbuffer support");

        glpBuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createGLPbuffer(null, caps, null, width, height, null);
        glpBuffer.addGLEventListener(renderer);
    }

Don't know what I missed before :)