Does LWJGL-Applet require AWTGLCanvas?

Started by elias4444, July 29, 2009, 19:44:40

Previous topic - Next topic

elias4444

Just wondering...

I can get ALMOST everything working just fine in my engine by using Display.setParent(Canvas) - notice, I use a Canvas object, and not AWTGLCanvas. However, I don't get any keyboard input.

In order to get input and whatnot, do I need to use AWTGLCanvas? I only ask because I'm getting some weird errors if I switch over, but if I have to, I'll push ahead with it.

Thanks.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

nope you don't need AWTGLCanvas, when using Display.setParent() Input works just as it would on a native display.

Be sure the Canvas/Display is getting focus.

elias4444

Hmmm... what else can I do to make sure the applet is getting focus? I've tried clicking on it numerous times.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

hmm, clicking should really give you focus.

which browser and os are you using?

elias4444

I've tried it on both Firefox 3.5 and Safari 4 on Mac OS X.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

could possibly be a bug on mac, does minecraft work for you?

keyboard input that is?

http://www.minecraft.net

elias4444

Hmmm... looking like a bug. I had mouse control, but no keyboard with Minecraft. It got a little tricky to get out of the game since I couldn't press ESC to release the mouse.  :P
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

its really odd that keyboard input should be broken on mac's, but to honest not much testing has gone into lwjgl applets + mac since the applet setParent stuff is relatively new and not tested too much on mac due to mac's being rare.

I've done some digging to see if other mac users suffer from the same problem and came across this thread on the minecraft forums

http://minecraftforum.net/viewtopic.php?id=960

apparently according to that thread the new update of Java has fixed the problem.

Any more info you can give regarding the problem? what type of mac do you have? and which version of Java do you use?

remember keyboard input will only get captured if the applet is getting focus, so could be that the applet is not getting focus for some reason, you could do some testing to see if clicking is actually give the Display focus, check this with Display.isActive() and parentCanvas.hasFocus();

thx

elias4444

Well, I'm on a Mac Pro, and I've setup the latest Java version (Java 6 64-bit) to load for Applets first from the Java Preferences. I also tried loading Minecraft on my Macbook Pro, but only get a black applet screen (in both Firefox and Safari).
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

I wrote a quick and dirty applet to test which version of Java the browser is actually using. Turns out, both machines are still using Java 5 (even though Java 6 has been bumped to the top of the preference order). Not sure what else can be done about that though.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

Looks like this guy knows the answer:

http://www.nobel-joergensen.com/roller/java/entry/java_6_applets_is_coming

Guess this means that Mac users once again have to wait (either that, or we need to get LWJGL applets working for Java 1.5 on the Mac).


=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

... Ok ...

I've been poking around through the AppletLoader code, and I noticed that the switchApplet() method starts the lwjglApplet in the current thread. Now, I'm no expert, so I'm probably just misunderstanding the code, but I've noticed with my own attempts that when I try to launch a Display from within a swing or AWT object, the keyboard never works (sound familiar?). In order to allow LWJGL to the Keyboard, I have to launch the openGL rendering class in a different thread. I'm not sure if this is a Mac only issue, but it sure sounds close to what we're seeing here.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

Its unlikely to be a lwjgl appletloader issue, since once its completes its job it passes over control to the applet it has just downloaded and disables itself. Its mostly likely to do with how Display.setParent() works, so your looking at the MacOSXDisplay class and other MacOSX* classes in the org.lwjgl.opengl.* package.

Quote from: javalwjgl on July 30, 2009, 18:05:42
remember keyboard input will only get captured if the applet is getting focus, so could be that the applet is not getting focus for some reason, you could do some testing to see if clicking is actually give the Display focus, check this with Display.isActive() and parentCanvas.hasFocus();

any luck with testing the above quoted parts with your lwjgl applet?

elias4444

Quoteany luck with testing the above quoted parts with your lwjgl applet?
None.  :(

I check for both methods. In my appletviewer (launched from Eclipse), I can gain focus by clicking on it, no problem.
In both Safari and Firefox however, I can't get focus by any means known to my pitiful brain.  ::)

On the Windows side, in Firefox, by clicking in the applet the Display becomes active, but the Canvas.hasFocus() still return as false.

Check it out:

http://www.tommytwisters.com/games/rollemdice/test/applet.html

Press the spacebar to role the dice (so long as you have focus, and you're not on a Mac).
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com