Concerning gui components

I’ve been studying jme today and thinking about where gui components might live in the architecture and how they would get rendered.

This is what I think so far, the interface, Render, would have a method called draw that takes as a parameter a class called something like GuiComponent. The GuiComponent class would perhaps extend the Geometry class.

Please correct me if I’m not understanding.

Also, how might a GuiComponent receive input from the mouse or keyboard?



That’s pretty much the way I was thinking. However, Nala naj and Big Bluey have probably put more thought into then me.

As far as mouse/keyboard interaction, I think call backs generated by InputActions would be best suited for that.

I’m looking forward to Spag 2.0 at the moment just to see how stuff has been changed.

I think GUI stuff would be good in geometry.

At the moment I don’t have much time but I’ve got LWJGL 0.8 working on this awful Matrox card, but I need to find/get a new one at some point.

As I design my gui classes I am finding that it might be advantageous to have each component render itself.

I’ve seen that LWJGLRenderer renders each type of object that might need to be rendered. Are there advantages to this approach over having each object render itself?

Also, if I want to add an object, such as a gui component, to an existing Renderer implementation, like LWJGLRenderer, what would be a good way to accomplish it.



The primary reason for a Renderer class that renders data types is pluggability. With this design, we can create a JOGLRenderer using that instead of LWJGLRenderer and no code would change on the client end. However, if we were to have the objects render themselves, the client would have to change all references to these objects when they wanted to use another renderer.

My recommendation would be this: You have your base class GUI class, Component. Every GUI element extends this class. Component has just enough information to be rendered, size, position, background, icons, etc. Then Renderer would have a draw(Component) method. This would allow you to render any GUI element with a single method.

However, if you feel strongly that the gui should render itself, there is nothing stopping you. LWJGL has static methods to GL and GLU. So you can use them anywhere.

Hope that helps.

I understand. I didn’t consider the pluggablity aspect.

I think I want my gui code to integrate with jME, so I’ll spend some time working out how to make it work with a pluggable renderer.

The more I get to know jME the more I like it. :slight_smile:

Thanks for your help.