hi!
i the display() method i am trying to to render to a pbuffer and then bind this pbuffer an draw it using glquads. here is what i do in my display:
// the glpbuffer object shoud only be created once
if(this.buffer==null) // private GLPbuffer buffer
{
GLCapabilities cap = new GLCapabilities();
cap.setDoubleBuffered(false);
cap.setPbufferRenderToTexture(true);
cap.setPbufferRenderToTextureRectangle(true);
GLDrawableFactory fact = GLDrawableFactory.getFactory();
if(!fact.canCreateGLPbuffer()) throw new RuntimeException("no glpbuffer");
this.buffer = fact.createGLPbuffer(cap, null, 320, 240, GLContext.getCurrent());
this.buffer.addGLEventListener(...);
}
// in the following 5 lines of code seems to be the problem
GLContext oldctx = GLContext.getCurrent();
GLContext bufferctx = this.buffer.getContext();
bufferctx.makeCurrent();
this.buffer.display();
oldctx.makeCurrent();
gl.glEnable(GL.GL_TEXTURE_2D); // what to enable here? there is no this.buffer.getTarget()
this.buffer.bindTexture();
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(...);
gl.glVertex3d(...),
gl.glTexCoord2f(...);
gl.glVertex3d(...),
gl.glTexCoord2f(...);
gl.glVertex3d(...),
gl.glTexCoord2f(...);
gl.glVertex3d(...),
gl.glEnd();
this.buffer.releaseTexture();
the code is always executed by the awt thread. no matter what i do with the contexts, either the this.buffer.display() writes “invalid context state” or the later binding of the pbuffer does.
what do i make wrong?
thanks in advance