[FIXED] Mac OS Java Update 2 ( 1.6.0_20) breaks LWJGL applets

Started by ShawnKendall, May 19, 2010, 03:40:50

Previous topic - Next topic

bobjob

How to use:

create the custom canvas
canvas = new ResizableCanvas();



init the canvas after Display.create();
Display.create(); 
canvas.init();


make sure to call doMacFix after update
Display.update();
canvas.doMacFix();


also to prevent any errors, make sure to call destroy before Display.destroy();
canvas.destroy();
Display.destroy();

optionally: to check if the fix is needed. you could also use this to force a Display window, instead of an applet.
canvas.requireMacFix();


The other methods included I use in order to handle my applet on resize.


Some problems:
* You will notice alot of stuff ups when the applet tries to grab the mouse, do this by pressing the esc key on the main menu, or seletecting the close menu button.
* In safari mouse movements only seem to regester if mouse key is down.

Edit: And can someone pleeeeease tell me a accurate way to determine which plugin version is running, thanx.

kappa

oh, really cool stuff, if you manage to find a fix/workaround for this problem then your a genius :)

Quote from: bobjob on September 19, 2010, 07:58:17
Edit: And can someone pleeeeease tell me a accurate way to determine which plugin version is running, thanx.

I haven't got a mac so not really got anyway to try this, but I am aware that the DeployJava.js has a method that can detect through javascript if plugin2 is running 'isPlugin2()'. Human readable version of the script is found here. Hopefully this'll allow you to find a java method to detect plugin2.

bobjob

Quote from: kappa on September 19, 2010, 09:28:23
oh, really cool stuff, if you manage to find a fix/workaround for this problem then your a genius :)
This isnt a long term viable solution as it has a incredible slow frame rate, but displaying something is infinetly more than nothing.

Quote
I haven't got a mac so not really got anyway to try this, but I am aware that the DeployJava.js has a method that can detect through javascript if plugin2 is running 'isPlugin2()'. Human readable version of the script is found here. Hopefully this'll allow you to find a java method to detect plugin2.
I will look into it, I might print out the complete list of properties in both versions and see if i can find some useful variations.

Also keyboard seems to be working fine.
So If anyone only uses keyboard in there applets, in that instance this fix should be enough.

bobjob

Some other strange behaviour that I cant seem to fix, Safari Mouse events seem to work fine if the java console (???) has focus.

kappa

Quote from: bobjob on September 19, 2010, 09:44:25
This isnt a long term viable solution as it has a incredible slow frame rate, but displaying something is infinetly more than nothing.

Another thing you could do is just not use Display.setParent() if plugin2 is detected on mac, that way when the applet is run you'll just get a popup LWJGL window. Think that should workround the applet offscreen rendering thing and just work at normal speed.

bobjob

Quote from: kappa on September 19, 2010, 10:06:16
Another thing you could do is just not use Display.setParent() if plugin2 is detected on mac, that way when the applet is run you'll just get a popup LWJGL window. Think that should workround the applet offscreen rendering thing and just work at normal speed.
yeah thats definetly the best solution for performance.

bobjob

Ok for those interest I think the Property to find out if your running plugin2 on mac is "java.rmi.server.RMIClassLoaderSpi"

if the value is not null && contains plugin2, then it should be enough to detect that plugin2 is running

Property check applet: have2chat.net/fvf/prop_test.html


Edit:
Updated the source code.
- Safari.
sadly the Mouse functions normally only (aswell as setGrabbed()) as long as the java console has focus.
- Chrome
Mouse.setGrabbed(true) causes errors.

I Think I will leave it there. I'v done the most that I can without going through the LWJGL source code.
Now Im off to watch the first two episodes of Vampire Diaries season 2 JOY!

bobjob

one other thing I was thinking, with the new plugin its possible to use JNLP, for cache and such.
Is it possible to pass vm_arguments?

If so then would it be possible to pass an arguement not to render to an offscreen buffer?

if I dont get a response Ill look into it, will fiddle around on it tomorow night.

jouvieje

Quote from: kappa on September 19, 2010, 10:06:16
Another thing you could do is just not use Display.setParent() if plugin2 is detected on mac, that way when the applet is run you'll just get a popup LWJGL window. Think that should workround the applet offscreen rendering thing and just work at normal speed.

Quote from: bobjob on September 19, 2010, 10:39:30
Ok for those interest I think the Property to find out if your running plugin2 on mac is "java.rmi.server.RMIClassLoaderSpi"

if the value is not null && contains plugin2, then it should be enough to detect that plugin2 is running

Thanks for the suggestions :)
The detection see to be fine, I have "java.rmi.server.RMIClassLoaderSpi:: sun.plugin2.applet.JNLP2RMIClassLoaderSpi" with plugin2

I think I'll go this way if plugin2 takes too much time to be fixed (I don't think that Apple is very reactive).

bobjob

Hey guys I made a class that will run the canvas in a window if the new plugin is detected.
its attached to this post.

as before, test case: have2chat.net/fvf
Keys 1, 2 switch between display types

This will help you if you dont have access to a Mac, and would like to run LWJGL but cant debug it.

Usage:
instead of creating a new Canvas().
use:
rContainer = new ResizableContainer(false);
Canvas canvas = rContainer.getCanvas();

the boolean variable in the ResizableContainer constructor is if you will
be using resizable applets (set your applet size in percentage) then set it true.


setup your canvas as usual (as if it was to run in an applet) before attaching the display,
but instead of using Display.setPerant(...);
use:
rContainer.attachDisplay();


and once every game cycle call this method
rContainer.checkResize()

you may notice that checkResize() returns a boolean value, I use this to
reset the GL viewport if needed.
you probably wont need the return value if you dont use resizable applets.



Other useful methods.
in order to get the current width and height use:
Canvas canvas = rContainer.getCanvas();
if (canvas != null) {
   canvas.getWidth();
   canvas.getHeight();
}

if the canvas is "null" then you will need to get the current DisplayMode, as it means you are running in fullscreen mode.


to set canvas screen mode if possible:
rContainer.setFullscreen(null); //SWITCH BETWEEN FULLSCREEN / APPLET
rContainer.setWindow(); //SWITCH BETWEEN WINDOW / APPLET


*note that this wont be the final version, as soon as a opengl supported mac update is released so will this class.

kappa

This issue should now be fixed in latest nightly builds of LWJGL, see this thread for me info.