Does LWJGL-Applet require AWTGLCanvas?

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

Previous topic - Next topic

kappa

ok great, so at least we know now that the keyboard fails due to focus not being available. So the bug is that the Display is not getting focus when it is clicked.

We had the same/similar issue with Linux and Keyboard input with lwjgl applets a while back but since we can test it easily (i use Linux) we were able to fix it (see last patch to LinuxDisplay).

Display.setParent() essentially just slaps a native Display on top of a canvas, so when you click the Display it knows that it has focus and grabs the keyboard. So as you have observed Canvas.hasFocus() is under the Display and doesn't get focus, if the Canvas does get focus it transfers it too the Display hence loosing focus itself (since only one thing can get focus at a time, either the Canvas or the Display).

Now I'm guessing that this is a similar bug to the one on linux, focus was being lost as soon as Display was clicked.

Next we need to know if Display ever gets focus, if you can output a

System.out.println("DISPLAY HAS FOCUS : " + Display.isActive() + " Canvas has Focus " + canvas.hasFocus());

every frame, then click the applet and check console if the Display ever returns true? (even if its only for 1 frame)

this'll hopefully narrow down the things that might be going wrong.

p.s. your applets works very nicely here on linux including keyboard input.

elias4444

Well, I tried it. Here's the output from my applet:

==========================================
Attempting to Initialize Graphics Mode
==========================================
fullscreen: Applet Mode
resolution: 800 x 600
colordepth: 32bpp
AAmode: x4
==========================================

Compiling: com/tommyengine/shaders/examples/shadowspotppl.vert ... 0 errors detected
Compiling: com/tommyengine/shaders/examples/shadowspotppl.frag ... 0 errors detected
* Epsilon: 1
* ShadowMap: 0
* shadowsActive: 6
* baseTexture: 8
* Accessibility: 2
* baseTextureActive: 7
* isSpotLight: 5
* normalMap: 4
* normalMapActive: 2
* vTangent: 1
==========================================
Texture System Enabled...
Max Texture Size: 4096
==========================================

Throwing Dice
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
Shadow Map FBO successfully created
Object Compiled. Faces: 108 Frames: 1
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
DISPLAY HAS FOCUS: false      CANVAS HAS FOCUS: false
etc...


Doesn't look like the Display or Canvas ever has focus.  ???
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

hmm, looks like it's a slightly different problem then, does clicking make a difference? (i.e. give focus for 1 frame)

elias4444

HA!!!! FOUND IT!!!!!!

The Applet object has to exist in my looping object! Currently, I have the Applet create a "scene" object, which runs the loop and updates the display (which is linked to the Canvas via a "screen" object). For some reason, as soon as I passed the Applet object into the scene object (by simply making it a variable in the scenes constructor), I could click for focus!!!

I'm not sure I understand the nuances of that, but it works!  ;D
Found that totally by chance too!

Now if I can just get it to shutdown properly :P

Thanks for the help. Sorry if I stirred up trouble again.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

elias4444

BTW, I still have the problem with the Minecraft.net applet... so you may want to fix that.  ;)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

kappa

k, i'll point this thread out to Markus next time I see him online :)

btw do keyboard controls for slick2d applets work for you? example like this game

elias4444

They do actually! Guess we should have tried those before!  :P
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com