Author Topic: Changing render at runtime  (Read 3080 times)

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Changing render at runtime
« on: December 25, 2008, 12:17:16 pm »
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.

Code: [Select]
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);
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Changing render at runtime
« Reply #1 on: December 25, 2008, 12:28:53 pm »
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?

Code: [Select]
Logger.setOnError(Logger.ON_ERROR_THROW_EXCEPTION);

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Changing render at runtime
« Reply #2 on: December 25, 2008, 02:28:37 pm »
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.)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Changing render at runtime
« Reply #3 on: December 25, 2008, 05:25:55 pm »
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?