GLJPanel and displaying with a minimized window

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

GLJPanel and displaying with a minimized window

r.jaoui
Hi all !

In a recent project, I have a small issue with Swing-based JOGL.

Basically, I want the program to keep runing (as in : keep launching the display() function when panel.repaint() is called) even when the window is minimized (in the task bar).

For now, eveything works, as in the rendering works when the window is visible, whether focused or not, but not when minimized.

My setup is :
- a GLJPanel linked to a GLEventListener.
- a run() function that every 10ms or so calls panel.repaint(), which then internally calls the GLEventListener's display(GLAutoDrawable displayable) function, on which the screen is rendered.

Here is the GLJPanel construction script :

PROFILE = GLProfile.get(GLProfile.GL2);

CAPABILITIES = new GLCapabilities(PROFILE);
CAPABILITIES.setSampleBuffers(true);
CAPABILITIES.setNumSamples(currentAntialiasingLevel);
CAPABILITIES.setStencilBits(8);
CAPABILITIES.setPBuffer(true);

panel = new GLJPanel(CAPABILITIES);
listener = new SPanelListener(this, panel);
panel.addGLEventListener(listener);

panel.setSize(width, height);

frame = new SFrame(this, width, height);


and here is the SFrame constructor (that extends JFrame) :

super();
this.context = context;

this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(width, height);

context.focused = this.isFocused();
focusListener = new SFocusListener(context);
this.addFocusListener(focusListener);

this.setContentPane(context.getPanel());


Note that I know that the panel.repaint() function is called when minimized, only the subsequent display() function is not.

Does anyone have any lead ? Thanks !
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel and displaying with a minimized window

gouessej
Administrator
Why not using offscreen rendering?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel and displaying with a minimized window

r.jaoui
In this specific project I'm already using Render-to-Texture, and as far as I understand, off-screen rendering basically works the same but by attaching RenderBuffers to the FrameBuffer (right?).

If so, since the display() function itself isn't called, how can the image be rendered, even off-screen? If the display() function were to be called but an error message was raised then I'd understand why using off-screen rendering, but in this case since the display() function altogether isn't called, I can't even tell OpenGL to perform off-screen rendering (btw, I'm actually planning to use off-screen rendering later on, so it will be implemented later on anyways, I just want to be sure that it will be able to solve the issue).

The issue is that the display function also holds all the processing that needs to be done at each frame, and that includes non-rendering operations that need to be made whether the screen is rendered or not.

Thank you for the help :)
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel and displaying with a minimized window

gouessej
Administrator
You can call GLAutoDrawable.display() directly.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel and displaying with a minimized window

r.jaoui
Oh I didn't know that but yep, works wonders, thank you so much :)
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel and displaying with a minimized window

gouessej
Administrator
You're welcome.
Julien Gouesse | Personal blog | Website