Changing render at runtime

Started by ErDetEnAnd?, December 25, 2008, 12:17:16 PM

Previous topic - Next topic

ErDetEnAnd?

How is this done?

I want to use the opengl renderer, but if acquiring of the opengl render fails I should use the software renderer (see code).

If once used opengl, and then requiring to initialize the render again and fails, then the software renderer is not probably initialized. What do I miss? This reinitialization works fine on software renderer only.

try {
    // Set up open gl
    buffer = new FrameBuffer(width, height, glOversampling);
    buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
    cGLScene = (AWTGLCanvas)buffer.enableGLCanvasRenderer();
} catch (Exception _) {
    // Use software-renderer
    buffer = new FrameBuffer(width, height, swOversampling);
    buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
}

EgonOlsen

jPCT only throws exceptions in that case if the Logger is advised to do so (by default, it's not). Maybe you haven't done this, so that the catch-block is never executed?


Logger.setOnError(Logger.ON_ERROR_THROW_EXCEPTION);

ErDetEnAnd?

Exceptions or not. No error is shown in the console when changing resolution in gl mode (VideoMode supported). I've read Paradroidz does this. Do you have a link thats not broken? :P

(I remember to re-add the canvas to the pane.)

EgonOlsen

Then i don't understand what you have in mind. If there's no exception, then OpenGL should be available and the catch-block won't be executed....why should it!?
About Paradroidz: No, there is no link to it anymore due to legal reason. Paradroidz let the user decide which mode to use. There was no automatic fallback to software mode, it was just an option. The only thing that it checked was, if LWJGL was available on a platform and disabling the hardware mode if not, but that was all. Apart from that, it used the native OpenGL-window, not the awt-glrenderer, which is a different story. The awt-glrenderer is initialized on first render, not when calling the enable...-method, because it has to take place in the awt event thread. Maybe that is part of your problem?