How to initializing a GLPBuffer in JOGL2
Posted by Martin on Aug 24, 2012; 2:56pm
URL: https://forum.jogamp.org/How-to-initializing-a-GLPBuffer-in-JOGL2-tp4025881.html
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