releaseCurrentContext() + swapBuffers() very slow in conjunction w. AWTGCanvas.

Started by oeh766, February 14, 2008, 16:36:26

Previous topic - Next topic

oeh766

Hi.

I also posted this message on the JME board, but it seems it's more related to LWJGL than JME. Any help would be highly appreciated.

On my journey in creating an embedded 3d view I constructed a model yesterday, which serves as a foundation for updating JME's geometry.

Next I started a separate thread to actively render 3D. This thread first changes the world model (by simply rotating some lines), then updates the corresponding nodes and finally calls canvas.paint(null).

In summary, I have three lines in my canvas; each related to a quad containing a texture. Every pass I simply calculate some sin() and cos() values and update the .y and .z position. The canvas is embedded in a swing panel.

Unfortunately, the performance of this approach is less than satisfying. It feels as if there are no more than 10FPS at max. I also did a profiling run, and the top two time-eaters are:

.

1. Does anyone have an idea how to improve this?

2. What would be the best option to mix active (OpenGL) and passive (Swing) rendering to archive the highest performance? (The OpenGL canvas must be able to smoothly render i.e., >> ~30 FPS) and also every Swing widget must be usable nicely.

3. What might I be doing wrong?

Posting code is a bit difficult, as the appropriate lines are scattered among lot of classes. But maybe at least the rendering code:

@Override
    public void doRender() {
        this.renderer.setBackgroundColor(ColorRGBA.black);
        this.renderer.clearBuffers();
        this.renderer.draw(this.rootNode);

        if (this.fengGuiDisplay != null) this.fengGuiDisplay.display();

        this.renderer.displayBackBuffer();
    }


And the repaint code:

((LWJGLCanvas) JMEAdapter.this.canvas).paint(null);

Matzon

fwiw, this doesn't seem to be an LWJGL issue as such.
releaseCurrentContext() just makes a call to nReleaseCurrentContext(), which is implemented like this:

JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nReleaseCurrentContext
(JNIEnv *env, jclass clazz) {
  wglMakeCurrent(NULL, NULL);
}


So it has more to do with using multiple contexts. Where is this happening and why?


oeh766

I used jME. There I created a canvas which was placed inside JInternalFrame, which itself was placed in a JDesktopPane. The machine itself is a MacbookPro, running Parallels Desktop with Windows XP.

Within Java I repeatedly called repaint() (and also played with others), but the result was almost always the same.

Yesterday I changed the 3D engine to xith3d, also using the LWJGL render. Here the problem seems to have gone, although the OpenGL performance isn't very good either (~20FPS rendering a single, white line). 

Update: I forgot, I wouldn't solely blame Parallels or the virtualization thing for this, there are windows-3D applications that run reasonably fast on my machine; so that can't be the only reason.