Best way to do a "overlay" (scores, info

Im working on my new game using Xith and Im wondering what the best way to make the game “overlay” is. Info such as scores, who’s turn it is, etc.

Im currently messing with the Swing functions. Is that the best way? Im have some issues with the Swing functions rendering kind of weird, especially text (hard to read).

Basically looking for the best way to put 2D graphics and text on top of my game, that is not affected by the 3D transformations.

Thanks!

Theres a complete UIOverlay/UIWindow package in Xith, is that what you’re playing with?

It allows you to “insert” swing windows as textures into the scene.

Kev

[quote]Im have some issues with the Swing functions rendering kind of weird, especially text (hard to read).
[/quote]
Does Xith3DGuiTest work OK in your case?

Yuri

Jens has a good tutorial on the topic as well:

http://xith.org/tutes/GettingStarted/html/integrating_swing.html

Will.

Yes, when I reference Swing I was referring to the UIOverlay/UIWindow and my code is based on the GSG tutorial.

Yuri brings up a good point. The Xith3DGuiTest demo does and has always worked fine for me. The text looks very crisp. I’ll do some further research to find out why my text is looking like its missing pixels.

My code was originally based on the GSG tutorial, I will check Xith3DGuiTest to see if I had anything wrong.

Thanks for the responses so far! Sounds like the UIOverlay/UIWindow is the way to go for my overlay?

Yep. Go for UIWindow. I was inspired by this thread and added Swing to my simple 3d world. I love it! Especially the part that you can set your Swing components to be translucent and see the 3d-World behind it :wink:

Take the example Jens created before and modify it a bit.

Disable the panel’s opaqueness

panel.setOpaque(false);

Set the textfield’s background to white but use alpha settings (50% here):

textfield.setBackground(new Color(1f,1f,1f,.5f);

And to make it work without showing that nasty window’s background around your textfield do not forget to enable alphablending for your TestWindow:

super(width, height, false, true)

Just one last note: add some 3D scenery - that will do it ::slight_smile:

thanks for that! ;D

Maybe Jens should add some of that info to his tute.

Will.

Ok, I got a chance to look and I’ve been messing with my code for a while. I started using the XithGuiTest code and it was working perfectly, but then, it started showing the same “artifacting” that I had with my own code. I traced the problem to an issue when I set the Width of the panel.

If I keep the width at 100, which is what they are using the demo, it looks great. If set the width to say, 150, it starts to look skewed. I have prepared an image that shows what Im talking about.

Here is some code just showing what “width” Im talking about…


...
            JPanel p = new JPanel();
            p.setDoubleBuffered(true);
            p.setSize(new Dimension(width,height));
...

Thanks for your help!

Here is the image showing the problem:

http://www.fightcompany.com/sputter/swing_gui_issue.jpg

@SpuTTer: That is quite strange. I experienced such behaviour in Swing with outdated Java-versions only … For me it does not depend upon width even with the string you are using… Which OS, Java version and font are you using? My configuration is Windows 2000, Java 1.4.2_03 and default font.
Did you tested this with a simple Java-Swing-App without using xith also? Are you usiong absolute positioning or a LayoutManager?

@William Denniss:
Regarding the input field (and thinking of additions to Jens’ tutorial) we also do need some text regarding editable textfields! This is because a key listener added to the canvas (used for navigation as e.g. in JCD’s demos) will be influenced by key input for the textfield also - just because of the UIEventAdapter. Same goes for mouse listeners.

Otherwise we would edit text and move around - btw. nice effect :wink:

Im on Windows XP, 1.4.2-b28. Im using the default font, but I’ve tried Serif size 12 also.

Im using the default layout right now but I also tried it with BoxLayout and got the same result.

My last ditch thought was to re-create a simple Swing app and see if it does the same thing.

Maybe I’ll try that tonight. Hopefully I can track this down.

Using 1.4.2_03-b02 here - currently 1.4.2_04 is out. Your version is a bit dusty I believe. Though it is not that old installing a newer JDK may be a quick solution as I found some problems in Sun’s bugparade that do not exactly match your problem but are somewhat related to it known for at least 1.4.x: 4866495 (Fonts of some Components look worse in 1.4.2 vs 1.4.1), 4840307, (TextField characters unreadable),
4924220 ( Microsoft Sans Serif (True Type) font is not rendered properly). I neither can guarantee that I found your bug nor that the latest version will help but I would give it a try also …

I will install 1.4.2_04 tonight and hopefully that’ll clear things up, pun intended!

Thanks for your time. I’ll let you know how it works out.

I finally figured this out… this strange occourance only happens in windowed mode. If I set my canvas to full screen, the text looks fine… Is this a bug?

A quick change from



//CanvasPeer cp = rp.makeCanvas(null, 800, 600, 16, false);

CanvasPeer cp = rp.makeCanvas(null, 800, 600, 16, true);


and the text is perfectly clear.