I’m having a ton of trouble trying to understand why I can not create a GLPbuffer at run-time, and call the display method on it. Everything works fine if I delete the call to the display method. It appears that JOGL is creating the GLPbuffer, but will not display it.
If I move the creation source code to the Init method of the GLEventListener then I can call the GLPbuffer.display method from another display method. But I can not create it in the display method. I don’t understand why?
Here is how to reproduce the problem.
I wanted to post the whole source code, but the text thing here says it’s to large.
So to reproduce this problem load gears.java from the JOGL demo’s, and insert the following source code at the top.
class c3dShadowCanvas implements GLEventListener {
public void init(GLDrawable drawable) {
drawable.setGL(new DebugGL(drawable.getGL()));
GL gl = drawable.getGL();
GLU glu = drawable.getGLU();
}
public void display(GLDrawable drawable) {
GL gl = drawable.getGL();
GLU glu = drawable.getGLU();
}
// Unused routines
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
Add this somewhere in the GearRenderer class.
private int count=0;
Then down in the GearRenderer.display(GLDrawable drawable) method add these lines at the start of the method call.
count++;
if (count==10) {
if (drawable.canCreateOffscreenDrawable()) {
// init pbuffer
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered( false );
GLPbuffer pbuffer = drawable.createOffscreenDrawable(caps, 200, 200 );
pbuffer.addGLEventListener(new c3dShadowCanvas());
pbuffer.display();
}
}
The reason I do this on frame 10 is not reason at all. I just want to demonstrate that I need to create the GLPbuffer at run-time, and can’t do it during initialization. This is because I never know if I will need the buffer, what size it will be, and how many I will need. It depends on parameters the user selects during run-time.
This is such a huge problem for me, and I’ve been trying to figure out what is going wrong with JOGL in the display method. I often get the “out of memory” error. If I debug this I find that the display method is called successfully, but the next future call to any GL method will cause an exception.
I’m braking something inside JOGL but I don’t know what.