JogLF - JOGL Look and Feel (link inside)

Hi,
I’d like to announce to the world JogLF http://www.vprise.com/articles/joglf.jsp a very early proof of concept implementation of a 3D look and feel based on the JOGL API. The linked article explains some of the complications I had to go through in order to develop this proof of concept which is in no way complete/correct/working/optimized etc… It was the work of two long weekends and a couple of late nights and the code looks pretty much like that. It is also my first real OpenGL application so I have an excuse ::slight_smile:
Anyway as I said in the article I think this proof of concept shows that this can be done (if the problems on Windows can be fixed) and I think this has great potential in several fields:

  1. As a UI library for the menus of games, to allow both the easy Swing programming model and the configurable look games require.

  2. As a way to diffrentiate UI in embedded systems.

  3. For any author who wants their UI to REALLY stand out.

I also think performance can be greatly improved and probably surpass current Swing performance due to the hardware acceleration available in some cards, but that is obviously very hardware dependant.

Pretty cool stuff. There are and have been a few efforts underway to use OpenGL acceleration in concert with Swing for various aims but I think this might be the first hardware accelerated L&F implemented purely by extending Swing and using a Java / OpenGL binding.

Thanks,
I’m mostly aware of these efforts, I wanted to make something unique and AFAIK no one did anything quite like this in Swing.
Does anyone around here have any idea of how to solve the problems I mentioned in the article? Did anyone other than myself get this to run/crash?

I just tried the code and was able to see 1st panel (add) on Windows [I had to uncomment conditional setting of the rendering thread in JoglfAnimator].

The spinning buttons were working, and the background highlight was changing positions when I clicked the buttons. Text inputs were working also (bit strange, but OK for test).

I was not able to switch to other tabs. The possible reason is that I got several exceptions before JOGL initialization:

java.lang.NullPointerException
      at javax.swing.text.FieldView.adjustAllocation(FieldView.java:79)
      at javax.swing.text.FieldView.adjustPaintRegion(FieldView.java:178)
      at javax.swing.text.PlainView.paint(PlainView.java:234)
      at javax.swing.text.FieldView.paint(FieldView.java:171)
      at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1319)
      at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:636)
      at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:770)
      at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:749)
      at javax.swing.JComponent.paintComponent(JComponent.java:541)
      at javax.swing.JComponent.paint(JComponent.java:808)
      at com.vprise.jogl.swing.joglf.BaseUIDelegate.update(BaseUIDelegate.java:141)
      at com.vprise.jogl.swing.joglf.AbstractUIDelegate.installUI(AbstractUIDelegate.java:71)
      at com.vprise.jogl.swing.joglf.BaseUIDelegate.installUI(BaseUIDelegate.java:69)
      at com.vprise.jogl.swing.joglf.TextUIDelegate.installUI(TextUIDelegate.java:45)
      at com.vprise.jogl.swing.joglf.JoglfTextFieldUI.installUI(JoglfTextFieldUI.java:55)
      at javax.swing.JComponent.setUI(JComponent.java:449)
      at javax.swing.text.JTextComponent.setUI(JTextComponent.java:287)
      at javax.swing.text.JTextComponent.updateUI(JTextComponent.java:297)
      at javax.swing.text.JTextComponent.<init>(JTextComponent.java:271)
      at javax.swing.JTextField.<init>(JTextField.java:211)
      at javax.swing.JTextField.<init>(JTextField.java:178)
      at com.vprise.jogl.swing.joglf.Demo$NoGrowTextField.<init>(Demo.java:447)
      at com.vprise.jogl.swing.joglf.Demo.createAddDvdPane(Demo.java:250)
      at com.vprise.jogl.swing.joglf.Demo.run(Demo.java:84)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

(several times)

and after JOGL initialization:

java.lang.ArrayIndexOutOfBoundsException: 0
      at com.vprise.jogl.swing.joglf.JoglfTabbedPaneUI.updateRectangles(JoglfTabbedPaneUI.java:118)
      at com.vprise.jogl.swing.joglf.JoglfTabbedPaneUI.componentResized(JoglfTabbedPaneUI.java:131)
      at java.awt.AWTEventMulticaster.componentResized(AWTEventMulticaster.java:102)
      at java.awt.Component.processComponentEvent(Component.java:4958)
      at java.awt.Component.processEvent(Component.java:4912)
      at java.awt.Container.processEvent(Container.java:1569)
      at java.awt.Component.dispatchEventImpl(Component.java:3615)
      at java.awt.Container.dispatchEventImpl(Container.java:1627)
      at java.awt.Component.dispatchEvent(Component.java:3477)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Yuri

Great Yuri!
Can you send in a patch for Windows?

I completely forgot to mention the terrible hacks I had to pull off to get the Animator working. Is anyone (Chris) aware of how to solve these things I ran into?

Anyway Yuri, I’m at a customer site right now but once I get back I’ll try to post instructions/guideline on how to fix your problem. Its in the second exception (the first one shouldn’t prevent the tabs). If you make any progress please let me know, the tab switching is one of the cooler effects.

Wow, great job :).
I implemented a very basic UI system with only a few components. I did not try to extend AWT or Swing. What you are doing is not a small task. You obviously have a lot of work left, but it is definitely a fantastic start!

Well, only thing I did I uncommented already existing lines in JoglfAnimator.java which ensure that setRenderingThread(…) called maximum once per drawable. Calling setRenderingThread(…) second time on Windows causes exception to be thrown, while on X and MacOS this is overriden and work different way. I think I should file an issue regarding this [will do].

If you are still interested in patch, here it is:

11c11
<     //private boolean[] threadSet = new boolean[0];
---
>     private boolean[] threadSet = new boolean[0];
24c24
<             //boolean[] threadSet = new boolean[this.threadSet.length + 1];
---
>             boolean[] threadSet = new boolean[this.threadSet.length + 1];
26c26
<             //System.arraycopy(this.threadSet, 0, threadSet, 0, this.threadSet.length);
---
>             System.arraycopy(this.threadSet, 0, threadSet, 0, this.threadSet.length);
28c28
<             //threadSet[this.threadSet.length] = false;
---
>             threadSet[this.threadSet.length] = false;
38c38
<             //this.threadSet = threadSet;
---
>             this.threadSet = threadSet;
74c74
<                                 //if(!threadSet[iter]) {
---
>                                 if(!threadSet[iter]) {
78,79c78,79
<                                     //threadSet[iter] = true;
<                                 //}
---
>                                     threadSet[iter] = true;
>                                 }
84a85,88
>                     } catch(InvocationTargetException err1) {
>                         err1.printStackTrace();
>                         System.err.println("InvocationTargetException details:");
>                         err1.getTargetException().printStackTrace();

Only JoglfAnimator.java changed.

Yuri

Issue submitted as Issue #47.

Note also that I am using the latest JOGL from CVS with some minor patches (which I don’t think affect behavior of JogLF).

Yuri

That must be it, I use the milestone build where these lines didn’t help so I commented them. I tried to build from CVS but it won’t build on Mandrake due to the different location of X and then failed on other things when I got over that part.
Anyway I never got it to run on Windows so its great to know that this can be done. According to the problems I’m having here I won’t get back to you tonight with the answer (anyone knows about javax.comm :wink: but I’ll try anyhow or tommorow morning before work.

Yuri, from looking at the code it seems to be a race condition try replacing the code in JoglfTabbedPaneUI


    void updateRectangles(JTabbedPane tabs) {
        for(int iter = 0 ; iter < tabs.getTabCount() ; iter++) {
            delegates[iter].setBounds(tabs.getBoundsAt(iter));
        }
    }

With:


    void updateRectangles(JTabbedPane tabs) {
        for(int iter = 0 ; iter < delegates.length ; iter++) {
            delegates[iter].setBounds(tabs.getBoundsAt(iter));
        }
    }

Syrusm,
yes there is a lot of work. The main question is should I do it?

I won’t do it if there isn’t any interest in the community for such an undertaking. So this is the main purpose of this thread IMO, if people will speak up and start using this then I’d be happy to spend some more work on this and getting this to work properly which I think is possible. I will obviously need some help from JOGL/OpenGL gurus and probably some fixes to Jogl itself.

So anyway people who are interested, speak up, download the source code and start contributing like Yuri :wink:

Thanks vprise,

I’ll check the fix tomorrow.

BTW, there is at least one more effort on Swing <-> JOGL interaction implemented as part of Xith3D API (www.xith.org). It has an overlay system which allows displaying Swing components inside 3D world. Maybe this will also be interesting for you.

Yuri

[quote]Syrusm,
yes there is a lot of work. The main question is should I do it?

I won’t do it if there isn’t any interest in the community for such an undertaking. So this is the main purpose of this thread IMO, if people will speak up and start using this then I’d be happy to spend some more work on this and getting this to work properly which I think is possible. I will obviously need some help from JOGL/OpenGL gurus and probably some fixes to Jogl itself.
[/quote]
Well, I’m definitely excited by this - a working OGL LaF would be perfect for demonstrating to the world

[] that Swing is actually (despite all it’s faults) a very powerful GUI building system
[
] that OGL on java has arrived, and “effortlessly” does some very useful and cool things.

NB the second point is assuming this ever gets to a stable point :). But the key point is that it shows in one fell swoop how “the world changes” with the existence (and mainstream support of) JOGL - seamless integration of OGL with Java’s core libs, utilizing some very high-level concepts (LAF) with a very low-level lib (OGL) that java has historically not had.

Personally, if this could be packaged into something that was quite easy to make custom 3D widgets with, whilst knowing only

[] The intricacies of Swing (e.g. how to develop with JButton etc)
[
] How to do basic stuff with OGL

then I’d start using it very rapidly; I’d port my custom (HTML-inspired) layout system back into a Swing LayoutManager for a start (within games, there’s little point being swing compatible at the moment given that you tend to want to remove EVERY piece of Swing rendering cos it’s ugly ;), and you have to cope with lots of subtle pitfalls in the Swing rendering systems).

