JME2 Renderer for NiftyGUI

Hi people. I am trying to re take nifty java2d renderer. I have updated to use nifty 1.2, but I have only two simple example applications, so I don't know if it is working right for everything nifty offers.



@Normen are you guys using the nifty java2d renderer or your implementation (or none of those)? the last time we talk I tried to merge your impl in the nifty java2d renderer source, but I don't remember if we talk after that.



My idea is to try to run nifty examples with java2d renderer and if they work correctly then I can say it is "complete" but if you are using it right now maybe you can provide me with better feedback.

arielsan said:

Hi people. I am trying to re take nifty java2d renderer. I have updated to use nifty 1.2, but I have only two simple example applications, so I don't know if it is working right for everything nifty offers.

@Normen are you guys using the nifty java2d renderer or your implementation (or none of those)? the last time we talk I tried to merge your impl in the nifty java2d renderer source, but I don't remember if we talk after that.

My idea is to try to run nifty examples with java2d renderer and if they work correctly then I can say it is "complete" but if you are using it right now maybe you can provide me with better feedback.

I'd like to use the java2d renderer for the preview of nifty files in jMP. I started moving to your implementation some time ago but I did not get far with it. One problem I have is that I'd need a system to add file paths as resource roots to the renderer (just like the FileLocator for the AssetManager in jme3). Atm it will only load stuff from the classpath and the images and xml files of a project are not on jMP's classpath..

Maybe I can change the way the RenderDevice loads the resources, using some kind of ResourceProvider interface (or something like that), and have a ResourceProviderNiftyImpl with the current implementation (let nifty handle with resources) and let you implement the ResourceProvider the way you want. Or use some similar way Spring does (or even use spring for this part) with urls: "classpath:helloworld.xml" or "file:helloworld.xml" (any url, even http://www.somewhere.com/helloworld.xml). The second way is more flexible if you, for example, want to have resources in classpath and others in other place.



I will think about it a bit, but tell me if I have understood the problem right.

@arielsan:

There currently is a discrepance for resolving/loading resources between niftys core and RenderDevice implementations. Loading font-files and images is currently handled inside the RenderDevice. This however has issues when the RenderDevice uses a different algorithm then Niftys itself. The JME2-Renderer for instance uses only Classpath based loading and not file based, see this post on the Nifty forum for details http://sourceforge.net/projects/nifty-gui/forums/forum/807893/topic/3800793.



Nifty core is using a ResourceLocator interface with different implementations for classpath, filebased, whatever resourceloading. This is similar to what JME and Slick2d do.



So maybe it would be better to let Nifty load all resources and just call the RenderDevice with the data only, like give it an InputStream? Together with allowing the ResourceLocators to be configured this would be the best way maybe?



Just some thoughts tho.

I didn't know about the possibility to add your own locations in the ResourceLoader static class, I am using exactly that to get the an input stream, so I think I don't have to do anything new, if someone configure the ResourceLocation he want, then I should be able to get the files correctly.



However, I think changing the interface of createImage to receive a InputStream instead a filename and derive the load of the resource always to the ResourceLoader, could work.