GL instance of hidden GLCanvas invalid?

Hi,

I’d like to do some things for which I do not need a visible GLCanvas (get the maximum size of a texture).
But:

GLCanvas c = new GLCanvas();
c.getGL().glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, intBuffer);
//...

returns 0! But, when the GLCanvas is visible, and I do the same in the init()-method, it works (returns 2048).
Is this normal? Is there no way to do things without a visible surface?

Thanks :slight_smile:

Andi

The GLCanvas must be visible in order for its OpenGL context to be valid. You can use a 1x1 GLPbuffer (see GLDrawableFactory.canCreateGLPbuffer(), createGLPbuffer() for this purpose. You’ll need to call display() once on the GLPbuffer to cause its OpenGL context to be created.

This doesn’t work too:

GLDrawableFactory f = GLDrawableFactory.getFactory();
//yes, f.canCreateGLPbuffer() returns true
GLPbuffer b = f.createGLPbuffer(new GLCapabilities(), null, 1, 1, null);
b.display();
b.getGL().glGetIntegerv(...);
//...

It returns 0 again… Must I register a GLEventListener and call the method within the init()-method?

Yes. Either that or you need to call b.getContext().makeCurrent() (checking the return value), then call your OpenGL functions, and then call b.getContext().release().

Now it works. Ken, thank you very much for your quick responses :slight_smile: