GLContext without GLCanvas

Hello,

is it possible to create a GLContext before using a GLCanvas?
My problem is, I want first create a texture object and then two windows showing this texture, but I need therefore a GL object ???

I tried the following code first with using a pixel buffer, but that didn’t work ( I get a StackOverflowError when setting the first window visible ) :

GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities caps = new GLCapabilities(profile);
caps.setAlphaBits(8); 
		
//create 1x1 Pixelbuffer for getting GLContext
if ( !GLDrawableFactory.getFactory(profile).canCreateGLPbuffer() )
    throw new Exception("Can not create pixel buffer. Graphic card is to old or drivers are not updated");
		
DefaultGLCapabilitiesChooser chooser = new DefaultGLCapabilitiesChooser();
		
GLPbuffer pbuffer 
	= GLDrawableFactory.getFactory(profile).createGLPbuffer(caps, chooser, 1, 1, null);
		
GLContext context = pbuffer.getContext();
context.makeCurrent();
		
GL2 gl = context.getGL().getGL2();
				
logger.info("GL_VENDOR: " + gl.glGetString(GL_VENDOR));
logger.info("GL_RENDERER: " + gl.glGetString(GL_RENDERER));
logger.info("GL_VERSION: " + gl.glGetString(GL_VERSION));

int texId = createTexture(gl, "myTexture.tga");

createFirstWindow(context, caps, chooser, texId); 

and in the first GLCanvas constructor :

public Constructor(GLContext context, GLCapabilities caps, GLCapabilitiesChooser chooser, int texId)
{
	super(caps, chooser, context, null);

        this.texId = texId;
		
	addGLEventListener(this);
}

but I get the following error, before the init of the GLEventListener is called :

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError at java.lang.String.<init>(Unknown Source) at java.lang.Long.toUnsignedString(Unknown Source) at java.lang.Long.toHexString(Unknown Source) at javax.media.nativewindow.DefaultGraphicsDevice.toString(DefaultGraphicsDevice.java:66) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at javax.media.nativewindow.DefaultGraphicsScreen.toString(DefaultGraphicsScreen.java:69) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at com.sun.opengl.impl.windows.wgl.WindowsWGLGraphicsConfiguration.toString(WindowsWGLGraphicsConfiguration.java:632) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at javax.media.nativewindow.awt.AWTGraphicsConfiguration.toString(AWTGraphicsConfiguration.java:126) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at javax.media.opengl.awt.GLCanvas.toString(GLCanvas.java:540) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at com.sun.opengl.impl.GLDrawableHelper.toString(GLDrawableHelper.java:62) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at javax.media.opengl.awt.GLCanvas.toString(GLCanvas.java:540) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at com.sun.opengl.impl.GLDrawableHelper.toString(GLDrawableHelper.java:62) at java.lang.String.valueOf(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at javax.media.opengl.awt.GLCanvas.toString(GLCanvas.java:540) at java.lang.String.valueOf(Unknown Source) ... and so on

dj3hut1