Use LWJGL and Graphics2D

Started by floyd82, September 24, 2011, 11:07:09

Previous topic - Next topic

floyd82

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

princec

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 :)

floyd82

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)...

Chuck

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.