LWJGL with Sound and the overall Performance

Good Morning, ;D

as i played around with the LWJGL lib, i regonized
that there are some problems with the priority.

As example, i converted the Lesson 36 from Nehe Tutorials # 36 (Render to Texture). So far so good.
If i running the standart Winamp in the background
the whole sound plackback is f*** up. Often Winamp stops the Playback complete while the demo runs. :-/

There were several Therads running how to make a framerate control, but i think this will not fix that problem when the frame rate were limited to eg. 60 FPS!
As Alienfluxx (Demoversion) runs fine on my maschine, i am looking for the reason of that problem.

Thx

  • Jens

So, your application is hogging all the cpu, yes?

You have two choices:
1 - Limit framerate (just cap to 10 FPS) - add a Thread.sleep(100) between each pass, it’ll be slow as hell, but show you if the problem still exists.

2 - call setProcessPriority to set your applications thread priority to something lower than winamp’s decoder thread -
Sys.setProcessPriority(Sys.LOW_PRIORITY);

hmmm, 8)

the Winamp was just a example…
If i like to play sound via Java the setProcessPriority
could be the one call make all better.

But sleep or yield or waht ever could not be the right solution for any performance/fps problem.
If the CPU takes 100% perfomance it is good when running in Fullscreenmode , but in Windowed mode there must somthing like a FPS contol.

Did you gave the LWJGL lib for default such a high Priority ?

  • Jens

[quote] Did you gave the LWJGL lib for default such a high Priority?
[/quote]
Yes, this is a game library…

[quote] If the CPU takes 100% perfomance it is good when running in Fullscreenmode , but in Windowed mode there must somthing like a FPS contol.
[/quote]
No. If you feel that your application should NOT hog the CPU then this is your responsibility. This is not something that should be decided by the library.

Try running Quake or the likes in windowed mode…

If I were making minesweeper with LWJGL, I would most likely do it in windowed mode, and cap framerate at 30 or so. Even better I would probably not have any framerate what so ever - I’d just paint when isDirty is true…

Quake 2 and 3 both run very well in windowed mode. They even release the mouse when the console is down. :wink:

For sure that the CPU must do the Work in FullscreenMode, but in Windowed Mode with a bit more
CPU intensiv there should be something like FPS Control !
What about the other OS ? If i set the priotity to a lower level, how it is done on eg. Linux Systems ?

Bye the Way, why is there a Class DisplayMode in LWJGL ? Im confusing about this, you should rename it,
cause i dont like code with full classnames to keep the overview of the Source…nobody writes code like this:

java.lang.String string = lwjgl.String.getString();
  • Jens

[quote]Quake 2 and 3 both run very well in windowed mode. They even release the mouse when the console is down. :wink:
[/quote]
Yeah, but the point being that they don’t cap framerate just because it’s in windowed mode!

[quote]For sure that the CPU must do the Work in FullscreenMode, but in Windowed Mode with a bit more
CPU intensiv there should be something like FPS Control !
[/quote]
Sure, but YOU should add it to your game - not LWJGL.

[quote] What about the other OS ? If i set the priotity to a lower level, how it is done on eg. Linux Systems ?
[/quote]
same as in windows… You just set the priority of the application - and the OS scheduler takes care of the rest.

[quote] Bye the Way, why is there a Class DisplayMode in LWJGL ? Im confusing about this, you should rename it,
cause i dont like code with full classnames to keep the overview of the Source
[/quote]
org.lwjgl.DisplayMode ?

Jep,

org.lwjgl.DisplayMode !

import org.lwjgl.DisplayMode; should do the trick ???

if java.awt.DisplayMode is your concern, just don’t import java.awt.*; it’s a bad habit anyway - which results in exactly these problems…

You are not understand what i try to say …

Why there are the DisplayMode in org.lwjgl ?
You also could use the normal class avaible in
java.awt package!

Is there any other DisplayMode given back as using
GraphicDevice class via getDisplayModes() Method ?

Sorry 4 all these supid Questions ;D

  • Jens

[quote]You also could use the normal class avaible in
java.awt package!
[/quote]
Oh no we couldn’t! We have no dependency on the AWT packages at all. LWJGL is designed to operate without any AWT.

Cas :slight_smile:

Then you should rename the class.

  • Jens

nah

Mac_Systems:

You forget that this is one of the main things packages are used for. By providing a name space two classes of the same name can exist and exist happily. Look at Vector… there are tons of Vector going around (java.util.Vector, lwjgl’s Vector, I have my own Vector, etc).

namespaces are a feature.

hmmm.

maybe, but for me it it bad Code Design!
Java Newbies will confuse this :o

If for example you work with XML there are serveral
Document Objects from Xerces to JDOM, if you have to convert one Document Object into the other the code
looks like sh**. Somebody else reading this will ask itself
“hey what da heck he is doing there ?”

But ok, i will stop this stuipd questions now!

  • Jens

Personally, I don’t mind duplicate class names at all when they’re used in different areas. The exception is when naming classes as the same as any in the java.lang package. That’s a big no-no.

Like org.lwjgl.Math or org.lwjgl.System. :wink:

Do you mean org.lwjgl.Sys? :stuck_out_tongue:

And org.lwjgl.Math appears to have been culled from the next release, as well! :wink:

@Mac_Systems, re: DisplayMode: It’s very, as in highly unlikely that you’d ever have java.awt.DisplayMode and org.lwjgl.DisplayMode in the same application, let alone the same source file. I wouldn’t worry about it, you’ll get used to it.

Oh, it’s Sys? Sorry, I was just trolling a bit. :wink:

LWJGL really is a great piece of work though, to be serious. :slight_smile: