JNLP and CPU usage issues

Started by elias4444, December 06, 2004, 11:46:26

Previous topic - Next topic

elias4444

Well, I've packed up a couple of my games in JNLPs, and at first thought all was just perfect. However, while my first game, which is not frame-rate dependant, runs fine, the second, which IS frame-rate dependant, ran very slow. I did some testing to discover that when I run them via a JNLP, the CPU ramps up to near 100%. The odd thing is though, that when I run them via a batch file, the CPU utilization is only around 20% and the game runs smooth as silk.

Anyone else ever see this problem? I've coded everything in Java 5.0 (1.5). I also made sure to use the exact same JARs for running the batch file as I did the JNLP. Is there a trick to this or something?

Also, on a side note, I like using JNLP to distribute my games that use lwjgl - it makes it much simpler. I noticed however, that many games (like AlienFlux) use a binary executable to launch the game. How do you do that?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

I have no idea why your games are suddenly using 100% CPU when launched via webstart - it's not normal.

As for launching via an exe - well, that's a simple JNI application that creates a Java VM, loads the game main class and executes main() on it. Dead easy to do. I'm going to root for Webstart again though for a bit. The exe is a last-ditch resort now.

Cas :)

elias

This is a long shot, but try adding this inside your <resources>:
<property name="sun.java2d.noddraw" value="true"/>


It should make sure that there's no ugly DirectX<->OpenGL interactions when AWT is used (by JWS). You could also try firing up a separate AWT window from the batch run to see if that makes a difference.

- elias

Anonymous

Unfortunately, that wasn't it. HOWEVER, you clued me into something else:

I'm setting sun.java2d.opengl and sun.java2d.translaccel both to true. Once I disabled those, I get the exact same high utilization issues from the command line like I do in JNLP.

So, does JNLP not allow those to be set for some reason? Can I override it somehow and set them anyway? I'll try out the property setting in the jnlp file and let you know.

elias4444

It looks like it's specifically the sun.java2d.opengl property. I can embed it into the program with the system.setproperty command, but jnlp won't recognize it. I also tried the "property name=" option in the JNLP, but it still won't enable it.

Any ideas? I could turn it off I suppose, but then I'd lose all of my acceleration in my game (since I'm using java2D with translucent images for sprites -- I'm using lwjgl for my sound only since I'm not an opengl guy).
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias

I'm afraid the only "safe" properties not ignored by Web Start 1.5 (previous version only recognized the heap size arg) are those listed in:

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html

and those you use are not listed.

- elias

princec

That's incorrect. All system properties are recognised by Webstart. What aren't recognised are VM parameters (-X).

The problem is that Webstart itself may be causing the problem with its own GUI.

Cas :)

elias4444

Ugh. Well, I've got issues then.  :(

So, I guess here are my options:
1) Convert all my image assets to gif or transparent-only png, severly lowering image quality in the game.
2) Run the game via a command line/batch process (is there a windows-batch method I could use rather than a .bat file?) - although I'm still a bit curious as to how well supported the sun.java2d.opengl setting is.
3) Learn OpenGL and hit the programming block as hard as I can (just frustrating because I was so close to finishing I thought). I'm really quite clueless as to how to do graphics in OpenGL.

Any opinions on the best direction? (Or other options that I'm not thinking of?)

Any help would be appreciated.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

Do it with OpenGL. It's surprisingly easy. Just be aware that if you've got an AWT widgets or Swing that you won't really be able to use them any more...

Cas :)

elias4444

I actually ended up using only java2D calls and made all of my menus and things "in-game," so, theoretically, it should be an easy port. I'm studying the SpaceInvaders104 code right now from the lwjgl site.

I figured that if I really wanted to get serious about game development, I'd have to go there someday anyway. I'm just a complete n00b though. It even took me a while to implement lwjgl for sound, and I'm still not sure I understand all the buffer and initialization stuff. Nice thing about Java though, once you finish building a good framework, you don't have to worry about it anymore unless it's got bugs. I just hope I get it right the first time.  :?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

"Alms... alms for the poor..."

Ok, believe it or not, I have a VERY simple port of my game going on OpenGL now (this is a big deal for me actually). I have two issues though:

1) I'm using the textureloader class from the SpaceInvaders source code. I'm not very excited about taking someone else's code. Is this ok?

2) None of my sprites are transparent anymore (they all have a black opaque box behind them). Is there a way to turn on translucency in OpenGL? (Come on, there's gotta be, right?)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

Ok, for the transparency, I had to add these to my initializer:

GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);

I can't believe it! I'm actually programming in OpenGL!  :P

But I am still concerned about using the textureloader from the spaceinvaders demo. Anyone see any license or anything for that code?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

nihon-jin

Quote from: "elias4444"But I am still concerned about using the textureloader from the spaceinvaders demo. Anyone see any license or anything for that code?
it's in the header of java source :roll: (same license as lwjlg)

princec

Texture loading code is so mind-bogglingly trivial it would be quite banal to actually enforce any kind of license on it anyway!

Cas :)

elias4444

Well, thank you guys SO much! I can't believe I'm actually doing stuff in OpenGL now!!!! I never thought it was possible. (BIG thanks to everyone who's worked on lwjgl!)

Now I'm off to experiment with lighting.  :wink:

Also, on a last note: anyway to change the window icon in the top left of the window when not in fullscreen mode? It's not as important, but would certainly be nice.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com