Starting again... GLJPanel problems...

Hey there,

I did know a little about JOGL a while back, but now I’m starting again and I’ve came across a little problem,

I want to take use a GLJPanel but I want to take control of the displaying myself, rather than calling display() or something.

I was wondering if there was something similar to the getGraphics() method in a regular JPanel, where i can get either a GL object or the GLAutoDrawable.
I’m not sure that the getGL() method in GLJPanel is quite what I’m after.

Thanks!
Mal.

The GLJPanel is an implementation of GLAutoDrawable.

I think what you’re looking for is active rendering with JOGL. To get it working, you’d make the jpanel visible, get its GLContext and make it current. This can be done with makeCurrent(), although you have to check its response to make sure it’s actually current. After the context is current, call getGL() on the context to get the GL object that lets you render opengl calls.

When you’re all done rendering, you’ll release the context and call swapBuffers() on the GLJPanel. When you create the GLJPanel, you’ll also want to disable auto-buffer swapping since you’re doing it manually.

It is generally not recommended to use active rendering because of threading issues with contexts and AWT. If the GLJPanel doesn’t work, you can try a GLCanvas.

If you are still learning JOGL, I highly suggest with implementing a GLEventListener because it’s a lot more stable.

Hey there!

Sorry to drag up an old post, and im really sorry it’s taken me this long to reply…
Although now i’ve come across another problem that’s related to it, a little bit…

It looks like that was what i was thinking about, and i had a quick look and thought it best to stick with a more roundabout way of using the listener than going through the active rendering…

The problem I have now though is related to textures. I’m finding it hard to find a way to load in textures in anything but the init() method of the gleventlistener.
The compiler keeps moaning about there not being a current context on the thread. I just wondered if anyone had came up with a way round this?

I may just be being daft, but essentially where I want to get to is to be able to dynamically load in textures from a class outside the panel
(sorry if that last bit didn’t make sense, trying to condense a project into a sentence isn’t easy)

Thanks, and sorry again if i’m being thick lol!
Mal.

I am thick… sorry!

I think i can get round it by using a textureData object in the class it relates to, then creating a Texture object from that in the display() method.

Does this sound daft at all?

Thanks,

Mal.

Yep, that’s a pretty good way of doing things. The TextureData can be loaded at anytime (with proper syncing of course), because it’s just data. As you’ve discovered, actually making a usable Texture does require the context to be current.