LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: floyd82 on September 24, 2011, 11:07:09

Title: Use LWJGL and Graphics2D
Post by: floyd82 on September 24, 2011, 11:07:09
Hi,

I'm currently developing a game inside a JFrame with java.awt.Canvas and heavy use of java2d (Graphics2D).
But now I find that the swing mouse and keyboard functions are insufficient for my purposes, because it is event based and I want to use polling. Can I use the LWJGL Mouse and Keyboard functions together with my JFrame and java.awt.Canvas?

I already tried using it but got "Display must be created." errors. It seems that I must have a LWJGL display to use the mouse and keyboard. I also found Display.setParent() and AWTGLCanvas, but I can't get it running...

Is it possible to use LWJGL and Graphics2D together?

Thank you very much in advance!
Stefan
Title: Re: Use LWJGL and Graphics2D
Post by: princec on September 24, 2011, 21:32:02
You could just use Jinput. Or really, as you're using AWT anyway, you should find that the event-based system is no more or less effective than polling.

Cas :)
Title: Re: Use LWJGL and Graphics2D
Post by: floyd82 on September 24, 2011, 22:53:12
Thanks for your answer!
I'll take a look at jinput...

I had the assumption, that the event based input handling is slower because of a lot of locking to get it thread safe via synchronized {}... With polling no synchronization is necessary and therefor faster (as said, only an assumption)...
Title: Re: Use LWJGL and Graphics2D
Post by: Chuck on September 25, 2011, 18:17:55
LWJGL's polling is synchronized too, but the locks disappear in a single-threaded app (which any swing app is unlikely to be).  I think you'll find just about anything is faster than AWT's input handling though, so JInput should be way more than fast enough.