Finally, if you want to guage interest…you should post in the J2D forum here. I’d guess that many people using Swing (hence interested in new LAF’s) probably don’t use JOGL at the moment, and vice versa.

As I am sure you know, there are numerous OpenGL based APIs (written in C/C++) that try to replicate the functionalities of APIs such as MFC in a 3D context.

As far as games go, many use 3D GUIs. For example, both WarcraftIII and QuakeIII launch in a 3D window to display their main menu. The HUD of an RTS game is practically a fully functional GUI. There is no question that every game needs GUI, and if there is a stable build of JogLF, it will probably be popular.

I hope more people see your post so that you can get more feedback.

Yuri,
I couldn’t find any information of the Swing effort within Xith3D?
I saw screenshots of games with Swing widgets floating in mid air and I am curious about how this was done specifically.
BTW did my suggestion solve the problem?

blahblahblahh,
Swing has faults? Didn’t notice :wink:

I don’t just need to gauge interest, if I posted to the JavaLobby I bet I would get quite a bit of wow’s etc… from people who won’t be able to help. Right now there are some technical problems and features I cannot (don’t have time to) implement since they may need fixes in Jogl. I’m sure a lot of the things I did are incorrect so I’m not looking for interested parties but interested parties in this forum (Xith3D forum would probably be good as well)!

Syrusm,
I don’t play games so I have no idea about warcraft etc…
Its a problem of a former addict, I get addicted to any game even minesweeper and Solitaire are a potential danger :wink:
Anyway I used to write games (the simulation side not the graphics) 6-7 years back and the guy that did the menuing systems for us had to work a couple of years to create the really simple menus!

Overall I just wrote it because its cool and its a cool demo, but I don’t have all that much time to maintain this (and to study the innards of Jogl) so I will need help to turn this into something thats at a level I can put on java.net or sourceforge (and show to the JavaLobby crowd). So far there were hardly any downloads of this even for such a small community, so if you know another Jogl hacker that might be interested…

Hi,

[quote]BTW did my suggestion solve the problem?
[/quote]
Partially. I still do not see the tabs in the upper-left corner [as shown on your screenshot], but if I click that area the tabs are switching with nice vertical scroll transition. Is it what I should get [I guess yes].

[quote]I couldn’t find any information of the Swing effort within Xith3D?
[/quote]
I know… Really lack of docs on Xith3D… but this is in progress.

[quote]I saw screenshots of games with Swing widgets floating in mid air and I am curious about how this was done specifically.
[/quote]
This is done as overlay system. Xith3D goes different way - overlay system provides special UIWindow class that allows Swing components to be rendered to texture, so you can embed Swing GUI elements in your “legacy” JOGL-based application [this is in very short words]. You can check “GUI Committed” thread in Xith3D forum [http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1065241333] for more details, as well as JavaWebStart-based demos Xith3DGuiTest and Xith3DTerrainTest on Xith3D Demos page at http://www.xith.org/demo/com.xith3d.test.php.

Yuri

[quote]Hi,

Partially. I still do not see the tabs in the upper-left corner [as shown on your screenshot], but if I click that area the tabs are switching with nice vertical scroll transition. Is it what I should get [I guess yes].
[/quote]
Yes this is what I was talking about, I had this problem also it stems from some hacks I did based on the basic look and feel. The right thing to do is to dump any dependancy on that and move to a clean structure and then it won’t depend on whether the basic look and feel initialized the internal structure I depend on. I’ll try to look for a workaround when I get the chance.

I don’t necessary need a doc link but a guy to help with all of these issues that I don’t necessarily know about since I was not involved in much of the earlier discussion and have absolutely no OpenGL background. The question is if we start off and pick a new project to do this, will there be participation and help or will I just write this huge complex thing that no one will use (and probably won’t work since I won’t get the technical help I need).

It seems that what these guys did (wrapping onto a texture) is pretty much what I did. This is not a good solution. It works for simple things (table/tree/list cells etc…) but it will not work well in larger elements. The demo looks cool but if you try to run a real application or even make serious changes to the demo things break in amusin/annoying ways.

[quote]This is done as overlay system. Xith3D goes different way - overlay system provides special UIWindow class that allows Swing components to be rendered to texture, so you can embed Swing GUI elements in your “legacy” JOGL-based application [this is in very short words]. You can check “GUI Committed” thread in Xith3D forum
[/quote]
This is very similar to what I did… Too bad I didn’t look deeper into Xith3D it seems cool, anyway I need to think of a direction to take the code and maybe basing it on top of Xith3D is a good idea.

So are there people in the Xith3D project who will be interested in this? Should I (or you) post to that forum as well or do they scan this one?

The UI system implemented in Xith3D is completely different than you did. It’s primary goal is to embed small pieces of Swing UI into apps where 3D rendering is primary visualization mechanism.

Your code acts vice versa - adding 3D capanilities to apps that basically start as 2D [hopefully I am right].

For me, implementation of JOGL-based L&F means a way how to re-use Swing UI experience of Java developers, which is valuable.

I don’t see UI system in Xith3D competing to L&F because of different purposes, but I also believe that both projects can benefit from each other.

Xith3D is a scenegraph-based API, and Swing/AWT UI is also something like scenegraph, so I see a lot of similarities and [of course] a lot of differences.

[quote]So are there people in the Xith3D project who will be interested in this? Should I (or you) post to that forum as well or do they scan this one?
[/quote]
I KNOW they are scanning this one, too [OK, at least me :)].

Yuri

[quote]I don’t see UI system in Xith3D competing to L&F because of different purposes, but I also believe that both projects can benefit from each other.

Xith3D is a scenegraph-based API, and Swing/AWT UI is also something like scenegraph, so I see a lot of similarities and [of course] a lot of differences.
[/quote]
That was what I meant in general :smiley:
I’d generally like to reuse as much common code as possible and not reinvent bugs and maintainance issues…

[quote]I KNOW they are scanning this one, too [OK, at least me :)].
[/quote]
OK, then why aren’t they speaking up?
I sent a message to David from that thread and I hope he will join this discussion.

I think it should be pretty easy to customize JogLF to allow integration with JOGL/Xith3D however right now to make elements “look good” I’m working in glOrtho mode otherwise the coordinate translation etc… is a bit complicated. I think this can be done without glOrtho but as I said I am no OpenGL expert and calculating the coordinates in everything got really complicated at some point.

If this issue can be solved then it should be pretty easy to integrate Swing and JOGL/Xith3D code without a performance penalty (all my rendering is done through Swing events so as long as the user does nothing with the Swing components the Swing thread is idle).

Hi Yuri,
I took a deeper look at the code and it seems like a race condition that I’m just not clear about, however this code should probably fix it regardless:


    void updateRectangles(JTabbedPane tabs) {
        if(delegates.length != tabs.getTabCount()) {
             setDelegates(tabs);
        }
        
       for(int iter = 0 ; iter < tabs.getTabCount() ; iter++) {
            delegates[iter].setBounds(tabs.getBoundsAt(iter));
       }
    }

So with this you should probably be able to see tabs.