Allow system provider to be changed

I need to import a model file to assess its contents.  This can throw an exception because there might not be a renderer in the system. To avoid this possibility I'd like to assure that there is a DummyDisplaySystem available before attempting any import.  Later, when I need to show the model in a canvas, I need to assure that there is a real display system present for rendering the model.

Unfortunately, once the provider is set,  DisplaySystem.setSystemProvider() will throw an exception if the provider is changed.  Unless there is some other mechanism for changing display systems, or assuring that import has a dummy renderer, I suggest that DisplaySystem.setSystemProvider() be modified to allow the provider to be changed.  (Note: The change to the code is simply to delete the test that throws the exception.)


You should be aware that the DisplaySystem is accessed through the SystemProvider, so changing it while rendering is occurring would be a problem.

public static DisplaySystem getDisplaySystem() {
   return getSystemProvider().getDisplaySystem();

There are lots of places within the code where the active renderer is obtained by going through the getDisplaySystem() call which accesses the current SystemProvider.


However, there is a way to dispose of the current SystemProvider via a call to resetSystemProvider().

If no SystemProvider is currently defined, LWJGL is used as a default.

Yes, but a real system, such as LWJGL, will not have a renderer until a canvas is created.  I don't need a canvas.  All I need is the dummy provider and its dummy renderer.

As for the "global" nature of the system access, that is precisely the reason why i need to "convince" the system to use the dummy instead of the real renderer.

As for the use of resetSystemProvider(), I'm not sure what the implications are of disposing the display system and then reconstituting it.  My approach, which is to simply create the providers ahead of time and then set them as needed seems a lot less heavyweight.

I made the fix on my end (commented out the exception test in setSystemProvider()). So far, with limited testing, it seems to work fine.  Before doing an import I make sure the system is using the dummy system.  Before doing any real rendering I make sure that the real system is in use.

Perhaps the ultimate solution is to refactor the import framework to work regardless of the system provider/system renderer state (e.g. always use the dummy renderer instead of the system renderer).

There are lots of times that an importer would be used to import a model into an active rendering session.  I'd suggest that refactoring import to use a provided Renderer would allow importing to work with either a DummyRenderer or an active renderer such LWJGL or JOGL.

Hopefully one of the anointed can weigh in and suggest the best workaround/fix for this.